mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
* Add yearly digest * Rename YearlyDigests to Users::Digests * Minor changes * Update yearly digest layout and styles * Add flags and chart to email * Update colors * Fix layout of stats in yearly digest view * Remove cron job for yearly digest scheduling * Update CHANGELOG.md * Update digest email setting handling * Allow sharing digest for 1 week or 1 month * Change Digests Distance to Bigint * Fix settings page
41 lines
1 KiB
Ruby
41 lines
1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class SettingsController < ApplicationController
|
|
before_action :authenticate_user!
|
|
before_action :authenticate_active_user!, only: %i[update]
|
|
|
|
def index; end
|
|
|
|
def update
|
|
existing_settings = current_user.safe_settings.settings
|
|
|
|
current_user.update(settings: existing_settings.merge(settings_params))
|
|
|
|
flash.now[:notice] = 'Settings updated'
|
|
|
|
redirect_to settings_path, notice: 'Settings updated'
|
|
end
|
|
|
|
def theme
|
|
current_user.update(theme: params[:theme])
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
end
|
|
|
|
def generate_api_key
|
|
current_user.update(api_key: SecureRandom.hex)
|
|
|
|
redirect_back(fallback_location: root_path)
|
|
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,
|
|
:immich_url, :immich_api_key, :photoprism_url, :photoprism_api_key,
|
|
:visits_suggestions_enabled, :digest_emails_enabled
|
|
)
|
|
end
|
|
end
|