Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: lazy load all resources
Kyle Mendell066eadcd64ff
diff --git a/Dockerfile b/Dockerfileindex aad4d0445..b74a42863 100644--- a/Dockerfile+++ b/Dockerfile@@ -35,37 +35,30 @@ RUN CGO_ENABLED=1 \./cmd/main.go# Stage 3: Production Image-FROM alpine:latest AS runner+FROM alpine:3.21 AS runner-# Install runtime dependencies-RUN apk upgrade && apk --no-cache add ca-certificates tzdata curl shadow su-exec+RUN apk upgrade && apk --no-cache add ca-certificates tzdata curl shadow su-exec docker docker-composeRUN delgroup ping && apk del iputils-# Set up environment variablesENV DOCKER_GID=998 PUID=2000 PGID=2000ENV GIN_MODE=releaseENV PORT=8080WORKDIR /app-# Create necessary directoriesRUN mkdir -p /app/data && chmod 755 /app/data-# Copy the binary from builderCOPY --from=backend-builder /build/arcane .-# Copy entrypoint scriptCOPY --chmod=755 scripts/docker/entrypoint.sh /usr/local/bin/entrypoint.sh-# Configure containerEXPOSE 8080VOLUME ["/app/data"]ARG VERSION="0.15.1"ARG REVISION="c052902"-# Add OCI standard labelsLABEL org.opencontainers.image.authors="OFKM Technologies"LABEL org.opencontainers.image.url="https://github.com/ofkm/arcane"LABEL org.opencontainers.image.documentation="https://github.com/ofkm/arcane/blob/main/README.md"@@ -75,8 +68,7 @@ LABEL org.opencontainers.image.revision=$REVISIONLABEL org.opencontainers.image.licenses="BSD-3-Clause"LABEL org.opencontainers.image.ref.name="arcane"LABEL org.opencontainers.image.title="Arcane"-LABEL org.opencontainers.image.description="Simple and Elegant Docker Management UI with Go backend and SvelteKit frontend"+LABEL org.opencontainers.image.description="Modern Docker Management, Made for Everyone"-# Set the entrypoint and commandENTRYPOINT ["/usr/local/bin/entrypoint.sh"]CMD ["./arcane"]\ No newline at end of filediff --git a/backend/internal/api/stack_handler.go b/backend/internal/api/stack_handler.goindex de2895084..e1efe9a5d 100644--- a/backend/internal/api/stack_handler.go+++ b/backend/internal/api/stack_handler.go@@ -38,37 +38,20 @@ func (h *StackHandler) ListStacks(c *gin.Context) {var stackList []map[string]interface{}for _, stack := range stacks {- services, err := h.stackService.GetStackServices(c.Request.Context(), stack.ID)- var serviceCount, runningCount int- if err != nil {- fmt.Printf("Warning: failed to get services for stack %s: %v\n", stack.ID, err)- serviceCount = stack.ServiceCount- runningCount = stack.RunningCount- services = nil- } else {- serviceCount = len(services)- runningCount = 0- for _, service := range services {- if service.Status == "running" {- runningCount++- }- }- }-stackResponse := map[string]interface{}{"id": stack.ID,"name": stack.Name,"path": stack.Path,"status": stack.Status,- "serviceCount": serviceCount,- "runningCount": runningCount,+ "serviceCount": stack.ServiceCount,+ "runningCount": stack.RunningCount,"createdAt": stack.CreatedAt,"updatedAt": stack.UpdatedAt,"autoUpdate": stack.AutoUpdate,"isExternal": stack.IsExternal,"isLegacy": stack.IsLegacy,"isRemote": stack.IsRemote,- "services": services,+ "services": nil, // Services are not fetched in the list view for performance.}stackList = append(stackList, stackResponse)}diff --git a/backend/internal/database/database.go b/backend/internal/database/database.goindex 09c57ac70..e10595bf3 100644--- a/backend/internal/database/database.go+++ b/backend/internal/database/database.go@@ -46,12 +46,12 @@ func Initialize(databaseURL string, environment string) (*DB, error) {}gormLogger := logger.New(- log.New(os.Stdout, "\r\n", log.LstdFlags), // io writer+ log.New(os.Stdout, "\r\n", log.LstdFlags),logger.Config{- SlowThreshold: time.Second, // Slow SQL threshold- LogLevel: logLevel, // Log level based on environment- IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger- Colorful: environment == "development", // Enable color in development+ SlowThreshold: time.Second,+ LogLevel: logLevel,+ IgnoreRecordNotFoundError: true,+ Colorful: environment == "development",},)@@ -60,12 +60,22 @@ func Initialize(databaseURL string, environment string) (*DB, error) {NowFunc: func() time.Time {return time.Now().UTC()},+ PrepareStmt: true,})if err != nil {return nil, fmt.Errorf("failed to connect to database: %w", err)}+ sqlDB, err := db.DB()+ if err != nil {+ return nil, fmt.Errorf("failed to get underlying sql.DB: %w", err)+ }++ sqlDB.SetMaxIdleConns(10)+ sqlDB.SetMaxOpenConns(100)+ sqlDB.SetConnMaxLifetime(time.Hour)+return &DB{db}, nil}diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelteindex 71a78d888..a4ebb3c0d 100644--- a/frontend/src/routes/+page.svelte+++ b/frontend/src/routes/+page.svelte@@ -3,19 +3,35 @@import * as Card from '$lib/components/ui/card/index.js';import { Button } from '$lib/components/ui/button/index.js';import UniversalTable from '$lib/components/universal-table.svelte';- import { AlertCircle, Box, HardDrive, Cpu, ArrowRight, PlayCircle, StopCircle, Trash2, RefreshCw, Loader2, Monitor } from '@lucide/svelte';+ import {+ AlertCircle,+ Box,+ HardDrive,+ Cpu,+ ArrowRight,+ PlayCircle,+ StopCircle,+ Trash2,+ RefreshCw,+ Loader2,+ Monitor+ } from '@lucide/svelte';import * as Alert from '$lib/components/ui/alert/index.js';- import { capitalizeFirstLetter, truncateString, shortId, parseStatusTime } from '$lib/utils/string.utils';+ import {+ capitalizeFirstLetter,+ truncateString,+ shortId,+ parseStatusTime+ } from '$lib/utils/string.utils';import { formatBytes } from '$lib/utils/bytes.util';import StatusBadge from '$lib/components/badges/status-badge.svelte';- import { invalidateAll } from '$app/navigation';import { toast } from 'svelte-sonner';import PruneConfirmationDialog from '$lib/components/dialogs/prune-confirmation-dialog.svelte';import * as Table from '$lib/components/ui/table';import { statusVariantMap } from '$lib/types/statuses';import { handleApiResultWithCallbacks } from '$lib/utils/api.util';import { tryCatch } from '$lib/utils/try-catch';- import { systemAPI, imageAPI, environmentAPI } from '$lib/services/api';+ import { systemAPI, imageAPI, environmentAPI, settingsAPI } from '$lib/services/api';import { openConfirmDialog } from '$lib/components/confirm-dialog';import MaturityItem from '$lib/components/maturity-item.svelte';import { onMount } from 'svelte';@@ -27,6 +43,7 @@import GitHubIcon from '$lib/icons/github-icon.svelte';import type { SystemStats } from '$lib/models/system-stats';import type { ContainerInfo, EnhancedContainerInfo } from '$lib/models/container-info';+ import type { Settings } from '$lib/types/settings.type';type EnhancedImageInfo = {Id: string;@@ -48,12 +65,12 @@let { data }: { data: PageData } = $props();let dashboardStates = $state({- dockerInfo: data.dockerInfo as any,- containers: data.containers as ContainerInfo[] | null,- images: data.images as EnhancedImageInfo[],- settings: data.settings,+ dockerInfo: null as any,+ containers: null as ContainerInfo[] | null,+ images: [] as EnhancedImageInfo[],+ settings: null as Settings | null,systemStats: null as SystemStats | null,- error: data.error,+ error: null as string | null,isPruneDialogOpen: false});@@ -62,36 +79,70 @@stopping: false,refreshing: false,pruning: false,- loadingStats: true+ loadingStats: true,+ loadingMaturity: true,+ loadingData: true});let liveSystemStats = $state(null as SystemStats | null);let statsInterval: NodeJS.Timeout | null = null;- const runningContainers = $derived(dashboardStates.containers?.filter((c: ContainerInfo) => c.State === 'running').length ?? 0);+ const runningContainers = $derived(+ dashboardStates.containers?.filter((c: ContainerInfo) => c.State === 'running').length ?? 0+ );- const stoppedContainers = $derived(dashboardStates.containers?.filter((c: ContainerInfo) => c.State === 'exited').length ?? 0);+ const stoppedContainers = $derived(+ dashboardStates.containers?.filter((c: ContainerInfo) => c.State === 'exited').length ?? 0+ );- const totalImageSize = $derived(dashboardStates.images?.reduce((sum, image) => sum + (image.Size || 0), 0) ?? 0);+ const totalImageSize = $derived(+ dashboardStates.images?.reduce((sum, image) => sum + (image.Size || 0), 0) ?? 0+ );- const containerUsagePercent = $derived(dashboardStates.containers?.length ? (runningContainers / dashboardStates.containers.length) * 100 : 0);+ const containerUsagePercent = $derived(+ dashboardStates.containers?.length+ ? (runningContainers / dashboardStates.containers.length) * 100+ : 0+ );const currentStats = $derived(dashboardStates.systemStats || liveSystemStats);function getContainerDisplayName(container: ContainerInfo): string {if (container.Names && container.Names.length > 0) {- return container.Names[0].startsWith('/') ? container.Names[0].substring(1) : container.Names[0];+ return container.Names[0].startsWith('/')+ ? container.Names[0].substring(1)+ : container.Names[0];}return shortId(container.Id);}- $effect(() => {- dashboardStates.dockerInfo = data.dockerInfo;- dashboardStates.containers = data.containers as ContainerInfo[] | null;- dashboardStates.images = data.images as EnhancedImageInfo[];- dashboardStates.settings = data.settings;- dashboardStates.error = data.error;- });+ async function loadInitialData() {+ try {+ isLoading.loadingData = true;++ const [dockerInfoResult, containersResult, imagesResult, settingsResult] =+ await Promise.allSettled([+ systemAPI.getDockerInfo(),+ environmentAPI.getContainers(),+ environmentAPI.getImages(),+ settingsAPI.getSettings()+ ]);++ dashboardStates.dockerInfo =+ dockerInfoResult.status === 'fulfilled' ? dockerInfoResult.value : null;+ dashboardStates.containers =+ containersResult.status === 'fulfilled' ? containersResult.value : [];+ dashboardStates.images = imagesResult.status === 'fulfilled' ? imagesResult.value : [];+ dashboardStates.settings =+ settingsResult.status === 'fulfilled' ? settingsResult.value : null;+ dashboardStates.error = null;+ } catch (err) {+ console.error('Error loading dashboard data:', err);+ dashboardStates.error = err instanceof Error ? err.message : 'Failed to load dashboard data';+ } finally {+ isLoading.loadingData = false;+ }+ }async function fetchLiveSystemStats() {try {@@ -99,12 +150,10 @@let stats: SystemStats | null = null;- // Handle different response formatsif (response && typeof response === 'object') {if ('success' in response && response.success && 'data' in response) {stats = response.data as SystemStats;} else if ('cpuUsage' in response) {- // Direct stats objectstats = response as SystemStats;}}@@ -123,26 +172,65 @@}}+ async function loadTopImagesMaturity() {+ if (!dashboardStates.images || dashboardStates.images.length === 0) {+ isLoading.loadingMaturity = false;+ return;+ }++ const topImageIds = [...dashboardStates.images]+ .sort((a, b) => (b.Size || 0) - (a.Size || 0))+ .slice(0, 5)+ .filter((img) => img.repo !== '<none>' && img.tag !== '<none>')+ .map((img) => img.Id);++ if (topImageIds.length === 0) {+ isLoading.loadingMaturity = false;+ return;+ }++ try {+ const BATCH_SIZE = 1;+ for (let i = 0; i < topImageIds.length; i += BATCH_SIZE) {+ const batch = topImageIds.slice(i, i + BATCH_SIZE);+ await imageAPI.checkMaturityBatch(batch);++ dashboardStates.images = dashboardStates.images.map((image) => {+ const storedMaturity = $maturityStore.maturityData[image.Id];+ return {+ ...image,+ maturity: storedMaturity !== undefined ? storedMaturity : image.maturity+ };+ });++ if (i + BATCH_SIZE < topImageIds.length) {+ await new Promise((resolve) => setTimeout(resolve, 100));+ }+ }+ } catch (error) {+ console.error('Error loading maturity data for dashboard images:', error);+ } finally {+ isLoading.loadingMaturity = false;+ }+ }+onMount(() => {let mounted = true;- (async () => {+ Promise.all([loadInitialData(), fetchLiveSystemStats()]).then(() => {if (mounted) {- await fetchLiveSystemStats();- await loadTopImagesMaturity();+ loadTopImagesMaturity();}- })();+ });- // Set up the intervalif (!statsInterval) {statsInterval = setInterval(() => {if (mounted) {fetchLiveSystemStats();}- }, 3000);+ }, 5000);}- // Cleanup functionreturn () => {mounted = false;if (statsInterval) {@@ -156,8 +244,7 @@if (isLoading.refreshing) return;isLoading.refreshing = true;try {- await invalidateAll();- await fetchLiveSystemStats();+ await Promise.all([loadInitialData(), fetchLiveSystemStats()]);} catch (err) {console.error('Error during dashboard refresh:', err);dashboardStates.error = 'Failed to refresh dashboard data.';@@ -175,7 +262,7 @@setLoadingState: (value) => (isLoading.starting = value),onSuccess: async () => {toast.success('All Containers Started Successfully.');- await invalidateAll();+ await loadInitialData();}});}@@ -195,7 +282,7 @@setLoadingState: (value) => (isLoading.stopping = value),onSuccess: async () => {toast.success('All Containers Stopped Successfully.');- await invalidateAll();+ await loadInitialData();}});}@@ -222,45 +309,13 @@onSuccess: async () => {dashboardStates.isPruneDialogOpen = false;const formattedTypes = selectedTypes.map((type) => capitalizeFirstLetter(type)).join(', ');- toast.success(`${formattedTypes} ${selectedTypes.length > 1 ? 'were' : 'was'} pruned successfully.`);- await invalidateAll();+ toast.success(+ `${formattedTypes} ${selectedTypes.length > 1 ? 'were' : 'was'} pruned successfully.`+ );+ await loadInitialData();}});}-- async function loadTopImagesMaturity() {- if (!dashboardStates.images || dashboardStates.images.length === 0) return;-- const topImageIds = [...dashboardStates.images]- .sort((a, b) => (b.Size || 0) - (a.Size || 0))- .slice(0, 5)- .filter((img) => img.repo !== '<none>' && img.tag !== '<none>')- .map((img) => img.Id);-- if (topImageIds.length === 0) return;-- try {- const BATCH_SIZE = 2;- for (let i = 0; i < topImageIds.length; i += BATCH_SIZE) {- const batch = topImageIds.slice(i, i + BATCH_SIZE);- await imageAPI.checkMaturityBatch(batch);-- dashboardStates.images = dashboardStates.images.map((image) => {- const storedMaturity = $maturityStore.maturityData[image.Id];- return {- ...image,- maturity: storedMaturity !== undefined ? storedMaturity : image.maturity- };- });-- if (i + BATCH_SIZE < topImageIds.length) {- await new Promise((resolve) => setTimeout(resolve, 50));- }- }- } catch (error) {- console.error('Error loading maturity data for dashboard images:', error);- }- }</script><div class="space-y-8">@@ -269,7 +324,16 @@<h1 class="text-3xl font-bold tracking-tight">Dashboard</h1><p class="text-muted-foreground mt-1 text-sm">Overview of your Container Environment</p></div>- <Button variant="outline" size="sm" class="arcane-button-restart h-9" onclick={refreshData} disabled={isLoading.refreshing || isLoading.starting || isLoading.stopping || isLoading.pruning}>+ <Button+ variant="outline"+ size="sm"+ class="arcane-button-restart h-9"+ onclick={refreshData}+ disabled={isLoading.refreshing ||+ isLoading.starting ||+ isLoading.stopping ||+ isLoading.pruning}+ >{#if isLoading.refreshing}<Loader2 class="mr-2 size-4 animate-spin" />{:else}@@ -290,419 +354,574 @@</Alert.Root>{/if}- <section>- <DropdownCard id="system-overview" title="System Overview" description="Hardware and Docker engine information" icon={Monitor} defaultExpanded={true}>- <div class="grid grid-cols-1 gap-6 md:grid-cols-3">- <!-- Containers & Docker Info Card -->- <Card.Root class="overflow-hidden">- <Card.Content class="p-6">- <div class="mb-4 flex items-center justify-between">- <div class="flex items-center gap-3">- <div class="rounded-lg bg-green-500/10 p-2.5">- <Box class="size-5 text-green-500" />- </div>- <div>- <p class="text-muted-foreground text-sm font-medium">Containers</p>- <p class="text-2xl font-bold">- {runningContainers}- <span class="text-muted-foreground text-sm font-normal">/ {dashboardStates.containers?.length || 0}</span>- </p>- </div>- </div>- </div>+ {#if isLoading.loadingData}+ <div class="space-y-8">+ <div class="bg-muted h-8 w-48 animate-pulse rounded"></div>- {#if dashboardStates.containers?.length}- <div class="mb-6">- <Meter label="Active Containers" valueLabel="{runningContainers} running" value={runningContainers} max={dashboardStates.containers.length} variant={containerUsagePercent > 80 ? 'warning' : 'success'} size="sm" />+ <Card.Root>+ <Card.Content class="p-6">+ <div class="grid grid-cols-1 gap-6 md:grid-cols-3">+ {#each Array(3) as _}+ <div class="space-y-4">+ <div class="bg-muted h-4 w-32 animate-pulse rounded"></div>+ <div class="bg-muted h-8 w-16 animate-pulse rounded"></div>+ <div class="bg-muted h-2 w-full animate-pulse rounded"></div></div>- {/if}+ {/each}+ </div>+ </Card.Content>+ </Card.Root>++ <div class="grid grid-cols-1 gap-5 sm:grid-cols-3">+ {#each Array(3) as _}+ <div class="bg-card flex flex-col items-center rounded-xl border p-6">+ <div class="bg-muted mb-4 size-12 animate-pulse rounded-full"></div>+ <div class="bg-muted h-4 w-24 animate-pulse rounded"></div>+ <div class="bg-muted mt-2 h-3 w-16 animate-pulse rounded"></div>+ </div>+ {/each}+ </div>- <!-- Docker Engine Info -->- <div class="space-y-3 border-t pt-4">- <div class="flex items-center gap-2">- <DockerIcon class="text-muted-foreground size-4" />- <p class="text-muted-foreground text-sm font-medium">Docker Engine</p>+ <div class="grid grid-cols-1 gap-6 lg:grid-cols-2">+ {#each Array(2) as _}+ <Card.Root>+ <Card.Header class="px-6">+ <div class="bg-muted h-6 w-32 animate-pulse rounded"></div>+ <div class="bg-muted h-4 w-24 animate-pulse rounded"></div>+ </Card.Header>+ <Card.Content>+ <div class="flex flex-col items-center justify-center px-6 py-12 text-center">+ <Loader2 class="text-muted-foreground mb-4 size-8 animate-spin" />+ <p class="text-lg font-medium">Loading data...</p></div>- <div class="grid grid-cols-2 gap-3 text-xs">- <div>- <p class="text-muted-foreground">Version</p>- <p class="font-medium">{dashboardStates.dockerInfo?.version || 'Unknown'}</p>- </div>- <div>- <p class="text-muted-foreground">OS</p>- <p class="font-medium">- {dashboardStates.dockerInfo?.os || dashboardStates.systemStats?.platform || 'Unknown'}- </p>+ </Card.Content>+ </Card.Root>+ {/each}+ </div>+ </div>+ {:else}+ <section>+ <DropdownCard+ id="system-overview"+ title="System Overview"+ description="Hardware and Docker engine information"+ icon={Monitor}+ defaultExpanded={true}+ >+ <div class="grid grid-cols-1 gap-6 md:grid-cols-3">+ <Card.Root class="overflow-hidden">+ <Card.Content class="p-6">+ <div class="mb-4 flex items-center justify-between">+ <div class="flex items-center gap-3">+ <div class="rounded-lg bg-green-500/10 p-2.5">+ <Box class="size-5 text-green-500" />+ </div>+ <div>+ <p class="text-muted-foreground text-sm font-medium">Containers</p>+ <p class="text-2xl font-bold">+ {runningContainers}+ <span class="text-muted-foreground text-sm font-normal"+ >/ {dashboardStates.containers?.length || 0}</span+ >+ </p>+ </div></div></div>- </div>- </Card.Content>- </Card.Root>- <!-- Images & System Storage Card -->- <Card.Root class="overflow-hidden">- <Card.Content class="p-6">- <div class="mb-4 flex items-center justify-between">- <div class="flex items-center gap-3">- <div class="rounded-lg bg-blue-500/10 p-2.5">- <HardDrive class="size-5 text-blue-500" />+ {#if dashboardStates.containers?.length}+ <div class="mb-6">+ <Meter+ label="Active Containers"+ valueLabel="{runningContainers} running"+ value={runningContainers}+ max={dashboardStates.containers.length}+ variant={containerUsagePercent > 80 ? 'warning' : 'success'}+ size="sm"+ /></div>- <div>- <p class="text-muted-foreground text-sm font-medium">Storage</p>- <p class="text-2xl font-bold">{dashboardStates.dockerInfo?.images || 0}</p>- <p class="text-muted-foreground text-xs">Docker images</p>- </div>- </div>- </div>+ {/if}- {#if isLoading.loadingStats}- <div class="py-6 text-center">- <Loader2 class="text-muted-foreground mx-auto mb-2 size-6 animate-spin" />- <p class="text-muted-foreground text-sm">Loading storage data...</p>+ <div class="space-y-3 border-t pt-4">+ <div class="flex items-center gap-2">+ <DockerIcon class="text-muted-foreground size-4" />+ <p class="text-muted-foreground text-sm font-medium">Docker Engine</p>+ </div>+ <div class="grid grid-cols-2 gap-3 text-xs">+ <div>+ <p class="text-muted-foreground">Version</p>+ <p class="font-medium">{dashboardStates.dockerInfo?.version || 'Unknown'}</p>+ </div>+ <div>+ <p class="text-muted-foreground">OS</p>+ <p class="font-medium">+ {dashboardStates.dockerInfo?.os ||+ dashboardStates.systemStats?.platform ||+ 'Unknown'}+ </p>+ </div>+ </div></div>- {:else if currentStats?.diskTotal && currentStats?.diskUsage !== undefined}- {@const storagePercent = Math.min(Math.max((currentStats.diskUsage / currentStats.diskTotal) * 100, 0), 100)}- <div class="mb-4">- <Meter label="System Storage" valueLabel="{storagePercent.toFixed(1)}%" value={storagePercent} max={100} variant={storagePercent > 85 ? 'destructive' : storagePercent > 70 ? 'warning' : 'success'} size="sm" />+ </Card.Content>+ </Card.Root>++ <Card.Root class="overflow-hidden">+ <Card.Content class="p-6">+ <div class="mb-4 flex items-center justify-between">+ <div class="flex items-center gap-3">+ <div class="rounded-lg bg-blue-500/10 p-2.5">+ <HardDrive class="size-5 text-blue-500" />+ </div>+ <div>+ <p class="text-muted-foreground text-sm font-medium">Storage</p>+ <p class="text-2xl font-bold">{dashboardStates.dockerInfo?.images || 0}</p>+ <p class="text-muted-foreground text-xs">Docker images</p>+ </div>+ </div></div>- <div class="text-muted-foreground space-y-1 text-xs">- <div class="flex justify-between">- <span>Used:</span>- <span class="font-medium">{formatBytes(currentStats.diskUsage)}</span>++ {#if isLoading.loadingStats}+ <div class="py-6 text-center">+ <Loader2 class="text-muted-foreground mx-auto mb-2 size-6 animate-spin" />+ <p class="text-muted-foreground text-sm">Loading storage data...</p></div>- <div class="flex justify-between">- <span>Total:</span>- <span class="font-medium">{formatBytes(currentStats.diskTotal)}</span>+ {:else if currentStats?.diskTotal && currentStats?.diskUsage !== undefined}+ {@const storagePercent = Math.min(+ Math.max((currentStats.diskUsage / currentStats.diskTotal) * 100, 0),+ 100+ )}+ <div class="mb-4">+ <Meter+ label="System Storage"+ valueLabel="{storagePercent.toFixed(1)}%"+ value={storagePercent}+ max={100}+ variant={storagePercent > 85+ ? 'destructive'+ : storagePercent > 70+ ? 'warning'+ : 'success'}+ size="sm"+ /></div>- {#if totalImageSize > 0}- <div class="border-border/50 flex justify-between border-t pt-1">+ <div class="text-muted-foreground space-y-1 text-xs">+ <div class="flex justify-between">+ <span>Used:</span>+ <span class="font-medium">{formatBytes(currentStats.diskUsage)}</span>+ </div>+ <div class="flex justify-between">+ <span>Total:</span>+ <span class="font-medium">{formatBytes(currentStats.diskTotal)}</span>+ </div>+ {#if totalImageSize > 0}+ <div class="border-border/50 flex justify-between border-t pt-1">+ <span>Docker Images:</span>+ <span class="font-medium">{formatBytes(totalImageSize)}</span>+ </div>+ {/if}+ </div>+ {:else if totalImageSize > 0}+ <div class="mb-4">+ <div class="py-4 text-center">+ <p class="text-muted-foreground text-sm">System storage data unavailable</p>+ </div>+ </div>+ <div class="text-muted-foreground text-xs">+ <div class="flex justify-between"><span>Docker Images:</span><span class="font-medium">{formatBytes(totalImageSize)}</span></div>- {/if}- </div>- {:else if totalImageSize > 0}- <div class="mb-4">- <div class="py-4 text-center">- <p class="text-muted-foreground text-sm">System storage data unavailable</p></div>- </div>- <div class="text-muted-foreground text-xs">- <div class="flex justify-between">- <span>Docker Images:</span>- <span class="font-medium">{formatBytes(totalImageSize)}</span>+ {:else}+ <div class="py-6 text-center">+ <p class="text-muted-foreground text-sm">No storage data available</p>+ </div>+ {/if}+ </Card.Content>+ </Card.Root>++ <Card.Root class="overflow-hidden">+ <Card.Content class="p-6">+ <div class="mb-4 flex items-center justify-between">+ <div class="flex items-center gap-3">+ <div class="rounded-lg bg-purple-500/10 p-2.5">+ <Cpu class="size-5 text-purple-500" />+ </div>+ <div>+ <p class="text-muted-foreground text-sm font-medium">Hardware</p>+ {#if isLoading.loadingStats}+ <div class="text-muted-foreground mt-1 text-xs">Loading...</div>+ {:else if currentStats}+ <div class="text-muted-foreground mt-1 flex items-center gap-4 text-xs">+ <span>{currentStats.cpuCount || 'N/A'} cores</span>+ <span+ >{currentStats.memoryTotal+ ? formatBytes(currentStats.memoryTotal, 0)+ : 'N/A'}</span+ >+ </div>+ {#if currentStats.hostname}+ <p class="text-muted-foreground mt-1 text-xs">{currentStats.hostname}</p>+ {/if}+ {:else}+ <div class="text-muted-foreground mt-1 text-xs">No data available</div>+ {/if}+ </div></div></div>- {:else}- <div class="py-6 text-center">- <p class="text-muted-foreground text-sm">No storage data available</p>- </div>- {/if}- </Card.Content>- </Card.Root>- <!-- Hardware & Performance Card -->- <Card.Root class="overflow-hidden">- <Card.Content class="p-6">- <div class="mb-4 flex items-center justify-between">- <div class="flex items-center gap-3">- <div class="rounded-lg bg-purple-500/10 p-2.5">- <Cpu class="size-5 text-purple-500" />+ {#if isLoading.loadingStats}+ <div class="py-6 text-center">+ <Loader2 class="text-muted-foreground mx-auto mb-2 size-6 animate-spin" />+ <p class="text-muted-foreground text-sm">Loading system stats...</p>+ </div>+ {:else if currentStats}+ {@const cpuPercent = Math.min(Math.max(currentStats.cpuUsage, 0), 100)}+ {@const memoryPercent = Math.min(+ Math.max((currentStats.memoryUsage / currentStats.memoryTotal) * 100, 0),+ 100+ )}+ <div class="space-y-4">+ <Meter+ label="CPU Usage"+ valueLabel="{cpuPercent.toFixed(1)}%"+ value={cpuPercent}+ max={100}+ variant={cpuPercent > 80+ ? 'destructive'+ : cpuPercent > 60+ ? 'warning'+ : 'success'}+ size="sm"+ />++ <Meter+ label="Memory Usage"+ valueLabel="{memoryPercent.toFixed(1)}%"+ value={memoryPercent}+ max={100}+ variant={memoryPercent > 80+ ? 'destructive'+ : memoryPercent > 60+ ? 'warning'+ : 'success'}+ size="sm"+ /></div>- <div>- <p class="text-muted-foreground text-sm font-medium">Hardware</p>- {#if isLoading.loadingStats}- <div class="text-muted-foreground mt-1 text-xs">Loading...</div>- {:else if currentStats}- <div class="text-muted-foreground mt-1 flex items-center gap-4 text-xs">- <span>{currentStats.cpuCount || 'N/A'} cores</span>- <span>{currentStats.memoryTotal ? formatBytes(currentStats.memoryTotal, 0) : 'N/A'}</span>+ <div class="text-muted-foreground space-y-1 pt-3 text-xs">+ {#if currentStats.architecture}+ <div class="flex justify-between">+ <span>Architecture:</span>+ <span class="font-medium">{currentStats.architecture}</span>+ </div>+ {/if}+ {#if currentStats.platform}+ <div class="flex justify-between">+ <span>Platform:</span>+ <span class="font-medium capitalize">{currentStats.platform}</span></div>- {#if currentStats.hostname}- <p class="text-muted-foreground mt-1 text-xs">{currentStats.hostname}</p>- {/if}- {:else}- <div class="text-muted-foreground mt-1 text-xs">No data available</div>{/if}</div>+ {:else}+ <div class="py-6 text-center">+ <p class="text-muted-foreground text-sm">System stats unavailable</p>+ </div>+ {/if}+ </Card.Content>+ </Card.Root>+ </div>+ </DropdownCard>+ </section>++ <section>+ <h2 class="mb-4 text-lg font-semibold tracking-tight">Quick Actions</h2>+ <div class="grid grid-cols-1 gap-5 sm:grid-cols-3">+ <button+ class="group bg-card relative flex flex-col items-center rounded-xl border p-6 shadow-sm transition-all hover:shadow-md disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:shadow-sm"+ disabled={!dashboardStates.dockerInfo ||+ stoppedContainers === 0 ||+ isLoading.starting ||+ isLoading.stopping ||+ isLoading.pruning}+ onclick={handleStartAll}+ >+ <div+ class="mb-4 flex size-12 items-center justify-center rounded-full bg-green-500/10 transition-colors group-hover:bg-green-500/20"+ >+ {#if isLoading.starting}+ <Loader2 class="size-6 animate-spin text-green-500" />+ {:else}+ <PlayCircle class="size-6 text-green-500" />+ {/if}+ </div>+ <span class="text-center text-base font-medium">Start All Stopped</span>+ <span class="text-muted-foreground mt-1 text-sm">{stoppedContainers} containers</span>+ </button>++ <button+ class="group bg-card relative flex flex-col items-center rounded-xl border p-6 shadow-sm transition-all hover:shadow-md disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:shadow-sm"+ disabled={!dashboardStates.dockerInfo ||+ runningContainers === 0 ||+ isLoading.starting ||+ isLoading.stopping ||+ isLoading.pruning}+ onclick={handleStopAll}+ >+ <div+ class="mb-4 flex size-12 items-center justify-center rounded-full bg-blue-500/10 transition-colors group-hover:bg-blue-500/20"+ >+ {#if isLoading.stopping}+ <Loader2 class="size-6 animate-spin text-blue-500" />+ {:else}+ <StopCircle class="size-6 text-blue-500" />+ {/if}+ </div>+ <span class="text-center text-base font-medium">Stop All Running</span>+ <span class="text-muted-foreground mt-1 text-sm">{runningContainers}</span>+ </button>++ <button+ class="group bg-card hover:border-destructive/50 disabled:hover:border-border relative flex flex-col items-center rounded-xl border p-6 shadow-sm transition-all hover:shadow-md disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:shadow-sm"+ disabled={!dashboardStates.dockerInfo ||+ isLoading.starting ||+ isLoading.stopping ||+ isLoading.pruning}+ onclick={() => (dashboardStates.isPruneDialogOpen = true)}+ >+ <div+ class="mb-4 flex size-12 items-center justify-center rounded-full bg-red-500/10 transition-colors group-hover:bg-red-500/20"+ >+ {#if isLoading.pruning}+ <Loader2 class="size-6 animate-spin text-red-500" />+ {:else}+ <Trash2 class="size-6 text-red-500" />+ {/if}+ </div>+ <span class="text-center text-base font-medium">Prune System</span>+ <span class="text-muted-foreground mt-1 text-sm">Clean unused resources</span>+ </button>+ </div>+ </section>++ <section>+ <h2 class="mb-4 text-lg font-semibold tracking-tight">Resources</h2>+ <div class="grid grid-cols-1 gap-6 lg:grid-cols-2">+ <Card.Root class="relative flex flex-col border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between">+ <div>+ <Card.Title+ ><a class="font-medium hover:underline" href="/containers">Containers</a+ ></Card.Title+ >+ <Card.Description class="pb-3">Recent containers</Card.Description></div>+ <Button+ variant="ghost"+ size="sm"+ href="/containers"+ disabled={!dashboardStates.dockerInfo}+ >+ View All+ <ArrowRight class="ml-2 size-4" />+ </Button></div>-- {#if isLoading.loadingStats}- <div class="py-6 text-center">- <Loader2 class="text-muted-foreground mx-auto mb-2 size-6 animate-spin" />- <p class="text-muted-foreground text-sm">Loading system stats...</p>- </div>- {:else if currentStats}- {@const cpuPercent = Math.min(Math.max(currentStats.cpuUsage, 0), 100)}- {@const memoryPercent = Math.min(Math.max((currentStats.memoryUsage / currentStats.memoryTotal) * 100, 0), 100)}- <div class="space-y-4">- <Meter label="CPU Usage" valueLabel="{cpuPercent.toFixed(1)}%" value={cpuPercent} max={100} variant={cpuPercent > 80 ? 'destructive' : cpuPercent > 60 ? 'warning' : 'success'} size="sm" />-- <Meter label="Memory Usage" valueLabel="{memoryPercent.toFixed(1)}%" value={memoryPercent} max={100} variant={memoryPercent > 80 ? 'destructive' : memoryPercent > 60 ? 'warning' : 'success'} size="sm" />- </div>- <div class="text-muted-foreground space-y-1 pt-3 text-xs">- {#if currentStats.architecture}- <div class="flex justify-between">- <span>Architecture:</span>- <span class="font-medium">{currentStats.architecture}</span>- </div>- {/if}- {#if currentStats.platform}- <div class="flex justify-between">- <span>Platform:</span>- <span class="font-medium capitalize">{currentStats.platform}</span>+ </Card.Header>+ <Card.Content class="flex-1 p-0">+ {#if dashboardStates.containers && dashboardStates.containers.length > 0}+ <div class="flex h-full flex-col">+ <div class="flex-1">+ <UniversalTable+ data={dashboardStates.containers.slice(0, 5).map(+ (c): EnhancedContainerInfo => ({+ ...c,+ displayName: getContainerDisplayName(c),+ statusSortValue: parseStatusTime(c.Status)+ })+ )}+ columns={[+ { accessorKey: 'displayName', header: 'Name' },+ { accessorKey: 'Image', header: 'Image' },+ { accessorKey: 'State', header: 'State' },+ { accessorKey: 'statusSortValue', header: 'Status' }+ ]}+ features={{+ filtering: false,+ selection: false+ }}+ sort={{+ defaultSort: { id: 'statusSortValue', desc: false }+ }}+ pagination={{+ pageSize: 5,+ pageSizeOptions: [5]+ }}+ display={{+ isDashboardTable: true+ }}+ >+ {#snippet rows({ item }: { item: EnhancedContainerInfo })}+ {@const stateVariant = statusVariantMap[item.State.toLowerCase()]}+ <Table.Cell>+ <a class="font-medium hover:underline" href="/containers/{item.Id}/">+ {item.displayName}+ </a>+ </Table.Cell>+ <Table.Cell title={item.Image}>+ {truncateString(item.Image, 40)}+ </Table.Cell>+ <Table.Cell>+ <StatusBadge+ variant={stateVariant}+ text={capitalizeFirstLetter(item.State)}+ />+ </Table.Cell>+ <Table.Cell>{item.Status}</Table.Cell>+ {/snippet}+ </UniversalTable>+ </div>+ {#if dashboardStates.containers.length > 5}+ <div class="bg-muted/40 text-muted-foreground border-t px-6 py-2 text-xs">+ Showing 5 of {dashboardStates.containers.length} containers</div>{/if}</div>- {:else}- <div class="py-6 text-center">- <p class="text-muted-foreground text-sm">System stats unavailable</p>+ {:else if !dashboardStates.error}+ <div class="flex flex-col items-center justify-center px-6 py-10 text-center">+ <Box class="text-muted-foreground mb-2 size-8 opacity-40" />+ <p class="text-muted-foreground text-sm">No containers found</p>+ <p class="text-muted-foreground mt-1 text-xs">+ Use Docker CLI or another tool to create containers+ </p></div>{/if}</Card.Content></Card.Root>- </div>- </DropdownCard>- </section>- <section>- <h2 class="mb-4 text-lg font-semibold tracking-tight">Quick Actions</h2>- <div class="grid grid-cols-1 gap-5 sm:grid-cols-3">- <button- class="group bg-card relative flex flex-col items-center rounded-xl border p-6 shadow-sm transition-all hover:shadow-md disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:shadow-sm"- disabled={!dashboardStates.dockerInfo || stoppedContainers === 0 || isLoading.starting || isLoading.stopping || isLoading.pruning}- onclick={handleStartAll}- >- <div class="mb-4 flex size-12 items-center justify-center rounded-full bg-green-500/10 transition-colors group-hover:bg-green-500/20">- {#if isLoading.starting}- <Loader2 class="size-6 animate-spin text-green-500" />- {:else}- <PlayCircle class="size-6 text-green-500" />- {/if}- </div>- <span class="text-center text-base font-medium">Start All Stopped</span>- <span class="text-muted-foreground mt-1 text-sm">{stoppedContainers} containers</span>- </button>-- <button- class="group bg-card relative flex flex-col items-center rounded-xl border p-6 shadow-sm transition-all hover:shadow-md disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:shadow-sm"- disabled={!dashboardStates.dockerInfo || runningContainers === 0 || isLoading.starting || isLoading.stopping || isLoading.pruning}- onclick={handleStopAll}- >- <div class="mb-4 flex size-12 items-center justify-center rounded-full bg-blue-500/10 transition-colors group-hover:bg-blue-500/20">- {#if isLoading.stopping}- <Loader2 class="size-6 animate-spin text-blue-500" />- {:else}- <StopCircle class="size-6 text-blue-500" />- {/if}- </div>- <span class="text-center text-base font-medium">Stop All Running</span>- <span class="text-muted-foreground mt-1 text-sm">{runningContainers}</span>- </button>-- <button- class="group bg-card hover:border-destructive/50 disabled:hover:border-border relative flex flex-col items-center rounded-xl border p-6 shadow-sm transition-all hover:shadow-md disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:shadow-sm"- disabled={!dashboardStates.dockerInfo || isLoading.starting || isLoading.stopping || isLoading.pruning}- onclick={() => (dashboardStates.isPruneDialogOpen = true)}- >- <div class="mb-4 flex size-12 items-center justify-center rounded-full bg-red-500/10 transition-colors group-hover:bg-red-500/20">- {#if isLoading.pruning}- <Loader2 class="size-6 animate-spin text-red-500" />- {:else}- <Trash2 class="size-6 text-red-500" />- {/if}- </div>- <span class="text-center text-base font-medium">Prune System</span>- <span class="text-muted-foreground mt-1 text-sm">Clean unused resources</span>- </button>- </div>- </section>-- <section>- <h2 class="mb-4 text-lg font-semibold tracking-tight">Resources</h2>- <div class="grid grid-cols-1 gap-6 lg:grid-cols-2">- <Card.Root class="relative flex flex-col border shadow-sm">- <Card.Header class="px-6">- <div class="flex items-center justify-between">- <div>- <Card.Title><a class="font-medium hover:underline" href="/containers">Containers</a></Card.Title>- <Card.Description class="pb-3">Recent containers</Card.Description>- </div>- <Button variant="ghost" size="sm" href="/containers" disabled={!dashboardStates.dockerInfo}>- View All- <ArrowRight class="ml-2 size-4" />- </Button>- </div>- </Card.Header>- <Card.Content class="flex-1 p-0">- {#if dashboardStates.containers && dashboardStates.containers.length > 0}- <div class="flex h-full flex-col">- <div class="flex-1">- <UniversalTable- data={dashboardStates.containers.slice(0, 5).map(- (c): EnhancedContainerInfo => ({- ...c,- displayName: getContainerDisplayName(c),- statusSortValue: parseStatusTime(c.Status)- })- )}- columns={[- { accessorKey: 'displayName', header: 'Name' },- { accessorKey: 'Image', header: 'Image' },- { accessorKey: 'State', header: 'State' },- { accessorKey: 'statusSortValue', header: 'Status' }- ]}- features={{- filtering: false,- selection: false- }}- sort={{- defaultSort: { id: 'statusSortValue', desc: false }- }}- pagination={{- pageSize: 5,- pageSizeOptions: [5]- }}- display={{- isDashboardTable: true- }}+ <Card.Root class="relative flex flex-col border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between">+ <div>+ <Card.Title+ ><a class="font-medium hover:underline" href="/images">Images</a></Card.Title>- {#snippet rows({ item }: { item: EnhancedContainerInfo })}- {@const stateVariant = statusVariantMap[item.State.toLowerCase()]}- <Table.Cell>- <a class="font-medium hover:underline" href="/containers/{item.Id}/">- {item.displayName}- </a>- </Table.Cell>- <Table.Cell title={item.Image}>- {truncateString(item.Image, 40)}- </Table.Cell>- <Table.Cell>- <StatusBadge variant={stateVariant} text={capitalizeFirstLetter(item.State)} />- </Table.Cell>- <Table.Cell>{item.Status}</Table.Cell>- {/snippet}- </UniversalTable>+ <Card.Description class="pb-3">Top 5 Largest Images</Card.Description></div>- {#if dashboardStates.containers.length > 5}- <div class="bg-muted/40 text-muted-foreground border-t px-6 py-2 text-xs">- Showing 5 of {dashboardStates.containers.length} containers- </div>- {/if}+ <Button+ variant="ghost"+ size="sm"+ href="/images"+ disabled={!dashboardStates.dockerInfo}+ >+ View All+ <ArrowRight class="ml-2 size-4" />+ </Button></div>- {:else if !dashboardStates.error}- <div class="flex flex-col items-center justify-center px-6 py-10 text-center">- <Box class="text-muted-foreground mb-2 size-8 opacity-40" />- <p class="text-muted-foreground text-sm">No containers found</p>- <p class="text-muted-foreground mt-1 text-xs">Use Docker CLI or another tool to create containers</p>- </div>- {/if}- </Card.Content>- </Card.Root>-- <Card.Root class="relative flex flex-col border shadow-sm">- <Card.Header class="px-6">- <div class="flex items-center justify-between">- <div>- <Card.Title><a class="font-medium hover:underline" href="/images">Images</a></Card.Title>- <Card.Description class="pb-3">Top 5 Largest Images</Card.Description>- </div>- <Button variant="ghost" size="sm" href="/images" disabled={!dashboardStates.dockerInfo}>- View All- <ArrowRight class="ml-2 size-4" />- </Button>- </div>- </Card.Header>- <Card.Content class="flex-1 p-0">- {#if dashboardStates.images?.length > 0}- <div class="flex h-full flex-col">- <div class="flex-1">- <UniversalTable- data={dashboardStates.images- .slice()- .sort((a, b) => (b.Size || 0) - (a.Size || 0))- .slice(0, 5)}- columns={[- { accessorKey: 'repo', header: 'Name' },- { accessorKey: 'inUse', header: ' ', enableSorting: false },- { accessorKey: 'tag', header: 'Tag' },- { accessorKey: 'Size', header: 'Size' }- ]}- features={{- filtering: false,- selection: false- }}- pagination={{- pageSize: 5,- pageSizeOptions: [5]- }}- display={{- isDashboardTable: true- }}- sort={{- defaultSort: { id: 'Size', desc: true }- }}- >- {#snippet rows({ item }: { item: EnhancedImageInfo })}- <Table.Cell>- <div class="flex items-center gap-2">- <div class="flex flex-1 items-center">- <MaturityItem maturity={item.maturity} isLoadingInBackground={!item.maturity} imageId={item.Id} />- <a class="shrink truncate font-medium hover:underline" href="/images/{item.Id}/">- {#if item.repo && item.repo !== '<none>'}- {item.repo}- {:else if item.RepoTags && item.RepoTags.length > 0 && item.RepoTags[0] !== '<none>:<none>'}- {item.RepoTags[0].split(':')[0]}- {:else}- {item.Id.substring(7, 19)}- {/if}- </a>+ </Card.Header>+ <Card.Content class="flex-1 p-0">+ {#if dashboardStates.images?.length > 0}+ <div class="flex h-full flex-col">+ <div class="flex-1">+ <UniversalTable+ data={dashboardStates.images+ .slice()+ .sort((a, b) => (b.Size || 0) - (a.Size || 0))+ .slice(0, 5)}+ columns={[+ { accessorKey: 'repo', header: 'Name' },+ { accessorKey: 'inUse', header: ' ', enableSorting: false },+ { accessorKey: 'tag', header: 'Tag' },+ { accessorKey: 'Size', header: 'Size' }+ ]}+ features={{+ filtering: false,+ selection: false+ }}+ pagination={{+ pageSize: 5,+ pageSizeOptions: [5]+ }}+ display={{+ isDashboardTable: true+ }}+ sort={{+ defaultSort: { id: 'Size', desc: true }+ }}+ >+ {#snippet rows({ item }: { item: EnhancedImageInfo })}+ <Table.Cell>+ <div class="flex items-center gap-2">+ <div class="flex flex-1 items-center">+ <MaturityItem+ maturity={item.maturity}+ isLoadingInBackground={!item.maturity}+ imageId={item.Id}+ />+ <a+ class="shrink truncate font-medium hover:underline"+ href="/images/{item.Id}/"+ >+ {#if item.repo && item.repo !== '<none>'}+ {item.repo}+ {:else if item.RepoTags && item.RepoTags.length > 0 && item.RepoTags[0] !== '<none>:<none>'}+ {item.RepoTags[0].split(':')[0]}+ {:else}+ {item.Id.substring(7, 19)}+ {/if}+ </a>+ </div></div>- </div>- </Table.Cell>- <Table.Cell>- {#if !item.inUse}- <StatusBadge text="Unused" variant="amber" />- {:else}- <StatusBadge text="In Use" variant="green" />- {/if}- </Table.Cell>- <Table.Cell>- {#if item.tag && item.tag !== '<none>'}- {item.tag}- {:else if item.RepoTags && item.RepoTags.length > 0 && item.RepoTags[0] !== '<none>:<none>'}- {item.RepoTags[0].split(':')[1] || 'latest'}- {:else}- <none>- {/if}- </Table.Cell>- <Table.Cell>{formatBytes(item.Size)}</Table.Cell>- {/snippet}- </UniversalTable>- </div>- {#if dashboardStates.images.length > 5}- <div class="bg-muted/40 text-muted-foreground border-t px-6 py-2 text-xs">- Showing 5 of {dashboardStates.images.length} images+ </Table.Cell>+ <Table.Cell>+ {#if !item.inUse}+ <StatusBadge text="Unused" variant="amber" />+ {:else}+ <StatusBadge text="In Use" variant="green" />+ {/if}+ </Table.Cell>+ <Table.Cell>+ {#if item.tag && item.tag !== '<none>'}+ {item.tag}+ {:else if item.RepoTags && item.RepoTags.length > 0 && item.RepoTags[0] !== '<none>:<none>'}+ {item.RepoTags[0].split(':')[1] || 'latest'}+ {:else}+ <none>+ {/if}+ </Table.Cell>+ <Table.Cell>{formatBytes(item.Size)}</Table.Cell>+ {/snippet}+ </UniversalTable></div>- {/if}- </div>- {:else if !dashboardStates.error}- <div class="flex flex-col items-center justify-center px-6 py-10 text-center">- <HardDrive class="text-muted-foreground mb-2 size-8 opacity-40" />- <p class="text-muted-foreground text-sm">No images found</p>- <p class="text-muted-foreground mt-1 text-xs">Pull images using Docker CLI or another tool</p>- </div>- {/if}- </Card.Content>- </Card.Root>- </div>- </section>+ {#if dashboardStates.images.length > 5}+ <div class="bg-muted/40 text-muted-foreground border-t px-6 py-2 text-xs">+ Showing 5 of {dashboardStates.images.length} images+ </div>+ {/if}+ </div>+ {:else if !dashboardStates.error}+ <div class="flex flex-col items-center justify-center px-6 py-10 text-center">+ <HardDrive class="text-muted-foreground mb-2 size-8 opacity-40" />+ <p class="text-muted-foreground text-sm">No images found</p>+ <p class="text-muted-foreground mt-1 text-xs">+ Pull images using Docker CLI or another tool+ </p>+ </div>+ {/if}+ </Card.Content>+ </Card.Root>+ </div>+ </section>+ {/if}<section class="mt-10 border-t pt-4"><div class="text-muted-foreground flex items-center justify-between text-sm"><div class="flex items-center">- <a href="https://github.com/ofkm/arcane" target="_blank" rel="noopener noreferrer" class="hover:text-foreground transition-colors" title="GitHub">+ <a+ href="https://github.com/ofkm/arcane"+ target="_blank"+ rel="noopener noreferrer"+ class="hover:text-foreground transition-colors"+ title="GitHub"+ ><GitHubIcon class="size-4 fill-current" /><span class="sr-only">GitHub</span></a>@@ -711,5 +930,11 @@</div></section>- <PruneConfirmationDialog bind:open={dashboardStates.isPruneDialogOpen} isPruning={isLoading.pruning} imagePruneMode={(dashboardStates.settings?.pruneMode as 'dangling' | 'all') || 'dangling'} onConfirm={confirmPrune} onCancel={() => (dashboardStates.isPruneDialogOpen = false)} />+ <PruneConfirmationDialog+ bind:open={dashboardStates.isPruneDialogOpen}+ isPruning={isLoading.pruning}+ imagePruneMode={(dashboardStates.settings?.pruneMode as 'dangling' | 'all') || 'dangling'}+ onConfirm={confirmPrune}+ onCancel={() => (dashboardStates.isPruneDialogOpen = false)}+ /></div>diff --git a/frontend/src/routes/+page.ts b/frontend/src/routes/+page.tsindex 21907ecd8..170636dda 100644--- a/frontend/src/routes/+page.ts+++ b/frontend/src/routes/+page.ts@@ -1,23 +1,32 @@import { systemAPI, settingsAPI, environmentAPI } from '$lib/services/api';export const load = async () => {- try {- const [dockerInfo, resources, settings] = await Promise.all([systemAPI.getDockerInfo(), environmentAPI.getAllResources(), settingsAPI.getSettings()]);-- return {- dockerInfo,- containers: resources.containers || [],- images: resources.images || [],- settings- };- } catch (error) {- console.error('Error loading dashboard data:', error);- return {- dockerInfo: null,- containers: [],- images: [],- settings: null,- error: error instanceof Error ? error.message : String(error)- };- }+ // try {+ // const [dockerInfoResult, containersResult, imagesResult, settingsResult] =+ // await Promise.allSettled([+ // systemAPI.getDockerInfo(),+ // environmentAPI.getContainers(),+ // environmentAPI.getImages(),+ // settingsAPI.getSettings()+ // ]);+ // const dockerInfo = dockerInfoResult.status === 'fulfilled' ? dockerInfoResult.value : null;+ // const containers = containersResult.status === 'fulfilled' ? containersResult.value : [];+ // const images = imagesResult.status === 'fulfilled' ? imagesResult.value : [];+ // const settings = settingsResult.status === 'fulfilled' ? settingsResult.value : null;+ // return {+ // dockerInfo,+ // containers,+ // images,+ // settings+ // };+ // } catch (error) {+ // console.error('Error loading dashboard data:', error);+ // return {+ // dockerInfo: null,+ // containers: [],+ // images: [],+ // settings: null,+ // error: error instanceof Error ? error.message : String(error)+ // };+ // }};diff --git a/frontend/src/routes/compose/+page.svelte b/frontend/src/routes/compose/+page.svelteindex 809a1dfce..14055c229 100644--- a/frontend/src/routes/compose/+page.svelte+++ b/frontend/src/routes/compose/+page.svelte@@ -2,7 +2,18 @@import type { PageData } from './$types';import * as Card from '$lib/components/ui/card/index.js';import { Button } from '$lib/components/ui/button/index.js';- import { AlertCircle, Layers, FileStack, Loader2, Play, RotateCcw, StopCircle, Trash2, Ellipsis, Pen } from '@lucide/svelte';+ import {+ AlertCircle,+ Layers,+ FileStack,+ Loader2,+ Play,+ RotateCcw,+ StopCircle,+ Trash2,+ Ellipsis,+ Pen+ } from '@lucide/svelte';import UniversalTable from '$lib/components/universal-table.svelte';import { openConfirmDialog } from '$lib/components/confirm-dialog';import * as Table from '$lib/components/ui/table';@@ -20,12 +31,18 @@import { tablePersistence } from '$lib/stores/table-store';import { formatFriendlyDate } from '$lib/utils/date.utils';import { autoUpdateAPI, environmentAPI } from '$lib/services/api';+ import { onMount } from 'svelte';+ import type { Stack } from '$lib/models/stack.type';let { data }: { data: PageData } = $props();- let stacks = $derived(Array.isArray(data.stacks) ? data.stacks : []);+ let stacks = $state(<Stack[]>[]);+ let error = $state<string | null>(null);+ let isLoadingStacks = $state(true);- const isLoading = $state<Record<'start' | 'stop' | 'restart' | 'remove' | 'destroy' | 'pull' | 'update', boolean>>({+ const isLoading = $state<+ Record<'start' | 'stop' | 'restart' | 'remove' | 'destroy' | 'pull' | 'update', boolean>+ >({start: false,stop: false,restart: false,@@ -40,6 +57,25 @@const runningStacks = $derived(stacks.filter((s) => s.status === 'running').length);const stoppedStacks = $derived(stacks.filter((s) => s.status === 'stopped').length);+ async function loadStacks() {+ try {+ isLoadingStacks = true;+ const response = await environmentAPI.getStacks();+ stacks = response || [];+ error = null;+ } catch (err) {+ console.error('Failed to load compose page:', err);+ error = err instanceof Error ? err.message : 'Failed to load Docker Compose stacks';+ stacks = [];+ } finally {+ isLoadingStacks = false;+ }+ }++ onMount(() => {+ loadStacks();+ });+async function performStackAction(action: StackActions, id: string) {isLoading[action as keyof typeof isLoading] = true;@@ -51,7 +87,7 @@setLoadingState: (value) => (isLoading.start = value),onSuccess: async () => {toast.success('Stack Started Successfully.');- await invalidateAll();+ await loadStacks();}});} else if (action === 'stop') {@@ -61,7 +97,7 @@setLoadingState: (value) => (isLoading.stop = value),onSuccess: async () => {toast.success('Stack Stopped Successfully.');- await invalidateAll();+ await loadStacks();}});} else if (action === 'restart') {@@ -71,7 +107,7 @@setLoadingState: (value) => (isLoading.restart = value),onSuccess: async () => {toast.success('Stack Restarted Successfully.');- await invalidateAll();+ await loadStacks();}});} else if (action === 'pull') {@@ -81,7 +117,7 @@setLoadingState: (value) => (isLoading.pull = value),onSuccess: async () => {toast.success('Stack Pulled successfully.');- await invalidateAll();+ await loadStacks();}});} else if (action === 'destroy') {@@ -98,7 +134,7 @@setLoadingState: (value) => (isLoading.destroy = value),onSuccess: async () => {toast.success('Stack Removed Successfully');- await invalidateAll();+ await loadStacks();}});}@@ -120,7 +156,7 @@setLoadingState: (value) => (isLoading.update = value),async onSuccess() {toast.success('Compose Projects Updated Successfully.');- await invalidateAll();+ await loadStacks();}});}@@ -134,185 +170,266 @@</div></div>- {#if data.error}+ {#if error}<Alert.Root variant="destructive"><AlertCircle class="size-4" /><Alert.Title>Error Loading Compose Projects</Alert.Title>- <Alert.Description>{data.error}</Alert.Description>+ <Alert.Description>{error}</Alert.Description></Alert.Root>{/if}- <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Compose Projects</p>- <p class="text-2xl font-bold">{totalStacks}</p>- </div>- <div class="bg-primary/10 rounded-full p-2">- <FileStack class="text-primary size-5" />- </div>- </Card.Content>- </Card.Root>+ {#if isLoadingStacks}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">+ {#each Array(3) as _}+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div class="space-y-2">+ <div class="bg-muted h-4 w-24 animate-pulse rounded"></div>+ <div class="bg-muted h-8 w-12 animate-pulse rounded"></div>+ </div>+ <div class="bg-muted size-10 animate-pulse rounded-full"></div>+ </Card.Content>+ </Card.Root>+ {/each}+ </div>- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Running</p>- <p class="text-2xl font-bold">{runningStacks}</p>+ <Card.Root class="border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between">+ <div>+ <Card.Title>Compose Projects List</Card.Title>+ </div>+ <div class="flex items-center gap-2">+ <div class="bg-muted h-9 w-32 animate-pulse rounded"></div>+ <div class="bg-muted h-9 w-28 animate-pulse rounded"></div>+ </div></div>- <div class="rounded-full bg-green-500/10 p-2">- <Layers class="size-5 text-green-500" />+ </Card.Header>+ <Card.Content>+ <div class="flex flex-col items-center justify-center px-6 py-12 text-center">+ <Loader2 class="text-muted-foreground mb-4 size-8 animate-spin" />+ <p class="text-lg font-medium">Loading Compose Projects...</p>+ <p class="text-muted-foreground mt-1 text-sm">Please wait while we fetch your projects</p></div></Card.Content></Card.Root>+ {:else}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Total Compose Projects</p>+ <p class="text-2xl font-bold">{totalStacks}</p>+ </div>+ <div class="bg-primary/10 rounded-full p-2">+ <FileStack class="text-primary size-5" />+ </div>+ </Card.Content>+ </Card.Root>- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Stopped</p>- <p class="text-2xl font-bold">{stoppedStacks}</p>- </div>- <div class="rounded-full bg-gray-500/10 p-2">- <Layers class="size-5 text-gray-500" />- </div>- </Card.Content>- </Card.Root>- </div>+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Running</p>+ <p class="text-2xl font-bold">{runningStacks}</p>+ </div>+ <div class="rounded-full bg-green-500/10 p-2">+ <Layers class="size-5 text-green-500" />+ </div>+ </Card.Content>+ </Card.Root>- <Card.Root class="border shadow-sm">- <Card.Header class="px-6">- <div class="flex items-center justify-between">- <div>- <Card.Title>Compose Projects List</Card.Title>- </div>- <div class="flex items-center gap-2">- {#if stacks.length > 0}- <ArcaneButton action="inspect" label="Update Compose Projects" onClick={() => handleCheckForUpdates()} loading={isLoading.update} loadingLabel="Updating..." disabled={isLoading.update} />- <ArcaneButton action="create" customLabel="Create Compose Project" onClick={() => goto(`/compose/new`)} />- {/if}- </div>- </div>- </Card.Header>- <Card.Content>- {#if stacks.length > 0}- <UniversalTable- data={stacks}- columns={[- { accessorKey: 'name', header: 'Name' },- { accessorKey: 'service_count', header: 'Services' },- { accessorKey: 'status', header: 'Status' },- { accessorKey: 'created_at', header: 'Created' },- { accessorKey: 'actions', header: ' ', enableSorting: false }- ]}- features={{- selection: false- }}- pagination={{- pageSize: tablePersistence.getPageSize('stacks')- }}- onPageSizeChange={(newSize) => {- tablePersistence.setPageSize('stacks', newSize);- }}- sort={{- defaultSort: { id: 'name', desc: false }- }}- display={{- filterPlaceholder: 'Search compose projects...',- noResultsMessage: 'No stacks found'- }}- >- {#snippet rows({ item })}- {@const stateVariant = item.status ? statusVariantMap[item.status.toLowerCase()] : 'gray'}- <Table.Cell>- <a class="font-medium hover:underline" href="/compose/{item.id}/">- {item.name}- </a>- </Table.Cell>- <Table.Cell>{item.serviceCount || 0}</Table.Cell>- <Table.Cell><StatusBadge variant={stateVariant} text={capitalizeFirstLetter(item.status)} /></Table.Cell>- <Table.Cell>{formatFriendlyDate(item.createdAt || '')}</Table.Cell>- <Table.Cell>- <DropdownMenu.Root>- <DropdownMenu.Trigger>- {#snippet child({ props })}- <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">- <span class="sr-only">Open menu</span>- <Ellipsis />- </Button>- {/snippet}- </DropdownMenu.Trigger>- <DropdownMenu.Content align="end">- <DropdownMenu.Group>- <DropdownMenu.Item onclick={() => goto(`/compose/${item.id}`)} disabled={isAnyLoading}>- <Pen class="size-4" />- Edit- </DropdownMenu.Item>+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Stopped</p>+ <p class="text-2xl font-bold">{stoppedStacks}</p>+ </div>+ <div class="rounded-full bg-gray-500/10 p-2">+ <Layers class="size-5 text-gray-500" />+ </div>+ </Card.Content>+ </Card.Root>+ </div>- {#if item.status !== 'running'}- <DropdownMenu.Item onclick={() => performStackAction('start', item.id)} disabled={isLoading.start || isAnyLoading}>- {#if isLoading.start}- <Loader2 class="size-4 animate-spin" />- {:else}- <Play class="size-4" />- {/if}- Start+ <Card.Root class="border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between">+ <div>+ <Card.Title>Compose Projects List</Card.Title>+ </div>+ <div class="flex items-center gap-2">+ {#if stacks.length > 0}+ <ArcaneButton+ action="inspect"+ label="Update Compose Projects"+ onClick={() => handleCheckForUpdates()}+ loading={isLoading.update}+ loadingLabel="Updating..."+ disabled={isLoading.update}+ />+ <ArcaneButton+ action="create"+ customLabel="Create Compose Project"+ onClick={() => goto(`/compose/new`)}+ />+ {/if}+ </div>+ </div>+ </Card.Header>+ <Card.Content>+ {#if stacks.length > 0}+ <UniversalTable+ data={stacks}+ columns={[+ { accessorKey: 'name', header: 'Name' },+ { accessorKey: 'service_count', header: 'Services' },+ { accessorKey: 'status', header: 'Status' },+ { accessorKey: 'created_at', header: 'Created' },+ { accessorKey: 'actions', header: ' ', enableSorting: false }+ ]}+ features={{+ selection: false+ }}+ pagination={{+ pageSize: tablePersistence.getPageSize('stacks')+ }}+ onPageSizeChange={(newSize) => {+ tablePersistence.setPageSize('stacks', newSize);+ }}+ sort={{+ defaultSort: { id: 'name', desc: false }+ }}+ display={{+ filterPlaceholder: 'Search compose projects...',+ noResultsMessage: 'No stacks found'+ }}+ >+ {#snippet rows({ item })}+ {@const stateVariant = item.status+ ? statusVariantMap[item.status.toLowerCase()]+ : 'gray'}+ <Table.Cell>+ <a class="font-medium hover:underline" href="/compose/{item.id}/">+ {item.name}+ </a>+ </Table.Cell>+ <Table.Cell>{item.serviceCount || 0}</Table.Cell>+ <Table.Cell+ ><StatusBadge+ variant={stateVariant}+ text={capitalizeFirstLetter(item.status)}+ /></Table.Cell+ >+ <Table.Cell>{formatFriendlyDate(item.createdAt || '')}</Table.Cell>+ <Table.Cell>+ <DropdownMenu.Root>+ <DropdownMenu.Trigger>+ {#snippet child({ props })}+ <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">+ <span class="sr-only">Open menu</span>+ <Ellipsis />+ </Button>+ {/snippet}+ </DropdownMenu.Trigger>+ <DropdownMenu.Content align="end">+ <DropdownMenu.Group>+ <DropdownMenu.Item+ onclick={() => goto(`/compose/${item.id}`)}+ disabled={isAnyLoading}+ >+ <Pen class="size-4" />+ Edit</DropdownMenu.Item>- {:else}- <DropdownMenu.Item onclick={() => performStackAction('restart', item.id)} disabled={isLoading.restart || isAnyLoading}>- {#if isLoading.restart}++ {#if item.status !== 'running'}+ <DropdownMenu.Item+ onclick={() => performStackAction('start', item.id)}+ disabled={isLoading.start || isAnyLoading}+ >+ {#if isLoading.start}+ <Loader2 class="size-4 animate-spin" />+ {:else}+ <Play class="size-4" />+ {/if}+ Start+ </DropdownMenu.Item>+ {:else}+ <DropdownMenu.Item+ onclick={() => performStackAction('restart', item.id)}+ disabled={isLoading.restart || isAnyLoading}+ >+ {#if isLoading.restart}+ <Loader2 class="size-4 animate-spin" />+ {:else}+ <RotateCcw class="size-4" />+ {/if}+ Restart+ </DropdownMenu.Item>++ <DropdownMenu.Item+ onclick={() => performStackAction('stop', item.id)}+ disabled={isLoading.stop || isAnyLoading}+ >+ {#if isLoading.stop}+ <Loader2 class="size-4 animate-spin" />+ {:else}+ <StopCircle class="size-4" />+ {/if}+ Stop+ </DropdownMenu.Item>+ {/if}++ <DropdownMenu.Item+ onclick={() => performStackAction('pull', item.id)}+ disabled={isLoading.pull || isAnyLoading}+ >+ {#if isLoading.pull}<Loader2 class="size-4 animate-spin" />{:else}<RotateCcw class="size-4" />{/if}- Restart+ Pull & Redeploy</DropdownMenu.Item>- <DropdownMenu.Item onclick={() => performStackAction('stop', item.id)} disabled={isLoading.stop || isAnyLoading}>- {#if isLoading.stop}+ <DropdownMenu.Separator />++ <DropdownMenu.Item+ class="focus:text-red-700! text-red-500"+ onclick={() => performStackAction('destroy', item.id)}+ disabled={isLoading.remove || isAnyLoading}+ >+ {#if isLoading.remove}<Loader2 class="size-4 animate-spin" />{:else}- <StopCircle class="size-4" />+ <Trash2 class="size-4" />{/if}- Stop+ Destroy</DropdownMenu.Item>- {/if}-- <DropdownMenu.Item onclick={() => performStackAction('pull', item.id)} disabled={isLoading.pull || isAnyLoading}>- {#if isLoading.pull}- <Loader2 class="size-4 animate-spin" />- {:else}- <RotateCcw class="size-4" />- {/if}- Pull & Redeploy- </DropdownMenu.Item>-- <DropdownMenu.Separator />-- <DropdownMenu.Item class="focus:text-red-700! text-red-500" onclick={() => performStackAction('destroy', item.id)} disabled={isLoading.remove || isAnyLoading}>- {#if isLoading.remove}- <Loader2 class="size-4 animate-spin" />- {:else}- <Trash2 class="size-4" />- {/if}- Destroy- </DropdownMenu.Item>- </DropdownMenu.Group>- </DropdownMenu.Content>- </DropdownMenu.Root>- </Table.Cell>- {/snippet}- </UniversalTable>- {:else if !data.error}- <div class="flex flex-col items-center justify-center px-6 py-12 text-center">- <FileStack class="text-muted-foreground mb-4 size-12 opacity-40" />- <p class="text-lg font-medium">No Projects found</p>- <p class="text-muted-foreground mt-1 max-w-md text-sm">Create a new stack using the "Create Project" button above</p>- <div class="mt-4 flex gap-3">- <ArcaneButton action="create" customLabel="Create Project" onClick={() => goto(`/compose/new`)} size="sm" />+ </DropdownMenu.Group>+ </DropdownMenu.Content>+ </DropdownMenu.Root>+ </Table.Cell>+ {/snippet}+ </UniversalTable>+ {:else if !error}+ <div class="flex flex-col items-center justify-center px-6 py-12 text-center">+ <FileStack class="text-muted-foreground mb-4 size-12 opacity-40" />+ <p class="text-lg font-medium">No Projects found</p>+ <p class="text-muted-foreground mt-1 max-w-md text-sm">+ Create a new stack using the "Create Project" button above+ </p>+ <div class="mt-4 flex gap-3">+ <ArcaneButton+ action="create"+ customLabel="Create Project"+ onClick={() => goto(`/compose/new`)}+ size="sm"+ />+ </div></div>- </div>- {/if}- </Card.Content>- </Card.Root>+ {/if}+ </Card.Content>+ </Card.Root>+ {/if}</div>diff --git a/frontend/src/routes/compose/+page.ts b/frontend/src/routes/compose/+page.tsindex d6874d5ac..ccf5d80ad 100644--- a/frontend/src/routes/compose/+page.ts+++ b/frontend/src/routes/compose/+page.ts@@ -1,22 +1,20 @@import { environmentAPI } from '$lib/services/api';export const load = async () => {- try {- // Load managed stacks- const response = await environmentAPI.getStacks();-- // Extract stacks from the API response structure- const stacks = response || [];-- return {- stacks,- error: null- };- } catch (error) {- console.error('Failed to load compose page:', error);- return {- stacks: [],- error: error instanceof Error ? error.message : 'Failed to load Docker Compose stacks'- };- }+ // try {+ // // Load managed stacks+ // const response = await environmentAPI.getStacks();+ // // Extract stacks from the API response structure+ // const stacks = response || [];+ // return {+ // stacks,+ // error: null+ // };+ // } catch (error) {+ // console.error('Failed to load compose page:', error);+ // return {+ // stacks: [],+ // error: error instanceof Error ? error.message : 'Failed to load Docker Compose stacks'+ // };+ // }};diff --git a/frontend/src/routes/containers/+page.svelte b/frontend/src/routes/containers/+page.svelteindex b9330b221..51dc9722e 100644--- a/frontend/src/routes/containers/+page.svelte+++ b/frontend/src/routes/containers/+page.svelte@@ -1,5 +1,15 @@<script lang="ts">- import { ScanSearch, Play, RotateCcw, StopCircle, Trash2, Loader2, Box, RefreshCw, Ellipsis } from '@lucide/svelte';+ import {+ ScanSearch,+ Play,+ RotateCcw,+ StopCircle,+ Trash2,+ Loader2,+ Box,+ RefreshCw,+ Ellipsis+ } from '@lucide/svelte';import { Button } from '$lib/components/ui/button/index.js';import * as Card from '$lib/components/ui/card/index.js';import UniversalTable from '$lib/components/universal-table.svelte';@@ -7,7 +17,7 @@import * as Table from '$lib/components/ui/table';import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';import CreateContainerSheet from '$lib/components/sheets/create-container-sheet.svelte';- import { goto, invalidateAll } from '$app/navigation';+ import { goto } from '$app/navigation';import { toast } from 'svelte-sonner';import { tryCatch } from '$lib/utils/try-catch';import StatusBadge from '$lib/components/badges/status-badge.svelte';@@ -22,12 +32,15 @@import { parseStatusTime } from '$lib/utils/string.utils';import type { ContainerInfo } from 'dockerode';import { autoUpdateAPI, environmentAPI } from '$lib/services/api';+ import { onMount } from 'svelte';- let { data }: { data: PageData & { containers: ContainerInfo[] } } = $props();- let containers = $state(data.containers);- let isRefreshing = $state(false);+ let { data }: { data: PageData } = $props();++ let containers = $state<ContainerInfo[]>([]);+ let isLoadingContainers = $state(true);let selectedIds = $state([]);let isCreateDialogOpen = $state(false);+let isLoading = $state({start: false,stop: false,@@ -36,55 +49,98 @@checking: false,create: false});+const isAnyLoading = $derived(Object.values(isLoading).some((loading) => loading));- const runningContainers = $derived(containers?.filter((c: ContainerInfo) => c.State === 'running').length || 0);- const stoppedContainers = $derived(containers?.filter((c: ContainerInfo) => c.State === 'exited').length || 0);+ const runningContainers = $derived(+ containers?.filter((c: ContainerInfo) => c.State === 'running').length || 0+ );+ const stoppedContainers = $derived(+ containers?.filter((c: ContainerInfo) => c.State === 'exited').length || 0+ );const totalContainers = $derived(containers?.length || 0);function getContainerDisplayName(container: ContainerInfo): string {if (container.Names && container.Names.length > 0) {- return container.Names[0].startsWith('/') ? container.Names[0].substring(1) : container.Names[0];+ return container.Names[0].startsWith('/')+ ? container.Names[0].substring(1)+ : container.Names[0];}return shortId(container.Id);}- $effect(() => {- containers = data.containers;- if (isRefreshing) {- isRefreshing = false;- }- });-- async function refreshData() {- isRefreshing = true;+ async function loadContainers() {try {- await invalidateAll();+ isLoadingContainers = true;+ const response = await environmentAPI.getContainers();+ containers = response || [];+ } catch (error) {+ console.error('Failed to load containers:', error);+ containers = [];} finally {- setTimeout(() => {- isRefreshing = false;- }, 300);+ isLoadingContainers = false;}}- function openCreateDialog() {- isCreateDialogOpen = true;+ onMount(() => {+ loadContainers();+ });++ async function performContainerAction(action: string, id: string) {+ isLoading[action as keyof typeof isLoading] = true;++ try {+ if (action === 'start') {+ handleApiResultWithCallbacks({+ result: await tryCatch(environmentAPI.startContainer(id)),+ message: 'Failed to Start Container',+ setLoadingState: (value) => (isLoading.start = value),+ async onSuccess() {+ toast.success('Container Started Successfully.');+ await loadContainers();+ }+ });+ } else if (action === 'stop') {+ handleApiResultWithCallbacks({+ result: await tryCatch(environmentAPI.stopContainer(id)),+ message: 'Failed to Stop Container',+ setLoadingState: (value) => (isLoading.stop = value),+ async onSuccess() {+ toast.success('Container Stopped Successfully.');+ await loadContainers();+ }+ });+ } else if (action === 'restart') {+ handleApiResultWithCallbacks({+ result: await tryCatch(environmentAPI.restartContainer(id)),+ message: 'Failed to Restart Container',+ setLoadingState: (value) => (isLoading.restart = value),+ async onSuccess() {+ toast.success('Container Restarted Successfully.');+ await loadContainers();+ }+ });+ }+ } catch (error) {+ console.error('Container action failed:', error);+ isLoading[action as keyof typeof isLoading] = false;+ }}async function handleRemoveContainer(id: string) {openConfirmDialog({- title: 'Delete Container',- message: 'Are you sure you want to delete this container? This action cannot be undone.',+ title: 'Confirm Container Removal',+ message: 'Are you sure you want to remove this container? This action cannot be undone.',confirm: {- label: 'Delete',+ label: 'Remove',destructive: true,action: async () => {handleApiResultWithCallbacks({result: await tryCatch(environmentAPI.deleteContainer(id)),message: 'Failed to Remove Container',setLoadingState: (value) => (isLoading.remove = value),- onSuccess: async () => {+ async onSuccess() {toast.success('Container Removed Successfully.');- await invalidateAll();+ await loadContainers();}});}@@ -92,45 +148,6 @@});}- async function performContainerAction(action: 'start' | 'stop' | 'restart', id: string) {- isLoading[action] = true;-- if (action === 'start') {- handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.startContainer(id)),- message: 'Failed to Start Container',- setLoadingState: (value) => (isLoading.start = value),- async onSuccess() {- toast.success('Container Started Successfully.');- await invalidateAll();- }- });- } else if (action === 'stop') {- handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.stopContainer(id)),- message: 'Failed to Stop Container',- setLoadingState: (value) => (isLoading.stop = value),- async onSuccess() {- toast.success('Container Stopped Successfully.');- await invalidateAll();- }- });- } else if (action === 'restart') {- handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.restartContainer(id)),- message: 'Failed to Restart Container',- setLoadingState: (value) => (isLoading.restart = value),- async onSuccess() {- toast.success('Container Restarted Successfully.');- await invalidateAll();- }- });- } else {- console.error('An Unknown Error Occurred');- toast.error('An Unknown Error Occurred');- }- }-async function handleCheckForUpdates() {isLoading.checking = true;handleApiResultWithCallbacks({@@ -139,10 +156,14 @@setLoadingState: (value) => (isLoading.checking = value),async onSuccess() {toast.success('Containers Updated Successfully.');- await invalidateAll();+ await loadContainers();}});}++ function openCreateDialog() {+ isCreateDialogOpen = true;+ }</script><div class="space-y-6">@@ -153,26 +174,21 @@</div></div>- <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">- <StatCard title="Total" value={totalContainers} icon={Box} class="border-l-primary border-l-4 transition-shadow hover:shadow-lg" />- <StatCard title="Running" value={runningContainers} icon={Box} iconColor="text-green-500" bgColor="bg-green-500/10" class="border-l-4 border-l-green-500" />- <StatCard title="Stopped" value={stoppedContainers} icon={Box} iconColor="text-amber-500" class="border-l-4 border-l-amber-500" />- </div>-- {#if containers?.length === 0}- <div class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center">- <Box class="text-muted-foreground mb-4 size-12 opacity-40" />- <p class="text-lg font-medium">No containers found</p>- <p class="text-muted-foreground mt-1 max-w-md text-sm">Create a new container using the "Create Container" button above or use the Docker CLI</p>- <div class="mt-4 flex gap-3">- <Button variant="secondary" onclick={refreshData}>- <RefreshCw class="size-4" />- Refresh- </Button>- <ArcaneButton action="create" label="Create Container" onClick={openCreateDialog} />- </div>+ {#if isLoadingContainers}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">+ {#each Array(3) as _}+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div class="space-y-2">+ <div class="bg-muted h-4 w-24 animate-pulse rounded"></div>+ <div class="bg-muted h-8 w-12 animate-pulse rounded"></div>+ </div>+ <div class="bg-muted size-10 animate-pulse rounded-full"></div>+ </Card.Content>+ </Card.Root>+ {/each}</div>- {:else}+<Card.Root class="border shadow-sm"><Card.Header class="px-6"><div class="flex items-center justify-between">@@ -180,137 +196,234 @@<Card.Title>Container List</Card.Title></div><div class="flex items-center gap-2">- <ArcaneButton action="inspect" label="Update Containers" onClick={() => handleCheckForUpdates()} loading={isLoading.checking} loadingLabel="Updating..." disabled={isLoading.checking} />- <ArcaneButton action="create" label="Create Container" onClick={openCreateDialog} />+ <div class="bg-muted h-9 w-32 animate-pulse rounded"></div>+ <div class="bg-muted h-9 w-28 animate-pulse rounded"></div></div></div></Card.Header><Card.Content>- <UniversalTable- data={containers.map((c: any) => ({- ...c,- displayName: getContainerDisplayName(c),- statusSortValue: parseStatusTime(c.Status)- }))}- columns={[- { accessorKey: 'displayName', header: 'Name' },- { accessorKey: 'Id', header: 'ID' },- { accessorKey: 'Image', header: 'Image' },- { accessorKey: 'State', header: 'State' },- { accessorKey: 'statusSortValue', header: 'Status' },- { accessorKey: 'actions', header: ' ', enableSorting: false }- ]}- features={{- selection: false- }}- pagination={{- pageSize: tablePersistence.getPageSize('containers')- }}- onPageSizeChange={(newSize) => {- tablePersistence.setPageSize('containers', newSize);- }}- sort={{- defaultSort: { id: 'displayName', desc: false }- }}- display={{- filterPlaceholder: 'Search containers...',- noResultsMessage: 'No containers found'- }}- bind:selectedIds- >- {#snippet rows({ item }: { item: ContainerInfo & { displayName: string; statusSortValue: number } })}- {@const stateVariant = statusVariantMap[item.State.toLowerCase()]}- <Table.Cell><a class="font-medium hover:underline" href="/containers/{item.Id}/">{item.displayName}</a></Table.Cell>- <Table.Cell>{shortId(item.Id)}</Table.Cell>- <Table.Cell>{item.Image}</Table.Cell>- <Table.Cell>- <StatusBadge variant={stateVariant} text={capitalizeFirstLetter(item.State)} />- </Table.Cell>- <Table.Cell>{item.Status}</Table.Cell>- <Table.Cell>- <DropdownMenu.Root>- <DropdownMenu.Trigger>- {#snippet child({ props })}- <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">- <span class="sr-only">Open menu</span>- <Ellipsis />- </Button>- {/snippet}- </DropdownMenu.Trigger>- <DropdownMenu.Content align="end">- <DropdownMenu.Group>- <DropdownMenu.Item onclick={() => goto(`/containers/${item.Id}`)} disabled={isAnyLoading}>- <ScanSearch class="size-4" />- Inspect- </DropdownMenu.Item>+ <div class="flex flex-col items-center justify-center px-6 py-12 text-center">+ <Loader2 class="text-muted-foreground mb-4 size-8 animate-spin" />+ <p class="text-lg font-medium">Loading Containers...</p>+ <p class="text-muted-foreground mt-1 text-sm">+ Please wait while we fetch your containers+ </p>+ </div>+ </Card.Content>+ </Card.Root>+ {:else}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">+ <StatCard+ title="Total"+ value={totalContainers}+ icon={Box}+ class="border-l-primary border-l-4 transition-shadow hover:shadow-lg"+ />+ <StatCard+ title="Running"+ value={runningContainers}+ icon={Box}+ iconColor="text-green-500"+ bgColor="bg-green-500/10"+ class="border-l-4 border-l-green-500"+ />+ <StatCard+ title="Stopped"+ value={stoppedContainers}+ icon={Box}+ iconColor="text-amber-500"+ class="border-l-4 border-l-amber-500"+ />+ </div>- {#if item.State !== 'running'}- <DropdownMenu.Item onclick={() => performContainerAction('start', item.Id)} disabled={isLoading.start || isAnyLoading}>- {#if isLoading.start}- <Loader2 class="size-4 animate-spin" />- {:else}- <Play class="size-4" />- {/if}- Start- </DropdownMenu.Item>- {:else}- <DropdownMenu.Item onclick={() => performContainerAction('restart', item.Id)} disabled={isLoading.restart || isAnyLoading}>- {#if isLoading.restart}- <Loader2 class="size-4 animate-spin" />- {:else}- <RotateCcw class="size-4" />- {/if}- Restart+ {#if containers?.length === 0}+ <div+ class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center"+ >+ <Box class="text-muted-foreground mb-4 size-12 opacity-40" />+ <p class="text-lg font-medium">No containers found</p>+ <p class="text-muted-foreground mt-1 max-w-md text-sm">+ Create a new container using the "Create Container" button above or use the Docker CLI+ </p>+ <div class="mt-4 flex gap-3">+ <Button variant="secondary" onclick={loadContainers}>+ <RefreshCw class="size-4" />+ Refresh+ </Button>+ <ArcaneButton action="create" label="Create Container" onClick={openCreateDialog} />+ </div>+ </div>+ {:else}+ <Card.Root class="border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between">+ <div>+ <Card.Title>Container List</Card.Title>+ </div>+ <div class="flex items-center gap-2">+ <ArcaneButton+ action="inspect"+ label="Update Containers"+ onClick={() => handleCheckForUpdates()}+ loading={isLoading.checking}+ loadingLabel="Updating..."+ disabled={isLoading.checking}+ />+ <ArcaneButton action="create" label="Create Container" onClick={openCreateDialog} />+ </div>+ </div>+ </Card.Header>+ <Card.Content>+ <UniversalTable+ data={containers.map((c: any) => ({+ ...c,+ displayName: getContainerDisplayName(c),+ statusSortValue: parseStatusTime(c.Status)+ }))}+ columns={[+ { accessorKey: 'displayName', header: 'Name' },+ { accessorKey: 'Id', header: 'ID' },+ { accessorKey: 'Image', header: 'Image' },+ { accessorKey: 'State', header: 'State' },+ { accessorKey: 'statusSortValue', header: 'Status' },+ { accessorKey: 'actions', header: ' ', enableSorting: false }+ ]}+ features={{+ selection: false+ }}+ pagination={{+ pageSize: tablePersistence.getPageSize('containers')+ }}+ onPageSizeChange={(newSize) => {+ tablePersistence.setPageSize('containers', newSize);+ }}+ sort={{+ defaultSort: { id: 'displayName', desc: false }+ }}+ display={{+ filterPlaceholder: 'Search containers...',+ noResultsMessage: 'No containers found'+ }}+ bind:selectedIds+ >+ {#snippet rows({+ item+ }: {+ item: ContainerInfo & { displayName: string; statusSortValue: number };+ })}+ {@const stateVariant = statusVariantMap[item.State.toLowerCase()]}+ <Table.Cell+ ><a class="font-medium hover:underline" href="/containers/{item.Id}/"+ >{item.displayName}</a+ ></Table.Cell+ >+ <Table.Cell>{shortId(item.Id)}</Table.Cell>+ <Table.Cell>{item.Image}</Table.Cell>+ <Table.Cell>+ <StatusBadge variant={stateVariant} text={capitalizeFirstLetter(item.State)} />+ </Table.Cell>+ <Table.Cell>{item.Status}</Table.Cell>+ <Table.Cell>+ <DropdownMenu.Root>+ <DropdownMenu.Trigger>+ {#snippet child({ props })}+ <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">+ <span class="sr-only">Open menu</span>+ <Ellipsis />+ </Button>+ {/snippet}+ </DropdownMenu.Trigger>+ <DropdownMenu.Content align="end">+ <DropdownMenu.Group>+ <DropdownMenu.Item+ onclick={() => goto(`/containers/${item.Id}`)}+ disabled={isAnyLoading}+ >+ <ScanSearch class="size-4" />+ Inspect</DropdownMenu.Item>- <DropdownMenu.Item onclick={() => performContainerAction('stop', item.Id)} disabled={isLoading.stop || isAnyLoading}>- {#if isLoading.stop}+ {#if item.State !== 'running'}+ <DropdownMenu.Item+ onclick={() => performContainerAction('start', item.Id)}+ disabled={isLoading.start || isAnyLoading}+ >+ {#if isLoading.start}+ <Loader2 class="size-4 animate-spin" />+ {:else}+ <Play class="size-4" />+ {/if}+ Start+ </DropdownMenu.Item>+ {:else}+ <DropdownMenu.Item+ onclick={() => performContainerAction('restart', item.Id)}+ disabled={isLoading.restart || isAnyLoading}+ >+ {#if isLoading.restart}+ <Loader2 class="size-4 animate-spin" />+ {:else}+ <RotateCcw class="size-4" />+ {/if}+ Restart+ </DropdownMenu.Item>++ <DropdownMenu.Item+ onclick={() => performContainerAction('stop', item.Id)}+ disabled={isLoading.stop || isAnyLoading}+ >+ {#if isLoading.stop}+ <Loader2 class="size-4 animate-spin" />+ {:else}+ <StopCircle class="size-4" />+ {/if}+ Stop+ </DropdownMenu.Item>+ {/if}++ <DropdownMenu.Separator />++ <DropdownMenu.Item+ class="focus:text-red-700! text-red-500"+ onclick={() => handleRemoveContainer(item.Id)}+ disabled={isLoading.remove || isAnyLoading}+ >+ {#if isLoading.remove}<Loader2 class="size-4 animate-spin" />{:else}- <StopCircle class="size-4" />+ <Trash2 class="size-4" />{/if}- Stop+ Remove</DropdownMenu.Item>- {/if}+ </DropdownMenu.Group>+ </DropdownMenu.Content>+ </DropdownMenu.Root>+ </Table.Cell>+ {/snippet}+ </UniversalTable>+ </Card.Content>+ </Card.Root>+ {/if}- <DropdownMenu.Separator />-- <DropdownMenu.Item class="focus:text-red-700! text-red-500" onclick={() => handleRemoveContainer(item.Id)} disabled={isLoading.remove || isAnyLoading}>- {#if isLoading.remove}- <Loader2 class="size-4 animate-spin" />- {:else}- <Trash2 class="size-4" />- {/if}- Remove- </DropdownMenu.Item>- </DropdownMenu.Group>- </DropdownMenu.Content>- </DropdownMenu.Root>- </Table.Cell>- {/snippet}- </UniversalTable>- </Card.Content>- </Card.Root>+ <CreateContainerSheet+ bind:open={isCreateDialogOpen}+ availableVolumes={[]}+ availableNetworks={[]}+ availableImages={[]}+ isLoading={isLoading.create}+ onSubmit={async (options) => {+ isLoading.create = true;+ handleApiResultWithCallbacks({+ result: await tryCatch(environmentAPI.createContainer(options)),+ message: 'Failed to Create Container',+ setLoadingState: (value) => (isLoading.create = value),+ onSuccess: async () => {+ toast.success('Container Created Successfully.');+ await loadContainers();+ isCreateDialogOpen = false;+ }+ });+ }}+ />{/if}-- <CreateContainerSheet- bind:open={isCreateDialogOpen}- availableVolumes={Array.isArray(data.volumes) ? data.volumes : []}- availableNetworks={Array.isArray(data.networks) ? data.networks : []}- availableImages={Array.isArray(data.images) ? data.images : []}- isLoading={isLoading.create}- onSubmit={async (options) => {- isLoading.create = true;- handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.createContainer(options)),- message: 'Failed to Create Container',- setLoadingState: (value) => (isLoading.create = value),- onSuccess: async () => {- toast.success('Container Created Successfully.');- await invalidateAll();- isCreateDialogOpen = false;- }- });- }}- /></div>diff --git a/frontend/src/routes/containers/+page.ts b/frontend/src/routes/containers/+page.tsdeleted file mode 100644index 12104e1b5..000000000--- a/frontend/src/routes/containers/+page.ts+++ /dev/null@@ -1,24 +0,0 @@-import { environmentAPI } from '$lib/services/api';-import type { PageLoad } from './$types';--export const load: PageLoad = async () => {- try {- const resources = await environmentAPI.getAllResources();-- return {- containers: resources.containers || [],- volumes: resources.volumes || [],- networks: resources.networks || [],- images: resources.images || []- };- } catch (error) {- console.error('Error loading container data:', error);- return {- containers: [],- volumes: [],- networks: [],- images: [],- error: error instanceof Error ? error.message : String(error)- };- }-};diff --git a/frontend/src/routes/images/+page.svelte b/frontend/src/routes/images/+page.svelteindex 4cf625def..67887d062 100644--- a/frontend/src/routes/images/+page.svelte+++ b/frontend/src/routes/images/+page.svelte@@ -3,10 +3,20 @@import type { EnhancedImageInfo } from '$lib/models/image.type';import UniversalTable from '$lib/components/universal-table.svelte';import { Button } from '$lib/components/ui/button/index.js';- import { Download, AlertCircle, HardDrive, Trash2, Loader2, ChevronDown, Ellipsis, ScanSearch, Funnel } from '@lucide/svelte';+ import {+ Download,+ AlertCircle,+ HardDrive,+ Trash2,+ Loader2,+ ChevronDown,+ Ellipsis,+ ScanSearch,+ Funnel+ } from '@lucide/svelte';import * as Alert from '$lib/components/ui/alert/index.js';import * as Card from '$lib/components/ui/card/index.js';- import { goto, invalidateAll } from '$app/navigation';+ import { goto } from '$app/navigation';import { toast } from 'svelte-sonner';import ImagePullSheet from '$lib/components/sheets/image-pull-sheet.svelte';import { formatBytes } from '$lib/utils/bytes.util';@@ -20,15 +30,21 @@import ArcaneButton from '$lib/components/arcane-button.svelte';import { tablePersistence } from '$lib/stores/table-store';import MaturityItem from '$lib/components/maturity-item.svelte';- import { maturityStore, triggerBulkMaturityCheck, enhanceImagesWithMaturity, loadImageMaturityBatch } from '$lib/stores/maturity-store';+ import {+ maturityStore,+ triggerBulkMaturityCheck,+ enhanceImagesWithMaturity,+ loadImageMaturityBatch+ } from '$lib/stores/maturity-store';import { environmentAPI } from '$lib/services/api';+ import { onMount } from 'svelte';let { data }: { data: PageData } = $props();- // Make images reactive to data changes- let images = $derived(Array.isArray(data.images) ? data.images : []);- let error = $state(data.error);+ let images = $state<EnhancedImageInfo[]>([]);+ let error = $state<string | null>(null);let selectedIds = $state<string[]>([]);+ let isLoadingImages = $state(true);let imageFilters = $state({showUsed: true,@@ -44,7 +60,6 @@});let isPullingInline = $state<Record<string, boolean>>({});-let isPullDialogOpen = $state(false);let isConfirmPruneDialogOpen = $state(false);@@ -52,8 +67,30 @@const totalSize = $derived(images?.reduce((acc, img) => acc + (img.Size || 0), 0) || 0);const enhancedImages = $derived(enhanceImagesWithMaturity(images, $maturityStore.maturityData));+ const filteredImages = $derived(+ enhancedImages.filter(+ (img) => (imageFilters.showUsed && img.InUse) || (imageFilters.showUnused && !img.InUse)+ ) as EnhancedImageInfo[]+ );- const filteredImages = $derived(enhancedImages.filter((img) => (imageFilters.showUsed && img.InUse) || (imageFilters.showUnused && !img.InUse)) as EnhancedImageInfo[]);+ async function loadImages() {+ try {+ isLoadingImages = true;+ const response = await environmentAPI.getImages();+ images = response || [];+ error = null;+ } catch (err) {+ console.error('Failed to load images:', err);+ error = err instanceof Error ? err.message : 'Failed to load images';+ images = [];+ } finally {+ isLoadingImages = false;+ }+ }++ onMount(() => {+ loadImages();+ });$effect(() => {if (images && images.length > 0) {@@ -61,10 +98,17 @@}});+ async function loadImagesMaturity() {+ if (!images || images.length === 0) return;++ const imageIds = images.map((img) => img.Id);+ await loadImageMaturityBatch(imageIds);+ }+async function refreshImages() {isLoading.refreshing = true;try {- await invalidateAll();+ await loadImages();} catch (error) {console.error('Failed to refresh images:', error);toast.error('Failed to refresh images');@@ -73,113 +117,49 @@}}- async function loadImagesMaturity() {- const imageIds = images- .filter((img) => {- if (!img.RepoTags || img.RepoTags.length === 0) return false;- const repoTag = img.RepoTags[0];- return repoTag !== '<none>:<none>' && repoTag.includes(':');- })- .map((img) => img.Id);-- if (imageIds.length > 0) {- await loadImageMaturityBatch(imageIds);- }- }-- async function handleTriggerBulkMaturityCheck() {- isLoading.checking = true;- try {- const result = await triggerBulkMaturityCheck();-- if (result.success) {- toast.success(result.message);- setTimeout(async () => {- await invalidateAll();- }, 1000);- } else {- toast.error(result.message);- }- } catch (error) {- console.error('Bulk maturity check error:', error);- toast.error('Failed to trigger maturity check');- } finally {- isLoading.checking = false;- }- }-- $effect(() => {- if ($maturityStore.isChecking && !isLoading.checking) {- isLoading.checking = true;- } else if (!$maturityStore.isChecking && isLoading.checking) {- }- });-- async function handleImageRemove(id: string) {- const image = images.find((img) => img.Id === id);- const imageIdentifier = image?.RepoTags?.[0] || id.substring(0, 12);-- openConfirmDialog({- title: 'Delete Image',- message: `Are you sure you want to delete ${imageIdentifier}? This action cannot be undone.`,- confirm: {- label: 'Delete',- destructive: true,- action: async () => {- isLoading.removing = true;- await handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.deleteImage(id)),- message: 'Failed to Remove Image',- setLoadingState: (value) => (isLoading.removing = value),- onSuccess: async () => {- toast.success(`Image "${imageIdentifier}" deleted successfully.`);- await invalidateAll();- }- });- isLoading.removing = false;- }- }- });- }-async function handleDeleteSelected() {+ if (selectedIds.length === 0) return;+openConfirmDialog({- title: 'Delete Selected Images',- message: `Are you sure you want to delete ${selectedIds.length} selected image(s)? This action cannot be undone. Images currently used by containers will not be deleted.`,+ title: `Remove ${selectedIds.length} Image${selectedIds.length > 1 ? 's' : ''}`,+ message: `Are you sure you want to remove the selected image${selectedIds.length > 1 ? 's' : ''}? This action cannot be undone.`,confirm: {- label: 'Delete',+ label: 'Remove',destructive: true,action: async () => {isLoading.removing = true;-let successCount = 0;let failureCount = 0;for (const id of selectedIds) {- const image = images.find((img) => img.Id === id);- const imageIdentifier = image?.RepoTags?.[0] || id.substring(0, 12);-- if (image?.InUse) {- toast.error(`Image "${imageIdentifier}" is in use and cannot be deleted.`);- failureCount++;- continue;- }-- await handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.deleteImage(id)),- message: `Failed to delete image "${imageIdentifier}"`,- setLoadingState: (value) => (isLoading.removing = value),- onSuccess: async () => {- toast.success(`Image "${imageIdentifier}" deleted successfully.`);+ const result = await tryCatch(environmentAPI.deleteImage(id));+ handleApiResultWithCallbacks({+ result,+ message: `Failed to remove image`,+ setLoadingState: () => {},+ onSuccess: () => {successCount++;}});++ if (result.error) {+ failureCount++;+ }}isLoading.removing = false;+if (successCount > 0) {- await invalidateAll();+ toast.success(+ `Successfully removed ${successCount} image${successCount > 1 ? 's' : ''}`+ );+ await loadImages();}++ if (failureCount > 0) {+ toast.error(`Failed to remove ${failureCount} image${failureCount > 1 ? 's' : ''}`);+ }+selectedIds = [];}}@@ -188,44 +168,41 @@async function handlePruneImages() {isLoading.pruning = true;- await handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.pruneImages() as Promise<{ message?: string }>),+ handleApiResultWithCallbacks({+ result: await tryCatch(environmentAPI.pruneImages()),message: 'Failed to Prune Images',setLoadingState: (value) => (isLoading.pruning = value),- onSuccess: async (result: { message?: string }) => {+ onSuccess: async () => {+ toast.success('Images Pruned Successfully');+ await loadImages();isConfirmPruneDialogOpen = false;- toast.success(result?.message ?? 'Images pruned successfully.');- await invalidateAll();}});}- async function handleInlineImagePull(imageIdentifier: string, fullImageName: string) {- if (!fullImageName) {- toast.error('Cannot pull image: name is missing.');- return;- }+ async function handleTriggerBulkMaturityCheck() {+ isLoading.checking = true;+ await triggerBulkMaturityCheck();+ isLoading.checking = false;+ }++ async function handleInlineImagePull(imageId: string, imageTag: string) {+ if (!imageTag) return;+ const imageIdentifier = imageId;isPullingInline = { ...isPullingInline, [imageIdentifier]: true };- let pullError = '';- let lastStatusText = `Pulling ${fullImageName}...`;- toast.info(lastStatusText, { id: `pull-${imageIdentifier}` });try {- const result = await environmentAPI.pullImage(fullImageName);-- if (result.error) {- throw new Error(result.error);- }-- toast.success(`Image "${fullImageName}" pulled successfully.`, {- id: `pull-${imageIdentifier}`+ const result = await tryCatch(environmentAPI.pullImage(imageTag));+ handleApiResultWithCallbacks({+ result,+ message: `Failed to pull image ${imageTag}`,+ setLoadingState: () => {},+ onSuccess: async () => {+ toast.success(`Image ${imageTag} pulled successfully`);+ await loadImages();+ }});- await invalidateAll();- } catch (error: any) {- console.error(`Pull image error for ${fullImageName}:`, error);- const message = error.message || `Failed to pull ${fullImageName}.`;- toast.error(message, { id: `pull-${imageIdentifier}` });} finally {isPullingInline = { ...isPullingInline, [imageIdentifier]: false };}@@ -239,7 +216,13 @@<p class="text-muted-foreground mt-1 text-sm">View and Manage your Container Images</p></div><div class="flex items-center gap-2">- <ArcaneButton action="restart" onClick={refreshImages} label="Refresh" loading={isLoading.refreshing} disabled={isLoading.refreshing} />+ <ArcaneButton+ action="restart"+ onClick={refreshImages}+ label="Refresh"+ loading={isLoading.refreshing}+ disabled={isLoading.refreshing}+ /></div></div>@@ -251,200 +234,291 @@</Alert.Root>{/if}- <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Images</p>- <p class="text-2xl font-bold">{totalImages}</p>- </div>- <div class="rounded-full bg-blue-500/10 p-2">- <HardDrive class="size-5 text-blue-500" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Size</p>- <p class="text-2xl font-bold">{formatBytes(totalSize)}</p>- </div>- <div class="rounded-full bg-purple-500/10 p-2">- <HardDrive class="size-5 text-purple-500" />- </div>- </Card.Content>- </Card.Root>- </div>+ {#if isLoadingImages}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">+ {#each Array(2) as _}+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div class="space-y-2">+ <div class="bg-muted h-4 w-24 animate-pulse rounded"></div>+ <div class="bg-muted h-8 w-12 animate-pulse rounded"></div>+ </div>+ <div class="bg-muted size-10 animate-pulse rounded-full"></div>+ </Card.Content>+ </Card.Root>+ {/each}+ </div>- {#if images && images.length > 0}<Card.Root class="border shadow-sm"><Card.Header class="px-6"><div class="flex items-center justify-between"><div>- <Card.Title>Image List</Card.Title>+ <Card.Title>Images List</Card.Title></div>-<div class="flex items-center gap-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- {#snippet child({ props })}- <Button {...props} variant="outline">- <Funnel class="size-4" />- Filter- <ChevronDown class="size-4" />- </Button>- {/snippet}- </DropdownMenu.Trigger>- <DropdownMenu.Content>- <DropdownMenu.Label>Image Usage</DropdownMenu.Label>- <DropdownMenu.CheckboxItem- checked={imageFilters.showUsed}- onCheckedChange={(checked) => {- imageFilters.showUsed = checked;- }}- >- Show Used Images- </DropdownMenu.CheckboxItem>- <DropdownMenu.CheckboxItem- checked={imageFilters.showUnused}- onCheckedChange={(checked) => {- imageFilters.showUnused = checked;- }}- >- Show Unused Images- </DropdownMenu.CheckboxItem>- </DropdownMenu.Content>- </DropdownMenu.Root>- {#if selectedIds.length > 0}- <ArcaneButton action="remove" onClick={() => handleDeleteSelected()} loading={isLoading.removing} disabled={isLoading.removing} />- {/if}- <ArcaneButton action="remove" label="Prune Unused" onClick={() => (isConfirmPruneDialogOpen = true)} loading={isLoading.pruning} loadingLabel="Pruning..." disabled={isLoading.pruning} />- <ArcaneButton action="pull" label="Pull Image" onClick={() => (isPullDialogOpen = true)} loading={isLoading.pulling} loadingLabel="Pulling..." disabled={isLoading.pulling} />- <ArcaneButton action="inspect" label="Recheck Maturities" onClick={() => handleTriggerBulkMaturityCheck()} loading={isLoading.checking} loadingLabel="Checking..." disabled={isLoading.checking} />+ <div class="bg-muted h-9 w-32 animate-pulse rounded"></div>+ <div class="bg-muted h-9 w-28 animate-pulse rounded"></div></div></div></Card.Header>-<Card.Content>- <UniversalTable- data={filteredImages}- columns={[- { accessorKey: 'repo', header: 'Name' },- { accessorKey: 'InUse', header: ' ', enableSorting: false },- { accessorKey: 'tag', header: 'Tag' },- { accessorKey: 'Id', header: 'Image ID', enableSorting: false },- { accessorKey: 'Size', header: 'Size' },- { accessorKey: 'actions', header: ' ', enableSorting: false }- ]}- idKey="Id"- display={{- filterPlaceholder: 'Search images...',- noResultsMessage: 'No images found'- }}- pagination={{- pageSize: tablePersistence.getPageSize('images')- }}- onPageSizeChange={(newSize) => {- tablePersistence.setPageSize('images', newSize);- }}- sort={{- defaultSort: { id: 'repo', desc: false }- }}- bind:selectedIds- >- {#snippet rows({ item })}- <Table.Cell>- <div class="flex items-center gap-2">- <div class="flex flex-1 items-center">- <MaturityItem maturity={item.maturity} imageId={item.Id} repo={item.repo} tag={item.tag} isLoadingInBackground={$maturityStore.isChecking} />- <a class="shrink truncate font-medium hover:underline" href="/images/{item.Id}/">- {item.repo}- </a>- </div>- </div>- </Table.Cell>- <Table.Cell>- {#if !item.InUse}- <StatusBadge text="Unused" variant="amber" />- {:else}- <StatusBadge text="In Use" variant="green" />- {/if}- </Table.Cell>- <Table.Cell>{item.tag}</Table.Cell>- <Table.Cell class="truncate">{item.Id}</Table.Cell>- <Table.Cell>{formatBytes(item.Size)}</Table.Cell>- <Table.Cell>+ <div class="flex flex-col items-center justify-center px-6 py-12 text-center">+ <Loader2 class="text-muted-foreground mb-4 size-8 animate-spin" />+ <p class="text-lg font-medium">Loading Images...</p>+ <p class="text-muted-foreground mt-1 text-sm">Please wait while we fetch your images</p>+ </div>+ </Card.Content>+ </Card.Root>+ {:else}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Total Images</p>+ <p class="text-2xl font-bold">{totalImages}</p>+ </div>+ <div class="rounded-full bg-blue-500/10 p-2">+ <HardDrive class="size-5 text-blue-500" />+ </div>+ </Card.Content>+ </Card.Root>++ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Total Size</p>+ <p class="text-2xl font-bold">{formatBytes(totalSize)}</p>+ </div>+ <div class="rounded-full bg-purple-500/10 p-2">+ <HardDrive class="size-5 text-purple-500" />+ </div>+ </Card.Content>+ </Card.Root>+ </div>++ {#if filteredImages.length > 0}+ <Card.Root class="border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between">+ <div>+ <Card.Title>Images List</Card.Title>+ </div>+ <div class="flex items-center gap-2"><DropdownMenu.Root><DropdownMenu.Trigger>{#snippet child({ props })}- <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">- <span class="sr-only">Open menu</span>- <Ellipsis />+ <Button {...props} variant="outline" size="sm">+ <Funnel class="mr-2 size-4" />+ Filter+ <ChevronDown class="ml-2 size-4" /></Button>{/snippet}</DropdownMenu.Trigger>- <DropdownMenu.Content align="end">- <DropdownMenu.Group>- <DropdownMenu.Item onclick={() => goto(`/images/${item.Id}`)}>- <ScanSearch class="size-4" />- Inspect- </DropdownMenu.Item>- <DropdownMenu.Item onclick={() => handleInlineImagePull(item.Id, item.RepoTags?.[0] || '')} disabled={isPullingInline[item.Id] || !item.RepoTags?.[0]}>- {#if isPullingInline[item.Id]}- <Loader2 class="size-4 animate-spin" />- Pulling...- {:else}- <Download class="size-4" />- Pull- {/if}- </DropdownMenu.Item>- <DropdownMenu.Item class="focus:text-red-700! text-red-500" onclick={() => handleImageRemove(item.Id)}>- <Trash2 class="size-4" />- Remove- </DropdownMenu.Item>- </DropdownMenu.Group>+ <DropdownMenu.Content>+ <DropdownMenu.Label>Image Usage</DropdownMenu.Label>+ <DropdownMenu.CheckboxItem+ checked={imageFilters.showUsed}+ onCheckedChange={(checked) => {+ imageFilters.showUsed = checked;+ }}+ >+ Show Used Images+ </DropdownMenu.CheckboxItem>+ <DropdownMenu.CheckboxItem+ checked={imageFilters.showUnused}+ onCheckedChange={(checked) => {+ imageFilters.showUnused = checked;+ }}+ >+ Show Unused Images+ </DropdownMenu.CheckboxItem></DropdownMenu.Content></DropdownMenu.Root>- </Table.Cell>- {/snippet}- </UniversalTable>- </Card.Content>- </Card.Root>- {:else if !error}- <div class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center">- <HardDrive class="text-muted-foreground mb-4 size-12 opacity-40" />- <p class="text-lg font-medium">No images found</p>- <p class="text-muted-foreground mt-1 max-w-md text-sm">Pull a new image using the "Pull Image" button above or use the Docker CLI</p>- <div class="mt-4 flex gap-3">- <Button variant="outline" size="sm" onclick={() => (isPullDialogOpen = true)}>- <Download class="size-4" />- Pull Image- </Button>+ {#if selectedIds.length > 0}+ <ArcaneButton+ action="remove"+ onClick={() => handleDeleteSelected()}+ loading={isLoading.removing}+ disabled={isLoading.removing}+ />+ {/if}+ <ArcaneButton+ action="remove"+ label="Prune Unused"+ onClick={() => (isConfirmPruneDialogOpen = true)}+ loading={isLoading.pruning}+ loadingLabel="Pruning..."+ disabled={isLoading.pruning}+ />+ <ArcaneButton+ action="pull"+ label="Pull Image"+ onClick={() => (isPullDialogOpen = true)}+ loading={isLoading.pulling}+ loadingLabel="Pulling..."+ disabled={isLoading.pulling}+ />+ <ArcaneButton+ action="inspect"+ label="Recheck Maturities"+ onClick={() => handleTriggerBulkMaturityCheck()}+ loading={isLoading.checking}+ loadingLabel="Checking..."+ disabled={isLoading.checking}+ />+ </div>+ </div>+ </Card.Header>+ <Card.Content>+ <UniversalTable+ data={filteredImages}+ columns={[+ { accessorKey: 'RepoTags', header: 'Repository:Tag' },+ { accessorKey: 'Id', header: 'Image ID' },+ { accessorKey: 'Size', header: 'Size' },+ { accessorKey: 'Created', header: 'Created' },+ { accessorKey: 'InUse', header: 'Status' },+ { accessorKey: 'maturity', header: 'Maturity' },+ { accessorKey: 'actions', header: ' ', enableSorting: false }+ ]}+ pagination={{+ pageSize: tablePersistence.getPageSize('images')+ }}+ onPageSizeChange={(newSize) => {+ tablePersistence.setPageSize('images', newSize);+ }}+ sort={{+ defaultSort: { id: 'Created', desc: true }+ }}+ display={{+ filterPlaceholder: 'Search images...',+ noResultsMessage: 'No images found'+ }}+ bind:selectedIds+ >+ {#snippet rows({ item })}+ <Table.Cell>+ {#if item.RepoTags && item.RepoTags.length > 0 && item.RepoTags[0] !== '<none>:<none>'}+ {item.RepoTags[0]}+ {:else}+ <span class="text-muted-foreground italic">Untagged</span>+ {/if}+ </Table.Cell>+ <Table.Cell>+ <code class="bg-muted rounded px-2 py-1 text-xs"+ >{item.Id?.substring(7, 19) || 'N/A'}</code+ >+ </Table.Cell>+ <Table.Cell>{formatBytes(item.Size || 0)}</Table.Cell>+ <Table.Cell>{new Date((item.Created || 0) * 1000).toLocaleDateString()}</Table.Cell>+ <Table.Cell>+ {#if item.InUse}+ <StatusBadge text="In Use" variant="green" />+ {:else}+ <StatusBadge text="Unused" variant="amber" />+ {/if}+ </Table.Cell>+ <Table.Cell>+ {#if item.maturity}+ <MaturityItem maturity={item.maturity} imageId={item.Id} />+ {:else}+ <span class="text-muted-foreground text-sm">N/A</span>+ {/if}+ </Table.Cell>+ <Table.Cell>+ <DropdownMenu.Root>+ <DropdownMenu.Trigger>+ {#snippet child({ props })}+ <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">+ <span class="sr-only">Open menu</span>+ <Ellipsis />+ </Button>+ {/snippet}+ </DropdownMenu.Trigger>+ <DropdownMenu.Content align="end">+ <DropdownMenu.Group>+ <DropdownMenu.Item onclick={() => goto(`/images/${item.Id}`)}>+ <ScanSearch class="size-4" />+ Inspect+ </DropdownMenu.Item>+ <DropdownMenu.Item+ onclick={() => handleInlineImagePull(item.Id, item.RepoTags?.[0] || '')}+ disabled={isPullingInline[item.Id] || !item.RepoTags?.[0]}+ >+ {#if isPullingInline[item.Id]}+ <Loader2 class="size-4 animate-spin" />+ Pulling...+ {:else}+ <Download class="size-4" />+ Pull+ {/if}+ </DropdownMenu.Item>+ <DropdownMenu.Separator />+ <DropdownMenu.Item+ class="focus:text-red-700! text-red-500"+ onclick={() => handleDeleteSelected()}+ disabled={isLoading.removing}+ >+ {#if isLoading.removing}+ <Loader2 class="size-4 animate-spin" />+ {:else}+ <Trash2 class="size-4" />+ {/if}+ Remove+ </DropdownMenu.Item>+ </DropdownMenu.Group>+ </DropdownMenu.Content>+ </DropdownMenu.Root>+ </Table.Cell>+ {/snippet}+ </UniversalTable>+ </Card.Content>+ </Card.Root>+ {:else if !error}+ <div class="flex flex-col items-center justify-center px-6 py-12 text-center">+ <HardDrive class="text-muted-foreground mb-4 size-12 opacity-40" />+ <p class="text-lg font-medium">No images found</p>+ <p class="text-muted-foreground mt-1 max-w-md text-sm">+ Pull an image using the "Pull Image" button above+ </p>+ <div class="mt-4 flex gap-3">+ <Button variant="outline" onclick={() => (isPullDialogOpen = true)}>+ <Download class="size-4" />+ Pull Image+ </Button>+ </div></div>- </div>+ {/if}++ <ImagePullSheet bind:open={isPullDialogOpen} onPullFinished={() => loadImages()} />++ <Dialog.Root bind:open={isConfirmPruneDialogOpen}>+ <Dialog.Content>+ <Dialog.Header>+ <Dialog.Title>Prune Unused Images</Dialog.Title>+ <Dialog.Description+ >Are you sure you want to remove all unused (dangling) Docker images? This will free up+ disk space but cannot be undone. Images actively used by containers will not be+ affected.</Dialog.Description+ >+ </Dialog.Header>+ <div class="flex justify-end gap-3 pt-6">+ <Button+ variant="outline"+ onclick={() => (isConfirmPruneDialogOpen = false)}+ disabled={isLoading.pruning}>Cancel</Button+ >+ <Button variant="destructive" onclick={handlePruneImages} disabled={isLoading.pruning}>+ {#if isLoading.pruning}+ <Loader2 class="mr-2 size-4 animate-spin" /> Prune Images+ {:else}+ Prune Images+ {/if}+ </Button>+ </div>+ </Dialog.Content>+ </Dialog.Root>{/if}-- <ImagePullSheet bind:open={isPullDialogOpen} onPullFinished={() => invalidateAll()} />-- <Dialog.Root bind:open={isConfirmPruneDialogOpen}>- <Dialog.Content>- <Dialog.Header>- <Dialog.Title>Prune Unused Images</Dialog.Title>- <Dialog.Description>Are you sure you want to remove all unused (dangling) Docker images? This will free up disk space but cannot be undone. Images actively used by containers will not be affected.</Dialog.Description>- </Dialog.Header>- <div class="flex justify-end gap-3 pt-6">- <Button variant="outline" onclick={() => (isConfirmPruneDialogOpen = false)} disabled={isLoading.pruning}>Cancel</Button>- <Button variant="destructive" onclick={handlePruneImages} disabled={isLoading.pruning}>- {#if isLoading.pruning}- <Loader2 class="mr-2 size-4 animate-spin" /> Prune Images- {:else}- Prune Images- {/if}- </Button>- </div>- </Dialog.Content>- </Dialog.Root></div><style>diff --git a/frontend/src/routes/images/+page.ts b/frontend/src/routes/images/+page.tsdeleted file mode 100644index 1db40c7b4..000000000--- a/frontend/src/routes/images/+page.ts+++ /dev/null@@ -1,50 +0,0 @@-import { environmentAPI, settingsAPI } from '$lib/services/api';-import type { EnhancedImageInfo } from '$lib/models/image.type';-import type { Settings } from '$lib/types/settings.type';--type ImageData = {- images: EnhancedImageInfo[];- error?: string;- settings: Settings;-};--export const load = async (): Promise<ImageData> => {- try {- const [images, settings] = await Promise.all([environmentAPI.getImages(), settingsAPI.getSettings()]);-- const enhancedImages = await Promise.all(- images.map(async (image): Promise<EnhancedImageInfo> => {- let repo = '<none>';- let tag = '<none>';- if (image.RepoTags && image.RepoTags.length > 0) {- const repoTag = image.RepoTags[0];- if (repoTag.includes(':')) {- [repo, tag] = repoTag.split(':');- } else {- repo = repoTag;- tag = 'latest';- }- }-- return {- ...image,- repo,- tag- };- })- );-- return {- images: enhancedImages,- settings- };- } catch (err: any) {- console.error('Failed to load images:', err);- const settings = await settingsAPI.getSettings().catch(() => ({}) as Settings);- return {- images: [],- error: err.message || 'Failed to connect to Docker or list images.',- settings: settings- };- }-};diff --git a/frontend/src/routes/networks/+page.svelte b/frontend/src/routes/networks/+page.svelteindex bb5c90c15..16275d8ce 100644--- a/frontend/src/routes/networks/+page.svelte+++ b/frontend/src/routes/networks/+page.svelte@@ -1,15 +1,15 @@<script lang="ts">- import { Trash2, Plus, Network, Ellipsis, ScanSearch } from '@lucide/svelte';+ import { Trash2, Plus, Network, Ellipsis, ScanSearch, Loader2 } from '@lucide/svelte';import { Button } from '$lib/components/ui/button/index.js';import * as Card from '$lib/components/ui/card/index.js';import * as Alert from '$lib/components/ui/alert/index.js';import * as Table from '$lib/components/ui/table';import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';import { toast } from 'svelte-sonner';- import { goto, invalidateAll } from '$app/navigation';+ import { goto } from '$app/navigation';import { openConfirmDialog } from '$lib/components/confirm-dialog';import type { PageData } from './$types';- import type { NetworkCreateOptions } from 'dockerode';+ import type { NetworkCreateOptions, NetworkInspectInfo } from 'dockerode';import UniversalTable from '$lib/components/universal-table.svelte';import { handleApiResultWithCallbacks } from '$lib/utils/api.util';import { tryCatch } from '$lib/utils/try-catch';@@ -18,15 +18,15 @@import { DEFAULT_NETWORK_NAMES } from '$lib/constants';import ArcaneButton from '$lib/components/arcane-button.svelte';import { tablePersistence } from '$lib/stores/table-store';+ import { onMount } from 'svelte';let { data }: { data: PageData } = $props();- let networkPageStates = $state({- networks: Array.isArray(data.networks) ? data.networks : [],- selectedNetworks: <string[]>[],- error: data.error,- isCreateDialogOpen: false- });+ let networks = $state(<NetworkInspectInfo[]>[]);+ let selectedNetworks = $state(<string[]>[]);+ let error = $state<string | null>(null);+ let isLoadingNetworks = $state(true);+ let isCreateDialogOpen = $state(false);let isLoading = $state({create: false,@@ -34,20 +34,34 @@refresh: false});- $effect(() => {- networkPageStates.networks = Array.isArray(data.networks) ? data.networks : [];- networkPageStates.error = data.error;- });+ const totalNetworks = $derived(networks.length);+ const bridgeNetworks = $derived(networks.filter((n) => n.Driver === 'bridge').length);+ const overlayNetworks = $derived(networks.filter((n) => n.Driver === 'overlay').length);++ async function loadNetworks() {+ try {+ isLoadingNetworks = true;+ const response = await environmentAPI.getNetworks();+ networks = Array.isArray(response) ? response : [];+ error = null;+ } catch (err) {+ console.error('Failed to load networks:', err);+ error = err instanceof Error ? err.message : 'Failed to load networks';+ networks = [];+ } finally {+ isLoadingNetworks = false;+ }+ }- const totalNetworks = $derived(networkPageStates.networks.length);- const bridgeNetworks = $derived(networkPageStates.networks.filter((n) => n.Driver === 'bridge').length);- const overlayNetworks = $derived(networkPageStates.networks.filter((n) => n.Driver === 'overlay').length);+ onMount(() => {+ loadNetworks();+ });async function refreshNetworks() {isLoading.refresh = true;try {const refreshedNetworks = await environmentAPI.getNetworks();- networkPageStates.networks = Array.isArray(refreshedNetworks) ? refreshedNetworks : [];+ networks = Array.isArray(refreshedNetworks) ? refreshedNetworks : [];} catch (error) {console.error('Failed to refresh networks:', error);toast.error('Failed to refresh networks');@@ -64,8 +78,8 @@setLoadingState: (value) => (isLoading.create = value),onSuccess: async () => {toast.success(`Network "${options.Name}" Created Successfully.`);- await invalidateAll();- networkPageStates.isCreateDialogOpen = false;+ await loadNetworks();+ isCreateDialogOpen = false;}});}@@ -88,7 +102,7 @@setLoadingState: (value) => (isLoading.remove = value),onSuccess: async () => {toast.success(`Network "${name}" Removed Successfully.`);- await invalidateAll();+ await loadNetworks();}});}@@ -97,17 +111,21 @@}async function handleDeleteSelectedNetworks() {- const selectedNetworks = networkPageStates.networks.filter((network) => networkPageStates.selectedNetworks.includes(network.Id));- const defaultNetworks = selectedNetworks.filter((network) => DEFAULT_NETWORK_NAMES.has(network.Name));+ const selectedNetworkList = networks.filter((network) => selectedNetworks.includes(network.Id));+ const defaultNetworks = selectedNetworkList.filter((network) =>+ DEFAULT_NETWORK_NAMES.has(network.Name)+ );if (defaultNetworks.length > 0) {- toast.error(`Cannot delete default networks: ${defaultNetworks.map((n) => n.Name).join(', ')}`);+ toast.error(+ `Cannot delete default networks: ${defaultNetworks.map((n) => n.Name).join(', ')}`+ );return;}openConfirmDialog({title: 'Delete Selected Networks',- message: `Are you sure you want to delete ${networkPageStates.selectedNetworks.length} selected network(s)? This action cannot be undone.`,+ message: `Are you sure you want to delete ${selectedNetworks.length} selected network(s)? This action cannot be undone.`,confirm: {label: 'Delete',destructive: true,@@ -117,8 +135,8 @@let successCount = 0;let failureCount = 0;- for (const networkId of networkPageStates.selectedNetworks) {- const network = networkPageStates.networks.find((n) => n.Id === networkId);+ for (const networkId of selectedNetworks) {+ const network = networks.find((n) => n.Id === networkId);if (!network) continue;const result = await tryCatch(environmentAPI.deleteNetwork(networkId));@@ -134,10 +152,10 @@isLoading.remove = false;if (successCount > 0) {setTimeout(async () => {- await invalidateAll();+ await loadNetworks();}, 500);}- networkPageStates.selectedNetworks = [];+ selectedNetworks = [];}}});@@ -151,143 +169,205 @@<p class="text-muted-foreground mt-1 text-sm">Manage your Docker networks</p></div><div class="flex items-center gap-2">- <ArcaneButton action="restart" onClick={refreshNetworks} loading={isLoading.refresh} disabled={isLoading.refresh} />+ <ArcaneButton+ action="restart"+ onClick={refreshNetworks}+ loading={isLoading.refresh}+ disabled={isLoading.refresh}+ /></div></div>- {#if networkPageStates.error}+ {#if error}<Alert.Root variant="destructive"><Alert.Title>Error Loading Networks</Alert.Title>- <Alert.Description>{networkPageStates.error}</Alert.Description>+ <Alert.Description>{error}</Alert.Description></Alert.Root>{/if}- <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Networks</p>- <p class="text-2xl font-bold">{totalNetworks}</p>- </div>- <div class="rounded-full bg-blue-500/10 p-2">- <Network class="size-5 text-blue-500" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Bridge Networks</p>- <p class="text-2xl font-bold">{bridgeNetworks}</p>- </div>- <div class="rounded-full bg-green-500/10 p-2">- <Network class="size-5 text-green-500" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Overlay Networks</p>- <p class="text-2xl font-bold">{overlayNetworks}</p>- </div>- <div class="rounded-full bg-purple-500/10 p-2">- <Network class="size-5 text-purple-500" />- </div>- </Card.Content>- </Card.Root>- </div>+ {#if isLoadingNetworks}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">+ {#each Array(3) as _}+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div class="space-y-2">+ <div class="bg-muted h-4 w-24 animate-pulse rounded"></div>+ <div class="bg-muted h-8 w-12 animate-pulse rounded"></div>+ </div>+ <div class="bg-muted size-10 animate-pulse rounded-full"></div>+ </Card.Content>+ </Card.Root>+ {/each}+ </div>- {#if networkPageStates.networks && networkPageStates.networks.length > 0}<Card.Root class="border shadow-sm"><Card.Header class="px-6"><div class="flex items-center justify-between"><Card.Title>Network List</Card.Title><div class="flex items-center gap-2">- {#if networkPageStates.selectedNetworks.length > 0}- <ArcaneButton action="remove" onClick={handleDeleteSelectedNetworks} loading={isLoading.remove} disabled={isLoading.remove} />- {/if}- <ArcaneButton action="create" label="Create Network" onClick={() => (networkPageStates.isCreateDialogOpen = true)} loading={isLoading.create} disabled={isLoading.create} />+ <div class="bg-muted h-9 w-28 animate-pulse rounded"></div></div></div></Card.Header>-<Card.Content>- <UniversalTable- data={networkPageStates.networks}- columns={[- { accessorKey: 'Name', header: 'Name' },- { accessorKey: 'Id', header: 'Network ID', enableSorting: false },- { accessorKey: 'Driver', header: 'Driver' },- { accessorKey: 'Scope', header: 'Scope' },- { accessorKey: 'actions', header: ' ', enableSorting: false }- ]}- idKey="Id"- display={{- filterPlaceholder: 'Search networks...',- noResultsMessage: 'No networks found'- }}- pagination={{- pageSize: tablePersistence.getPageSize('networks')- }}- onPageSizeChange={(newSize) => {- tablePersistence.setPageSize('networks', newSize);- }}- sort={{- defaultSort: { id: 'Name', desc: false }- }}- bind:selectedIds={networkPageStates.selectedNetworks}- >- {#snippet rows({ item })}- <Table.Cell>- <a class="font-medium hover:underline" href="/networks/{item.Id}/">{item.Name}</a>- </Table.Cell>- <Table.Cell class="truncate font-mono text-sm">{item.Id}</Table.Cell>- <Table.Cell>{item.Driver}</Table.Cell>- <Table.Cell>{item.Scope}</Table.Cell>- <Table.Cell>- <DropdownMenu.Root>- <DropdownMenu.Trigger>- {#snippet child({ props })}- <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">- <span class="sr-only">Open menu</span>- <Ellipsis />- </Button>- {/snippet}- </DropdownMenu.Trigger>- <DropdownMenu.Content align="end">- <DropdownMenu.Group>- <DropdownMenu.Item onclick={() => goto(`/networks/${item.Id}`)}>- <ScanSearch class="size-4" />- Inspect- </DropdownMenu.Item>- <DropdownMenu.Item class="focus:text-red-700! text-red-500" onclick={() => handleDeleteNetwork(item.Id, item.Name)} disabled={DEFAULT_NETWORK_NAMES.has(item.Name)}>- <Trash2 class="size-4" />- Remove- </DropdownMenu.Item>- </DropdownMenu.Group>- </DropdownMenu.Content>- </DropdownMenu.Root>- </Table.Cell>- {/snippet}- </UniversalTable>+ <div class="flex flex-col items-center justify-center px-6 py-12 text-center">+ <Loader2 class="text-muted-foreground mb-4 size-8 animate-spin" />+ <p class="text-lg font-medium">Loading Networks...</p>+ <p class="text-muted-foreground mt-1 text-sm">Please wait while we fetch your networks</p>+ </div></Card.Content></Card.Root>- {:else if !networkPageStates.error}- <div class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center">- <Network class="text-muted-foreground mb-4 size-12 opacity-40" />- <p class="text-lg font-medium">No networks found</p>- <p class="text-muted-foreground mt-1 max-w-md text-sm">Create a new network using the "Create Network" button above or use the Docker CLI</p>- <div class="mt-4 flex gap-3">- <Button variant="outline" size="sm" onclick={() => (networkPageStates.isCreateDialogOpen = true)}>- <Plus class="size-4" />- Create Network- </Button>- </div>+ {:else}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Total Networks</p>+ <p class="text-2xl font-bold">{totalNetworks}</p>+ </div>+ <div class="rounded-full bg-blue-500/10 p-2">+ <Network class="size-5 text-blue-500" />+ </div>+ </Card.Content>+ </Card.Root>++ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Bridge Networks</p>+ <p class="text-2xl font-bold">{bridgeNetworks}</p>+ </div>+ <div class="rounded-full bg-green-500/10 p-2">+ <Network class="size-5 text-green-500" />+ </div>+ </Card.Content>+ </Card.Root>++ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Overlay Networks</p>+ <p class="text-2xl font-bold">{overlayNetworks}</p>+ </div>+ <div class="rounded-full bg-purple-500/10 p-2">+ <Network class="size-5 text-purple-500" />+ </div>+ </Card.Content>+ </Card.Root></div>++ {#if networks && networks.length > 0}+ <Card.Root class="border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between">+ <Card.Title>Network List</Card.Title>+ <div class="flex items-center gap-2">+ {#if selectedNetworks.length > 0}+ <ArcaneButton+ action="remove"+ onClick={handleDeleteSelectedNetworks}+ loading={isLoading.remove}+ disabled={isLoading.remove}+ />+ {/if}+ <ArcaneButton+ action="create"+ label="Create Network"+ onClick={() => (isCreateDialogOpen = true)}+ loading={isLoading.create}+ disabled={isLoading.create}+ />+ </div>+ </div>+ </Card.Header>++ <Card.Content>+ <UniversalTable+ data={networks}+ columns={[+ { accessorKey: 'Name', header: 'Name' },+ { accessorKey: 'Id', header: 'Network ID', enableSorting: false },+ { accessorKey: 'Driver', header: 'Driver' },+ { accessorKey: 'Scope', header: 'Scope' },+ { accessorKey: 'actions', header: ' ', enableSorting: false }+ ]}+ idKey="Id"+ display={{+ filterPlaceholder: 'Search networks...',+ noResultsMessage: 'No networks found'+ }}+ pagination={{+ pageSize: tablePersistence.getPageSize('networks')+ }}+ onPageSizeChange={(newSize) => {+ tablePersistence.setPageSize('networks', newSize);+ }}+ sort={{+ defaultSort: { id: 'Name', desc: false }+ }}+ bind:selectedIds={selectedNetworks}+ >+ {#snippet rows({ item })}+ <Table.Cell>+ <a class="font-medium hover:underline" href="/networks/{item.Id}/">{item.Name}</a>+ </Table.Cell>+ <Table.Cell class="truncate font-mono text-sm">{item.Id}</Table.Cell>+ <Table.Cell>{item.Driver}</Table.Cell>+ <Table.Cell>{item.Scope}</Table.Cell>+ <Table.Cell>+ <DropdownMenu.Root>+ <DropdownMenu.Trigger>+ {#snippet child({ props })}+ <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">+ <span class="sr-only">Open menu</span>+ <Ellipsis />+ </Button>+ {/snippet}+ </DropdownMenu.Trigger>+ <DropdownMenu.Content align="end">+ <DropdownMenu.Group>+ <DropdownMenu.Item onclick={() => goto(`/networks/${item.Id}`)}>+ <ScanSearch class="size-4" />+ Inspect+ </DropdownMenu.Item>+ <DropdownMenu.Item+ class="focus:text-red-700! text-red-500"+ onclick={() => handleDeleteNetwork(item.Id, item.Name)}+ disabled={DEFAULT_NETWORK_NAMES.has(item.Name)}+ >+ <Trash2 class="size-4" />+ Remove+ </DropdownMenu.Item>+ </DropdownMenu.Group>+ </DropdownMenu.Content>+ </DropdownMenu.Root>+ </Table.Cell>+ {/snippet}+ </UniversalTable>+ </Card.Content>+ </Card.Root>+ {:else if !error}+ <div+ class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center"+ >+ <Network class="text-muted-foreground mb-4 size-12 opacity-40" />+ <p class="text-lg font-medium">No networks found</p>+ <p class="text-muted-foreground mt-1 max-w-md text-sm">+ Create a new network using the "Create Network" button above or use the Docker CLI+ </p>+ <div class="mt-4 flex gap-3">+ <Button variant="outline" size="sm" onclick={() => (isCreateDialogOpen = true)}>+ <Plus class="size-4" />+ Create Network+ </Button>+ </div>+ </div>+ {/if}{/if}- <CreateNetworkSheet bind:open={networkPageStates.isCreateDialogOpen} isLoading={isLoading.create} onSubmit={handleCreateNetworkSubmit} />+ <CreateNetworkSheet+ bind:open={isCreateDialogOpen}+ isLoading={isLoading.create}+ onSubmit={handleCreateNetworkSubmit}+ /></div>diff --git a/frontend/src/routes/networks/+page.ts b/frontend/src/routes/networks/+page.tsindex 9a0a5c9b7..78075ea15 100644--- a/frontend/src/routes/networks/+page.ts+++ b/frontend/src/routes/networks/+page.ts@@ -1,24 +1,17 @@-import type { PageLoad } from './$types';import { environmentAPI } from '$lib/services/api';-import type { NetworkInspectInfo } from 'dockerode';--type NetworkPageData = {- networks: NetworkInspectInfo[];- error?: string;-};+import type { PageLoad } from './$types';-export const load: PageLoad = async (): Promise<NetworkPageData> => {- try {- const networks = await environmentAPI.getNetworks();- return {- networks: Array.isArray(networks) ? networks : []- };- } catch (err: unknown) {- console.error('Failed to load networks:', err);- const message = err instanceof Error ? err.message : 'Failed to connect to Docker or list networks.';- return {- networks: [],- error: message- };- }+export const load: PageLoad = async () => {+ // try {+ // const networks = await environmentAPI.getNetworks();+ // return {+ // networks: networks || []+ // };+ // } catch (error) {+ // console.error('Error loading networks data:', error);+ // return {+ // networks: [],+ // error: error instanceof Error ? error.message : String(error)+ // };+ // }};diff --git a/frontend/src/routes/volumes/+page.svelte b/frontend/src/routes/volumes/+page.svelteindex 97689d00b..e993018d3 100644--- a/frontend/src/routes/volumes/+page.svelte+++ b/frontend/src/routes/volumes/+page.svelte@@ -1,36 +1,48 @@<script lang="ts">- import { HardDrive, Trash2, Plus, Funnel, ChevronDown, Ellipsis, ScanSearch } from '@lucide/svelte';+ import { Trash2, HardDrive, Ellipsis, ScanSearch, Loader2, ChevronDown } from '@lucide/svelte';import { Button } from '$lib/components/ui/button/index.js';import * as Card from '$lib/components/ui/card/index.js';import * as Alert from '$lib/components/ui/alert/index.js';import * as Table from '$lib/components/ui/table';import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';import { toast } from 'svelte-sonner';- import { goto, invalidateAll } from '$app/navigation';+ import { goto } from '$app/navigation';import { openConfirmDialog } from '$lib/components/confirm-dialog';import type { PageData } from './$types';import UniversalTable from '$lib/components/universal-table.svelte';import { handleApiResultWithCallbacks } from '$lib/utils/api.util';import { tryCatch } from '$lib/utils/try-catch';- import CreateVolumeSheet from '$lib/components/sheets/create-volume-sheet.svelte';import { formatFriendlyDate } from '$lib/utils/date.utils';+ import CreateVolumeSheet from '$lib/components/sheets/create-volume-sheet.svelte';import StatusBadge from '$lib/components/badges/status-badge.svelte';import type { VolumeCreateOptions, VolumeInspectInfo } from 'dockerode';import ArcaneButton from '$lib/components/arcane-button.svelte';import { tablePersistence } from '$lib/stores/table-store';import { environmentAPI } from '$lib/services/api';+ import { onMount } from 'svelte';let { data }: { data: PageData } = $props();- let volumePageStates = $state({- volumes: Array.isArray(data.volumes) ? data.volumes : [],- selectedIds: <string[]>[],- error: data.error,+ let volumes = $state<EnhancedVolumeInfo[]>([]);+ let error = $state<string | null>(null);+ let selectedIds = $state<string[]>([]);+ let isLoadingVolumes = $state(true);++ let volumeFilters = $state({showUsed: true,showUnused: true});- const filteredVolumes = $derived(volumePageStates.volumes.filter((vol) => (volumePageStates.showUsed && vol.inUse) || (volumePageStates.showUnused && !vol.inUse)));+ type EnhancedVolumeInfo = VolumeInspectInfo & {+ inUse: boolean;+ CreatedAt: string;+ };++ const filteredVolumes = $derived(+ volumes.filter(+ (vol) => (volumeFilters.showUsed && vol.inUse) || (volumeFilters.showUnused && !vol.inUse)+ )+ );let isDialogOpen = $state({create: false,@@ -43,45 +55,58 @@refresh: false});- const totalVolumes = $derived(volumePageStates.volumes.length);+ const totalVolumes = $derived(volumes.length);+ const usedVolumes = $derived(volumes.filter((v) => v.inUse).length);+ const unusedVolumes = $derived(volumes.filter((v) => !v.inUse).length);- async function refreshVolumes() {- isLoading.refresh = true;+ async function loadVolumes() {try {- const refreshedVolumes = await environmentAPI.getVolumes();- const volumes = Array.isArray(refreshedVolumes) ? refreshedVolumes : [];-- const enhancedVolumes = await Promise.all(- volumes.map(async (volume) => {- const inUse = await environmentAPI.getVolumeUsage(volume.Name).catch(() => true);- return { ...volume, inUse };- })- );-- volumePageStates.volumes = enhancedVolumes;- } catch (error) {- console.error('Failed to refresh volumes:', error);- toast.error('Failed to refresh volumes');+ isLoadingVolumes = true;+ const response = await environmentAPI.getVolumes();+ volumes = response || [];+ error = null;+ } catch (err) {+ console.error('Failed to load volumes:', err);+ error = err instanceof Error ? err.message : 'Failed to load volumes';+ volumes = [];} finally {- isLoading.refresh = false;+ isLoadingVolumes = false;}}- async function handleRemoveVolumeConfirm(volumeName: string) {+ onMount(() => {+ loadVolumes();+ });++ async function handleCreateVolumeSubmit(options: VolumeCreateOptions) {+ isLoading.creating = true;+ handleApiResultWithCallbacks({+ result: await tryCatch(environmentAPI.createVolume(options)),+ message: `Failed to Create Volume "${options.Name}"`,+ setLoadingState: (value) => (isLoading.creating = value),+ onSuccess: async () => {+ toast.success(`Volume "${options.Name}" Created Successfully.`);+ await loadVolumes();+ isDialogOpen.create = false;+ }+ });+ }++ async function handleRemoveVolumeConfirm(name: string) {openConfirmDialog({- title: 'Delete Volume',- message: `Are you sure you want to delete volume "${volumeName}"? This action cannot be undone.`,+ title: `Remove Volume "${name}"`,+ message: `Are you sure you want to remove the volume "${name}"? This action cannot be undone and will permanently delete all data stored in this volume.`,confirm: {- label: 'Delete',+ label: 'Remove',destructive: true,action: async () => {handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.deleteVolume(volumeName)),- message: `Failed to Remove Volume "${volumeName}"`,+ result: await tryCatch(environmentAPI.deleteVolume(name)),+ message: `Failed to Remove Volume "${name}"`,setLoadingState: (value) => (isLoading.remove = value),onSuccess: async () => {- toast.success(`Volume "${volumeName}" Removed Successfully.`);- await invalidateAll();+ toast.success(`Volume "${name}" Removed Successfully.`);+ await loadVolumes();}});}@@ -89,49 +114,28 @@});}- async function handleCreateVolume(volumeCreate: VolumeCreateOptions) {- handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.createVolume(volumeCreate)),- message: `Failed to Create Volume "${volumeCreate.Name}"`,- setLoadingState: (value) => (isLoading.creating = value),- onSuccess: async () => {- toast.success(`Volume "${volumeCreate.Name}" created successfully.`);- await invalidateAll();- isDialogOpen.create = false;- }- });- }-async function handleDeleteSelected() {+ if (selectedIds.length === 0) return;+openConfirmDialog({- title: 'Delete Selected Volumes',- message: `Are you sure you want to delete ${volumePageStates.selectedIds.length} selected volume(s)? This action cannot be undone. Volumes currently used by containers will not be deleted.`,+ title: `Remove ${selectedIds.length} Volume${selectedIds.length > 1 ? 's' : ''}`,+ message: `Are you sure you want to remove the selected volume${selectedIds.length > 1 ? 's' : ''}? This action cannot be undone and will permanently delete all data.`,confirm: {- label: 'Delete',+ label: 'Remove',destructive: true,action: async () => {isLoading.remove = true;-let successCount = 0;let failureCount = 0;- for (const name of volumePageStates.selectedIds) {- const volume = volumePageStates.volumes?.find((v) => v.Name === name);-- if (volume?.inUse) {- toast.error(`Volume "${volume.Name}" is in use and cannot be deleted.`);- failureCount++;- continue;- }-- if (!volume?.Name) continue;- const result = await tryCatch(environmentAPI.deleteVolume(volume.Name));+ for (const volumeName of selectedIds) {+ const result = await tryCatch(environmentAPI.deleteVolume(volumeName));handleApiResultWithCallbacks({result,- message: `Failed to delete volume "${volume.Name}"`,- setLoadingState: (value) => (isLoading.remove = value),- onSuccess: async () => {- toast.success(`Volume "${volume.Name}" deleted successfully.`);+ message: `Failed to remove volume ${volumeName}`,+ setLoadingState: () => {},+ onSuccess: () => {+ toast.success(`Volume "${volumeName}" deleted successfully.`);successCount++;}});@@ -144,18 +148,14 @@if (successCount > 0) {setTimeout(async () => {- await invalidateAll();+ await loadVolumes();}, 500);}- volumePageStates.selectedIds = [];+ selectedIds = [];}}});}-- $effect(() => {- volumePageStates.volumes = Array.isArray(data.volumes) ? data.volumes : [];- });</script><div class="space-y-6">@@ -165,167 +165,228 @@<p class="text-muted-foreground mt-1 text-sm">Manage your Docker volumes</p></div><div class="flex items-center gap-2">- <ArcaneButton action="restart" onClick={refreshVolumes} label="Refresh" loading={isLoading.refresh} disabled={isLoading.refresh} />+ <ArcaneButton+ action="restart"+ onClick={loadVolumes}+ label="Refresh"+ loading={isLoading.refresh}+ disabled={isLoading.refresh}+ /></div></div>- {#if volumePageStates.error}+ {#if error}<Alert.Root variant="destructive"><Alert.Title>Error Loading Volumes</Alert.Title>- <Alert.Description>{volumePageStates.error}</Alert.Description>+ <Alert.Description>{error}</Alert.Description></Alert.Root>{/if}- <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Volumes</p>- <p class="text-2xl font-bold">{totalVolumes}</p>- </div>- <div class="rounded-full bg-blue-500/10 p-2">- <HardDrive class="size-5 text-blue-500" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">In Use</p>- <p class="text-2xl font-bold">{volumePageStates.volumes.filter((v) => v.inUse).length}</p>- </div>- <div class="rounded-full bg-green-500/10 p-2">- <HardDrive class="size-5 text-green-500" />- </div>- </Card.Content>- </Card.Root>- </div>+ {#if isLoadingVolumes}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">+ {#each Array(2) as _}+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div class="space-y-2">+ <div class="bg-muted h-4 w-24 animate-pulse rounded"></div>+ <div class="bg-muted h-8 w-12 animate-pulse rounded"></div>+ </div>+ <div class="bg-muted size-10 animate-pulse rounded-full"></div>+ </Card.Content>+ </Card.Root>+ {/each}+ </div>- {#if volumePageStates.volumes && volumePageStates.volumes.length > 0}<Card.Root class="border shadow-sm"><Card.Header class="px-6"><div class="flex items-center justify-between">- <Card.Title>Volume List</Card.Title>+ <div>+ <Card.Title>Volumes List</Card.Title>+ </div><div class="flex items-center gap-2">- <DropdownMenu.Root>- <DropdownMenu.Trigger>- {#snippet child({ props })}- <Button {...props} variant="outline">- <Funnel class="size-4" />- Filter- <ChevronDown class="size-4" />- </Button>- {/snippet}- </DropdownMenu.Trigger>- <DropdownMenu.Content>- <DropdownMenu.Label>Volume Usage</DropdownMenu.Label>- <DropdownMenu.CheckboxItem- checked={volumePageStates.showUsed}- onCheckedChange={(checked) => {- volumePageStates.showUsed = checked;- }}- >- Show Used Volumes- </DropdownMenu.CheckboxItem>- <DropdownMenu.CheckboxItem- checked={volumePageStates.showUnused}- onCheckedChange={(checked) => {- volumePageStates.showUnused = checked;- }}- >- Show Unused Volumes- </DropdownMenu.CheckboxItem>- </DropdownMenu.Content>- </DropdownMenu.Root>- {#if volumePageStates.selectedIds.length > 0}- <ArcaneButton action="remove" onClick={handleDeleteSelected} loading={isLoading.remove} disabled={isLoading.remove} />- {/if}- <ArcaneButton action="create" label="Create Volume" onClick={() => (isDialogOpen.create = true)} loading={isLoading.creating} disabled={isLoading.creating} />+ <div class="bg-muted h-9 w-32 animate-pulse rounded"></div>+ <div class="bg-muted h-9 w-28 animate-pulse rounded"></div></div></div></Card.Header>-<Card.Content>- <UniversalTable- data={filteredVolumes}- columns={[- { accessorKey: 'Name', header: 'Name' },- { accessorKey: 'inUse', header: 'Status', enableSorting: false },- { accessorKey: 'Driver', header: 'Driver' },- { accessorKey: 'CreatedAt', header: 'Created' },- { accessorKey: 'actions', header: ' ', enableSorting: false }- ]}- idKey="Name"- display={{- filterPlaceholder: 'Search volumes...',- noResultsMessage: 'No volumes found'- }}- pagination={{- pageSize: tablePersistence.getPageSize('volumes')- }}- onPageSizeChange={(newSize) => {- tablePersistence.setPageSize('volumes', newSize);- }}- sort={{- defaultSort: { id: 'Name', desc: false }- }}- bind:selectedIds={volumePageStates.selectedIds}- >- {#snippet rows({ item })}- <Table.Cell>- <a class="font-medium hover:underline" href="/volumes/{item.Name}/">{item.Name}</a>- </Table.Cell>- <Table.Cell>- {#if item.inUse}- <StatusBadge text="In Use" variant="green" />- {:else}- <StatusBadge text="Unused" variant="amber" />- {/if}- </Table.Cell>- <Table.Cell>{item.Driver}</Table.Cell>- <Table.Cell>{formatFriendlyDate(item.CreatedAt)}</Table.Cell>- <Table.Cell>+ <div class="flex flex-col items-center justify-center px-6 py-12 text-center">+ <Loader2 class="text-muted-foreground mb-4 size-8 animate-spin" />+ <p class="text-lg font-medium">Loading Volumes...</p>+ <p class="text-muted-foreground mt-1 text-sm">Please wait while we fetch your volumes</p>+ </div>+ </Card.Content>+ </Card.Root>+ {:else}+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">+ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Total Volumes</p>+ <p class="text-2xl font-bold">{totalVolumes}</p>+ </div>+ <div class="rounded-full bg-blue-500/10 p-2">+ <HardDrive class="size-5 text-blue-500" />+ </div>+ </Card.Content>+ </Card.Root>++ <Card.Root>+ <Card.Content class="flex items-center justify-between p-4">+ <div>+ <p class="text-muted-foreground text-sm font-medium">Used Volumes</p>+ <p class="text-2xl font-bold">{usedVolumes}</p>+ </div>+ <div class="rounded-full bg-green-500/10 p-2">+ <HardDrive class="size-5 text-green-500" />+ </div>+ </Card.Content>+ </Card.Root>+ </div>++ {#if filteredVolumes.length > 0}+ <Card.Root class="border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between">+ <div>+ <Card.Title>Volumes List</Card.Title>+ </div>+ <div class="flex items-center gap-2"><DropdownMenu.Root><DropdownMenu.Trigger>{#snippet child({ props })}- <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">- <span class="sr-only">Open menu</span>- <Ellipsis />+ <Button {...props} variant="outline" size="sm">+ Filter <ChevronDown class="ml-2 size-4" /></Button>{/snippet}</DropdownMenu.Trigger>- <DropdownMenu.Content align="end">- <DropdownMenu.Group>- <DropdownMenu.Item onclick={() => goto(`/volumes/${item.Name}`)}>- <ScanSearch class="size-4" />- Inspect- </DropdownMenu.Item>- <DropdownMenu.Item class="focus:text-red-700! text-red-500" onclick={() => handleRemoveVolumeConfirm(item.Name)}>- <Trash2 class="size-4" />- Remove- </DropdownMenu.Item>- </DropdownMenu.Group>+ <DropdownMenu.Content>+ <DropdownMenu.Label>Volume Usage</DropdownMenu.Label>+ <DropdownMenu.CheckboxItem+ checked={volumeFilters.showUsed}+ onCheckedChange={(checked) => {+ volumeFilters.showUsed = checked;+ }}+ >+ Show Used Volumes+ </DropdownMenu.CheckboxItem>+ <DropdownMenu.CheckboxItem+ checked={volumeFilters.showUnused}+ onCheckedChange={(checked) => {+ volumeFilters.showUnused = checked;+ }}+ >+ Show Unused Volumes+ </DropdownMenu.CheckboxItem></DropdownMenu.Content></DropdownMenu.Root>- </Table.Cell>- {/snippet}- </UniversalTable>- </Card.Content>- </Card.Root>- {:else if !volumePageStates.error}- <div class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center">- <HardDrive class="text-muted-foreground mb-4 size-12 opacity-40" />- <p class="text-lg font-medium">No volumes found</p>- <p class="text-muted-foreground mt-1 max-w-md text-sm">Create a new volume using the "Create Volume" button above or use the Docker CLI</p>- <div class="mt-4 flex gap-3">- <Button variant="outline" size="sm" onclick={() => (isDialogOpen.create = true)}>- <Plus class="size-4" />- Create Volume- </Button>+ {#if selectedIds.length > 0}+ <ArcaneButton+ action="remove"+ onClick={handleDeleteSelected}+ loading={isLoading.remove}+ disabled={isLoading.remove}+ />+ {/if}+ <ArcaneButton+ action="create"+ label="Create Volume"+ onClick={() => (isDialogOpen.create = true)}+ loading={isLoading.creating}+ disabled={isLoading.creating}+ />+ </div>+ </div>+ </Card.Header>+ <Card.Content>+ <UniversalTable+ data={filteredVolumes}+ columns={[+ { accessorKey: 'Name', header: 'Name' },+ { accessorKey: 'inUse', header: 'Status' },+ { accessorKey: 'Driver', header: 'Driver' },+ { accessorKey: 'CreatedAt', header: 'Created' },+ { accessorKey: 'actions', header: ' ', enableSorting: false }+ ]}+ pagination={{+ pageSize: tablePersistence.getPageSize('volumes')+ }}+ onPageSizeChange={(newSize) => {+ tablePersistence.setPageSize('volumes', newSize);+ }}+ sort={{+ defaultSort: { id: 'Name', desc: false }+ }}+ bind:selectedIds+ >+ {#snippet rows({ item })}+ <Table.Cell>+ <a class="font-medium hover:underline" href="/volumes/{item.Name}/">{item.Name}</a>+ </Table.Cell>+ <Table.Cell>+ {#if item.inUse}+ <StatusBadge text="In Use" variant="green" />+ {:else}+ <StatusBadge text="Unused" variant="amber" />+ {/if}+ </Table.Cell>+ <Table.Cell>{item.Driver}</Table.Cell>+ <Table.Cell>{formatFriendlyDate(item.CreatedAt)}</Table.Cell>+ <Table.Cell>+ <DropdownMenu.Root>+ <DropdownMenu.Trigger>+ {#snippet child({ props })}+ <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">+ <span class="sr-only">Open menu</span>+ <Ellipsis />+ </Button>+ {/snippet}+ </DropdownMenu.Trigger>+ <DropdownMenu.Content align="end">+ <DropdownMenu.Group>+ <DropdownMenu.Item onclick={() => goto(`/volumes/${item.Name}`)}>+ <ScanSearch class="size-4" />+ Inspect+ </DropdownMenu.Item>+ <DropdownMenu.Item+ class="focus:text-red-700! text-red-500"+ onclick={() => handleRemoveVolumeConfirm(item.Name)}+ >+ <Trash2 class="size-4" />+ Remove+ </DropdownMenu.Item>+ </DropdownMenu.Group>+ </DropdownMenu.Content>+ </DropdownMenu.Root>+ </Table.Cell>+ {/snippet}+ </UniversalTable>+ </Card.Content>+ </Card.Root>+ {:else if !error}+ <div+ class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center"+ >+ <HardDrive class="text-muted-foreground mb-4 size-12 opacity-40" />+ <p class="text-lg font-medium">No volumes found</p>+ <p class="text-muted-foreground mt-1 max-w-md text-sm">+ Create a new volume using the "Create Volume" button above+ </p>+ <div class="mt-4 flex gap-3">+ <ArcaneButton+ action="create"+ label="Create Volume"+ onClick={() => (isDialogOpen.create = true)}+ size="sm"+ />+ </div></div>- </div>- {/if}+ {/if}- <CreateVolumeSheet bind:open={isDialogOpen.create} isLoading={isLoading.creating} onSubmit={(volumeCreateData) => handleCreateVolume(volumeCreateData)} />+ <CreateVolumeSheet+ bind:open={isDialogOpen.create}+ isLoading={isLoading.creating}+ onSubmit={handleCreateVolumeSubmit}+ />+ {/if}</div>diff --git a/frontend/src/routes/volumes/+page.ts b/frontend/src/routes/volumes/+page.tsdeleted file mode 100644index 53177338d..000000000--- a/frontend/src/routes/volumes/+page.ts+++ /dev/null@@ -1,42 +0,0 @@-import { environmentAPI } from '$lib/services/api';-import type { PageLoad } from './$types';-import type { VolumeInspectInfo } from 'dockerode';--type EnhancedVolumeInfo = VolumeInspectInfo & {- inUse: boolean;- CreatedAt: string;-};--type VolumePageData = {- volumes: EnhancedVolumeInfo[];- error?: string;-};--export const load: PageLoad = async (): Promise<VolumePageData> => {- try {- const volumesData = await environmentAPI.getVolumes();- const volumes = Array.isArray(volumesData) ? volumesData : [];-- const enhancedVolumes = await Promise.all(- volumes.map(async (volume): Promise<EnhancedVolumeInfo> => {- const inUse = await environmentAPI.getVolumeUsage(volume.Name);-- return {- ...volume,- inUse: inUse.data ? inUse.data.inUse : false- };- })- );-- return {- volumes: enhancedVolumes- };- } catch (err: unknown) {- console.error('Failed to load volumes:', err);- const message = err instanceof Error ? err.message : 'Failed to connect to Docker or list volumes.';- return {- volumes: [],- error: message- };- }-};