import type { HostSummary } from "../api"; import { Sparkline } from "./Sparkline"; function Bar({ label, pct }: { label: string; pct: number | null }) { const value = pct ?? 0; const color = value > 90 ? "#e5484d" : value > 75 ? "#f5a623" : "#3fb950"; return (
{label}
{pct === null ? "—" : `${pct.toFixed(0)}%`}
); } function formatUptime(sec: number | null): string { if (sec === null) return "—"; const days = Math.floor(sec / 86400); const hours = Math.floor((sec % 86400) / 3600); if (days > 0) return `${days}d ${hours}h`; const minutes = Math.floor((sec % 3600) / 60); return `${hours}h ${minutes}m`; } export function HostCard({ host }: { host: HostSummary }) { return (
{host.displayName} {formatUptime(host.uptimeSec)}
{(host.cpuPressurePct !== null || host.memPressurePct !== null) && (
{host.cpuPressurePct !== null && CPU pressure {host.cpuPressurePct.toFixed(1)}%} {host.memPressurePct !== null && Mem pressure {host.memPressurePct.toFixed(1)}%}
)}
); }