import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import type { MetricsChartConfig, MetricsChartMetric, MetricsChartRange, WidgetEditFormProps, } from "@/types/homepage-types"; import { getSSHHosts } from "@/api/ssh-host-management-api"; const METRICS: { id: MetricsChartMetric; label: string }[] = [ { id: "cpu", label: "CPU" }, { id: "memory", label: "Memory" }, { id: "disk", label: "Disk" }, { id: "net_rx", label: "RX MB/s" }, { id: "net_tx", label: "TX MB/s" }, ]; const RANGES: { id: MetricsChartRange; label: string }[] = [ { id: "15m", label: "15m" }, { id: "1h", label: "1h" }, { id: "6h", label: "6h" }, { id: "24h", label: "24h" }, ]; export function MetricsChartEditForm({ config, onChange, }: WidgetEditFormProps) { const { t } = useTranslation(); const [hosts, setHosts] = useState<{ id: number; name: string }[]>([]); useEffect(() => { getSSHHosts() .then((h) => setHosts(h.map((x) => ({ id: x.id, name: x.name })))) .catch(() => {}); }, []); return (
{METRICS.map((m) => ( ))}
{RANGES.map((r) => ( ))}
); }