Merge pull request #2794 from Owaiseimdad/Network-patch-fixes-part-1

Fixed the selector and also null points for networks
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-08-15 13:12:04 -07:00
commit cd203ff067
2 files changed
+55 -48

No files matched your search

@@ -1,8 +1,9 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { FormControl, InputLabel, Select, MenuItem, Box } from "@mui/material"; import { Box } from "@mui/material";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import Select from "../../../../../Components/Inputs/Select";
import NetworkStatBoxes from "./NetworkStatBoxes"; import NetworkStatBoxes from "./NetworkStatBoxes";
import NetworkCharts from "./NetworkCharts"; import NetworkCharts from "./NetworkCharts";
import MonitorTimeFrameHeader from "../../../../../Components/MonitorTimeFrameHeader"; import MonitorTimeFrameHeader from "../../../../../Components/MonitorTimeFrameHeader";
@@ -63,27 +64,17 @@ const Network = ({ net, checks, isLoading, dateRange, setDateRange }) => {
gap={theme.spacing(4)} gap={theme.spacing(4)}
> >
{availableInterfaces.length > 0 && ( {availableInterfaces.length > 0 && (
<FormControl <Select
variant="outlined" name="networkInterface"
size="small" label={t("networkInterface")}
value={selectedInterface}
onChange={(e) => setSelectedInterface(e.target.value)}
items={availableInterfaces.map((interfaceName) => ({
_id: interfaceName,
name: interfaceName,
}))}
sx={{ minWidth: 200 }} sx={{ minWidth: 200 }}
> />
<InputLabel>{t("networkInterface")}</InputLabel>
<Select
value={selectedInterface}
onChange={(e) => setSelectedInterface(e.target.value)}
label={t("networkInterface")}
>
{availableInterfaces.map((interfaceName) => (
<MenuItem
key={interfaceName}
value={interfaceName}
>
{interfaceName}
</MenuItem>
))}
</Select>
</FormControl>
)} )}
<MonitorTimeFrameHeader <MonitorTimeFrameHeader
isLoading={isLoading} isLoading={isLoading}
@@ -218,9 +218,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
{ {
$project: { $project: {
diskCount: { diskCount: {
$size: "$disk", $size: { $ifNull: ["$disk", []] },
}, },
netCount: { $size: "$net" }, netCount: { $size: { $ifNull: ["$net", []] } },
}, },
}, },
{ {
@@ -381,7 +381,7 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
}, },
net: { net: {
$map: { $map: {
input: { $range: [0, { $size: { $arrayElemAt: ["$net", 0] } }] }, input: { $range: [0, { $size: { $ifNull: [{ $arrayElemAt: ["$net", 0] }, []] } }] },
as: "netIndex", as: "netIndex",
in: { in: {
name: { name: {
@@ -409,7 +409,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
$arrayElemAt: [ $arrayElemAt: [
{ {
$map: { $map: {
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] }, input: {
$arrayElemAt: [{ $ifNull: ["$net", []] }, { $subtract: [{ $size: { $ifNull: ["$net", []] } }, 1] }],
},
as: "iface", as: "iface",
in: "$$iface.bytes_sent", in: "$$iface.bytes_sent",
}, },
@@ -418,7 +420,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
], ],
}, },
tFirst: { $arrayElemAt: ["$updatedAts", 0] }, tFirst: { $arrayElemAt: ["$updatedAts", 0] },
tLast: { $arrayElemAt: ["$updatedAts", { $subtract: [{ $size: "$updatedAts" }, 1] }] }, tLast: {
$arrayElemAt: [{ $ifNull: ["$updatedAts", []] }, { $subtract: [{ $size: { $ifNull: ["$updatedAts", []] } }, 1] }],
},
}, },
in: { in: {
$cond: [ $cond: [
@@ -444,7 +448,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
$arrayElemAt: [ $arrayElemAt: [
{ {
$map: { $map: {
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] }, input: {
$arrayElemAt: [{ $ifNull: ["$net", []] }, { $subtract: [{ $size: { $ifNull: ["$net", []] } }, 1] }],
},
as: "iface", as: "iface",
in: "$$iface.bytes_recv", in: "$$iface.bytes_recv",
}, },
@@ -453,7 +459,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
], ],
}, },
tFirst: { $arrayElemAt: ["$updatedAts", 0] }, tFirst: { $arrayElemAt: ["$updatedAts", 0] },
tLast: { $arrayElemAt: ["$updatedAts", { $subtract: [{ $size: "$updatedAts" }, 1] }] }, tLast: {
$arrayElemAt: [{ $ifNull: ["$updatedAts", []] }, { $subtract: [{ $size: { $ifNull: ["$updatedAts", []] } }, 1] }],
},
}, },
in: { in: {
$cond: [ $cond: [
@@ -479,7 +487,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
$arrayElemAt: [ $arrayElemAt: [
{ {
$map: { $map: {
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] }, input: {
$arrayElemAt: [{ $ifNull: ["$net", []] }, { $subtract: [{ $size: { $ifNull: ["$net", []] } }, 1] }],
},
as: "iface", as: "iface",
in: "$$iface.packets_sent", in: "$$iface.packets_sent",
}, },
@@ -488,7 +498,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
], ],
}, },
tFirst: { $arrayElemAt: ["$updatedAts", 0] }, tFirst: { $arrayElemAt: ["$updatedAts", 0] },
tLast: { $arrayElemAt: ["$updatedAts", { $subtract: [{ $size: "$updatedAts" }, 1] }] }, tLast: {
$arrayElemAt: [{ $ifNull: ["$updatedAts", []] }, { $subtract: [{ $size: { $ifNull: ["$updatedAts", []] } }, 1] }],
},
}, },
in: { in: {
$cond: [ $cond: [
@@ -522,9 +534,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
$map: { $map: {
input: { input: {
$arrayElemAt: [ $arrayElemAt: [
"$net", { $ifNull: ["$net", []] },
{ {
$subtract: [{ $size: "$net" }, 1], $subtract: [{ $size: { $ifNull: ["$net", []] } }, 1],
}, },
], ],
}, },
@@ -538,9 +550,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
tFirst: { $arrayElemAt: ["$updatedAts", 0] }, tFirst: { $arrayElemAt: ["$updatedAts", 0] },
tLast: { tLast: {
$arrayElemAt: [ $arrayElemAt: [
"$updatedAts", { $ifNull: ["$updatedAts", []] },
{ {
$subtract: [{ $size: "$updatedAts" }, 1], $subtract: [{ $size: { $ifNull: ["$updatedAts", []] } }, 1],
}, },
], ],
}, },
@@ -566,7 +578,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
$arrayElemAt: [ $arrayElemAt: [
{ {
$map: { $map: {
input: { $arrayElemAt: ["$net", { $subtract: [{ $size: "$net" }, 1] }] }, input: {
$arrayElemAt: [{ $ifNull: ["$net", []] }, { $subtract: [{ $size: { $ifNull: ["$net", []] } }, 1] }],
},
as: "iface", as: "iface",
in: "$$iface.err_in", in: "$$iface.err_in",
}, },
@@ -575,7 +589,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
], ],
}, },
tFirst: { $arrayElemAt: ["$updatedAts", 0] }, tFirst: { $arrayElemAt: ["$updatedAts", 0] },
tLast: { $arrayElemAt: ["$updatedAts", { $subtract: [{ $size: "$updatedAts" }, 1] }] }, tLast: {
$arrayElemAt: [{ $ifNull: ["$updatedAts", []] }, { $subtract: [{ $size: { $ifNull: ["$updatedAts", []] } }, 1] }],
},
}, },
in: { in: {
$cond: [ $cond: [
@@ -609,9 +625,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
$map: { $map: {
input: { input: {
$arrayElemAt: [ $arrayElemAt: [
"$net", { $ifNull: ["$net", []] },
{ {
$subtract: [{ $size: "$net" }, 1], $subtract: [{ $size: { $ifNull: ["$net", []] } }, 1],
}, },
], ],
}, },
@@ -625,9 +641,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
tFirst: { $arrayElemAt: ["$updatedAts", 0] }, tFirst: { $arrayElemAt: ["$updatedAts", 0] },
tLast: { tLast: {
$arrayElemAt: [ $arrayElemAt: [
"$updatedAts", { $ifNull: ["$updatedAts", []] },
{ {
$subtract: [{ $size: "$updatedAts" }, 1], $subtract: [{ $size: { $ifNull: ["$updatedAts", []] } }, 1],
}, },
], ],
}, },
@@ -664,9 +680,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
$map: { $map: {
input: { input: {
$arrayElemAt: [ $arrayElemAt: [
"$net", { $ifNull: ["$net", []] },
{ {
$subtract: [{ $size: "$net" }, 1], $subtract: [{ $size: { $ifNull: ["$net", []] } }, 1],
}, },
], ],
}, },
@@ -680,9 +696,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
tFirst: { $arrayElemAt: ["$updatedAts", 0] }, tFirst: { $arrayElemAt: ["$updatedAts", 0] },
tLast: { tLast: {
$arrayElemAt: [ $arrayElemAt: [
"$updatedAts", { $ifNull: ["$updatedAts", []] },
{ {
$subtract: [{ $size: "$updatedAts" }, 1], $subtract: [{ $size: { $ifNull: ["$updatedAts", []] } }, 1],
}, },
], ],
}, },
@@ -719,9 +735,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
$map: { $map: {
input: { input: {
$arrayElemAt: [ $arrayElemAt: [
"$net", { $ifNull: ["$net", []] },
{ {
$subtract: [{ $size: "$net" }, 1], $subtract: [{ $size: { $ifNull: ["$net", []] } }, 1],
}, },
], ],
}, },
@@ -735,9 +751,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
tFirst: { $arrayElemAt: ["$updatedAts", 0] }, tFirst: { $arrayElemAt: ["$updatedAts", 0] },
tLast: { tLast: {
$arrayElemAt: [ $arrayElemAt: [
"$updatedAts", { $ifNull: ["$updatedAts", []] },
{ {
$subtract: [{ $size: "$updatedAts" }, 1], $subtract: [{ $size: { $ifNull: ["$updatedAts", []] } }, 1],
}, },
], ],
}, },