diff --git a/src/lib/server/hosts/overview.ts b/src/lib/server/hosts/overview.ts new file mode 100644 index 0000000..8833d59 --- /dev/null +++ b/src/lib/server/hosts/overview.ts @@ -0,0 +1,16 @@ +import { db } from '../db/index.js'; +import { listHosts } from './index.js'; +import { presentHostPreparation } from './preparation.js'; +import type { Host } from '../../hosts.js'; + +export interface HostOverview extends Host { serverCount: number } + +/** Count assigned servers without loading their telemetry or historical placements. */ +export function hostOverview(): HostOverview[] { + const hosts = listHosts(); + const counts = new Map((db().prepare(`SELECT i.host_id, COUNT(*) AS count FROM native_instances i + JOIN servers s ON s.name = i.server + WHERE i.retired_at IS NULL AND s.destroyed_at IS NULL + GROUP BY i.host_id`).all() as { host_id: string; count: number }[]).map(row => [row.host_id, row.count])); + return hosts.map(host => ({ ...presentHostPreparation(host), serverCount: counts.get(host.id) ?? 0 })); +} diff --git a/src/lib/ui/components/AddHostDrawer.svelte b/src/lib/ui/components/AddHostDrawer.svelte new file mode 100644 index 0000000..6231292 --- /dev/null +++ b/src/lib/ui/components/AddHostDrawer.svelte @@ -0,0 +1,61 @@ + + + + + diff --git a/src/lib/ui/components/HostList.svelte b/src/lib/ui/components/HostList.svelte new file mode 100644 index 0000000..e829f3e --- /dev/null +++ b/src/lib/ui/components/HostList.svelte @@ -0,0 +1,40 @@ + + +
| Host | Status | Servers | CPU | Memory used / total | Disk used / total |
|---|---|---|---|---|---|
| {host.name}{#if host.hostname && host.hostname !== host.name}{host.hostname}{/if} + {#if stale && host.lastHeartbeat}Resource readings stale{/if} | +{host.serverCount} | +{hostCpuUsage(host.inventory.cpuUsagePercent)} | +{hostUsedSpace(host.inventory.memoryTotal, host.inventory.memoryAvailable)} | +{hostUsedSpace(host.inventory.storageTotal, host.inventory.storageAvailable)} | +