mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-21 04:56:18 +00:00
Update network-traffic-chart.tsx
This commit is contained in:
@@ -187,11 +187,20 @@ export function NetworkTrafficChart({
|
|||||||
|
|
||||||
setData(transformedData)
|
setData(transformedData)
|
||||||
|
|
||||||
const totalReceived = transformedData.reduce((sum: number, item: NetworkMetricsData) => sum + item.netIn, 0)
|
const totalReceivedGB = result.data.reduce((sum: number, item: any, index: number) => {
|
||||||
const totalSent = transformedData.reduce((sum: number, item: NetworkMetricsData) => sum + item.netOut, 0)
|
const intervalSeconds = index > 0 ? item.time - result.data[index - 1].time : 60
|
||||||
|
const netInBytes = (item.netin || 0) * intervalSeconds
|
||||||
|
return sum + (netInBytes / 1024 / 1024 / 1024)
|
||||||
|
}, 0)
|
||||||
|
|
||||||
|
const totalSentGB = result.data.reduce((sum: number, item: any, index: number) => {
|
||||||
|
const intervalSeconds = index > 0 ? item.time - result.data[index - 1].time : 60
|
||||||
|
const netOutBytes = (item.netout || 0) * intervalSeconds
|
||||||
|
return sum + (netOutBytes / 1024 / 1024 / 1024)
|
||||||
|
}, 0)
|
||||||
|
|
||||||
if (onTotalsCalculated) {
|
if (onTotalsCalculated) {
|
||||||
onTotalsCalculated({ received: totalReceived, sent: totalSent })
|
onTotalsCalculated({ received: totalReceivedGB, sent: totalSentGB })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInitialLoad) {
|
if (isInitialLoad) {
|
||||||
|
|||||||
Reference in New Issue
Block a user