Skip to content

Commit

Permalink
Merge pull request #199 from Freika/feature/map-settings
Browse files Browse the repository at this point in the history
Map settings
  • Loading branch information
Freika authored Aug 28, 2024
2 parents d11cfd8 + fbc5eba commit 0cc5ac0
Show file tree
Hide file tree
Showing 15 changed files with 801 additions and 183 deletions.
2 changes: 1 addition & 1 deletion .app_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.1
0.12.2
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.12.2] — 2024-08-28

### Added

- `PATCH /api/v1/settings` endpoint to update user settings with swagger docs
- `GET /api/v1/settings` endpoint to get user settings with swagger docs
- Missing `page` and `per_page` query parameters to the `GET /api/v1/points` endpoint swagger docs

### Changed

- Map settings moved to the map itself and are available in the top right corner of the map under the gear icon.


## [0.12.1] — 2024-08-25

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions app/assets/builds/tailwind.css

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,37 @@
.timeline-box {
overflow: visible !important;
}

/* Style for the settings panel */
.leaflet-settings-panel {
background-color: white;
padding: 10px;
border: 1px solid #ccc;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.leaflet-settings-panel label {
display: block;
margin-bottom: 5px;
}

.leaflet-settings-panel input {
width: 100%;
margin-bottom: 10px;
padding: 5px;
border: 1px solid #ccc;
border-radius: 3px;
}

.leaflet-settings-panel button {
padding: 5px 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
}

.leaflet-settings-panel button:hover {
background-color: #0056b3;
}
36 changes: 36 additions & 0 deletions app/controllers/api/v1/settings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

class Api::V1::SettingsController < ApiController
def index
render json: {
settings: current_api_user.settings,
status: 'success'
}, status: :ok
end

def update
settings_params.each { |key, value| current_api_user.settings[key] = value }

if current_api_user.save
render json: {
message: 'Settings updated',
settings: current_api_user.settings,
status: 'success'
}, status: :ok
else
render json: {
message: 'Something went wrong',
errors: current_api_user.errors.full_messages
}, status: :unprocessable_entity
end
end

private

def settings_params
params.require(:settings).permit(
:meters_between_routes, :minutes_between_routes, :fog_of_war_meters,
:time_threshold_minutes, :merge_threshold_minutes, :route_opacity
)
end
end
Loading

0 comments on commit 0cc5ac0

Please sign in to comment.