2024-05-18 06:13:29 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class SettingsController < ApplicationController
|
|
|
|
|
before_action :authenticate_user!
|
|
|
|
|
|
2024-08-21 12:40:54 -04:00
|
|
|
def index; end
|
2024-06-20 17:57:00 -04:00
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
current_user.update(settings: settings_params)
|
|
|
|
|
|
|
|
|
|
flash.now[:notice] = 'Settings updated'
|
|
|
|
|
|
|
|
|
|
redirect_to settings_path, notice: 'Settings updated'
|
|
|
|
|
end
|
|
|
|
|
|
2024-05-18 06:13:29 -04:00
|
|
|
def theme
|
|
|
|
|
current_user.update(theme: params[:theme])
|
|
|
|
|
|
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
|
|
|
end
|
2024-05-25 07:57:50 -04:00
|
|
|
|
|
|
|
|
def generate_api_key
|
|
|
|
|
current_user.update(api_key: SecureRandom.hex)
|
|
|
|
|
|
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
|
|
|
end
|
2024-06-20 17:57:00 -04:00
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def settings_params
|
2024-06-25 16:30:11 -04:00
|
|
|
params.require(:settings).permit(
|
2024-07-24 14:25:16 -04:00
|
|
|
:meters_between_routes, :minutes_between_routes, :fog_of_war_meters,
|
2024-08-21 12:40:54 -04:00
|
|
|
:time_threshold_minutes, :merge_threshold_minutes, :route_opacity,
|
2024-12-02 10:52:05 -05:00
|
|
|
:immich_url, :immich_api_key, :photoprism_url, :photoprism_api_key
|
2024-06-25 16:30:11 -04:00
|
|
|
)
|
2024-06-20 17:57:00 -04:00
|
|
|
end
|
2024-05-18 06:13:29 -04:00
|
|
|
end
|