diff --git a/AppImage/components/network-metrics.tsx b/AppImage/components/network-metrics.tsx index c00cd3f..6ebe940 100644 --- a/AppImage/components/network-metrics.tsx +++ b/AppImage/components/network-metrics.tsx @@ -104,6 +104,18 @@ const formatBytes = (bytes: number | undefined): string => { 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` @@ -170,8 +182,8 @@ export function NetworkMetrics() { ) } - const trafficInGB = (networkData.traffic.bytes_recv / 1024 ** 3).toFixed(2) - const trafficOutGB = (networkData.traffic.bytes_sent / 1024 ** 3).toFixed(2) + const trafficInFormatted = formatStorage(networkData.traffic.bytes_recv) + const trafficOutFormatted = formatStorage(networkData.traffic.bytes_sent) const packetsRecvK = networkData.traffic.packets_recv ? (networkData.traffic.packets_recv / 1000).toFixed(0) : "0" const totalErrors = (networkData.traffic.errin || 0) + (networkData.traffic.errout || 0) @@ -204,11 +216,11 @@ export function NetworkMetrics() {
Received: - ↓ {trafficInGB} GB + ↓ {trafficInFormatted}
Sent: - ↑ {trafficOutGB} GB + ↑ {trafficOutFormatted}

Total data transferred

diff --git a/AppImage/components/proxmox-dashboard.tsx b/AppImage/components/proxmox-dashboard.tsx index 4cb0f6c..38aa8db 100644 --- a/AppImage/components/proxmox-dashboard.tsx +++ b/AppImage/components/proxmox-dashboard.tsx @@ -166,7 +166,7 @@ export function ProxmoxDashboard() { case "network": return "Network" case "vms": - return "Virtual Machines" + return "VMs & LXCs" case "hardware": return "Hardware" case "logs": @@ -316,7 +316,7 @@ export function ProxmoxDashboard() { value="vms" className="data-[state=active]:bg-blue-500 data-[state=active]:text-white data-[state=active]:rounded-md" > - Virtual Machines + VMs & LXCs - Virtual Machines + VMs & LXCs