feat(client): add live fleet dashboard, sparkline charts, Server Inspector, TOFU/MITM dialogs, and Key Manager UI

This commit is contained in:
tyuXX 2026-11-26 18:55:10 +00:00
parent 2d7709035b
commit 75b969f044
9 changed files with 1200 additions and 46 deletions

View file

@ -1,11 +1,16 @@
import type {
ConfigError,
ConfigWarning,
DiskSample,
MetricSample,
ProbeSample,
ServerRuntimeState,
VaultState,
} from '../../shared/ws-protocol.js';
export type RouteId =
| 'dashboard'
| 'server-detail'
| 'systems'
| 'terminal'
| 'sftp'
@ -38,6 +43,33 @@ export interface ConfigOverview {
settings: Record<string, unknown>;
}
export interface ServerEntry {
config: {
id: string;
name: string;
host: string;
port: number;
username: string;
credentialId: string;
jumpHostId?: string;
sudoCredentialId?: string;
tags: string[];
osHint: 'auto' | 'linux' | 'bsd' | 'macos';
pollIntervalSec: number;
probes: Array<Record<string, unknown>>;
enabled: boolean;
};
runtime: ServerRuntimeState;
telemetry: {
serverId: string;
os?: 'linux' | 'bsd' | 'macos';
sample?: MetricSample;
disks: DiskSample[];
probes: Record<string, ProbeSample>;
lastError?: string;
} | null;
}
export interface ClientState {
bootstrapped: boolean;
authenticated: boolean;
@ -48,6 +80,7 @@ export interface ClientState {
elevatedUntil: number | null;
theme: string;
route: RouteId;
selectedServerId?: string;
overview: ConfigOverview | null;
}
@ -92,6 +125,23 @@ export function fmtTime(ts: number | string | null | undefined): string {
return Number.isNaN(d.getTime()) ? '—' : d.toISOString().replace('T', ' ').slice(0, 19);
}
export function fmtBytesPerSec(bps: number): string {
if (!Number.isFinite(bps) || bps <= 0) return '0 B/s';
if (bps < 1024) return `${Math.round(bps)} B/s`;
if (bps < 1024 * 1024) return `${(bps / 1024).toFixed(1)} KB/s`;
return `${(bps / (1024 * 1024)).toFixed(2)} MB/s`;
}
export function fmtUptime(sec: number): string {
if (!Number.isFinite(sec) || sec <= 0) return '0m';
const d = Math.floor(sec / 86400);
const h = Math.floor((sec % 86400) / 3600);
const m = Math.floor((sec % 3600) / 60);
if (d > 0) return `${d}d ${h}h`;
if (h > 0) return `${h}h ${m}m`;
return `${m}m`;
}
export function extractErrorMessage(err: unknown): string {
return err instanceof Error ? err.message : String(err);
}