Skip to content

Modern Docker Management, Designed for Everyone

fix: settings not saving on submission

Kyle Mendell520178b28141
diff --git a/backend/internal/dto/settings_dto.go b/backend/internal/dto/settings_dto.go
index d1c8fb917..28f9430cc 100644
--- a/backend/internal/dto/settings_dto.go
+++ b/backend/internal/dto/settings_dto.go
@@ -18,7 +18,7 @@ type UpdateSettingsDto struct {
AutoUpdateInterval *string `json:"autoUpdateInterval,omitempty"`
PollingEnabled *string `json:"pollingEnabled,omitempty"`
PollingInterval *string `json:"pollingInterval,omitempty"`
- PruneMode *string `json:"pruneMode,omitempty"`
+ PruneMode *string `json:"dockerPruneMode,omitempty" binding:"omitempty,oneof=all dangling"`
BaseServerURL *string `json:"baseServerUrl,omitempty"`
// Authentication settings
diff --git a/frontend/src/lib/types/settings.type.ts b/frontend/src/lib/types/settings.type.ts
index de78a961e..159b172ec 100644
--- a/frontend/src/lib/types/settings.type.ts
+++ b/frontend/src/lib/types/settings.type.ts
@@ -12,7 +12,7 @@ export type Settings = {
autoUpdateInterval: number;
pollingEnabled: boolean;
pollingInterval: number;
- dockerPruneMode: string;
+ dockerPruneMode: 'all' | 'dangling';
baseServerUrl: string;
// Authentication settings
diff --git a/frontend/src/routes/settings/docker/+page.svelte b/frontend/src/routes/settings/docker/+page.svelte
index 18168b926..1e8f4323a 100644
--- a/frontend/src/routes/settings/docker/+page.svelte
+++ b/frontend/src/routes/settings/docker/+page.svelte
@@ -7,26 +7,50 @@
import { Label } from '$lib/components/ui/label/index.js';
import * as Alert from '$lib/components/ui/alert/index.js';
import { toast } from 'svelte-sonner';
- import { invalidateAll } from '$app/navigation';
import type { Settings } from '$lib/types/settings.type';
import settingsStore from '$lib/stores/config-store';
import { settingsAPI } from '$lib/services/api';
import FormInput from '$lib/components/form/form-input.svelte';
let { data } = $props();
- let currentSettings = $state(data.settings);
+ let currentSettings = $state<Settings>(data.settings);
let isLoading = $state({
saving: false,
testing: false
});
+ let pollingIntervalInput = $state<FormInputType<number>>({
+ value: 0,
+ error: null
+ });
+
+ let pollingEnabledSwitch = $state<FormInputType<boolean>>({
+ value: false,
+ error: null
+ });
+
+ let autoUpdateSwitch = $state<FormInputType<boolean>>({
+ value: false,
+ error: null
+ });
+
+ let autoUpdateIntervalInput = $state<FormInputType<number>>({
+ value: 5,
+ error: null
+ });
+
+ const _initialPruneMode = data.settings?.dockerPruneMode === 'dangling' ? 'dangling' : 'all';
+
+ let pruneModeValue = $state<'all' | 'dangling'>(_initialPruneMode);
+
async function updateSettingsConfig(updatedSettings: Partial<Settings>) {
try {
- currentSettings = await settingsAPI.updateSettings({
- ...currentSettings,
- ...updatedSettings
- });
+ await settingsAPI.updateSettings(updatedSettings as any);
+
+ currentSettings = { ...currentSettings, ...updatedSettings };
+
+ settingsStore.set(currentSettings);
settingsStore.reload();
} catch (error) {
console.error('Error updating settings:', error);
@@ -37,15 +61,14 @@
function handleDockerSettingUpdates() {
isLoading.saving = true;
updateSettingsConfig({
- dockerPruneMode: 'all',
+ dockerPruneMode: pruneModeValue,
autoUpdateEnabled: autoUpdateSwitch.value,
pollingEnabled: pollingEnabledSwitch.value,
pollingInterval: pollingIntervalInput.value,
autoUpdateInterval: autoUpdateIntervalInput.value
})
- .then(async () => {
+ .then(() => {
toast.success(`Settings Saved Successfully`);
- await invalidateAll();
})
.catch((error) => {
toast.error('Failed to save settings');
@@ -56,31 +79,14 @@
});
}
- let pollingIntervalInput = $state<FormInputType<number>>({
- value: 0,
- error: null
- });
-
- let pollingEnabledSwitch = $state<FormInputType<boolean>>({
- value: false,
- error: null
- });
-
- let autoUpdateSwitch = $state<FormInputType<boolean>>({
- value: false,
- error: null
- });
-
- let autoUpdateIntervalInput = $state<FormInputType<number>>({
- value: 5,
- error: null
- });
-
$effect(() => {
- pollingIntervalInput.value = currentSettings.pollingInterval || 60;
- pollingEnabledSwitch.value = currentSettings.pollingEnabled || false;
- autoUpdateSwitch.value = currentSettings.autoUpdateEnabled || false;
- autoUpdateIntervalInput.value = currentSettings.autoUpdateInterval || 60;
+ if (!isLoading.saving) {
+ pollingIntervalInput.value = currentSettings.pollingInterval || 60;
+ pollingEnabledSwitch.value = currentSettings.pollingEnabled || false;
+ autoUpdateSwitch.value = currentSettings.autoUpdateEnabled || false;
+ autoUpdateIntervalInput.value = currentSettings.autoUpdateInterval || 60;
+ pruneModeValue = currentSettings.dockerPruneMode === 'dangling' ? 'dangling' : 'all';
+ }
});
let isPollingConfigValid = $derived(
@@ -125,7 +131,7 @@
</div>
<!-- Alert Section -->
- {#if currentSettings.autoUpdateEnabled && currentSettings.pollingEnabled}
+ {#if autoUpdateSwitch.value && pollingEnabledSwitch.value}
<div class="settings-alert">
<Alert.Root variant="warning">
<Zap class="size-4" />
@@ -163,7 +169,7 @@
description="Periodically check registries for newer image versions"
/>
- {#if currentSettings.pollingEnabled}
+ {#if pollingEnabledSwitch.value}
<div class="space-y-4 pl-4">
<FormInput
bind:input={pollingIntervalInput}
@@ -194,7 +200,7 @@
description="Automatically update containers when newer images are found"
/>
- {#if currentSettings.autoUpdateEnabled}
+ {#if autoUpdateSwitch.value}
<div class="pl-4">
<FormInput
bind:input={autoUpdateIntervalInput}
@@ -213,7 +219,7 @@
<Alert.Title>Automation Summary</Alert.Title>
<Alert.Description>
<ul class="list-inside list-disc text-sm">
- {#if currentSettings.autoUpdateEnabled}
+ {#if autoUpdateSwitch.value}
<li>Images checked every {pollingIntervalInput.value || 60} minutes</li>
{:else}
<li>Manual updates only (auto-update disabled)</li>
@@ -245,11 +251,10 @@
<Label for="pruneMode" class="text-base font-medium">Prune Action Behavior</Label>
<RadioGroup.Root
- value={currentSettings.dockerPruneMode || 'all'}
+ value={pruneModeValue}
onValueChange={(val) => {
- updateSettingsConfig({
- dockerPruneMode: val as 'all' | 'dangling'
- }).catch((error) => {
+ pruneModeValue = val as 'all' | 'dangling';
+ updateSettingsConfig({ dockerPruneMode: pruneModeValue }).catch((error) => {
toast.error('Failed to update prune mode');
console.error('Error updating prune mode:', error);
});
@@ -293,7 +298,7 @@
<p class="text-muted-foreground text-sm">
<strong>Note:</strong> This setting affects the "Prune Unused Images" action on the
Images page.
- {(currentSettings.dockerPruneMode || 'all') === 'all'
+ {pruneModeValue === 'all'
? 'All unused images will be removed, which frees up more space but may require re-downloading images later.'
: 'Only dangling images will be removed, which is safer but may leave some unused images behind.'}
</p>
diff --git a/frontend/src/routes/settings/general/+page.svelte b/frontend/src/routes/settings/general/+page.svelte
index e366a3471..0271fe832 100644
--- a/frontend/src/routes/settings/general/+page.svelte
+++ b/frontend/src/routes/settings/general/+page.svelte
@@ -5,7 +5,6 @@
import { Save, RefreshCw, Folder, Globe } from '@lucide/svelte';
import type { FormInput as FormInputType } from '$lib/utils/form.utils';
import { toast } from 'svelte-sonner';
- import { invalidateAll } from '$app/navigation';
import type { Settings } from '$lib/types/settings.type';
import settingsStore from '$lib/stores/config-store';
import { settingsAPI } from '$lib/services/api';
@@ -19,6 +18,7 @@
...currentSettings,
...updatedSettings
});
+ settingsStore.set(currentSettings);
settingsStore.reload();
} catch (error) {
console.error('Error updating settings:', error);
@@ -34,7 +34,6 @@
})
.then(async () => {
toast.success(`Settings Saved Successfully`);
- await invalidateAll();
})
.catch((error) => {
toast.error('Failed to save settings');
@@ -60,8 +59,15 @@
});
$effect(() => {
- stacksDirectoryInput.value = currentSettings.stacksDirectory || '';
- baseServerUrlInput.value = currentSettings.baseServerUrl || 'localhost';
+ const s = $settingsStore ?? currentSettings;
+ if (!s) return;
+
+ currentSettings = s;
+
+ if (!isLoading.saving) {
+ stacksDirectoryInput.value = s.stacksDirectory || '';
+ baseServerUrlInput.value = s.baseServerUrl || 'localhost';
+ }
});
</script>
@@ -109,10 +115,10 @@
</Card.Header>
<Card.Content class="pt-0">
<FormInput
- label="Stacks Directory"
+ label="Projects Directory"
placeholder="data/projects"
bind:input={stacksDirectoryInput}
- helpText="Directory where Docker Compose stack files are stored"
+ helpText="Directory where Docker Compose files are stored (this is inside the container)"
/>
</Card.Content>
</Card.Root>
diff --git a/frontend/src/routes/settings/security/+page.svelte b/frontend/src/routes/settings/security/+page.svelte
index 897a3e77c..e625e9e07 100644
--- a/frontend/src/routes/settings/security/+page.svelte
+++ b/frontend/src/routes/settings/security/+page.svelte
@@ -60,6 +60,7 @@
...currentSettings,
...updatedSettings
});
+ settingsStore.set(currentSettings);
settingsStore.reload();
} catch (error) {
console.error('Error updating settings:', error);
@@ -90,7 +91,6 @@
})
.then(async () => {
toast.success(`Settings Saved Successfully`);
- await invalidateAll();
})
.catch((error) => {
toast.error('Failed to save settings');
@@ -111,7 +111,6 @@
function openOidcDialog() {
if (!isOidcViewMode) {
- // Parse current config if it exists
if (currentSettings.authOidcConfig) {
try {
const oidcConfig = JSON.parse(currentSettings.authOidcConfig);