2026-01-25 02:09:33 +00:00
|
|
|
import type { Monitor } from "@/Types/Monitor";
|
|
|
|
|
import Stack from "@mui/material/Stack";
|
|
|
|
|
import Typography from "@mui/material/Typography";
|
2026-04-07 07:02:44 -04:00
|
|
|
import { PulseDot, Dot, StrategyBadge } from "@/Components/design-elements";
|
2026-01-25 02:09:33 +00:00
|
|
|
import { getStatusColor, formatUrl } from "@/Utils/MonitorUtils";
|
|
|
|
|
import { useTheme } from "@mui/material/styles";
|
2026-02-20 18:10:43 +00:00
|
|
|
import { typographyLevels } from "@/Utils/Theme/Palette";
|
2026-01-25 02:09:33 +00:00
|
|
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
2026-04-07 07:02:44 -04:00
|
|
|
import { LAYOUT } from "@/Utils/Theme/constants";
|
2026-07-31 13:00:58 -07:00
|
|
|
import { formatDuration } from "@/Utils/TimeUtils";
|
2026-01-25 02:09:33 +00:00
|
|
|
export const MonitorStatus = ({ monitor }: { monitor: Monitor }) => {
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
|
|
|
|
|
|
|
|
|
if (!monitor) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<Stack>
|
|
|
|
|
<Typography
|
2026-04-29 09:37:37 -07:00
|
|
|
fontSize={typographyLevels.xxl}
|
2026-01-25 02:09:33 +00:00
|
|
|
fontWeight={500}
|
|
|
|
|
overflow={"hidden"}
|
|
|
|
|
textOverflow={"ellipsis"}
|
|
|
|
|
whiteSpace={"nowrap"}
|
|
|
|
|
>
|
|
|
|
|
{monitor.name}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Stack
|
|
|
|
|
direction="row"
|
|
|
|
|
alignItems={"center"}
|
2026-04-07 07:02:44 -04:00
|
|
|
gap={theme.spacing(LAYOUT.XS)}
|
2026-01-25 02:09:33 +00:00
|
|
|
>
|
|
|
|
|
<PulseDot color={getStatusColor(monitor.status, theme)} />
|
|
|
|
|
<Typography
|
|
|
|
|
fontSize={typographyLevels.l}
|
|
|
|
|
fontWeight={"bolder"}
|
2026-04-26 01:22:01 -04:00
|
|
|
fontFamily={theme.typography.fontFamilyMonospace}
|
2026-01-25 02:09:33 +00:00
|
|
|
overflow={"hidden"}
|
|
|
|
|
textOverflow={"ellipsis"}
|
|
|
|
|
whiteSpace={"nowrap"}
|
|
|
|
|
>
|
|
|
|
|
{formatUrl(monitor?.url)}
|
|
|
|
|
</Typography>
|
2026-04-07 07:02:44 -04:00
|
|
|
{monitor.type === "pagespeed" && monitor.strategy && (
|
|
|
|
|
<>
|
|
|
|
|
<Dot />
|
|
|
|
|
<StrategyBadge strategy={monitor.strategy} />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2026-01-25 02:09:33 +00:00
|
|
|
{!isSmall && (
|
|
|
|
|
<>
|
|
|
|
|
<Dot />
|
2026-07-31 13:05:10 -07:00
|
|
|
<Typography>
|
|
|
|
|
Checking every {formatDuration(monitor?.interval, true)}
|
|
|
|
|
</Typography>
|
2026-01-25 02:09:33 +00:00
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Stack>
|
|
|
|
|
</Stack>
|
|
|
|
|
);
|
|
|
|
|
};
|