2025-01-31 13:43:57 -08:00
|
|
|
// Components
|
2025-08-03 00:30:04 +05:30
|
|
|
import { Stack, Typography, Tab } from "@mui/material";
|
2025-09-27 14:54:55 -07:00
|
|
|
import Breadcrumbs from "@/Components/v1/Breadcrumbs/index.jsx";
|
|
|
|
|
import MonitorDetailsControlHeader from "@/Components/v1/MonitorDetailsControlHeader/index.jsx";
|
|
|
|
|
import MonitorTimeFrameHeader from "@/Components/v1/MonitorTimeFrameHeader/index.jsx";
|
2025-09-25 10:11:41 -07:00
|
|
|
import StatusBoxes from "./Components/StatusBoxes/index.jsx";
|
|
|
|
|
import GaugeBoxes from "./Components/GaugeBoxes/index.jsx";
|
|
|
|
|
import AreaChartBoxes from "./Components/AreaChartBoxes/index.jsx";
|
2025-09-27 14:54:55 -07:00
|
|
|
import GenericFallback from "@/Components/v1/GenericFallback/index.jsx";
|
2025-09-25 10:11:41 -07:00
|
|
|
import NetworkStats from "./Components/NetworkStats/index.jsx";
|
2026-01-16 19:07:49 -05:00
|
|
|
import ContainerStats from "./Components/ContainerStats/index.jsx";
|
2025-09-27 14:54:55 -07:00
|
|
|
import CustomTabList from "@/Components/v1/Tab/index.jsx";
|
2025-08-03 00:30:04 +05:30
|
|
|
import TabContext from "@mui/lab/TabContext";
|
2025-01-31 13:43:57 -08:00
|
|
|
|
|
|
|
|
// Utils
|
2024-11-19 11:40:45 +08:00
|
|
|
import { useTheme } from "@emotion/react";
|
2026-01-12 23:57:39 +00:00
|
|
|
import { useIsAdmin } from "@/Hooks/useIsAdmin.js";
|
|
|
|
|
import { useFetchHardwareMonitorById } from "../../../Hooks/monitorHooks.js";
|
2025-01-31 13:43:57 -08:00
|
|
|
import { useState } from "react";
|
2025-03-12 00:56:28 +05:30
|
|
|
import { useTranslation } from "react-i18next";
|
2025-01-31 13:43:57 -08:00
|
|
|
import { useParams } from "react-router-dom";
|
2024-11-23 12:00:35 +08:00
|
|
|
|
2025-01-31 13:43:57 -08:00
|
|
|
// Constants
|
|
|
|
|
const BREADCRUMBS = [
|
|
|
|
|
{ name: "infrastructure monitors", path: "/infrastructure" },
|
|
|
|
|
{ name: "details", path: "" },
|
|
|
|
|
];
|
|
|
|
|
const InfrastructureDetails = () => {
|
|
|
|
|
// Local state
|
2025-03-05 11:23:45 -08:00
|
|
|
const [dateRange, setDateRange] = useState("recent");
|
2025-06-16 11:17:09 +08:00
|
|
|
const [trigger, setTrigger] = useState(false);
|
2025-08-03 00:30:04 +05:30
|
|
|
const [tab, setTab] = useState("details");
|
2024-11-19 14:39:58 +08:00
|
|
|
|
2025-01-31 13:43:57 -08:00
|
|
|
// Utils
|
2024-11-19 11:40:45 +08:00
|
|
|
const theme = useTheme();
|
|
|
|
|
const { monitorId } = useParams();
|
2025-03-12 00:56:28 +05:30
|
|
|
const { t } = useTranslation();
|
2025-03-14 21:37:03 -04:00
|
|
|
const isAdmin = useIsAdmin();
|
2024-11-25 12:25:48 +08:00
|
|
|
|
2025-06-12 12:44:46 +08:00
|
|
|
const [monitor, isLoading, networkError] = useFetchHardwareMonitorById({
|
2025-01-31 13:43:57 -08:00
|
|
|
monitorId,
|
|
|
|
|
dateRange,
|
2025-06-16 11:17:09 +08:00
|
|
|
updateTrigger: trigger,
|
2025-01-31 13:43:57 -08:00
|
|
|
});
|
2024-12-31 20:00:22 -08:00
|
|
|
|
2025-06-16 11:17:09 +08:00
|
|
|
const triggerUpdate = () => {
|
|
|
|
|
setTrigger(!trigger);
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-31 13:43:57 -08:00
|
|
|
if (networkError === true) {
|
|
|
|
|
return (
|
|
|
|
|
<GenericFallback>
|
|
|
|
|
<Typography
|
|
|
|
|
variant="h1"
|
|
|
|
|
marginY={theme.spacing(4)}
|
|
|
|
|
color={theme.palette.primary.contrastTextTertiary}
|
2024-11-19 11:40:45 +08:00
|
|
|
>
|
2025-06-07 19:30:55 +02:00
|
|
|
{t("common.toasts.networkError")}
|
2025-01-31 13:43:57 -08:00
|
|
|
</Typography>
|
2025-06-07 19:30:55 +02:00
|
|
|
<Typography>{t("common.toasts.checkConnection")}</Typography>
|
2025-01-31 13:43:57 -08:00
|
|
|
</GenericFallback>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-12-31 20:00:22 -08:00
|
|
|
|
2025-02-01 07:59:40 -08:00
|
|
|
if (!isLoading && monitor?.stats?.checks?.length === 0) {
|
|
|
|
|
return (
|
|
|
|
|
<Stack gap={theme.spacing(10)}>
|
|
|
|
|
<Breadcrumbs list={BREADCRUMBS} />
|
2025-06-16 11:17:09 +08:00
|
|
|
<MonitorDetailsControlHeader
|
2025-02-01 07:59:40 -08:00
|
|
|
path={"infrastructure"}
|
2025-06-16 11:17:09 +08:00
|
|
|
isLoading={isLoading}
|
|
|
|
|
isAdmin={isAdmin}
|
2025-02-01 07:59:40 -08:00
|
|
|
monitor={monitor}
|
2025-06-16 11:17:09 +08:00
|
|
|
triggerUpdate={triggerUpdate}
|
2025-02-01 07:59:40 -08:00
|
|
|
/>
|
|
|
|
|
<GenericFallback>
|
2025-03-12 00:56:28 +05:30
|
|
|
<Typography>{t("distributedUptimeDetailsNoMonitorHistory")}</Typography>
|
2025-02-01 07:59:40 -08:00
|
|
|
</GenericFallback>
|
|
|
|
|
</Stack>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-12-31 20:00:22 -08:00
|
|
|
|
2025-01-31 13:43:57 -08:00
|
|
|
return (
|
|
|
|
|
<Stack gap={theme.spacing(10)}>
|
|
|
|
|
<Breadcrumbs list={BREADCRUMBS} />
|
2025-06-16 11:17:09 +08:00
|
|
|
<MonitorDetailsControlHeader
|
2025-01-31 13:43:57 -08:00
|
|
|
path={"infrastructure"}
|
2025-06-16 11:17:09 +08:00
|
|
|
isLoading={isLoading}
|
2025-03-14 21:37:03 -04:00
|
|
|
isAdmin={isAdmin}
|
2025-01-31 13:43:57 -08:00
|
|
|
monitor={monitor}
|
2025-06-16 11:17:09 +08:00
|
|
|
triggerUpdate={triggerUpdate}
|
2025-01-31 13:43:57 -08:00
|
|
|
/>
|
2025-08-03 00:30:04 +05:30
|
|
|
<TabContext value={tab}>
|
|
|
|
|
<CustomTabList
|
|
|
|
|
value={tab}
|
|
|
|
|
onChange={(e, v) => setTab(v)}
|
|
|
|
|
>
|
|
|
|
|
<Tab
|
2025-08-05 21:04:15 +05:30
|
|
|
label={t("details")}
|
2025-08-03 00:30:04 +05:30
|
|
|
value="details"
|
|
|
|
|
/>
|
|
|
|
|
<Tab
|
2025-08-05 21:04:15 +05:30
|
|
|
label={t("network")}
|
2025-08-03 00:30:04 +05:30
|
|
|
value="network"
|
|
|
|
|
/>
|
2026-01-16 19:07:49 -05:00
|
|
|
{monitor?.enableProxmoxContainers && (
|
|
|
|
|
<Tab
|
|
|
|
|
label={t("containers")}
|
|
|
|
|
value="containers"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-08-03 00:30:04 +05:30
|
|
|
</CustomTabList>
|
|
|
|
|
{tab === "details" && (
|
|
|
|
|
<>
|
|
|
|
|
<StatusBoxes
|
|
|
|
|
shouldRender={!isLoading}
|
|
|
|
|
monitor={monitor}
|
|
|
|
|
/>
|
|
|
|
|
<GaugeBoxes
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
monitor={monitor}
|
|
|
|
|
/>
|
|
|
|
|
<MonitorTimeFrameHeader
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
dateRange={dateRange}
|
|
|
|
|
setDateRange={setDateRange}
|
|
|
|
|
/>
|
|
|
|
|
<AreaChartBoxes
|
|
|
|
|
shouldRender={!isLoading}
|
|
|
|
|
monitor={monitor}
|
2025-08-20 18:14:42 -04:00
|
|
|
dateRange={dateRange}
|
2025-08-03 00:30:04 +05:30
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{tab === "network" && (
|
|
|
|
|
<NetworkStats
|
|
|
|
|
net={monitor?.stats?.aggregateData?.latestCheck?.net || []}
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
checks={monitor?.stats?.checks}
|
|
|
|
|
dateRange={dateRange}
|
|
|
|
|
setDateRange={setDateRange}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2026-01-16 19:07:49 -05:00
|
|
|
{tab === "containers" && monitor?.enableProxmoxContainers && (
|
|
|
|
|
<ContainerStats
|
|
|
|
|
containers={monitor?.stats?.aggregateData?.latestCheck?.containers || []}
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
checks={monitor?.stats?.checks}
|
|
|
|
|
dateRange={dateRange}
|
|
|
|
|
setDateRange={setDateRange}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-08-03 00:30:04 +05:30
|
|
|
</TabContext>
|
2025-01-31 13:43:57 -08:00
|
|
|
</Stack>
|
2024-11-19 11:40:45 +08:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default InfrastructureDetails;
|