Skip to content

Modern Docker Management, Designed for Everyone

fix: selected environment id not persisting across refreshes

Kyle Mendelld87db5b83cfa
diff --git a/backend/internal/api/system_handler.go b/backend/internal/api/system_handler.go
index 16122b1f6..0736fbf6e 100644
--- a/backend/internal/api/system_handler.go
+++ b/backend/internal/api/system_handler.go
@@ -354,7 +354,13 @@ func (h *SystemHandler) Stats(c *gin.Context) {
}
diskUsagePath := h.getDiskUsagePath(c.Request.Context())
- diskInfo, _ := disk.Usage(diskUsagePath)
+ diskInfo, err := disk.Usage(diskUsagePath)
+ if err != nil || diskInfo == nil || diskInfo.Total == 0 {
+ if diskUsagePath != "/" {
+ diskInfo, _ = disk.Usage("/")
+ }
+ }
+
var diskUsed, diskTotal uint64
if diskInfo != nil {
diskUsed = diskInfo.Used
diff --git a/backend/internal/services/system_service.go b/backend/internal/services/system_service.go
index f1b4b1d4e..5c9e957c4 100644
--- a/backend/internal/services/system_service.go
+++ b/backend/internal/services/system_service.go
@@ -497,5 +497,9 @@ func (s *SystemService) ConvertToDockerCompose(parsed *models.DockerRunCommand)
}
func (s *SystemService) GetDiskUsagePath(ctx context.Context) string {
- return s.settingsService.GetStringSetting(ctx, "diskUsagePath", "data/projects")
+ path := s.settingsService.GetStringSetting(ctx, "diskUsagePath", "/")
+ if path == "" {
+ path = "/"
+ }
+ return path
}
diff --git a/frontend/src/lib/components/logs/log-viewer.svelte b/frontend/src/lib/components/logs/log-viewer.svelte
index c6f4adc04..8cacd96ae 100644
--- a/frontend/src/lib/components/logs/log-viewer.svelte
+++ b/frontend/src/lib/components/logs/log-viewer.svelte
@@ -1,7 +1,6 @@
<script lang="ts">
import { dev } from '$app/environment';
- import { get } from 'svelte/store';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import { m } from '$lib/paraglide/messages';
import { ReconnectingWebSocket } from '$lib/utils/ws';
import { cn } from '$lib/utils';
@@ -141,7 +140,7 @@
}
async function buildLogWsEndpoint(): Promise<string> {
- const currentEnv = get(environmentStore.selected);
+ const currentEnv = environmentStore.selected;
const envId = currentEnv?.id || 'local';
const basePath =
type === 'project'
diff --git a/frontend/src/lib/components/mobile-nav/mobile-user-card.svelte b/frontend/src/lib/components/mobile-nav/mobile-user-card.svelte
index 3b615ecac..a6bc53819 100644
--- a/frontend/src/lib/components/mobile-nav/mobile-user-card.svelte
+++ b/frontend/src/lib/components/mobile-nav/mobile-user-card.svelte
@@ -8,7 +8,7 @@
import LanguagesIcon from '@lucide/svelte/icons/languages';
import Sun from '@lucide/svelte/icons/sun';
import Moon from '@lucide/svelte/icons/moon';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Environment } from '$lib/types/environment.type';
import { mode, toggleMode } from 'mode-watcher';
import { toast } from 'svelte-sonner';
@@ -26,30 +26,15 @@
let { user, class: className = '' }: Props = $props();
let userCardExpanded = $state(false);
- let currentSelectedEnvironment = $state<Environment | null>(null);
- let availableEnvironments = $state<Environment[]>([]);
const isDarkMode = $derived(mode.current === 'dark');
- $effect(() => {
- const unsubscribeSelected = environmentStore.selected.subscribe((value) => {
- currentSelectedEnvironment = value;
- });
- const unsubscribeAvailable = environmentStore.available.subscribe((value) => {
- availableEnvironments = value;
- });
- return () => {
- unsubscribeSelected();
- unsubscribeAvailable();
- };
- });
-
const effectiveUser = $derived(user);
const isAdmin = $derived(!!effectiveUser.roles?.includes('admin'));
- const selectedValue = $derived(currentSelectedEnvironment?.id || '');
+ const selectedValue = $derived(environmentStore.selected?.id || '');
async function handleEnvSelect(envId: string) {
- const env = availableEnvironments.find((e) => e.id === envId);
+ const env = environmentStore.available.find((e) => e.id === envId);
if (!env) return;
try {
@@ -122,7 +107,7 @@
<div class="bg-background/50 border-border/20 rounded-2xl border p-4">
<div class="flex items-center gap-3">
<div class="bg-primary/10 text-primary flex aspect-square size-8 items-center justify-center rounded-lg">
- {#if currentSelectedEnvironment?.isLocal}
+ {#if environmentStore.selected?.isLocal}
<ServerIcon class="size-4" />
{:else}
<RouterIcon class="size-4" />
@@ -133,21 +118,21 @@
{m.sidebar_environment_label()}
</div>
<div class="text-foreground text-sm font-medium">
- {currentSelectedEnvironment ? getEnvLabel(currentSelectedEnvironment) : m.sidebar_no_environment()}
+ {environmentStore.selected ? getEnvLabel(environmentStore.selected) : m.sidebar_no_environment()}
</div>
- {#if currentSelectedEnvironment}
+ {#if environmentStore.selected}
<div class="text-muted-foreground/60 text-xs">
- {getConnectionString(currentSelectedEnvironment)}
+ {getConnectionString(environmentStore.selected)}
</div>
{/if}
</div>
- {#if availableEnvironments.length > 1}
+ {#if environmentStore.available.length > 1}
<Select.Root type="single" value={selectedValue} onValueChange={handleEnvSelect}>
<Select.Trigger class="bg-background/50 border-border/30 text-foreground h-9 w-32 text-sm font-medium">
<span class="truncate">Switch</span>
</Select.Trigger>
<Select.Content class="min-w-[160px] max-w-[280px]">
- {#each availableEnvironments as env (env.id)}
+ {#each environmentStore.available as env (env.id)}
<Select.Item value={env.id} class="text-sm">
{getEnvLabel(env)}
</Select.Item>
diff --git a/frontend/src/lib/components/sheets/image-pull-sheet.svelte b/frontend/src/lib/components/sheets/image-pull-sheet.svelte
index 27edca98f..fb54a12c4 100644
--- a/frontend/src/lib/components/sheets/image-pull-sheet.svelte
+++ b/frontend/src/lib/components/sheets/image-pull-sheet.svelte
@@ -7,8 +7,7 @@
import { z } from 'zod/v4';
import { createForm, preventDefault } from '$lib/utils/form.utils';
import { toast } from 'svelte-sonner';
- import { environmentStore, LOCAL_DOCKER_ENVIRONMENT_ID } from '$lib/stores/environment.store';
- import { get } from 'svelte/store';
+ import { environmentStore, LOCAL_DOCKER_ENVIRONMENT_ID } from '$lib/stores/environment.store.svelte';
import { m } from '$lib/paraglide/messages';
type ImagePullFormProps = {
@@ -217,7 +216,7 @@
}
function getCurrentEnvironmentId(): string {
- const env = get(environmentStore.selected);
+ const env = environmentStore.selected;
return env?.id || LOCAL_DOCKER_ENVIRONMENT_ID;
}
</script>
diff --git a/frontend/src/lib/components/sidebar/sidebar-env-switcher.svelte b/frontend/src/lib/components/sidebar/sidebar-env-switcher.svelte
index e3a87a1ab..b88970ae7 100644
--- a/frontend/src/lib/components/sidebar/sidebar-env-switcher.svelte
+++ b/frontend/src/lib/components/sidebar/sidebar-env-switcher.svelte
@@ -7,7 +7,7 @@
import PlusIcon from '@lucide/svelte/icons/plus';
import RouterIcon from '@lucide/svelte/icons/router';
import ServerIcon from '@lucide/svelte/icons/server';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Environment } from '$lib/types/environment.type';
import { goto } from '$app/navigation';
import { toast } from 'svelte-sonner';
@@ -24,21 +24,6 @@
const sidebar = useSidebar();
let dropdownOpen = $state(false);
- let currentSelectedEnvironment = $state<Environment | null>(null);
- let availableEnvironments = $state<Environment[]>([]);
-
- $effect(() => {
- const unsubscribeSelected = environmentStore.selected.subscribe((value) => {
- currentSelectedEnvironment = value;
- });
- const unsubscribeAvailable = environmentStore.available.subscribe((value) => {
- availableEnvironments = value;
- });
- return () => {
- unsubscribeSelected();
- unsubscribeAvailable();
- };
- });
$effect(() => {
if (sidebar.state === 'collapsed' && !sidebar.isHovered && dropdownOpen) {
@@ -88,9 +73,9 @@
size="lg"
class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
>
- {#if currentSelectedEnvironment}
+ {#if environmentStore.selected}
<div class="bg-primary text-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg">
- {#if currentSelectedEnvironment.isLocal}
+ {#if environmentStore.selected.isLocal}
<ServerIcon class="size-4" />
{:else}
<RouterIcon class="size-4" />
@@ -98,10 +83,10 @@
</div>
<div class="grid flex-1 text-left text-sm leading-tight">
<span class="truncate font-medium">
- {getEnvLabel(currentSelectedEnvironment)}
+ {getEnvLabel(environmentStore.selected)}
</span>
<span class="truncate text-xs">
- {getConnectionString(currentSelectedEnvironment)}
+ {getConnectionString(environmentStore.selected)}
</span>
</div>
{:else}
@@ -137,7 +122,7 @@
}}
>
<DropdownMenu.Label class="text-muted-foreground text-xs">{m.sidebar_select_environment()}</DropdownMenu.Label>
- {#if availableEnvironments.length === 0}
+ {#if environmentStore.available.length === 0}
<DropdownMenu.Item disabled class="gap-2 p-2">
<div class="flex size-6 items-center justify-center rounded-md border">
<ServerIcon class="size-3.5 shrink-0" />
@@ -145,8 +130,8 @@
<span>{m.sidebar_no_environments()}</span>
</DropdownMenu.Item>
{:else}
- {#each availableEnvironments as env (env.id)}
- {@const isActive = currentSelectedEnvironment?.id === env.id}
+ {#each environmentStore.available as env (env.id)}
+ {@const isActive = environmentStore.selected?.id === env.id}
<DropdownMenu.Item
onSelect={() => !isActive && handleSelect(env)}
class={cn(
diff --git a/frontend/src/lib/services/container-service.ts b/frontend/src/lib/services/container-service.ts
index b3a76b046..178117f99 100644
--- a/frontend/src/lib/services/container-service.ts
+++ b/frontend/src/lib/services/container-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import { environmentStore } from '$lib/stores/environment.store';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { ContainerStatusCounts, ContainerSummaryDto, ContainerStats } from '$lib/types/container.type';
import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
import { transformPaginationParams } from '$lib/utils/params.util';
diff --git a/frontend/src/lib/services/image-service.ts b/frontend/src/lib/services/image-service.ts
index c8aacf2f1..7626ab8ad 100644
--- a/frontend/src/lib/services/image-service.ts
+++ b/frontend/src/lib/services/image-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import { environmentStore } from '$lib/stores/environment.store';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { ImageSummaryDto, ImageUsageCounts, ImageUpdateInfoDto } from '$lib/types/image.type';
import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
import type { AutoUpdateCheck, AutoUpdateResult } from '$lib/types/auto-update.type';
diff --git a/frontend/src/lib/services/network-service.ts b/frontend/src/lib/services/network-service.ts
index 1c1097104..19acc6abb 100644
--- a/frontend/src/lib/services/network-service.ts
+++ b/frontend/src/lib/services/network-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import { environmentStore } from '$lib/stores/environment.store';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { NetworkSummaryDto, NetworkUsageCounts } from '$lib/types/network.type';
import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
import type { NetworkCreateOptions } from 'dockerode';
diff --git a/frontend/src/lib/services/project-service.ts b/frontend/src/lib/services/project-service.ts
index 4618f17d7..9e2b30c20 100644
--- a/frontend/src/lib/services/project-service.ts
+++ b/frontend/src/lib/services/project-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import { environmentStore } from '$lib/stores/environment.store';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Project, ProjectStatusCounts } from '$lib/types/project.type';
import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
import { transformPaginationParams } from '$lib/utils/params.util';
diff --git a/frontend/src/lib/services/settings-service.ts b/frontend/src/lib/services/settings-service.ts
index 95b709d87..207e05222 100644
--- a/frontend/src/lib/services/settings-service.ts
+++ b/frontend/src/lib/services/settings-service.ts
@@ -1,6 +1,6 @@
import BaseAPIService from './api-service';
import type { Settings, OidcStatusInfo } from '$lib/types/settings.type';
-import { environmentStore } from '$lib/stores/environment.store';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
type KeyValuePair = { key: string; value: string };
diff --git a/frontend/src/lib/services/system-service.ts b/frontend/src/lib/services/system-service.ts
index 42a4d2b56..9d2785d49 100644
--- a/frontend/src/lib/services/system-service.ts
+++ b/frontend/src/lib/services/system-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import { environmentStore } from '$lib/stores/environment.store';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { DockerInfo } from '$lib/types/docker-info.type';
export class SystemService extends BaseAPIService {
diff --git a/frontend/src/lib/services/volume-service.ts b/frontend/src/lib/services/volume-service.ts
index 8e54323d9..2ed18e3b2 100644
--- a/frontend/src/lib/services/volume-service.ts
+++ b/frontend/src/lib/services/volume-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import { environmentStore } from '$lib/stores/environment.store';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { VolumeSummaryDto, VolumeDetailDto, VolumeUsageDto, VolumeUsageCounts } from '$lib/types/volume.type';
import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
import type { VolumeCreateOptions } from 'dockerode';
diff --git a/frontend/src/lib/stores/environment.store.ts b/frontend/src/lib/stores/environment.store.svelte.ts
similarity index 58%
rename from frontend/src/lib/stores/environment.store.ts
rename to frontend/src/lib/stores/environment.store.svelte.ts
index aa6d0c5f7..a3a816bab 100644
--- a/frontend/src/lib/stores/environment.store.ts
+++ b/frontend/src/lib/stores/environment.store.svelte.ts
@@ -1,4 +1,4 @@
-import { writable, get } from 'svelte/store';
+import { PersistedState } from 'runed';
import { invalidateAll } from '$app/navigation';
import type { Environment } from '$lib/types/environment.type';
@@ -16,16 +16,19 @@ export const localDockerEnvironment: Environment = {
};
function createEnvironmentManagementStore() {
- const _selectedEnvironment = writable<Environment | null>(null);
- const _availableEnvironments = writable<Environment[]>([]);
+ const selectedEnvironmentId = new PersistedState<string | null>('selectedEnvironmentId', null);
+
+ let _selectedEnvironment = $state<Environment | null>(null);
+ let _availableEnvironments = $state<Environment[]>([]);
let _initialized = false;
+ let _initializedWithData = false;
let _resolveReadyPromiseFunction: () => void;
const _readyPromise = new Promise<void>((resolve) => {
_resolveReadyPromiseFunction = resolve;
});
- function _updateAvailable(environments: Environment[], hasLocalDocker: boolean) {
+ function _updateAvailable(environments: Environment[], hasLocalDocker: boolean): Environment[] {
const newAvailable: Environment[] = [];
if (hasLocalDocker) {
@@ -33,75 +36,68 @@ function createEnvironmentManagementStore() {
}
newAvailable.push(...environments.map((env) => ({ ...env, isLocal: false })));
- _availableEnvironments.set(newAvailable);
+ _availableEnvironments = newAvailable;
return newAvailable;
}
- function _getSavedEnvironmentId(): string | null {
- if (localStorage) {
- return localStorage.getItem('selectedEnvironmentId');
- }
- return null;
- }
-
function _selectInitialEnvironment(available: Environment[]): Environment | null {
- const savedId = _getSavedEnvironmentId();
+ const savedId = selectedEnvironmentId.current;
if (savedId) {
const found = available.find((env) => env.id === savedId);
if (found) {
- _selectedEnvironment.set(found);
+ _selectedEnvironment = found;
return found;
}
}
- if (available.includes(localDockerEnvironment)) {
- _selectedEnvironment.set(localDockerEnvironment);
+ if (available.some((env) => env.id === localDockerEnvironment.id)) {
+ _selectedEnvironment = localDockerEnvironment;
return localDockerEnvironment;
}
if (available.length > 0) {
- _selectedEnvironment.set(available[0]);
+ _selectedEnvironment = available[0];
return available[0];
}
- _selectedEnvironment.set(null);
+ _selectedEnvironment = null;
return null;
}
return {
- selected: {
- subscribe: _selectedEnvironment.subscribe
+ get selected(): Environment | null {
+ return _selectedEnvironment;
},
- available: {
- subscribe: _availableEnvironments.subscribe
+ get available(): Environment[] {
+ return _availableEnvironments;
},
initialize: async (environmentsData: Environment[], hasLocalDocker: boolean) => {
const available = _updateAvailable(environmentsData, hasLocalDocker);
+ const hasRealEnvironments = environmentsData.length > 0;
if (!_initialized) {
_selectInitialEnvironment(available);
_initialized = true;
+ if (hasRealEnvironments) {
+ _initializedWithData = true;
+ }
_resolveReadyPromiseFunction();
+ } else if (hasRealEnvironments && !_initializedWithData) {
+ _selectInitialEnvironment(available);
+ _initializedWithData = true;
} else {
- const currentSelected = get(_selectedEnvironment);
- if (currentSelected && !available.find((env) => env.id === currentSelected.id)) {
+ if (_selectedEnvironment && !available.find((env) => env.id === _selectedEnvironment!.id)) {
_selectInitialEnvironment(available);
- } else if (!currentSelected && available.length > 0) {
+ } else if (!_selectedEnvironment && available.length > 0) {
_selectInitialEnvironment(available);
}
}
},
setEnvironment: async (environment: Environment) => {
- const currentSelected = get(_selectedEnvironment);
-
- if (currentSelected?.id !== environment.id) {
- _selectedEnvironment.set(environment);
-
- if (localStorage) {
- localStorage.setItem('selectedEnvironmentId', environment.id);
- }
-
+ if (_selectedEnvironment?.id !== environment.id) {
+ _selectedEnvironment = environment;
+ selectedEnvironmentId.current = environment.id;
await invalidateAll();
}
},
@@ -110,8 +106,7 @@ function createEnvironmentManagementStore() {
ready: _readyPromise,
getCurrentEnvironmentId: async (): Promise<string> => {
await _readyPromise;
- const current = get(_selectedEnvironment);
- return current ? current.id : LOCAL_DOCKER_ENVIRONMENT_ID;
+ return _selectedEnvironment ? _selectedEnvironment.id : LOCAL_DOCKER_ENVIRONMENT_ID;
}
};
}
diff --git a/frontend/src/routes/+layout.ts b/frontend/src/routes/+layout.ts
index 74fbc676f..f7bc38bc7 100644
--- a/frontend/src/routes/+layout.ts
+++ b/frontend/src/routes/+layout.ts
@@ -1,4 +1,4 @@
-import { environmentStore } from '$lib/stores/environment.store';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
import versionService from '$lib/services/version-service';
import { tryCatch } from '$lib/utils/try-catch';
import userStore from '$lib/stores/user-store';
diff --git a/frontend/src/routes/containers/+page.svelte b/frontend/src/routes/containers/+page.svelte
index cb2130762..ea28e96be 100644
--- a/frontend/src/routes/containers/+page.svelte
+++ b/frontend/src/routes/containers/+page.svelte
@@ -7,7 +7,7 @@
import { containerService } from '$lib/services/container-service';
import ContainerTable from './container-table.svelte';
import { m } from '$lib/paraglide/messages';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Environment } from '$lib/types/environment.type';
import { imageService } from '$lib/services/image-service';
import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
@@ -74,7 +74,7 @@
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
- const env = $selectedEnvStore as Environment | null;
+ const env = selectedEnvStore as Environment | null;
if (!env) return;
if (lastEnvId === null) {
lastEnvId = env.id;
diff --git a/frontend/src/routes/containers/[containerId]/+page.svelte b/frontend/src/routes/containers/[containerId]/+page.svelte
index d3e1f6d94..e3f758bbd 100644
--- a/frontend/src/routes/containers/[containerId]/+page.svelte
+++ b/frontend/src/routes/containers/[containerId]/+page.svelte
@@ -33,7 +33,7 @@
import ContainerLogsPanel from '../components/ContainerLogsPanel.svelte';
import ContainerShell from '../components/ContainerShell.svelte';
import { createContainerStatsWebSocket, type ReconnectingWebSocket } from '$lib/utils/ws';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
let { data } = $props();
let container = $derived(data?.container as ContainerDetailsDto);
diff --git a/frontend/src/routes/containers/components/ContainerShell.svelte b/frontend/src/routes/containers/components/ContainerShell.svelte
index f58387198..53366529e 100644
--- a/frontend/src/routes/containers/components/ContainerShell.svelte
+++ b/frontend/src/routes/containers/components/ContainerShell.svelte
@@ -4,7 +4,7 @@
import TerminalControls from '$lib/components/terminal/terminal-controls.svelte';
import TerminalIcon from '@lucide/svelte/icons/terminal';
import { m } from '$lib/paraglide/messages';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import settingsStore from '$lib/stores/config-store';
let {
diff --git a/frontend/src/routes/dashboard/+page.svelte b/frontend/src/routes/dashboard/+page.svelte
index 59edd33e3..fd2132af7 100644
--- a/frontend/src/routes/dashboard/+page.svelte
+++ b/frontend/src/routes/dashboard/+page.svelte
@@ -7,8 +7,7 @@
import { tryCatch } from '$lib/utils/try-catch';
import { openConfirmDialog } from '$lib/components/confirm-dialog';
import { onMount } from 'svelte';
- import { get } from 'svelte/store';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import { createStatsWebSocket } from '$lib/utils/ws';
import type { ReconnectingWebSocket } from '$lib/utils/ws';
import MeterMetric from '$lib/components/meter-metric.svelte';
@@ -148,7 +147,7 @@
}
const getEnvId = () => {
- const env = get(environmentStore.selected);
+ const env = environmentStore.selected;
return env ? env.id : '0';
};
@@ -174,17 +173,15 @@
}
$effect(() => {
- const unsubscribe = environmentStore.selected.subscribe(async (env) => {
- if (!env) return;
- if (statsWSClient) {
- statsWSClient.close();
- statsWSClient = null;
- resetStats();
- setupStatsWS();
- await refreshData();
- }
- });
- return () => unsubscribe();
+ const env = environmentStore.selected;
+ if (!env) return;
+ if (statsWSClient) {
+ statsWSClient.close();
+ statsWSClient = null;
+ resetStats();
+ setupStatsWS();
+ refreshData();
+ }
});
async function handleStartAll() {
diff --git a/frontend/src/routes/environments/[id]/+page.svelte b/frontend/src/routes/environments/[id]/+page.svelte
index 2fee2e6c9..d520c8070 100644
--- a/frontend/src/routes/environments/[id]/+page.svelte
+++ b/frontend/src/routes/environments/[id]/+page.svelte
@@ -14,21 +14,14 @@
import Label from '$lib/components/ui/label/label.svelte';
import { m } from '$lib/paraglide/messages';
import { environmentManagementService } from '$lib/services/env-mgmt-service.js';
- import { environmentStore } from '$lib/stores/environment.store';
- import type { Environment } from '$lib/types/environment.type';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
let { data } = $props();
let { environment, settings } = $derived(data);
let showSwitchDialog = $state(false);
- let currentEnvironment = $state<Environment | null>(null);
- $effect(() => {
- const unsubscribe = environmentStore.selected.subscribe((env) => {
- currentEnvironment = env;
- });
- return unsubscribe;
- });
+ let currentEnvironment = $derived(environmentStore.selected);
let isRefreshing = $state(false);
let isTestingConnection = $state(false);
@@ -156,7 +149,7 @@
<div class="lg:col-span-1">
<Card.Root class="flex flex-col gap-6 py-3">
<Card.Header
- class="@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6"
+ class="@container/card-header has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6 grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6"
>
<Card.Title class="text-lg">{m.environments_sections_title()}</Card.Title>
</Card.Header>
@@ -185,7 +178,7 @@
<div class="space-y-6">
<Card.Root class="flex flex-col gap-6 py-3">
<Card.Header
- class="@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6"
+ class="@container/card-header has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6 grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6"
>
<Card.Title class="flex items-center gap-2">
<MonitorIcon class="size-5" />
@@ -400,7 +393,7 @@
<div class="space-y-6">
<Card.Root class="flex flex-col gap-6 py-3">
<Card.Header
- class="@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6"
+ class="@container/card-header has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6 grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6"
>
<Card.Title class="flex items-center gap-2">
<GlobeIcon class="h-5 w-5" />
@@ -414,7 +407,7 @@
</div>
<div>
<Label class="text-muted-foreground text-sm font-medium">{m.environments_api_url()}</Label>
- <div class="bg-muted mt-1 rounded-md px-3 py-2 font-mono text-sm break-all">{environment.apiUrl}</div>
+ <div class="bg-muted mt-1 break-all rounded-md px-3 py-2 font-mono text-sm">{environment.apiUrl}</div>
</div>
<div class="pt-4">
<Button onclick={testConnection} disabled={isTestingConnection} class="w-full">
@@ -434,7 +427,7 @@
<div class="space-y-6">
<Card.Root class="flex flex-col gap-6 py-3">
<Card.Header
- class="@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6"
+ class="@container/card-header has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6 grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6"
>
<Card.Title class="flex items-center gap-2">
<SettingsIcon class="h-5 w-5" />
@@ -473,7 +466,7 @@
</div>
{#if isRefreshing}
- <div class="fixed right-4 bottom-4 flex items-center gap-2 rounded-lg bg-blue-600 px-3 py-2 text-white shadow-lg">
+ <div class="fixed bottom-4 right-4 flex items-center gap-2 rounded-lg bg-blue-600 px-3 py-2 text-white shadow-lg">
<RefreshCwIcon class="h-4 w-4 animate-spin" />
<span class="text-sm">{m.environments_refreshing()}</span>
</div>
diff --git a/frontend/src/routes/environments/[id]/+page.ts b/frontend/src/routes/environments/[id]/+page.ts
index fe3a87df4..26d01e05c 100644
--- a/frontend/src/routes/environments/[id]/+page.ts
+++ b/frontend/src/routes/environments/[id]/+page.ts
@@ -1,6 +1,5 @@
import { environmentManagementService } from '$lib/services/env-mgmt-service';
import { settingsService } from '$lib/services/settings-service';
-import { environmentStore } from '$lib/stores/environment.store';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params }) => {
diff --git a/frontend/src/routes/images/+page.svelte b/frontend/src/routes/images/+page.svelte
index 8967fbeee..b494c2788 100644
--- a/frontend/src/routes/images/+page.svelte
+++ b/frontend/src/routes/images/+page.svelte
@@ -12,7 +12,7 @@
import ImageTable from './image-table.svelte';
import { m } from '$lib/paraglide/messages';
import { imageService } from '$lib/services/image-service';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Environment } from '$lib/types/environment.type';
import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
@@ -91,7 +91,7 @@
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
- const env = $selectedEnvStore as Environment | null;
+ const env = selectedEnvStore as Environment | null;
if (!env) return;
if (lastEnvId === null) {
lastEnvId = env.id;
diff --git a/frontend/src/routes/networks/+page.svelte b/frontend/src/routes/networks/+page.svelte
index f42f4c5f9..f158c94d7 100644
--- a/frontend/src/routes/networks/+page.svelte
+++ b/frontend/src/routes/networks/+page.svelte
@@ -9,7 +9,7 @@
import NetworkTable from './network-table.svelte';
import { m } from '$lib/paraglide/messages';
import { networkService } from '$lib/services/network-service';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Environment } from '$lib/types/environment.type';
import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
@@ -73,7 +73,7 @@
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
- const env = $selectedEnvStore as Environment | null;
+ const env = selectedEnvStore as Environment | null;
if (!env) return;
if (lastEnvId === null) {
lastEnvId = env.id;
diff --git a/frontend/src/routes/projects/+page.svelte b/frontend/src/routes/projects/+page.svelte
index 7d76e771a..387f07d9e 100644
--- a/frontend/src/routes/projects/+page.svelte
+++ b/frontend/src/routes/projects/+page.svelte
@@ -10,7 +10,7 @@
import { m } from '$lib/paraglide/messages';
import { projectService } from '$lib/services/project-service';
import { imageService } from '$lib/services/image-service';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Environment } from '$lib/types/environment.type';
import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
@@ -72,7 +72,7 @@
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
- const env = $selectedEnvStore as Environment | null;
+ const env = selectedEnvStore as Environment | null;
if (!env) return;
if (lastEnvId === null) {
lastEnvId = env.id;
diff --git a/frontend/src/routes/volumes/+page.svelte b/frontend/src/routes/volumes/+page.svelte
index 32bb0e917..7a5ac7559 100644
--- a/frontend/src/routes/volumes/+page.svelte
+++ b/frontend/src/routes/volumes/+page.svelte
@@ -10,7 +10,7 @@
import VolumeTable from './volume-table.svelte';
import { m } from '$lib/paraglide/messages';
import { volumeService } from '$lib/services/volume-service';
- import { environmentStore } from '$lib/stores/environment.store';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Environment } from '$lib/types/environment.type';
import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
@@ -77,7 +77,7 @@
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
- const env = $selectedEnvStore as Environment | null;
+ const env = selectedEnvStore as Environment | null;
if (!env) return;
if (lastEnvId === null) {
lastEnvId = env.id;