fix: harden dashboard model validation

This commit is contained in:
vince 2026-06-18 17:43:55 +02:00
parent 7cfd5b4069
commit 74651a49de
4 changed files with 288 additions and 13 deletions

View file

@ -44,7 +44,7 @@ export const dimensionLabDashboardFixture: DashboardDocument = {
metric("system-disk-peak", "System Disk Peak", "percent", 49, "linux /boot", "ok"),
metric("peak-cpu-busy", "Peak CPU Busy", "percent", 3, "linux-infra", "ok"),
metric("top-cpu-container", "Top CPU Container", "percent", 7.9, "container placeholder", "ok"),
metric("top-ram-container", "Top RAM Container", "bytes", "5.2 GB", "container placeholder", "danger"),
metric("top-ram-container", "Top RAM Container", "bytes", 5.2 * 1024 ** 3, "container placeholder", "danger"),
metric("gpu-3060-load", "3060 GPU Load", "percent", 0, "RTX 3060", "ok"),
metric("gpu-3060-vram", "3060 VRAM", "percent", 0, "RTX 3060", "ok"),
metric("gpu-3060-temp", "3060 Temp", "temperature", 54, "RTX 3060", "ok"),
@ -111,14 +111,14 @@ export const dimensionLabDashboardFixture: DashboardDocument = {
],
};
type ValueKind = "percent" | "bytes" | "temperature" | "latency" | "number" | "text";
type NumericValueKind = "percent" | "bytes" | "temperature" | "latency" | "number";
type Severity = "neutral" | "ok" | "warning" | "danger" | "stale" | "unavailable";
function metric(
id: string,
label: string,
kind: ValueKind,
value: number | string,
kind: NumericValueKind,
value: number,
detail: string,
severity: Severity,
) {