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

69 lines
1.9 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";
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
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={[
"Check if a website or service is up and running",
"Make use of UpRock's distributed network",
]}
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;