import { useEffect, useState } from "react"; import { Server } from "lucide-react"; import { useTranslation } from "react-i18next"; import { registerWidget } from "./WidgetRegistry"; import type { HostStatusConfig, HostMetricKey, WidgetComponentProps, } from "@/types/homepage-types"; import { GRID_SIZE } from "@/types/homepage-types"; import { getServerStatusById, getServerMetricsById, } from "@/api/host-metrics-status-api"; import { getSSHHosts } from "@/api/ssh-host-management-api"; import type { ServerMetrics } from "@/main-axios"; import { WidgetTitle } from "./WidgetTitle"; function getAccentColor(): string { return ( getComputedStyle(document.documentElement) .getPropertyValue("--accent-brand") .trim() || "#f59145" ); } const DEFAULT_METRICS: HostMetricKey[] = ["cpu", "memory"]; function migrateConfig(config: HostStatusConfig): HostMetricKey[] { if (config.shownMetrics?.length) return config.shownMetrics; if (config.showMetrics === false) return []; const metrics: HostMetricKey[] = ["cpu", "memory"]; if (config.showDisk) metrics.push("disk"); return metrics; } interface MetricBarProps { label: string; value: number | null; sublabel?: string; } function MetricBar({ label, value, sublabel }: MetricBarProps) { const pct = value ?? 0; const color = pct > 90 ? "#ef4444" : pct > 70 ? "#f97316" : getAccentColor(); return (