diff --git a/AppImage/components/network-metrics.tsx b/AppImage/components/network-metrics.tsx index 21d0479..d1c105a 100644 --- a/AppImage/components/network-metrics.tsx +++ b/AppImage/components/network-metrics.tsx @@ -153,6 +153,7 @@ export function NetworkMetrics() { const [selectedInterface, setSelectedInterface] = useState(null) const [timeframe, setTimeframe] = useState<"hour" | "day" | "week" | "month" | "year">("day") + const [networkTotals, setNetworkTotals] = useState<{ received: number; sent: number }>({ received: 0, sent: 0 }) if (isLoading) { return ( @@ -185,8 +186,8 @@ export function NetworkMetrics() { ) } - const trafficInFormatted = formatStorage(networkData.traffic.bytes_recv) - const trafficOutFormatted = formatStorage(networkData.traffic.bytes_sent) + const trafficInFormatted = formatStorage(networkTotals.received * 1024 * 1024 * 1024) // Convert GB to bytes + const trafficOutFormatted = formatStorage(networkTotals.sent * 1024 * 1024 * 1024) const packetsRecvK = networkData.traffic.packets_recv ? (networkData.traffic.packets_recv / 1000).toFixed(0) : "0" const totalErrors = (networkData.traffic.errin || 0) + (networkData.traffic.errout || 0) @@ -206,6 +207,23 @@ export function NetworkMetrics() { healthColor = "bg-yellow-500/10 text-yellow-500 border-yellow-500/20" } + 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" + } + } + return (
{/* Network Overview Cards */} @@ -317,7 +335,18 @@ export function NetworkMetrics() { - +
+
+ Received: + ↓ {trafficInFormatted} +
+
+ Sent: + ↑ {trafficOutFormatted} +
+

Data transferred in {getTimeframeLabel().toLowerCase()}

+
+