Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: configurable disk usage path (#650)
Kyle Mendell8d3b973d7936
diff --git a/backend/internal/api/system_handler.go b/backend/internal/api/system_handler.goindex df75e014c..07795797b 100644--- a/backend/internal/api/system_handler.go+++ b/backend/internal/api/system_handler.go@@ -1,6 +1,7 @@package apiimport (+ "context""log/slog""net/http""runtime"@@ -228,6 +229,14 @@ func (h *SystemHandler) StartAllStoppedContainers(c *gin.Context) {})}+func (h *SystemHandler) getDiskUsagePath(ctx context.Context) string {+ diskUsagePath := h.systemService.GetDiskUsagePath(ctx)+ if diskUsagePath == "" {+ diskUsagePath = "/"+ }+ return diskUsagePath+}+func (h *SystemHandler) StopAllContainers(c *gin.Context) {result, err := h.systemService.StopAllContainers(c.Request.Context())if err != nil {@@ -283,7 +292,8 @@ func (h *SystemHandler) Stats(c *gin.Context) {memTotal = memInfo.Total}- diskInfo, _ := disk.Usage("/")+ diskUsagePath := h.getDiskUsagePath(c.Request.Context())+ diskInfo, _ := disk.Usage(diskUsagePath)var diskUsed, diskTotal uint64if diskInfo != nil {diskUsed = diskInfo.Useddiff --git a/backend/internal/dto/settings_dto.go b/backend/internal/dto/settings_dto.goindex 9b1284d8c..9840adf29 100644--- a/backend/internal/dto/settings_dto.go+++ b/backend/internal/dto/settings_dto.go@@ -14,6 +14,7 @@ type SettingDto struct {type UpdateSettingsDto struct {// Core settingsProjectsDirectory *string `json:"projectsDirectory,omitempty"`+ DiskUsagePath *string `json:"diskUsagePath,omitempty"`AutoUpdate *string `json:"autoUpdate,omitempty"`AutoUpdateInterval *string `json:"autoUpdateInterval,omitempty"`PollingEnabled *string `json:"pollingEnabled,omitempty"`diff --git a/backend/internal/models/settings.go b/backend/internal/models/settings.goindex e05670fc0..8cee4794f 100644--- a/backend/internal/models/settings.go+++ b/backend/internal/models/settings.go@@ -45,6 +45,7 @@ func (s SettingVariable) AsDurationSeconds() time.Duration {type Settings struct {// DockerProjectsDirectory SettingVariable `key:"projectsDirectory"`+ DiskUsagePath SettingVariable `key:"diskUsagePath"`AutoUpdate SettingVariable `key:"autoUpdate"`AutoUpdateInterval SettingVariable `key:"autoUpdateInterval"`PollingEnabled SettingVariable `key:"pollingEnabled"`diff --git a/backend/internal/services/settings_service.go b/backend/internal/services/settings_service.goindex 9c0cbcaad..9e25bbdf3 100644--- a/backend/internal/services/settings_service.go+++ b/backend/internal/services/settings_service.go@@ -77,6 +77,7 @@ func (s *SettingsService) LoadDatabaseSettings(ctx context.Context) (err error)func (s *SettingsService) getDefaultSettings() *models.Settings {return &models.Settings{ProjectsDirectory: models.SettingVariable{Value: "data/projects"},+ DiskUsagePath: models.SettingVariable{Value: "data/projects"},AutoUpdate: models.SettingVariable{Value: "false"},AutoUpdateInterval: models.SettingVariable{Value: "1440"},PollingEnabled: models.SettingVariable{Value: "true"},diff --git a/backend/internal/services/system_service.go b/backend/internal/services/system_service.goindex eacc1d274..0c6a8d4c7 100644--- a/backend/internal/services/system_service.go+++ b/backend/internal/services/system_service.go@@ -479,3 +479,7 @@ func (s *SystemService) ConvertToDockerCompose(parsed *models.DockerRunCommand)return string(yamlData), envVars, serviceName, nil}++func (s *SystemService) GetDiskUsagePath(ctx context.Context) string {+ return s.settingsService.GetStringSetting(ctx, "diskUsagePath", "data/projects")+}diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex cf8264eb4..dd3b4b0cb 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -385,6 +385,14 @@"dashboard_meter_memory_desc": "RAM utilization","dashboard_meter_disk": "Disk Usage","dashboard_meter_disk_desc": "Storage utilization",+ "dashboard_meter_disk_used": "Used",+ "dashboard_meter_disk_free": "Free",+ "dashboard_meter_disk_monitoring": "Monitoring: {path}",+ "disk_usage_settings": "Disk Usage Settings",+ "disk_usage_settings_description": "Configure which directory to monitor for disk usage metrics.",+ "disk_usage_save": "Disk usage path updated successfully",+ "disk_usage_save_failed": "Failed to update disk usage path",+ "directory_path": "Directory Path","dashboard_docker_details_title": "Docker Details","common_confirm": "Confirm","containers_title": "Containers",@@ -1184,8 +1192,6 @@"docker_info_paused_label": "Paused","docker_info_stopped_label": "Stopped","docker_info_images_label": "Images",- "dashboard_meter_disk_used": "Used",- "dashboard_meter_disk_free": "Free","dashboard_meter_disk_total": "Total","dashboard_docker_overview": "Docker Overview","services": "Services",@@ -1226,5 +1232,5 @@"variables_duplicate_keys_error": "Duplicate keys found. Please ensure all keys are unique.","variables_save_success": "Global variables saved successfully","variables_save_failed": "Failed to save. Please try again.",- "containers_group_by_project": "Group by Project"+ "containers_group_by_project": "Group by Project"}diff --git a/frontend/src/lib/components/disk-meter.svelte b/frontend/src/lib/components/disk-meter.svelteindex 1a3b265ad..787be55ff 100644--- a/frontend/src/lib/components/disk-meter.svelte+++ b/frontend/src/lib/components/disk-meter.svelte@@ -1,10 +1,19 @@<script lang="ts">import * as Card from '$lib/components/ui/card';+ import * as Popover from '$lib/components/ui/popover';+ import { Button } from '$lib/components/ui/button';+ import { Input } from '$lib/components/ui/input';+ import { Label } from '$lib/components/ui/label';import { Progress } from '$lib/components/ui/progress/index.js';import HardDriveIcon from '@lucide/svelte/icons/hard-drive';import LoaderCircleIcon from '@lucide/svelte/icons/loader-circle';+ import SettingsIcon from '@lucide/svelte/icons/settings';import { m } from '$lib/paraglide/messages';import bytes from 'bytes';+ import settingsStore from '$lib/stores/config-store';+ import { settingsService } from '$lib/services/settings-service';+ import { toast } from 'svelte-sonner';+ import { z } from 'zod/v4';let {diskUsage,@@ -24,6 +33,40 @@const diskFree = $derived(diskUsage !== undefined && diskTotal !== undefined ? diskTotal - diskUsage : 0);+ let diskUsagePath = $state($settingsStore.diskUsagePath || 'data/projects');+ let popoverOpen = $state(false);+ let isSaving = $state(false);++ const pathSchema = z+ .string()+ .min(1, 'Path cannot be empty')+ .refine((path) => !path.includes('..'), 'Path cannot contain ".."')+ .refine((path) => !/^[a-zA-Z]:/.test(path), 'Windows-style paths are not supported');++ async function saveDiskUsagePath() {+ const trimmedPath = diskUsagePath.trim();+ const result = pathSchema.safeParse(trimmedPath);++ if (!result.success) {+ const firstError = result.error.issues[0];+ toast.error(firstError.message);+ return;+ }++ isSaving = true;+ try {+ await settingsService.updateSettings({ diskUsagePath: trimmedPath });+ settingsStore.set({ ...$settingsStore, diskUsagePath: trimmedPath });+ toast.success(m.disk_usage_save());+ popoverOpen = false;+ } catch (error) {+ console.error('Failed to update disk usage path:', error);+ toast.error(m.disk_usage_save_failed());+ } finally {+ isSaving = false;+ }+ }+function formatBytes(value: number): string {return bytes.format(value, { unitSeparator: ' ' }) ?? '-';}@@ -36,7 +79,47 @@<div class="min-w-0 flex-1"><div class="text-foreground text-sm font-semibold">{m.dashboard_meter_disk()}</div><div class="text-muted-foreground text-xs">{m.dashboard_meter_disk_desc()}</div>+ <div class="text-muted-foreground/70 mt-0.5 text-[10px] font-mono">+ {m.dashboard_meter_disk_monitoring({ path: $settingsStore.diskUsagePath })}+ </div></div>+ <Popover.Root bind:open={popoverOpen}>+ <Popover.Trigger>+ {#snippet child({ props })}+ <Button {...props} variant="ghost" size="icon" class="hover:bg-muted h-7 w-7 shrink-0">+ <SettingsIcon class="size-4" />+ </Button>+ {/snippet}+ </Popover.Trigger>+ <Popover.Content class="w-80">+ <div class="space-y-4">+ <div class="space-y-2">+ <h4 class="text-sm font-medium leading-none">{m.disk_usage_settings()}</h4>+ <p class="text-muted-foreground text-sm">{m.disk_usage_settings_description()}</p>+ </div>+ <div class="space-y-2">+ <Label for="disk-path">{m.directory_path()}</Label>+ <Input id="disk-path" placeholder="data/projects" bind:value={diskUsagePath} disabled={isSaving} />+ </div>+ <div class="flex justify-end gap-2">+ <Button+ variant="outline"+ size="sm"+ onclick={() => {+ diskUsagePath = $settingsStore.diskUsagePath || 'data/projects';+ popoverOpen = false;+ }}+ disabled={isSaving}+ >+ Cancel+ </Button>+ <Button size="sm" onclick={saveDiskUsagePath} disabled={isSaving}>+ {isSaving ? m.common_saving() : m.common_save()}+ </Button>+ </div>+ </div>+ </Popover.Content>+ </Popover.Root>{/snippet}</Card.Header>@@ -70,7 +153,7 @@<div class="bg-muted h-3 w-12 animate-pulse rounded"></div><div class="bg-muted h-4 w-16 animate-pulse rounded"></div>{:else}- <div class="text-muted-foreground text-[10px] font-medium tracking-wide uppercase">+ <div class="text-muted-foreground text-[10px] font-medium uppercase tracking-wide">{m.dashboard_meter_disk_used()}</div><div class="text-foreground text-sm font-semibold">@@ -84,7 +167,7 @@<div class="bg-muted h-3 w-12 animate-pulse rounded"></div><div class="bg-muted h-4 w-16 animate-pulse rounded"></div>{:else}- <div class="text-muted-foreground text-[10px] font-medium tracking-wide uppercase">+ <div class="text-muted-foreground text-[10px] font-medium uppercase tracking-wide">{m.dashboard_meter_disk_free()}</div><div class="text-foreground text-sm font-semibold">diff --git a/frontend/src/lib/services/settings-service.ts b/frontend/src/lib/services/settings-service.tsindex 963e0a53c..95b709d87 100644--- a/frontend/src/lib/services/settings-service.ts+++ b/frontend/src/lib/services/settings-service.ts@@ -21,7 +21,7 @@ export default class SettingsService extends BaseAPIService {return this.normalize(res.data);}- async updateSettings(settings: Settings) {+ async updateSettings(settings: Partial<Settings>) {const envId = await environmentStore.getCurrentEnvironmentId();const payload: Record<string, string> = {};for (const key in settings) {diff --git a/frontend/src/lib/types/settings.type.ts b/frontend/src/lib/types/settings.type.tsindex 7ca67c894..9d173e16d 100644--- a/frontend/src/lib/types/settings.type.ts+++ b/frontend/src/lib/types/settings.type.ts@@ -9,6 +9,7 @@ export type SettingRawResponse = {export type Settings = {projectsDirectory: string;+ diskUsagePath: string;autoUpdate: boolean;autoUpdateInterval: number;pollingEnabled: boolean;