diff --git a/AppImage/components/network-metrics.tsx b/AppImage/components/network-metrics.tsx index de956a5..ac9bf9f 100644 --- a/AppImage/components/network-metrics.tsx +++ b/AppImage/components/network-metrics.tsx @@ -220,11 +220,16 @@ export function NetworkMetrics() { ...(networkData.vm_lxc_interfaces || []), ] - const topInterface = allInterfaces.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 - }, allInterfaces[0] || { name: "N/A", type: "unknown", bytes_recv: 0, bytes_sent: 0 }) + const vmLxcInterfaces = networkData.vm_lxc_interfaces || [] + + 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) @@ -299,9 +304,18 @@ export function NetworkMetrics() { {topInterface.name} - - {getInterfaceTypeBadge(topInterface.type).label} - + {topInterface.vm_type ? ( + + {getVMTypeBadge(topInterface.vm_type).label} + + ) : ( + + {getInterfaceTypeBadge(topInterface.type).label} + + )} + {topInterface.vm_name && topInterface.vm_name !== "N/A" && ( + → {topInterface.vm_name} + )} Total traffic: {formatBytes(topInterfaceTraffic)} @@ -648,7 +662,7 @@ export function NetworkMetrics() { {/* Interface Details Modal */} setSelectedInterface(null)}> - +
Total traffic: {formatBytes(topInterfaceTraffic)}