Skip to content

Modern Docker Management, Designed for Everyone

chore: improve ui consistency and maintainability (#582)

Chase Baucomb0ef5d95f3ce
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 1be909887..815ba21b2 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1091,5 +1091,7 @@
"using_server_default": "Using server default",
"mobile_navigation": "Mobile navigation",
"on": "On",
- "off": "Off"
+ "off": "Off",
+ "tap_to_edit": "Tap to edit",
+ "cannot_edit": "Cannot edit"
}
diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelte
index 59f0fe0d9..3cbe5396d 100644
--- a/frontend/src/lib/components/action-buttons.svelte
+++ b/frontend/src/lib/components/action-buttons.svelte
@@ -9,8 +9,6 @@
import DownloadIcon from '@lucide/svelte/icons/download';
import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import { environmentStore, LOCAL_DOCKER_ENVIRONMENT_ID } from '$lib/stores/environment.store';
- import { get } from 'svelte/store';
import { m } from '$lib/paraglide/messages';
import { containerService } from '$lib/services/container-service';
import { projectService } from '$lib/services/project-service';
@@ -417,8 +415,7 @@
</script>
<div>
- <!-- Desktop / tablet buttons -->
- <div class="hidden items-center gap-2 sm:flex">
+ <div class="hidden items-center gap-2 lg:flex">
{#if !isRunning}
{#if type === 'container'}
<ArcaneButton action="start" onclick={() => handleStart()} loading={uiLoading.start} />
@@ -475,10 +472,9 @@
{/if}
</div>
- <!-- Mobile: ellipsis dropdown -->
- <div class="flex items-center sm:hidden">
+ <div class="flex items-center lg:hidden">
<DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
+ <DropdownMenu.Trigger class="bg-background/70 inline-flex size-9 items-center justify-center rounded-lg border">
<span class="sr-only">{m.common_open_menu()}</span>
<EllipsisIcon />
</DropdownMenu.Trigger>
diff --git a/frontend/src/lib/components/code-editor/editor.svelte b/frontend/src/lib/components/code-editor/editor.svelte
index 99346d1f9..805150f44 100644
--- a/frontend/src/lib/components/code-editor/editor.svelte
+++ b/frontend/src/lib/components/code-editor/editor.svelte
@@ -19,10 +19,17 @@
placeholder = m.editor_placeholder(),
readOnly = false,
height = '550px',
- fontSize = '11px',
+ fontSize = '12px',
class: className = ''
} = $props();
+ const dynamicHeight = $derived(() => {
+ if (height === 'full' || height === 'auto') {
+ return 'calc(100dvh - 240px)';
+ }
+ return height;
+ });
+
let editorView: EditorView;
function getLanguageExtension(lang: CodeLanguage): Extension[] {
@@ -65,7 +72,7 @@
const styles = $derived({
'&': {
- height,
+ height: dynamicHeight(),
fontSize
},
'&.cm-editor[contenteditable=false]': {
diff --git a/frontend/src/lib/components/log-viewer.svelte b/frontend/src/lib/components/log-viewer.svelte
index c5c671845..586f545a4 100644
--- a/frontend/src/lib/components/log-viewer.svelte
+++ b/frontend/src/lib/components/log-viewer.svelte
@@ -298,8 +298,8 @@
<div
bind:this={logContainer}
- class="log-viewer overflow-y-auto rounded-lg border bg-black font-mono text-sm text-white"
- style="height: {height}"
+ class="log-viewer overflow-y-auto rounded-lg border bg-black font-mono text-xs text-white sm:text-sm"
+ style="height: {height}; min-height: 300px;"
role="log"
aria-live={isStreaming ? 'polite' : 'off'}
aria-relevant="additions"
@@ -320,7 +320,32 @@
</div>
{:else}
{#each visibleLogs as log (log.id)}
- <div class="flex border-l-2 border-transparent px-3 py-1 transition-colors hover:border-blue-500 hover:bg-gray-900/50">
+ <div
+ class="border-l-2 border-transparent px-3 py-2 transition-colors hover:border-blue-500 hover:bg-gray-900/50 sm:hidden"
+ >
+ <div class="mb-1 flex items-center gap-2 text-xs">
+ <span class="shrink-0 {getLevelClass(log.level)}">
+ {log.level.toUpperCase()}
+ </span>
+ {#if type === 'project' && log.service}
+ <span class="shrink-0 truncate text-blue-400" title={log.service}>
+ {log.service}
+ </span>
+ {/if}
+ {#if showTimestamps}
+ <span class="ml-auto shrink-0 text-gray-500">
+ {new Date(log.timestamp).toLocaleTimeString()}
+ </span>
+ {/if}
+ </div>
+ <div class="text-sm break-words whitespace-pre-wrap text-gray-300">
+ {log.message}
+ </div>
+ </div>
+
+ <div
+ class="hidden border-l-2 border-transparent px-3 py-1 transition-colors hover:border-blue-500 hover:bg-gray-900/50 sm:flex"
+ >
{#if showTimestamps}
<span class="mr-3 min-w-fit shrink-0 text-xs text-gray-500">
{formatTimestamp(log.timestamp)}
@@ -334,7 +359,7 @@
{log.service}
</span>
{/if}
- <span class="flex-1 whitespace-pre-wrap break-words text-gray-300">
+ <span class="flex-1 break-words whitespace-pre-wrap text-gray-300">
{log.message}
</span>
</div>
diff --git a/frontend/src/lib/components/tab-bar/index.ts b/frontend/src/lib/components/tab-bar/index.ts
new file mode 100644
index 000000000..6f57c40f3
--- /dev/null
+++ b/frontend/src/lib/components/tab-bar/index.ts
@@ -0,0 +1,2 @@
+export { default as TabBar } from './tab-bar.svelte';
+export type { TabItem } from './types.ts';
\ No newline at end of file
diff --git a/frontend/src/lib/components/tab-bar/tab-bar.svelte b/frontend/src/lib/components/tab-bar/tab-bar.svelte
new file mode 100644
index 000000000..ad6fcfe00
--- /dev/null
+++ b/frontend/src/lib/components/tab-bar/tab-bar.svelte
@@ -0,0 +1,49 @@
+<script lang="ts">
+ import * as Tabs from '$lib/components/ui/tabs/index.js';
+ import { cn } from '$lib/utils.js';
+ import type { TabItem } from './types.ts';
+
+ interface Props {
+ items: TabItem[];
+ value: string;
+ onValueChange: (value: string) => void;
+ class?: string;
+ }
+
+ let { items, onValueChange, class: className }: Props = $props();
+</script>
+
+<Tabs.List class={cn('flex overflow-x-auto scrollbar-hide justify-start gap-4 w-full', className)}>
+ {#each items as item}
+ {@const IconComponent = item.icon}
+ <Tabs.Trigger
+ value={item.value}
+ class={cn('gap-2 flex-shrink-0 whitespace-nowrap', item.class)}
+ disabled={item.disabled}
+ onclick={() => onValueChange(item.value)}
+ >
+ {#if IconComponent}
+ <IconComponent class="size-4" />
+ {/if}
+ {item.label}
+ {#if item.badge !== undefined}
+ <span
+ class="bg-primary text-primary-foreground ml-1 inline-flex min-w-[18px] items-center justify-center rounded-full px-1 text-[10px] font-medium"
+ >
+ {item.badge}
+ </span>
+ {/if}
+ </Tabs.Trigger>
+ {/each}
+</Tabs.List>
+
+<style>
+ :global(.scrollbar-hide) {
+ -ms-overflow-style: none; /* IE and Edge */
+ scrollbar-width: none; /* Firefox */
+ }
+
+ :global(.scrollbar-hide::-webkit-scrollbar) {
+ display: none; /* Chrome, Safari and Opera */
+ }
+</style>
diff --git a/frontend/src/lib/components/tab-bar/types.ts b/frontend/src/lib/components/tab-bar/types.ts
new file mode 100644
index 000000000..de934c59f
--- /dev/null
+++ b/frontend/src/lib/components/tab-bar/types.ts
@@ -0,0 +1,10 @@
+import type { Icon as IconType } from '@lucide/svelte';
+
+export interface TabItem {
+ value: string;
+ label: string;
+ icon?: typeof IconType;
+ badge?: string | number;
+ disabled?: boolean;
+ class?: string;
+}
diff --git a/frontend/src/lib/layouts/index.ts b/frontend/src/lib/layouts/index.ts
new file mode 100644
index 000000000..561e98030
--- /dev/null
+++ b/frontend/src/lib/layouts/index.ts
@@ -0,0 +1,3 @@
+export { default as ResourcePageLayout, type ActionButton, type StatCardConfig, type StatCardsColumns } from './resource-page-layout.svelte';
+export { default as TabbedPageLayout } from './tabbed-page-layout.svelte';
+export { default as SettingsPageLayout, type SettingsActionButton, type SettingsStatCard, type SettingsPageType } from './settings-page-layout.svelte';
diff --git a/frontend/src/lib/layouts/resource-page-layout.svelte b/frontend/src/lib/layouts/resource-page-layout.svelte
new file mode 100644
index 000000000..b82865fcc
--- /dev/null
+++ b/frontend/src/lib/layouts/resource-page-layout.svelte
@@ -0,0 +1,164 @@
+<script lang="ts">
+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';
+ import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
+ import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
+ import StatCard from '$lib/components/stat-card.svelte';
+ import type { Snippet } from 'svelte';
+ import type { Icon as IconType } from '@lucide/svelte';
+ import type { Action } from '$lib/components/arcane-button/index.js';
+
+ export interface ActionButton {
+ id: string;
+ action: Action;
+ label: string;
+ loadingLabel?: string;
+ loading?: boolean;
+ disabled?: boolean;
+ onclick: () => void;
+ showOnMobile?: boolean;
+ }
+
+ export interface StatCardConfig {
+ title: string;
+ value: string | number;
+ subtitle?: string;
+ icon: typeof IconType;
+ iconColor?: string;
+ bgColor?: string;
+ class?: string;
+ }
+
+ export type StatCardsColumns = 'auto' | 1 | 2 | 3 | 4 | 5;
+
+ interface Props {
+ title: string;
+ subtitle?: string;
+ actionButtons?: ActionButton[];
+ statCards?: StatCardConfig[];
+ statCardsColumns?: StatCardsColumns;
+ mainContent: Snippet;
+ additionalContent?: Snippet;
+ class?: string;
+ containerClass?: string;
+ }
+
+ let {
+ title,
+ subtitle,
+ actionButtons = [],
+ statCards = [],
+ statCardsColumns = 'auto',
+ mainContent,
+ additionalContent,
+ class: className = '',
+ containerClass = 'space-y-6'
+ }: Props = $props();
+
+ const mobileVisibleButtons = $derived(actionButtons.filter((btn) => btn.showOnMobile));
+ const mobileDropdownButtons = $derived(actionButtons.filter((btn) => !btn.showOnMobile));
+
+ const getStatCardsGridClass = (columns: typeof statCardsColumns) => {
+ switch (columns) {
+ case 1:
+ return 'grid-cols-1';
+ case 2:
+ return 'grid-cols-1 sm:grid-cols-2';
+ case 3:
+ return 'grid-cols-1 sm:grid-cols-3';
+ case 4:
+ return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4';
+ case 5:
+ return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-5';
+ case 'auto':
+ default:
+ if (statCards.length <= 2) return 'grid-cols-1 sm:grid-cols-2';
+ if (statCards.length === 3) return 'grid-cols-1 sm:grid-cols-3';
+ if (statCards.length === 4) return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4';
+ return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-5';
+ }
+ };
+</script>
+
+<div class="{containerClass} {className}">
+ <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
+ <div>
+ <h1 class="text-2xl font-bold tracking-tight sm:text-3xl">{title}</h1>
+ {#if subtitle}
+ <p class="text-muted-foreground mt-1 text-sm">{subtitle}</p>
+ {/if}
+ </div>
+
+ {#if actionButtons.length > 0}
+ <div class="hidden items-center gap-2 sm:flex">
+ {#each actionButtons as button}
+ <ArcaneButton
+ action={button.action}
+ customLabel={button.label}
+ loadingLabel={button.loadingLabel}
+ loading={button.loading}
+ disabled={button.disabled}
+ onclick={button.onclick}
+ />
+ {/each}
+ </div>
+
+ <div class="absolute top-4 right-4 flex items-center gap-2 sm:hidden">
+ {#each mobileVisibleButtons as button}
+ <ArcaneButton
+ action={button.action}
+ customLabel={button.label}
+ loadingLabel={button.loadingLabel}
+ loading={button.loading}
+ disabled={button.disabled}
+ onclick={button.onclick}
+ size="sm"
+ />
+ {/each}
+
+ {#if mobileDropdownButtons.length > 0}
+ <DropdownMenu.Root>
+ <DropdownMenu.Trigger class="bg-background/70 inline-flex size-9 items-center justify-center rounded-lg border">
+ <span class="sr-only">Open menu</span>
+ <EllipsisIcon class="size-4" />
+ </DropdownMenu.Trigger>
+
+ <DropdownMenu.Content
+ align="end"
+ class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[160px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
+ >
+ <DropdownMenu.Group>
+ {#each mobileDropdownButtons as button}
+ <DropdownMenu.Item onclick={button.onclick} disabled={button.disabled || button.loading}>
+ {button.loading ? button.loadingLabel || button.label : button.label}
+ </DropdownMenu.Item>
+ {/each}
+ </DropdownMenu.Group>
+ </DropdownMenu.Content>
+ </DropdownMenu.Root>
+ {/if}
+ </div>
+ {/if}
+ </div>
+
+ {#if statCards && statCards.length > 0}
+ <div class="grid gap-4 {getStatCardsGridClass(statCardsColumns)}">
+ {#each statCards as card}
+ <StatCard
+ title={card.title}
+ value={card.value}
+ subtitle={card.subtitle}
+ icon={card.icon}
+ iconColor={card.iconColor}
+ bgColor={card.bgColor}
+ class={card.class}
+ />
+ {/each}
+ </div>
+ {/if}
+
+ {@render mainContent()}
+
+ {#if additionalContent}
+ {@render additionalContent()}
+ {/if}
+</div>
diff --git a/frontend/src/lib/layouts/settings-page-layout.svelte b/frontend/src/lib/layouts/settings-page-layout.svelte
new file mode 100644
index 000000000..d93956a75
--- /dev/null
+++ b/frontend/src/lib/layouts/settings-page-layout.svelte
@@ -0,0 +1,194 @@
+<script lang="ts">
+ import type { Snippet } from 'svelte';
+ import type { Icon as IconType } from '@lucide/svelte';
+ import UiConfigDisabledTag from '$lib/components/ui-config-disabled-tag.svelte';
+ import StatCard from '$lib/components/stat-card.svelte';
+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';
+ import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
+ import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
+ import type { Action } from '$lib/components/arcane-button/index.js';
+
+ export interface SettingsActionButton {
+ id: string;
+ action: Action;
+ label: string;
+ loadingLabel?: string;
+ loading?: boolean;
+ disabled?: boolean;
+ onclick: () => void;
+ showOnMobile?: boolean;
+ }
+
+ export interface SettingsStatCard {
+ title: string;
+ value: string | number;
+ subtitle?: string;
+ icon: typeof IconType;
+ iconColor?: string;
+ bgColor?: string;
+ class?: string;
+ }
+
+ export type SettingsPageType = 'form' | 'management';
+ export type StatCardsColumns = 'auto' | 1 | 2 | 3 | 4 | 5;
+
+ interface Props {
+ title: string;
+ description?: string;
+ icon: typeof IconType;
+ pageType?: SettingsPageType;
+ showReadOnlyTag?: boolean;
+ actionButtons?: SettingsActionButton[];
+ statCards?: SettingsStatCard[];
+ statCardsColumns?: StatCardsColumns;
+ mainContent: Snippet;
+ additionalContent?: Snippet;
+ class?: string;
+ }
+
+ let {
+ title,
+ description,
+ icon: Icon,
+ pageType = 'form',
+ showReadOnlyTag = false,
+ actionButtons = [],
+ statCards = [],
+ statCardsColumns = 'auto',
+ mainContent,
+ additionalContent,
+ class: className = ''
+ }: Props = $props();
+
+ const mobileVisibleButtons = $derived(actionButtons.filter((btn) => btn.showOnMobile));
+ const mobileDropdownButtons = $derived(actionButtons.filter((btn) => !btn.showOnMobile));
+
+ const getStatCardsGridClass = (columns: typeof statCardsColumns) => {
+ switch (columns) {
+ case 1:
+ return 'grid-cols-1';
+ case 2:
+ return 'grid-cols-1 sm:grid-cols-2';
+ case 3:
+ return 'grid-cols-1 sm:grid-cols-3';
+ case 4:
+ return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4';
+ case 5:
+ return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-5';
+ case 'auto':
+ default:
+ if (statCards.length <= 2) return 'grid-cols-1 sm:grid-cols-2';
+ if (statCards.length === 3) return 'grid-cols-1 sm:grid-cols-3';
+ if (statCards.length === 4) return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4';
+ return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-5';
+ }
+ };
+</script>
+
+<div class="px-2 py-4 sm:px-6 sm:py-6 lg:px-8 {className}">
+ <div
+ class="from-background/60 via-background/40 to-background/60 relative overflow-hidden rounded-xl border bg-gradient-to-br p-4 shadow-sm sm:p-6"
+ >
+ <div class="bg-primary/10 pointer-events-none absolute -top-10 -right-10 size-40 rounded-full blur-3xl"></div>
+ <div class="bg-muted/40 pointer-events-none absolute -bottom-10 -left-10 size-40 rounded-full blur-3xl"></div>
+ <div class="relative flex items-start gap-3 sm:gap-4">
+ <div
+ class="bg-primary/10 text-primary ring-primary/20 flex size-8 shrink-0 items-center justify-center rounded-lg ring-1 sm:size-10"
+ >
+ <Icon class="size-4 sm:size-5" />
+ </div>
+
+ <div class="min-w-0 flex-1">
+ <div class="flex items-start justify-between gap-3">
+ <h1 class="settings-title min-w-0 text-xl sm:text-3xl">{title}</h1>
+ <div class="flex shrink-0 items-center gap-2">
+ {#if showReadOnlyTag}
+ <UiConfigDisabledTag />
+ {/if}
+
+ {#if pageType === 'management' && actionButtons.length > 0}
+ <div class="hidden items-center gap-2 sm:flex">
+ {#each actionButtons as button}
+ <ArcaneButton
+ action={button.action}
+ customLabel={button.label}
+ loadingLabel={button.loadingLabel}
+ loading={button.loading}
+ disabled={button.disabled}
+ onclick={button.onclick}
+ size="sm"
+ />
+ {/each}
+ </div>
+
+ <div class="flex items-center gap-2 sm:hidden">
+ {#each mobileVisibleButtons as button}
+ <ArcaneButton
+ action={button.action}
+ customLabel={button.label}
+ loadingLabel={button.loadingLabel}
+ loading={button.loading}
+ disabled={button.disabled}
+ onclick={button.onclick}
+ size="sm"
+ />
+ {/each}
+
+ {#if mobileDropdownButtons.length > 0}
+ <DropdownMenu.Root>
+ <DropdownMenu.Trigger
+ class="bg-background/70 inline-flex size-8 items-center justify-center rounded-lg border"
+ >
+ <span class="sr-only">Open menu</span>
+ <EllipsisIcon class="size-4" />
+ </DropdownMenu.Trigger>
+
+ <DropdownMenu.Content
+ align="end"
+ class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[160px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
+ >
+ <DropdownMenu.Group>
+ {#each mobileDropdownButtons as button}
+ <DropdownMenu.Item onclick={button.onclick} disabled={button.disabled || button.loading}>
+ {button.loading ? button.loadingLabel || button.label : button.label}
+ </DropdownMenu.Item>
+ {/each}
+ </DropdownMenu.Group>
+ </DropdownMenu.Content>
+ </DropdownMenu.Root>
+ {/if}
+ </div>
+ {/if}
+ </div>
+ </div>
+ {#if description}
+ <p class="text-muted-foreground mt-1 text-sm sm:text-base">{description}</p>
+ {/if}
+ </div>
+ </div>
+ </div>
+
+ {#if pageType === 'management' && statCards && statCards.length > 0}
+ <div class="mt-6 grid gap-4 sm:mt-8 {getStatCardsGridClass(statCardsColumns)}">
+ {#each statCards as card}
+ <StatCard
+ title={card.title}
+ value={card.value}
+ subtitle={card.subtitle}
+ icon={card.icon}
+ iconColor={card.iconColor}
+ bgColor={card.bgColor}
+ class={card.class}
+ />
+ {/each}
+ </div>
+ {/if}
+
+ <div class="mt-6 sm:mt-8">
+ {@render mainContent()}
+ </div>
+
+ {#if additionalContent}
+ {@render additionalContent()}
+ {/if}
+</div>
diff --git a/frontend/src/lib/layouts/tabbed-page-layout.svelte b/frontend/src/lib/layouts/tabbed-page-layout.svelte
new file mode 100644
index 000000000..480c2686f
--- /dev/null
+++ b/frontend/src/lib/layouts/tabbed-page-layout.svelte
@@ -0,0 +1,103 @@
+<script lang="ts">
+ import { Button } from '$lib/components/ui/button/index.js';
+ import * as Tabs from '$lib/components/ui/tabs/index.js';
+ import { TabBar, type TabItem } from '$lib/components/tab-bar/index.js';
+ import ArrowLeftIcon from '@lucide/svelte/icons/arrow-left';
+ import type { Snippet } from 'svelte';
+ import { browser } from '$app/environment';
+ import { cn } from '$lib/utils';
+
+ interface Props {
+ backUrl: string;
+ backLabel: string;
+ tabItems: TabItem[];
+ selectedTab: string;
+ onTabChange: (value: string) => void;
+ headerInfo: Snippet;
+ headerActions?: Snippet;
+ subHeader?: Snippet;
+ tabContent: Snippet<[string]>;
+ class?: string;
+ showFloatingHeader?: boolean;
+ }
+
+ let {
+ backUrl,
+ backLabel,
+ tabItems,
+ selectedTab,
+ onTabChange,
+ headerInfo,
+ headerActions,
+ subHeader,
+ tabContent,
+ class: className = '',
+ showFloatingHeader = false
+ }: Props = $props();
+
+ $effect(() => {
+ if (browser) {
+ const onScroll = () => {
+ showFloatingHeader = window.scrollY > 100;
+ };
+ window.addEventListener('scroll', onScroll);
+ return () => window.removeEventListener('scroll', onScroll);
+ }
+ });
+</script>
+
+<div class={cn('bg-background min-h-screen', className)}>
+ <Tabs.Root value={selectedTab} class="flex min-h-0 w-full flex-1 flex-col">
+ <div
+ class="bg-background/95 sticky top-0 z-20 border-b backdrop-blur transition-all duration-300"
+ style="opacity: {showFloatingHeader ? 0 : 1}; pointer-events: {showFloatingHeader ? 'none' : 'auto'};"
+ >
+ <div class="max-w-full px-4 py-3">
+ <div class="flex items-start justify-between gap-3">
+ <div class="flex min-w-0 items-start gap-3">
+ <Button variant="ghost" size="sm" href={backUrl}>
+ <ArrowLeftIcon class="mr-2 size-4" />
+ {backLabel}
+ </Button>
+ <div class="min-w-0">
+ {@render headerInfo()}
+ </div>
+ </div>
+ {#if headerActions}
+ {@render headerActions()}
+ {/if}
+ </div>
+
+ {#if subHeader}
+ {@render subHeader()}
+ {/if}
+
+ <div class="mt-4">
+ <TabBar items={tabItems} value={selectedTab} onValueChange={onTabChange} />
+ </div>
+ </div>
+ </div>
+
+ {#if showFloatingHeader}
+ <div class="fixed top-4 left-1/2 z-30 -translate-x-1/2 transition-all duration-300 ease-in-out">
+ <div class="bg-background/90 border-border/50 rounded-lg border px-4 py-3 shadow-xl backdrop-blur-xl">
+ <div class="flex items-center gap-4">
+ <div class="min-w-0">
+ {@render headerInfo()}
+ </div>
+ {#if headerActions}
+ <div class="bg-border h-4 w-px"></div>
+ {@render headerActions()}
+ {/if}
+ </div>
+ </div>
+ </div>
+ {/if}
+
+ <div class="min-h-0 flex-1 overflow-hidden">
+ <div class="h-full px-1 py-4 sm:px-4">
+ {@render tabContent(selectedTab)}
+ </div>
+ </div>
+ </Tabs.Root>
+</div>
diff --git a/frontend/src/routes/containers/+page.svelte b/frontend/src/routes/containers/+page.svelte
index 6e8f3fd7d..cb2130762 100644
--- a/frontend/src/routes/containers/+page.svelte
+++ b/frontend/src/routes/containers/+page.svelte
@@ -4,16 +4,13 @@
import { toast } from 'svelte-sonner';
import { tryCatch } from '$lib/utils/try-catch';
import { handleApiResultWithCallbacks } from '$lib/utils/api.util';
- import StatCard from '$lib/components/stat-card.svelte';
import { containerService } from '$lib/services/container-service';
import ContainerTable from './container-table.svelte';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
import { m } from '$lib/paraglide/messages';
- import { environmentStore } from '$lib/stores/environment.store';
- import type { Environment } from '$lib/types/environment.type';
+ import { environmentStore } from '$lib/stores/environment.store';
+ import type { Environment } from '$lib/types/environment.type';
import { imageService } from '$lib/services/image-service';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data } = $props();
@@ -74,13 +71,11 @@
});
}
- // React to environment changes
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
const env = $selectedEnvStore as Environment | null;
if (!env) return;
- // Skip initial page load
if (lastEnvId === null) {
lastEnvId = env.id;
return;
@@ -90,111 +85,90 @@
refreshContainers();
}
});
-</script>
-<div class="space-y-6">
- <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div>
- <h1 class="text-3xl font-bold tracking-tight">{m.containers_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">{m.containers_subtitle()}</p>
- </div>
- <!-- Desktop buttons -->
- <div class="hidden items-center gap-2 sm:flex">
- <ArcaneButton
- action="create"
- customLabel={m.containers_create_button()}
- onclick={() => (isCreateDialogOpen = true)}
- loading={isLoading.create}
- disabled={isLoading.create}
- />
- <ArcaneButton
- action="inspect"
- customLabel={m.containers_check_updates()}
- onclick={handleCheckForUpdates}
- loading={isLoading.checking}
- disabled={isLoading.checking}
- />
- <ArcaneButton
- action="restart"
- onclick={refreshContainers}
- customLabel={m.common_refresh()}
- loading={isLoading.refreshing}
- disabled={isLoading.refreshing}
- />
- </div>
+ const actionButtons: ActionButton[] = $derived.by(() => [
+ {
+ id: 'create',
+ action: 'create',
+ label: m.containers_create_button(),
+ onclick: () => (isCreateDialogOpen = true),
+ loading: isLoading.create,
+ disabled: isLoading.create
+ },
+ {
+ id: 'check-updates',
+ action: 'inspect',
+ label: m.containers_check_updates(),
+ onclick: handleCheckForUpdates,
+ loading: isLoading.checking,
+ disabled: isLoading.checking
+ },
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.common_refresh(),
+ onclick: refreshContainers,
+ loading: isLoading.refreshing,
+ disabled: isLoading.refreshing
+ }
+ ]);
- <!-- Mobile / tablet: dropdown menu (positioned top-right on small screens) -->
- <div class="absolute right-4 top-4 flex items-center sm:static sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
+ const statCards: StatCardConfig[] = $derived([
+ {
+ title: m.containers_total(),
+ value: containerStatusCounts.totalContainers,
+ icon: BoxIcon,
+ class: 'border-l-primary border-l-4 transition-shadow hover:shadow-lg'
+ },
+ {
+ title: m.containers_running(),
+ value: containerStatusCounts.runningContainers,
+ icon: BoxIcon,
+ iconColor: 'text-green-500',
+ bgColor: 'bg-green-500/10',
+ class: 'border-l-4 border-l-green-500'
+ },
+ {
+ title: m.containers_stopped(),
+ value: containerStatusCounts.stoppedContainers,
+ icon: BoxIcon,
+ iconColor: 'text-amber-500',
+ class: 'border-l-4 border-l-amber-500'
+ }
+ ]);
+</script>
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[160px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- <DropdownMenu.Item onclick={() => (isCreateDialogOpen = true)} disabled={isLoading.create}>
- {m.containers_create_button()}
- </DropdownMenu.Item>
- <DropdownMenu.Item onclick={handleCheckForUpdates} disabled={isLoading.checking}>
- {m.containers_check_updates()}
- </DropdownMenu.Item>
- <DropdownMenu.Item onclick={refreshContainers} disabled={isLoading.refreshing}>
- {m.common_refresh()}
- </DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- </div>
- </div>
+<ResourcePageLayout
+ title={m.containers_title()}
+ subtitle={m.containers_subtitle()}
+ {actionButtons}
+ {statCards}
+ statCardsColumns={3}
+>
+ {#snippet mainContent()}
+ <ContainerTable bind:containers bind:selectedIds bind:requestOptions {baseServerUrl} />
+ {/snippet}
- <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
- <StatCard
- title={m.containers_total()}
- value={containerStatusCounts.totalContainers}
- icon={BoxIcon}
- class="border-l-primary border-l-4 transition-shadow hover:shadow-lg"
+ {#snippet additionalContent()}
+ <CreateContainerSheet
+ bind:open={isCreateDialogOpen}
+ availableVolumes={[]}
+ availableNetworks={[]}
+ availableImages={[]}
+ isLoading={isLoading.create}
+ onSubmit={async (options) => {
+ isLoading.create = true;
+ handleApiResultWithCallbacks({
+ result: await tryCatch(containerService.createContainer(options)),
+ message: m.containers_create_failed(),
+ setLoadingState: (value) => (isLoading.create = value),
+ onSuccess: async () => {
+ toast.success(m.containers_create_success());
+ containers = await containerService.getContainers(requestOptions);
+ isCreateDialogOpen = false;
+ }
+ });
+ }}
/>
- <StatCard
- title={m.containers_running()}
- value={containerStatusCounts.runningContainers}
- icon={BoxIcon}
- iconColor="text-green-500"
- bgColor="bg-green-500/10"
- class="border-l-4 border-l-green-500"
- />
- <StatCard
- title={m.containers_stopped()}
- value={containerStatusCounts.stoppedContainers}
- icon={BoxIcon}
- iconColor="text-amber-500"
- class="border-l-4 border-l-amber-500"
- />
- </div>
-
- <ContainerTable bind:containers bind:selectedIds bind:requestOptions {baseServerUrl} />
-
- <CreateContainerSheet
- bind:open={isCreateDialogOpen}
- availableVolumes={[]}
- availableNetworks={[]}
- availableImages={[]}
- isLoading={isLoading.create}
- onSubmit={async (options) => {
- isLoading.create = true;
- handleApiResultWithCallbacks({
- result: await tryCatch(containerService.createContainer(options)),
- message: m.containers_create_failed(),
- setLoadingState: (value) => (isLoading.create = value),
- onSuccess: async () => {
- toast.success(m.containers_create_success());
- containers = await containerService.getContainers(requestOptions);
- isCreateDialogOpen = false;
- }
- });
- }}
- />
-</div>
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/containers/[containerId]/+page.svelte b/frontend/src/routes/containers/[containerId]/+page.svelte
index c8b82adf4..8c53fd73b 100644
--- a/frontend/src/routes/containers/[containerId]/+page.svelte
+++ b/frontend/src/routes/containers/[containerId]/+page.svelte
@@ -1,32 +1,32 @@
<script lang="ts">
- import * as Card from '$lib/components/ui/card/index.js';
import { Button } from '$lib/components/ui/button/index.js';
import ArrowLeftIcon from '@lucide/svelte/icons/arrow-left';
import CircleAlertIcon from '@lucide/svelte/icons/alert-circle';
import RefreshCwIcon from '@lucide/svelte/icons/refresh-cw';
import HardDriveIcon from '@lucide/svelte/icons/hard-drive';
- import ClockIcon from '@lucide/svelte/icons/clock';
- import NetworkIcon from '@lucide/svelte/icons/network';
- import TerminalIcon from '@lucide/svelte/icons/terminal';
- import SettingsIcon from '@lucide/svelte/icons/settings';
import ActivityIcon from '@lucide/svelte/icons/activity';
import FileTextIcon from '@lucide/svelte/icons/file-text';
+ import SettingsIcon from '@lucide/svelte/icons/settings';
+ import NetworkIcon from '@lucide/svelte/icons/network';
import DatabaseIcon from '@lucide/svelte/icons/database';
import { invalidateAll } from '$app/navigation';
- import { Badge } from '$lib/components/ui/badge/index.js';
import ActionButtons from '$lib/components/action-buttons.svelte';
+ import StatusBadge from '$lib/components/badges/status-badge.svelte';
import { format } from 'date-fns';
import bytes from 'bytes';
import type Docker from 'dockerode';
- import StatusBadge from '$lib/components/badges/status-badge.svelte';
import { onDestroy } from 'svelte';
- import LogViewer from '$lib/components/log-viewer.svelte';
- import { Progress } from '$lib/components/ui/progress/index.js';
- import { browser } from '$app/environment';
- import Separator from '$lib/components/ui/separator/separator.svelte';
import type { ContainerDetailsDto, ContainerNetworkSettings } from '$lib/types/container.type';
import { m } from '$lib/paraglide/messages';
- import PortBadges from '$lib/components/port-badges.svelte';
+ import TabbedPageLayout from '$lib/layouts/tabbed-page-layout.svelte';
+ import { type TabItem } from '$lib/components/tab-bar/index.js';
+ import * as Tabs from '$lib/components/ui/tabs/index.js';
+ import ContainerOverview from '../components/ContainerOverview.svelte';
+ import ContainerStats from '../components/ContainerStats.svelte';
+ import ContainerConfiguration from '../components/ContainerConfiguration.svelte';
+ import ContainerNetwork from '../components/ContainerNetwork.svelte';
+ import ContainerStorage from '../components/ContainerStorage.svelte';
+ import ContainerLogsPanel from '../components/ContainerLogsPanel.svelte';
interface NetworkConfig {
IPAddress?: string;
@@ -38,10 +38,6 @@
[key: string]: any;
}
- function ensureNetworkConfig(config: any): NetworkConfig {
- return config as NetworkConfig;
- }
-
let { data } = $props();
let container = $derived(data?.container as ContainerDetailsDto);
let stats = $derived((data?.stats ?? null) as Docker.ContainerStats | null);
@@ -52,13 +48,11 @@
let removing = $state(false);
let isRefreshing = $state(false);
- let activeSection = $state<string>('overview');
+ let selectedTab = $state<string>('overview');
let autoScrollLogs = $state(true);
let isStreaming = $state(false);
- let logViewer = $state<LogViewer>();
let statsEventSource: EventSource | null = $state(null);
- let showFloatingHeader = $state(false);
const cleanContainerName = (name: string | undefined): string => {
if (!name) return m.containers_not_found_title();
@@ -110,7 +104,7 @@
}
$effect(() => {
- if (activeSection === 'stats' && container?.state?.running) {
+ if (selectedTab === 'stats' && container?.state?.running) {
startStatsStream();
} else if (statsEventSource) {
closeStatsStream();
@@ -140,8 +134,8 @@
const cpuUsagePercent = $derived(calculateCPUPercent(stats));
const memoryUsageBytes = $derived(stats?.memory_stats?.usage || 0);
const memoryLimitBytes = $derived(stats?.memory_stats?.limit || 0);
- const memoryUsageFormatted = $derived(bytes.format(memoryUsageBytes));
- const memoryLimitFormatted = $derived(bytes.format(memoryLimitBytes));
+ const memoryUsageFormatted = $derived(bytes.format(memoryUsageBytes || 0) || '0 B');
+ const memoryLimitFormatted = $derived(bytes.format(memoryLimitBytes || 0) || '0 B');
const memoryUsagePercent = $derived(memoryLimitBytes > 0 ? (memoryUsageBytes / memoryLimitBytes) * 100 : 0);
const getPrimaryIpAddress = (networkSettings: ContainerNetworkSettings | undefined | null): string => {
@@ -196,51 +190,25 @@
const hasMounts = $derived(!!(container?.mounts && container.mounts.length > 0));
const showStats = $derived(!!(container?.state?.running && stats));
- const navigationSections = [
- { id: 'overview', label: m.containers_nav_overview(), icon: HardDriveIcon },
- { id: 'stats', label: m.containers_nav_metrics(), icon: ActivityIcon },
- { id: 'logs', label: m.containers_nav_logs(), icon: FileTextIcon },
- { id: 'config', label: m.containers_nav_config(), icon: SettingsIcon },
- { id: 'network', label: m.containers_nav_networks(), icon: NetworkIcon },
- { id: 'storage', label: m.containers_nav_storage(), icon: DatabaseIcon }
- ] as const;
-
- const visibleNavigationSections = $derived(
- navigationSections.filter((s) => {
- if (s.id === 'stats') return showStats;
- if (s.id === 'config') return showConfiguration;
- if (s.id === 'network') return hasNetworks;
- if (s.id === 'storage') return hasMounts;
- return true;
- })
- );
+ const tabItems = $derived<TabItem[]>([
+ { value: 'overview', label: m.containers_nav_overview(), icon: HardDriveIcon },
+ ...(showStats ? [{ value: 'stats', label: m.containers_nav_metrics(), icon: ActivityIcon }] : []),
+ { value: 'logs', label: m.containers_nav_logs(), icon: FileTextIcon },
+ ...(showConfiguration ? [{ value: 'config', label: m.containers_nav_config(), icon: SettingsIcon }] : []),
+ ...(hasNetworks ? [{ value: 'network', label: m.containers_nav_networks(), icon: NetworkIcon }] : []),
+ ...(hasMounts ? [{ value: 'storage', label: m.containers_nav_storage(), icon: DatabaseIcon }] : [])
+ ]);
$effect(() => {
- if (!visibleNavigationSections.some((s) => s.id === activeSection)) {
- activeSection = visibleNavigationSections[0]?.id ?? 'overview';
+ if (!tabItems.some((t) => t.value === selectedTab)) {
+ selectedTab = tabItems[0]?.value ?? 'overview';
}
});
- type SectionId = (typeof navigationSections)[number]['id'];
-
- function scrollToSection(sectionId: SectionId) {
- activeSection = sectionId;
- const element = document.getElementById(sectionId);
- if (element) {
- element.scrollIntoView({ behavior: 'smooth', block: 'start' });
- }
+ function onTabChange(value: string) {
+ selectedTab = value;
}
- $effect(() => {
- if (browser) {
- const onScroll = () => {
- showFloatingHeader = window.scrollY > 100;
- };
- window.addEventListener('scroll', onScroll);
- return () => window.removeEventListener('scroll', onScroll);
- }
- });
-
function parseDockerDate(input: string | Date | undefined | null): Date | null {
if (!input) return null;
if (input instanceof Date) return isNaN(input.getTime()) ? null : input;
@@ -271,645 +239,113 @@
);
</script>
-<div class="bg-background min-h-screen">
- {#if container}
- <div
- class="bg-background/95 sticky top-0 z-20 border-b backdrop-blur transition-all duration-300"
- style="opacity: {showFloatingHeader ? 0 : 1}; pointer-events: {showFloatingHeader ? 'none' : 'auto'};"
- >
- <div class="max-w-full px-4 py-3">
- <div class="flex items-center justify-between">
- <div class="flex items-center gap-3">
- <Button variant="ghost" size="sm" href="/containers">
- <ArrowLeftIcon class="mr-2 size-4" />
- {m.common_back()}
- </Button>
- <div class="bg-border h-4 w-px"></div>
- <div class="flex items-center gap-2">
- <h1 class="max-w-[300px] truncate text-lg font-semibold" title={containerDisplayName}>
- {containerDisplayName}
- </h1>
- {#if container?.state}
- <StatusBadge
- variant={container.state.status === 'running' ? 'green' : container.state.status === 'exited' ? 'red' : 'amber'}
- text={container.state.status}
- />
- {/if}
- </div>
- </div>
-
- <div class="flex items-center gap-2">
- {#if container}
- <ActionButtons
- id={container.id}
- type="container"
- itemState={container.state?.running ? 'running' : 'stopped'}
- loading={{ start: starting, stop: stopping, restart: restarting, remove: removing }}
- />
- {/if}
- </div>
- </div>
+{#if container}
+ <TabbedPageLayout backUrl="/containers" backLabel={m.common_back()} {tabItems} {selectedTab} {onTabChange}>
+ {#snippet headerInfo()}
+ <div class="flex items-center gap-2">
+ <h1 class="max-w-[300px] truncate text-lg font-semibold" title={containerDisplayName}>
+ {containerDisplayName}
+ </h1>
+ {#if container?.state}
+ <StatusBadge
+ variant={container.state.status === 'running' ? 'green' : container.state.status === 'exited' ? 'red' : 'amber'}
+ text={container.state.status}
+ />
+ {/if}
</div>
- </div>
+ {/snippet}
+
+ {#snippet headerActions()}
+ <ActionButtons
+ id={container.id}
+ type="container"
+ itemState={container.state?.running ? 'running' : 'stopped'}
+ loading={{ start: starting, stop: stopping, restart: restarting, remove: removing }}
+ />
+ {/snippet}
+
+ {#snippet tabContent(activeTab)}
+ <Tabs.Content value="overview" class="h-full">
+ <div class="space-y-8">
+ <ContainerOverview {container} {primaryIpAddress} />
+ </div>
+ </Tabs.Content>
- {#if showFloatingHeader}
- <div class="fixed left-1/2 top-4 z-30 -translate-x-1/2 transition-all duration-300 ease-in-out">
- <div class="bg-background/90 border-border/50 rounded-lg border px-4 py-3 shadow-xl backdrop-blur-xl">
- <div class="flex items-center gap-4">
- <div class="flex items-center gap-2">
- <h2 class="max-w-[150px] truncate text-sm font-medium" title={containerDisplayName}>
- {containerDisplayName}
- </h2>
- {#if container?.state}
- <StatusBadge
- variant={container.state.status === 'running' ? 'green' : container.state.status === 'exited' ? 'red' : 'amber'}
- text={container.state.status}
- class="text-xs"
- />
- {/if}
- </div>
- <div class="bg-border h-4 w-px"></div>
- <ActionButtons
- id={container.id}
- type="container"
- itemState={container.state?.running ? 'running' : 'stopped'}
- loading={{ start: starting, stop: stopping, restart: restarting, remove: removing }}
+ {#if showStats}
+ <Tabs.Content value="stats" class="h-full">
+ <div class="space-y-8">
+ <ContainerStats
+ {container}
+ {stats}
+ {cpuUsagePercent}
+ {memoryUsageBytes}
+ {memoryLimitBytes}
+ {memoryUsageFormatted}
+ {memoryLimitFormatted}
+ {memoryUsagePercent}
/>
</div>
+ </Tabs.Content>
+ {/if}
+
+ <Tabs.Content value="logs" class="h-full">
+ <div class="h-full">
+ <ContainerLogsPanel
+ containerId={container?.id}
+ bind:autoScroll={autoScrollLogs}
+ onStart={handleLogStart}
+ onStop={handleLogStop}
+ onClear={handleLogClear}
+ onToggleAutoScroll={handleToggleAutoScroll}
+ />
</div>
- </div>
- {/if}
-
- <div class="flex min-h-0 overflow-hidden">
- <div class="bg-background/50 w-16 shrink-0 border-r">
- <div class="sticky top-16 p-2">
- <nav class="space-y-1">
- {#each visibleNavigationSections as section}
- {@const IconComponent = section.icon}
- <button
- onclick={() => scrollToSection(section.id)}
- class="relative flex w-full items-center justify-center rounded-md p-3 text-sm font-medium transition-colors
- {activeSection === section.id
- ? 'bg-primary/10 text-primary border-primary/20 border'
- : 'text-muted-foreground hover:text-foreground hover:bg-muted/50'}"
- title={section.label}
- >
- <IconComponent class="size-4" />
- </button>
- {/each}
- </nav>
- </div>
- </div>
+ </Tabs.Content>
- <div class="min-w-0 flex-1 overflow-hidden">
- <div class="max-w-none p-6">
+ {#if showConfiguration}
+ <Tabs.Content value="config" class="h-full">
<div class="space-y-8">
- <section id="overview" class="scroll-mt-20">
- <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
- <HardDriveIcon class="size-5" />
- {m.containers_details_title()}
- </h2>
-
- <div class="mb-6">
- <Card.Root class="rounded-lg border shadow-sm">
- <Card.Header class="pb-4">
- <Card.Title>{m.containers_details_title()}</Card.Title>
- <Card.Description class="text-muted-foreground text-sm">
- {m.containers_details_description()}
- </Card.Description>
- </Card.Header>
-
- <Card.Content class="space-y-6">
- <div class="space-y-4">
- <div class="flex items-center gap-3">
- <div class="rounded bg-blue-50 p-2 dark:bg-blue-950/20">
- <HardDriveIcon class="size-4 text-blue-600" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="text-muted-foreground text-sm">{m.common_image()}</div>
- <div class="truncate font-medium" title={container.image}>
- {container.image || m.common_na()}
- </div>
- </div>
- </div>
-
- <div class="flex items-center gap-3">
- <div class="rounded bg-green-50 p-2 dark:bg-green-950/20">
- <ClockIcon class="size-4 text-green-600" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="text-muted-foreground text-sm">{m.common_created()}</div>
- <div class="font-medium" title={formatDockerDate(container?.created)}>
- {formatDockerDate(container?.created)}
- </div>
- </div>
- </div>
-
- <div class="flex items-center gap-3">
- <div class="rounded bg-purple-50 p-2 dark:bg-purple-950/20">
- <NetworkIcon class="size-4 text-purple-600" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="text-muted-foreground text-sm">{m.containers_ip_address()}</div>
- <div class="font-medium">{primaryIpAddress}</div>
- </div>
- </div>
-
- <div class="flex items-center gap-3">
- <div class="rounded bg-amber-50 p-2 dark:bg-amber-950/20">
- <TerminalIcon class="size-4 text-amber-600" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="text-muted-foreground text-sm">{m.containers_command()}</div>
- <div class="truncate font-medium" title={container.config?.cmd?.join(' ')}>
- {container.config?.cmd?.join(' ') || m.common_na()}
- </div>
- </div>
- </div>
- </div>
-
- <Separator />
-
- <div class="space-y-3">
- <h4 class="text-sm font-semibold tracking-tight">{m.containers_system()}</h4>
-
- <div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
- <div class="space-y-1">
- <div class="text-muted-foreground text-xs">{m.common_id()}</div>
- <div class="bg-muted/50 max-w-full truncate rounded px-2 py-1.5 font-mono text-xs">
- {container.id}
- </div>
- </div>
-
- {#if container.config?.workingDir}
- <div class="space-y-1">
- <div class="text-muted-foreground text-xs">{m.containers_working_directory()}</div>
- <div class="bg-muted/50 max-w-full truncate rounded px-2 py-1.5 font-mono text-xs">
- {container.config.workingDir}
- </div>
- </div>
- {/if}
-
- {#if container.config?.user}
- <div class="space-y-1">
- <div class="text-muted-foreground text-xs">{m.common_user()}</div>
- <div class="bg-muted/50 inline-flex rounded px-2 py-1.5 font-mono text-xs">
- {container.config.user}
- </div>
- </div>
- {/if}
-
- {#if container.state?.health}
- <div class="space-y-1 sm:col-span-2">
- <div class="text-muted-foreground text-xs">{m.containers_health_label()}</div>
- <div class="flex flex-wrap items-center gap-3">
- <StatusBadge
- variant={container.state.health.status === 'healthy'
- ? 'green'
- : container.state.health.status === 'unhealthy'
- ? 'red'
- : 'amber'}
- text={container.state.health.status}
- />
- {#if container.state.health.log && container.state.health.log.length > 0}
- {@const first = container.state.health.log[0]}
- {@const lastCheck = (first?.Start ?? first?.start) as string | undefined}
- {#if lastCheck}
- <span class="text-muted-foreground text-xs">
- {m.containers_health_last_check({ time: formatDockerDate(lastCheck) })}
- </span>
- {/if}
- {/if}
- </div>
- </div>
- {/if}
- </div>
- </div>
- </Card.Content>
- </Card.Root>
- </div>
- </section>
-
- {#if showStats}
- <section id="stats" class="scroll-mt-20">
- <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
- <ActivityIcon class="size-5" />
- {m.containers_resource_metrics()}
- </h2>
-
- <Card.Root class="rounded-lg border shadow-sm">
- <Card.Content class="p-6">
- {#if stats && container.state?.running}
- <div class="grid grid-cols-1 gap-8 lg:grid-cols-2">
- <div class="space-y-6">
- <div class="space-y-2">
- <div class="flex justify-between">
- <span class="text-sm font-medium">{m.dashboard_meter_cpu()}</span>
- <span class="text-muted-foreground text-sm">{cpuUsagePercent.toFixed(2)}%</span>
- </div>
- <Progress
- value={cpuUsagePercent}
- max={100}
- class="h-2 {cpuUsagePercent > 80
- ? '[&>div]:bg-destructive'
- : cpuUsagePercent > 60
- ? '[&>div]:bg-warning'
- : ''}"
- />
- </div>
-
- <div class="space-y-2">
- <div class="flex justify-between">
- <span class="text-sm font-medium">{m.dashboard_meter_memory()}</span>
- <span class="text-muted-foreground text-sm"
- >{memoryUsageFormatted} / {memoryLimitFormatted} ({memoryUsagePercent.toFixed(1)}%)</span
- >
- </div>
- <Progress
- value={memoryUsagePercent}
- max={100}
- class="h-2 {memoryUsagePercent > 80
- ? '[&>div]:bg-destructive'
- : memoryUsagePercent > 60
- ? '[&>div]:bg-warning'
- : ''}"
- />
- </div>
- </div>
-
- <div class="space-y-6">
- <div>
- <h4 class="mb-4 flex items-center gap-2 font-medium">
- <NetworkIcon class="size-4" />
- {m.containers_network_io()}
- </h4>
- <div class="grid grid-cols-2 gap-4">
- <div class="bg-muted/30 rounded p-4">
- <div class="text-muted-foreground text-sm">{m.containers_network_received()}</div>
- <div class="mt-1 font-medium">
- {bytes.format(stats.networks?.eth0?.rx_bytes || 0)}
- </div>
- </div>
- <div class="bg-muted/30 rounded p-4">
- <div class="text-muted-foreground text-sm">{m.containers_network_transmitted()}</div>
- <div class="mt-1 font-medium">
- {bytes.format(stats.networks?.eth0?.tx_bytes || 0)}
- </div>
- </div>
- </div>
- </div>
-
- {#if stats.blkio_stats && stats.blkio_stats.io_service_bytes_recursive && stats.blkio_stats.io_service_bytes_recursive.length > 0}
- <div>
- <h4 class="mb-4 font-medium">{m.containers_block_io()}</h4>
- <div class="grid grid-cols-2 gap-4">
- <div class="bg-muted/30 rounded p-4">
- <div class="text-muted-foreground text-sm">{m.containers_block_io_read()}</div>
- <div class="mt-1 font-medium">
- {bytes.format(
- stats.blkio_stats.io_service_bytes_recursive
- .filter((item) => item.op === 'Read')
- .reduce((acc, item) => acc + item.value, 0)
- )}
- </div>
- </div>
- <div class="bg-muted/30 rounded p-4">
- <div class="text-muted-foreground text-sm">{m.containers_block_io_write()}</div>
- <div class="mt-1 font-medium">
- {bytes.format(
- stats.blkio_stats.io_service_bytes_recursive
- .filter((item) => item.op === 'Write')
- .reduce((acc, item) => acc + item.value, 0)
- )}
- </div>
- </div>
- </div>
- </div>
- {/if}
- </div>
- </div>
-
- {#if stats.pids_stats && stats.pids_stats.current !== undefined}
- <div class="mt-6 border-t pt-6">
- <div class="text-sm">
- <span class="text-muted-foreground">{m.containers_process_count()}</span>
- <span class="ml-2 font-medium">{stats.pids_stats.current}</span>
- </div>
- </div>
- {/if}
- {:else if !container.state?.running}
- <div class="text-muted-foreground py-12 text-center">{m.containers_stats_unavailable()}</div>
- {:else}
- <div class="text-muted-foreground py-12 text-center">{m.containers_stats_loading()}</div>
- {/if}
- </Card.Content>
- </Card.Root>
- </section>
- {/if}
-
- <section id="logs" class="scroll-mt-20">
- <div class="mb-6 flex items-center justify-between">
- <h2 class="flex items-center gap-2 text-xl font-semibold">
- <FileTextIcon class="size-5" />
- {m.containers_logs_title()}
- </h2>
-
- <div class="flex items-center gap-3">
- <label class="flex items-center gap-2">
- <input type="checkbox" bind:checked={autoScrollLogs} class="size-4" />
- {m.common_autoscroll()}
- </label>
- <Button variant="outline" size="sm" onclick={() => logViewer?.clearLogs()}>{m.common_clear()}</Button>
- {#if isStreaming}
- <div class="flex items-center gap-2">
- <div class="size-2 animate-pulse rounded-full bg-green-500"></div>
- <span class="text-sm font-medium text-green-600">{m.common_live()}</span>
- </div>
- <Button variant="outline" size="sm" onclick={() => logViewer?.stopLogStream()}>{m.common_stop()}</Button>
- {:else}
- <Button variant="outline" size="sm" onclick={() => logViewer?.startLogStream()} disabled={!container?.id}>
- {m.common_start()}
- </Button>
- {/if}
- </div>
- </div>
-
- <Card.Root class="rounded-lg border shadow-sm">
- <Card.Content class="p-0">
- <LogViewer
- bind:this={logViewer}
- bind:autoScroll={autoScrollLogs}
- type="container"
- containerId={container?.id}
- maxLines={500}
- showTimestamps={true}
- height="400px"
- onStart={handleLogStart}
- onStop={handleLogStop}
- onClear={handleLogClear}
- onToggleAutoScroll={handleToggleAutoScroll}
- />
- </Card.Content>
- </Card.Root>
- </section>
-
- {#if showConfiguration}
- <section id="config" class="scroll-mt-20">
- <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
- <SettingsIcon class="size-5" />
- {m.containers_configuration_title()}
- </h2>
-
- <Card.Root class="rounded-lg border shadow-sm">
- <Card.Header class="pb-4">
- <Card.Title>{m.containers_env_ports_labels_title()}</Card.Title>
- <Card.Description class="text-muted-foreground text-sm">
- {m.containers_env_ports_labels_description()}
- </Card.Description>
- </Card.Header>
-
- <Card.Content class="space-y-8">
- {#if hasEnvVars}
- <div>
- <h3 class="mb-3 text-sm font-semibold tracking-tight">{m.containers_env_vars_title()}</h3>
-
- {#if container.config?.env && container.config.env.length > 0}
- <ul class="divide-border/60 divide-y">
- {#each container.config.env as env, index (index)}
- {#if env.includes('=')}
- {@const [key, ...valueParts] = env.split('=')}
- {@const value = valueParts.join('=')}
- <li class="px-4 py-2.5">
- <div class="flex min-w-0 items-center gap-3">
- <Badge variant="secondary">
- {key}:
- </Badge>
- <span class="truncate font-semibold" title={value}>{value}</span>
- </div>
- </li>
- {:else}
- <li class="px-4 py-2.5">
- <div class="flex min-w-0 items-center gap-3">
- <Badge variant="secondary">ENV:</Badge>
- <span class="truncate font-semibold" title={env}>{env}</span>
- </div>
- </li>
- {/if}
- {/each}
- </ul>
- {:else}
- <div class="text-muted-foreground py-8 text-center">{m.containers_no_env_vars()}</div>
- {/if}
- </div>
- {/if}
-
- {#if hasEnvVars && (hasPorts || hasLabels)}
- <Separator />
- {/if}
-
- {#if hasPorts}
- <div>
- <h3 class="mb-3 text-sm font-semibold tracking-tight">{m.containers_port_mappings()}</h3>
- <PortBadges ports={container.ports ?? []} {baseServerUrl} />
- </div>
- {/if}
-
- {#if hasPorts && hasLabels}
- <Separator />
- {/if}
-
- {#if hasLabels}
- <div>
- <h3 class="mb-3 text-sm font-semibold tracking-tight">{m.common_labels()}</h3>
-
- {#if container.labels && Object.keys(container.labels).length > 0}
- <ul class="divide-border/60 divide-y">
- {#each Object.entries(container.labels) as [key, value] (key)}
- <li class="px-4 py-2.5">
- <div class="flex min-w-0 items-center gap-3">
- <Badge variant="secondary">
- {key}:
- </Badge>
- <span class="truncate font-semibold" title={value?.toString()}>
- {value?.toString() || ''}
- </span>
- </div>
- </li>
- {/each}
- </ul>
- {:else}
- <div class="text-muted-foreground py-8 text-center">{m.containers_no_labels_defined()}</div>
- {/if}
- </div>
- {/if}
- </Card.Content>
- </Card.Root>
- </section>
- {/if}
-
- {#if hasNetworks}
- <section id="network" class="scroll-mt-20">
- <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
- <NetworkIcon class="size-5" />
- {m.containers_networks_title()}
- </h2>
-
- <Card.Root class="rounded-lg border shadow-sm">
- <Card.Content class="p-6">
- {#if container.networkSettings?.networks && Object.keys(container.networkSettings.networks).length > 0}
- <div class="space-y-6">
- {#each Object.entries(container.networkSettings.networks) as [networkName, rawNetworkConfig] (networkName)}
- {@const networkConfig = ensureNetworkConfig({
- IPAddress: rawNetworkConfig.ipAddress,
- IPPrefixLen: rawNetworkConfig.ipPrefixLen,
- Gateway: rawNetworkConfig.gateway,
- MacAddress: rawNetworkConfig.macAddress,
- Aliases: rawNetworkConfig.aliases
- })}
- <div class="rounded border p-4">
- <div class="mb-4 font-medium">{networkName}</div>
- <div class="grid grid-cols-2 gap-4 lg:grid-cols-4">
- <div>
- <div class="text-muted-foreground text-sm">{m.containers_ip_address()}</div>
- <div class="font-mono">{rawNetworkConfig.ipAddress || m.common_na()}</div>
- </div>
- <div>
- <div class="text-muted-foreground text-sm">{m.containers_gateway()}</div>
- <div class="font-mono">{rawNetworkConfig.gateway || m.common_na()}</div>
- </div>
- <div>
- <div class="text-muted-foreground text-sm">{m.containers_mac_address()}</div>
- <div class="font-mono">{rawNetworkConfig.macAddress || m.common_na()}</div>
- </div>
- <div>
- <div class="text-muted-foreground text-sm">{m.containers_subnet()}</div>
- <div class="font-mono">
- {rawNetworkConfig.ipPrefixLen
- ? `${rawNetworkConfig.ipAddress}/${rawNetworkConfig.ipPrefixLen}`
- : m.common_na()}
- </div>
- </div>
- {#if rawNetworkConfig.aliases && rawNetworkConfig.aliases.length > 0}
- <div class="col-span-2">
- <div class="text-muted-foreground text-sm">{m.containers_aliases()}</div>
- <div class="font-mono">{rawNetworkConfig.aliases.join(', ')}</div>
- </div>
- {/if}
- </div>
- </div>
- {/each}
- </div>
- {:else}
- <div class="text-muted-foreground py-12 text-center">{m.containers_no_networks_connected()}</div>
- {/if}
- </Card.Content>
- </Card.Root>
- </section>
- {/if}
-
- {#if hasMounts}
- <section id="storage" class="scroll-mt-20">
- <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
- <DatabaseIcon class="size-5" />
- {m.containers_storage_title()}
- </h2>
-
- <Card.Root class="rounded-lg border shadow-sm">
- <Card.Content class="p-6">
- {#if container.mounts && container.mounts.length > 0}
- <div class="space-y-4">
- {#each container.mounts as mount (mount.destination)}
- <div class="overflow-hidden rounded border">
- <div class="bg-muted/20 flex items-center justify-between p-4">
- <div class="flex items-center gap-3">
- <div
- class="rounded p-2 {mount.type === 'volume'
- ? 'bg-purple-100 dark:bg-purple-950'
- : mount.type === 'bind'
- ? 'bg-blue-100 dark:bg-blue-950'
- : 'bg-amber-100 dark:bg-amber-950'}"
- >
- {#if mount.type === 'volume'}
- <DatabaseIcon class="size-4 text-purple-600" />
- {:else if mount.type === 'bind'}
- <HardDriveIcon class="size-4 text-blue-600" />
- {:else}
- <TerminalIcon class="size-4 text-amber-600" />
- {/if}
- </div>
- <div>
- <div class="font-medium">
- {mount.type === 'tmpfs'
- ? m.containers_mount_type_tmpfs()
- : mount.type === 'volume'
- ? mount.name || m.containers_mount_type_volume()
- : m.containers_mount_type_bind()}
- </div>
- <div class="text-muted-foreground text-sm">
- {mount.type} mount {mount.rw ? `(${m.common_rw()})` : `(${m.common_ro()})`}
- </div>
- </div>
- </div>
- <Badge variant={mount.rw ? 'outline' : 'secondary'}>
- {mount.rw ? m.common_rw() : m.common_ro()}
- </Badge>
- </div>
- <div class="space-y-3 p-4">
- <div class="flex">
- <span class="text-muted-foreground w-24 font-medium">{m.containers_mount_label_container()}</span>
- <span class="bg-muted/50 flex-1 rounded px-2 py-1 font-mono">{mount.destination}</span>
- </div>
- <div class="flex">
- <span class="text-muted-foreground w-24 font-medium">
- {mount.type === 'volume'
- ? m.containers_mount_label_volume()
- : mount.type === 'bind'
- ? m.containers_mount_label_host()
- : m.containers_mount_label_source()}
- </span>
- <span class="bg-muted/50 flex-1 rounded px-2 py-1 font-mono">{mount.source}</span>
- </div>
- </div>
- </div>
- {/each}
- </div>
- {:else}
- <div class="py-12 text-center">
- <div class="bg-muted/50 mx-auto mb-4 flex size-16 items-center justify-center rounded-full">
- <DatabaseIcon class="text-muted-foreground size-6" />
- </div>
- <div class="text-muted-foreground">{m.containers_no_mounts_configured()}</div>
- </div>
- {/if}
- </Card.Content>
- </Card.Root>
- </section>
- {/if}
+ <ContainerConfiguration {container} {hasEnvVars} {hasPorts} {hasLabels} {baseServerUrl} />
</div>
- </div>
+ </Tabs.Content>
+ {/if}
+
+ {#if hasNetworks}
+ <Tabs.Content value="network" class="h-full">
+ <div class="space-y-8">
+ <ContainerNetwork {container} />
+ </div>
+ </Tabs.Content>
+ {/if}
+
+ {#if hasMounts}
+ <Tabs.Content value="storage" class="h-full">
+ <div class="space-y-8">
+ <ContainerStorage {container} />
+ </div>
+ </Tabs.Content>
+ {/if}
+ {/snippet}
+ </TabbedPageLayout>
+{:else}
+ <div class="flex min-h-screen items-center justify-center">
+ <div class="text-center">
+ <div class="bg-muted/50 mb-6 inline-flex rounded-full p-6">
+ <CircleAlertIcon class="text-muted-foreground size-10" />
</div>
- </div>
- {:else}
- <div class="flex min-h-screen items-center justify-center">
- <div class="text-center">
- <div class="bg-muted/50 mb-6 inline-flex rounded-full p-6">
- <CircleAlertIcon class="text-muted-foreground size-10" />
- </div>
- <h2 class="mb-3 text-2xl font-medium">{m.containers_not_found_title()}</h2>
- <p class="text-muted-foreground mb-8 max-w-md text-center">
- {m.containers_not_found_description()}
- </p>
- <div class="flex justify-center gap-4">
- <Button variant="outline" href="/containers">
- <ArrowLeftIcon class="mr-2 size-4" />
- {m.common_back_to_containers()}
- </Button>
- <Button variant="default" onclick={refreshData}>
- <RefreshCwIcon class="mr-2 size-4" />
- {m.common_retry()}
- </Button>
- </div>
+ <h2 class="mb-3 text-2xl font-medium">{m.containers_not_found_title()}</h2>
+ <p class="text-muted-foreground mb-8 max-w-md text-center">
+ {m.containers_not_found_description()}
+ </p>
+ <div class="flex justify-center gap-4">
+ <Button variant="outline" href="/containers">
+ <ArrowLeftIcon class="mr-2 size-4" />
+ {m.common_back_to_containers()}
+ </Button>
+ <Button variant="default" onclick={refreshData}>
+ <RefreshCwIcon class="mr-2 size-4" />
+ {m.common_retry()}
+ </Button>
</div>
</div>
- {/if}
-</div>
+ </div>
+{/if}
diff --git a/frontend/src/routes/containers/components/ContainerConfiguration.svelte b/frontend/src/routes/containers/components/ContainerConfiguration.svelte
new file mode 100644
index 000000000..339ef17e1
--- /dev/null
+++ b/frontend/src/routes/containers/components/ContainerConfiguration.svelte
@@ -0,0 +1,111 @@
+<script lang="ts">
+ import * as Card from '$lib/components/ui/card/index.js';
+ import { Badge } from '$lib/components/ui/badge/index.js';
+ import SettingsIcon from '@lucide/svelte/icons/settings';
+ import Separator from '$lib/components/ui/separator/separator.svelte';
+ import PortBadges from '$lib/components/port-badges.svelte';
+ import { m } from '$lib/paraglide/messages';
+ import type { ContainerDetailsDto } from '$lib/types/container.type';
+
+ interface Props {
+ container: ContainerDetailsDto;
+ hasEnvVars: boolean;
+ hasPorts: boolean;
+ hasLabels: boolean;
+ baseServerUrl: string;
+ }
+
+ let { container, hasEnvVars, hasPorts, hasLabels, baseServerUrl }: Props = $props();
+</script>
+
+<section class="scroll-mt-20">
+ <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
+ <SettingsIcon class="size-5" />
+ {m.containers_configuration_title()}
+ </h2>
+
+ <Card.Root class="rounded-lg border shadow-sm">
+ <Card.Header class="pb-4">
+ <Card.Title>{m.containers_env_ports_labels_title()}</Card.Title>
+ <Card.Description class="text-muted-foreground text-sm">
+ {m.containers_env_ports_labels_description()}
+ </Card.Description>
+ </Card.Header>
+
+ <Card.Content class="space-y-8">
+ {#if hasEnvVars}
+ <div>
+ <h3 class="mb-3 text-sm font-semibold tracking-tight">{m.containers_env_vars_title()}</h3>
+
+ {#if container.config?.env && container.config.env.length > 0}
+ <ul class="divide-border/60 divide-y">
+ {#each container.config.env as env, index (index)}
+ {#if env.includes('=')}
+ {@const [key, ...valueParts] = env.split('=')}
+ {@const value = valueParts.join('=')}
+ <li class="px-4 py-2.5">
+ <div class="flex min-w-0 items-center gap-3">
+ <Badge variant="secondary">
+ {key}:
+ </Badge>
+ <span class="truncate font-semibold" title={value}>{value}</span>
+ </div>
+ </li>
+ {:else}
+ <li class="px-4 py-2.5">
+ <div class="flex min-w-0 items-center gap-3">
+ <Badge variant="secondary">ENV:</Badge>
+ <span class="truncate font-semibold" title={env}>{env}</span>
+ </div>
+ </li>
+ {/if}
+ {/each}
+ </ul>
+ {:else}
+ <div class="text-muted-foreground py-8 text-center">{m.containers_no_env_vars()}</div>
+ {/if}
+ </div>
+ {/if}
+
+ {#if hasEnvVars && (hasPorts || hasLabels)}
+ <Separator />
+ {/if}
+
+ {#if hasPorts}
+ <div>
+ <h3 class="mb-3 text-sm font-semibold tracking-tight">{m.containers_port_mappings()}</h3>
+ <PortBadges ports={container.ports ?? []} {baseServerUrl} />
+ </div>
+ {/if}
+
+ {#if hasPorts && hasLabels}
+ <Separator />
+ {/if}
+
+ {#if hasLabels}
+ <div>
+ <h3 class="mb-3 text-sm font-semibold tracking-tight">{m.common_labels()}</h3>
+
+ {#if container.labels && Object.keys(container.labels).length > 0}
+ <ul class="divide-border/60 divide-y">
+ {#each Object.entries(container.labels) as [key, value] (key)}
+ <li class="px-4 py-2.5">
+ <div class="flex min-w-0 items-center gap-3">
+ <Badge variant="secondary">
+ {key}:
+ </Badge>
+ <span class="truncate font-semibold" title={value?.toString()}>
+ {value?.toString() || ''}
+ </span>
+ </div>
+ </li>
+ {/each}
+ </ul>
+ {:else}
+ <div class="text-muted-foreground py-8 text-center">{m.containers_no_labels_defined()}</div>
+ {/if}
+ </div>
+ {/if}
+ </Card.Content>
+ </Card.Root>
+</section>
diff --git a/frontend/src/routes/containers/components/ContainerLogsPanel.svelte b/frontend/src/routes/containers/components/ContainerLogsPanel.svelte
new file mode 100644
index 000000000..79f55c8c1
--- /dev/null
+++ b/frontend/src/routes/containers/components/ContainerLogsPanel.svelte
@@ -0,0 +1,150 @@
+<script lang="ts">
+ import * as Card from '$lib/components/ui/card/index.js';
+ import { Button } from '$lib/components/ui/button/index.js';
+ import FileTextIcon from '@lucide/svelte/icons/file-text';
+ import RefreshCwIcon from '@lucide/svelte/icons/refresh-cw';
+ import LogViewer from '$lib/components/log-viewer.svelte';
+ import { m } from '$lib/paraglide/messages';
+
+ let {
+ containerId,
+ autoScroll = $bindable(),
+ onStart,
+ onStop,
+ onClear,
+ onToggleAutoScroll
+ }: {
+ containerId: string | undefined;
+ autoScroll: boolean;
+ onStart: () => void;
+ onStop: () => void;
+ onClear: () => void;
+ onToggleAutoScroll: () => void;
+ } = $props();
+
+ let isStreaming = $state(false);
+ let viewer = $state<LogViewer>();
+
+ function handleStart() {
+ isStreaming = true;
+ onStart();
+ }
+
+ function handleStop() {
+ isStreaming = false;
+ onStop();
+ }
+
+ function handleClear() {
+ onClear();
+ }
+
+ function handleToggleAutoScroll() {
+ onToggleAutoScroll();
+ }
+</script>
+
+<div class="mb-3 flex flex-col gap-3 sm:hidden">
+ <div class="flex items-center justify-between">
+ <div class="flex items-center gap-2">
+ <FileTextIcon class="size-5" />
+ <h2 class="text-lg font-semibold">{m.containers_logs_title()}</h2>
+ </div>
+ {#if isStreaming}
+ <div class="flex items-center gap-2">
+ <div class="size-2 animate-pulse rounded-full bg-green-500"></div>
+ <span class="text-sm font-medium text-green-600">{m.common_live()}</span>
+ </div>
+ {/if}
+ </div>
+
+ <div class="flex items-center justify-between gap-3">
+ <label class="flex items-center gap-2">
+ <input type="checkbox" bind:checked={autoScroll} class="size-4" />
+ {m.common_autoscroll()}
+ </label>
+ <div class="flex items-center gap-2">
+ <Button variant="outline" size="sm" onclick={() => viewer?.clearLogs()}>{m.common_clear()}</Button>
+ {#if isStreaming}
+ <Button variant="outline" size="sm" onclick={() => viewer?.stopLogStream()}>
+ {m.common_stop()}
+ </Button>
+ {:else}
+ <Button variant="outline" size="sm" onclick={() => viewer?.startLogStream()} disabled={!containerId}>
+ {m.common_start()}
+ </Button>
+ {/if}
+ <Button
+ variant="outline"
+ size="sm"
+ onclick={() => {
+ viewer?.stopLogStream();
+ viewer?.startLogStream();
+ }}
+ aria-label="Refresh logs"
+ title="Refresh"
+ >
+ <RefreshCwIcon class="size-4" />
+ </Button>
+ </div>
+ </div>
+</div>
+
+<div class="mb-3 hidden items-center justify-between sm:flex">
+ <div class="flex items-center gap-3">
+ <FileTextIcon class="size-5" />
+ <h2 class="text-xl font-semibold">{m.containers_logs_title()}</h2>
+ {#if isStreaming}
+ <div class="flex items-center gap-2">
+ <div class="size-2 animate-pulse rounded-full bg-green-500"></div>
+ <span class="text-sm font-medium text-green-600">{m.common_live()}</span>
+ </div>
+ {/if}
+ </div>
+ <div class="flex items-center gap-3">
+ <label class="flex items-center gap-2">
+ <input type="checkbox" bind:checked={autoScroll} class="size-4" />
+ {m.common_autoscroll()}
+ </label>
+ <Button variant="outline" size="sm" onclick={() => viewer?.clearLogs()}>{m.common_clear()}</Button>
+ {#if isStreaming}
+ <Button variant="outline" size="sm" onclick={() => viewer?.stopLogStream()}>{m.common_stop()}</Button>
+ {:else}
+ <Button variant="outline" size="sm" onclick={() => viewer?.startLogStream()} disabled={!containerId}>
+ {m.common_start()}
+ </Button>
+ {/if}
+ <Button
+ variant="outline"
+ size="sm"
+ onclick={() => {
+ viewer?.stopLogStream();
+ viewer?.startLogStream();
+ }}
+ aria-label="Refresh logs"
+ title="Refresh"
+ >
+ <RefreshCwIcon class="size-4" />
+ </Button>
+ </div>
+</div>
+
+<Card.Root class="overflow-hidden border">
+ <Card.Content class="p-0">
+ <div class="w-full overflow-hidden">
+ <LogViewer
+ bind:this={viewer}
+ bind:autoScroll
+ type="container"
+ {containerId}
+ maxLines={500}
+ showTimestamps={true}
+ height="calc(100vh - 280px)"
+ onStart={handleStart}
+ onStop={handleStop}
+ onClear={handleClear}
+ onToggleAutoScroll={handleToggleAutoScroll}
+ />
+ </div>
+ </Card.Content>
+</Card.Root>
diff --git a/frontend/src/routes/containers/components/ContainerNetwork.svelte b/frontend/src/routes/containers/components/ContainerNetwork.svelte
new file mode 100644
index 000000000..6d5509a29
--- /dev/null
+++ b/frontend/src/routes/containers/components/ContainerNetwork.svelte
@@ -0,0 +1,84 @@
+<script lang="ts">
+ import * as Card from '$lib/components/ui/card/index.js';
+ import NetworkIcon from '@lucide/svelte/icons/network';
+ import { m } from '$lib/paraglide/messages';
+ import type { ContainerDetailsDto } from '$lib/types/container.type';
+
+ interface NetworkConfig {
+ IPAddress?: string;
+ IPPrefixLen?: number;
+ Gateway?: string;
+ MacAddress?: string;
+ Aliases?: string[];
+ Links?: string[];
+ [key: string]: any;
+ }
+
+ interface Props {
+ container: ContainerDetailsDto;
+ }
+
+ let { container }: Props = $props();
+
+ function ensureNetworkConfig(config: any): NetworkConfig {
+ return config as NetworkConfig;
+ }
+</script>
+
+<section class="scroll-mt-20">
+ <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
+ <NetworkIcon class="size-5" />
+ {m.containers_networks_title()}
+ </h2>
+
+ <Card.Root class="rounded-lg border shadow-sm">
+ <Card.Content class="p-6">
+ {#if container.networkSettings?.networks && Object.keys(container.networkSettings.networks).length > 0}
+ <div class="space-y-6">
+ {#each Object.entries(container.networkSettings.networks) as [networkName, rawNetworkConfig] (networkName)}
+ {@const networkConfig = ensureNetworkConfig({
+ IPAddress: rawNetworkConfig.ipAddress,
+ IPPrefixLen: rawNetworkConfig.ipPrefixLen,
+ Gateway: rawNetworkConfig.gateway,
+ MacAddress: rawNetworkConfig.macAddress,
+ Aliases: rawNetworkConfig.aliases
+ })}
+ <div class="rounded border p-4">
+ <div class="mb-4 font-medium">{networkName}</div>
+ <div class="grid grid-cols-2 gap-4 lg:grid-cols-4">
+ <div>
+ <div class="text-muted-foreground text-sm">{m.containers_ip_address()}</div>
+ <div class="font-mono">{rawNetworkConfig.ipAddress || m.common_na()}</div>
+ </div>
+ <div>
+ <div class="text-muted-foreground text-sm">{m.containers_gateway()}</div>
+ <div class="font-mono">{rawNetworkConfig.gateway || m.common_na()}</div>
+ </div>
+ <div>
+ <div class="text-muted-foreground text-sm">{m.containers_mac_address()}</div>
+ <div class="font-mono">{rawNetworkConfig.macAddress || m.common_na()}</div>
+ </div>
+ <div>
+ <div class="text-muted-foreground text-sm">{m.containers_subnet()}</div>
+ <div class="font-mono">
+ {rawNetworkConfig.ipPrefixLen
+ ? `${rawNetworkConfig.ipAddress}/${rawNetworkConfig.ipPrefixLen}`
+ : m.common_na()}
+ </div>
+ </div>
+ {#if rawNetworkConfig.aliases && rawNetworkConfig.aliases.length > 0}
+ <div class="col-span-2">
+ <div class="text-muted-foreground text-sm">{m.containers_aliases()}</div>
+ <div class="font-mono">{rawNetworkConfig.aliases.join(', ')}</div>
+ </div>
+ {/if}
+ </div>
+ </div>
+ {/each}
+ </div>
+ {:else}
+ <div class="text-muted-foreground py-12 text-center">{m.containers_no_networks_connected()}</div>
+ {/if}
+ </Card.Content>
+ </Card.Root>
+</section>
diff --git a/frontend/src/routes/containers/components/ContainerOverview.svelte b/frontend/src/routes/containers/components/ContainerOverview.svelte
new file mode 100644
index 000000000..308274e54
--- /dev/null
+++ b/frontend/src/routes/containers/components/ContainerOverview.svelte
@@ -0,0 +1,170 @@
+<script lang="ts">
+ import * as Card from '$lib/components/ui/card/index.js';
+ import HardDriveIcon from '@lucide/svelte/icons/hard-drive';
+ import ClockIcon from '@lucide/svelte/icons/clock';
+ import NetworkIcon from '@lucide/svelte/icons/network';
+ import TerminalIcon from '@lucide/svelte/icons/terminal';
+ import Separator from '$lib/components/ui/separator/separator.svelte';
+ import StatusBadge from '$lib/components/badges/status-badge.svelte';
+ import { m } from '$lib/paraglide/messages';
+ import type { ContainerDetailsDto } from '$lib/types/container.type';
+ import { format } from 'date-fns';
+
+ interface Props {
+ container: ContainerDetailsDto;
+ primaryIpAddress: string;
+ }
+
+ let { container, primaryIpAddress }: Props = $props();
+
+ function parseDockerDate(input: string | Date | undefined | null): Date | null {
+ if (!input) return null;
+ if (input instanceof Date) return isNaN(input.getTime()) ? null : input;
+
+ const s = String(input).trim();
+ if (!s || s.startsWith('0001-01-01')) return null;
+
+ const m = s.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(\.\d+)?Z$/);
+ let normalized = s;
+ if (m) {
+ const base = m[1];
+ const frac = m[2] ? m[2].slice(1) : '';
+ const ms = frac ? '.' + frac.slice(0, 3).padEnd(3, '0') : '';
+ normalized = `${base}${ms}Z`;
+ }
+
+ const d = new Date(normalized);
+ return isNaN(d.getTime()) ? null : d;
+ }
+
+ function formatDockerDate(input: string | Date | undefined | null, fmt = 'PP p'): string {
+ const d = parseDockerDate(input);
+ return d ? format(d, fmt) : 'N/A';
+ }
+</script>
+
+<section class="scroll-mt-20">
+ <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
+ <HardDriveIcon class="size-5" />
+ {m.containers_details_title()}
+ </h2>
+
+ <div class="mb-6">
+ <Card.Root class="rounded-lg border shadow-sm">
+ <Card.Header class="pb-4">
+ <Card.Title>{m.containers_details_title()}</Card.Title>
+ <Card.Description class="text-muted-foreground text-sm">
+ {m.containers_details_description()}
+ </Card.Description>
+ </Card.Header>
+
+ <Card.Content class="space-y-6">
+ <div class="space-y-4">
+ <div class="flex items-center gap-3">
+ <div class="rounded bg-blue-50 p-2 dark:bg-blue-950/20">
+ <HardDriveIcon class="size-4 text-blue-600" />
+ </div>
+ <div class="min-w-0 flex-1">
+ <div class="text-muted-foreground text-sm">{m.common_image()}</div>
+ <div class="truncate font-medium" title={container.image}>
+ {container.image || m.common_na()}
+ </div>
+ </div>
+ </div>
+
+ <div class="flex items-center gap-3">
+ <div class="rounded bg-green-50 p-2 dark:bg-green-950/20">
+ <ClockIcon class="size-4 text-green-600" />
+ </div>
+ <div class="min-w-0 flex-1">
+ <div class="text-muted-foreground text-sm">{m.common_created()}</div>
+ <div class="font-medium" title={formatDockerDate(container?.created)}>
+ {formatDockerDate(container?.created)}
+ </div>
+ </div>
+ </div>
+
+ <div class="flex items-center gap-3">
+ <div class="rounded bg-purple-50 p-2 dark:bg-purple-950/20">
+ <NetworkIcon class="size-4 text-purple-600" />
+ </div>
+ <div class="min-w-0 flex-1">
+ <div class="text-muted-foreground text-sm">{m.containers_ip_address()}</div>
+ <div class="font-medium">{primaryIpAddress}</div>
+ </div>
+ </div>
+
+ <div class="flex items-center gap-3">
+ <div class="rounded bg-amber-50 p-2 dark:bg-amber-950/20">
+ <TerminalIcon class="size-4 text-amber-600" />
+ </div>
+ <div class="min-w-0 flex-1">
+ <div class="text-muted-foreground text-sm">{m.containers_command()}</div>
+ <div class="truncate font-medium" title={container.config?.cmd?.join(' ')}>
+ {container.config?.cmd?.join(' ') || m.common_na()}
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <Separator />
+
+ <div class="space-y-3">
+ <h4 class="text-sm font-semibold tracking-tight">{m.containers_system()}</h4>
+
+ <div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
+ <div class="space-y-1">
+ <div class="text-muted-foreground text-xs">{m.common_id()}</div>
+ <div class="bg-muted/50 max-w-full truncate rounded px-2 py-1.5 font-mono text-xs">
+ {container.id}
+ </div>
+ </div>
+
+ {#if container.config?.workingDir}
+ <div class="space-y-1">
+ <div class="text-muted-foreground text-xs">{m.containers_working_directory()}</div>
+ <div class="bg-muted/50 max-w-full truncate rounded px-2 py-1.5 font-mono text-xs">
+ {container.config.workingDir}
+ </div>
+ </div>
+ {/if}
+
+ {#if container.config?.user}
+ <div class="space-y-1">
+ <div class="text-muted-foreground text-xs">{m.common_user()}</div>
+ <div class="bg-muted/50 inline-flex rounded px-2 py-1.5 font-mono text-xs">
+ {container.config.user}
+ </div>
+ </div>
+ {/if}
+
+ {#if container.state?.health}
+ <div class="space-y-1 sm:col-span-2">
+ <div class="text-muted-foreground text-xs">{m.containers_health_label()}</div>
+ <div class="flex flex-wrap items-center gap-3">
+ <StatusBadge
+ variant={container.state.health.status === 'healthy'
+ ? 'green'
+ : container.state.health.status === 'unhealthy'
+ ? 'red'
+ : 'amber'}
+ text={container.state.health.status}
+ />
+ {#if container.state.health.log && container.state.health.log.length > 0}
+ {@const first = container.state.health.log[0]}
+ {@const lastCheck = (first?.Start ?? first?.start) as string | undefined}
+ {#if lastCheck}
+ <span class="text-muted-foreground text-xs">
+ {m.containers_health_last_check({ time: formatDockerDate(lastCheck) })}
+ </span>
+ {/if}
+ {/if}
+ </div>
+ </div>
+ {/if}
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
+ </div>
+</section>
diff --git a/frontend/src/routes/containers/components/ContainerStats.svelte b/frontend/src/routes/containers/components/ContainerStats.svelte
new file mode 100644
index 000000000..3e585c5f9
--- /dev/null
+++ b/frontend/src/routes/containers/components/ContainerStats.svelte
@@ -0,0 +1,143 @@
+<script lang="ts">
+ import * as Card from '$lib/components/ui/card/index.js';
+ import ActivityIcon from '@lucide/svelte/icons/activity';
+ import NetworkIcon from '@lucide/svelte/icons/network';
+ import { Progress } from '$lib/components/ui/progress/index.js';
+ import { m } from '$lib/paraglide/messages';
+ import bytes from 'bytes';
+ import type Docker from 'dockerode';
+ import type { ContainerDetailsDto } from '$lib/types/container.type';
+
+ interface Props {
+ container: ContainerDetailsDto;
+ stats: Docker.ContainerStats | null;
+ cpuUsagePercent: number;
+ memoryUsageBytes: number;
+ memoryLimitBytes: number;
+ memoryUsageFormatted: string;
+ memoryLimitFormatted: string;
+ memoryUsagePercent: number;
+ }
+
+ let {
+ container,
+ stats,
+ cpuUsagePercent,
+ memoryUsageBytes,
+ memoryLimitBytes,
+ memoryUsageFormatted,
+ memoryLimitFormatted,
+ memoryUsagePercent
+ }: Props = $props();
+</script>
+
+<section class="scroll-mt-20">
+ <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
+ <ActivityIcon class="size-5" />
+ {m.containers_resource_metrics()}
+ </h2>
+
+ <Card.Root class="rounded-lg border shadow-sm">
+ <Card.Content class="p-6">
+ {#if stats && container.state?.running}
+ <div class="grid grid-cols-1 gap-8 lg:grid-cols-2">
+ <div class="space-y-6">
+ <div class="space-y-2">
+ <div class="flex justify-between">
+ <span class="text-sm font-medium">{m.dashboard_meter_cpu()}</span>
+ <span class="text-muted-foreground text-sm">{cpuUsagePercent.toFixed(2)}%</span>
+ </div>
+ <Progress
+ value={cpuUsagePercent}
+ max={100}
+ class="h-2 {cpuUsagePercent > 80 ? '[&>div]:bg-destructive' : cpuUsagePercent > 60 ? '[&>div]:bg-warning' : ''}"
+ />
+ </div>
+
+ <div class="space-y-2">
+ <div class="flex justify-between">
+ <span class="text-sm font-medium">{m.dashboard_meter_memory()}</span>
+ <span class="text-muted-foreground text-sm"
+ >{memoryUsageFormatted} / {memoryLimitFormatted} ({memoryUsagePercent.toFixed(1)}%)</span
+ >
+ </div>
+ <Progress
+ value={memoryUsagePercent}
+ max={100}
+ class="h-2 {memoryUsagePercent > 80
+ ? '[&>div]:bg-destructive'
+ : memoryUsagePercent > 60
+ ? '[&>div]:bg-warning'
+ : ''}"
+ />
+ </div>
+ </div>
+
+ <div class="space-y-6">
+ <div>
+ <h4 class="mb-4 flex items-center gap-2 font-medium">
+ <NetworkIcon class="size-4" />
+ {m.containers_network_io()}
+ </h4>
+ <div class="grid grid-cols-2 gap-4">
+ <div class="bg-muted/30 rounded p-4">
+ <div class="text-muted-foreground text-sm">{m.containers_network_received()}</div>
+ <div class="mt-1 font-medium">
+ {bytes.format(stats.networks?.eth0?.rx_bytes || 0)}
+ </div>
+ </div>
+ <div class="bg-muted/30 rounded p-4">
+ <div class="text-muted-foreground text-sm">{m.containers_network_transmitted()}</div>
+ <div class="mt-1 font-medium">
+ {bytes.format(stats.networks?.eth0?.tx_bytes || 0)}
+ </div>
+ </div>
+ </div>
+ </div>
+
+ {#if stats.blkio_stats && stats.blkio_stats.io_service_bytes_recursive && stats.blkio_stats.io_service_bytes_recursive.length > 0}
+ <div>
+ <h4 class="mb-4 font-medium">{m.containers_block_io()}</h4>
+ <div class="grid grid-cols-2 gap-4">
+ <div class="bg-muted/30 rounded p-4">
+ <div class="text-muted-foreground text-sm">{m.containers_block_io_read()}</div>
+ <div class="mt-1 font-medium">
+ {bytes.format(
+ stats.blkio_stats.io_service_bytes_recursive
+ .filter((item) => item.op === 'Read')
+ .reduce((acc, item) => acc + item.value, 0)
+ )}
+ </div>
+ </div>
+ <div class="bg-muted/30 rounded p-4">
+ <div class="text-muted-foreground text-sm">{m.containers_block_io_write()}</div>
+ <div class="mt-1 font-medium">
+ {bytes.format(
+ stats.blkio_stats.io_service_bytes_recursive
+ .filter((item) => item.op === 'Write')
+ .reduce((acc, item) => acc + item.value, 0)
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ {/if}
+ </div>
+ </div>
+
+ {#if stats.pids_stats && stats.pids_stats.current !== undefined}
+ <div class="mt-6 border-t pt-6">
+ <div class="text-sm">
+ <span class="text-muted-foreground">{m.containers_process_count()}</span>
+ <span class="ml-2 font-medium">{stats.pids_stats.current}</span>
+ </div>
+ </div>
+ {/if}
+ {:else if !container.state?.running}
+ <div class="text-muted-foreground py-12 text-center">{m.containers_stats_unavailable()}</div>
+ {:else}
+ <div class="text-muted-foreground py-12 text-center">{m.containers_stats_loading()}</div>
+ {/if}
+ </Card.Content>
+ </Card.Root>
+</section>
diff --git a/frontend/src/routes/containers/components/ContainerStorage.svelte b/frontend/src/routes/containers/components/ContainerStorage.svelte
new file mode 100644
index 000000000..7e8d9c952
--- /dev/null
+++ b/frontend/src/routes/containers/components/ContainerStorage.svelte
@@ -0,0 +1,92 @@
+<script lang="ts">
+ import * as Card from '$lib/components/ui/card/index.js';
+ import { Badge } from '$lib/components/ui/badge/index.js';
+ import DatabaseIcon from '@lucide/svelte/icons/database';
+ import HardDriveIcon from '@lucide/svelte/icons/hard-drive';
+ import TerminalIcon from '@lucide/svelte/icons/terminal';
+ import { m } from '$lib/paraglide/messages';
+ import type { ContainerDetailsDto } from '$lib/types/container.type';
+
+ interface Props {
+ container: ContainerDetailsDto;
+ }
+
+ let { container }: Props = $props();
+</script>
+
+<section class="scroll-mt-20">
+ <h2 class="mb-6 flex items-center gap-2 text-xl font-semibold">
+ <DatabaseIcon class="size-5" />
+ {m.containers_storage_title()}
+ </h2>
+
+ <Card.Root class="rounded-lg border shadow-sm">
+ <Card.Content class="p-6">
+ {#if container.mounts && container.mounts.length > 0}
+ <div class="space-y-4">
+ {#each container.mounts as mount (mount.destination)}
+ <div class="overflow-hidden rounded border">
+ <div class="bg-muted/20 flex items-center justify-between p-4">
+ <div class="flex items-center gap-3">
+ <div
+ class="rounded p-2 {mount.type === 'volume'
+ ? 'bg-purple-100 dark:bg-purple-950'
+ : mount.type === 'bind'
+ ? 'bg-blue-100 dark:bg-blue-950'
+ : 'bg-amber-100 dark:bg-amber-950'}"
+ >
+ {#if mount.type === 'volume'}
+ <DatabaseIcon class="size-4 text-purple-600" />
+ {:else if mount.type === 'bind'}
+ <HardDriveIcon class="size-4 text-blue-600" />
+ {:else}
+ <TerminalIcon class="size-4 text-amber-600" />
+ {/if}
+ </div>
+ <div>
+ <div class="font-medium">
+ {mount.type === 'tmpfs'
+ ? m.containers_mount_type_tmpfs()
+ : mount.type === 'volume'
+ ? mount.name || m.containers_mount_type_volume()
+ : m.containers_mount_type_bind()}
+ </div>
+ <div class="text-muted-foreground text-sm">
+ {mount.type} mount {mount.rw ? `(${m.common_rw()})` : `(${m.common_ro()})`}
+ </div>
+ </div>
+ </div>
+ <Badge variant={mount.rw ? 'outline' : 'secondary'}>
+ {mount.rw ? m.common_rw() : m.common_ro()}
+ </Badge>
+ </div>
+ <div class="space-y-3 p-4">
+ <div class="flex">
+ <span class="text-muted-foreground w-24 font-medium">{m.containers_mount_label_container()}</span>
+ <span class="bg-muted/50 flex-1 rounded px-2 py-1 font-mono">{mount.destination}</span>
+ </div>
+ <div class="flex">
+ <span class="text-muted-foreground w-24 font-medium">
+ {mount.type === 'volume'
+ ? m.containers_mount_label_volume()
+ : mount.type === 'bind'
+ ? m.containers_mount_label_host()
+ : m.containers_mount_label_source()}
+ </span>
+ <span class="bg-muted/50 flex-1 rounded px-2 py-1 font-mono">{mount.source}</span>
+ </div>
+ </div>
+ </div>
+ {/each}
+ </div>
+ {:else}
+ <div class="py-12 text-center">
+ <div class="bg-muted/50 mx-auto mb-4 flex size-16 items-center justify-center rounded-full">
+ <DatabaseIcon class="text-muted-foreground size-6" />
+ </div>
+ <div class="text-muted-foreground">{m.containers_no_mounts_configured()}</div>
+ </div>
+ {/if}
+ </Card.Content>
+ </Card.Root>
+</section>
diff --git a/frontend/src/routes/customize/registries/+page.svelte b/frontend/src/routes/customize/registries/+page.svelte
index f6f2f58ee..3439311b9 100644
--- a/frontend/src/routes/customize/registries/+page.svelte
+++ b/frontend/src/routes/customize/registries/+page.svelte
@@ -6,13 +6,11 @@
import type { ContainerRegistryCreateDto, ContainerRegistryUpdateDto } from '$lib/types/container-registry.type';
import ContainerRegistryFormSheet from '$lib/components/sheets/container-registry-sheet.svelte';
import RegistryTable from './registry-table.svelte';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
import { handleApiResultWithCallbacks } from '$lib/utils/api.util';
import { tryCatch } from '$lib/utils/try-catch';
import { m } from '$lib/paraglide/messages';
import { containerRegistryService } from '$lib/services/container-registry-service';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data } = $props();
@@ -77,115 +75,96 @@
isLoading[loadingKey] = false;
}
}
-</script>
-
-<div class="space-y-6">
- <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div>
- <h1 class="text-3xl font-bold tracking-tight">{m.registries_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">
- {m.registries_subtitle()}
- </p>
- </div>
- <div class="hidden items-center gap-2 sm:flex">
- <ArcaneButton action="create" onclick={openCreateRegistryDialog} customLabel={m.registries_add_button()} />
- <ArcaneButton
- action="restart"
- onclick={refreshRegistries}
- customLabel={m.common_refresh()}
- loading={isLoading.refresh}
- disabled={isLoading.refresh}
- />
- </div>
-
- <div class="absolute right-4 top-4 flex items-center sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
-
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[160px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- <DropdownMenu.Item onclick={openCreateRegistryDialog}>
- {m.registries_add_button()}
- </DropdownMenu.Item>
- <DropdownMenu.Item onclick={refreshRegistries} disabled={isLoading.refresh}>
- {m.common_refresh()}
- </DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- </div>
- </div>
- <Card.Root class="border shadow-sm">
- <Card.Header class="pb-4">
- <div class="flex items-center gap-3">
- <div class="rounded-full bg-green-500/10 p-2">
- <KeyIcon class="size-5 text-green-500" />
- </div>
- <div>
- <Card.Title>{m.registries_credentials_title()}</Card.Title>
- <Card.Description>
- {m.registries_credentials_description()}
- </Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content>
- <RegistryTable bind:registries bind:selectedIds bind:requestOptions onEditRegistry={openEditRegistryDialog} />
- </Card.Content>
- </Card.Root>
+ const actionButtons: ActionButton[] = [
+ {
+ id: 'create',
+ action: 'create',
+ label: m.registries_add_button(),
+ onclick: openCreateRegistryDialog
+ },
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.common_refresh(),
+ onclick: refreshRegistries,
+ loading: isLoading.refresh,
+ disabled: isLoading.refresh
+ }
+ ];
+</script>
- <Card.Root class="border shadow-sm">
- <Card.Header>
- <Card.Title class="text-lg">{m.registries_info_title()}</Card.Title>
- <Card.Description>{m.registries_info_description()}</Card.Description>
- </Card.Header>
- <Card.Content>
- <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
- <div class="space-y-3">
- <h4 class="text-sm font-medium">{m.registries_popular_public_title()}</h4>
- <div class="space-y-2 text-sm">
- <div class="flex justify-between">
- <span class="text-muted-foreground">{m.registry_docker_hub()}</span>
- <code class="bg-muted rounded px-2 py-1 text-xs">{m.registry_docker_hub_url()}</code>
+<ResourcePageLayout title={m.registries_title()} subtitle={m.registries_subtitle()} {actionButtons}>
+ {#snippet mainContent()}
+ <div class="space-y-6">
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-4">
+ <div class="flex items-center gap-3">
+ <div class="rounded-full bg-green-500/10 p-2">
+ <KeyIcon class="size-5 text-green-500" />
</div>
- <div class="flex justify-between">
- <span class="text-muted-foreground">{m.registry_github_container_registry()}</span>
- <code class="bg-muted rounded px-2 py-1 text-xs">{m.registry_github_url()}</code>
+ <div>
+ <Card.Title>{m.registries_credentials_title()}</Card.Title>
+ <Card.Description>
+ {m.registries_credentials_description()}
+ </Card.Description>
</div>
- <div class="flex justify-between">
- <span class="text-muted-foreground">{m.registry_google_container_registry()}</span>
- <code class="bg-muted rounded px-2 py-1 text-xs">{m.registry_google_url()}</code>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <RegistryTable bind:registries bind:selectedIds bind:requestOptions onEditRegistry={openEditRegistryDialog} />
+ </Card.Content>
+ </Card.Root>
+
+ <Card.Root class="border shadow-sm">
+ <Card.Header>
+ <Card.Title class="text-lg">{m.registries_info_title()}</Card.Title>
+ <Card.Description>{m.registries_info_description()}</Card.Description>
+ </Card.Header>
+ <Card.Content>
+ <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
+ <div class="space-y-3">
+ <h4 class="text-sm font-medium">{m.registries_popular_public_title()}</h4>
+ <div class="space-y-2 text-sm">
+ <div class="flex justify-between">
+ <span class="text-muted-foreground">{m.registry_docker_hub()}</span>
+ <code class="bg-muted rounded px-2 py-1 text-xs">{m.registry_docker_hub_url()}</code>
+ </div>
+ <div class="flex justify-between">
+ <span class="text-muted-foreground">{m.registry_github_container_registry()}</span>
+ <code class="bg-muted rounded px-2 py-1 text-xs">{m.registry_github_url()}</code>
+ </div>
+ <div class="flex justify-between">
+ <span class="text-muted-foreground">{m.registry_google_container_registry()}</span>
+ <code class="bg-muted rounded px-2 py-1 text-xs">{m.registry_google_url()}</code>
+ </div>
+ <div class="flex justify-between">
+ <span class="text-muted-foreground">{m.registry_quay_io()}</span>
+ <code class="bg-muted rounded px-2 py-1 text-xs">{m.registry_quay_url()}</code>
+ </div>
+ </div>
</div>
- <div class="flex justify-between">
- <span class="text-muted-foreground">{m.registry_quay_io()}</span>
- <code class="bg-muted rounded px-2 py-1 text-xs">{m.registry_quay_url()}</code>
+ <div class="space-y-3">
+ <h4 class="text-sm font-medium">{m.registries_auth_notes_title()}</h4>
+ <div class="text-muted-foreground space-y-1 text-sm">
+ <p>• {m.registries_auth_notes_bullet_docker_hub()}</p>
+ <p>• {m.registries_auth_notes_bullet_github()}</p>
+ <p>• {m.registries_auth_notes_bullet_anonymous()}</p>
+ <p>• {m.registries_auth_notes_bullet_encrypted()}</p>
+ </div>
</div>
</div>
- </div>
- <div class="space-y-3">
- <h4 class="text-sm font-medium">{m.registries_auth_notes_title()}</h4>
- <div class="text-muted-foreground space-y-1 text-sm">
- <p>• {m.registries_auth_notes_bullet_docker_hub()}</p>
- <p>• {m.registries_auth_notes_bullet_github()}</p>
- <p>• {m.registries_auth_notes_bullet_anonymous()}</p>
- <p>• {m.registries_auth_notes_bullet_encrypted()}</p>
- </div>
- </div>
- </div>
- </Card.Content>
- </Card.Root>
-</div>
+ </Card.Content>
+ </Card.Root>
+ </div>
+ {/snippet}
-<ContainerRegistryFormSheet
- bind:open={isRegistryDialogOpen}
- bind:registryToEdit
- onSubmit={handleRegistryDialogSubmit}
- isLoading={isLoading.create || isLoading.edit}
-/>
+ {#snippet additionalContent()}
+ <ContainerRegistryFormSheet
+ bind:open={isRegistryDialogOpen}
+ bind:registryToEdit
+ onSubmit={handleRegistryDialogSubmit}
+ isLoading={isLoading.create || isLoading.edit}
+ />
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/customize/templates/+page.svelte b/frontend/src/routes/customize/templates/+page.svelte
index 24e5ee842..ae264b588 100644
--- a/frontend/src/routes/customize/templates/+page.svelte
+++ b/frontend/src/routes/customize/templates/+page.svelte
@@ -15,12 +15,10 @@
import FolderOpenIcon from '@lucide/svelte/icons/folder-open';
import UsersIcon from '@lucide/svelte/icons/users';
import { toast } from 'svelte-sonner';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
import AddTemplateRegistrySheet from '$lib/components/sheets/add-template-registry-sheet.svelte';
- import StatCard from '$lib/components/stat-card.svelte';
import { m } from '$lib/paraglide/messages';
import { templateService } from '$lib/services/template-service.js';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data } = $props();
@@ -116,155 +114,143 @@
isLoading.addingRegistry = false;
}
}
-</script>
-
-<div class="space-y-6">
- <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div>
- <h1 class="text-3xl font-bold tracking-tight">{m.templates_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">
- {m.templates_subtitle()}
- <a href="https://arcane.ofkm.dev/docs/templates" class="text-primary ml-1 hover:underline">{m.templates_learn_more()}</a>
- </p>
- </div>
-
- <div class="hidden sm:flex">
- <Button onclick={refreshTemplates} class="h-10" variant="outline">
- <RefreshCwIcon class="mr-2 size-4" />
- {m.templates_refresh()}
- </Button>
- </div>
-
- <div class="absolute right-4 top-4 flex items-center sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[160px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- <DropdownMenu.Item onclick={refreshTemplates}>
- {m.templates_refresh()}
- </DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- </div>
- </div>
+ const actionButtons: ActionButton[] = [
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.templates_refresh(),
+ onclick: refreshTemplates
+ }
+ ];
- <div class="grid grid-cols-1 gap-4 md:grid-cols-3">
- <StatCard
- title={m.templates_local_templates()}
- value={localTemplateCount}
- icon={FolderOpenIcon}
- iconColor="text-blue-500"
- class="border-l-4 border-l-blue-500"
- />
- <StatCard
- title={m.templates_remote_templates()}
- value={remoteTemplateCount}
- icon={GlobeIcon}
- iconColor="text-green-500"
- class="border-l-4 border-l-green-500"
- />
- <StatCard
- title={m.templates_registries()}
- value={registries.length}
- icon={FileTextIcon}
- iconColor="text-purple-500"
- class="border-l-4 border-l-purple-500"
- />
- </div>
+ const statCards: StatCardConfig[] = $derived([
+ {
+ title: m.templates_local_templates(),
+ value: localTemplateCount,
+ icon: FolderOpenIcon,
+ iconColor: 'text-blue-500',
+ class: 'border-l-4 border-l-blue-500'
+ },
+ {
+ title: m.templates_remote_templates(),
+ value: remoteTemplateCount,
+ icon: GlobeIcon,
+ iconColor: 'text-green-500',
+ class: 'border-l-4 border-l-green-500'
+ },
+ {
+ title: m.templates_registries(),
+ value: registries.length,
+ icon: FileTextIcon,
+ iconColor: 'text-purple-500',
+ class: 'border-l-4 border-l-purple-500'
+ }
+ ]);
+</script>
- <Separator />
+<ResourcePageLayout
+ title={m.templates_title()}
+ subtitle={`${m.templates_subtitle()} `}
+ {actionButtons}
+ {statCards}
+ statCardsColumns={3}
+>
+ {#snippet mainContent()}
+ <div class="space-y-6">
+ <Separator />
- <div class="space-y-4">
- <div class="flex items-center justify-between">
- <h2 class="text-xl font-semibold">{m.templates_registries_section_title()}</h2>
- <Button onclick={() => (showAddRegistrySheet = true)}>
- <PlusIcon class="mr-2 size-4" />
- {m.registries_add_button()}
- </Button>
- </div>
- {#if registries.length == 0}
- <Alert.Root>
- <GlobeIcon class="size-4" />
- <Alert.Title>{m.templates_alert_remote_registries_title()}</Alert.Title>
- <Alert.Description>{m.templates_alert_remote_registries_description()}</Alert.Description>
- </Alert.Root>
+ <div class="space-y-4">
+ <div class="flex items-center justify-between">
+ <h2 class="text-xl font-semibold">{m.templates_registries_section_title()}</h2>
+ <Button onclick={() => (showAddRegistrySheet = true)}>
+ <PlusIcon class="mr-2 size-4" />
+ {m.registries_add_button()}
+ </Button>
+ </div>
+ {#if registries.length == 0}
+ <Alert.Root>
+ <GlobeIcon class="size-4" />
+ <Alert.Title>{m.templates_alert_remote_registries_title()}</Alert.Title>
+ <Alert.Description>{m.templates_alert_remote_registries_description()}</Alert.Description>
+ </Alert.Root>
- <Alert.Root class="border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-950">
- <UsersIcon class="size-4" />
- <Alert.Title>{m.templates_community_registry_title()}</Alert.Title>
- <Alert.Description class="space-y-2">
- <p>{m.templates_community_registry_description()}</p>
- <div class="flex w-full max-w-[475px] flex-col gap-2">
- <Snippet text="https://templates.arcane.ofkm.dev/registry.json" />
- </div>
- </Alert.Description>
- </Alert.Root>
- {/if}
- {#if registries.length > 0}
- <div class="space-y-3">
- {#each registries as registry}
- <Card class="p-4">
- <div class="flex items-center justify-between">
- <div class="flex-1">
- <div class="mb-1 flex items-center gap-2">
- <h4 class="font-medium">{registry.name}</h4>
- <Badge variant={registry.enabled ? 'default' : 'secondary'}>
- {registry.enabled ? m.common_enabled() : m.common_disabled()}
- </Badge>
- </div>
- <p class="text-muted-foreground break-all text-sm">{registry.url}</p>
- {#if registry.description}
- <p class="text-muted-foreground mt-1 text-sm">{registry.description}</p>
- {/if}
+ <Alert.Root class="border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-950">
+ <UsersIcon class="size-4" />
+ <Alert.Title>{m.templates_community_registry_title()}</Alert.Title>
+ <Alert.Description class="space-y-2">
+ <p>{m.templates_community_registry_description()}</p>
+ <div class="flex w-full max-w-[475px] flex-col gap-2">
+ <Snippet text="https://templates.arcane.ofkm.dev/registry.json" />
</div>
- <div class="flex items-center gap-2">
- <Switch
- checked={registry.enabled}
- onCheckedChange={(checked) => updateRegistry(registry.id, { enabled: checked })}
- disabled={isLoading.updating.has(registry.id)}
- />
+ </Alert.Description>
+ </Alert.Root>
+ {/if}
+ {#if registries.length > 0}
+ <div class="space-y-3">
+ {#each registries as registry}
+ <Card class="p-4">
+ <div class="flex items-center justify-between">
+ <div class="flex-1">
+ <div class="mb-1 flex items-center gap-2">
+ <h4 class="font-medium">{registry.name}</h4>
+ <Badge variant={registry.enabled ? 'default' : 'secondary'}>
+ {registry.enabled ? m.common_enabled() : m.common_disabled()}
+ </Badge>
+ </div>
+ <p class="text-muted-foreground break-all text-sm">{registry.url}</p>
+ {#if registry.description}
+ <p class="text-muted-foreground mt-1 text-sm">{registry.description}</p>
+ {/if}
+ </div>
+ <div class="flex items-center gap-2">
+ <Switch
+ checked={registry.enabled}
+ onCheckedChange={(checked) => updateRegistry(registry.id, { enabled: checked })}
+ disabled={isLoading.updating.has(registry.id)}
+ />
- <Button variant="outline" size="sm" onclick={() => window.open(registry.url, '_blank')}>
- <ExternalLinkIcon class="size-4" />
- </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ onclick={() => window.open(registry.url, '_blank', 'noopener,noreferrer')}
+ >
+ <ExternalLinkIcon class="size-4" />
+ </Button>
- <Button
- variant="destructive"
- size="sm"
- onclick={() => removeRegistry(registry.id)}
- disabled={isLoading.removing.has(registry.id)}
- >
- {#if isLoading.removing.has(registry.id)}
- <RefreshCwIcon class="size-4 animate-spin" />
- {:else}
- <Trash2Icon class="size-4" />
- {/if}
- </Button>
- </div>
- </div>
- </Card>
- {/each}
- </div>
- {:else}
- <div class="text-muted-foreground py-6 text-center">
- <GlobeIcon class="mx-auto mb-4 size-12 opacity-50" />
- <p class="mb-2">{m.templates_no_registries_title()}</p>
- <p class="text-sm">{m.templates_no_registries_description()}</p>
+ <Button
+ variant="destructive"
+ size="sm"
+ onclick={() => removeRegistry(registry.id)}
+ disabled={isLoading.removing.has(registry.id)}
+ >
+ {#if isLoading.removing.has(registry.id)}
+ <RefreshCwIcon class="size-4 animate-spin" />
+ {:else}
+ <Trash2Icon class="size-4" />
+ {/if}
+ </Button>
+ </div>
+ </div>
+ </Card>
+ {/each}
+ </div>
+ {:else}
+ <div class="text-muted-foreground py-6 text-center">
+ <GlobeIcon class="mx-auto mb-4 size-12 opacity-50" />
+ <p class="mb-2">{m.templates_no_registries_title()}</p>
+ <p class="text-sm">{m.templates_no_registries_description()}</p>
+ </div>
+ {/if}
</div>
- {/if}
- </div>
+ </div>
+ {/snippet}
- <AddTemplateRegistrySheet
- bind:open={showAddRegistrySheet}
- onSubmit={handleRegistrySubmit}
- isLoading={isLoading.addingRegistry}
- />
-</div>
+ {#snippet additionalContent()}
+ <AddTemplateRegistrySheet
+ bind:open={showAddRegistrySheet}
+ onSubmit={handleRegistrySubmit}
+ isLoading={isLoading.addingRegistry}
+ />
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/environments/+page.svelte b/frontend/src/routes/environments/+page.svelte
index 73a48e86a..933a62a00 100644
--- a/frontend/src/routes/environments/+page.svelte
+++ b/frontend/src/routes/environments/+page.svelte
@@ -1,9 +1,6 @@
<script lang="ts">
import ServerIcon from '@lucide/svelte/icons/server';
import { toast } from 'svelte-sonner';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
import NewEnvironmentSheet from '$lib/components/sheets/new-environment-sheet.svelte';
import EnvironmentTable from './environment-table.svelte';
import { tryCatch } from '$lib/utils/try-catch';
@@ -11,6 +8,7 @@
import { openConfirmDialog } from '$lib/components/confirm-dialog';
import { m } from '$lib/paraglide/messages';
import { environmentManagementService } from '$lib/services/env-mgmt-service';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data } = $props();
@@ -94,64 +92,43 @@
toast.success(m.environments_created_success());
refresh();
}
-</script>
-
-<div class="space-y-6">
- <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div class="flex items-center gap-2">
- <div>
- <h1 class="text-3xl font-bold tracking-tight">{m.environments_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">{m.environments_subtitle()}</p>
- </div>
- </div>
- <div class="hidden items-center gap-2 sm:flex">
- {#if selectedIds.length > 0}
- <ArcaneButton
- action="remove"
- customLabel={m.environments_remove_selected_button()}
- onclick={handleBulkDelete}
- loading={isLoading.deleting}
- disabled={isLoading.deleting}
- />
- {/if}
- <ArcaneButton action="create" customLabel={m.environments_add_button()} onclick={() => (showEnvironmentSheet = true)} />
- <ArcaneButton
- action="restart"
- customLabel={m.common_refresh()}
- onclick={refresh}
- loading={isLoading.refresh}
- disabled={isLoading.refresh}
- />
- </div>
-
- <div class="absolute right-4 top-4 flex items-center sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[160px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- {#if selectedIds.length > 0}
- <DropdownMenu.Item onclick={handleBulkDelete} disabled={isLoading.deleting}>
- {m.environments_remove_selected_button()}
- </DropdownMenu.Item>
- {/if}
- <DropdownMenu.Item onclick={() => (showEnvironmentSheet = true)}>{m.environments_add_button()}</DropdownMenu.Item>
- <DropdownMenu.Item onclick={refresh} disabled={isLoading.refresh}>
- {m.common_refresh()}
- </DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- </div>
- </div>
+ const actionButtons: ActionButton[] = $derived([
+ ...(selectedIds.length > 0
+ ? [
+ {
+ id: 'remove-selected',
+ action: 'remove' as const,
+ label: m.environments_remove_selected_button(),
+ onclick: handleBulkDelete,
+ loading: isLoading.deleting,
+ disabled: isLoading.deleting
+ }
+ ]
+ : []),
+ {
+ id: 'create',
+ action: 'create' as const,
+ label: m.environments_add_button(),
+ onclick: () => (showEnvironmentSheet = true)
+ },
+ {
+ id: 'refresh',
+ action: 'restart' as const,
+ label: m.common_refresh(),
+ onclick: refresh,
+ loading: isLoading.refresh,
+ disabled: isLoading.refresh
+ }
+ ]);
+</script>
- <EnvironmentTable bind:environments bind:selectedIds bind:requestOptions />
-</div>
+<ResourcePageLayout title={m.environments_title()} subtitle={m.environments_subtitle()} {actionButtons}>
+ {#snippet mainContent()}
+ <EnvironmentTable bind:environments bind:selectedIds bind:requestOptions />
+ {/snippet}
-<NewEnvironmentSheet bind:open={showEnvironmentSheet} {onEnvironmentCreated} />
+ {#snippet additionalContent()}
+ <NewEnvironmentSheet bind:open={showEnvironmentSheet} {onEnvironmentCreated} />
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/events/+page.svelte b/frontend/src/routes/events/+page.svelte
index fd2beea46..23896280b 100644
--- a/frontend/src/routes/events/+page.svelte
+++ b/frontend/src/routes/events/+page.svelte
@@ -4,15 +4,12 @@
import { tryCatch } from '$lib/utils/try-catch';
import { handleApiResultWithCallbacks } from '$lib/utils/api.util';
import type { PageData } from './$types';
- import StatCard from '$lib/components/stat-card.svelte';
import type { Event } from '$lib/types/event.type';
import EventTable from './event-table.svelte';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
import { openConfirmDialog } from '$lib/components/confirm-dialog';
import { m } from '$lib/paraglide/messages';
import { eventService } from '$lib/services/event-service';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data }: { data: PageData } = $props();
@@ -89,96 +86,83 @@
}
});
}
-</script>
-<div class="flex h-full flex-col space-y-6">
- <div class="relative flex items-center justify-between">
- <div class="space-y-1">
- <h2 class="text-2xl font-semibold tracking-tight">{m.events_title()}</h2>
- <p class="text-muted-foreground text-sm">{m.events_subtitle()}</p>
- </div>
- <div class="hidden items-center gap-2 sm:flex">
- {#if selectedIds.length > 0}
- <ArcaneButton
- action="remove"
- customLabel={m.events_remove_selected()}
- onclick={handleDeleteSelected}
- loading={isLoading.deleting}
- disabled={isLoading.deleting}
- />
- {/if}
- <ArcaneButton
- action="restart"
- customLabel={m.common_refresh()}
- onclick={refreshEvents}
- loading={isLoading.refreshing}
- disabled={isLoading.refreshing}
- />
- </div>
-
- <div class="absolute right-4 top-4 flex items-center sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
+ const actionButtons: ActionButton[] = $derived([
+ ...(selectedIds.length > 0
+ ? [
+ {
+ id: 'remove-selected',
+ action: 'remove' as const,
+ label: m.events_remove_selected(),
+ onclick: handleDeleteSelected,
+ loading: isLoading.deleting,
+ disabled: isLoading.deleting
+ }
+ ]
+ : []),
+ {
+ id: 'refresh',
+ action: 'restart' as const,
+ label: m.common_refresh(),
+ onclick: refreshEvents,
+ loading: isLoading.refreshing,
+ disabled: isLoading.refreshing
+ }
+ ]);
+
+ const statCards: StatCardConfig[] = $derived([
+ {
+ title: m.events_total(),
+ value: totalEvents,
+ subtitle: m.events_total_subtitle(),
+ icon: ActivityIcon
+ },
+ {
+ title: m.events_info(),
+ value: infoEvents,
+ subtitle: m.events_info_subtitle(),
+ icon: ActivityIcon,
+ iconColor: 'text-blue-500',
+ bgColor: 'bg-blue-500/10'
+ },
+ {
+ title: m.events_success(),
+ value: successEvents,
+ subtitle: m.events_success_subtitle(),
+ icon: ActivityIcon,
+ iconColor: 'text-green-500',
+ bgColor: 'bg-green-500/10'
+ },
+ {
+ title: m.events_warning(),
+ value: warningEvents,
+ subtitle: m.events_warning_subtitle(),
+ icon: ActivityIcon,
+ iconColor: 'text-yellow-500',
+ bgColor: 'bg-yellow-500/10'
+ },
+ {
+ title: m.events_error(),
+ value: errorEvents,
+ subtitle: m.events_error_subtitle(),
+ icon: ActivityIcon,
+ iconColor: 'text-red-500',
+ bgColor: 'bg-red-500/10'
+ }
+ ]);
+</script>
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[180px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- {#if selectedIds.length > 0}
- <DropdownMenu.Item onclick={handleDeleteSelected} disabled={isLoading.deleting}>
- {m.events_remove_selected()}
- </DropdownMenu.Item>
- {/if}
- <DropdownMenu.Item onclick={refreshEvents} disabled={isLoading.refreshing}>
- {m.common_refresh()}
- </DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
+<ResourcePageLayout
+ title={m.events_title()}
+ subtitle={m.events_subtitle()}
+ {actionButtons}
+ {statCards}
+ statCardsColumns={5}
+ containerClass="flex h-full flex-col space-y-6"
+>
+ {#snippet mainContent()}
+ <div class="flex-1 overflow-hidden">
+ <EventTable bind:events bind:selectedIds bind:requestOptions />
</div>
- </div>
-
- <div class="grid gap-4 md:grid-cols-5">
- <StatCard title={m.events_total()} value={totalEvents} icon={ActivityIcon} subtitle={m.events_total_subtitle()} />
- <StatCard
- title={m.events_info()}
- value={infoEvents}
- icon={ActivityIcon}
- iconColor="text-blue-500"
- bgColor="bg-blue-500/10"
- subtitle={m.events_info_subtitle()}
- />
- <StatCard
- title={m.events_success()}
- value={successEvents}
- icon={ActivityIcon}
- iconColor="text-green-500"
- bgColor="bg-green-500/10"
- subtitle={m.events_success_subtitle()}
- />
- <StatCard
- title={m.events_warning()}
- value={warningEvents}
- icon={ActivityIcon}
- iconColor="text-yellow-500"
- bgColor="bg-yellow-500/10"
- subtitle={m.events_warning_subtitle()}
- />
- <StatCard
- title={m.events_error()}
- value={errorEvents}
- icon={ActivityIcon}
- iconColor="text-red-500"
- bgColor="bg-red-500/10"
- subtitle={m.events_error_subtitle()}
- />
- </div>
-
- <div class="flex-1 overflow-hidden">
- <EventTable bind:events bind:selectedIds bind:requestOptions />
- </div>
-</div>
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/images/+page.svelte b/frontend/src/routes/images/+page.svelte
index 18ba2e28c..338d66c75 100644
--- a/frontend/src/routes/images/+page.svelte
+++ b/frontend/src/routes/images/+page.svelte
@@ -9,15 +9,12 @@
import * as Dialog from '$lib/components/ui/dialog/index.js';
import { handleApiResultWithCallbacks } from '$lib/utils/api.util';
import { tryCatch } from '$lib/utils/try-catch';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
- import StatCard from '$lib/components/stat-card.svelte';
import ImageTable from './image-table.svelte';
import { m } from '$lib/paraglide/messages';
import { imageService } from '$lib/services/image-service';
- import { environmentStore } from '$lib/stores/environment.store';
- import type { Environment } from '$lib/types/environment.type';
+ import { environmentStore } from '$lib/stores/environment.store';
+ import type { Environment } from '$lib/types/environment.type';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data } = $props();
@@ -88,16 +85,14 @@
async onSuccess(newImageCounts) {
imageUsageCounts = newImageCounts;
}
- });
+ });
}
- // React to environment changes
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
const env = $selectedEnvStore as Environment | null;
if (!env) return;
- // Skip initial page load
if (lastEnvId === null) {
lastEnvId = env.id;
return;
@@ -107,115 +102,95 @@
refreshImages();
}
});
-</script>
-<div class="space-y-6">
- <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div>
- <h1 class="text-2xl font-bold">{m.images_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">{m.images_subtitle()}</p>
- </div>
- <div class="hidden items-center gap-2 sm:flex">
- <ArcaneButton action="pull" customLabel={m.images_pull_image()} onclick={() => (isPullDialogOpen = true)} />
- <ArcaneButton
- action="inspect"
- customLabel={m.images_check_updates()}
- onclick={handleTriggerBulkUpdateCheck}
- loading={isLoading.checking}
- loadingLabel={m.images_checking()}
- disabled={isLoading.checking}
- />
- <ArcaneButton
- action="remove"
- customLabel={m.images_prune_unused()}
- onclick={() => (isConfirmPruneDialogOpen = true)}
- loading={isLoading.pruning}
- loadingLabel={m.images_pruning()}
- disabled={isLoading.pruning}
- />
- <ArcaneButton
- action="restart"
- onclick={refreshImages}
- customLabel={m.common_refresh()}
- loading={isLoading.refreshing}
- disabled={isLoading.refreshing}
- />
- </div>
+ const actionButtons: ActionButton[] = $derived.by(() => [
+ {
+ id: 'pull',
+ action: 'pull',
+ label: m.images_pull_image(),
+ onclick: () => (isPullDialogOpen = true)
+ },
+ {
+ id: 'check-updates',
+ action: 'inspect',
+ label: m.images_check_updates(),
+ loadingLabel: m.images_checking(),
+ onclick: handleTriggerBulkUpdateCheck,
+ loading: isLoading.checking,
+ disabled: isLoading.checking
+ },
+ {
+ id: 'prune',
+ action: 'remove',
+ label: m.images_prune_unused(),
+ loadingLabel: m.images_pruning(),
+ onclick: () => (isConfirmPruneDialogOpen = true),
+ loading: isLoading.pruning,
+ disabled: isLoading.pruning
+ },
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.common_refresh(),
+ onclick: refreshImages,
+ loading: isLoading.refreshing,
+ disabled: isLoading.refreshing
+ }
+ ]);
- <div class="absolute right-4 top-4 flex items-center sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
+ const statCards: StatCardConfig[] = $derived([
+ {
+ title: m.images_total(),
+ value: imageUsageCounts.totalImages,
+ icon: HardDriveIcon,
+ iconColor: 'text-blue-500',
+ class: 'border-l-4 border-l-blue-500'
+ },
+ {
+ title: m.images_total_size(),
+ value: String(bytes.format(imageUsageCounts.totalImageSize)),
+ icon: PackageIcon,
+ iconColor: 'text-amber-500',
+ class: 'border-l-4 border-l-amber-500'
+ }
+ ]);
+</script>
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[180px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- <DropdownMenu.Item onclick={() => (isPullDialogOpen = true)}>{m.images_pull_image()}</DropdownMenu.Item>
- <DropdownMenu.Item onclick={handleTriggerBulkUpdateCheck} disabled={isLoading.checking}>
- {m.images_check_updates()}
- </DropdownMenu.Item>
- <DropdownMenu.Item onclick={() => (isConfirmPruneDialogOpen = true)} disabled={isLoading.pruning}>
- {m.images_prune_unused()}
- </DropdownMenu.Item>
- <DropdownMenu.Item onclick={refreshImages} disabled={isLoading.refreshing}>
- {m.common_refresh()}
- </DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- </div>
- </div>
+<ResourcePageLayout title={m.images_title()} subtitle={m.images_subtitle()} {actionButtons} {statCards} statCardsColumns={2}>
+ {#snippet mainContent()}
+ <ImageTable bind:images bind:selectedIds bind:requestOptions />
+ {/snippet}
- <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
- <StatCard
- title={m.images_total()}
- value={imageUsageCounts.totalImages}
- icon={HardDriveIcon}
- iconColor="text-blue-500"
- class="border-l-4 border-l-blue-500"
- />
- <StatCard
- title={m.images_total_size()}
- value={String(bytes.format(imageUsageCounts.totalImageSize))}
- icon={PackageIcon}
- iconColor="text-amber-500"
- class="border-l-4 border-l-amber-500"
+ {#snippet additionalContent()}
+ <ImagePullSheet
+ bind:open={isPullDialogOpen}
+ onPullFinished={async () => (images = await imageService.getImages(requestOptions))}
/>
- </div>
- <ImageTable bind:images bind:selectedIds bind:requestOptions />
-
- <ImagePullSheet
- bind:open={isPullDialogOpen}
- onPullFinished={async () => (images = await imageService.getImages(requestOptions))}
- />
- <Dialog.Root bind:open={isConfirmPruneDialogOpen}>
- <Dialog.Content>
- <Dialog.Header>
- <Dialog.Title>{m.images_prune_confirm_title()}</Dialog.Title>
- <Dialog.Description>
- {m.images_prune_confirm_description({ mode: String(data.settings.dockerPruneMode) })}
- </Dialog.Description>
- </Dialog.Header>
- <div class="flex justify-end gap-3 pt-6">
- <Button variant="outline" onclick={() => (isConfirmPruneDialogOpen = false)} disabled={isLoading.pruning}>
- {m.common_cancel()}
- </Button>
- <Button variant="destructive" onclick={handlePruneImages} disabled={isLoading.pruning}>
- {#if isLoading.pruning}
- <LoaderCircleIcon class="mr-2 size-4 animate-spin" /> {m.images_pruning()}
- {:else}
- {m.images_prune_action()}
- {/if}
- </Button>
- </div>
- </Dialog.Content>
- </Dialog.Root>
-</div>
+ <Dialog.Root bind:open={isConfirmPruneDialogOpen}>
+ <Dialog.Content>
+ <Dialog.Header>
+ <Dialog.Title>{m.images_prune_confirm_title()}</Dialog.Title>
+ <Dialog.Description>
+ {m.images_prune_confirm_description({ mode: String(data.settings.dockerPruneMode) })}
+ </Dialog.Description>
+ </Dialog.Header>
+ <div class="flex justify-end gap-3 pt-6">
+ <Button variant="outline" onclick={() => (isConfirmPruneDialogOpen = false)} disabled={isLoading.pruning}>
+ {m.common_cancel()}
+ </Button>
+ <Button variant="destructive" onclick={handlePruneImages} disabled={isLoading.pruning}>
+ {#if isLoading.pruning}
+ <LoaderCircleIcon class="mr-2 size-4 animate-spin" /> {m.images_pruning()}
+ {:else}
+ {m.images_prune_action()}
+ {/if}
+ </Button>
+ </div>
+ </Dialog.Content>
+ </Dialog.Root>
+ {/snippet}
+</ResourcePageLayout>
<style>
:global(body) {
diff --git a/frontend/src/routes/networks/+page.svelte b/frontend/src/routes/networks/+page.svelte
index f90d53023..f42f4c5f9 100644
--- a/frontend/src/routes/networks/+page.svelte
+++ b/frontend/src/routes/networks/+page.svelte
@@ -6,15 +6,12 @@
import { handleApiResultWithCallbacks } from '$lib/utils/api.util';
import { tryCatch } from '$lib/utils/try-catch';
import CreateNetworkSheet from '$lib/components/sheets/create-network-sheet.svelte';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
- import StatCard from '$lib/components/stat-card.svelte';
import NetworkTable from './network-table.svelte';
import { m } from '$lib/paraglide/messages';
import { networkService } from '$lib/services/network-service';
- import { environmentStore } from '$lib/stores/environment.store';
- import type { Environment } from '$lib/types/environment.type';
+ import { environmentStore } from '$lib/stores/environment.store';
+ import type { Environment } from '$lib/types/environment.type';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data } = $props();
@@ -33,7 +30,7 @@
async function refreshNetworks() {
isLoading.refresh = true;
let refreshingNetworkList = true;
- let refreshingNetworkCounts = true;
+ let refreshingNetworkCounts = true;
handleApiResultWithCallbacks({
result: await tryCatch(networkService.getNetworks(requestOptions)),
message: m.networks_refresh_failed(),
@@ -73,13 +70,11 @@
});
}
- // React to environment changes
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
const env = $selectedEnvStore as Environment | null;
if (!env) return;
- // Skip initial page load
if (lastEnvId === null) {
lastEnvId = env.id;
return;
@@ -89,65 +84,48 @@
refreshNetworks();
}
});
-</script>
-
-<div class="space-y-6">
- <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div>
- <h1 class="text-3xl font-bold tracking-tight">{m.networks_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">{m.networks_subtitle()}</p>
- </div>
- <div class="hidden items-center gap-2 sm:flex">
- <ArcaneButton action="create" customLabel={m.networks_create_button()} onclick={() => (isCreateDialogOpen = true)} />
- <ArcaneButton
- action="restart"
- onclick={refreshNetworks}
- customLabel={m.common_refresh()}
- loading={isLoading.refresh}
- disabled={isLoading.refresh}
- />
- </div>
-
- <div class="absolute right-4 top-4 flex items-center sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[160px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- <DropdownMenu.Item onclick={() => (isCreateDialogOpen = true)} disabled={isLoading.create}
- >{m.networks_create_button()}</DropdownMenu.Item
- >
- <DropdownMenu.Item onclick={refreshNetworks} disabled={isLoading.refresh}>{m.common_refresh()}</DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- </div>
- </div>
+ const actionButtons: ActionButton[] = $derived.by(() => [
+ {
+ id: 'create',
+ action: 'create',
+ label: m.networks_create_button(),
+ onclick: () => (isCreateDialogOpen = true)
+ },
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.common_refresh(),
+ onclick: refreshNetworks,
+ loading: isLoading.refresh,
+ disabled: isLoading.refresh
+ }
+ ]);
- <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
- <StatCard
- title={m.networks_total()}
- value={totalNetworks}
- icon={NetworkIcon}
- iconColor="text-blue-500"
- class="border-l-4 border-l-blue-500"
- />
- <StatCard
- title={m.unused_networks()}
- value={unusedNetworks}
- icon={EthernetPortIcon}
- iconColor="text-amber-500"
- class="border-l-4 border-l-amber-500"
- />
- </div>
+ const statCards: StatCardConfig[] = $derived([
+ {
+ title: m.networks_total(),
+ value: totalNetworks,
+ icon: NetworkIcon,
+ iconColor: 'text-blue-500',
+ class: 'border-l-4 border-l-blue-500'
+ },
+ {
+ title: m.unused_networks(),
+ value: unusedNetworks,
+ icon: EthernetPortIcon,
+ iconColor: 'text-amber-500',
+ class: 'border-l-4 border-l-amber-500'
+ }
+ ]);
+</script>
- <NetworkTable bind:networks bind:selectedIds bind:requestOptions />
+<ResourcePageLayout title={m.networks_title()} subtitle={m.networks_subtitle()} {actionButtons} {statCards} statCardsColumns={2}>
+ {#snippet mainContent()}
+ <NetworkTable bind:networks bind:selectedIds bind:requestOptions />
+ {/snippet}
- <CreateNetworkSheet bind:open={isCreateDialogOpen} isLoading={isLoading.create} onSubmit={handleCreateNetworkSubmit} />
-</div>
+ {#snippet additionalContent()}
+ <CreateNetworkSheet bind:open={isCreateDialogOpen} isLoading={isLoading.create} onSubmit={handleCreateNetworkSubmit} />
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/projects/+page.svelte b/frontend/src/routes/projects/+page.svelte
index c0f41ee9b..7d76e771a 100644
--- a/frontend/src/routes/projects/+page.svelte
+++ b/frontend/src/routes/projects/+page.svelte
@@ -5,17 +5,14 @@
import { toast } from 'svelte-sonner';
import { handleApiResultWithCallbacks } from '$lib/utils/api.util';
import { tryCatch } from '$lib/utils/try-catch';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
- import StatCard from '$lib/components/stat-card.svelte';
import ProjectsTable from './projects-table.svelte';
import { goto } from '$app/navigation';
import { m } from '$lib/paraglide/messages';
import { projectService } from '$lib/services/project-service';
import { imageService } from '$lib/services/image-service';
- import { environmentStore } from '$lib/stores/environment.store';
- import type { Environment } from '$lib/types/environment.type';
+ import { environmentStore } from '$lib/stores/environment.store';
+ import type { Environment } from '$lib/types/environment.type';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data } = $props();
@@ -72,13 +69,11 @@
});
}
- // React to environment changes
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
const env = $selectedEnvStore as Environment | null;
if (!env) return;
- // Skip initial page load
if (lastEnvId === null) {
lastEnvId = env.id;
return;
@@ -88,80 +83,59 @@
refreshCompose();
}
});
-</script>
-
-<div class="space-y-6">
- <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div>
- <h1 class="text-3xl font-bold tracking-tight">{m.projects_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">{m.compose_subtitle()}</p>
- </div>
- <div class="hidden items-center gap-2 sm:flex">
- <ArcaneButton
- action="inspect"
- customLabel={m.compose_update_projects()}
- onclick={handleCheckForUpdates}
- loading={isLoading.updating}
- disabled={isLoading.updating}
- />
- <ArcaneButton action="create" customLabel={m.compose_create_project()} onclick={() => goto(`/projects/new`)} />
- <ArcaneButton
- action="restart"
- customLabel={m.common_refresh()}
- onclick={refreshCompose}
- loading={isLoading.refreshing}
- disabled={isLoading.refreshing}
- />
- </div>
-
- <div class="absolute right-4 top-4 flex items-center sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[180px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- <DropdownMenu.Item onclick={handleCheckForUpdates} disabled={isLoading.updating}>
- {m.compose_update_projects()}
- </DropdownMenu.Item>
- <DropdownMenu.Item onclick={() => goto(`/projects/new`)}>{m.compose_create_project()}</DropdownMenu.Item>
- <DropdownMenu.Item onclick={refreshCompose} disabled={isLoading.refreshing}>
- {m.common_refresh()}
- </DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- </div>
- </div>
+ const actionButtons: ActionButton[] = $derived.by(() => [
+ {
+ id: 'check-updates',
+ action: 'inspect',
+ label: m.compose_update_projects(),
+ onclick: handleCheckForUpdates,
+ loading: isLoading.updating,
+ disabled: isLoading.updating
+ },
+ {
+ id: 'create',
+ action: 'create',
+ label: m.compose_create_project(),
+ onclick: () => goto('/projects/new')
+ },
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.common_refresh(),
+ onclick: refreshCompose,
+ loading: isLoading.refreshing,
+ disabled: isLoading.refreshing
+ }
+ ]);
- <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
- <StatCard
- title={m.compose_total()}
- value={totalCompose}
- icon={FileStackIcon}
- iconColor="text-amber-500"
- class="border-l-4 border-l-amber-500"
- />
- <StatCard
- title={m.compose_running()}
- value={runningCompose}
- icon={PlayCircleIcon}
- iconColor="text-green-500"
- class="border-l-4 border-l-green-500"
- />
- <StatCard
- title={m.compose_stopped()}
- value={stoppedCompose}
- icon={StopCircleIcon}
- iconColor="text-red-500"
- class="border-l-4 border-l-red-500"
- />
- </div>
+ const statCards: StatCardConfig[] = $derived([
+ {
+ title: m.compose_total(),
+ value: totalCompose,
+ icon: FileStackIcon,
+ iconColor: 'text-amber-500',
+ class: 'border-l-4 border-l-amber-500'
+ },
+ {
+ title: m.compose_running(),
+ value: runningCompose,
+ icon: PlayCircleIcon,
+ iconColor: 'text-green-500',
+ class: 'border-l-4 border-l-green-500'
+ },
+ {
+ title: m.compose_stopped(),
+ value: stoppedCompose,
+ icon: StopCircleIcon,
+ iconColor: 'text-red-500',
+ class: 'border-l-4 border-l-red-500'
+ }
+ ]);
+</script>
- <ProjectsTable bind:projects bind:selectedIds bind:requestOptions={projectRequestOptions} />
-</div>
+<ResourcePageLayout title={m.projects_title()} subtitle={m.compose_subtitle()} {actionButtons} {statCards} statCardsColumns={3}>
+ {#snippet mainContent()}
+ <ProjectsTable bind:projects bind:selectedIds bind:requestOptions={projectRequestOptions} />
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/projects/[projectId]/+page.svelte b/frontend/src/routes/projects/[projectId]/+page.svelte
index 39dc3a7bb..48d487958 100644
--- a/frontend/src/routes/projects/[projectId]/+page.svelte
+++ b/frontend/src/routes/projects/[projectId]/+page.svelte
@@ -2,14 +2,14 @@
import type { Project } from '$lib/types/project.type';
import { Button } from '$lib/components/ui/button/index.js';
import * as Tabs from '$lib/components/ui/tabs/index.js';
- import * as Tooltip from '$lib/components/ui/tooltip/index.js';
- import { Separator } from '$lib/components/ui/separator/index.js';
import { ArcaneButton } from '$lib/components/arcane-button/index.js';
import ArrowLeftIcon from '@lucide/svelte/icons/arrow-left';
import FileStackIcon from '@lucide/svelte/icons/file-stack';
import LayersIcon from '@lucide/svelte/icons/layers';
import SettingsIcon from '@lucide/svelte/icons/settings';
import LogsIcon from '@lucide/svelte/icons/logs';
+ import { type TabItem } from '$lib/components/tab-bar/index.js';
+ import TabbedPageLayout from '$lib/layouts/tabbed-page-layout.svelte';
import ActionButtons from '$lib/components/action-buttons.svelte';
import StatusBadge from '$lib/components/badges/status-badge.svelte';
import { getStatusVariant } from '$lib/utils/status.utils';
@@ -25,7 +25,7 @@
import EditableName from '../components/EditableName.svelte';
import ServicesGrid from '../components/ServicesGrid.svelte';
import CodePanel from '../components/CodePanel.svelte';
- import StackLogsPanel from '../components/ProjectLogsPanel.svelte';
+ import ProjectsLogsPanel from '../components/ProjectLogsPanel.svelte';
import { projectService } from '$lib/services/project-service';
let { data } = $props();
@@ -75,12 +75,31 @@
let canEditName = $derived(!isLoading.saving && project?.status !== 'running' && project?.status !== 'partially running');
let autoScrollStackLogs = $state(true);
- let showFloatingHeader = $state(false);
let selectedTab = $state<'services' | 'compose' | 'logs'>('compose');
let composeOpen = $state(true);
let envOpen = $state(true);
+ const tabItems = $derived<TabItem[]>([
+ {
+ value: 'services',
+ label: m.compose_nav_services(),
+ icon: LayersIcon,
+ badge: project?.serviceCount
+ },
+ {
+ value: 'compose',
+ label: m.compose_nav_config(),
+ icon: SettingsIcon
+ },
+ {
+ value: 'logs',
+ label: m.compose_nav_logs(),
+ icon: LogsIcon,
+ disabled: project?.status !== 'running'
+ }
+ ]);
+
let nameInputRef = $state<HTMLInputElement | null>(null);
type ComposeUIPrefs = {
@@ -112,15 +131,6 @@
autoScrollStackLogs = cur.autoScroll ?? defaultComposeUIPrefs.autoScroll;
});
- // Scroll listener with cleanup (reactive)
- $effect(() => {
- const handleScroll = () => {
- showFloatingHeader = window.scrollY > 100;
- };
- window.addEventListener('scroll', handleScroll);
- return () => window.removeEventListener('scroll', handleScroll);
- });
-
async function handleSaveChanges() {
if (!project || !hasChanges) return;
@@ -162,179 +172,132 @@
}
</script>
-<div class="bg-background flex h-full flex-col overflow-hidden overscroll-y-none">
- {#if project}
- <Tabs.Root value={selectedTab} class="flex min-h-0 w-full flex-1 flex-col">
- <div class="bg-background sticky top-0 flex-shrink-0 border-b backdrop-blur">
- <div class="mx-auto max-w-full px-4 py-3">
- <div class="flex items-center justify-between gap-3">
- <div class="flex min-w-0 items-center gap-3">
- <Button variant="ghost" size="sm" href="/projects">
- <ArrowLeftIcon class="mr-2 size-4" />
- {m.common_back()}
- </Button>
- <Separator orientation="vertical" class="mx-1 h-5" />
- <div class="min-w-0">
- <div class="flex items-center gap-2">
- <EditableName
- bind:value={$inputs.name.value}
- bind:ref={nameInputRef}
- error={$inputs.name.error ?? undefined}
- originalValue={originalName}
- canEdit={canEditName}
- onCommit={saveNameIfChanged}
- />
- {#if project.status}
- <StatusBadge variant={getStatusVariant(project.status)} text={capitalizeFirstLetter(project.status)} />
- {/if}
- </div>
- {#if project.createdAt}
- <p class="text-muted-foreground mt-0.5 text-xs">
- {m.common_created()}: {new Date(project.createdAt ?? '').toLocaleDateString()}
- </p>
- {/if}
- </div>
- </div>
- <div class="flex items-center gap-2">
- {#if hasChanges}
- <ArcaneButton
- action="save"
- loading={isLoading.saving}
- onclick={handleSaveChanges}
- disabled={!hasChanges}
- customLabel={m.common_save()}
- loadingLabel={m.common_saving()}
- />
- {/if}
- <ActionButtons
- id={project.id}
- type="project"
- itemState={project.status}
- bind:startLoading={isLoading.deploying}
- bind:stopLoading={isLoading.stopping}
- bind:restartLoading={isLoading.restarting}
- bind:removeLoading={isLoading.removing}
- bind:redeployLoading={isLoading.redeploying}
- onActionComplete={() => invalidateAll()}
- />
- </div>
- </div>
-
- <div class="mt-4">
- <Tabs.List class="w-full justify-start gap-4">
- <Tabs.Trigger
- value="services"
- class="gap-2"
- onclick={() => {
- selectedTab = 'services';
- persistPrefs();
- }}
- >
- <LayersIcon class="size-4" />
- {m.compose_nav_services()}
- {#if project.serviceCount}
- <span
- class="bg-primary text-primary-foreground ml-1 inline-flex min-w-[18px] items-center justify-center rounded-full px-1 text-[10px] font-medium"
- >
- {project.serviceCount}
- </span>
- {/if}
- </Tabs.Trigger>
- <Tabs.Trigger
- value="compose"
- class="gap-2"
- onclick={() => {
- selectedTab = 'compose';
- persistPrefs();
- }}
- >
- <SettingsIcon class="size-4" />
- {m.compose_nav_config()}
- </Tabs.Trigger>
- <Tabs.Trigger
- value="logs"
- class="gap-2"
- disabled={project.status !== 'running'}
- onclick={() => {
- selectedTab = 'logs';
- persistPrefs();
- }}
- >
- <LogsIcon class="size-4" />
- {m.compose_nav_logs()}
- </Tabs.Trigger>
- </Tabs.List>
- </div>
- </div>
+{#if project}
+ <TabbedPageLayout
+ backUrl="/projects"
+ backLabel={m.common_back()}
+ {tabItems}
+ {selectedTab}
+ onTabChange={(value) => {
+ selectedTab = value as 'services' | 'compose' | 'logs';
+ persistPrefs();
+ }}
+ >
+ {#snippet headerInfo()}
+ <div class="flex items-center gap-2">
+ <EditableName
+ bind:value={$inputs.name.value}
+ bind:ref={nameInputRef}
+ variant="inline"
+ error={$inputs.name.error ?? undefined}
+ originalValue={originalName}
+ canEdit={canEditName}
+ onCommit={saveNameIfChanged}
+ class="hidden sm:block"
+ />
+ <EditableName
+ bind:value={$inputs.name.value}
+ bind:ref={nameInputRef}
+ variant="block"
+ error={$inputs.name.error ?? undefined}
+ originalValue={originalName}
+ canEdit={canEditName}
+ onCommit={saveNameIfChanged}
+ class="block sm:hidden"
+ />
+ {#if project.status}
+ <StatusBadge variant={getStatusVariant(project.status)} text={capitalizeFirstLetter(project.status)} />
+ {/if}
</div>
+ {#if project.createdAt}
+ <p class="text-muted-foreground mt-0.5 hidden text-xs sm:block">
+ {m.common_created()}: {new Date(project.createdAt ?? '').toLocaleDateString()}
+ </p>
+ {/if}
+ {/snippet}
- <div class="min-h-0 flex-1 overflow-hidden">
- <div class="h-full px-4 py-4">
- <Tabs.Content value="services" class="h-full min-h-0">
- <ServicesGrid services={project.services} />
- </Tabs.Content>
+ {#snippet headerActions()}
+ <div class="flex items-center gap-2">
+ {#if hasChanges}
+ <ArcaneButton
+ action="save"
+ loading={isLoading.saving}
+ onclick={handleSaveChanges}
+ disabled={!hasChanges}
+ customLabel={m.common_save()}
+ loadingLabel={m.common_saving()}
+ />
+ {/if}
+ <ActionButtons
+ id={project.id}
+ type="project"
+ itemState={project.status}
+ bind:startLoading={isLoading.deploying}
+ bind:stopLoading={isLoading.stopping}
+ bind:restartLoading={isLoading.restarting}
+ bind:removeLoading={isLoading.removing}
+ bind:redeployLoading={isLoading.redeploying}
+ onActionComplete={() => invalidateAll()}
+ />
+ </div>
+ {/snippet}
- <Tabs.Content value="compose" class="h-full min-h-0">
- <div class="grid h-full min-h-0 grid-cols-1 gap-4 lg:grid-cols-3" style="grid-template-rows: 1fr;">
- <div class="h-full min-h-0 lg:col-span-2">
- <CodePanel
- bind:open={composeOpen}
- title={m.compose_compose_file_title()}
- language="yaml"
- bind:value={$inputs.composeContent.value}
- placeholder={m.compose_compose_placeholder()}
- error={$inputs.composeContent.error ?? undefined}
- />
- </div>
+ {#snippet tabContent()}
+ <Tabs.Content value="services" class="h-full">
+ <ServicesGrid services={project.services} />
+ </Tabs.Content>
- <div class="h-full min-h-0 lg:col-span-1">
- <CodePanel
- bind:open={envOpen}
- title={m.compose_env_title()}
- language="env"
- bind:value={$inputs.envContent.value}
- placeholder={m.compose_env_placeholder()}
- error={$inputs.envContent.error ?? undefined}
- />
- </div>
- </div>
- </Tabs.Content>
+ <Tabs.Content value="compose" class="h-full">
+ <div class="grid h-full grid-cols-1 gap-4 lg:grid-cols-5" style="grid-template-rows: 1fr;">
+ <div class="h-full lg:col-span-3">
+ <CodePanel
+ bind:open={composeOpen}
+ title={m.compose_compose_file_title()}
+ language="yaml"
+ bind:value={$inputs.composeContent.value}
+ placeholder={m.compose_compose_placeholder()}
+ error={$inputs.composeContent.error ?? undefined}
+ />
+ </div>
- <Tabs.Content value="logs" class="h-full min-h-0">
- {#if project.status == 'running'}
- <div class="h-full min-h-0">
- <StackLogsPanel projectId={project.id} bind:autoScroll={autoScrollStackLogs} />
- </div>
- {:else}
- <div class="text-muted-foreground py-12 text-center">{m.compose_logs_title()} Unavailable</div>
- {/if}
- </Tabs.Content>
- </div>
- </div>
- </Tabs.Root>
- {:else if !data.error}
- <div class="flex min-h-screen items-center justify-center">
- <div class="text-center">
- <div class="bg-muted/50 mb-6 inline-flex rounded-full p-6">
- <FileStackIcon class="text-muted-foreground size-10" />
+ <div class="h-full lg:col-span-2">
+ <CodePanel
+ bind:open={envOpen}
+ title={m.compose_env_title()}
+ language="env"
+ bind:value={$inputs.envContent.value}
+ placeholder={m.compose_env_placeholder()}
+ error={$inputs.envContent.error ?? undefined}
+ />
+ </div>
</div>
- <h2 class="mb-3 text-2xl font-medium">{m.compose_not_found_title()}</h2>
- <p class="text-muted-foreground mb-8 max-w-md text-center">
- {m.compose_not_found_description()}
- </p>
- <Button variant="outline" href="/projects">
- <ArrowLeftIcon class="mr-2 size-4" />
- {m.compose_back_to_projects()}
- </Button>
+ </Tabs.Content>
+
+ <Tabs.Content value="logs" class="h-full">
+ {#if project.status == 'running'}
+ <div class="h-full">
+ <ProjectsLogsPanel projectId={project.id} bind:autoScroll={autoScrollStackLogs} />
+ </div>
+ {:else}
+ <div class="text-muted-foreground py-12 text-center">{m.compose_logs_title()} Unavailable</div>
+ {/if}
+ </Tabs.Content>
+ {/snippet}
+ </TabbedPageLayout>
+{:else if !data.error}
+ <div class="flex min-h-screen items-center justify-center">
+ <div class="text-center">
+ <div class="bg-muted/50 mb-6 inline-flex rounded-full p-6">
+ <FileStackIcon class="text-muted-foreground size-10" />
</div>
+ <h2 class="mb-3 text-2xl font-medium">{m.compose_not_found_title()}</h2>
+ <p class="text-muted-foreground mb-8 max-w-md text-center">
+ {m.compose_not_found_description()}
+ </p>
+ <Button variant="outline" href="/projects">
+ <ArrowLeftIcon class="mr-2 size-4" />
+ {m.compose_back_to_projects()}
+ </Button>
</div>
- {/if}
-
- <Tooltip.Provider />
-</div>
-
-<style>
- :global(.tab-body) {
- height: calc(100dvh - 152px);
- }
-</style>
+ </div>
+{/if}
diff --git a/frontend/src/routes/projects/components/CodePanel.svelte b/frontend/src/routes/projects/components/CodePanel.svelte
index dce6989d9..a216e31a3 100644
--- a/frontend/src/routes/projects/components/CodePanel.svelte
+++ b/frontend/src/routes/projects/components/CodePanel.svelte
@@ -20,11 +20,11 @@
} = $props();
</script>
-<div class="flex items-center justify-between px-4 py-2">
- <h3 class="text-sm font-semibold">{title}</h3>
+<div class="flex items-center justify-between py-2">
+ <h3 class="text-xs font-semibold sm:text-sm">{title}</h3>
</div>
-<div class="h-[560px] w-full overflow-hidden px-4 pb-4">
- <CodeEditor bind:value {language} {placeholder} />
+<div class="min-h-[560px] w-full overflow-hidden pb-4 [&_.cm-content]:text-xs sm:[&_.cm-content]:text-sm">
+ <CodeEditor bind:value {language} {placeholder} height="full" />
{#if error}
<p class="text-destructive mt-2 text-xs">{error}</p>
{/if}
diff --git a/frontend/src/routes/projects/components/EditableName.svelte b/frontend/src/routes/projects/components/EditableName.svelte
index 5bae89eee..80bded483 100644
--- a/frontend/src/routes/projects/components/EditableName.svelte
+++ b/frontend/src/routes/projects/components/EditableName.svelte
@@ -6,21 +6,26 @@
import PencilIcon from '@lucide/svelte/icons/pencil';
import { tick } from 'svelte';
import { m } from '$lib/paraglide/messages';
+ import { cn } from '$lib/utils';
let {
value = $bindable(),
ref = $bindable(),
+ variant = 'block',
error,
originalValue,
canEdit = true,
- onCommit
+ onCommit,
+ class: className = ''
}: {
value: string;
ref: HTMLInputElement | null;
+ variant?: 'block' | 'inline';
error?: string;
originalValue: string;
canEdit?: boolean;
onCommit?: () => void;
+ class?: string;
} = $props();
let isEditing = $state(false);
@@ -33,64 +38,122 @@
}
</script>
-<div class="group flex items-center gap-1">
+<div class={cn('group w-full', className)}>
{#if isEditing}
- <Input
- bind:ref
- bind:value
- class="h-8 max-w-[360px] px-2 text-lg font-semibold {error ? 'border-destructive' : ''}"
- autofocus
- onkeydown={(e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
+ {#if variant === 'block'}
+ <Input
+ bind:ref
+ bind:value
+ class="h-8 min-w-[120px] max-w-[280px] px-2 text-left text-base font-semibold {error ? 'border-destructive' : ''}"
+ autofocus
+ onkeydown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ onCommit?.();
+ isEditing = false;
+ }
+ if (e.key === 'Escape') {
+ value = originalValue;
+ isEditing = false;
+ }
+ }}
+ onblur={() => {
+ if (!isEditing) return;
onCommit?.();
isEditing = false;
- }
- if (e.key === 'Escape') {
- value = originalValue;
+ }}
+ disabled={!canEdit}
+ />
+ {:else}
+ <Input
+ bind:ref
+ bind:value
+ class="h-8 max-w-[360px] px-2 text-lg font-semibold {error ? 'border-destructive' : ''}"
+ autofocus
+ onkeydown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ onCommit?.();
+ isEditing = false;
+ }
+ if (e.key === 'Escape') {
+ value = originalValue;
+ isEditing = false;
+ }
+ }}
+ onblur={() => {
+ if (!isEditing) return;
+ onCommit?.();
isEditing = false;
- }
- }}
- onblur={() => {
- if (!isEditing) return;
- onCommit?.();
- isEditing = false;
- }}
- disabled={!canEdit}
- />
- {:else}
- <h1 class="m-0 max-w-[360px]">
+ }}
+ disabled={!canEdit}
+ />
+ {/if}
+ {:else if variant === 'block'}
+ <h1 class="m-0 w-full">
<button
type="button"
- class="w-full truncate bg-transparent px-0 py-0 text-left text-lg font-semibold leading-none"
- title={value}
+ class="hover:bg-muted/50 focus:ring-ring min-h-[32px] w-full rounded bg-transparent px-1 py-1 text-center text-base font-semibold transition-colors focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
+ title={canEdit ? `${value} (tap to edit)` : value}
onclick={beginEdit}
disabled={!canEdit}
>
- {value}
+ <span class="block truncate">{value}</span>
</button>
</h1>
+
{#if canEdit}
- <Button
- variant="ghost"
- size="icon"
- class="size-6 opacity-0 transition-opacity group-hover:opacity-100"
- aria-label="Edit name"
- title="Edit name"
- onclick={beginEdit}
- >
- <PencilIcon class="size-3.5" />
- </Button>
+ <div class="flex items-center justify-center">
+ <span class="text-muted-foreground flex items-center gap-0.5 text-[8px] whitespace-nowrap opacity-30">
+ <PencilIcon class="size-1.5" />
+ {m.tap_to_edit()}
+ </span>
+ </div>
{:else}
- <Tooltip.Root>
- <Tooltip.Trigger>
- <span class="text-muted-foreground inline-flex cursor-help items-center leading-none">
- <InfoIcon class="relative top-0.5 size-4 shrink-0" />
- </span>
- </Tooltip.Trigger>
- <Tooltip.Content>{m.compose_name_change_not_allowed()}</Tooltip.Content>
- </Tooltip.Root>
+ <div class="flex items-center justify-center">
+ <span class="text-muted-foreground inline-flex cursor-help items-center gap-0.5 text-[8px] whitespace-nowrap opacity-40">
+ <InfoIcon class="size-1.5" />
+ {m.cannot_edit()}
+ </span>
+ </div>
{/if}
+ {:else}
+ <div class="flex items-center gap-1">
+ <h1 class="m-0 max-w-[360px]">
+ <button
+ type="button"
+ class="w-full truncate bg-transparent px-0 py-0 text-left text-lg leading-none font-semibold"
+ title={value}
+ onclick={beginEdit}
+ disabled={!canEdit}
+ >
+ {value}
+ </button>
+ </h1>
+ {#if canEdit}
+ <Button
+ variant="ghost"
+ size="icon"
+ class="size-6 opacity-0 transition-opacity group-hover:opacity-100"
+ aria-label="Edit name"
+ title="Edit name"
+ onclick={beginEdit}
+ >
+ <PencilIcon class="size-3.5" />
+ </Button>
+ {:else}
+ <Tooltip.Provider>
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+ <span class="text-muted-foreground inline-flex cursor-help items-center leading-none">
+ <InfoIcon class="relative top-0.5 size-4 shrink-0" />
+ </span>
+ </Tooltip.Trigger>
+ <Tooltip.Content>{m.compose_name_change_not_allowed()}</Tooltip.Content>
+ </Tooltip.Root>
+ </Tooltip.Provider>
+ {/if}
+ </div>
{/if}
</div>
diff --git a/frontend/src/routes/projects/components/ProjectLogsPanel.svelte b/frontend/src/routes/projects/components/ProjectLogsPanel.svelte
index 29ee7a3c2..ac5c65644 100644
--- a/frontend/src/routes/projects/components/ProjectLogsPanel.svelte
+++ b/frontend/src/routes/projects/components/ProjectLogsPanel.svelte
@@ -27,10 +27,62 @@
function onToggleAutoScroll() {}
</script>
-<div class="mb-3 flex items-center justify-between">
- <div class="flex items-center gap-2">
+<div class="mb-3 flex flex-col gap-3 sm:hidden">
+ <div class="flex items-center justify-between">
+ <div class="flex items-center gap-2">
+ <TerminalIcon class="size-5" />
+ <h2 class="text-lg font-semibold">{m.compose_logs_title()}</h2>
+ </div>
+ {#if isStreaming}
+ <div class="flex items-center gap-2">
+ <div class="size-2 animate-pulse rounded-full bg-green-500"></div>
+ <span class="text-sm font-medium text-green-600">{m.common_live()}</span>
+ </div>
+ {/if}
+ </div>
+
+ <div class="flex items-center justify-between gap-3">
+ <label class="flex items-center gap-2 text-sm">
+ <input type="checkbox" bind:checked={autoScroll} class="size-4" />
+ {m.common_autoscroll()}
+ </label>
+ <div class="flex items-center gap-2">
+ <Button variant="outline" size="sm" onclick={() => viewer?.clearLogs()}>{m.common_clear()}</Button>
+ {#if isStreaming}
+ <Button variant="outline" size="sm" onclick={() => viewer?.stopLogStream()}>
+ {m.common_stop()}
+ </Button>
+ {:else}
+ <Button variant="outline" size="sm" onclick={() => viewer?.startLogStream()} disabled={!projectId}>
+ {m.common_start()}
+ </Button>
+ {/if}
+ <Button
+ variant="outline"
+ size="sm"
+ onclick={() => {
+ viewer?.stopLogStream();
+ viewer?.startLogStream();
+ }}
+ aria-label="Refresh logs"
+ title="Refresh"
+ >
+ <RefreshCwIcon class="size-4" />
+ </Button>
+ </div>
+ </div>
+</div>
+
+<div class="mb-3 hidden items-center justify-between sm:flex">
+ <div class="flex items-center gap-3">
<TerminalIcon class="size-5" />
<h2 class="text-xl font-semibold">{m.compose_logs_title()}</h2>
+ {#if isStreaming}
+ <div class="flex items-center gap-2">
+ <div class="size-2 animate-pulse rounded-full bg-green-500"></div>
+ <span class="text-sm font-medium text-green-600">{m.common_live()}</span>
+ </div>
+ {/if}
</div>
<div class="flex items-center gap-3">
<label class="flex items-center gap-2">
@@ -39,10 +91,6 @@
</label>
<Button variant="outline" size="sm" onclick={() => viewer?.clearLogs()}>{m.common_clear()}</Button>
{#if isStreaming}
- <div class="flex items-center gap-2">
- <div class="size-2 animate-pulse rounded-full bg-green-500"></div>
- <span class="text-sm font-medium text-green-600">{m.common_live()}</span>
- </div>
<Button variant="outline" size="sm" onclick={() => viewer?.stopLogStream()}>{m.common_stop()}</Button>
{:else}
<Button variant="outline" size="sm" onclick={() => viewer?.startLogStream()} disabled={!projectId}>
@@ -74,7 +122,7 @@
type="project"
maxLines={500}
showTimestamps={true}
- height="600px"
+ height="calc(100vh - 280px)"
{onStart}
{onStop}
{onClear}
diff --git a/frontend/src/routes/settings/docker/+page.svelte b/frontend/src/routes/settings/docker/+page.svelte
index f1329be5c..f88b7adc2 100644
--- a/frontend/src/routes/settings/docker/+page.svelte
+++ b/frontend/src/routes/settings/docker/+page.svelte
@@ -1,12 +1,23 @@
<script lang="ts">
+ import ZapIcon from '@lucide/svelte/icons/zap';
+ import * as Alert from '$lib/components/ui/alert/index.js';
+ import { toast } from 'svelte-sonner';
import type { Settings } from '$lib/types/settings.type';
+ import { z } from 'zod/v4';
+ import { getContext, onMount } from 'svelte';
+ import { createForm } from '$lib/utils/form.utils';
+ import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';
+ import * as Card from '$lib/components/ui/card';
+ import SelectWithLabel from '$lib/components/form/select-with-label.svelte';
+ import { m } from '$lib/paraglide/messages';
+ import ActivityIcon from '@lucide/svelte/icons/activity';
+ import RefreshCwIcon from '@lucide/svelte/icons/refresh-cw';
+ import TrashIcon from '@lucide/svelte/icons/trash';
+ import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';
import settingsStore from '$lib/stores/config-store';
- import UiConfigDisabledTag from '$lib/components/ui-config-disabled-tag.svelte';
- import DockerSettingsForm from '../forms/docker-settings-form.svelte';
import BoxesIcon from '@lucide/svelte/icons/boxes';
- import { m } from '$lib/paraglide/messages';
- import { getContext } from 'svelte';
import { settingsService } from '$lib/services/settings-service';
+ import { SettingsPageLayout } from '$lib/layouts/index.js';
let { data } = $props();
let currentSettings = $state<Settings>(data.settings);
@@ -14,22 +25,105 @@
let isLoading = $state(false);
const isReadOnly = $derived.by(() => $settingsStore.uiConfigDisabled);
-
const formState = getContext('settingsFormState') as any;
+ const formSchema = z.object({
+ pollingEnabled: z.boolean(),
+ pollingInterval: z.number().int().min(5).max(10080),
+ autoUpdate: z.boolean(),
+ autoUpdateInterval: z.number().int(),
+ dockerPruneMode: z.enum(['all', 'dangling'])
+ });
+
+ let pruneMode = $derived(currentSettings.dockerPruneMode);
+
+ type PollingIntervalMode = 'hourly' | 'daily' | 'weekly' | 'custom';
+
+ const imagePollingOptions: Array<{
+ value: PollingIntervalMode;
+ label: string;
+ description: string;
+ minutes?: number;
+ }> = [
+ {
+ value: 'hourly',
+ minutes: 60,
+ label: m.hourly(),
+ description: m.polling_hourly_description()
+ },
+ {
+ value: 'daily',
+ minutes: 1440,
+ label: m.daily(),
+ description: m.polling_daily_description()
+ },
+ {
+ value: 'weekly',
+ minutes: 10080,
+ label: m.weekly(),
+ description: m.polling_weekly_description()
+ },
+ {
+ value: 'custom',
+ label: m.custom(),
+ description: m.use_custom_polling_value()
+ }
+ ];
+
+ const presetToMinutes = Object.fromEntries(
+ imagePollingOptions.filter((o) => o.value !== 'custom').map((o) => [o.value, o.minutes!])
+ ) as Record<Exclude<PollingIntervalMode, 'custom'>, number>;
+
+ let pollingIntervalMode = $state<PollingIntervalMode>(
+ imagePollingOptions.find((o) => o.minutes === currentSettings.pollingInterval)?.value ?? 'custom'
+ );
+
+ const pruneModeOptions = [
+ {
+ value: 'all',
+ label: m.docker_prune_all(),
+ description: m.docker_prune_all_description()
+ },
+ {
+ value: 'dangling',
+ label: m.docker_prune_dangling(),
+ description: m.docker_prune_dangling_description()
+ }
+ ];
+
+ const pruneModeDescription = $derived(
+ pruneModeOptions.find((o) => o.value === pruneMode)?.description ?? m.docker_prune_mode_description()
+ );
+
+ let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, currentSettings));
+
+ const formHasChanges = $derived.by(
+ () =>
+ $formInputs.pollingEnabled.value !== currentSettings.pollingEnabled ||
+ $formInputs.pollingInterval.value !== currentSettings.pollingInterval ||
+ $formInputs.autoUpdate.value !== currentSettings.autoUpdate ||
+ $formInputs.autoUpdateInterval.value != currentSettings.autoUpdateInterval ||
+ $formInputs.dockerPruneMode.value != currentSettings.dockerPruneMode
+ );
$effect(() => {
+ hasChanges = formHasChanges;
if (formState) {
formState.hasChanges = hasChanges;
formState.isLoading = isLoading;
}
});
+ // Keep form value in sync with preset selection unless "custom"
+ $effect(() => {
+ if (pollingIntervalMode !== 'custom') {
+ $formInputs.pollingInterval.value = presetToMinutes[pollingIntervalMode];
+ }
+ });
+
async function updateSettingsConfig(updatedSettings: Partial<Settings>) {
try {
await settingsService.updateSettings(updatedSettings as any);
-
currentSettings = { ...currentSettings, ...updatedSettings };
-
settingsStore.set(currentSettings);
settingsStore.reload();
} catch (error) {
@@ -37,35 +131,171 @@
throw error;
}
}
+
+ async function onSubmit() {
+ const formData = form.validate();
+ if (!formData) {
+ toast.error('Please check the form for errors');
+ return;
+ }
+ isLoading = true;
+
+ await updateSettingsConfig(formData)
+ .then(() => toast.success(m.general_settings_saved()))
+ .catch((error) => {
+ console.error('Failed to save settings:', error);
+ toast.error('Failed to save settings. Please try again.');
+ })
+ .finally(() => (isLoading = false));
+ }
+
+ function resetForm() {
+ $formInputs.pollingEnabled.value = currentSettings.pollingEnabled;
+ $formInputs.pollingInterval.value = currentSettings.pollingInterval;
+ $formInputs.autoUpdate.value = currentSettings.autoUpdate;
+ $formInputs.autoUpdateInterval.value = currentSettings.autoUpdateInterval;
+ $formInputs.dockerPruneMode.value = currentSettings.dockerPruneMode;
+ }
+
+ onMount(() => {
+ if (formState) {
+ formState.saveFunction = onSubmit;
+ formState.resetFunction = resetForm;
+ }
+ });
</script>
-<div class="px-4 py-4 sm:px-6 sm:py-6 lg:px-8">
- <div
- class="from-background/60 via-background/40 to-background/60 relative overflow-hidden rounded-xl border bg-gradient-to-br p-4 shadow-sm sm:p-6"
- >
- <div class="bg-primary/10 pointer-events-none absolute -right-10 -top-10 size-40 rounded-full blur-3xl"></div>
- <div class="bg-muted/40 pointer-events-none absolute -bottom-10 -left-10 size-40 rounded-full blur-3xl"></div>
- <div class="relative flex items-start gap-3 sm:gap-4">
- <div
- class="bg-primary/10 text-primary ring-primary/20 flex size-8 shrink-0 items-center justify-center rounded-lg ring-1 sm:size-10"
- >
- <BoxesIcon class="size-4 sm:size-5" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="flex items-start justify-between gap-3">
- <h1 class="settings-title min-w-0 text-xl sm:text-3xl">{m.docker_title()}</h1>
- {#if isReadOnly}
- <div class="shrink-0">
- <UiConfigDisabledTag />
+<SettingsPageLayout
+ title={m.docker_title()}
+ description={m.docker_description()}
+ icon={BoxesIcon}
+ pageType="form"
+ showReadOnlyTag={isReadOnly}
+>
+ {#snippet mainContent()}
+ <fieldset disabled={isReadOnly} class="relative">
+ <div class="space-y-4 sm:space-y-6">
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <ActivityIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">Image Polling</Card.Title>
+ <Card.Description class="text-xs">Configure automatic image update checking</Card.Description>
+ </div>
</div>
- {/if}
- </div>
- <p class="text-muted-foreground mt-1 text-sm sm:text-base">{m.docker_description()}</p>
- </div>
- </div>
- </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-4 sm:px-6">
+ <div class="space-y-3">
+ <SwitchWithLabel
+ id="pollingEnabled"
+ label={m.docker_enable_polling_label()}
+ description={m.docker_enable_polling_description()}
+ bind:checked={$formInputs.pollingEnabled.value}
+ />
+
+ {#if $formInputs.pollingEnabled.value}
+ <div class="border-primary/20 space-y-3 border-l-2 pl-3">
+ <SelectWithLabel
+ id="pollingIntervalMode"
+ name="pollingIntervalMode"
+ bind:value={pollingIntervalMode}
+ label={m.docker_polling_interval_label()}
+ placeholder="Select interval"
+ options={imagePollingOptions.map(({ value, label, description }) => ({ value, label, description }))}
+ />
+
+ {#if pollingIntervalMode === 'custom'}
+ <TextInputWithLabel
+ bind:value={$formInputs.pollingInterval.value}
+ label={m.custom_polling_interval()}
+ placeholder={m.docker_polling_interval_placeholder()}
+ helpText={m.docker_polling_interval_description()}
+ type="number"
+ />
+ {/if}
+
+ {#if $formInputs.pollingInterval.value < 30}
+ <Alert.Root variant="warning">
+ <ZapIcon class="size-4" />
+ <Alert.Title>{m.docker_rate_limit_warning_title()}</Alert.Title>
+ <Alert.Description>{m.docker_rate_limit_warning_description()}</Alert.Description>
+ </Alert.Root>
+ {/if}
+ </div>
+ {/if}
+ </div>
+ </Card.Content>
+ </Card.Root>
+
+ {#if $formInputs.pollingEnabled.value}
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <RefreshCwIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">Auto Updates</Card.Title>
+ <Card.Description class="text-xs"
+ >Automatically update containers when new images are available</Card.Description
+ >
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-4 sm:px-6">
+ <div class="space-y-3">
+ <SwitchWithLabel
+ id="autoUpdateSwitch"
+ label={m.docker_auto_update_label()}
+ description={m.docker_auto_update_description()}
+ bind:checked={$formInputs.autoUpdate.value}
+ />
+
+ {#if $formInputs.autoUpdate.value}
+ <div class="border-primary/20 border-l-2 pl-3">
+ <TextInputWithLabel
+ bind:value={$formInputs.autoUpdateInterval.value}
+ label={m.docker_auto_update_interval_label()}
+ placeholder={m.docker_auto_update_interval_placeholder()}
+ helpText={m.docker_auto_update_interval_description()}
+ type="number"
+ />
+ </div>
+ {/if}
+ </div>
+ </Card.Content>
+ </Card.Root>
+ {/if}
- <div class="mt-6 sm:mt-8">
- <DockerSettingsForm settings={currentSettings} callback={updateSettingsConfig} bind:hasChanges bind:isLoading />
- </div>
-</div>
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <TrashIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">Cleanup Settings</Card.Title>
+ <Card.Description class="text-xs">Configure how Docker images are pruned</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-4 sm:px-6">
+ <SelectWithLabel
+ id="dockerPruneMode"
+ name="pruneMode"
+ bind:value={$formInputs.dockerPruneMode.value}
+ label={m.docker_prune_action_label()}
+ description={pruneModeDescription}
+ placeholder={m.docker_prune_placeholder()}
+ options={pruneModeOptions}
+ onValueChange={(v) => (pruneMode = v as 'all' | 'dangling')}
+ />
+ </Card.Content>
+ </Card.Root>
+ </div>
+ </fieldset>
+ {/snippet}
+</SettingsPageLayout>
diff --git a/frontend/src/routes/settings/forms/docker-settings-form.svelte b/frontend/src/routes/settings/forms/docker-settings-form.svelte
deleted file mode 100644
index 61e033f81..000000000
--- a/frontend/src/routes/settings/forms/docker-settings-form.svelte
+++ /dev/null
@@ -1,280 +0,0 @@
-<script lang="ts">
- import ZapIcon from '@lucide/svelte/icons/zap';
- import * as Alert from '$lib/components/ui/alert/index.js';
- import { toast } from 'svelte-sonner';
- import type { Settings } from '$lib/types/settings.type';
- import { z } from 'zod/v4';
- import { getContext, onMount } from 'svelte';
- import { createForm } from '$lib/utils/form.utils';
- import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';
- import * as Card from '$lib/components/ui/card';
- import SelectWithLabel from '$lib/components/form/select-with-label.svelte';
- import { m } from '$lib/paraglide/messages';
- import ActivityIcon from '@lucide/svelte/icons/activity';
- import RefreshCwIcon from '@lucide/svelte/icons/refresh-cw';
- import TrashIcon from '@lucide/svelte/icons/trash';
- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';
- import settingsStore from '$lib/stores/config-store';
-
- let {
- callback,
- settings,
- hasChanges = $bindable(),
- isLoading = $bindable(false)
- }: {
- settings: Settings;
- callback: (appConfig: Partial<Settings>) => Promise<void>;
- hasChanges: boolean;
- isLoading: boolean;
- } = $props();
-
- let pruneMode = $state(settings.dockerPruneMode);
- const uiConfigDisabled = $state($settingsStore.uiConfigDisabled);
-
- type PollingIntervalMode = 'hourly' | 'daily' | 'weekly' | 'custom';
-
- const imagePollingOptions: Array<{
- value: PollingIntervalMode;
- label: string;
- description: string;
- minutes?: number;
- }> = [
- {
- value: 'hourly',
- minutes: 60,
- label: m.hourly(),
- description: m.polling_hourly_description()
- },
- {
- value: 'daily',
- minutes: 1440,
- label: m.daily(),
- description: m.polling_daily_description()
- },
- {
- value: 'weekly',
- minutes: 10080,
- label: m.weekly(),
- description: m.polling_weekly_description()
- },
- {
- value: 'custom',
- label: m.custom(),
- description: m.use_custom_polling_value()
- }
- ];
-
- const presetToMinutes = Object.fromEntries(
- imagePollingOptions.filter((o) => o.value !== 'custom').map((o) => [o.value, o.minutes!])
- ) as Record<Exclude<PollingIntervalMode, 'custom'>, number>;
-
- let pollingIntervalMode = $state<PollingIntervalMode>(
- imagePollingOptions.find((o) => o.minutes === settings.pollingInterval)?.value ?? 'custom'
- );
-
- const pruneModeOptions = [
- {
- value: 'all',
- label: m.docker_prune_all(),
- description: m.docker_prune_all_description()
- },
- {
- value: 'dangling',
- label: m.docker_prune_dangling(),
- description: m.docker_prune_dangling_description()
- }
- ];
-
- const pruneModeDescription = $derived(
- pruneModeOptions.find((o) => o.value === pruneMode)?.description ?? m.docker_prune_mode_description()
- );
-
- const formSchema = z.object({
- pollingEnabled: z.boolean(),
- pollingInterval: z.number().int().min(5).max(10080),
- autoUpdate: z.boolean(),
- autoUpdateInterval: z.number().int(),
- dockerPruneMode: z.enum(['all', 'dangling'])
- });
-
- let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, settings));
-
- const formHasChanges = $derived.by(
- () =>
- $formInputs.pollingEnabled.value !== settings.pollingEnabled ||
- $formInputs.pollingInterval.value !== settings.pollingInterval ||
- $formInputs.autoUpdate.value !== settings.autoUpdate ||
- $formInputs.autoUpdateInterval.value != settings.autoUpdateInterval ||
- $formInputs.dockerPruneMode.value != settings.dockerPruneMode
- );
-
- $effect(() => {
- hasChanges = formHasChanges;
- });
-
- // Keep form value in sync with preset selection unless "custom"
- $effect(() => {
- if (pollingIntervalMode !== 'custom') {
- $formInputs.pollingInterval.value = presetToMinutes[pollingIntervalMode];
- }
- });
-
- async function onSubmit() {
- const data = form.validate();
- if (!data) {
- toast.error('Please check the form for errors');
- return;
- }
- isLoading = true;
-
- await callback(data)
- .then(() => toast.success(m.general_settings_saved()))
- .catch((error) => {
- console.error('Failed to save settings:', error);
- toast.error('Failed to save settings. Please try again.');
- })
- .finally(() => (isLoading = false));
- }
-
- function resetForm() {
- $formInputs.pollingEnabled.value = settings.pollingEnabled;
- $formInputs.pollingInterval.value = settings.pollingInterval;
- $formInputs.autoUpdate.value = settings.autoUpdate;
- $formInputs.autoUpdateInterval.value = settings.autoUpdateInterval;
- $formInputs.dockerPruneMode.value = settings.dockerPruneMode;
- }
-
- onMount(() => {
- const formState = getContext('settingsFormState') as any;
- if (formState) {
- formState.saveFunction = onSubmit;
- formState.resetFunction = resetForm;
- }
- });
-</script>
-
-<fieldset disabled={uiConfigDisabled} class="relative">
- <div class="space-y-4 sm:space-y-6">
- <!-- Image Polling Card -->
- <Card.Root class="pt-0 overflow-hidden">
- <Card.Header class="!py-4 bg-muted/20 border-b">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <ActivityIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">Image Polling</Card.Title>
- <Card.Description class="text-xs">Configure automatic image update checking</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-4 sm:px-6">
- <div class="space-y-3">
- <SwitchWithLabel
- id="pollingEnabled"
- label={m.docker_enable_polling_label()}
- description={m.docker_enable_polling_description()}
- bind:checked={$formInputs.pollingEnabled.value}
- />
-
- {#if $formInputs.pollingEnabled.value}
- <div class="border-primary/20 space-y-3 border-l-2 pl-3">
- <SelectWithLabel
- id="pollingIntervalMode"
- name="pollingIntervalMode"
- bind:value={pollingIntervalMode}
- label={m.docker_polling_interval_label()}
- placeholder="Select interval"
- options={imagePollingOptions.map(({ value, label, description }) => ({ value, label, description }))}
- />
-
- {#if pollingIntervalMode === 'custom'}
- <TextInputWithLabel
- bind:value={$formInputs.pollingInterval.value}
- label={m.custom_polling_interval()}
- placeholder={m.docker_polling_interval_placeholder()}
- helpText={m.docker_polling_interval_description()}
- type="number"
- />
- {/if}
-
- {#if $formInputs.pollingInterval.value < 30}
- <Alert.Root variant="warning">
- <ZapIcon class="size-4" />
- <Alert.Title>{m.docker_rate_limit_warning_title()}</Alert.Title>
- <Alert.Description>{m.docker_rate_limit_warning_description()}</Alert.Description>
- </Alert.Root>
- {/if}
- </div>
- {/if}
- </div>
- </Card.Content>
- </Card.Root>
-
- {#if $formInputs.pollingEnabled.value}
- <!-- Auto Update Card -->
- <Card.Root class="pt-0 overflow-hidden">
- <Card.Header class="!py-4 bg-muted/20 border-b">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <RefreshCwIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">Auto Updates</Card.Title>
- <Card.Description class="text-xs">Automatically update containers when new images are available</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-4 sm:px-6">
- <div class="space-y-3">
- <SwitchWithLabel
- id="autoUpdateSwitch"
- label={m.docker_auto_update_label()}
- description={m.docker_auto_update_description()}
- bind:checked={$formInputs.autoUpdate.value}
- />
-
- {#if $formInputs.autoUpdate.value}
- <div class="border-primary/20 border-l-2 pl-3">
- <TextInputWithLabel
- bind:value={$formInputs.autoUpdateInterval.value}
- label={m.docker_auto_update_interval_label()}
- placeholder={m.docker_auto_update_interval_placeholder()}
- helpText={m.docker_auto_update_interval_description()}
- type="number"
- />
- </div>
- {/if}
- </div>
- </Card.Content>
- </Card.Root>
- {/if}
-
- <!-- Cleanup Settings Card -->
- <Card.Root class="pt-0 overflow-hidden">
- <Card.Header class="!py-4 bg-muted/20 border-b">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <TrashIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">Cleanup Settings</Card.Title>
- <Card.Description class="text-xs">Configure how Docker images are pruned</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-4 sm:px-6">
- <SelectWithLabel
- id="dockerPruneMode"
- name="pruneMode"
- bind:value={$formInputs.dockerPruneMode.value}
- label={m.docker_prune_action_label()}
- description={pruneModeDescription}
- placeholder={m.docker_prune_placeholder()}
- options={pruneModeOptions}
- onValueChange={(v) => (pruneMode = v as 'all' | 'dangling')}
- />
- </Card.Content>
- </Card.Root>
- </div>
-</fieldset>
diff --git a/frontend/src/routes/settings/forms/general-settings-form.svelte b/frontend/src/routes/settings/forms/general-settings-form.svelte
deleted file mode 100644
index 82feecb2d..000000000
--- a/frontend/src/routes/settings/forms/general-settings-form.svelte
+++ /dev/null
@@ -1,139 +0,0 @@
-<script lang="ts">
- import { z } from 'zod/v4';
- import { getContext, onMount } from 'svelte';
- import { createForm } from '$lib/utils/form.utils';
- import * as Card from '$lib/components/ui/card';
- import type { Settings } from '$lib/types/settings.type';
- import { toast } from 'svelte-sonner';
- import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';
- import { m } from '$lib/paraglide/messages';
- import FolderIcon from '@lucide/svelte/icons/folder';
- import UserIcon from '@lucide/svelte/icons/user';
- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';
- import settingsStore from '$lib/stores/config-store';
-
- let {
- settings,
- callback,
- hasChanges = $bindable(),
- isLoading = $bindable(false)
- }: {
- settings: Settings;
- callback: (appConfig: Partial<Settings>) => Promise<void>;
- hasChanges: boolean;
- isLoading: boolean;
- } = $props();
-
- const uiConfigDisabled = $state($settingsStore.uiConfigDisabled);
-
- const formSchema = z.object({
- projectsDirectory: z.string().min(1, m.general_projects_directory_required()),
- baseServerUrl: z.string().min(1, m.general_base_url_required()),
- enableGravatar: z.boolean()
- });
-
- let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, settings));
-
- const formHasChanges = $derived.by(
- () =>
- $formInputs.projectsDirectory.value !== settings.projectsDirectory ||
- $formInputs.baseServerUrl.value !== settings.baseServerUrl ||
- $formInputs.enableGravatar.value !== settings.enableGravatar
- );
-
- $effect(() => {
- hasChanges = formHasChanges;
- });
-
- async function onSubmit() {
- const data = form.validate();
- if (!data) {
- toast.error('Please check the form for errors');
- return;
- }
- isLoading = true;
-
- await callback(data)
- .then(() => toast.success(m.general_settings_saved()))
- .catch((error) => {
- console.error('Failed to save settings:', error);
- toast.error('Failed to save settings. Please try again.');
- })
- .finally(() => (isLoading = false));
- }
-
- function resetForm() {
- $formInputs.projectsDirectory.value = settings.projectsDirectory;
- $formInputs.baseServerUrl.value = settings.baseServerUrl;
- $formInputs.enableGravatar.value = settings.enableGravatar;
- }
-
- onMount(() => {
- const formState = getContext('settingsFormState') as any;
- if (formState) {
- formState.saveFunction = onSubmit;
- formState.resetFunction = resetForm;
- }
- });
-</script>
-
-<fieldset disabled={uiConfigDisabled} class="relative">
- <div class="space-y-4 sm:space-y-6">
- <!-- Projects Configuration Card -->
- <Card.Root class="pt-0 overflow-hidden">
- <Card.Header class="!py-4 bg-muted/20 border-b">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <FolderIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">{m.general_projects_heading()}</Card.Title>
- <Card.Description class="text-xs">{m.general_projects_description()}</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-4 sm:px-6">
- <div class="space-y-3">
- <TextInputWithLabel
- bind:value={$formInputs.projectsDirectory.value}
- label={m.general_projects_directory_label()}
- placeholder={m.general_projects_directory_placeholder()}
- helpText={m.general_projects_directory_help()}
- type="text"
- />
-
- <TextInputWithLabel
- bind:value={$formInputs.baseServerUrl.value}
- label={m.general_base_url_label()}
- placeholder={m.general_base_url_placeholder()}
- helpText={m.general_base_url_help()}
- type="text"
- />
- </div>
- </Card.Content>
- </Card.Root>
-
- <!-- User Preferences Card -->
- <Card.Root class="pt-0 overflow-hidden">
- <Card.Header class="!py-4 bg-muted/20 border-b">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <UserIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">{m.general_user_avatars_heading()}</Card.Title>
- <Card.Description class="text-xs">{m.general_user_avatars_description()}</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-4 sm:px-6">
- <SwitchWithLabel
- id="enableGravatar"
- label={m.general_enable_gravatar_label()}
- description={m.general_enable_gravatar_description()}
- bind:checked={$formInputs.enableGravatar.value}
- />
- </Card.Content>
- </Card.Root>
- </div>
-</fieldset>
diff --git a/frontend/src/routes/settings/forms/navigation-settings-form.svelte b/frontend/src/routes/settings/forms/navigation-settings-form.svelte
deleted file mode 100644
index abe48ab44..000000000
--- a/frontend/src/routes/settings/forms/navigation-settings-form.svelte
+++ /dev/null
@@ -1,226 +0,0 @@
-<script lang="ts">
- import { z } from 'zod/v4';
- import { getContext, onMount } from 'svelte';
- import { createForm } from '$lib/utils/form.utils';
- import * as Card from '$lib/components/ui/card';
- import type { Settings } from '$lib/types/settings.type';
- import { toast } from 'svelte-sonner';
- import EyeIcon from '@lucide/svelte/icons/eye';
- import MousePointerClickIcon from '@lucide/svelte/icons/mouse-pointer-click';
- import ScrollTextIcon from '@lucide/svelte/icons/scroll-text';
- import NavigationIcon from '@lucide/svelte/icons/navigation';
- import NavigationSettingControl from '$lib/components/navigation-setting-control.svelte';
- import NavigationModeSettingControl from '$lib/components/navigation-mode-setting-control.svelte';
- import settingsStore from '$lib/stores/config-store';
- import { m } from '$lib/paraglide/messages';
- import { navigationSettingsOverridesStore, resetNavigationVisibility } from '$lib/utils/navigation.utils';
-
- let {
- settings,
- callback,
- hasChanges = $bindable(),
- isLoading = $bindable(false)
- }: {
- settings: Settings;
- callback: (appConfig: Partial<Settings>) => Promise<void>;
- hasChanges: boolean;
- isLoading: boolean;
- } = $props();
-
- const uiConfigDisabled = $state($settingsStore.uiConfigDisabled);
-
- // Track local override state using the shared store
- let persistedState = $state(navigationSettingsOverridesStore.current);
-
- const formSchema = z.object({
- mobileNavigationMode: z.enum(['floating', 'docked']),
- mobileNavigationShowLabels: z.boolean(),
- mobileNavigationScrollToHide: z.boolean(),
- mobileNavigationTapToHide: z.boolean()
- });
-
- let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, settings));
-
- const formHasChanges = $derived.by(
- () =>
- $formInputs.mobileNavigationMode.value !== settings.mobileNavigationMode ||
- $formInputs.mobileNavigationShowLabels.value !== settings.mobileNavigationShowLabels ||
- $formInputs.mobileNavigationScrollToHide.value !== settings.mobileNavigationScrollToHide ||
- $formInputs.mobileNavigationTapToHide.value !== settings.mobileNavigationTapToHide
- );
-
- $effect(() => {
- hasChanges = formHasChanges;
- });
-
- function setLocalOverride(key: 'mode' | 'showLabels' | 'scrollToHide' | 'tapToHide', value: any) {
- const currentOverrides = navigationSettingsOverridesStore.current;
- navigationSettingsOverridesStore.current = {
- ...currentOverrides,
- [key]: value
- };
- persistedState = navigationSettingsOverridesStore.current;
-
- // Reset navigation bar visibility when behavior settings change
- if (key === 'scrollToHide' || key === 'tapToHide') {
- resetNavigationVisibility();
- }
- }
-
- function clearLocalOverride(key: 'mode' | 'showLabels' | 'scrollToHide' | 'tapToHide') {
- const currentOverrides = navigationSettingsOverridesStore.current;
- const newOverrides = { ...currentOverrides };
- delete newOverrides[key];
- navigationSettingsOverridesStore.current = newOverrides;
- persistedState = navigationSettingsOverridesStore.current;
-
- // Reset navigation bar visibility when behavior settings change
- if (key === 'scrollToHide' || key === 'tapToHide') {
- resetNavigationVisibility();
- }
-
- toast.success(`Local override cleared for ${key.replace(/([A-Z])/g, ' $1').toLowerCase()}`);
- }
-
- async function onSubmit() {
- const data = form.validate();
- if (!data) {
- toast.error('Please check the form for errors');
- return;
- }
- isLoading = true;
-
- // Check if behavior settings changed
- const behaviorChanged =
- data.mobileNavigationScrollToHide !== settings.mobileNavigationScrollToHide ||
- data.mobileNavigationTapToHide !== settings.mobileNavigationTapToHide;
-
- await callback(data)
- .then(() => {
- toast.success(m.navigation_settings_saved());
-
- // Reset navigation bar visibility if behavior settings changed
- if (behaviorChanged) {
- resetNavigationVisibility();
- }
- })
- .catch((error) => {
- console.error('Failed to save navigation settings:', error);
- toast.error('Failed to save navigation settings. Please try again.');
- })
- .finally(() => (isLoading = false));
- }
-
- function resetForm() {
- $formInputs.mobileNavigationMode.value = settings.mobileNavigationMode;
- $formInputs.mobileNavigationShowLabels.value = settings.mobileNavigationShowLabels;
- $formInputs.mobileNavigationScrollToHide.value = settings.mobileNavigationScrollToHide;
- $formInputs.mobileNavigationTapToHide.value = settings.mobileNavigationTapToHide;
- }
-
- onMount(() => {
- const formState = getContext('settingsFormState') as any;
- if (formState) {
- formState.saveFunction = onSubmit;
- formState.resetFunction = resetForm;
- }
- });
-</script>
-
-<div class="space-y-4 sm:space-y-6">
- <!-- Mobile Navigation Appearance Card -->
- <Card.Root class="overflow-hidden pt-0">
- <Card.Header class="bg-muted/20 border-b !py-4">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <NavigationIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">{m.navigation_mobile_appearance_title()}</Card.Title>
- <Card.Description class="text-xs">{m.navigation_mobile_appearance_description()}</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-3 sm:px-6 sm:py-4">
- <div class="grid grid-cols-1 gap-3 sm:gap-4 lg:grid-cols-[repeat(auto-fit,minmax(400px,1fr))]">
- <NavigationModeSettingControl
- id="mobileNavigationMode"
- label={m.navigation_mode_label()}
- description={m.navigation_mode_description()}
- icon={NavigationIcon}
- serverValue={$formInputs.mobileNavigationMode.value}
- localOverride={persistedState.mode}
- onServerChange={(value) => {
- $formInputs.mobileNavigationMode.value = value;
- }}
- onLocalOverride={(value) => setLocalOverride('mode', value)}
- onClearOverride={() => clearLocalOverride('mode')}
- serverDisabled={uiConfigDisabled}
- />
-
- <NavigationSettingControl
- id="mobileNavigationShowLabels"
- label={m.navigation_show_labels_label()}
- description={m.navigation_show_labels_description()}
- icon={EyeIcon}
- serverValue={$formInputs.mobileNavigationShowLabels.value}
- localOverride={persistedState.showLabels}
- onServerChange={(value) => {
- $formInputs.mobileNavigationShowLabels.value = value;
- }}
- onLocalOverride={(value) => setLocalOverride('showLabels', value)}
- onClearOverride={() => clearLocalOverride('showLabels')}
- serverDisabled={uiConfigDisabled}
- />
- </div>
- </Card.Content>
- </Card.Root>
-
- <!-- Mobile Navigation Behavior Card -->
- <Card.Root class="overflow-hidden pt-0">
- <Card.Header class="bg-muted/20 border-b !py-4">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <NavigationIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">{m.navigation_mobile_behavior_title()}</Card.Title>
- <Card.Description class="text-xs">{m.navigation_mobile_behavior_description()}</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-3 sm:px-6 sm:py-4">
- <div class="grid grid-cols-1 gap-3 sm:gap-4 lg:grid-cols-[repeat(auto-fit,minmax(400px,1fr))]">
- <NavigationSettingControl
- id="mobileNavigationScrollToHide"
- label={m.navigation_scroll_to_hide_label()}
- description={m.navigation_scroll_to_hide_description()}
- icon={ScrollTextIcon}
- serverValue={$formInputs.mobileNavigationScrollToHide.value}
- localOverride={persistedState.scrollToHide}
- onServerChange={(value) => {
- $formInputs.mobileNavigationScrollToHide.value = value;
- }}
- onLocalOverride={(value) => setLocalOverride('scrollToHide', value)}
- onClearOverride={() => clearLocalOverride('scrollToHide')}
- serverDisabled={uiConfigDisabled}
- />
-
- <NavigationSettingControl
- id="mobileNavigationTapToHide"
- label={m.navigation_tap_to_hide_label()}
- description={m.navigation_tap_to_hide_description()}
- icon={MousePointerClickIcon}
- serverValue={$formInputs.mobileNavigationTapToHide.value}
- localOverride={persistedState.tapToHide}
- onServerChange={(value) => {
- $formInputs.mobileNavigationTapToHide.value = value;
- }}
- onLocalOverride={(value) => setLocalOverride('tapToHide', value)}
- onClearOverride={() => clearLocalOverride('tapToHide')}
- serverDisabled={uiConfigDisabled}
- />
- </div>
- </Card.Content>
- </Card.Root>
-</div>
diff --git a/frontend/src/routes/settings/forms/security-settings-form.svelte b/frontend/src/routes/settings/forms/security-settings-form.svelte
deleted file mode 100644
index b8d8c9ec3..000000000
--- a/frontend/src/routes/settings/forms/security-settings-form.svelte
+++ /dev/null
@@ -1,362 +0,0 @@
-<script lang="ts">
- import { z } from 'zod/v4';
- import { getContext, onMount } from 'svelte';
- import { createForm } from '$lib/utils/form.utils';
- import * as Card from '$lib/components/ui/card';
- import { Button } from '$lib/components/ui/button';
- import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';
- import OidcConfigDialog from '$lib/components/dialogs/oidc-config-dialog.svelte';
- import { toast } from 'svelte-sonner';
- import type { Settings } from '$lib/types/settings.type';
- import type { OidcStatusInfo } from '$lib/types/settings.type';
- import * as Tooltip from '$lib/components/ui/tooltip/index.js';
- import { m } from '$lib/paraglide/messages';
- import LockIcon from '@lucide/svelte/icons/lock';
- import ClockIcon from '@lucide/svelte/icons/clock';
- import KeyIcon from '@lucide/svelte/icons/key';
- import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';
- import settingsStore from '$lib/stores/config-store';
-
- let {
- settings,
- oidcStatus,
- callback,
- hasChanges = $bindable(),
- isLoading = $bindable(false)
- }: {
- settings: Settings;
- oidcStatus: OidcStatusInfo;
- callback: (appConfig: Partial<Settings>) => Promise<void>;
- hasChanges: boolean;
- isLoading: boolean;
- } = $props();
-
- let showOidcConfigDialog = $state(false);
-
- let oidcConfigForm = $state({
- clientId: '',
- clientSecret: '',
- issuerUrl: '',
- scopes: 'openid email profile',
- adminClaim: '',
- adminValue: ''
- });
-
- const formSchema = z
- .object({
- authLocalEnabled: z.boolean(),
- authOidcEnabled: z.boolean(),
- authSessionTimeout: z
- .number(m.security_session_timeout_required())
- .int(m.security_session_timeout_integer())
- .min(15, m.security_session_timeout_min())
- .max(1440, m.security_session_timeout_max()),
- authPasswordPolicy: z.enum(['basic', 'standard', 'strong'])
- })
- .superRefine((data, ctx) => {
- // If server forces OIDC, the constraint is already satisfied
- if (oidcStatus.envForced) return;
- if (!data.authLocalEnabled && !data.authOidcEnabled) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: m.security_enable_one_provider(),
- path: ['authLocalEnabled']
- });
- }
- });
-
- let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, settings));
-
- const formHasChanges = $derived.by(
- () =>
- $formInputs.authLocalEnabled.value !== settings.authLocalEnabled ||
- $formInputs.authOidcEnabled.value !== settings.authOidcEnabled ||
- $formInputs.authSessionTimeout.value !== settings.authSessionTimeout ||
- $formInputs.authPasswordPolicy.value !== settings.authPasswordPolicy
- );
-
- $effect(() => {
- hasChanges = formHasChanges;
- });
-
- // Helper: treat OIDC as active if forced by server or enabled in form
- const isOidcActive = () => $formInputs.authOidcEnabled.value || oidcStatus.envForced;
-
- async function onSubmit() {
- const data = form.validate();
- if (!data) {
- toast.error('Please check the form for errors');
- return;
- }
-
- isLoading = true;
-
- let authOidcConfig = settings.authOidcConfig;
- if (data.authOidcEnabled && !oidcStatus.envForced) {
- authOidcConfig = JSON.stringify({
- clientId: oidcConfigForm.clientId,
- clientSecret: oidcConfigForm.clientSecret || '',
- issuerUrl: oidcConfigForm.issuerUrl,
- scopes: oidcConfigForm.scopes,
- adminClaim: oidcConfigForm.adminClaim || '',
- adminValue: oidcConfigForm.adminValue || ''
- });
- }
-
- await callback({
- authLocalEnabled: data.authLocalEnabled,
- authOidcEnabled: data.authOidcEnabled,
- authSessionTimeout: data.authSessionTimeout,
- authPasswordPolicy: data.authPasswordPolicy
- })
- .then(() => toast.success(m.security_settings_saved()))
- .catch((error) => {
- console.error('Failed to save settings:', error);
- toast.error('Failed to save settings. Please try again.');
- })
- .finally(() => (isLoading = false));
- }
-
- function resetForm() {
- $formInputs.authLocalEnabled.value = settings.authLocalEnabled;
- $formInputs.authOidcEnabled.value = settings.authOidcEnabled;
- $formInputs.authSessionTimeout.value = settings.authSessionTimeout;
- $formInputs.authPasswordPolicy.value = settings.authPasswordPolicy;
- }
-
- onMount(() => {
- const formState = getContext('settingsFormState') as any;
- if (formState) {
- formState.saveFunction = onSubmit;
- formState.resetFunction = resetForm;
- }
- });
-
- // Only depend on envForced; open config when enabling and not forced
- function handleOidcSwitchChange(checked: boolean) {
- $formInputs.authOidcEnabled.value = checked;
-
- if (!checked && !$formInputs.authLocalEnabled.value && !oidcStatus.envForced) {
- $formInputs.authLocalEnabled.value = true;
- toast.info(m.security_local_enabled_info());
- }
-
- if (checked && !oidcStatus.envForced) {
- showOidcConfigDialog = true;
- }
- }
-
- function handleLocalSwitchChange(checked: boolean) {
- if (!checked && !isOidcActive()) {
- $formInputs.authLocalEnabled.value = true;
- toast.error(m.security_enable_one_provider_error());
- return;
- }
- $formInputs.authLocalEnabled.value = checked;
- }
-
- function openOidcDialog() {
- if (settings.authOidcConfig) {
- const cfg = JSON.parse(settings.authOidcConfig);
- oidcConfigForm.clientId = cfg.clientId || '';
- oidcConfigForm.issuerUrl = cfg.issuerUrl || '';
- oidcConfigForm.scopes = cfg.scopes || 'openid email profile';
- oidcConfigForm.adminClaim = cfg.adminClaim || '';
- oidcConfigForm.adminValue = cfg.adminValue || '';
- }
- oidcConfigForm.clientSecret = '';
- showOidcConfigDialog = true;
- }
-
- async function handleSaveOidcConfig() {
- try {
- isLoading = true;
- $formInputs.authOidcEnabled.value = true;
-
- const data = form.validate();
- if (!data) {
- isLoading = false;
- return;
- }
-
- const authOidcConfig = JSON.stringify({
- clientId: oidcConfigForm.clientId,
- clientSecret: oidcConfigForm.clientSecret || '',
- issuerUrl: oidcConfigForm.issuerUrl,
- scopes: oidcConfigForm.scopes,
- adminClaim: oidcConfigForm.adminClaim || '',
- adminValue: oidcConfigForm.adminValue || ''
- });
-
- await callback({
- authOidcEnabled: true,
- authOidcConfig
- });
-
- toast.success(m.security_oidc_saved());
- showOidcConfigDialog = false;
- } finally {
- isLoading = false;
- }
- }
-
- const uiConfigDisabled = $state($settingsStore.uiConfigDisabled);
-</script>
-
-<fieldset disabled={uiConfigDisabled} class="relative">
- <div class="space-y-4 sm:space-y-6">
- <!-- Authentication Methods Card -->
- <Card.Root class="pt-0 overflow-hidden">
- <Card.Header class="!py-4 bg-muted/20 border-b">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <LockIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">{m.security_authentication_heading()}</Card.Title>
- <Card.Description class="text-xs">Configure login methods for your application</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-4 sm:px-6">
- <div class="space-y-3">
- <SwitchWithLabel
- id="localAuthSwitch"
- label={m.security_local_auth_label()}
- description={m.security_local_auth_description()}
- bind:checked={$formInputs.authLocalEnabled.value}
- onCheckedChange={handleLocalSwitchChange}
- />
-
- <div class="space-y-2">
- <SwitchWithLabel
- id="oidcAuthSwitch"
- label={m.security_oidc_auth_label()}
- description={oidcStatus.envForced ? m.security_oidc_auth_description_forced() : m.security_oidc_auth_description()}
- disabled={oidcStatus.envForced}
- bind:checked={$formInputs.authOidcEnabled.value}
- onCheckedChange={handleOidcSwitchChange}
- />
-
- {#if isOidcActive()}
- <div class="pl-8 sm:pl-11">
- {#if oidcStatus.envForced}
- {#if !oidcStatus.envConfigured}
- <Button variant="link" class="text-destructive h-auto p-0 text-xs hover:underline" onclick={openOidcDialog}>
- {m.security_server_forces_oidc_missing_env()}
- </Button>
- {:else}
- <Button variant="link" class="h-auto p-0 text-xs text-sky-600 hover:underline" onclick={openOidcDialog}>
- {m.security_oidc_configured_forced_view()}
- </Button>
- {/if}
- {:else}
- <Button variant="link" class="h-auto p-0 text-xs text-sky-600 hover:underline" onclick={openOidcDialog}>
- {m.security_manage_oidc_config()}
- </Button>
- {/if}
- </div>
- {/if}
- </div>
- </div>
- </Card.Content>
- </Card.Root>
-
- <!-- Session Settings Card -->
- <Card.Root class="pt-0 overflow-hidden">
- <Card.Header class="!py-4 bg-muted/20 border-b">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <ClockIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">{m.security_session_heading()}</Card.Title>
- <Card.Description class="text-xs">Configure session timeout and duration</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-4 sm:px-6">
- <TextInputWithLabel
- bind:value={$formInputs.authSessionTimeout.value}
- label={m.security_session_timeout_label()}
- placeholder={m.security_session_timeout_placeholder()}
- helpText={m.security_session_timeout_description()}
- type="number"
- />
- </Card.Content>
- </Card.Root>
-
- <!-- Password Policy Card -->
- <Card.Root class="pt-0 overflow-hidden">
- <Card.Header class="!py-4 bg-muted/20 border-b">
- <div class="flex items-center gap-3">
- <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
- <KeyIcon class="size-4" />
- </div>
- <div>
- <Card.Title class="text-base">{m.security_password_policy_label()}</Card.Title>
- <Card.Description class="text-xs">Set password strength requirements</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content class="px-3 py-4 sm:px-6">
- <Tooltip.Provider>
- <div class="grid grid-cols-1 gap-2 sm:grid-cols-3 sm:gap-3" role="group" aria-labelledby="passwordPolicyLabel">
- <Tooltip.Root>
- <Tooltip.Trigger>
- <Button
- variant={$formInputs.authPasswordPolicy.value === 'basic' ? 'default' : 'outline'}
- class={$formInputs.authPasswordPolicy.value === 'basic'
- ? 'arcane-button-create h-12 w-full text-xs sm:text-sm'
- : 'arcane-button-restart h-12 w-full text-xs sm:text-sm'}
- onclick={() => ($formInputs.authPasswordPolicy.value = 'basic')}
- type="button"
- >{m.security_password_policy_basic()}
- </Button>
- </Tooltip.Trigger>
- <Tooltip.Content side="top" align="center">{m.security_password_policy_basic_tooltip()}</Tooltip.Content>
- </Tooltip.Root>
-
- <Tooltip.Root>
- <Tooltip.Trigger>
- <Button
- variant={$formInputs.authPasswordPolicy.value === 'standard' ? 'default' : 'outline'}
- class={$formInputs.authPasswordPolicy.value === 'standard'
- ? 'arcane-button-create h-12 w-full text-xs sm:text-sm'
- : 'arcane-button-restart h-12 w-full text-xs sm:text-sm'}
- onclick={() => ($formInputs.authPasswordPolicy.value = 'standard')}
- type="button"
- >{m.security_password_policy_standard()}
- </Button>
- </Tooltip.Trigger>
- <Tooltip.Content side="top" align="center">{m.security_password_policy_standard_tooltip()}</Tooltip.Content>
- </Tooltip.Root>
-
- <Tooltip.Root>
- <Tooltip.Trigger>
- <Button
- variant={$formInputs.authPasswordPolicy.value === 'strong' ? 'default' : 'outline'}
- class={$formInputs.authPasswordPolicy.value === 'strong'
- ? 'arcane-button-create h-12 w-full text-xs sm:text-sm'
- : 'arcane-button-restart h-12 w-full text-xs sm:text-sm'}
- onclick={() => ($formInputs.authPasswordPolicy.value = 'strong')}
- type="button"
- >{m.security_password_policy_strong()}
- </Button>
- </Tooltip.Trigger>
- <Tooltip.Content side="top" align="center">{m.security_password_policy_strong_tooltip()}</Tooltip.Content>
- </Tooltip.Root>
- </div>
- </Tooltip.Provider>
- </Card.Content>
- </Card.Root>
- </div>
-</fieldset>
-
-<OidcConfigDialog
- bind:open={showOidcConfigDialog}
- currentSettings={settings}
- {oidcStatus}
- bind:oidcForm={oidcConfigForm}
- onSave={handleSaveOidcConfig}
-/>
diff --git a/frontend/src/routes/settings/general/+page.svelte b/frontend/src/routes/settings/general/+page.svelte
index bea59a9db..be0ead2e9 100644
--- a/frontend/src/routes/settings/general/+page.svelte
+++ b/frontend/src/routes/settings/general/+page.svelte
@@ -1,12 +1,19 @@
<script lang="ts">
+ import { z } from 'zod/v4';
+ import { getContext, onMount } from 'svelte';
+ import { createForm } from '$lib/utils/form.utils';
+ import * as Card from '$lib/components/ui/card';
import type { Settings } from '$lib/types/settings.type';
+ import { toast } from 'svelte-sonner';
+ import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';
+ import { m } from '$lib/paraglide/messages';
+ import FolderIcon from '@lucide/svelte/icons/folder';
+ import UserIcon from '@lucide/svelte/icons/user';
+ import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';
import settingsStore from '$lib/stores/config-store';
- import UiConfigDisabledTag from '$lib/components/ui-config-disabled-tag.svelte';
- import GeneralSettingsForm from '../forms/general-settings-form.svelte';
import SettingsIcon from '@lucide/svelte/icons/settings';
- import { m } from '$lib/paraglide/messages';
- import { getContext } from 'svelte';
import { settingsService } from '$lib/services/settings-service';
+ import { SettingsPageLayout } from '$lib/layouts/index.js';
let { data } = $props();
let currentSettings = $state(data.settings);
@@ -14,10 +21,24 @@
let isLoading = $state(false);
const isReadOnly = $derived.by(() => $settingsStore.uiConfigDisabled);
-
const formState = getContext('settingsFormState') as any;
+ const formSchema = z.object({
+ projectsDirectory: z.string().min(1, m.general_projects_directory_required()),
+ baseServerUrl: z.string().min(1, m.general_base_url_required()),
+ enableGravatar: z.boolean()
+ });
+
+ let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, currentSettings));
+
+ const formHasChanges = $derived.by(
+ () =>
+ $formInputs.projectsDirectory.value !== currentSettings.projectsDirectory ||
+ $formInputs.baseServerUrl.value !== currentSettings.baseServerUrl ||
+ $formInputs.enableGravatar.value !== currentSettings.enableGravatar
+ );
$effect(() => {
+ hasChanges = formHasChanges;
if (formState) {
formState.hasChanges = hasChanges;
formState.isLoading = isLoading;
@@ -35,35 +56,103 @@
throw error;
}
}
+
+ async function onSubmit() {
+ const data = form.validate();
+ if (!data) {
+ toast.error('Please check the form for errors');
+ return;
+ }
+ isLoading = true;
+
+ await updateSettingsConfig(data)
+ .then(() => toast.success(m.general_settings_saved()))
+ .catch((error) => {
+ console.error('Failed to save settings:', error);
+ toast.error('Failed to save settings. Please try again.');
+ })
+ .finally(() => (isLoading = false));
+ }
+
+ function resetForm() {
+ $formInputs.projectsDirectory.value = currentSettings.projectsDirectory;
+ $formInputs.baseServerUrl.value = currentSettings.baseServerUrl;
+ $formInputs.enableGravatar.value = currentSettings.enableGravatar;
+ }
+
+ onMount(() => {
+ if (formState) {
+ formState.saveFunction = onSubmit;
+ formState.resetFunction = resetForm;
+ }
+ });
</script>
-<div class="px-2 py-4 sm:px-6 sm:py-6 lg:px-8">
- <div
- class="from-background/60 via-background/40 to-background/60 relative overflow-hidden rounded-xl border bg-gradient-to-br p-4 shadow-sm sm:p-6"
- >
- <div class="bg-primary/10 pointer-events-none absolute -right-10 -top-10 size-40 rounded-full blur-3xl"></div>
- <div class="bg-muted/40 pointer-events-none absolute -bottom-10 -left-10 size-40 rounded-full blur-3xl"></div>
- <div class="relative flex items-start gap-3 sm:gap-4">
- <div
- class="bg-primary/10 text-primary ring-primary/20 flex size-8 shrink-0 items-center justify-center rounded-lg ring-1 sm:size-10"
- >
- <SettingsIcon class="size-4 sm:size-5" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="flex items-start justify-between gap-3">
- <h1 class="settings-title min-w-0 text-xl sm:text-3xl">{m.general_title()}</h1>
- {#if isReadOnly}
- <div class="shrink-0">
- <UiConfigDisabledTag />
+<SettingsPageLayout
+ title={m.general_title()}
+ description={m.general_description()}
+ icon={SettingsIcon}
+ pageType="form"
+ showReadOnlyTag={isReadOnly}
+>
+ {#snippet mainContent()}
+ <fieldset disabled={isReadOnly} class="relative">
+ <div class="space-y-4 sm:space-y-6">
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <FolderIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">{m.general_projects_heading()}</Card.Title>
+ <Card.Description class="text-xs">{m.general_projects_description()}</Card.Description>
+ </div>
</div>
- {/if}
- </div>
- <p class="text-muted-foreground mt-1 text-sm sm:text-base">{m.general_description()}</p>
- </div>
- </div>
- </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-4 sm:px-6">
+ <div class="space-y-3">
+ <TextInputWithLabel
+ bind:value={$formInputs.projectsDirectory.value}
+ label={m.general_projects_directory_label()}
+ placeholder={m.general_projects_directory_placeholder()}
+ helpText={m.general_projects_directory_help()}
+ type="text"
+ />
+
+ <TextInputWithLabel
+ bind:value={$formInputs.baseServerUrl.value}
+ label={m.general_base_url_label()}
+ placeholder={m.general_base_url_placeholder()}
+ helpText={m.general_base_url_help()}
+ type="text"
+ />
+ </div>
+ </Card.Content>
+ </Card.Root>
- <div class="mt-6 sm:mt-8">
- <GeneralSettingsForm settings={currentSettings} callback={updateSettingsConfig} bind:hasChanges bind:isLoading />
- </div>
-</div>
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <UserIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">{m.general_user_avatars_heading()}</Card.Title>
+ <Card.Description class="text-xs">{m.general_user_avatars_description()}</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-4 sm:px-6">
+ <SwitchWithLabel
+ id="enableGravatar"
+ label={m.general_enable_gravatar_label()}
+ description={m.general_enable_gravatar_description()}
+ bind:checked={$formInputs.enableGravatar.value}
+ />
+ </Card.Content>
+ </Card.Root>
+ </div>
+ </fieldset>
+ {/snippet}
+</SettingsPageLayout>
diff --git a/frontend/src/routes/settings/navigation/+page.svelte b/frontend/src/routes/settings/navigation/+page.svelte
index e6e7671d6..d3bc807ca 100644
--- a/frontend/src/routes/settings/navigation/+page.svelte
+++ b/frontend/src/routes/settings/navigation/+page.svelte
@@ -1,12 +1,21 @@
<script lang="ts">
+ import { z } from 'zod/v4';
+ import { getContext, onMount } from 'svelte';
+ import { createForm } from '$lib/utils/form.utils';
+ import * as Card from '$lib/components/ui/card';
import type { Settings } from '$lib/types/settings.type';
- import settingsStore from '$lib/stores/config-store';
- import { settingsService } from '$lib/services/settings-service';
- import UiConfigDisabledTag from '$lib/components/ui-config-disabled-tag.svelte';
- import NavigationSettingsForm from '../forms/navigation-settings-form.svelte';
+ import { toast } from 'svelte-sonner';
+ import EyeIcon from '@lucide/svelte/icons/eye';
+ import MousePointerClickIcon from '@lucide/svelte/icons/mouse-pointer-click';
+ import ScrollTextIcon from '@lucide/svelte/icons/scroll-text';
import NavigationIcon from '@lucide/svelte/icons/navigation';
+ import NavigationSettingControl from '$lib/components/navigation-setting-control.svelte';
+ import NavigationModeSettingControl from '$lib/components/navigation-mode-setting-control.svelte';
+ import settingsStore from '$lib/stores/config-store';
import { m } from '$lib/paraglide/messages';
- import { getContext } from 'svelte';
+ import { navigationSettingsOverridesStore, resetNavigationVisibility } from '$lib/utils/navigation.utils';
+ import { settingsService } from '$lib/services/settings-service';
+ import { SettingsPageLayout } from '$lib/layouts/index.js';
let { data } = $props();
let currentSettings = $state(data.settings);
@@ -14,16 +23,64 @@
let isLoading = $state(false);
const isReadOnly = $derived.by(() => $settingsStore.uiConfigDisabled);
-
const formState = getContext('settingsFormState') as any;
+ const formSchema = z.object({
+ mobileNavigationMode: z.enum(['floating', 'docked']),
+ mobileNavigationShowLabels: z.boolean(),
+ mobileNavigationScrollToHide: z.boolean(),
+ mobileNavigationTapToHide: z.boolean()
+ });
+
+ // Track local override state using the shared store
+ let persistedState = $state(navigationSettingsOverridesStore.current);
+
+ let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, currentSettings));
+
+ const formHasChanges = $derived.by(
+ () =>
+ $formInputs.mobileNavigationMode.value !== currentSettings.mobileNavigationMode ||
+ $formInputs.mobileNavigationShowLabels.value !== currentSettings.mobileNavigationShowLabels ||
+ $formInputs.mobileNavigationScrollToHide.value !== currentSettings.mobileNavigationScrollToHide ||
+ $formInputs.mobileNavigationTapToHide.value !== currentSettings.mobileNavigationTapToHide
+ );
$effect(() => {
+ hasChanges = formHasChanges;
if (formState) {
formState.hasChanges = hasChanges;
formState.isLoading = isLoading;
}
});
+ function setLocalOverride(key: 'mode' | 'showLabels' | 'scrollToHide' | 'tapToHide', value: any) {
+ const currentOverrides = navigationSettingsOverridesStore.current;
+ navigationSettingsOverridesStore.current = {
+ ...currentOverrides,
+ [key]: value
+ };
+ persistedState = navigationSettingsOverridesStore.current;
+
+ // Reset navigation bar visibility when behavior settings change
+ if (key === 'scrollToHide' || key === 'tapToHide') {
+ resetNavigationVisibility();
+ }
+ }
+
+ function clearLocalOverride(key: 'mode' | 'showLabels' | 'scrollToHide' | 'tapToHide') {
+ const currentOverrides = navigationSettingsOverridesStore.current;
+ const newOverrides = { ...currentOverrides };
+ delete newOverrides[key];
+ navigationSettingsOverridesStore.current = newOverrides;
+ persistedState = navigationSettingsOverridesStore.current;
+
+ // Reset navigation bar visibility when behavior settings change
+ if (key === 'scrollToHide' || key === 'tapToHide') {
+ resetNavigationVisibility();
+ }
+
+ toast.success(`Local override cleared for ${key.replace(/([A-Z])/g, ' $1').toLowerCase()}`);
+ }
+
async function updateSettingsConfig(updatedSettings: Partial<Settings>) {
try {
await settingsService.updateSettings(updatedSettings as any);
@@ -35,35 +92,153 @@
throw error;
}
}
+
+ async function onSubmit() {
+ const formData = form.validate();
+ if (!formData) {
+ toast.error('Please check the form for errors');
+ return;
+ }
+ isLoading = true;
+
+ // Check if behavior settings changed
+ const behaviorChanged =
+ formData.mobileNavigationScrollToHide !== currentSettings.mobileNavigationScrollToHide ||
+ formData.mobileNavigationTapToHide !== currentSettings.mobileNavigationTapToHide;
+
+ await updateSettingsConfig(formData)
+ .then(() => {
+ toast.success(m.navigation_settings_saved());
+
+ // Reset navigation bar visibility if behavior settings changed
+ if (behaviorChanged) {
+ resetNavigationVisibility();
+ }
+ })
+ .catch((error) => {
+ console.error('Failed to save navigation settings:', error);
+ toast.error('Failed to save navigation settings. Please try again.');
+ })
+ .finally(() => (isLoading = false));
+ }
+
+ function resetForm() {
+ $formInputs.mobileNavigationMode.value = currentSettings.mobileNavigationMode;
+ $formInputs.mobileNavigationShowLabels.value = currentSettings.mobileNavigationShowLabels;
+ $formInputs.mobileNavigationScrollToHide.value = currentSettings.mobileNavigationScrollToHide;
+ $formInputs.mobileNavigationTapToHide.value = currentSettings.mobileNavigationTapToHide;
+ }
+
+ onMount(() => {
+ if (formState) {
+ formState.saveFunction = onSubmit;
+ formState.resetFunction = resetForm;
+ }
+ });
</script>
-<div class="px-2 py-4 sm:px-6 sm:py-6 lg:px-8">
- <div
- class="from-background/60 via-background/40 to-background/60 relative overflow-hidden rounded-xl border bg-gradient-to-br p-4 shadow-sm sm:p-6"
- >
- <div class="bg-primary/10 pointer-events-none absolute -top-10 -right-10 size-40 rounded-full blur-3xl"></div>
- <div class="bg-muted/40 pointer-events-none absolute -bottom-10 -left-10 size-40 rounded-full blur-3xl"></div>
- <div class="relative flex items-start gap-3 sm:gap-4">
- <div
- class="bg-primary/10 text-primary ring-primary/20 flex size-8 shrink-0 items-center justify-center rounded-lg ring-1 sm:size-10"
- >
- <NavigationIcon class="size-4 sm:size-5" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="flex items-start justify-between gap-3">
- <h1 class="settings-title min-w-0 text-xl sm:text-3xl">{m.navigation_title()}</h1>
- {#if isReadOnly}
- <div class="shrink-0">
- <UiConfigDisabledTag />
+<SettingsPageLayout
+ title={m.navigation_title()}
+ description={m.navigation_description()}
+ icon={NavigationIcon}
+ pageType="form"
+ showReadOnlyTag={isReadOnly}
+>
+ {#snippet mainContent()}
+ <div class="space-y-4 sm:space-y-6">
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <NavigationIcon class="size-4" />
</div>
- {/if}
- </div>
- <p class="text-muted-foreground mt-1 text-sm sm:text-base">{m.navigation_description()}</p>
- </div>
- </div>
- </div>
+ <div>
+ <Card.Title class="text-base">{m.navigation_mobile_appearance_title()}</Card.Title>
+ <Card.Description class="text-xs">{m.navigation_mobile_appearance_description()}</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-3 sm:px-6 sm:py-4">
+ <div class="grid grid-cols-1 gap-3 sm:gap-4 lg:grid-cols-[repeat(auto-fit,minmax(400px,1fr))]">
+ <NavigationModeSettingControl
+ id="mobileNavigationMode"
+ label={m.navigation_mode_label()}
+ description={m.navigation_mode_description()}
+ icon={NavigationIcon}
+ serverValue={$formInputs.mobileNavigationMode.value}
+ localOverride={persistedState.mode}
+ onServerChange={(value) => {
+ $formInputs.mobileNavigationMode.value = value;
+ }}
+ onLocalOverride={(value) => setLocalOverride('mode', value)}
+ onClearOverride={() => clearLocalOverride('mode')}
+ serverDisabled={isReadOnly}
+ />
+
+ <NavigationSettingControl
+ id="mobileNavigationShowLabels"
+ label={m.navigation_show_labels_label()}
+ description={m.navigation_show_labels_description()}
+ icon={EyeIcon}
+ serverValue={$formInputs.mobileNavigationShowLabels.value}
+ localOverride={persistedState.showLabels}
+ onServerChange={(value) => {
+ $formInputs.mobileNavigationShowLabels.value = value;
+ }}
+ onLocalOverride={(value) => setLocalOverride('showLabels', value)}
+ onClearOverride={() => clearLocalOverride('showLabels')}
+ serverDisabled={isReadOnly}
+ />
+ </div>
+ </Card.Content>
+ </Card.Root>
- <div class="mt-6 sm:mt-8">
- <NavigationSettingsForm settings={currentSettings} callback={updateSettingsConfig} bind:hasChanges bind:isLoading />
- </div>
-</div>
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <NavigationIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">{m.navigation_mobile_behavior_title()}</Card.Title>
+ <Card.Description class="text-xs">{m.navigation_mobile_behavior_description()}</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-3 sm:px-6 sm:py-4">
+ <div class="grid grid-cols-1 gap-3 sm:gap-4 lg:grid-cols-[repeat(auto-fit,minmax(400px,1fr))]">
+ <NavigationSettingControl
+ id="mobileNavigationScrollToHide"
+ label={m.navigation_scroll_to_hide_label()}
+ description={m.navigation_scroll_to_hide_description()}
+ icon={ScrollTextIcon}
+ serverValue={$formInputs.mobileNavigationScrollToHide.value}
+ localOverride={persistedState.scrollToHide}
+ onServerChange={(value) => {
+ $formInputs.mobileNavigationScrollToHide.value = value;
+ }}
+ onLocalOverride={(value) => setLocalOverride('scrollToHide', value)}
+ onClearOverride={() => clearLocalOverride('scrollToHide')}
+ serverDisabled={isReadOnly}
+ />
+
+ <NavigationSettingControl
+ id="mobileNavigationTapToHide"
+ label={m.navigation_tap_to_hide_label()}
+ description={m.navigation_tap_to_hide_description()}
+ icon={MousePointerClickIcon}
+ serverValue={$formInputs.mobileNavigationTapToHide.value}
+ localOverride={persistedState.tapToHide}
+ onServerChange={(value) => {
+ $formInputs.mobileNavigationTapToHide.value = value;
+ }}
+ onLocalOverride={(value) => setLocalOverride('tapToHide', value)}
+ onClearOverride={() => clearLocalOverride('tapToHide')}
+ serverDisabled={isReadOnly}
+ />
+ </div>
+ </Card.Content>
+ </Card.Root>
+ </div>
+ {/snippet}
+</SettingsPageLayout>
diff --git a/frontend/src/routes/settings/security/+page.svelte b/frontend/src/routes/settings/security/+page.svelte
index 88764674f..8ee1fde53 100644
--- a/frontend/src/routes/settings/security/+page.svelte
+++ b/frontend/src/routes/settings/security/+page.svelte
@@ -1,13 +1,23 @@
<script lang="ts">
+ import { z } from 'zod/v4';
+ import { getContext, onMount } from 'svelte';
+ import { createForm } from '$lib/utils/form.utils';
+ import * as Card from '$lib/components/ui/card';
+ import { Button } from '$lib/components/ui/button';
+ import SwitchWithLabel from '$lib/components/form/labeled-switch.svelte';
+ import OidcConfigDialog from '$lib/components/dialogs/oidc-config-dialog.svelte';
+ import { toast } from 'svelte-sonner';
import type { PageData } from './$types';
import type { Settings } from '$lib/types/settings.type';
- import settingsStore from '$lib/stores/config-store';
- import UiConfigDisabledTag from '$lib/components/ui-config-disabled-tag.svelte';
- import SecuritySettingsForm from '../forms/security-settings-form.svelte';
- import LockIcon from '@lucide/svelte/icons/lock';
+ import * as Tooltip from '$lib/components/ui/tooltip/index.js';
import { m } from '$lib/paraglide/messages';
- import { getContext } from 'svelte';
+ import LockIcon from '@lucide/svelte/icons/lock';
+ import ClockIcon from '@lucide/svelte/icons/clock';
+ import KeyIcon from '@lucide/svelte/icons/key';
+ import TextInputWithLabel from '$lib/components/form/text-input-with-label.svelte';
+ import settingsStore from '$lib/stores/config-store';
import { settingsService } from '$lib/services/settings-service';
+ import { SettingsPageLayout } from '$lib/layouts/index.js';
let { data }: { data: PageData } = $props();
let currentSettings = $state<Settings>(data.settings);
@@ -15,16 +25,62 @@
let isLoading = $state(false);
const isReadOnly = $derived.by(() => $settingsStore.uiConfigDisabled);
-
const formState = getContext('settingsFormState') as any;
+ const formSchema = z
+ .object({
+ authLocalEnabled: z.boolean(),
+ authOidcEnabled: z.boolean(),
+ authSessionTimeout: z
+ .number(m.security_session_timeout_required())
+ .int(m.security_session_timeout_integer())
+ .min(15, m.security_session_timeout_min())
+ .max(1440, m.security_session_timeout_max()),
+ authPasswordPolicy: z.enum(['basic', 'standard', 'strong'])
+ })
+ .superRefine((formData, ctx) => {
+ // If server forces OIDC, the constraint is already satisfied
+ if (data.oidcStatus.envForced) return;
+ if (!formData.authLocalEnabled && !formData.authOidcEnabled) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: m.security_enable_one_provider(),
+ path: ['authLocalEnabled']
+ });
+ }
+ });
+
+ let showOidcConfigDialog = $state(false);
+
+ let oidcConfigForm = $state({
+ clientId: '',
+ clientSecret: '',
+ issuerUrl: '',
+ scopes: 'openid email profile',
+ adminClaim: '',
+ adminValue: ''
+ });
+
+ let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, currentSettings));
+
+ const formHasChanges = $derived.by(
+ () =>
+ $formInputs.authLocalEnabled.value !== currentSettings.authLocalEnabled ||
+ $formInputs.authOidcEnabled.value !== currentSettings.authOidcEnabled ||
+ $formInputs.authSessionTimeout.value !== currentSettings.authSessionTimeout ||
+ $formInputs.authPasswordPolicy.value !== currentSettings.authPasswordPolicy
+ );
$effect(() => {
+ hasChanges = formHasChanges;
if (formState) {
formState.hasChanges = hasChanges;
formState.isLoading = isLoading;
}
});
+ // Helper: treat OIDC as active if forced by server or enabled in form
+ const isOidcActive = () => $formInputs.authOidcEnabled.value || data.oidcStatus.envForced;
+
async function updateSettingsConfig(updatedSettings: Partial<Settings>) {
try {
await settingsService.updateSettings(updatedSettings as any);
@@ -36,41 +92,294 @@
throw error;
}
}
+
+ async function onSubmit() {
+ const formData = form.validate();
+ if (!formData) {
+ toast.error('Please check the form for errors');
+ return;
+ }
+
+ isLoading = true;
+
+ let authOidcConfig = currentSettings.authOidcConfig;
+ if (formData.authOidcEnabled && !data.oidcStatus.envForced) {
+ authOidcConfig = JSON.stringify({
+ clientId: oidcConfigForm.clientId,
+ clientSecret: oidcConfigForm.clientSecret || '',
+ issuerUrl: oidcConfigForm.issuerUrl,
+ scopes: oidcConfigForm.scopes,
+ adminClaim: oidcConfigForm.adminClaim || '',
+ adminValue: oidcConfigForm.adminValue || ''
+ });
+ }
+
+ await updateSettingsConfig({
+ authLocalEnabled: formData.authLocalEnabled,
+ authOidcEnabled: formData.authOidcEnabled,
+ authSessionTimeout: formData.authSessionTimeout,
+ authPasswordPolicy: formData.authPasswordPolicy,
+ ...(formData.authOidcEnabled && !data.oidcStatus.envForced && { authOidcConfig })
+ })
+ .then(() => toast.success(m.security_settings_saved()))
+ .catch((error) => {
+ console.error('Failed to save settings:', error);
+ toast.error('Failed to save settings. Please try again.');
+ })
+ .finally(() => (isLoading = false));
+ }
+
+ function resetForm() {
+ $formInputs.authLocalEnabled.value = currentSettings.authLocalEnabled;
+ $formInputs.authOidcEnabled.value = currentSettings.authOidcEnabled;
+ $formInputs.authSessionTimeout.value = currentSettings.authSessionTimeout;
+ $formInputs.authPasswordPolicy.value = currentSettings.authPasswordPolicy;
+ }
+
+ // Only depend on envForced; open config when enabling and not forced
+ function handleOidcSwitchChange(checked: boolean) {
+ $formInputs.authOidcEnabled.value = checked;
+
+ if (!checked && !$formInputs.authLocalEnabled.value && !data.oidcStatus.envForced) {
+ $formInputs.authLocalEnabled.value = true;
+ toast.info(m.security_local_enabled_info());
+ }
+
+ if (checked && !data.oidcStatus.envForced) {
+ showOidcConfigDialog = true;
+ }
+ }
+
+ function handleLocalSwitchChange(checked: boolean) {
+ if (!checked && !isOidcActive()) {
+ $formInputs.authLocalEnabled.value = true;
+ toast.error(m.security_enable_one_provider_error());
+ return;
+ }
+ $formInputs.authLocalEnabled.value = checked;
+ }
+
+ function openOidcDialog() {
+ if (currentSettings.authOidcConfig) {
+ const cfg = JSON.parse(currentSettings.authOidcConfig);
+ oidcConfigForm.clientId = cfg.clientId || '';
+ oidcConfigForm.issuerUrl = cfg.issuerUrl || '';
+ oidcConfigForm.scopes = cfg.scopes || 'openid email profile';
+ oidcConfigForm.adminClaim = cfg.adminClaim || '';
+ oidcConfigForm.adminValue = cfg.adminValue || '';
+ }
+ oidcConfigForm.clientSecret = '';
+ showOidcConfigDialog = true;
+ }
+
+ async function handleSaveOidcConfig() {
+ try {
+ isLoading = true;
+ $formInputs.authOidcEnabled.value = true;
+
+ const formData = form.validate();
+ if (!formData) {
+ isLoading = false;
+ return;
+ }
+
+ const authOidcConfig = JSON.stringify({
+ clientId: oidcConfigForm.clientId,
+ clientSecret: oidcConfigForm.clientSecret || '',
+ issuerUrl: oidcConfigForm.issuerUrl,
+ scopes: oidcConfigForm.scopes,
+ adminClaim: oidcConfigForm.adminClaim || '',
+ adminValue: oidcConfigForm.adminValue || ''
+ });
+
+ await updateSettingsConfig({
+ authOidcEnabled: true,
+ authOidcConfig
+ });
+
+ toast.success(m.security_oidc_saved());
+ showOidcConfigDialog = false;
+ } finally {
+ isLoading = false;
+ }
+ }
+
+ onMount(() => {
+ if (formState) {
+ formState.saveFunction = onSubmit;
+ formState.resetFunction = resetForm;
+ }
+ });
</script>
-<div class="px-2 py-4 sm:px-6 sm:py-6 lg:px-8">
- <div
- class="from-background/60 via-background/40 to-background/60 relative overflow-hidden rounded-xl border bg-gradient-to-br p-4 shadow-sm sm:p-6"
- >
- <div class="bg-primary/10 pointer-events-none absolute -right-10 -top-10 size-40 rounded-full blur-3xl"></div>
- <div class="bg-muted/40 pointer-events-none absolute -bottom-10 -left-10 size-40 rounded-full blur-3xl"></div>
- <div class="relative flex items-start gap-3 sm:gap-4">
- <div
- class="bg-primary/10 text-primary ring-primary/20 flex size-8 shrink-0 items-center justify-center rounded-lg ring-1 sm:size-10"
- >
- <LockIcon class="size-4 sm:size-5" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="flex items-start justify-between gap-3">
- <h1 class="settings-title min-w-0 text-xl sm:text-3xl">{m.security_title()}</h1>
- {#if isReadOnly}
- <div class="shrink-0">
- <UiConfigDisabledTag />
+<SettingsPageLayout
+ title={m.security_title()}
+ description={m.security_description()}
+ icon={LockIcon}
+ pageType="form"
+ showReadOnlyTag={isReadOnly}
+>
+ {#snippet mainContent()}
+ <fieldset disabled={isReadOnly} class="relative">
+ <div class="space-y-4 sm:space-y-6">
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <LockIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">{m.security_authentication_heading()}</Card.Title>
+ <Card.Description class="text-xs">Configure login methods for your application</Card.Description>
+ </div>
</div>
- {/if}
- </div>
- <p class="text-muted-foreground mt-1 text-sm sm:text-base">{m.security_description()}</p>
- </div>
- </div>
- </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-4 sm:px-6">
+ <div class="space-y-3">
+ <SwitchWithLabel
+ id="localAuthSwitch"
+ label={m.security_local_auth_label()}
+ description={m.security_local_auth_description()}
+ bind:checked={$formInputs.authLocalEnabled.value}
+ onCheckedChange={handleLocalSwitchChange}
+ />
+
+ <div class="space-y-2">
+ <SwitchWithLabel
+ id="oidcAuthSwitch"
+ label={m.security_oidc_auth_label()}
+ description={data.oidcStatus.envForced
+ ? m.security_oidc_auth_description_forced()
+ : m.security_oidc_auth_description()}
+ disabled={data.oidcStatus.envForced}
+ bind:checked={$formInputs.authOidcEnabled.value}
+ onCheckedChange={handleOidcSwitchChange}
+ />
+
+ {#if isOidcActive()}
+ <div class="pl-8 sm:pl-11">
+ {#if data.oidcStatus.envForced}
+ {#if !data.oidcStatus.envConfigured}
+ <Button
+ variant="link"
+ class="text-destructive h-auto p-0 text-xs hover:underline"
+ onclick={openOidcDialog}
+ >
+ {m.security_server_forces_oidc_missing_env()}
+ </Button>
+ {:else}
+ <Button variant="link" class="h-auto p-0 text-xs text-sky-600 hover:underline" onclick={openOidcDialog}>
+ {m.security_oidc_configured_forced_view()}
+ </Button>
+ {/if}
+ {:else}
+ <Button variant="link" class="h-auto p-0 text-xs text-sky-600 hover:underline" onclick={openOidcDialog}>
+ {m.security_manage_oidc_config()}
+ </Button>
+ {/if}
+ </div>
+ {/if}
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
- <div class="mt-6 sm:mt-8">
- <SecuritySettingsForm
- settings={currentSettings}
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <ClockIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">{m.security_session_heading()}</Card.Title>
+ <Card.Description class="text-xs">Configure session timeout and duration</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-4 sm:px-6">
+ <TextInputWithLabel
+ bind:value={$formInputs.authSessionTimeout.value}
+ label={m.security_session_timeout_label()}
+ placeholder={m.security_session_timeout_placeholder()}
+ helpText={m.security_session_timeout_description()}
+ type="number"
+ />
+ </Card.Content>
+ </Card.Root>
+
+ <Card.Root class="overflow-hidden pt-0">
+ <Card.Header class="bg-muted/20 border-b !py-4">
+ <div class="flex items-center gap-3">
+ <div class="bg-primary/10 text-primary ring-primary/20 flex size-8 items-center justify-center rounded-lg ring-1">
+ <KeyIcon class="size-4" />
+ </div>
+ <div>
+ <Card.Title class="text-base">{m.security_password_policy_label()}</Card.Title>
+ <Card.Description class="text-xs">Set password strength requirements</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content class="px-3 py-4 sm:px-6">
+ <Tooltip.Provider>
+ <div class="grid grid-cols-1 gap-2 sm:grid-cols-3 sm:gap-3" role="group" aria-labelledby="passwordPolicyLabel">
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+ <Button
+ variant={$formInputs.authPasswordPolicy.value === 'basic' ? 'default' : 'outline'}
+ class={$formInputs.authPasswordPolicy.value === 'basic'
+ ? 'arcane-button-create h-12 w-full text-xs sm:text-sm'
+ : 'arcane-button-restart h-12 w-full text-xs sm:text-sm'}
+ onclick={() => ($formInputs.authPasswordPolicy.value = 'basic')}
+ type="button"
+ >{m.security_password_policy_basic()}
+ </Button>
+ </Tooltip.Trigger>
+ <Tooltip.Content side="top" align="center">{m.security_password_policy_basic_tooltip()}</Tooltip.Content>
+ </Tooltip.Root>
+
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+ <Button
+ variant={$formInputs.authPasswordPolicy.value === 'standard' ? 'default' : 'outline'}
+ class={$formInputs.authPasswordPolicy.value === 'standard'
+ ? 'arcane-button-create h-12 w-full text-xs sm:text-sm'
+ : 'arcane-button-restart h-12 w-full text-xs sm:text-sm'}
+ onclick={() => ($formInputs.authPasswordPolicy.value = 'standard')}
+ type="button"
+ >{m.security_password_policy_standard()}
+ </Button>
+ </Tooltip.Trigger>
+ <Tooltip.Content side="top" align="center">{m.security_password_policy_standard_tooltip()}</Tooltip.Content>
+ </Tooltip.Root>
+
+ <Tooltip.Root>
+ <Tooltip.Trigger>
+ <Button
+ variant={$formInputs.authPasswordPolicy.value === 'strong' ? 'default' : 'outline'}
+ class={$formInputs.authPasswordPolicy.value === 'strong'
+ ? 'arcane-button-create h-12 w-full text-xs sm:text-sm'
+ : 'arcane-button-restart h-12 w-full text-xs sm:text-sm'}
+ onclick={() => ($formInputs.authPasswordPolicy.value = 'strong')}
+ type="button"
+ >{m.security_password_policy_strong()}
+ </Button>
+ </Tooltip.Trigger>
+ <Tooltip.Content side="top" align="center">{m.security_password_policy_strong_tooltip()}</Tooltip.Content>
+ </Tooltip.Root>
+ </div>
+ </Tooltip.Provider>
+ </Card.Content>
+ </Card.Root>
+ </div>
+ </fieldset>
+ {/snippet}
+ {#snippet additionalContent()}
+ <OidcConfigDialog
+ bind:open={showOidcConfigDialog}
+ {currentSettings}
oidcStatus={data.oidcStatus}
- callback={updateSettingsConfig}
- bind:hasChanges
- bind:isLoading
+ bind:oidcForm={oidcConfigForm}
+ onSave={handleSaveOidcConfig}
/>
- </div>
-</div>
+ {/snippet}
+</SettingsPageLayout>
diff --git a/frontend/src/routes/settings/users/+page.svelte b/frontend/src/routes/settings/users/+page.svelte
index 3c5763503..101018853 100644
--- a/frontend/src/routes/settings/users/+page.svelte
+++ b/frontend/src/routes/settings/users/+page.svelte
@@ -5,8 +5,6 @@
import { toast } from 'svelte-sonner';
import { handleApiResultWithCallbacks } from '$lib/utils/api.util';
import { tryCatch } from '$lib/utils/try-catch';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
- import StatCard from '$lib/components/stat-card.svelte';
import UserTable from './user-table.svelte';
import UserFormSheet from '$lib/components/sheets/user-form-sheet.svelte';
import type { SearchPaginationSortRequest } from '$lib/types/pagination.type';
@@ -14,6 +12,7 @@
import type { CreateUser } from '$lib/types/user.type';
import { m } from '$lib/paraglide/messages';
import { userService } from '$lib/services/user-service';
+ import { SettingsPageLayout, type SettingsActionButton, type SettingsStatCard } from '$lib/layouts/index.js';
let { data } = $props();
@@ -108,63 +107,53 @@
console.error('Failed to submit user:', error);
}
}
-</script>
-<div class="px-2 py-4 sm:px-6 sm:py-6 lg:px-8">
- <div
- class="from-background/60 via-background/40 to-background/60 relative overflow-hidden rounded-xl border bg-gradient-to-br p-4 shadow-sm sm:p-6"
- >
- <div class="bg-primary/10 pointer-events-none absolute -right-10 -top-10 size-40 rounded-full blur-3xl"></div>
- <div class="bg-muted/40 pointer-events-none absolute -bottom-10 -left-10 size-40 rounded-full blur-3xl"></div>
- <div class="relative flex items-start gap-3 sm:gap-4">
- <div
- class="bg-primary/10 text-primary ring-primary/20 flex size-8 shrink-0 items-center justify-center rounded-lg ring-1 sm:size-10"
- >
- <UsersIcon class="size-4 sm:size-5" />
- </div>
- <div class="min-w-0 flex-1">
- <div class="flex items-start justify-between gap-3">
- <h1 class="settings-title min-w-0 text-xl sm:text-3xl">{m.users_title()}</h1>
- <div class="flex shrink-0 items-center gap-2">
- <ArcaneButton
- action="create"
- customLabel={m.users_create_button()}
- onclick={openCreateDialog}
- loading={isLoading.creating}
- disabled={isLoading.creating}
- />
- </div>
- </div>
- <p class="text-muted-foreground mt-1 text-sm sm:text-base">{m.users_subtitle()}</p>
- </div>
- </div>
- </div>
-
- <div class="mt-6 space-y-4 sm:mt-8 sm:space-y-6">
- <div class="grid grid-cols-1 gap-3 sm:grid-cols-3 sm:gap-4">
- <StatCard
- title={m.users_total()}
- value={totalUsers}
- icon={UsersIcon}
- iconColor="text-blue-500"
- class="border-l-4 border-l-blue-500"
- />
- <StatCard
- title={m.users_administrators()}
- value={adminUsers}
- icon={ShieldIcon}
- iconColor="text-red-500"
- class="border-l-4 border-l-red-500"
- />
- <StatCard
- title={m.users_regular()}
- value={regularUsers}
- icon={UserCheckIcon}
- iconColor="text-green-500"
- class="border-l-4 border-l-green-500"
- />
- </div>
+ const actionButtons: SettingsActionButton[] = $derived.by(() => [
+ {
+ id: 'create',
+ action: 'create',
+ label: m.users_create_button(),
+ onclick: openCreateDialog,
+ loading: isLoading.creating,
+ disabled: isLoading.creating
+ }
+ ]);
+
+ const statCards: SettingsStatCard[] = $derived([
+ {
+ title: m.users_total(),
+ value: totalUsers,
+ icon: UsersIcon,
+ iconColor: 'text-blue-500',
+ class: 'border-l-4 border-l-blue-500'
+ },
+ {
+ title: m.users_administrators(),
+ value: adminUsers,
+ icon: ShieldIcon,
+ iconColor: 'text-red-500',
+ class: 'border-l-4 border-l-red-500'
+ },
+ {
+ title: m.users_regular(),
+ value: regularUsers,
+ icon: UserCheckIcon,
+ iconColor: 'text-green-500',
+ class: 'border-l-4 border-l-green-500'
+ }
+ ]);
+</script>
+<SettingsPageLayout
+ title={m.users_title()}
+ description={m.users_subtitle()}
+ icon={UsersIcon}
+ pageType="management"
+ {actionButtons}
+ {statCards}
+ statCardsColumns={3}
+>
+ {#snippet mainContent()}
<UserTable
bind:users
bind:selectedIds
@@ -174,7 +163,9 @@
}}
onEditUser={openEditDialog}
/>
+ {/snippet}
+ {#snippet additionalContent()}
<UserFormSheet
bind:open={isDialogOpen.create}
userToEdit={null}
@@ -190,5 +181,5 @@
onSubmit={handleUserSubmit}
isLoading={isLoading.editing}
/>
- </div>
-</div>
+ {/snippet}
+</SettingsPageLayout>
diff --git a/frontend/src/routes/volumes/+page.svelte b/frontend/src/routes/volumes/+page.svelte
index 8a9010613..32bb0e917 100644
--- a/frontend/src/routes/volumes/+page.svelte
+++ b/frontend/src/routes/volumes/+page.svelte
@@ -7,15 +7,12 @@
import { tryCatch } from '$lib/utils/try-catch';
import CreateVolumeSheet from '$lib/components/sheets/create-volume-sheet.svelte';
import type { VolumeCreateOptions } from 'dockerode';
- import { ArcaneButton } from '$lib/components/arcane-button/index.js';
- import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
- import EllipsisIcon from '@lucide/svelte/icons/ellipsis';
- import StatCard from '$lib/components/stat-card.svelte';
import VolumeTable from './volume-table.svelte';
import { m } from '$lib/paraglide/messages';
import { volumeService } from '$lib/services/volume-service';
- import { environmentStore } from '$lib/stores/environment.store';
- import type { Environment } from '$lib/types/environment.type';
+ import { environmentStore } from '$lib/stores/environment.store';
+ import type { Environment } from '$lib/types/environment.type';
+ import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '$lib/layouts/index.js';
let { data } = $props();
@@ -52,7 +49,7 @@
async function refreshVolumes() {
isLoading.refresh = true;
let refreshingVolumeList = true;
- let refreshingVolumeCounts = true;
+ let refreshingVolumeCounts = true;
handleApiResultWithCallbacks({
result: await tryCatch(volumeService.getVolumes(requestOptions)),
message: m.volumes_refresh_failed(),
@@ -77,13 +74,11 @@
});
}
- // React to environment changes
const selectedEnvStore = environmentStore.selected;
let lastEnvId: string | null = null;
$effect(() => {
const env = $selectedEnvStore as Environment | null;
if (!env) return;
- // Skip initial page load
if (lastEnvId === null) {
lastEnvId = env.id;
return;
@@ -93,80 +88,57 @@
refreshVolumes();
}
});
-</script>
-
-<div class="space-y-6">
- <div class="relative flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div>
- <h1 class="text-3xl font-bold tracking-tight">{m.volumes_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">{m.volumes_subtitle()}</p>
- </div>
- <div class="hidden items-center gap-2 sm:flex">
- <ArcaneButton
- action="create"
- customLabel={m.volumes_create_button()}
- onclick={() => (isCreateDialogOpen = true)}
- loading={isLoading.creating}
- disabled={isLoading.creating}
- />
- <ArcaneButton
- action="restart"
- onclick={refreshVolumes}
- customLabel={m.common_refresh()}
- loading={isLoading.refresh}
- disabled={isLoading.refresh}
- />
- </div>
-
- <div class="absolute right-4 top-4 flex items-center sm:hidden">
- <DropdownMenu.Root>
- <DropdownMenu.Trigger class="bg-background/70 flex inline-flex size-9 items-center justify-center rounded-lg border">
- <span class="sr-only">{m.common_open_menu()}</span>
- <EllipsisIcon />
- </DropdownMenu.Trigger>
- <DropdownMenu.Content
- align="end"
- class="bg-card/80 supports-[backdrop-filter]:bg-card/60 z-50 min-w-[160px] rounded-md p-1 shadow-lg backdrop-blur-sm supports-[backdrop-filter]:backdrop-blur-sm"
- >
- <DropdownMenu.Group>
- <DropdownMenu.Item onclick={() => (isCreateDialogOpen = true)} disabled={isLoading.creating}>
- {m.volumes_create_button()}
- </DropdownMenu.Item>
- <DropdownMenu.Item onclick={refreshVolumes} disabled={isLoading.refresh}>
- {m.common_refresh()}
- </DropdownMenu.Item>
- </DropdownMenu.Group>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- </div>
- </div>
+ const actionButtons: ActionButton[] = $derived.by(() => [
+ {
+ id: 'create',
+ action: 'create',
+ label: m.volumes_create_button(),
+ onclick: () => (isCreateDialogOpen = true),
+ loading: isLoading.creating,
+ disabled: isLoading.creating
+ },
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.common_refresh(),
+ onclick: refreshVolumes,
+ loading: isLoading.refresh,
+ disabled: isLoading.refresh
+ }
+ ]);
- <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
- <StatCard
- title={m.volumes_stat_total()}
- value={totalVolumes}
- icon={HardDriveIcon}
- iconColor="text-blue-500"
- class="border-l-4 border-l-blue-500"
- />
- <StatCard
- title={m.volumes_stat_used()}
- value={usedVolumes}
- icon={ArchiveRestoreIcon}
- iconColor="text-green-500"
- class="border-l-4 border-l-green-500"
- />
- <StatCard
- title={m.volumes_stat_unused()}
- value={unusedVolumes}
- icon={ArchiveXIcon}
- iconColor="text-red-500"
- class="border-l-4 border-l-red-500"
- />
- </div>
+ const statCards: StatCardConfig[] = $derived([
+ {
+ title: m.volumes_stat_total(),
+ value: totalVolumes,
+ icon: HardDriveIcon,
+ iconColor: 'text-blue-500',
+ class: 'border-l-4 border-l-blue-500'
+ },
+ {
+ title: m.volumes_stat_used(),
+ value: usedVolumes,
+ icon: ArchiveRestoreIcon,
+ iconColor: 'text-green-500',
+ class: 'border-l-4 border-l-green-500'
+ },
+ {
+ title: m.volumes_stat_unused(),
+ value: unusedVolumes,
+ icon: ArchiveXIcon,
+ iconColor: 'text-red-500',
+ class: 'border-l-4 border-l-red-500'
+ }
+ ]);
+</script>
- <VolumeTable bind:volumes bind:selectedIds bind:requestOptions />
+<ResourcePageLayout title={m.volumes_title()} subtitle={m.volumes_subtitle()} {actionButtons} {statCards} statCardsColumns={3}>
+ {#snippet mainContent()}
+ <VolumeTable bind:volumes bind:selectedIds bind:requestOptions />
+ {/snippet}
- <CreateVolumeSheet bind:open={isCreateDialogOpen} isLoading={isLoading.creating} onSubmit={handleCreateVolumeSubmit} />
-</div>
+ {#snippet additionalContent()}
+ <CreateVolumeSheet bind:open={isCreateDialogOpen} isLoading={isLoading.creating} onSubmit={handleCreateVolumeSubmit} />
+ {/snippet}
+</ResourcePageLayout>