"use client" import { useEffect, useState } from "react" import { Card, CardContent, CardHeader, CardTitle } from "./ui/card" import { Badge } from "./ui/badge" import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "./ui/dialog" import { Wifi, Activity, Network, Router, AlertCircle, Zap, Timer, EthernetPort, ArrowDown, ArrowUp, Box, ChevronRight } from 'lucide-react' import useSWR from "swr" import { NetworkTrafficChart } from "./network-traffic-chart" import { NetworkFlow, type NetworkFlowData } from "./network-flow" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./ui/select" import { fetchApi } from "../lib/api-config" import { formatNetworkTraffic, getNetworkUnit } from "../lib/format-network" import { LatencyDetailModal } from "./latency-detail-modal" import { AreaChart, Area, LineChart, Line, ResponsiveContainer, YAxis } from "recharts" interface NetworkData { interfaces: NetworkInterface[] physical_interfaces?: NetworkInterface[] bridge_interfaces?: NetworkInterface[] vm_lxc_interfaces?: NetworkInterface[] traffic: { bytes_sent: number bytes_recv: number packets_sent?: number packets_recv?: number packet_loss_in?: number packet_loss_out?: number dropin?: number dropout?: number errin?: number errout?: number } active_count?: number total_count?: number physical_active_count?: number physical_total_count?: number bridge_active_count?: number bridge_total_count?: number vm_lxc_active_count?: number vm_lxc_total_count?: number hostname?: string domain?: string dns_servers?: string[] } interface NetworkInterface { name: string type: string status: string speed: number duplex: string mtu: number mac_address: string | null addresses: Array<{ ip: string netmask: string }> bytes_sent?: number bytes_recv?: number packets_sent?: number packets_recv?: number errors_in?: number errors_out?: number drops_in?: number drops_out?: number // Live rate (bytes/sec) computed by the backend as the delta // between this poll and the previous one. Present from the second // /api/network response onward; absent on the first call after the // service starts or after a long pause. rx_Bps?: number tx_Bps?: number // Hardware ceiling parsed from ethtool's "Supported link modes". // The card shows "(max N Gbps)" next to the negotiated speed when // the link is auto-negotiated below the NIC's max. max_speed?: number // Bridges that have this physical NIC as their underlying interface // (directly, or as a bond slave). Surfaced in the card so the // operator can see "this NIC → vmbr0" at a glance. used_by_bridges?: string[] bond_mode?: string bond_slaves?: string[] bond_active_slave?: string | null bridge_members?: string[] bridge_physical_interface?: string bridge_bond_slaves?: string[] packet_loss_in?: number packet_loss_out?: number vmid?: number vm_name?: string vm_type?: string vm_status?: string } // Same dot-prefix tone the Storage cards use, so a "no errors" / // "errors present" cue reads identically across pages. const NetStatusDot = ({ tone }: { tone: "ok" | "warn" | "fail" }) => { const cls = tone === "ok" ? "bg-green-500" : tone === "warn" ? "bg-yellow-500" : "bg-red-500" return } const netCounterTone = (n: number | null | undefined): "ok" | "warn" | "fail" => { if (!n || n <= 0) return "ok" if (n < 10) return "warn" return "fail" } // Icon picker — defaults to the actual port type rather than a Wi-Fi // glyph for everything. Wireless interfaces (wl*/wifi*) keep the Wi-Fi // glyph; wired NICs use EthernetPort; bonds/bridges/vlans get more // specific icons so the operator can tell them apart at a glance. function getInterfaceIcon(iface: NetworkInterface): React.ComponentType<{ className?: string }> { const name = (iface.name || "").toLowerCase() const type = (iface.type || "").toLowerCase() if (name.startsWith("wl") || name.startsWith("wifi")) return Wifi if (type === "bridge") return Network if (type === "bond") return Router if (type === "vlan") return Activity if (type === "vm_lxc" || type === "virtual") return Box // Physical wired NIC (eth0, enp*, ens*, eno*, nic0, …) → ethernet port. return EthernetPort } // Match the dark blue badge tone the Storage card uses for the disk // type chip, but mapped to the actual interface class. function getInterfaceTypeChip(type: string) { switch ((type || "").toLowerCase()) { case "physical": return { className: "bg-blue-500/10 text-blue-400 border-blue-500/20", label: "Physical" } case "bridge": return { className: "bg-green-500/10 text-green-400 border-green-500/20", label: "Bridge" } case "bond": return { className: "bg-purple-500/10 text-purple-400 border-purple-500/20", label: "Bond" } case "vlan": return { className: "bg-cyan-500/10 text-cyan-400 border-cyan-500/20", label: "VLAN" } case "vm_lxc": case "virtual": return { className: "bg-orange-500/10 text-orange-400 border-orange-500/20", label: "Virtual" } default: return { className: "bg-gray-500/10 text-gray-400 border-gray-500/20", label: type || "Unknown" } } } // Per-interface card matching the Storage page's "Physical Disks" // pattern: 2-line header (identity / live state), horizontal divider, // vertical key→value stat block, footer with serial + arrow CTA. // Replaces the row-style block that was unchanged since 1.0.0. function renderPhysicalInterfaceCardV2( iface: NetworkInterface, onOpen: (iface: NetworkInterface) => void, ) { const Icon = getInterfaceIcon(iface) const chip = getInterfaceTypeChip(iface.type) const isUp = (iface.status || "").toLowerCase() === "up" const firstAddr = iface.addresses?.[0]?.ip || "" const extraAddrs = Math.max(0, (iface.addresses?.length || 0) - 1) const speedStr = formatSpeed(iface.speed) // Hardware max in Mbps from ethtool. Show only when it's different // from the negotiated speed (avoids "1 Gbps (max 1 Gbps)" noise). const maxSpeedStr = iface.max_speed && iface.max_speed !== iface.speed ? formatSpeed(iface.max_speed) : "" const bridgesUsing = iface.used_by_bridges || [] const errIn = iface.errors_in ?? 0 const errOut = iface.errors_out ?? 0 const dropIn = iface.drops_in ?? 0 const dropOut = iface.drops_out ?? 0 const totalErrors = errIn + errOut const totalDrops = dropIn + dropOut return (
onOpen(iface)} > {/* Header L1: identity (icon + name + type) | status. */}

{iface.name}

{chip.label}
{iface.status || "?"}
{/* Header L2: speed + max (when negotiated < hw) | duplex. */}
{speedStr} {maxSpeedStr && ( · max {maxSpeedStr} )} {iface.duplex || "—"}
{/* Separator. */}
{/* Stats: key uppercase left · value right. */}
{firstAddr && (
IP {firstAddr}{extraAddrs > 0 ? ` (+${extraAddrs})` : ""}
)}
MTU {iface.mtu || "—"}
{bridgesUsing.length > 0 && (
Bridge {bridgesUsing.map((b) => `→ ${b}`).join(" ")}
)} {/* Live RX/TX rate. Same wording the Network Traffic chart uses ("Received" / "Sent") and the same canonical colours (green for Received, blue for Sent). Falls back to "—" until the backend has a delta — first poll after start has no previous sample to compute against. */}
Received {iface.rx_Bps !== undefined ? formatRate(iface.rx_Bps) : "—"}
Sent {iface.tx_Bps !== undefined ? formatRate(iface.tx_Bps) : "—"}
{(totalErrors > 0 || totalDrops > 0) && ( <> {totalErrors > 0 && (
Errors {totalErrors.toLocaleString()}
)} {totalDrops > 0 && (
Drops {totalDrops.toLocaleString()}
)} )}
{/* Footer: MAC (left, mono) + arrow CTA (right). */}
{iface.mac_address ? ( MAC: {iface.mac_address} ) : ( )}
) } const getInterfaceTypeBadge = (type: string) => { switch (type) { case "physical": return { color: "bg-blue-500/10 text-blue-500 border-blue-500/20", label: "Physical" } case "bridge": return { color: "bg-green-500/10 text-green-500 border-green-500/20", label: "Bridge" } case "bond": return { color: "bg-purple-500/10 text-purple-500 border-purple-500/20", label: "Bond" } case "vlan": return { color: "bg-cyan-500/10 text-cyan-500 border-cyan-500/20", label: "VLAN" } case "vm_lxc": return { color: "bg-orange-500/10 text-orange-500 border-orange-500/20", label: "Virtual" } case "virtual": return { color: "bg-orange-500/10 text-orange-500 border-orange-500/20", label: "Virtual" } default: return { color: "bg-gray-500/10 text-gray-500 border-gray-500/20", label: "Unknown" } } } const getVMTypeBadge = (vmType: string | undefined) => { if (vmType === "lxc") { return { color: "bg-cyan-500/10 text-cyan-500 border-cyan-500/20", label: "LXC" } } else if (vmType === "vm") { return { color: "bg-purple-500/10 text-purple-500 border-purple-500/20", label: "VM" } } return { color: "bg-gray-500/10 text-gray-500 border-gray-500/20", label: "Unknown" } } // Format bytes/sec into the canonical network unit ladder. // Matches the convention used by the Network Traffic chart so the // rates on the per-interface cards and the chart read the same way. const formatRate = (bps: number | undefined): string => { if (bps === undefined || bps === null || !Number.isFinite(bps)) return "—" if (bps < 1) return "0 B/s" const k = 1024 const sizes = ["B/s", "KB/s", "MB/s", "GB/s"] const i = Math.min(sizes.length - 1, Math.floor(Math.log(bps) / Math.log(k))) const v = bps / Math.pow(k, i) return `${v >= 100 ? v.toFixed(0) : v.toFixed(v >= 10 ? 1 : 2)} ${sizes[i]}` } const formatBytes = (bytes: number | undefined): string => { if (!bytes || bytes === 0) return "0 B" const k = 1024 const sizes = ["B", "KB", "MB", "GB", "TB"] const i = Math.floor(Math.log(bytes) / Math.log(k)) return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}` } const formatStorage = (bytes: number): string => { if (bytes === 0) return "0 B" const k = 1024 const sizes = ["B", "KB", "MB", "GB", "TB", "PB"] const i = Math.floor(Math.log(bytes) / Math.log(k)) const value = bytes / Math.pow(k, i) // Use 1 decimal place for values >= 10, 2 decimal places for values < 10 const decimals = value >= 10 ? 1 : 2 return `${value.toFixed(decimals)} ${sizes[i]}` } const formatSpeed = (speed: number): string => { if (speed === 0) return "N/A" if (speed >= 1000) return `${(speed / 1000).toFixed(1)} Gbps` return `${speed} Mbps` } const fetcher = async (url: string): Promise => { return fetchApi(url) } export function NetworkMetrics() { const { data: networkData, error, isLoading, } = useSWR("/api/network", fetcher, { // Was 15 s — too long for the Network Flow's pulse animation // which needs near-live rates. 3 s gives the dashboard responsive // updates without hammering the backend. refreshInterval: 3000, revalidateOnFocus: true, revalidateOnReconnect: true, }) const [selectedInterface, setSelectedInterface] = useState(null) const [timeframe, setTimeframe] = useState<"hour" | "day" | "week" | "month" | "year">("day") const [modalTimeframe, setModalTimeframe] = useState<"hour" | "day" | "week" | "month" | "year">("day") const [networkTotals, setNetworkTotals] = useState<{ received: number; sent: number }>({ received: 0, sent: 0 }) const [interfaceTotals, setInterfaceTotals] = useState<{ received: number; sent: number }>({ received: 0, sent: 0 }) const [latencyModalOpen, setLatencyModalOpen] = useState(false) const [networkUnit, setNetworkUnit] = useState<"Bytes" | "Bits">(() => getNetworkUnit()) // Latency history for sparkline (last hour) const { data: latencyData } = useSWR<{ data: Array<{ timestamp: number; value: number }> stats: { min: number; max: number; avg: number; current: number } target: string }>("/api/network/latency/history?target=gateway&timeframe=hour", (url: string) => fetchApi(url), { refreshInterval: 60000, revalidateOnFocus: false } ) useEffect(() => { setNetworkUnit(getNetworkUnit()) const handleUnitChange = (e: CustomEvent) => { setNetworkUnit(e.detail === "Bits" ? "Bits" : "Bytes") } window.addEventListener("networkUnitChanged" as any, handleUnitChange) return () => window.removeEventListener("networkUnitChanged" as any, handleUnitChange) }, []) const { data: modalNetworkData } = useSWR(selectedInterface ? "/api/network" : null, fetcher, { refreshInterval: 17000, revalidateOnFocus: false, revalidateOnReconnect: true, }) const { data: interfaceHistoricalData } = useSWR(`/api/node/metrics?timeframe=${timeframe}`, fetcher, { refreshInterval: 29000, revalidateOnFocus: false, }) if (isLoading) { return (
Loading network data...

Scanning interfaces, bridges and traffic

) } if (error || !networkData) { return (
Flask Server Not Available
{error?.message || "Unable to connect to the Flask server. Please ensure the server is running and try again."}
) } const trafficInFormatted = formatNetworkTraffic( networkTotals.received * 1024 ** 3, networkUnit, 2 ) const trafficOutFormatted = formatNetworkTraffic( networkTotals.sent * 1024 ** 3, networkUnit, 2 ) const packetsRecvK = networkData.traffic.packets_recv ? (networkData.traffic.packets_recv / 1000).toFixed(0) : "0" const totalErrors = (networkData.traffic.errin || 0) + (networkData.traffic.errout || 0) const packetLossIn = networkData.traffic.packet_loss_in || 0 const packetLossOut = networkData.traffic.packet_loss_out || 0 const avgPacketLoss = ((packetLossIn + packetLossOut) / 2).toFixed(2) // Determine health status let healthStatus = "Healthy" let healthColor = "bg-green-500/10 text-green-500 border-green-500/20" if (Number.parseFloat(avgPacketLoss) > 5 || totalErrors > 1000) { healthStatus = "Critical" healthColor = "bg-red-500/10 text-red-500 border-red-500/20" } else if (Number.parseFloat(avgPacketLoss) >= 1 || totalErrors >= 100) { healthStatus = "Warning" healthColor = "bg-yellow-500/10 text-yellow-500 border-yellow-500/20" } const allInterfaces = [ ...(networkData.physical_interfaces || []), ...(networkData.bridge_interfaces || []), ...(networkData.vm_lxc_interfaces || []), ] const vmLxcInterfaces = (networkData.vm_lxc_interfaces || []).sort((a, b) => { const vmidA = a.vmid ?? Number.MAX_SAFE_INTEGER const vmidB = b.vmid ?? Number.MAX_SAFE_INTEGER return vmidA - vmidB }) const topInterface = vmLxcInterfaces.length > 0 ? vmLxcInterfaces.reduce((top, iface) => { const ifaceTraffic = (iface.bytes_recv || 0) + (iface.bytes_sent || 0) const topTraffic = (top.bytes_recv || 0) + (top.bytes_sent || 0) return ifaceTraffic > topTraffic ? iface : top }, vmLxcInterfaces[0]) : { name: "No VM/LXC", type: "unknown", bytes_recv: 0, bytes_sent: 0, vm_name: "N/A" } const topInterfaceTraffic = (topInterface.bytes_recv || 0) + (topInterface.bytes_sent || 0) const getTimeframeLabel = () => { switch (timeframe) { case "hour": return "1 Hour" case "day": return "24 Hours" case "week": return "7 Days" case "month": return "30 Days" case "year": return "1 Year" default: return "24 Hours" } } // Compact form for inline header use. The full "24 Hours" gets noisy // next to the title; "Past 24 h" keeps the same meaning in less space. const getTimeframeShortLabel = () => { switch (timeframe) { case "hour": return "Past 1 h" case "day": return "Past 24 h" case "week": return "Past 7 d" case "month": return "Past 30 d" case "year": return "Past 1 y" default: return "Past 24 h" } } const hostname = networkData.hostname || "N/A" const domain = networkData.domain || "N/A" const dnsServers = networkData.dns_servers || [] const primaryDNS = dnsServers[0] || "N/A" const secondaryDNS = dnsServers[1] || "N/A" return (
{/* Network Overview Cards */}
{/* ── Network Traffic (preview restyle: Down/Up dual headline + stacked bar) ── */} {(() => { const downBytes = networkData.traffic.bytes_recv || 0 const upBytes = networkData.traffic.bytes_sent || 0 const totalBytes = downBytes + upBytes const downPct = totalBytes > 0 ? (downBytes / totalBytes) * 100 : 50 const upPct = totalBytes > 0 ? (upBytes / totalBytes) * 100 : 50 return (
Network Traffic {getTimeframeShortLabel()}
Down
{trafficInFormatted}
Up
{trafficOutFormatted}
Down {Math.round(downPct)}% Up {Math.round(upPct)}%
) })()} {/* ── Active Interfaces (preview restyle v2: revertido al original con title uppercase) ── */} Active Interfaces
{(networkData.physical_active_count ?? 0) + (networkData.bridge_active_count ?? 0)}
Physical: {networkData.physical_active_count ?? 0}/{networkData.physical_total_count ?? 0} Bridges: {networkData.bridge_active_count ?? 0}/{networkData.bridge_total_count ?? 0}

{(networkData.physical_total_count ?? 0) + (networkData.bridge_total_count ?? 0)} total interfaces

{/* ── Network Status (preview restyle: packet-loss highlight + 2x2 grid) ── */} Network Status {healthStatus === 'Healthy' ? '✓ ' : ''}{healthStatus} {(() => { const lossPct = Number.parseFloat(avgPacketLoss) || 0 const lossColor = lossPct >= 5 ? 'text-red-500' : lossPct >= 1 ? 'text-orange-500' : lossPct > 0 ? 'text-yellow-500' : 'text-blue-500' return (
{avgPacketLoss}% Packet Loss
) })()}
Hostname:
{hostname}
DNS:
{primaryDNS}
Errors:
{totalErrors}
Domain:
{networkData.domain || '—'}
{/* Latency Card with Sparkline */} setLatencyModalOpen(true)} > Network Latency
{latencyData?.stats?.current ?? 0} ms
{(latencyData?.stats?.current ?? 0) < 50 ? "Excellent" : (latencyData?.stats?.current ?? 0) < 100 ? "Good" : (latencyData?.stats?.current ?? 0) < 200 ? "Fair" : "Poor"}
{/* Sparkline */} {latencyData?.data && latencyData.data.length > 0 && (
)}

Avg: {latencyData?.stats?.avg ?? 0}ms | Max: {latencyData?.stats?.max ?? 0}ms

{/* Timeframe Selector */}
{/* Network Traffic Card with Chart */} Network Traffic {/* Network Flow — proof of concept. Lives next to Network Traffic while the design is validated on a real host. Once approved, this card replaces (or pairs with) the chart above. */} {(() => { const toMBps = (bps?: number) => (bps || 0) / (1024 * 1024) const allIfaces = [ ...(networkData.physical_interfaces || []), ...(networkData.bridge_interfaces || []), ...(networkData.vm_lxc_interfaces || []), ] const flowData: NetworkFlowData = { nics: (networkData.physical_interfaces || []).map((p) => ({ id: p.name, link: formatSpeed(p.speed), rx: toMBps(p.rx_Bps), tx: toMBps(p.tx_Bps), status: (p.status || "").toLowerCase() === "up" ? "up" : "down", })), bridges: (networkData.bridge_interfaces || []).map((b) => ({ id: b.name, parent: b.bridge_physical_interface, })), consumers: [ (() => { // PROXMOX node = sum of every running guest's rate. // This stays consistent with each bridge's own label // (which sums the same guest rates), and with the // total trunk flow — no discrepancy between the host's // displayed rate and the sum of its bridges. const runningGuests = (networkData.vm_lxc_interfaces || []).filter( (v) => v.vm_status !== "stopped" ) return { id: "host", label: "host", kind: "host" as const, bridge: (networkData.bridge_interfaces?.[0]?.name) || "", rx: runningGuests.reduce((a, v) => a + toMBps(v.rx_Bps), 0), tx: runningGuests.reduce((a, v) => a + toMBps(v.tx_Bps), 0), } })(), ...(networkData.vm_lxc_interfaces || []).map((v) => { // Authoritative bridge from the kernel (read by the // backend from /sys/class/net//master). Fallback // to bridge_members scan, then first bridge as last // resort so we never silently drop a guest. const ownerName = (v as any).bridge_owner || (networkData.bridge_interfaces || []).find((b) => (b.bridge_members || []).includes(v.name) )?.name || (networkData.bridge_interfaces?.[0]?.name || "") return { id: v.name, label: v.vm_name || v.name, kind: (v.vm_type === "vm" ? "vm" : "lxc") as "vm" | "lxc", bridge: ownerName, rx: toMBps(v.rx_Bps), tx: toMBps(v.tx_Bps), offline: v.vm_status === "stopped", } }), ], } return ( { // Map the clicked node back to a NetworkInterface and // open the same details modal the cards below use. The // virtual "host" id never matches a real interface, so // it's a no-op — tapping the PROXMOX circle does nothing // (there's no host-level modal in this view). if (name === "host") return const match = allIfaces.find((iface) => iface.name === name) if (match) setSelectedInterface(match) }} /> ) })()} {/* Physical Interfaces section */} Physical Interfaces {networkData.physical_active_count ?? 0}/{networkData.physical_total_count ?? 0} Active {/* Same responsive grid as the Storage page: 3 cols desktop, 2 cols tablet, 1 col mobile. Cards self-size so a row of long interface names won't push others off-screen. */}
{networkData.physical_interfaces.map((iface) => renderPhysicalInterfaceCardV2(iface, setSelectedInterface), )}
{networkData.bridge_interfaces && networkData.bridge_interfaces.length > 0 && ( Bridge Interfaces {networkData.bridge_active_count ?? 0}/{networkData.bridge_total_count ?? 0} Active
{networkData.bridge_interfaces.map((interface_, index) => { const typeBadge = getInterfaceTypeBadge(interface_.type) return (
setSelectedInterface(interface_)} > {/* First row: Icon, Name, Type Badge, Physical Interface (responsive), Status */}
{interface_.name}
{typeBadge.label} {interface_.bridge_physical_interface && (
→ {interface_.bridge_physical_interface} {interface_.bridge_physical_interface.startsWith("bond") && networkData.physical_interfaces && ( <> {(() => { const bondInterface = networkData.physical_interfaces.find( (iface) => iface.name === interface_.bridge_physical_interface, ) if (bondInterface?.bond_slaves && bondInterface.bond_slaves.length > 0) { return ( ({bondInterface.bond_slaves.join(", ")}) ) } return null })()} )} {interface_.bridge_bond_slaves && interface_.bridge_bond_slaves.length > 0 && ( ({interface_.bridge_bond_slaves.join(", ")}) )}
)}
{interface_.status.toUpperCase()}
{/* Second row: Details - Responsive layout */}
IP Address
{interface_.addresses.length > 0 ? interface_.addresses[0].ip : "N/A"}
Speed
{formatSpeed(interface_.speed)}
Duplex
{interface_.duplex}
MTU
{interface_.mtu}
{interface_.mac_address && (
MAC
{interface_.mac_address}
)}
) })}
)} {/* VM & LXC Network Interfaces section */} {networkData.vm_lxc_interfaces && networkData.vm_lxc_interfaces.length > 0 && ( VM & LXC Network Interfaces {networkData.vm_lxc_active_count ?? 0} / {networkData.vm_lxc_total_count ?? 0} Active
{vmLxcInterfaces.map((interface_, index) => { const vmTypeBadge = getVMTypeBadge(interface_.vm_type) return (
setSelectedInterface(interface_)} > {/* First row: Icon, Name, VM/LXC Badge, VM Name, Status */}
{interface_.name}
{vmTypeBadge.label} {interface_.vm_name && (
→ {interface_.vm_name}
)}
{interface_.status.toUpperCase()}
{/* Second row: Details - Responsive layout */}
VMID
{interface_.vmid ?? "N/A"}
Speed
{formatSpeed(interface_.speed)}
Duplex
{interface_.duplex}
MTU
{interface_.mtu}
{interface_.mac_address && (
MAC
{interface_.mac_address}
)}
) })}
)} {/* Interface Details Modal */} setSelectedInterface(null)}> {selectedInterface?.name} - Interface Details View detailed information and network traffic statistics for this interface {selectedInterface?.status.toLowerCase() === "up" && selectedInterface?.vm_type !== "vm" && (
)}
{selectedInterface && (
{(() => { // Find the current interface data from modalNetworkData if available const currentInterfaceData = modalNetworkData ? [ ...(modalNetworkData.physical_interfaces || []), ...(modalNetworkData.bridge_interfaces || []), ...(modalNetworkData.vm_lxc_interfaces || []), ].find((iface) => iface.name === selectedInterface.name) : selectedInterface const displayInterface = currentInterfaceData || selectedInterface return ( <> {/* Basic Information */}

Basic Information

Interface Name
{displayInterface.name}
Type
{getInterfaceTypeBadge(displayInterface.type).label}
{displayInterface.type === "bridge" && displayInterface.bridge_physical_interface && (
Physical Interface
{displayInterface.bridge_physical_interface}
{displayInterface.bridge_physical_interface.startsWith("bond") && modalNetworkData?.physical_interfaces && ( <> {(() => { const bondInterface = modalNetworkData.physical_interfaces.find( (iface) => iface.name === displayInterface.bridge_physical_interface, ) if (bondInterface?.bond_slaves && bondInterface.bond_slaves.length > 0) { return (
Bond Members
{bondInterface.bond_slaves.map((slave, idx) => ( {slave} ))}
) } return null })()} )} {displayInterface.bridge_bond_slaves && displayInterface.bridge_bond_slaves.length > 0 && (
Bond Members
{displayInterface.bridge_bond_slaves.map((slave, idx) => ( {slave} ))}
)}
)} {displayInterface.type === "vm_lxc" && displayInterface.vm_name && (
VM/LXC Name
{displayInterface.vm_name} {displayInterface.vm_type && ( {getVMTypeBadge(displayInterface.vm_type).label} )}
)}
Status
{displayInterface.status.toUpperCase()}
Speed
{formatSpeed(displayInterface.speed)}
Duplex
{displayInterface.duplex}
MTU
{displayInterface.mtu}
{displayInterface.mac_address && (
MAC Address
{displayInterface.mac_address}
)}
{/* IP Addresses */} {displayInterface.addresses.length > 0 && (

IP Addresses

{displayInterface.addresses.map((addr, idx) => (
{addr.ip}
Netmask: {addr.netmask}
))}
)} {/* Network Traffic Statistics - Only show if interface is UP and NOT a VM interface */} {displayInterface.status.toLowerCase() === "up" && displayInterface.vm_type !== "vm" ? (

Network Traffic Statistics ( {modalTimeframe === "hour" ? "Last Hour" : modalTimeframe === "day" ? "Last 24 Hours" : modalTimeframe === "week" ? "Last 7 Days" : modalTimeframe === "month" ? "Last 30 Days" : "Last Year"} )

{networkUnit === "Bits" ? "Bits Received" : "Bytes Received"}
{formatNetworkTraffic( interfaceTotals.received * 1024 ** 3, networkUnit, 2 )}
{networkUnit === "Bits" ? "Bits Sent" : "Bytes Sent"}
{formatNetworkTraffic( interfaceTotals.sent * 1024 ** 3, networkUnit, 2 )}
Packets Received
{displayInterface.packets_recv?.toLocaleString() || "N/A"}
Packets Sent
{displayInterface.packets_sent?.toLocaleString() || "N/A"}
Errors In
{displayInterface.errors_in || 0}
Errors Out
{displayInterface.errors_out || 0}
Drops In
{displayInterface.drops_in || 0}
Drops Out
{displayInterface.drops_out || 0}
) : displayInterface.status.toLowerCase() === "up" && displayInterface.vm_type === "vm" ? (

Traffic since last boot

{networkUnit === "Bits" ? "Bits Received" : "Bytes Received"}
{formatNetworkTraffic(displayInterface.bytes_recv || 0, networkUnit)}
{networkUnit === "Bits" ? "Bits Sent" : "Bytes Sent"}
{formatNetworkTraffic(displayInterface.bytes_sent || 0, networkUnit)}
Packets Received
{displayInterface.packets_recv?.toLocaleString() || "N/A"}
Packets Sent
{displayInterface.packets_sent?.toLocaleString() || "N/A"}
Errors In
{displayInterface.errors_in || 0}
Errors Out
{displayInterface.errors_out || 0}
Drops In
{displayInterface.drops_in || 0}
Drops Out
{displayInterface.drops_out || 0}
) : (

Interface Inactive

This interface is currently down. Network traffic statistics are not available.

)} {/* Bond Information */} {displayInterface.type === "bond" && displayInterface.bond_slaves && (

Bond Configuration

Bonding Mode
{displayInterface.bond_mode || "Unknown"}
{displayInterface.bond_active_slave && (
Active Slave
{displayInterface.bond_active_slave}
)}
Slave Interfaces
{displayInterface.bond_slaves.map((slave, idx) => ( {slave} ))}
)} {/* Bridge Information */} {displayInterface.type === "bridge" && displayInterface.bridge_members && (

Bridge Configuration

Virtual Member Interfaces
{displayInterface.bridge_members.length > 0 ? ( displayInterface.bridge_members .filter( (member) => !member.startsWith("enp") && !member.startsWith("eth") && !member.startsWith("eno") && !member.startsWith("ens") && !member.startsWith("wlan") && !member.startsWith("wlp"), ) .map((member, idx) => ( {member} )) ) : (
No virtual members
)}
)} ) })()}
)}
{/* Latency Detail Modal */}
) }