Files
Checkmate/Client/src/Pages/DistributedUptime/Monitors/index.jsx
T

76 lines
2.1 KiB
React
Raw Normal View History

2025-02-05 13:31:41 -08:00
// Components
2025-02-06 14:57:28 -08:00
import { Stack, Typography } from "@mui/material";
2025-02-05 13:59:56 -08:00
import Breadcrumbs from "../../../Components/Breadcrumbs";
2025-02-06 14:57:28 -08:00
import CreateMonitorHeader from "../../../Components/MonitorCreateHeader";
import MonitorTable from "./Components/MonitorTable";
import Fallback from "../../../Components/Fallback";
import GenericFallback from "../../../Components/GenericFallback";
2025-02-05 13:31:41 -08:00
// Utils
import { useTheme } from "@mui/material/styles";
2025-02-06 14:57:28 -08:00
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
import { useSubscribeToMonitors } from "./Hooks/useSubscribeToMonitors";
import SkeletonLayout from "./Components/Skeleton";
2025-02-05 13:31:41 -08:00
// Constants
const BREADCRUMBS = [{ name: `Distributed Uptime`, path: "/distributed-uptime" }];
const DistributedUptimeMonitors = () => {
// Local state
// Utils
const theme = useTheme();
2025-02-06 14:57:28 -08:00
const isAdmin = useIsAdmin();
const [isLoading, networkError, monitors, monitorsSummary, filteredMonitors] =
useSubscribeToMonitors();
2025-02-05 13:31:41 -08:00
if (isLoading) {
return <SkeletonLayout />;
}
2025-02-06 14:57:28 -08:00
if (networkError) {
return (
<GenericFallback>
<Typography
variant="h1"
marginY={theme.spacing(4)}
color={theme.palette.primary.contrastTextTertiary}
>
Network error
</Typography>
<Typography>Please check your connection</Typography>
</GenericFallback>
);
}
2025-02-05 13:31:41 -08:00
2025-02-06 14:57:28 -08:00
if (typeof monitorsSummary !== "undefined" && monitorsSummary.totalMonitors === 0) {
return (
<Fallback
vowelStart={false}
title="distributed uptime monitor"
checks={[
2025-02-06 16:08:26 -08:00
"Check if a server is online from multiple locations",
"Detect outages and performance issues in real time",
"Reduce false alarms by verifying downtime from different networks",
"Provide insights on regional availability and latency",
2025-02-06 14:57:28 -08:00
]}
link="/distributed-uptime/create"
isAdmin={isAdmin}
/>
);
}
2025-02-05 13:31:41 -08:00
return (
2025-02-06 14:57:28 -08:00
<Stack gap={theme.spacing(10)}>
2025-02-05 13:31:41 -08:00
<Breadcrumbs list={BREADCRUMBS} />
2025-02-06 14:57:28 -08:00
<CreateMonitorHeader
isAdmin={isAdmin}
shouldRender={!isLoading}
path="/distributed-uptime/create"
/>
<MonitorTable
isLoading={isLoading}
monitors={filteredMonitors}
/>
2025-02-05 13:31:41 -08:00
</Stack>
);
};
export default DistributedUptimeMonitors;