Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: properly persist local vs environment settings (#775)
Kyle Mendell54a6f14b5a28
diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.goindex dfee64bdc..d5c74363a 100644--- a/backend/internal/models/settings.go+++ b/backend/internal/models/settings.go@@ -49,7 +49,7 @@ type Settings struct {BaseServerURL SettingVariable `key:"baseServerUrl" meta:"label=Base Server URL;type=text;keywords=base,url,server,domain,host,endpoint,address,link;category=general;description=Set the base URL for the application"`EnableGravatar SettingVariable `key:"enableGravatar" meta:"label=Enable Gravatar;type=boolean;keywords=gravatar,avatar,profile,picture,image,user,photo;category=general;description=Enable Gravatar profile pictures for users"`DefaultShell SettingVariable `key:"defaultShell" meta:"label=Default Shell;type=text;keywords=shell,default,shellpath,path,login;category=general;description=Default shell to use for commands"`- AccentColor SettingVariable `key:"accentColor,public" meta:"label=Accent Color;type=text;keywords=color,accent,theme,css,appearance,ui;category=general;description=Primary accent color for UI"`+ AccentColor SettingVariable `key:"accentColor,public,local" meta:"label=Accent Color;type=text;keywords=color,accent,theme,css,appearance,ui;category=general;description=Primary accent color for UI"`// Deprecated: OnboardingCompleted is no longer used as of the onboarding removal.// This field is kept for backward compatibility and is automatically set to true on startup.@@ -77,11 +77,11 @@ type Settings struct {AuthOidcConfig SettingVariable `key:"authOidcConfig,sensitive" meta:"label=OIDC Config;type=text;keywords=oidc,config,client,id,issuer,secret,oauth;category=security;description=OIDC provider configuration"`// Navigation category- MobileNavigationMode SettingVariable `key:"mobileNavigationMode,public" meta:"label=Mobile Navigation Mode;type=select;keywords=mode,style,type,floating,docked,position,layout,design,appearance,bottom;category=navigation;description=Choose between floating or docked navigation on mobile" catmeta:"id=navigation;title=Navigation;icon=navigation;url=/settings/navigation;description=Customize navigation and interface behavior"`- MobileNavigationShowLabels SettingVariable `key:"mobileNavigationShowLabels,public" meta:"label=Show Navigation Labels;type=boolean;keywords=labels,text,icons,display,show,hide,names,captions,titles,visible,toggle;category=navigation;description=Display text labels alongside navigation icons"`- MobileNavigationScrollToHide SettingVariable `key:"mobileNavigationScrollToHide,public" meta:"label=Scroll to Hide;type=boolean;keywords=scroll,hide,auto-hide,behavior,down,up,automatic,disappear,vanish,minimize,collapse;category=navigation;description=Automatically hide navigation when scrolling down"`- SidebarHoverExpansion SettingVariable `key:"sidebarHoverExpansion,public" meta:"label=Sidebar Hover Expansion;type=boolean;keywords=sidebar,hover,expansion,expand,desktop,mouse,over,collapsed,collapsible,icon,labels,text,preview,peek,tooltip,overlay,temporary,quick,access,navigation,menu,items,submenu,nested;category=navigation;description=Expand sidebar on hover in desktop mode"`- GlassEffectEnabled SettingVariable `key:"glassEffectEnabled,public" meta:"label=Glass Effect;type=boolean;keywords=glass,glassmorphism,blur,backdrop,frosted,effect,gradient,ambient,design,ui,appearance,modern,visual,style,theme,transparency,translucent;category=navigation;description=Enable modern glassmorphism design with blur, gradients, and ambient effects"`+ MobileNavigationMode SettingVariable `key:"mobileNavigationMode,public,local" meta:"label=Mobile Navigation Mode;type=select;keywords=mode,style,type,floating,docked,position,layout,design,appearance,bottom;category=navigation;description=Choose between floating or docked navigation on mobile" catmeta:"id=navigation;title=Navigation;icon=navigation;url=/settings/navigation;description=Customize navigation and interface behavior"`+ MobileNavigationShowLabels SettingVariable `key:"mobileNavigationShowLabels,public,local" meta:"label=Show Navigation Labels;type=boolean;keywords=labels,text,icons,display,show,hide,names,captions,titles,visible,toggle;category=navigation;description=Display text labels alongside navigation icons"`+ MobileNavigationScrollToHide SettingVariable `key:"mobileNavigationScrollToHide,public,local" meta:"label=Scroll to Hide;type=boolean;keywords=scroll,hide,auto-hide,behavior,down,up,automatic,disappear,vanish,minimize,collapse;category=navigation;description=Automatically hide navigation when scrolling down"`+ SidebarHoverExpansion SettingVariable `key:"sidebarHoverExpansion,public,local" meta:"label=Sidebar Hover Expansion;type=boolean;keywords=sidebar,hover,expansion,expand,desktop,mouse,over,collapsed,collapsible,icon,labels,text,preview,peek,tooltip,overlay,temporary,quick,access,navigation,menu,items,submenu,nested;category=navigation;description=Expand sidebar on hover in desktop mode"`+ GlassEffectEnabled SettingVariable `key:"glassEffectEnabled,public,local" meta:"label=Glass Effect;type=boolean;keywords=glass,glassmorphism,blur,backdrop,frosted,effect,gradient,ambient,design,ui,appearance,modern,visual,style,theme,transparency,translucent;category=navigation;description=Enable modern glassmorphism design with blur, gradients, and ambient effects"`InstanceID SettingVariable `key:"instanceId,internal" meta:"label=Instance ID;type=text;keywords=instance,id,uuid,identifier;category=internal;description=Unique instance identifier"`}@@ -142,6 +142,21 @@ func (s *Settings) FieldByKey(key string) (defaultValue string, isPublic bool, ireturn "", false, false, SettingKeyNotFoundError{field: key}}+func (s *Settings) IsLocalSetting(key string) bool {+ rt := reflect.TypeOf(s).Elem()++ for i := 0; i < rt.NumField(); i++ {+ tagValue := strings.Split(rt.Field(i).Tag.Get("key"), ",")+ keyFromTag := tagValue[0]++ if keyFromTag == key {+ return slices.Contains(tagValue, "local")+ }+ }++ return false+}+func (s *Settings) UpdateField(key string, value string, noSensitive bool) error {rv := reflect.ValueOf(s).Elem()rt := rv.Type()diff --git a/frontend/src/lib/services/settings-service.ts b/frontend/src/lib/services/settings-service.tsindex 207e05222..a46a14c38 100644--- a/frontend/src/lib/services/settings-service.ts+++ b/frontend/src/lib/services/settings-service.ts@@ -1,17 +1,41 @@import BaseAPIService from './api-service';import type { Settings, OidcStatusInfo } from '$lib/types/settings.type';import { environmentStore } from '$lib/stores/environment.store.svelte';+import { isLocalSetting, extractLocalSettings, extractEnvironmentSettings } from '$lib/utils/settings.util';type KeyValuePair = { key: string; value: string };export default class SettingsService extends BaseAPIService {async getSettings(): Promise<Settings> {const envId = await environmentStore.getCurrentEnvironmentId();- const res = await this.api.get(`/environments/${envId}/settings`);- return this.normalize(res.data);++ // If we're on environment 0, just get all settings normally+ if (envId === '0') {+ const res = await this.api.get(`/environments/0/settings`);+ return this.normalize(res.data);+ }++ // For remote environments, merge:+ // - UI settings from environment 0 (main instance)+ // - Environment-specific settings from current environment+ const [mainSettings, envSettings] = await Promise.all([+ this.api.get('/environments/0/settings'),+ this.api.get(`/environments/${envId}/settings`)+ ]);++ const mainNormalized = this.normalize(mainSettings.data);+ const envNormalized = this.normalize(envSettings.data);++ // Extract UI settings from main, environment settings from current env+ const uiSettings = extractLocalSettings(mainNormalized);+ const operationalSettings = extractEnvironmentSettings(envNormalized);++ // Merge them+ return { ...operationalSettings, ...uiSettings } as Settings;}async getSettingsForEnvironment(environmentId: string): Promise<Settings> {+ // When viewing a specific environment's settings page, show all its settingsconst res = await this.api.get(`/environments/${environmentId}/settings`);return this.normalize(res.data);}@@ -23,13 +47,41 @@ export default class SettingsService extends BaseAPIService {async updateSettings(settings: Partial<Settings>) {const envId = await environmentStore.getCurrentEnvironmentId();- const payload: Record<string, string> = {};++ const uiSettings: Record<string, any> = {};+ const envSettings: Record<string, any> = {};++ // Separate UI settings from environment settingsfor (const key in settings) {- const v = (settings as any)[key];- payload[key] = typeof v === 'object' && v !== null ? JSON.stringify(v) : String(v);+ if (isLocalSetting(key)) {+ uiSettings[key] = settings[key as keyof Settings];+ } else {+ envSettings[key] = settings[key as keyof Settings];+ }}- const res = await this.api.put(`/environments/${envId}/settings`, payload);- return this.normalize(res.data);++ // Update UI settings on environment 0 (main instance)+ if (Object.keys(uiSettings).length > 0) {+ const payload: Record<string, string> = {};+ for (const key in uiSettings) {+ const v = uiSettings[key];+ payload[key] = typeof v === 'object' && v !== null ? JSON.stringify(v) : String(v);+ }+ await this.api.put('/environments/0/settings', payload);+ }++ // Update environment settings on current environment+ if (Object.keys(envSettings).length > 0) {+ const payload: Record<string, string> = {};+ for (const key in envSettings) {+ const v = envSettings[key];+ payload[key] = typeof v === 'object' && v !== null ? JSON.stringify(v) : String(v);+ }+ await this.api.put(`/environments/${envId}/settings`, payload);+ }++ // Reload and return merged settings+ return this.getSettings();}async getOidcStatus(): Promise<OidcStatusInfo> {diff --git a/frontend/src/lib/utils/settings.util.ts b/frontend/src/lib/utils/settings.util.tsnew file mode 100644index 000000000..ee55604d7--- /dev/null+++ b/frontend/src/lib/utils/settings.util.ts@@ -0,0 +1,41 @@+export type LocalSettings = {+ accentColor: string;+ mobileNavigationMode: string;+ mobileNavigationShowLabels: boolean;+ mobileNavigationScrollToHide: boolean;+ sidebarHoverExpansion: boolean;+ glassEffectEnabled: boolean;+};++const LOCAL_SETTING_KEYS = new Set([+ 'accentColor',+ 'mobileNavigationMode',+ 'mobileNavigationShowLabels',+ 'mobileNavigationScrollToHide',+ 'sidebarHoverExpansion',+ 'glassEffectEnabled'+]);++export function isLocalSetting(key: string): boolean {+ return LOCAL_SETTING_KEYS.has(key);+}++export function extractLocalSettings(settings: Record<string, any>): Partial<LocalSettings> {+ const local: Partial<LocalSettings> = {};+ for (const key of LOCAL_SETTING_KEYS) {+ if (key in settings) {+ local[key as keyof LocalSettings] = settings[key];+ }+ }+ return local;+}++export function extractEnvironmentSettings(settings: Record<string, any>): Record<string, any> {+ const env: Record<string, any> = {};+ for (const key in settings) {+ if (!LOCAL_SETTING_KEYS.has(key)) {+ env[key] = settings[key];+ }+ }+ return env;+}