Files
Checkmate/client/src/Components/design-elements/MonitorStatus.tsx
T

62 lines
1.7 KiB
TypeScript
Raw Normal View History

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";
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";
import { LAYOUT } from "@/Utils/Theme/constants";
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"}
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"}
fontFamily={theme.typography.fontFamilyMonospace}
2026-01-25 02:09:33 +00:00
overflow={"hidden"}
textOverflow={"ellipsis"}
whiteSpace={"nowrap"}
>
{formatUrl(monitor?.url)}
</Typography>
{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>
);
};