fix: connections page traffic calculation

This commit is contained in:
wonfen 2025-02-19 02:24:21 +08:00
parent 1378068a30
commit bb1dbfcfc3
2 changed files with 5 additions and 12 deletions

View File

@ -178,7 +178,7 @@
"Process": "Process", "Process": "Process",
"Time": "Time", "Time": "Time",
"Source": "Source", "Source": "Source",
"Destination": "Destination IP", "Destination": "Destination",
"DestinationPort": "Destination Port", "DestinationPort": "Destination Port",
"Close Connection": "Close Connection", "Close Connection": "Close Connection",
"Rules": "Rules", "Rules": "Rules",

View File

@ -127,9 +127,8 @@ const ConnectionsPage = () => {
return isPaused ? (frozenData ?? connData) : connData; return isPaused ? (frozenData ?? connData) : connData;
}, [isPaused, frozenData, connData]); }, [isPaused, frozenData, connData]);
const [filterConn, download, upload] = useMemo(() => { const [filterConn] = useMemo(() => {
const orderFunc = orderOpts[curOrderOpt]; const orderFunc = orderOpts[curOrderOpt];
let connections = displayData.connections.filter((conn) => { let connections = displayData.connections.filter((conn) => {
const { host, destinationIP, process } = conn.metadata; const { host, destinationIP, process } = conn.metadata;
return ( return (
@ -139,13 +138,7 @@ const ConnectionsPage = () => {
if (orderFunc) connections = orderFunc(connections); if (orderFunc) connections = orderFunc(connections);
let download = 0; return [connections];
let upload = 0;
connections.forEach((x) => {
download += x.download;
upload += x.upload;
});
return [connections, download, upload];
}, [displayData, match, curOrderOpt]); }, [displayData, match, curOrderOpt]);
const onCloseAll = useLockFn(closeAllConnections); const onCloseAll = useLockFn(closeAllConnections);
@ -181,10 +174,10 @@ const ConnectionsPage = () => {
header={ header={
<Box sx={{ display: "flex", alignItems: "center", gap: 2 }}> <Box sx={{ display: "flex", alignItems: "center", gap: 2 }}>
<Box sx={{ mx: 1 }}> <Box sx={{ mx: 1 }}>
{t("Downloaded")}: {parseTraffic(download)} {t("Downloaded")}: {parseTraffic(displayData.downloadTotal)}
</Box> </Box>
<Box sx={{ mx: 1 }}> <Box sx={{ mx: 1 }}>
{t("Uploaded")}: {parseTraffic(upload)} {t("Uploaded")}: {parseTraffic(displayData.uploadTotal)}
</Box> </Box>
<IconButton <IconButton
color="inherit" color="inherit"