Skip to content

Modern Docker Management, Designed for Everyone

feat: settings page overhaul (#48)

Kyle Mendellf5ac649f004f
diff --git a/.gitignore b/.gitignore
index de2faab13..73137b64c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,4 +23,6 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.arcane/*
-.arcane/stacks/*
\ No newline at end of file
+.arcane/stacks/*
+.dev-data/*
+.dev-data/settings/*
\ No newline at end of file
diff --git a/app-settings.json b/app-settings.json
index 1698ad104..9a1503b43 100644
--- a/app-settings.json
+++ b/app-settings.json
@@ -1,7 +1,6 @@
{
"dockerHost": "unix:///var/run/docker.sock",
"autoRefresh": true,
- "refreshInterval": 10,
- "darkMode": true,
+ "pollingInterval": 5,
"stacksDirectory": "/app/data/stacks"
}
diff --git a/package-lock.json b/package-lock.json
index 871d08a81..82895d2cb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,6 +16,8 @@
"dockerode-compose": "^1.4.0",
"js-yaml": "^4.1.0",
"nanoid": "^5.1.5",
+ "proper-lockfile": "^4.1.2",
+ "redis": "^4.7.0",
"svelte-codemirror-editor": "^1.4.1"
},
"devDependencies": {
@@ -29,6 +31,7 @@
"@types/dockerode": "^3.3.38",
"@types/dockerode-compose": "^1.4.1",
"@types/js-yaml": "^4.0.9",
+ "@types/proper-lockfile": "^4.1.4",
"bits-ui": "^1.3.19",
"clsx": "^2.1.1",
"eslint": "^9.25.1",
@@ -1220,6 +1223,65 @@
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
"license": "BSD-3-Clause"
},
+ "node_modules/@redis/bloom": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz",
+ "integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@redis/client": "^1.0.0"
+ }
+ },
+ "node_modules/@redis/client": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.6.0.tgz",
+ "integrity": "sha512-aR0uffYI700OEEH4gYnitAnv3vzVGXCFvYfdpu/CJKvk4pHfLPEy/JSZyrpQ+15WhXe1yJRXLtfQ84s4mEXnPg==",
+ "license": "MIT",
+ "dependencies": {
+ "cluster-key-slot": "1.1.2",
+ "generic-pool": "3.9.0",
+ "yallist": "4.0.0"
+ },
+ "engines": {
+ "node": ">=14"
+ }
+ },
+ "node_modules/@redis/graph": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz",
+ "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@redis/client": "^1.0.0"
+ }
+ },
+ "node_modules/@redis/json": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.7.tgz",
+ "integrity": "sha512-6UyXfjVaTBTJtKNG4/9Z8PSpKE6XgSyEb8iwaqDcy+uKrd/DGYHTWkUdnQDyzm727V7p21WUMhsqz5oy65kPcQ==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@redis/client": "^1.0.0"
+ }
+ },
+ "node_modules/@redis/search": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.2.0.tgz",
+ "integrity": "sha512-tYoDBbtqOVigEDMAcTGsRlMycIIjwMCgD8eR2t0NANeQmgK/lvxNAvYyb6bZDD4frHRhIHkJu2TBRvB0ERkOmw==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@redis/client": "^1.0.0"
+ }
+ },
+ "node_modules/@redis/time-series": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.1.0.tgz",
+ "integrity": "sha512-c1Q99M5ljsIuc4YdaCwfUEXsofakb9c8+Zse2qxTadu8TalLXuAESzLvFAvNVbkmSlvlzIQOLpBCmWI9wTOt+g==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@redis/client": "^1.0.0"
+ }
+ },
"node_modules/@rollup/plugin-commonjs": {
"version": "28.0.3",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.3.tgz",
@@ -2156,6 +2218,16 @@
"undici-types": "~6.21.0"
}
},
+ "node_modules/@types/proper-lockfile": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/@types/proper-lockfile/-/proper-lockfile-4.1.4.tgz",
+ "integrity": "sha512-uo2ABllncSqg9F1D4nugVl9v93RmjxF6LJzQLMLDdPaXCUIDPeOJ21Gbqi43xNKzBi/WQ0Q0dICqufzQbMjipQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/retry": "*"
+ }
+ },
"node_modules/@types/resolve": {
"version": "1.20.2",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz",
@@ -2163,6 +2235,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/retry": {
+ "version": "0.12.5",
+ "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.5.tgz",
+ "integrity": "sha512-3xSjTp3v03X/lSQLkczaN9UIEwJMoMCA1+Nb5HfbJEQWogdeQIyVtTvxPXDQjZ5zws8rFQfVfRdz03ARihPJgw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/ssh2": {
"version": "1.15.5",
"resolved": "https://registry.npmjs.org/@types/ssh2/-/ssh2-1.15.5.tgz",
@@ -2832,6 +2911,15 @@
"node": ">=6"
}
},
+ "node_modules/cluster-key-slot": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz",
+ "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/codemirror": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz",
@@ -3624,6 +3712,15 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/generic-pool": {
+ "version": "3.9.0",
+ "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz",
+ "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 4"
+ }
+ },
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
@@ -3663,7 +3760,6 @@
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
- "dev": true,
"license": "ISC"
},
"node_modules/graphemer": {
@@ -4714,6 +4810,17 @@
"node": ">= 0.8.0"
}
},
+ "node_modules/proper-lockfile": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz",
+ "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==",
+ "license": "MIT",
+ "dependencies": {
+ "graceful-fs": "^4.2.4",
+ "retry": "^0.12.0",
+ "signal-exit": "^3.0.2"
+ }
+ },
"node_modules/property-expr": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/property-expr/-/property-expr-2.0.6.tgz",
@@ -4833,6 +4940,23 @@
"url": "https://paulmillr.com/funding/"
}
},
+ "node_modules/redis": {
+ "version": "4.7.0",
+ "resolved": "https://registry.npmjs.org/redis/-/redis-4.7.0.tgz",
+ "integrity": "sha512-zvmkHEAdGMn+hMRXuMBtu4Vo5P6rHQjLoHftu+lBqq8ZTA3RCVC/WzD790bkKKiNFp7d5/9PcSD19fJyyRvOdQ==",
+ "license": "MIT",
+ "workspaces": [
+ "./packages/*"
+ ],
+ "dependencies": {
+ "@redis/bloom": "1.2.0",
+ "@redis/client": "1.6.0",
+ "@redis/graph": "1.1.1",
+ "@redis/json": "1.0.7",
+ "@redis/search": "1.2.0",
+ "@redis/time-series": "1.1.0"
+ }
+ },
"node_modules/regenerator-runtime": {
"version": "0.14.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
@@ -4881,6 +5005,15 @@
"node": ">=4"
}
},
+ "node_modules/retry": {
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz",
+ "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 4"
+ }
+ },
"node_modules/reusify": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz",
@@ -5054,6 +5187,12 @@
"node": ">=8"
}
},
+ "node_modules/signal-exit": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
+ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",
+ "license": "ISC"
+ },
"node_modules/sirv": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.1.tgz",
@@ -5952,6 +6091,12 @@
"node": ">=10"
}
},
+ "node_modules/yallist": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
+ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
+ "license": "ISC"
+ },
"node_modules/yaml": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.1.tgz",
diff --git a/package.json b/package.json
index 472cc6722..8b6e3da52 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
"@types/dockerode": "^3.3.38",
"@types/dockerode-compose": "^1.4.1",
"@types/js-yaml": "^4.0.9",
+ "@types/proper-lockfile": "^4.1.4",
"bits-ui": "^1.3.19",
"clsx": "^2.1.1",
"eslint": "^9.25.1",
@@ -52,6 +53,8 @@
"dockerode-compose": "^1.4.0",
"js-yaml": "^4.1.0",
"nanoid": "^5.1.5",
+ "proper-lockfile": "^4.1.2",
+ "redis": "^4.7.0",
"svelte-codemirror-editor": "^1.4.1"
}
}
diff --git a/src/lib/components/ui/tabs/index.ts b/src/lib/components/ui/tabs/index.ts
new file mode 100644
index 000000000..f1ab372c6
--- /dev/null
+++ b/src/lib/components/ui/tabs/index.ts
@@ -0,0 +1,18 @@
+import { Tabs as TabsPrimitive } from "bits-ui";
+import Content from "./tabs-content.svelte";
+import List from "./tabs-list.svelte";
+import Trigger from "./tabs-trigger.svelte";
+
+const Root = TabsPrimitive.Root;
+
+export {
+ Root,
+ Content,
+ List,
+ Trigger,
+ //
+ Root as Tabs,
+ Content as TabsContent,
+ List as TabsList,
+ Trigger as TabsTrigger,
+};
diff --git a/src/lib/components/ui/tabs/tabs-content.svelte b/src/lib/components/ui/tabs/tabs-content.svelte
new file mode 100644
index 000000000..f1c051570
--- /dev/null
+++ b/src/lib/components/ui/tabs/tabs-content.svelte
@@ -0,0 +1,19 @@
+<script lang="ts">
+ import { Tabs as TabsPrimitive } from "bits-ui";
+ import { cn } from "$lib/utils.js";
+
+ let {
+ ref = $bindable(null),
+ class: className,
+ ...restProps
+ }: TabsPrimitive.ContentProps = $props();
+</script>
+
+<TabsPrimitive.Content
+ bind:ref
+ class={cn(
+ "ring-offset-background focus-visible:ring-ring mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
+ className
+ )}
+ {...restProps}
+/>
diff --git a/src/lib/components/ui/tabs/tabs-list.svelte b/src/lib/components/ui/tabs/tabs-list.svelte
new file mode 100644
index 000000000..f03e5fc73
--- /dev/null
+++ b/src/lib/components/ui/tabs/tabs-list.svelte
@@ -0,0 +1,19 @@
+<script lang="ts">
+ import { Tabs as TabsPrimitive } from "bits-ui";
+ import { cn } from "$lib/utils.js";
+
+ let {
+ ref = $bindable(null),
+ class: className,
+ ...restProps
+ }: TabsPrimitive.ListProps = $props();
+</script>
+
+<TabsPrimitive.List
+ bind:ref
+ class={cn(
+ "bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1",
+ className
+ )}
+ {...restProps}
+/>
diff --git a/src/lib/components/ui/tabs/tabs-trigger.svelte b/src/lib/components/ui/tabs/tabs-trigger.svelte
new file mode 100644
index 000000000..f1f5825ec
--- /dev/null
+++ b/src/lib/components/ui/tabs/tabs-trigger.svelte
@@ -0,0 +1,19 @@
+<script lang="ts">
+ import { Tabs as TabsPrimitive } from "bits-ui";
+ import { cn } from "$lib/utils.js";
+
+ let {
+ ref = $bindable(null),
+ class: className,
+ ...restProps
+ }: TabsPrimitive.TriggerProps = $props();
+</script>
+
+<TabsPrimitive.Trigger
+ bind:ref
+ class={cn(
+ "ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm",
+ className
+ )}
+ {...restProps}
+/>
diff --git a/src/lib/services/compose.ts b/src/lib/services/compose.ts
index 6b45658a4..4bbec96cc 100644
--- a/src/lib/services/compose.ts
+++ b/src/lib/services/compose.ts
@@ -10,83 +10,86 @@ import type {
StackUpdate,
} from "$lib/types/stack";
import yaml from "js-yaml";
+import { getSettings, ensureStacksDirectory } from "./settings-service";
-let STACKS_DIR = process.env.STACKS_DIR || join("/app/data/stacks");
+// This will be populated on initialization
+let STACKS_DIR = "";
/**
- * Update the stacks directory path
+ * Initialize the compose service with settings
+ * This should be called at app startup
+ */
+export async function initComposeService(): Promise<void> {
+ try {
+ // Get settings to initialize the stacks directory
+ const settings = await getSettings();
+ STACKS_DIR = settings.stacksDirectory;
+ console.log(`Stacks directory initialized: ${STACKS_DIR}`);
+
+ // Ensure the directory exists
+ await ensureStacksDir();
+ } catch (err) {
+ console.error("Error initializing compose service:", err);
+ // We'll initialize again when needed in other functions
+ }
+}
+
+/**
+ * Update the stacks directory path - used when settings are updated
* @param {string} directory New stacks directory path
*/
export function updateStacksDirectory(directory: string): void {
if (directory) {
STACKS_DIR = directory;
console.log(`Stacks directory updated to: ${STACKS_DIR}`);
- // No need to re-initialize anything here since
- // each function call will use the updated STACKS_DIR
}
}
/**
- * Ensure stacks directory exists
+ * Ensure stacks directory exists and return the path
*/
-async function ensureStacksDir(): Promise<void> {
+async function ensureStacksDir(): Promise<string> {
try {
- await fs.mkdir(STACKS_DIR, { recursive: true });
+ // If STACKS_DIR is empty, initialize from settings
+ if (!STACKS_DIR) {
+ // Get from settings service
+ STACKS_DIR = await ensureStacksDirectory();
+ } else {
+ // Just ensure the directory exists
+ await fs.mkdir(STACKS_DIR, { recursive: true });
+ }
+ return STACKS_DIR;
} catch (err) {
console.error("Error creating stacks directory:", err);
throw new Error("Failed to create stacks storage directory");
}
}
-/**
- * Initialize the compose service with settings
- * This should be called at app startup
- */
-export async function initComposeService(): Promise<void> {
- try {
- // Update settings path to match the new location
- const settingsPath = join("/app/data/app-settings.json");
- const settingsData = await fs
- .readFile(settingsPath, "utf8")
- .catch(() => "{}");
- const settings = JSON.parse(settingsData);
-
- if (settings.stacksDirectory) {
- STACKS_DIR = settings.stacksDirectory;
- console.log(`Stacks directory initialized from settings: ${STACKS_DIR}`);
- }
-
- // Ensure the directory exists
- await ensureStacksDir();
- } catch (err) {
- console.error("Error initializing compose service:", err);
- // Fall back to default directory and ensure it exists
- await ensureStacksDir();
- }
-}
-
/**
* Get stack directory path
* @param {string} stackId
*/
-function getStackDir(stackId: string): string {
- return join(STACKS_DIR, stackId);
+async function getStackDir(stackId: string): Promise<string> {
+ const stacksDir = await ensureStacksDir();
+ return join(stacksDir, stackId);
}
/**
* Get compose file path
* @param {string} stackId
*/
-function getComposeFilePath(stackId: string): string {
- return join(getStackDir(stackId), "docker-compose.yml");
+async function getComposeFilePath(stackId: string): Promise<string> {
+ const stackDir = await getStackDir(stackId);
+ return join(stackDir, "docker-compose.yml");
}
/**
* Get stack metadata file path
* @param {string} stackId
*/
-function getStackMetaPath(stackId: string): string {
- return join(getStackDir(stackId), "meta.json");
+async function getStackMetaPath(stackId: string): Promise<string> {
+ const stackDir = await getStackDir(stackId);
+ return join(stackDir, "meta.json");
}
/**
@@ -95,8 +98,7 @@ function getStackMetaPath(stackId: string): string {
*/
async function getComposeInstance(stackId: string): Promise<DockerodeCompose> {
const docker = getDockerClient();
- const composePath = getComposeFilePath(stackId);
- // The third parameter is the project name, used as namespace for containers
+ const composePath = await getComposeFilePath(stackId);
return new DockerodeCompose(docker, composePath, stackId);
}
@@ -197,16 +199,16 @@ async function getStackServices(
* @returns {Promise<Array<Stack>>} List of stacks
*/
export async function loadComposeStacks(): Promise<Stack[]> {
- await ensureStacksDir();
+ const stacksDir = await ensureStacksDir();
try {
- const stackDirs = await fs.readdir(STACKS_DIR);
+ const stackDirs = await fs.readdir(stacksDir);
const stacks: Stack[] = [];
for (const dir of stackDirs) {
try {
- const metaPath = getStackMetaPath(dir);
- const composePath = getComposeFilePath(dir);
+ const metaPath = await getStackMetaPath(dir);
+ const composePath = await getComposeFilePath(dir);
const [metaContent, composeContent] = await Promise.all([
fs.readFile(metaPath, "utf8"),
@@ -256,8 +258,8 @@ export async function loadComposeStacks(): Promise<Stack[]> {
*/
export async function getStack(stackId: string): Promise<Stack> {
try {
- const metaPath = getStackMetaPath(stackId);
- const composePath = getComposeFilePath(stackId);
+ const metaPath = await getStackMetaPath(stackId);
+ const composePath = await getComposeFilePath(stackId);
const [metaContent, composeContent] = await Promise.all([
fs.readFile(metaPath, "utf8"),
@@ -308,12 +310,9 @@ export async function createStack(
name: string,
composeContent: string
): Promise<Stack> {
- await ensureStacksDir();
-
- const id = nanoid();
- const stackDir = getStackDir(id);
- const composePath = getComposeFilePath(id);
- const metaPath = getStackMetaPath(id);
+ const stackDir = await getStackDir(nanoid());
+ const composePath = join(stackDir, "docker-compose.yml");
+ const metaPath = join(stackDir, "meta.json");
const meta: StackMeta = {
name,
@@ -329,7 +328,7 @@ export async function createStack(
]);
return {
- id,
+ id: nanoid(),
name: meta.name,
serviceCount: 0,
runningCount: 0,
@@ -352,8 +351,8 @@ export async function updateStack(
stackId: string,
updates: StackUpdate
): Promise<Stack> {
- const metaPath = getStackMetaPath(stackId);
- const composePath = getComposeFilePath(stackId);
+ const metaPath = await getStackMetaPath(stackId);
+ const composePath = await getComposeFilePath(stackId);
try {
// Read existing meta
@@ -471,7 +470,7 @@ export async function removeStack(stackId: string): Promise<boolean> {
await compose.down();
// Then delete the stack files
- const stackDir = getStackDir(stackId);
+ const stackDir = await getStackDir(stackId);
await fs.rm(stackDir, { recursive: true, force: true });
return true;
@@ -524,7 +523,7 @@ export async function discoverExternalStacks(): Promise<Stack[]> {
for (const [projectName, services] of Object.entries(projectMap)) {
// Check if this stack is already in our managed stacks
- const stackDir = getStackDir(projectName);
+ const stackDir = await getStackDir(projectName);
try {
await fs.access(stackDir);
// Stack is managed by Arcane, skip it
diff --git a/src/lib/services/settings-service.ts b/src/lib/services/settings-service.ts
index 1064e24d9..99cb2919c 100644
--- a/src/lib/services/settings-service.ts
+++ b/src/lib/services/settings-service.ts
@@ -1,72 +1,253 @@
-import type { SettingsData } from "$lib/types/settings";
-import { updateStacksDirectory } from "./compose";
-import { updateDockerConnection } from "./docker-service";
import fs from "fs/promises";
import path from "path";
+import proper from "proper-lockfile";
+import type { SettingsData } from "$lib/types/settings";
+
+// Determine if we're in development or production
+const isDev = process.env.NODE_ENV === "development";
+
+// Configure paths based on environment
+const BASE_PATH = isDev
+ ? path.resolve(process.cwd(), ".dev-data")
+ : "/app/data";
-// Update the settings file path to be in /app/data directory
-const SETTINGS_FILE = path.resolve("/app/data/app-settings.json");
+const SETTINGS_FILE = path.join(BASE_PATH, "app-settings.json");
+const SETTINGS_FOLDER = path.join(BASE_PATH, "settings");
-// Default settings
-const DEFAULT_SETTINGS: SettingsData = {
- dockerHost: "unix:///var/run/docker.sock",
- autoRefresh: true,
- refreshInterval: 10,
- darkMode: true,
- stacksDirectory: path.resolve("/app/data/stacks"),
+// Default settings - also adapt paths for development environment
+export const DEFAULT_SETTINGS: SettingsData = {
+ dockerHost: isDev
+ ? process.platform === "win32"
+ ? "npipe:////./pipe/docker_engine"
+ : "unix:///var/run/docker.sock"
+ : "unix:///var/run/docker.sock",
+ autoUpdate: false,
+ pollingEnabled: true,
+ pollingInterval: 10,
+ stacksDirectory: path.resolve(BASE_PATH, "stacks"),
+ externalServices: {
+ valkey: {
+ enabled: false,
+ host: "localhost",
+ port: 6379,
+ username: "",
+ password: "",
+ keyPrefix: "arcane:settings:",
+ },
+ },
};
-// Get settings
+// Path getter functions
+export function getBasePath(): string {
+ return BASE_PATH;
+}
+
+export function getSettingsFilePath(): string {
+ return SETTINGS_FILE;
+}
+
+export function getStacksDirectory(): string {
+ return DEFAULT_SETTINGS.stacksDirectory;
+}
+
+// Log configured paths on startup
+console.log(`Settings service configured with:
+- Environment: ${isDev ? "Development" : "Production"}
+- Settings file: ${SETTINGS_FILE}
+- Settings folder: ${SETTINGS_FOLDER}
+- Default stacks directory: ${DEFAULT_SETTINGS.stacksDirectory}
+`);
+
+// Make sure directories exist
+async function ensureDirs() {
+ await fs.mkdir(path.dirname(SETTINGS_FILE), { recursive: true });
+ await fs.mkdir(SETTINGS_FOLDER, { recursive: true });
+}
+
+/**
+ * Create stacks directory if it doesn't exist
+ */
+export async function ensureStacksDirectory(): Promise<string> {
+ try {
+ const settings = await getSettings();
+ const stacksDir = settings.stacksDirectory;
+
+ await fs.mkdir(stacksDir, { recursive: true });
+ return stacksDir;
+ } catch (err) {
+ console.error("Error ensuring stacks directory:", err);
+ // Fall back to default
+ try {
+ await fs.mkdir(DEFAULT_SETTINGS.stacksDirectory, { recursive: true });
+ return DEFAULT_SETTINGS.stacksDirectory;
+ } catch (innerErr) {
+ console.error("Failed to create default stacks directory:", innerErr);
+ throw new Error("Unable to create stacks directory");
+ }
+ }
+}
+
+// Save a setting to its own file
+async function saveSetting(key: string, value: any): Promise<void> {
+ const filePath = path.join(SETTINGS_FOLDER, `${key}.json`);
+
+ // Make sure the directory exists
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
+
+ try {
+ // Create the file if it doesn't exist
+ try {
+ await fs.access(filePath);
+ } catch {
+ await fs.writeFile(filePath, "{}");
+ }
+
+ // Acquire a lock
+ const release = await proper.lock(filePath, { retries: 5 });
+
+ try {
+ await fs.writeFile(filePath, JSON.stringify(value));
+ } finally {
+ // Release the lock
+ await release();
+ }
+ } catch (error) {
+ console.error(`Error saving setting ${key}:`, error);
+ throw error;
+ }
+}
+
+// Get a setting from its own file
+async function getSetting(key: string): Promise<any | null> {
+ const filePath = path.join(SETTINGS_FOLDER, `${key}.json`);
+
+ try {
+ const data = await fs.readFile(filePath, "utf-8");
+ return JSON.parse(data);
+ } catch (error) {
+ return null;
+ }
+}
+
+// Get all settings
export async function getSettings(): Promise<SettingsData> {
try {
- const settingsDir = path.dirname(SETTINGS_FILE);
- await fs.mkdir(settingsDir, { recursive: true });
+ await ensureDirs();
- const data = await fs.readFile(SETTINGS_FILE, "utf-8").catch(() => {
- console.log("Settings file not found, using defaults.");
- return JSON.stringify(DEFAULT_SETTINGS);
- });
+ // Try to load the main settings file first (as override)
+ let fileSettings: Partial<SettingsData> = {};
+ try {
+ const data = await fs.readFile(SETTINGS_FILE, "utf-8");
+ fileSettings = JSON.parse(data);
- const settings = { ...DEFAULT_SETTINGS, ...JSON.parse(data) };
+ // If in development and paths are production paths, convert them
+ if (isDev) {
+ // Convert any absolute /app/data paths to local development paths
+ if (
+ fileSettings.stacksDirectory &&
+ fileSettings.stacksDirectory.startsWith("/app/data")
+ ) {
+ fileSettings.stacksDirectory = fileSettings.stacksDirectory.replace(
+ "/app/data",
+ BASE_PATH
+ );
+ }
+ }
+ } catch (error) {
+ console.log("No main settings file found");
+ }
- // Don't try to update Docker connection during build time
- if (process.env.NODE_ENV !== "build") {
- await saveSettings(settings, false); // Don't update connections during initialization
+ // Load individual settings
+ const individualSettings: Record<string, any> = {};
+ try {
+ const files = await fs.readdir(SETTINGS_FOLDER);
+ for (const file of files) {
+ if (file.endsWith(".json")) {
+ const key = file.replace(".json", "");
+ const value = await getSetting(key);
+ if (value !== null) {
+ individualSettings[key] = value;
+ }
+ }
+ }
+ } catch (error) {
+ console.error("Error reading individual settings:", error);
}
- return settings;
+ // Merge in order: defaults < individual < file
+ const mergedSettings = {
+ ...DEFAULT_SETTINGS,
+ ...individualSettings,
+ ...fileSettings,
+ };
+
+ // Ensure stacks directory exists
+ await fs.mkdir(mergedSettings.stacksDirectory, { recursive: true });
+
+ return mergedSettings;
} catch (error) {
console.error("Error loading settings:", error);
return DEFAULT_SETTINGS;
}
}
-// Save settings
-export async function saveSettings(
- settings: SettingsData,
- updateConnections = true
-): Promise<void> {
+// Save all settings
+export async function saveSettings(settings: SettingsData): Promise<void> {
+ await ensureDirs();
+
try {
- // Ensure directory exists
- const settingsDir = path.dirname(SETTINGS_FILE);
- await fs.mkdir(settingsDir, { recursive: true });
-
- // Write the settings
- await fs.writeFile(
- SETTINGS_FILE,
- JSON.stringify(settings, null, 2),
- "utf-8"
- );
-
- console.log("Settings saved to:", SETTINGS_FILE);
-
- // Apply settings to runtime services - but skip during builds or initial loading
- if (updateConnections && process.env.NODE_ENV !== "build") {
- updateDockerConnection(settings.dockerHost);
- updateStacksDirectory(settings.stacksDirectory);
+ // In development mode, ensure paths are relative to the current environment
+ let settingsToSave = { ...settings };
+
+ // If we're in development and the stacks directory is still a production path
+ if (isDev && settingsToSave.stacksDirectory?.startsWith("/app/data")) {
+ settingsToSave.stacksDirectory = settingsToSave.stacksDirectory.replace(
+ "/app/data",
+ BASE_PATH
+ );
+ }
+
+ // Save each setting to its own file for granular access
+ const flatSettings = flattenObject(settingsToSave);
+ for (const [key, value] of Object.entries(flatSettings)) {
+ await saveSetting(key, value);
}
+
+ // Also save the complete settings as a snapshot
+ await fs.writeFile(SETTINGS_FILE, JSON.stringify(settingsToSave, null, 2));
+
+ // Ensure the stacks directory exists
+ await fs.mkdir(settingsToSave.stacksDirectory, { recursive: true });
+
+ console.log("Settings saved successfully");
} catch (error) {
console.error("Error saving settings:", error);
- throw new Error("Failed to save settings.");
+ throw new Error("Failed to save settings");
+ }
+}
+
+// Helper function to flatten nested objects
+function flattenObject(obj: any, prefix = ""): Record<string, any> {
+ return Object.keys(obj).reduce((acc: Record<string, any>, k: string) => {
+ const pre = prefix.length ? `${prefix}.` : "";
+ if (
+ typeof obj[k] === "object" &&
+ obj[k] !== null &&
+ !Array.isArray(obj[k])
+ ) {
+ Object.assign(acc, flattenObject(obj[k], `${pre}${k}`));
+ } else {
+ acc[`${pre}${k}`] = obj[k];
+ }
+ return acc;
+ }, {});
+}
+
+// Helper to parse JSON values
+function tryParse(value: string): any {
+ try {
+ return JSON.parse(value);
+ } catch {
+ return value;
}
}
diff --git a/src/lib/services/valkey-service.ts b/src/lib/services/valkey-service.ts
new file mode 100644
index 000000000..9320c4e48
--- /dev/null
+++ b/src/lib/services/valkey-service.ts
@@ -0,0 +1,151 @@
+import { createClient, type RedisClientType } from "redis";
+import { getSettings } from "./settings-service";
+
+let client: RedisClientType | null = null;
+let isConnected = false;
+
+type ValKeyConfig = {
+ host: string;
+ port: number;
+ password?: string;
+ username?: string;
+};
+
+const DEFAULT_CONFIG: ValKeyConfig = {
+ host: "localhost",
+ port: 6379,
+};
+
+/**
+ * Initialize the Valkey client connection
+ */
+export async function initValKeyClient(
+ config: ValKeyConfig = DEFAULT_CONFIG
+): Promise<void> {
+ try {
+ // Close any existing connection
+ if (client) {
+ await client.quit();
+ isConnected = false;
+ }
+
+ // Create connection URL
+ const url = `redis://${
+ config.username ? `${config.username}:${config.password}@` : ""
+ }${config.host}:${config.port}`;
+
+ client = createClient({
+ url,
+ socket: {
+ reconnectStrategy: (retries: number): number =>
+ Math.min(retries * 50, 1000),
+ },
+ });
+
+ client.on("error", (err: Error) => {
+ console.error("Valkey/Redis Client Error:", err);
+ isConnected = false;
+ });
+
+ client.on("connect", () => {
+ console.log("Connected to Valkey/Redis server");
+ isConnected = true;
+ });
+
+ await client.connect();
+ } catch (error) {
+ console.error("Failed to initialize Valkey connection:", error);
+ isConnected = false;
+ }
+}
+
+/**
+ * Initialize Valkey client based on application settings
+ */
+export async function initValKeyFromSettings(): Promise<boolean> {
+ try {
+ const settings = await getSettings();
+
+ // If Valkey is not enabled in settings, return false
+ if (!settings.externalServices?.valkey?.enabled) {
+ return false;
+ }
+
+ const valkeySettings = settings.externalServices.valkey;
+
+ await initValKeyClient({
+ host: valkeySettings.host,
+ port: valkeySettings.port,
+ username: valkeySettings.username,
+ password: valkeySettings.password,
+ });
+
+ return isConnected;
+ } catch (error) {
+ console.error("Failed to initialize Valkey from settings:", error);
+ return false;
+ }
+}
+
+/**
+ * Check if the client is connected
+ */
+export function isValKeyConnected(): boolean {
+ return isConnected && client !== null;
+}
+
+/**
+ * Get a value from Valkey
+ */
+export async function getValue(key: string): Promise<string | null> {
+ if (!isConnected || !client) return null;
+
+ try {
+ return await client.get(key);
+ } catch (error) {
+ console.error(`Error retrieving key ${key} from Valkey:`, error);
+ return null;
+ }
+}
+
+/**
+ * Set a value in Valkey
+ */
+export async function setValue(key: string, value: string): Promise<boolean> {
+ if (!isConnected || !client) return false;
+
+ try {
+ await client.set(key, value);
+ return true;
+ } catch (error) {
+ console.error(`Error setting key ${key} in Valkey:`, error);
+ return false;
+ }
+}
+
+/**
+ * Get all values matching a pattern
+ */
+export async function getKeysValues(
+ pattern: string
+): Promise<Record<string, string>> {
+ if (!isConnected || !client) return {};
+
+ try {
+ const keys = await client.keys(pattern);
+ const result: Record<string, string> = {};
+
+ for (const key of keys) {
+ const value = await client.get(key);
+ if (value) result[key] = value;
+ }
+
+ return result;
+ } catch (error) {
+ console.error(
+ `Error retrieving keys matching ${pattern} from Valkey:`,
+ error
+ );
+ return {};
+ }
+}
diff --git a/src/lib/types/settings.ts b/src/lib/types/settings.ts
index d8602bf2b..d7b968522 100644
--- a/src/lib/types/settings.ts
+++ b/src/lib/types/settings.ts
@@ -1,7 +1,23 @@
-export type SettingsData = {
+export interface SettingsData {
dockerHost: string;
- autoRefresh: boolean;
- refreshInterval: number;
- darkMode: boolean;
+ autoUpdate: boolean;
+ pollingEnabled: boolean;
+ pollingInterval: number;
stacksDirectory: string;
-};
+ registryCredentials?: Array<{
+ url: string;
+ username: string;
+ password: string;
+ }>;
+ externalServices: {
+ valkey?: {
+ enabled: boolean;
+ host: string;
+ port: number;
+ username?: string;
+ password?: string;
+ keyPrefix: string;
+ };
+ // Other services can be added here in the future
+ };
+}
diff --git a/src/routes/settings/+page.server.ts b/src/routes/settings/+page.server.ts
index 33c1620eb..8efd49690 100644
--- a/src/routes/settings/+page.server.ts
+++ b/src/routes/settings/+page.server.ts
@@ -6,7 +6,6 @@ import type { SettingsData } from "$lib/types/settings";
export const load: PageServerLoad = async ({ locals }) => {
const settings = await getSettings();
- // Generate a CSRF token
const csrf = crypto.randomUUID();
return {
@@ -17,48 +16,97 @@ export const load: PageServerLoad = async ({ locals }) => {
export const actions: Actions = {
default: async ({ request }) => {
- const formData = await request.formData();
+ let formData = new FormData();
+ try {
+ formData = await request.formData();
+ const settings = await getSettings();
- const dockerHost = formData.get("dockerHost") as string;
- const autoRefresh = formData.get("autoRefresh") === "on";
- const refreshIntervalStr = formData.get("refreshInterval") as string;
- const darkMode = formData.get("darkMode") === "on";
- const stacksDirectory = (formData.get("stacksDirectory") as string) || "";
+ // Get all form values
+ const dockerHost = formData.get("dockerHost") as string;
- if (!dockerHost) {
- return fail(400, {
- error: "Docker host cannot be empty.",
- values: Object.fromEntries(formData),
- });
- }
+ // Explicitly check for the "on" value for both toggle switches
+ const autoUpdate = formData.get("autoUpdate") === "on";
+ const pollingEnabled = formData.get("pollingEnabled") === "on";
- let refreshInterval = parseInt(refreshIntervalStr, 10);
- if (isNaN(refreshInterval) || refreshInterval < 5 || refreshInterval > 60) {
- return fail(400, {
- error: "Refresh interval must be between 5 and 60 seconds.",
- values: Object.fromEntries(formData),
- });
- }
+ const pollingIntervalStr = formData.get("pollingInterval") as string;
+ const stacksDirectory = (formData.get("stacksDirectory") as string) || "";
- if (!stacksDirectory) {
- return fail(400, {
- error: "Stacks directory cannot be empty.",
- values: Object.fromEntries(formData),
+ // Add logging to debug form values
+ console.log("Form data received:", {
+ dockerHost,
+ autoUpdate: formData.get("autoUpdate"),
+ pollingEnabled: formData.get("pollingEnabled"),
+ pollingInterval: pollingIntervalStr,
});
- }
- const updatedSettings: SettingsData = {
- dockerHost,
- autoRefresh,
- refreshInterval,
- darkMode,
- stacksDirectory,
- };
+ if (!dockerHost) {
+ return fail(400, {
+ error: "Docker host cannot be empty.",
+ values: Object.fromEntries(formData),
+ });
+ }
- try {
+ if (!stacksDirectory) {
+ return fail(400, {
+ error: "Stacks directory cannot be empty.",
+ values: Object.fromEntries(formData),
+ });
+ }
+
+ // Process polling interval only if polling is enabled
+ let pollingInterval = settings.pollingInterval || 10;
+ if (pollingEnabled) {
+ const parsedInterval = parseInt(pollingIntervalStr, 10);
+ if (
+ !isNaN(parsedInterval) &&
+ parsedInterval >= 5 &&
+ parsedInterval <= 60
+ ) {
+ pollingInterval = parsedInterval;
+ } else if (pollingIntervalStr) {
+ // Only show error if the user actually entered a value
+ return fail(400, {
+ error: "Polling interval must be between 5 and 60 minutes.",
+ values: {
+ ...Object.fromEntries(formData),
+ pollingEnabled: "on", // Make sure we retain the enabled state
+ autoUpdate: formData.get("autoUpdate"), // Preserve autoUpdate state as well
+ },
+ });
+ }
+ }
+
+ // Extract Valkey settings
+ const valkeyEnabled = formData.get("valkeyEnabled") === "on";
+ const externalServices = {
+ ...settings.externalServices,
+ valkey: {
+ enabled: valkeyEnabled,
+ host: formData.get("valkeyHost")?.toString() || "localhost",
+ port: parseInt(formData.get("valkeyPort")?.toString() || "6379", 10),
+ username: formData.get("valkeyUsername")?.toString() || "",
+ password: formData.get("valkeyPassword")?.toString() || "",
+ keyPrefix:
+ formData.get("valkeyKeyPrefix")?.toString() || "arcane:settings:",
+ },
+ };
+
+ const updatedSettings: SettingsData = {
+ ...settings,
+ dockerHost,
+ autoUpdate,
+ pollingEnabled,
+ pollingInterval,
+ stacksDirectory,
+ externalServices,
+ };
+
+ // Save updated settings
await saveSettings(updatedSettings);
- return { success: true, settings: updatedSettings };
+
+ return { success: true };
} catch (error: any) {
+ console.error("Error updating settings:", error);
return fail(500, {
error: error.message || "Failed to save settings.",
values: Object.fromEntries(formData),
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte
index bfefc8e13..53c4d6ad6 100644
--- a/src/routes/settings/+page.svelte
+++ b/src/routes/settings/+page.svelte
@@ -1,19 +1,16 @@
<script lang="ts">
import { run } from "svelte/legacy";
-
import { enhance } from "$app/forms";
- import * as Form from "$lib/components/ui/form/index.js";
- import * as Card from "$lib/components/ui/card/index.js";
+ import * as Tabs from "$lib/components/ui/tabs/index.js";
import { Button } from "$lib/components/ui/button/index.js";
- import { Input } from "$lib/components/ui/input/index.js";
- import { Switch } from "$lib/components/ui/switch/index.js";
- import { Separator } from "$lib/components/ui/separator/index.js";
import { Save, RefreshCw } from "@lucide/svelte";
import type { ActionData, PageData } from "./$types";
import { toast } from "svelte-sonner";
- import * as Alert from "$lib/components/ui/alert/index.js";
- import { AlertCircle } from "@lucide/svelte";
- import { onMount } from "svelte";
+ import AppSettings from "./tabs/app-settings.svelte";
+ import UserManagement from "./tabs/user-management.svelte";
+ import Authentication from "./tabs/authentication.svelte";
+ import RbacSettings from "./tabs/rbac-settings.svelte";
+ import ExternalServices from "./tabs/external-services.svelte";
interface Props {
data: PageData;
@@ -22,34 +19,31 @@
let { data, form }: Props = $props();
- let settings = $derived(data.settings);
-
+ // Track active tab
+ let activeTab = $state("app-settings");
let saving = $state(false);
- // Update form values from form.values if there was an error, otherwise from settings
- let dockerHost = $derived(
- form?.values?.dockerHost || settings?.dockerHost || ""
- );
- let autoRefresh = $derived(
- form?.values?.autoRefresh !== undefined
- ? form.values.autoRefresh === "on"
- : settings?.autoRefresh || false
- );
- let refreshInterval = $derived(
- form?.values?.refreshInterval !== undefined
- ? form.values.refreshInterval
- : settings?.refreshInterval || 10
- );
- let darkMode = $derived(
- form?.values?.darkMode !== undefined
- ? form.values.darkMode === "on"
- : settings?.darkMode || false
- );
- let stacksDirectory = $derived(
- form?.values?.stacksDirectory || settings?.stacksDirectory || ""
- );
+ // Keep the tab IDs consistent with the trigger values
+ const tabs = [
+ { id: "app-settings", label: "General", component: AppSettings },
+ {
+ id: "user-management",
+ label: "User Management",
+ component: UserManagement,
+ },
+ {
+ id: "authentication",
+ label: "Authentication",
+ component: Authentication,
+ },
+ { id: "rbac", label: "RBAC", component: RbacSettings },
+ {
+ id: "external-services",
+ label: "External Services",
+ component: ExternalServices,
+ },
+ ];
- // Handle form submission result
run(() => {
if (form?.success) {
toast.success("Settings saved successfully");
@@ -57,10 +51,6 @@
toast.error(form.error);
}
});
-
- onMount(() => {
- // Any initialization needed
- });
</script>
<div class="space-y-6">
@@ -69,9 +59,10 @@
<div>
<h1 class="text-3xl font-bold tracking-tight">Settings</h1>
<p class="text-sm text-muted-foreground mt-1">
- Configure Arcane's connection and behavior
+ Configure Arcane's settings and permissions
</p>
</div>
+
<Button type="submit" form="settings-form" disabled={saving} class="h-10">
{#if saving}
<RefreshCw class="mr-2 h-4 w-4 animate-spin" />
@@ -83,204 +74,44 @@
</Button>
</div>
- <!-- Alerts -->
- {#if form?.error}
- <Alert.Root variant="destructive">
- <AlertCircle class="h-4 w-4 mr-2" />
- <Alert.Title>Error Saving Settings</Alert.Title>
- <Alert.Description>{form.error}</Alert.Description>
- </Alert.Root>
- {/if}
-
- {#if form?.success}
- <Alert.Root
- variant="default"
- class="bg-primary/10 text-primary border border-primary"
- >
- <AlertCircle class="h-4 w-4 mr-2" />
- <Alert.Title>Settings Saved</Alert.Title>
- <Alert.Description
- >Your settings have been updated successfully.</Alert.Description
- >
- </Alert.Root>
- {/if}
-
- <!-- Settings Form -->
- <form
- method="POST"
- action="?"
- id="settings-form"
- class="space-y-6"
- use:enhance={() => {
- saving = true;
- return async ({ update }) => {
- saving = false;
- await update();
- };
- }}
+ <!-- Tabs Navigation -->
+ <Tabs.Root
+ value={activeTab}
+ onValueChange={(val) => (activeTab = val)}
+ class="w-full"
>
- <!-- Add a hidden input with a CSRF token -->
- <input type="hidden" name="csrf_token" value={data.csrf} />
-
- <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
- <!-- Docker Connection Card -->
- <Card.Root class="border shadow-sm">
- <Card.Header class="pb-3">
- <div class="flex items-center gap-2">
- <div class="bg-blue-500/10 p-2 rounded-full">
- <Save class="h-5 w-5 text-blue-500" />
- </div>
- <div>
- <Card.Title>Docker Settings</Card.Title>
- <Card.Description
- >Configure your Docker connection</Card.Description
- >
- </div>
- </div>
- </Card.Header>
- <Card.Content>
- <div class="space-y-4">
- <!-- Fix Form.Field to use the correct component structure -->
- <div class="space-y-2">
- <label for="dockerHost" class="text-sm font-medium"
- >Docker Host</label
- >
- <Input
- type="text"
- id="dockerHost"
- name="dockerHost"
- bind:value={dockerHost}
- placeholder="unix:///var/run/docker.sock"
- required
- />
- <p class="text-xs text-muted-foreground">
- For local Docker: unix:///var/run/docker.sock (Unix) or
- npipe:////./pipe/docker_engine (Windows)
- </p>
- </div>
-
- <!-- Add this block for stacks directory with correct structure -->
- <div class="space-y-2">
- <label for="stacksDirectory" class="text-sm font-medium"
- >Stacks Directory</label
- >
- <Input
- type="text"
- id="stacksDirectory"
- name="stacksDirectory"
- bind:value={stacksDirectory}
- placeholder="/app/data/stacks"
- required
- />
- <p class="text-xs text-muted-foreground">
- Directory where Docker Compose stacks will be stored inside the
- container.
- </p>
- <p class="text-xs font-bold text-destructive">
- Changing this setting will not move existing stacks!
- </p>
- </div>
- </div>
- </Card.Content>
- </Card.Root>
-
- <!-- Application Settings Card -->
- <div class="space-y-6">
- <!-- Auto Refresh Settings Card -->
- <Card.Root class="border shadow-sm">
- <Card.Header class="pb-3">
- <div class="flex items-center gap-2">
- <div class="bg-amber-500/10 p-2 rounded-full">
- <RefreshCw class="h-5 w-5 text-amber-500" />
- </div>
- <div>
- <Card.Title>Auto Refresh</Card.Title>
- <Card.Description
- >Control data refresh behavior</Card.Description
- >
- </div>
- </div>
- </Card.Header>
- <Card.Content class="space-y-6">
- <div
- class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
- >
- <div class="space-y-0.5">
- <label for="autoRefreshSwitch" class="text-base font-medium"
- >Auto Refresh</label
- >
- <p class="text-sm text-muted-foreground">
- Automatically refresh data periodically
- </p>
- </div>
- <Switch
- id="autoRefreshSwitch"
- name="autoRefresh"
- bind:checked={autoRefresh}
- />
- </div>
-
- {#if autoRefresh}
- <div class="space-y-2 px-1">
- <label for="refreshInterval" class="text-sm font-medium">
- Refresh Interval (seconds)
- </label>
- <Input
- id="refreshInterval"
- name="refreshInterval"
- type="number"
- bind:value={refreshInterval}
- min="5"
- max="60"
- />
- {#if form?.error && form.values?.refreshInterval && (parseInt(String(form.values.refreshInterval), 10) < 5 || parseInt(String(form.values.refreshInterval), 10) > 60)}
- <p class="text-sm text-destructive">
- Must be between 5 and 60.
- </p>
- {:else}
- <p class="text-xs text-muted-foreground">
- Set between 5-60 seconds. Lower values increase server load.
- </p>
- {/if}
- </div>
- {/if}
- </Card.Content>
- </Card.Root>
-
- <!-- UI Settings Card -->
- <Card.Root class="border shadow-sm">
- <Card.Header class="pb-3">
- <div class="flex items-center gap-2">
- <div class="bg-purple-500/10 p-2 rounded-full">
- <Save class="h-5 w-5 text-purple-500" />
- </div>
- <div>
- <Card.Title>UI Settings</Card.Title>
- <Card.Description>Customize the appearance</Card.Description>
- </div>
- </div>
- </Card.Header>
- <Card.Content>
- <div
- class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
- >
- <div class="space-y-0.5">
- <label for="darkModeSwitch" class="text-base font-medium"
- >Dark Mode</label
- >
- <p class="text-sm text-muted-foreground">
- Enable the dark color theme
- </p>
- </div>
- <Switch
- id="darkModeSwitch"
- name="darkMode"
- bind:checked={darkMode}
- />
- </div>
- </Card.Content>
- </Card.Root>
- </div>
- </div>
- </form>
+ <Tabs.List
+ class="grid grid-cols-5 sm:grid-cols-5 md:w-full md:max-w-3xl mb-4"
+ >
+ {#each tabs as tab}
+ <Tabs.Trigger value={tab.id} class="whitespace-nowrap">
+ {tab.label}
+ </Tabs.Trigger>
+ {/each}
+ </Tabs.List>
+
+ <!-- Tab Contents -->
+ <form
+ method="POST"
+ action="?"
+ id="settings-form"
+ class="space-y-6"
+ use:enhance={() => {
+ saving = true;
+ return async ({ update }) => {
+ saving = false;
+ await update();
+ };
+ }}
+ >
+ <!-- Add a hidden input with a CSRF token -->
+ <input type="hidden" name="csrf_token" value={data.csrf} />
+
+ {#each tabs as tab}
+ <Tabs.Content value={tab.id} class="space-y-4">
+ <svelte:component this={tab.component} {data} {form} />
+ </Tabs.Content>
+ {/each}
+ </form>
+ </Tabs.Root>
</div>
diff --git a/src/routes/settings/tabs/app-settings.svelte b/src/routes/settings/tabs/app-settings.svelte
new file mode 100644
index 000000000..3c5b074b5
--- /dev/null
+++ b/src/routes/settings/tabs/app-settings.svelte
@@ -0,0 +1,314 @@
+<script lang="ts">
+ import * as Card from "$lib/components/ui/card/index.js";
+ import { Input } from "$lib/components/ui/input/index.js";
+ import { Switch } from "$lib/components/ui/switch/index.js";
+ import { Save, RefreshCw, Key, Plus, Trash2 } from "@lucide/svelte";
+ import type { ActionData, PageData } from "../$types";
+
+ let { data, form } = $props<{ data: PageData; form: ActionData }>();
+
+ let settings = $derived(data.settings);
+
+ // Update form values from form.values if there was an error, otherwise from settings
+ let dockerHost = $derived(
+ form?.values?.dockerHost || settings?.dockerHost || ""
+ );
+
+ // Make sure the pollingEnabled variable comes from settings.pollingEnabled
+ let pollingEnabled = $derived(
+ form?.values?.pollingEnabled !== undefined
+ ? form.values.pollingEnabled === "on"
+ : settings?.pollingEnabled || false
+ );
+
+ // Rename to pollingInterval to be consistent
+ let pollingInterval = $derived(
+ form?.values?.pollingInterval !== undefined
+ ? form.values.pollingInterval
+ : settings?.pollingInterval || 10
+ );
+
+ let stacksDirectory = $derived(
+ form?.values?.stacksDirectory || settings?.stacksDirectory || ""
+ );
+ let autoUpdate = $derived(
+ form?.values?.autoUpdate !== undefined
+ ? form.values.autoUpdate === "on"
+ : settings?.autoUpdate || false
+ );
+
+ let registryCredentials = $derived(
+ form?.values?.registryCredentials || settings?.registryCredentials || []
+ );
+
+ const defaultRegistry = { url: "", username: "", password: "" };
+
+ function addRegistry() {
+ registryCredentials = [...registryCredentials, { ...defaultRegistry }];
+ }
+
+ // Remove a registry
+ function removeRegistry(index: number) {
+ registryCredentials = registryCredentials.filter(
+ (_: unknown, i: number) => i !== index
+ );
+ }
+</script>
+
+<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
+ <!-- Docker Connection Card -->
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-3">
+ <div class="flex items-center gap-2">
+ <div class="bg-blue-500/10 p-2 rounded-full">
+ <Save class="h-5 w-5 text-blue-500" />
+ </div>
+ <div>
+ <Card.Title>Docker Settings</Card.Title>
+ <Card.Description>Configure your Docker connection</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-4">
+ <div class="space-y-2">
+ <label for="dockerHost" class="text-sm font-medium">Docker Host</label
+ >
+ <Input
+ type="text"
+ id="dockerHost"
+ name="dockerHost"
+ bind:value={dockerHost}
+ placeholder="unix:///var/run/docker.sock"
+ required
+ />
+ <p class="text-xs text-muted-foreground">
+ For local Docker: unix:///var/run/docker.sock (Unix) or
+ npipe:////./pipe/docker_engine (Windows)
+ </p>
+ </div>
+
+ <div class="space-y-2">
+ <label for="stacksDirectory" class="text-sm font-medium"
+ >Stacks Directory</label
+ >
+ <Input
+ type="text"
+ id="stacksDirectory"
+ name="stacksDirectory"
+ bind:value={stacksDirectory}
+ placeholder="/app/data/stacks"
+ required
+ />
+ <p class="text-xs text-muted-foreground">
+ Directory where Docker Compose stacks will be stored inside the
+ container.
+ </p>
+ <p class="text-xs font-bold text-destructive">
+ Changing this setting will not move existing stacks!
+ </p>
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
+
+ <div class="space-y-6">
+ <!-- Polling Settings Card -->
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-3">
+ <div class="flex items-center gap-2">
+ <div class="bg-amber-500/10 p-2 rounded-full">
+ <RefreshCw class="h-5 w-5 text-amber-500" />
+ </div>
+ <div>
+ <Card.Title>Image Polling</Card.Title>
+ <Card.Description>Control container image polling</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content class="space-y-6">
+ <div
+ class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
+ >
+ <div class="space-y-0.5">
+ <label for="pollingEnabledSwitch" class="text-base font-medium"
+ >Check for New Images</label
+ >
+ <p class="text-sm text-muted-foreground">
+ Periodically check for newer versions of container images
+ </p>
+ </div>
+ <Switch
+ id="pollingEnabledSwitch"
+ name="pollingEnabled"
+ bind:checked={pollingEnabled}
+ />
+ </div>
+
+ {#if pollingEnabled}
+ <div class="space-y-2 px-1">
+ <label for="pollingInterval" class="text-sm font-medium">
+ Polling Interval (minutes)
+ </label>
+ <Input
+ id="pollingInterval"
+ name="pollingInterval"
+ type="number"
+ bind:value={pollingInterval}
+ min="5"
+ max="60"
+ />
+ {#if form?.error && form.values?.pollingInterval && (parseInt(String(form.values.pollingInterval), 10) < 5 || parseInt(String(form.values.pollingInterval), 10) > 60)}
+ <p class="text-sm text-destructive">
+ Must be between 5 and 60 minutes.
+ </p>
+ {:else}
+ <p class="text-xs text-muted-foreground">
+ Set between 5-60 minutes.
+ </p>
+ {/if}
+ </div>
+
+ <!-- Auto Update option -->
+ <div
+ class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
+ >
+ <div class="space-y-0.5">
+ <label for="autoUpdateSwitch" class="text-base font-medium"
+ >Auto Update Containers</label
+ >
+ <p class="text-sm text-muted-foreground">
+ Automatically update containers when newer images are available
+ </p>
+ </div>
+ <Switch
+ id="autoUpdateSwitch"
+ name="autoUpdate"
+ bind:checked={autoUpdate}
+ />
+ </div>
+ {/if}
+ </Card.Content>
+ </Card.Root>
+ </div>
+
+ <!-- Docker Registry Credentials Card -->
+ <Card.Root class="border shadow-sm lg:col-span-2">
+ <Card.Header class="pb-3">
+ <div class="flex items-center gap-2">
+ <div class="bg-green-500/10 p-2 rounded-full">
+ <Key class="h-5 w-5 text-green-500" />
+ </div>
+ <div>
+ <Card.Title>Docker Registry Credentials</Card.Title>
+ <Card.Description>
+ Configure access to private Docker registries
+ </Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-4">
+ <div class="space-y-2">
+ <p class="text-sm text-muted-foreground">
+ Add credentials for private registries like Docker Hub, GitHub
+ Container Registry (ghcr.io), or other private repositories.
+ </p>
+
+ {#if registryCredentials.length === 0}
+ <div
+ class="text-center py-4 text-muted-foreground text-sm border rounded-md"
+ >
+ No registry credentials configured yet
+ </div>
+ {:else}
+ <div class="space-y-4">
+ {#each registryCredentials as registry, index}
+ <div class="border rounded-md p-4 space-y-3">
+ <div class="flex justify-between items-center">
+ <h4 class="font-medium">Registry #{index + 1}</h4>
+ <button
+ type="button"
+ class="text-destructive hover:text-destructive/80"
+ onclick={() => removeRegistry(index)}
+ >
+ <Trash2 class="h-4 w-4" />
+ </button>
+ </div>
+
+ <div class="space-y-2">
+ <label
+ for={`registry-url-${index}`}
+ class="text-sm font-medium">Registry URL</label
+ >
+ <Input
+ type="text"
+ id={`registry-url-${index}`}
+ name={`registryCredentials[${index}].url`}
+ bind:value={registry.url}
+ placeholder="ghcr.io, registry.hub.docker.com, etc."
+ required
+ />
+ </div>
+
+ <div class="space-y-2">
+ <label
+ for={`registry-username-${index}`}
+ class="text-sm font-medium">Username</label
+ >
+ <Input
+ type="text"
+ id={`registry-username-${index}`}
+ name={`registryCredentials[${index}].username`}
+ bind:value={registry.username}
+ placeholder="Username"
+ required
+ />
+ </div>
+
+ <div class="space-y-2">
+ <label
+ for={`registry-password-${index}`}
+ class="text-sm font-medium">Password / Access Token</label
+ >
+ <Input
+ type="password"
+ id={`registry-password-${index}`}
+ name={`registryCredentials[${index}].password`}
+ bind:value={registry.password}
+ placeholder="Password or access token"
+ required
+ />
+ <p class="text-xs text-muted-foreground">
+ For GitHub, use a personal access token with the
+ appropriate scopes.
+ </p>
+ </div>
+ </div>
+ {/each}
+ </div>
+ {/if}
+
+ <button
+ type="button"
+ class="w-full mt-4 flex items-center justify-center gap-2 border border-dashed rounded-md py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted/30"
+ onclick={addRegistry}
+ >
+ <Plus class="h-4 w-4" /> Add Registry Credentials
+ </button>
+
+ <p class="text-xs text-muted-foreground mt-2">
+ Common registry URLs:
+ <span class="font-medium">registry.hub.docker.com</span> (Docker
+ Hub),
+ <span class="font-medium">ghcr.io</span> (GitHub Container
+ Registry),
+ <span class="font-medium"
+ >[account].dkr.ecr.[region].amazonaws.com</span
+ > (AWS ECR)
+ </p>
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
+</div>
diff --git a/src/routes/settings/tabs/authentication.svelte b/src/routes/settings/tabs/authentication.svelte
new file mode 100644
index 000000000..683f7c33e
--- /dev/null
+++ b/src/routes/settings/tabs/authentication.svelte
@@ -0,0 +1,220 @@
+<script lang="ts">
+ import * as Card from "$lib/components/ui/card/index.js";
+ import { Button } from "$lib/components/ui/button/index.js";
+ import { Input } from "$lib/components/ui/input/index.js";
+ import { Switch } from "$lib/components/ui/switch/index.js";
+ import { Lock, Key, Shield } from "@lucide/svelte";
+ import type { ActionData, PageData } from "../$types";
+ import * as Form from "$lib/components/ui/form/index.js";
+
+ let { data, form } = $props<{ data: PageData; form: ActionData }>();
+
+ // Authentication settings
+ let enableLocalAuth = $state(true);
+ let enableOAuth = $state(false);
+ let enableLDAP = $state(false);
+ let sessionTimeout = $state(60);
+ let passwordPolicy = $state("medium");
+</script>
+
+<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
+ <!-- General Auth Settings -->
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-3">
+ <div class="flex items-center gap-2">
+ <div class="bg-indigo-500/10 p-2 rounded-full">
+ <Lock class="h-5 w-5 text-indigo-500" />
+ </div>
+ <div>
+ <Card.Title>Authentication Methods</Card.Title>
+ <Card.Description>Configure how users sign in</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-4">
+ <!-- Local Auth -->
+ <div
+ class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
+ >
+ <div class="space-y-0.5">
+ <label for="localAuthSwitch" class="text-base font-medium"
+ >Local Authentication</label
+ >
+ <p class="text-sm text-muted-foreground">
+ Username and password stored in the system
+ </p>
+ </div>
+ <Switch
+ id="localAuthSwitch"
+ name="enableLocalAuth"
+ bind:checked={enableLocalAuth}
+ />
+ </div>
+
+ <!-- OAuth -->
+ <div
+ class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
+ >
+ <div class="space-y-0.5">
+ <label for="oauthSwitch" class="text-base font-medium"
+ >OAuth/OpenID Connect</label
+ >
+ <p class="text-sm text-muted-foreground">
+ Single sign-on with external providers
+ </p>
+ </div>
+ <Switch
+ id="oauthSwitch"
+ name="enableOAuth"
+ bind:checked={enableOAuth}
+ />
+ </div>
+
+ <!-- LDAP -->
+ <div
+ class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
+ >
+ <div class="space-y-0.5">
+ <label for="ldapSwitch" class="text-base font-medium"
+ >LDAP/Active Directory</label
+ >
+ <p class="text-sm text-muted-foreground">
+ Authentication via directory service
+ </p>
+ </div>
+ <Switch id="ldapSwitch" name="enableLDAP" bind:checked={enableLDAP} />
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
+
+ <!-- Session Settings -->
+ <div class="space-y-6">
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-3">
+ <div class="flex items-center gap-2">
+ <div class="bg-cyan-500/10 p-2 rounded-full">
+ <Key class="h-5 w-5 text-cyan-500" />
+ </div>
+ <div>
+ <Card.Title>Session Settings</Card.Title>
+ <Card.Description>Configure session behavior</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-4">
+ <div class="space-y-2">
+ <label for="sessionTimeout" class="text-sm font-medium"
+ >Session Timeout (minutes)</label
+ >
+ <Input
+ type="number"
+ id="sessionTimeout"
+ name="sessionTimeout"
+ bind:value={sessionTimeout}
+ min="15"
+ max="1440"
+ />
+ <p class="text-xs text-muted-foreground">
+ Time until inactive sessions are automatically logged out (15-1440
+ minutes)
+ </p>
+ </div>
+
+ <div class="space-y-2">
+ <label for="passwordPolicy" class="text-sm font-medium"
+ >Password Policy</label
+ >
+ <div class="grid grid-cols-3 gap-2">
+ <Button
+ variant={passwordPolicy === "low" ? "default" : "outline"}
+ class="w-full"
+ onclick={() => (passwordPolicy = "low")}
+ >
+ Basic
+ </Button>
+ <Button
+ variant={passwordPolicy === "medium" ? "default" : "outline"}
+ class="w-full"
+ onclick={() => (passwordPolicy = "medium")}
+ >
+ Standard
+ </Button>
+ <Button
+ variant={passwordPolicy === "high" ? "default" : "outline"}
+ class="w-full"
+ onclick={() => (passwordPolicy = "high")}
+ >
+ Strong
+ </Button>
+ </div>
+ <input
+ type="hidden"
+ id="passwordPolicy"
+ name="passwordPolicy"
+ value={passwordPolicy}
+ />
+ <p class="text-xs text-muted-foreground mt-1">
+ {#if passwordPolicy === "low"}
+ Basic: Minimum 8 characters
+ {:else if passwordPolicy === "medium"}
+ Standard: Minimum 10 characters, requires mixed case and numbers
+ {:else}
+ Strong: Minimum 12 characters, requires mixed case, numbers and
+ special characters
+ {/if}
+ </p>
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
+
+ <!-- 2FA Settings -->
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-3">
+ <div class="flex items-center gap-2">
+ <div class="bg-emerald-500/10 p-2 rounded-full">
+ <Shield class="h-5 w-5 text-emerald-500" />
+ </div>
+ <div>
+ <Card.Title>Two-Factor Authentication</Card.Title>
+ <Card.Description>Extra security layer</Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-4">
+ <div
+ class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
+ >
+ <div class="space-y-0.5">
+ <label for="require2faSwitch" class="text-base font-medium"
+ >Require 2FA</label
+ >
+ <p class="text-sm text-muted-foreground">
+ Force all users to set up two-factor authentication
+ </p>
+ </div>
+ <Switch id="require2faSwitch" name="require2fa" />
+ </div>
+
+ <div
+ class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
+ >
+ <div class="space-y-0.5">
+ <label for="allowTotpSwitch" class="text-base font-medium"
+ >Allow App-Based 2FA</label
+ >
+ <p class="text-sm text-muted-foreground">
+ Allow authentication apps (TOTP)
+ </p>
+ </div>
+ <Switch id="allowTotpSwitch" name="allowTotp" checked />
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
+ </div>
+</div>
diff --git a/src/routes/settings/tabs/external-services.svelte b/src/routes/settings/tabs/external-services.svelte
new file mode 100644
index 000000000..0c1ec55b8
--- /dev/null
+++ b/src/routes/settings/tabs/external-services.svelte
@@ -0,0 +1,211 @@
+<script lang="ts">
+ import * as Card from "$lib/components/ui/card/index.js";
+ import { Input } from "$lib/components/ui/input/index.js";
+ import { Switch } from "$lib/components/ui/switch/index.js";
+ import { Database, CircuitBoard } from "@lucide/svelte";
+ import type { ActionData, PageData } from "../$types";
+
+ let { data, form } = $props<{ data: PageData; form: ActionData }>();
+
+ let settings = $derived(data.settings);
+
+ // Valkey settings
+ let valkeyEnabled = $derived(
+ form?.values?.valkeyEnabled !== undefined
+ ? form.values.valkeyEnabled === "on"
+ : settings?.externalServices?.valkey?.enabled || false
+ );
+
+ let valkeyHost = $derived(
+ form?.values?.valkeyHost ||
+ settings?.externalServices?.valkey?.host ||
+ "localhost"
+ );
+
+ let valkeyPort = $derived(
+ form?.values?.valkeyPort !== undefined
+ ? form.values.valkeyPort
+ : settings?.externalServices?.valkey?.port || 6379
+ );
+
+ let valkeyUsername = $derived(
+ form?.values?.valkeyUsername ||
+ settings?.externalServices?.valkey?.username ||
+ ""
+ );
+
+ let valkeyPassword = $derived(
+ form?.values?.valkeyPassword ||
+ settings?.externalServices?.valkey?.password ||
+ ""
+ );
+
+ let valkeyKeyPrefix = $derived(
+ form?.values?.valkeyKeyPrefix ||
+ settings?.externalServices?.valkey?.keyPrefix ||
+ "arcane:settings:"
+ );
+</script>
+
+<div class="grid grid-cols-1 lg:grid-cols-1 gap-6">
+ <!-- External Services Header -->
+ <div class="space-y-2">
+ <h2 class="text-2xl font-bold tracking-tight">External Services</h2>
+ <p class="text-muted-foreground">
+ Configure connections to external services for enhanced functionality.
+ </p>
+ </div>
+
+ <!-- Valkey/Redis Card -->
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-3">
+ <div class="flex items-center gap-2">
+ <div class="bg-purple-500/10 p-2 rounded-full">
+ <Database class="h-5 w-5 text-purple-500" />
+ </div>
+ <div>
+ <Card.Title>Valkey/Redis Integration</Card.Title>
+ <Card.Description>
+ Connect to Valkey or Redis for distributed caching and state
+ management
+ </Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-4">
+ <div
+ class="flex items-center justify-between rounded-lg border p-4 bg-muted/30"
+ >
+ <div class="space-y-0.5">
+ <label for="valkeyEnabledSwitch" class="text-base font-medium"
+ >Enable Valkey/Redis</label
+ >
+ <p class="text-sm text-muted-foreground">
+ Use Valkey/Redis for enhanced performance and reliability
+ </p>
+ </div>
+ <Switch
+ id="valkeyEnabledSwitch"
+ name="valkeyEnabled"
+ bind:checked={valkeyEnabled}
+ />
+ </div>
+
+ {#if valkeyEnabled}
+ <div
+ class="grid grid-cols-1 md:grid-cols-2 gap-4 p-4 border rounded-lg"
+ >
+ <div class="space-y-2">
+ <label for="valkeyHost" class="text-sm font-medium"
+ >Server Host</label
+ >
+ <Input
+ type="text"
+ id="valkeyHost"
+ name="valkeyHost"
+ bind:value={valkeyHost}
+ placeholder="localhost"
+ required
+ />
+ </div>
+
+ <div class="space-y-2">
+ <label for="valkeyPort" class="text-sm font-medium"
+ >Server Port</label
+ >
+ <Input
+ type="number"
+ id="valkeyPort"
+ name="valkeyPort"
+ bind:value={valkeyPort}
+ placeholder="6379"
+ required
+ />
+ </div>
+
+ <div class="space-y-2">
+ <label for="valkeyUsername" class="text-sm font-medium"
+ >Username</label
+ >
+ <Input
+ type="text"
+ id="valkeyUsername"
+ name="valkeyUsername"
+ bind:value={valkeyUsername}
+ placeholder="(optional)"
+ />
+ </div>
+
+ <div class="space-y-2">
+ <label for="valkeyPassword" class="text-sm font-medium"
+ >Password</label
+ >
+ <Input
+ type="password"
+ id="valkeyPassword"
+ name="valkeyPassword"
+ bind:value={valkeyPassword}
+ placeholder="(optional)"
+ />
+ </div>
+
+ <div class="space-y-2 md:col-span-2">
+ <label for="valkeyKeyPrefix" class="text-sm font-medium"
+ >Key Prefix</label
+ >
+ <Input
+ type="text"
+ id="valkeyKeyPrefix"
+ name="valkeyKeyPrefix"
+ bind:value={valkeyKeyPrefix}
+ placeholder="arcane:settings:"
+ />
+ <p class="text-xs text-muted-foreground">
+ Prefix used for keys when storing values in Valkey/Redis
+ </p>
+ </div>
+
+ <div
+ class="md:col-span-2 p-3 rounded-md bg-blue-50 text-blue-800 border border-blue-200"
+ >
+ <p class="text-sm">
+ <span class="font-medium">Usage:</span> When enabled, Valkey/Redis
+ will be used for caching and distributed state management, improving
+ performance.
+ </p>
+ </div>
+ </div>
+ {/if}
+ </div>
+ </Card.Content>
+ </Card.Root>
+
+ <!-- Placeholder for future services -->
+ <Card.Root class="border shadow-sm border-dashed">
+ <Card.Header class="pb-3">
+ <div class="flex items-center gap-2">
+ <div class="bg-gray-500/10 p-2 rounded-full">
+ <CircuitBoard class="h-5 w-5 text-gray-500" />
+ </div>
+ <div>
+ <Card.Title>Additional Services</Card.Title>
+ <Card.Description>
+ More integrations will be available in future updates
+ </Card.Description>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="text-center py-8 text-muted-foreground">
+ <p>
+ Future services MAY include database connections, monitoring tools,
+ and more.
+ </p>
+ <p class="text-sm mt-2">
+ Check back for updates or suggest integrations!
+ </p>
+ </div>
+ </Card.Content>
+ </Card.Root>
+</div>
diff --git a/src/routes/settings/tabs/rbac-settings.svelte b/src/routes/settings/tabs/rbac-settings.svelte
new file mode 100644
index 000000000..fb74683a7
--- /dev/null
+++ b/src/routes/settings/tabs/rbac-settings.svelte
@@ -0,0 +1,208 @@
+<script lang="ts">
+ import * as Card from "$lib/components/ui/card/index.js";
+ import { Button } from "$lib/components/ui/button/index.js";
+ import { Input } from "$lib/components/ui/input/index.js";
+ import { Shield, Plus, Users, Settings } from "@lucide/svelte";
+ import type { ActionData, PageData } from "../$types";
+ import * as DropdownMenu from "$lib/components/ui/dropdown-menu/index.js";
+
+ let { data, form } = $props<{ data: PageData; form: ActionData }>();
+
+ // Sample roles for demonstration
+ const roles = [
+ {
+ id: 1,
+ name: "Admin",
+ description: "Full system access",
+ permissions: [
+ "containers:manage",
+ "stacks:manage",
+ "volumes:manage",
+ "networks:manage",
+ "settings:manage",
+ "users:manage",
+ ],
+ },
+ {
+ id: 2,
+ name: "User",
+ description: "Container and stack operations",
+ permissions: [
+ "containers:view",
+ "containers:manage",
+ "stacks:view",
+ "stacks:manage",
+ "volumes:view",
+ "networks:view",
+ ],
+ },
+ {
+ id: 3,
+ name: "Viewer",
+ description: "Read-only access",
+ permissions: [
+ "containers:view",
+ "stacks:view",
+ "volumes:view",
+ "networks:view",
+ ],
+ },
+ ];
+
+ // Available permissions categories
+ const permissionCategories = [
+ {
+ name: "Containers",
+ permissions: [
+ "containers:view",
+ "containers:manage",
+ "containers:deploy",
+ ],
+ },
+ {
+ name: "Stacks",
+ permissions: ["stacks:view", "stacks:manage", "stacks:deploy"],
+ },
+ {
+ name: "Volumes",
+ permissions: ["volumes:view", "volumes:manage", "volumes:create"],
+ },
+ {
+ name: "Networks",
+ permissions: ["networks:view", "networks:manage", "networks:create"],
+ },
+ {
+ name: "Settings",
+ permissions: ["settings:view", "settings:manage"],
+ },
+ {
+ name: "Users",
+ permissions: ["users:view", "users:manage", "users:create"],
+ },
+ ];
+
+ let selectedRole = $state(roles[0]);
+</script>
+
+<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
+ <!-- Roles List -->
+ <div class="lg:col-span-1">
+ <Card.Root class="border shadow-sm h-full">
+ <Card.Header class="pb-3">
+ <div class="flex items-center justify-between">
+ <div class="flex items-center gap-2">
+ <div class="bg-blue-500/10 p-2 rounded-full">
+ <Users class="h-5 w-5 text-blue-500" />
+ </div>
+ <Card.Title>Roles</Card.Title>
+ </div>
+ <Button variant="outline" size="sm">
+ <Plus class="h-4 w-4 mr-1" /> Add
+ </Button>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-2">
+ {#each roles as role}
+ <button
+ class="w-full text-left p-3 rounded-md border transition-colors flex items-center justify-between
+ {selectedRole.id === role.id
+ ? 'bg-primary text-primary-foreground border-primary'
+ : 'hover:bg-muted/50'}"
+ onclick={() => (selectedRole = role)}
+ >
+ <div>
+ <div class="font-medium">{role.name}</div>
+ <div
+ class="text-xs {selectedRole.id === role.id
+ ? 'text-primary-foreground/90'
+ : 'text-muted-foreground'}"
+ >
+ {role.description}
+ </div>
+ </div>
+ <Shield class="h-4 w-4 opacity-70" />
+ </button>
+ {/each}
+ </div>
+ </Card.Content>
+ </Card.Root>
+ </div>
+
+ <!-- Role Details -->
+ <div class="lg:col-span-2">
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-3">
+ <div class="flex items-center justify-between">
+ <div class="flex items-center gap-2">
+ <div class="bg-purple-500/10 p-2 rounded-full">
+ <Settings class="h-5 w-5 text-purple-500" />
+ </div>
+ <div>
+ <Card.Title>Role: {selectedRole.name}</Card.Title>
+ <Card.Description>{selectedRole.description}</Card.Description>
+ </div>
+ </div>
+ <div class="space-x-2">
+ <Button variant="outline" size="sm">Delete</Button>
+ <Button size="sm">Save Changes</Button>
+ </div>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-6">
+ <!-- Role Info -->
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <div class="space-y-2">
+ <label for="roleName" class="text-sm font-medium">Role Name</label
+ >
+ <Input
+ id="roleName"
+ name="roleName"
+ value={selectedRole.name}
+ placeholder="Enter role name"
+ />
+ </div>
+ <div class="space-y-2">
+ <label for="roleDescription" class="text-sm font-medium"
+ >Description</label
+ >
+ <Input
+ id="roleDescription"
+ name="roleDescription"
+ value={selectedRole.description}
+ placeholder="Brief description"
+ />
+ </div>
+ </div>
+
+ <!-- Permissions -->
+ <div>
+ <h3 class="text-sm font-medium mb-3">Permissions</h3>
+ <div class="border rounded-md divide-y">
+ {#each permissionCategories as category}
+ <div class="p-3">
+ <h4 class="font-medium mb-2">{category.name}</h4>
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
+ {#each category.permissions as permission}
+ <label class="flex items-center space-x-2 text-sm">
+ <input
+ type="checkbox"
+ class="rounded border-gray-300 text-primary focus:ring-primary"
+ checked={selectedRole.permissions.includes(
+ permission
+ )}
+ />
+ <span>{permission.split(":")[1]}</span>
+ </label>
+ {/each}
+ </div>
+ </div>
+ {/each}
+ </div>
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
+ </div>
+</div>
diff --git a/src/routes/settings/tabs/user-management.svelte b/src/routes/settings/tabs/user-management.svelte
new file mode 100644
index 000000000..fbbbca6c7
--- /dev/null
+++ b/src/routes/settings/tabs/user-management.svelte
@@ -0,0 +1,110 @@
+<script lang="ts">
+ import * as Card from "$lib/components/ui/card/index.js";
+ import { Button } from "$lib/components/ui/button/index.js";
+ import { Input } from "$lib/components/ui/input/index.js";
+ import {
+ UserPlus,
+ User,
+ Search,
+ MoreHorizontal,
+ Trash,
+ } from "@lucide/svelte";
+ import type { ActionData, PageData } from "../$types";
+ import * as DropdownMenu from "$lib/components/ui/dropdown-menu/index.js";
+
+ let { data, form } = $props<{ data: PageData; form: ActionData }>();
+
+ // Sample users for demonstration
+ const users = [
+ { id: 1, name: "Admin User", email: "[email protected]", role: "Admin" },
+ { id: 2, name: "Regular User", email: "[email protected]", role: "User" },
+ { id: 3, name: "Viewer", email: "[email protected]", role: "Viewer" },
+ ];
+
+ let searchQuery = $state("");
+</script>
+
+<div class="space-y-6">
+ <Card.Root class="border shadow-sm">
+ <Card.Header class="pb-3">
+ <div class="flex items-center justify-between">
+ <div class="flex items-center gap-2">
+ <div class="bg-green-500/10 p-2 rounded-full">
+ <User class="h-5 w-5 text-green-500" />
+ </div>
+ <div>
+ <Card.Title>User Management</Card.Title>
+ <Card.Description>Manage system users</Card.Description>
+ </div>
+ </div>
+ <Button variant="default" size="sm">
+ <UserPlus class="h-4 w-4 mr-2" />
+ Add User
+ </Button>
+ </div>
+ </Card.Header>
+ <Card.Content>
+ <div class="space-y-4">
+ <!-- Search -->
+ <div class="relative">
+ <Search
+ class="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"
+ />
+ <Input
+ type="search"
+ placeholder="Search users..."
+ class="pl-8"
+ bind:value={searchQuery}
+ />
+ </div>
+
+ <!-- Users Table -->
+ <div class="border rounded-md">
+ <table class="w-full">
+ <thead>
+ <tr class="border-b bg-muted/50">
+ <th class="text-left p-2 pl-4 font-medium">Name</th>
+ <th class="text-left p-2 font-medium">Email</th>
+ <th class="text-left p-2 font-medium">Role</th>
+ <th class="text-right p-2 pr-4 font-medium">Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each users.filter((u) => u.name
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase()) || u.email
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase())) as user}
+ <tr class="border-b last:border-0">
+ <td class="p-2 pl-4">{user.name}</td>
+ <td class="p-2">{user.email}</td>
+ <td class="p-2">{user.role}</td>
+ <td class="p-2 pr-4 text-right">
+ <DropdownMenu.Root>
+ <DropdownMenu.Trigger>
+ <Button variant="ghost" size="icon" class="h-8 w-8">
+ <MoreHorizontal class="h-4 w-4" />
+ <span class="sr-only">Open menu</span>
+ </Button>
+ </DropdownMenu.Trigger>
+ <DropdownMenu.Content align="end">
+ <DropdownMenu.Item>Edit User</DropdownMenu.Item>
+ <DropdownMenu.Item>Change Password</DropdownMenu.Item>
+ <DropdownMenu.Item>Modify Roles</DropdownMenu.Item>
+ <DropdownMenu.Separator />
+ <DropdownMenu.Item class="text-destructive">
+ <Trash class="h-4 w-4 mr-2" />
+ Delete User
+ </DropdownMenu.Item>
+ </DropdownMenu.Content>
+ </DropdownMenu.Root>
+ </td>
+ </tr>
+ {/each}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </Card.Content>
+ </Card.Root>
+</div>