initial commit
This commit is contained in:
1 parent
7cb985116e
commit
75acf7b38f
955 files changed
+37333
-87054
No files matched your search
@@ -0,0 +1,72 @@
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Box from "@mui/material/Box";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import type { ICheck } from "@/types/check";
|
||||
import { HistogramResponseTimeTooltip } from "@/components/monitors/HistogramResponseTimeTooltip";
|
||||
import { normalizeResponseTimes } from "@/utils/DataUtils";
|
||||
|
||||
const BAR_HEIGHT = "50px";
|
||||
|
||||
export const HistogramStatusPage = ({ checks }: { checks: ICheck[] }) => {
|
||||
const theme = useTheme();
|
||||
const normalChecks = normalizeResponseTimes(checks, "responseTime");
|
||||
let data = Array<any>();
|
||||
|
||||
if (!normalChecks || normalChecks.length === 0) {
|
||||
return null;
|
||||
}
|
||||
if (normalChecks.length !== 25) {
|
||||
const placeholders = Array(25 - normalChecks.length).fill({
|
||||
status: "placeholder",
|
||||
});
|
||||
data = [...normalChecks, ...placeholders];
|
||||
} else {
|
||||
data = normalChecks;
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack
|
||||
direction="row"
|
||||
spacing={"auto"}
|
||||
height={BAR_HEIGHT}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
sx={{
|
||||
cursor: "default",
|
||||
}}
|
||||
>
|
||||
{data.map((check, index) => {
|
||||
return (
|
||||
<HistogramResponseTimeTooltip key={`${check}-${index}`} check={check}>
|
||||
<Box
|
||||
position="relative"
|
||||
width={{
|
||||
xs: theme.spacing(2),
|
||||
sm: theme.spacing(6),
|
||||
}}
|
||||
bgcolor={theme.palette.primary.lowContrast}
|
||||
sx={{
|
||||
borderRadius: theme.spacing(1.5),
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
position="absolute"
|
||||
bottom={0}
|
||||
width="100%"
|
||||
height={`${check.normalResponseTime}%`}
|
||||
bgcolor={
|
||||
check.status === "up"
|
||||
? theme.palette.success.lowContrast
|
||||
: theme.palette.error.lowContrast
|
||||
}
|
||||
sx={{
|
||||
borderRadius: theme.spacing(1.5),
|
||||
transition: "height 600ms cubic-bezier(0.4, 0, 0.2, 1)",
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</HistogramResponseTimeTooltip>
|
||||
);
|
||||
})}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import { ExternalLink } from "lucide-react";
|
||||
|
||||
import type { IStatusPageWithMonitors } from "@/types/status-page";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
const HOST = import.meta.env.VITE_APP_HOST;
|
||||
|
||||
export const NameHeader = ({
|
||||
statusPage,
|
||||
}: {
|
||||
statusPage: IStatusPageWithMonitors;
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Stack direction={"row"} alignItems={"flex-end"} spacing={theme.spacing(4)}>
|
||||
<Typography variant="h1">{statusPage?.name}</Typography>
|
||||
{statusPage?.isPublished && (
|
||||
<Stack
|
||||
component={"a"}
|
||||
href={`${HOST}/status-pages/public/${statusPage?.url}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
direction={"row"}
|
||||
sx={{ textDecoration: "none", color: "inherit" }}
|
||||
>
|
||||
<Typography>Public link</Typography>
|
||||
<ExternalLink size={16} strokeWidth={1.5} />
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Stack from "@mui/material/Stack";
|
||||
|
||||
import { getStatusPageHeaderConfig } from "@/utils/MonitorUtils";
|
||||
import type { IStatusPageWithMonitors } from "@/types/status-page";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
|
||||
export const StatusHeader = ({
|
||||
statusPage,
|
||||
}: {
|
||||
statusPage: IStatusPageWithMonitors;
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const headerConfig = getStatusPageHeaderConfig(statusPage?.monitors || []);
|
||||
|
||||
return (
|
||||
<Stack
|
||||
width={"100%"}
|
||||
bgcolor={theme.palette[headerConfig.paletteKey].lowContrast}
|
||||
borderRadius={theme.shape.borderRadius}
|
||||
padding={theme.spacing(4)}
|
||||
>
|
||||
<Typography variant="h2" alignSelf={"center"}>
|
||||
{headerConfig.message}
|
||||
</Typography>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
import Grid from "@mui/material/Grid";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { HistogramStatusPage } from "./HistogramStatusPage";
|
||||
import { StatusLabel } from "@/components/design-elements";
|
||||
|
||||
import type { IMonitor } from "@/types/monitor";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
|
||||
export const StatusPageRow = ({ monitor }: { monitor: IMonitor }) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Grid container>
|
||||
<Grid size={12}>
|
||||
<Typography>{monitor?.name}</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 8, sm: 10 }}>
|
||||
<HistogramStatusPage checks={monitor?.latestChecks} />
|
||||
</Grid>
|
||||
<Grid
|
||||
size={{ xs: 4, sm: 2 }}
|
||||
paddingLeft={theme.spacing(10)}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
justifyContent={"flex-start"}
|
||||
>
|
||||
<StatusLabel status={monitor?.status} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user