import { Cable, Container, Network, Wifi, WifiOff } from "lucide-react"; import { useTranslation } from "react-i18next"; import type { ServerMetrics } from "@/main-axios.ts"; import { SectionCard } from "@/components/section-card"; interface NetworkWidgetProps { metrics: ServerMetrics | null; metricsHistory: ServerMetrics[]; } export function NetworkWidget({ metrics }: NetworkWidgetProps) { const { t } = useTranslation(); const metricsWithNetwork = metrics as ServerMetrics & { network?: { interfaces?: Array<{ name: string; state: string; ip: string; rx?: string; tx?: string; }>; }; }; const interfaces = metricsWithNetwork?.network?.interfaces ?? []; const ifaceIcon = (name: string) => { if (/^(wl|wlan|wifi|ath)/.test(name)) return ; if (/^(eth|en|enp|eno|ens)/.test(name)) return ; if (/^(docker|br-|veth|virbr|vlan|bond|tun|tap|wg|lo)/.test(name)) return ; return ; }; return ( } >
{interfaces.length === 0 ? (
{t("serverStats.noInterfacesFound")}
) : (
{interfaces.map((iface, i) => (
{ifaceIcon(iface.name)}
{iface.name}
{iface.state}
{iface.ip} {(iface.rx || iface.tx) && ( ↓ {iface.rx ?? "—"} / ↑ {iface.tx ?? "—"} )}
))}
)}
); }