From 43a54e8b4c9cd721cffb17a7795b1f0fcbd64841 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Tue, 14 Jul 2026 09:04:23 +0000 Subject: [PATCH] Rename Uptime tab to States; add RAM/disk progress bars per service Co-Authored-By: Claude Sonnet 4.6 --- src/pages/AdminMonitor.tsx | 84 +++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 23 deletions(-) diff --git a/src/pages/AdminMonitor.tsx b/src/pages/AdminMonitor.tsx index 5c5eddc..2c5ce83 100644 --- a/src/pages/AdminMonitor.tsx +++ b/src/pages/AdminMonitor.tsx @@ -25,10 +25,36 @@ function relativeTime(iso: string | null | undefined): string | null { return new Date(iso).toLocaleDateString(undefined, { day: 'numeric', month: 'short' }) } +interface StatRange { total: number; used: number } + interface HealthStatus { name: string up: boolean ms: number | null + ram: StatRange | null + disk: StatRange | null +} + +function formatBytes(b: number): string { + if (b >= 1_073_741_824) return `${(b / 1_073_741_824).toFixed(1)} GB` + if (b >= 1_048_576) return `${(b / 1_048_576).toFixed(0)} MB` + return `${(b / 1024).toFixed(0)} KB` +} + +function StatBar({ label, stat }: { label: string; stat: StatRange }) { + const pct = Math.min(100, Math.round((stat.used / stat.total) * 100)) + const color = pct > 85 ? 'var(--danger)' : pct > 70 ? '#d97706' : '#16a34a' + return ( +
+
+ {label} + {pct}% · {formatBytes(stat.used)} / {formatBytes(stat.total)} +
+
+
+
+
+ ) } interface DeployEntry { @@ -42,7 +68,7 @@ interface DeployEntry { } export function AdminMonitor({ user }: { user: User }) { - const [tab, setTab] = useState<'updates' | 'uptime' | 'deploys'>('updates') + const [tab, setTab] = useState<'updates' | 'states' | 'deploys'>('updates') const [statuses, setStatuses] = useState([]) const [deploys, setDeploys] = useState([]) const [health, setHealth] = useState([]) @@ -60,7 +86,7 @@ export function AdminMonitor({ user }: { user: User }) { } } - async function fetchHealth() { + async function fetchStates() { setLoading(true) try { const res = await fetch('/deploy/health-status', { credentials: 'include' }) @@ -96,9 +122,9 @@ export function AdminMonitor({ user }: { user: User }) { useEffect(() => { if (tab === 'updates') fetchStatus() if (tab === 'deploys') fetchDeploys() - if (tab === 'uptime') { - fetchHealth() - const id = setInterval(fetchHealth, 30_000) + if (tab === 'states') { + fetchStates() + const id = setInterval(fetchStates, 30_000) return () => clearInterval(id) } }, [tab]) @@ -107,7 +133,7 @@ export function AdminMonitor({ user }: { user: User }) { const tabs = [ { key: 'updates' as const, label: 'Updates', icon: }, - { key: 'uptime' as const, label: 'Uptime', icon: }, + { key: 'states' as const, label: 'States', icon: }, { key: 'deploys' as const, label: 'Deploy Log', icon: }, ] @@ -225,12 +251,12 @@ export function AdminMonitor({ user }: { user: User }) {
)} - {/* Uptime tab */} - {tab === 'uptime' && ( + {/* States tab */} + {tab === 'states' && (
-

Service Health

-