Merge pull request #3569 from bluewave-labs/feat/status-page-themes-frontend
feat(status-page): four selectable themes for the public status page
This commit is contained in:
41 files changed
+3704
-617
No files matched your search
@@ -12,13 +12,15 @@ Checkmate is an open-source uptime and infrastructure monitoring application. It
|
|||||||
```bash
|
```bash
|
||||||
cd client
|
cd client
|
||||||
npm install
|
npm install
|
||||||
npm run dev # Start dev server at http://localhost:5173
|
npm run dev -- --port 10001 --strictPort # Local dev port is 10001 (5173 is used by another project on this machine)
|
||||||
npm run build # TypeScript check + production build
|
npm run build # TypeScript check + production build
|
||||||
npm run lint # ESLint (strict, max-warnings 0)
|
npm run lint # ESLint (strict, max-warnings 0)
|
||||||
npm run format # Prettier formatting
|
npm run format # Prettier formatting
|
||||||
npm run format-check # Check formatting
|
npm run format-check # Check formatting
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Server `.env` on this machine is configured with `CLIENT_HOST="http://localhost:10001"` to match the client dev port. If you change the client port, keep `.env` in sync.
|
||||||
|
|
||||||
### Server (Node.js/Express)
|
### Server (Node.js/Express)
|
||||||
```bash
|
```bash
|
||||||
cd server
|
cd server
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { statusPageSchema, type StatusPageFormData } from "@/Validation/statusPage";
|
import { statusPageSchema, type StatusPageFormData } from "@/Validation/statusPage";
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
import type { StatusPage } from "@/Types/StatusPage";
|
||||||
|
import {
|
||||||
|
DEFAULT_STATUS_PAGE_THEME,
|
||||||
|
DEFAULT_STATUS_PAGE_THEME_MODE,
|
||||||
|
} from "@/Types/StatusPage";
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
|
||||||
interface UseStatusPageFormOptions {
|
interface UseStatusPageFormOptions {
|
||||||
@@ -36,6 +40,8 @@ export const useStatusPageForm = ({
|
|||||||
showAdminLoginLink: data?.showAdminLoginLink ?? false,
|
showAdminLoginLink: data?.showAdminLoginLink ?? false,
|
||||||
showInfrastructure: data?.showInfrastructure ?? false,
|
showInfrastructure: data?.showInfrastructure ?? false,
|
||||||
customCSS: data?.customCSS || "",
|
customCSS: data?.customCSS || "",
|
||||||
|
theme: data?.theme ?? DEFAULT_STATUS_PAGE_THEME,
|
||||||
|
themeMode: data?.themeMode ?? DEFAULT_STATUS_PAGE_THEME_MODE,
|
||||||
logo: transformLogo(data?.logo),
|
logo: transformLogo(data?.logo),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import RadioGroup from "@mui/material/RadioGroup";
|
||||||
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
import { useTheme } from "@mui/material/styles";
|
||||||
|
import { RadioWithDescription, Select } from "@/Components/inputs";
|
||||||
|
import {
|
||||||
|
STATUS_PAGE_THEMES,
|
||||||
|
STATUS_PAGE_THEME_MODES,
|
||||||
|
type StatusPageTheme,
|
||||||
|
type StatusPageThemeMode,
|
||||||
|
} from "@/Types/StatusPage";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
theme: StatusPageTheme;
|
||||||
|
themeMode: StatusPageThemeMode;
|
||||||
|
onThemeChange: (value: StatusPageTheme) => void;
|
||||||
|
onThemeModeChange: (value: StatusPageThemeMode) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ThemePicker = ({
|
||||||
|
theme,
|
||||||
|
themeMode,
|
||||||
|
onThemeChange,
|
||||||
|
onThemeModeChange,
|
||||||
|
}: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const muiTheme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack spacing={muiTheme.spacing(6)}>
|
||||||
|
<RadioGroup
|
||||||
|
value={theme}
|
||||||
|
onChange={(_, value) => onThemeChange(value as StatusPageTheme)}
|
||||||
|
>
|
||||||
|
<Stack spacing={muiTheme.spacing(4)}>
|
||||||
|
{STATUS_PAGE_THEMES.map((option) => (
|
||||||
|
<RadioWithDescription
|
||||||
|
key={option}
|
||||||
|
value={option}
|
||||||
|
label={t(`pages.statusPages.form.theme.options.${option}.name`)}
|
||||||
|
description={t(
|
||||||
|
`pages.statusPages.form.theme.options.${option}.description`
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<Select
|
||||||
|
fieldLabel={t("pages.statusPages.form.themeMode.label")}
|
||||||
|
value={themeMode}
|
||||||
|
onChange={(e) => onThemeModeChange(e.target.value as StatusPageThemeMode)}
|
||||||
|
>
|
||||||
|
{STATUS_PAGE_THEME_MODES.map((mode) => (
|
||||||
|
<MenuItem
|
||||||
|
key={mode}
|
||||||
|
value={mode}
|
||||||
|
>
|
||||||
|
{t(`pages.statusPages.form.themeMode.${mode}`)}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -34,6 +34,7 @@ import timezones from "@/Utils/timezones.json";
|
|||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { HeaderConfigStatusControls } from "./Components/HeaderConfigStatusControls";
|
import { HeaderConfigStatusControls } from "./Components/HeaderConfigStatusControls";
|
||||||
|
import { ThemePicker } from "./Components/ThemePicker";
|
||||||
|
|
||||||
const monitorsUrl = (() => {
|
const monitorsUrl = (() => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
@@ -139,6 +140,8 @@ const CreateStatusPage = () => {
|
|||||||
fd.append("showUptimePercentage", String(data.showUptimePercentage));
|
fd.append("showUptimePercentage", String(data.showUptimePercentage));
|
||||||
fd.append("showAdminLoginLink", String(data.showAdminLoginLink));
|
fd.append("showAdminLoginLink", String(data.showAdminLoginLink));
|
||||||
fd.append("showInfrastructure", String(data.showInfrastructure));
|
fd.append("showInfrastructure", String(data.showInfrastructure));
|
||||||
|
if (data.theme) fd.append("theme", data.theme);
|
||||||
|
if (data.themeMode) fd.append("themeMode", data.themeMode);
|
||||||
|
|
||||||
data.monitors.forEach((monitorId) => {
|
data.monitors.forEach((monitorId) => {
|
||||||
fd.append("monitors[]", monitorId);
|
fd.append("monitors[]", monitorId);
|
||||||
@@ -438,6 +441,30 @@ const CreateStatusPage = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<ConfigBox
|
||||||
|
title={t("pages.statusPages.form.theme.title")}
|
||||||
|
subtitle={t("pages.statusPages.form.theme.description")}
|
||||||
|
rightContent={
|
||||||
|
<Controller
|
||||||
|
name="theme"
|
||||||
|
control={control}
|
||||||
|
render={({ field: themeField }) => (
|
||||||
|
<Controller
|
||||||
|
name="themeMode"
|
||||||
|
control={control}
|
||||||
|
render={({ field: modeField }) => (
|
||||||
|
<ThemePicker
|
||||||
|
theme={themeField.value ?? "refined"}
|
||||||
|
themeMode={modeField.value ?? "auto"}
|
||||||
|
onThemeChange={themeField.onChange}
|
||||||
|
onThemeModeChange={modeField.onChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
title={t("pages.statusPages.form.features.title")}
|
title={t("pages.statusPages.form.features.title")}
|
||||||
subtitle={t("pages.statusPages.form.features.description")}
|
subtitle={t("pages.statusPages.form.features.description")}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { Settings, ExternalLink } from "lucide-react";
|
|||||||
import { useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
import { PUBLIC_STATUS_PAGE_PREFIX, type StatusPage } from "@/Types/StatusPage";
|
||||||
|
|
||||||
interface HeaderStatusPageControlsProps {
|
interface HeaderStatusPageControlsProps {
|
||||||
isAdmin: boolean;
|
isAdmin: boolean;
|
||||||
@@ -50,7 +50,7 @@ export const HeaderStatusPageControls = ({
|
|||||||
<Typography
|
<Typography
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open(
|
window.open(
|
||||||
`/status/public/${statusPage.url}`,
|
`${PUBLIC_STATUS_PAGE_PREFIX}/${statusPage.url}`,
|
||||||
"_blank",
|
"_blank",
|
||||||
"noopener,noreferrer"
|
"noopener,noreferrer"
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,246 +0,0 @@
|
|||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { Gauge } from "@/Components/design-elements";
|
|
||||||
import { useTheme } from "@mui/material/styles";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import prettyBytes from "pretty-bytes";
|
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import Grid from "@mui/material/Grid";
|
|
||||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import { LAYOUT, SPACING } from "@/Utils/Theme/constants";
|
|
||||||
|
|
||||||
const GAUGE_RADIUS = 60;
|
|
||||||
const GAUGE_STROKE_WIDTH = 12;
|
|
||||||
const PERCENTAGE_MULTIPLIER = 100;
|
|
||||||
|
|
||||||
interface StatusPageMonitor extends Monitor {
|
|
||||||
checks?: Monitor["recentChecks"];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MetricDetail {
|
|
||||||
label: string;
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MetricConfig {
|
|
||||||
key: string;
|
|
||||||
label: string;
|
|
||||||
hasData: boolean;
|
|
||||||
progress: number;
|
|
||||||
details: MetricDetail[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const MetricDetailRow = ({ label, value }: MetricDetail) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
justifyContent="space-between"
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2">{value}</Typography>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
interface MetricItemProps {
|
|
||||||
label: string;
|
|
||||||
progress: number;
|
|
||||||
details?: MetricDetail[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const MetricItem = ({ label, progress, details }: MetricItemProps) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
|
||||||
return (
|
|
||||||
<Grid
|
|
||||||
size={isSmall ? 12 : 4}
|
|
||||||
sx={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
alignItems: "center",
|
|
||||||
textAlign: "center",
|
|
||||||
gap: theme.spacing(SPACING.LG),
|
|
||||||
padding: theme.spacing(LAYOUT.XS),
|
|
||||||
borderRight: isSmall ? "none" : `1px solid ${theme.palette.divider}`,
|
|
||||||
borderBottom: isSmall ? `1px solid ${theme.palette.divider}` : "none",
|
|
||||||
"&:last-child": {
|
|
||||||
borderRight: "none",
|
|
||||||
borderBottom: "none",
|
|
||||||
paddingBottom: theme.spacing(SPACING.LG),
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
display="flex"
|
|
||||||
flexDirection="column"
|
|
||||||
alignItems="center"
|
|
||||||
>
|
|
||||||
<Gauge
|
|
||||||
progress={progress}
|
|
||||||
radius={GAUGE_RADIUS}
|
|
||||||
strokeWidth={GAUGE_STROKE_WIDTH}
|
|
||||||
/>
|
|
||||||
<Typography variant="body2">{label}</Typography>
|
|
||||||
</Box>
|
|
||||||
{details && details.length > 0 && (
|
|
||||||
<Box
|
|
||||||
width="100%"
|
|
||||||
paddingX={theme.spacing(LAYOUT.LG)}
|
|
||||||
>
|
|
||||||
{details.map((detail) => (
|
|
||||||
<MetricDetailRow
|
|
||||||
key={detail.label}
|
|
||||||
label={detail.label}
|
|
||||||
value={detail.value}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
type LatestCheck = NonNullable<Monitor["recentChecks"]>[number];
|
|
||||||
|
|
||||||
const buildCpuMetric = (
|
|
||||||
check: LatestCheck,
|
|
||||||
t: (key: string) => string
|
|
||||||
): MetricConfig | null => {
|
|
||||||
if (!check.cpu || typeof check.cpu.usage_percent !== "number") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const usagePercent = (check.cpu.usage_percent ?? 0) * PERCENTAGE_MULTIPLIER;
|
|
||||||
return {
|
|
||||||
key: "cpu",
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.cpu"),
|
|
||||||
hasData: true,
|
|
||||||
progress: usagePercent,
|
|
||||||
details: [
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.usage"),
|
|
||||||
value: `${usagePercent.toFixed(2)}%`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildMemoryMetric = (
|
|
||||||
check: LatestCheck,
|
|
||||||
t: (key: string) => string
|
|
||||||
): MetricConfig | null => {
|
|
||||||
if (
|
|
||||||
!check.memory ||
|
|
||||||
typeof check.memory.usage_percent !== "number" ||
|
|
||||||
typeof check.memory.used_bytes !== "number" ||
|
|
||||||
typeof check.memory.total_bytes !== "number"
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
key: "memory",
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.memory"),
|
|
||||||
hasData: true,
|
|
||||||
progress: (check.memory.usage_percent ?? 0) * PERCENTAGE_MULTIPLIER,
|
|
||||||
details: [
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.used"),
|
|
||||||
value: prettyBytes(check.memory.used_bytes ?? 0),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.total"),
|
|
||||||
value: prettyBytes(check.memory.total_bytes ?? 0),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildDiskMetric = (
|
|
||||||
check: LatestCheck,
|
|
||||||
t: (key: string) => string
|
|
||||||
): MetricConfig | null => {
|
|
||||||
if (!check.disk || check.disk.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const disks = check.disk;
|
|
||||||
const avgUsagePercent =
|
|
||||||
(disks.reduce((acc, disk) => acc + (disk?.usage_percent ?? 0), 0) / disks.length) *
|
|
||||||
PERCENTAGE_MULTIPLIER;
|
|
||||||
const totalUsedBytes = disks.reduce((acc, disk) => acc + (disk?.used_bytes ?? 0), 0);
|
|
||||||
const totalTotalBytes = disks.reduce((acc, disk) => acc + (disk?.total_bytes ?? 0), 0);
|
|
||||||
|
|
||||||
return {
|
|
||||||
key: "disk",
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.disk"),
|
|
||||||
hasData: true,
|
|
||||||
progress: avgUsagePercent,
|
|
||||||
details: [
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.used"),
|
|
||||||
value: prettyBytes(totalUsedBytes),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t("pages.statusPages.monitorsList.infrastructure.total"),
|
|
||||||
value: prettyBytes(totalTotalBytes),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const InfrastructureMetrics = ({ monitor }: { monitor: StatusPageMonitor }) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const latestCheck = monitor.recentChecks?.[0] ?? monitor.checks?.[0];
|
|
||||||
|
|
||||||
if (!latestCheck) {
|
|
||||||
return (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.noData")}
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const metrics: MetricConfig[] = [
|
|
||||||
buildCpuMetric(latestCheck, t),
|
|
||||||
buildMemoryMetric(latestCheck, t),
|
|
||||||
buildDiskMetric(latestCheck, t),
|
|
||||||
].filter((m): m is MetricConfig => m !== null);
|
|
||||||
|
|
||||||
if (metrics.length === 0) {
|
|
||||||
return (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
>
|
|
||||||
{t("pages.statusPages.monitorsList.noData")}
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Grid
|
|
||||||
container
|
|
||||||
alignItems="center"
|
|
||||||
padding={theme.spacing(LAYOUT.XS)}
|
|
||||||
>
|
|
||||||
{metrics.map(({ key, label, progress, details }) => (
|
|
||||||
<MetricItem
|
|
||||||
key={key}
|
|
||||||
label={label}
|
|
||||||
progress={progress}
|
|
||||||
details={details}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import { HistogramResponseTime, HeatmapResponseTime } from "@/Components/common";
|
|
||||||
import { StatusLabel, BaseBox } from "@/Components/design-elements";
|
|
||||||
import { SwitchComponent } from "@/Components/inputs";
|
|
||||||
import { InfrastructureMetrics } from "@/Pages/StatusPage/Status/Components/InfrastructureMetrics";
|
|
||||||
|
|
||||||
import { useTheme, type Theme } from "@mui/material/styles";
|
|
||||||
import { useSelector } from "react-redux";
|
|
||||||
import { useState } from "react";
|
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
|
||||||
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
|
||||||
import type { RootState } from "@/Types/state";
|
|
||||||
import { LAYOUT, SPACING } from "@/Utils/Theme/constants";
|
|
||||||
|
|
||||||
interface StatusPageMonitor extends Monitor {
|
|
||||||
checks?: Monitor["recentChecks"];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MonitorsListProps {
|
|
||||||
statusPage: StatusPage;
|
|
||||||
monitors: StatusPageMonitor[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const getMonitorBadgeStyles = (monitorType: string, theme: Theme) => {
|
|
||||||
const bg =
|
|
||||||
monitorType === "hardware" ? theme.palette.info.light : theme.palette.success.light;
|
|
||||||
return {
|
|
||||||
backgroundColor: bg,
|
|
||||||
color: theme.palette.background.paper,
|
|
||||||
padding: `${theme.spacing(SPACING.SM)} ${theme.spacing(SPACING.LG)}`,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const MonitorHeader = ({
|
|
||||||
monitor,
|
|
||||||
showURL,
|
|
||||||
}: {
|
|
||||||
monitor: StatusPageMonitor;
|
|
||||||
showURL: boolean;
|
|
||||||
}) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
justifyContent="space-between"
|
|
||||||
gap={theme.spacing(LAYOUT.XS)}
|
|
||||||
mb={theme.spacing(LAYOUT.XS)}
|
|
||||||
>
|
|
||||||
<Box sx={{ overflow: "hidden", minWidth: 0, flex: 1 }}>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
gap={theme.spacing(SPACING.LG)}
|
|
||||||
mb={theme.spacing(SPACING.SM)}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="h6"
|
|
||||||
sx={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}
|
|
||||||
>
|
|
||||||
{monitor.name}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="caption"
|
|
||||||
sx={getMonitorBadgeStyles(monitor.type ?? "", theme)}
|
|
||||||
>
|
|
||||||
{getMonitorTypeLabel(monitor.type, t)}
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
|
||||||
{showURL && monitor.url && (
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color={theme.palette.text.secondary}
|
|
||||||
sx={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}
|
|
||||||
>
|
|
||||||
{monitor.url}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
<StatusLabel status={monitor.status} />
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const MonitorContent = ({
|
|
||||||
monitor,
|
|
||||||
statusPage,
|
|
||||||
chartType,
|
|
||||||
}: {
|
|
||||||
monitor: StatusPageMonitor;
|
|
||||||
statusPage: StatusPage;
|
|
||||||
chartType: string;
|
|
||||||
}) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
|
|
||||||
if (monitor.type === "hardware") {
|
|
||||||
if (statusPage.showInfrastructure === false) return null;
|
|
||||||
return <InfrastructureMetrics monitor={monitor} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (statusPage.showCharts === false) return null;
|
|
||||||
|
|
||||||
const checks = monitor.checks?.slice().reverse() ?? [];
|
|
||||||
return (
|
|
||||||
<Box sx={{ overflow: "hidden", minWidth: 0, flex: 1, mb: theme.spacing(SPACING.LG) }}>
|
|
||||||
{chartType === "histogram" ? (
|
|
||||||
<HistogramResponseTime
|
|
||||||
height={{ xs: 50, md: 100 }}
|
|
||||||
gap={{ xs: theme.spacing(SPACING.SM), md: theme.spacing(LAYOUT.SM) }}
|
|
||||||
checks={checks}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<HeatmapResponseTime checks={checks} />
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MonitorsList = ({ statusPage, monitors }: MonitorsListProps) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const showURL = useSelector((state: RootState) => state.ui?.showURL);
|
|
||||||
const [chartType, setChartType] = useState<"histogram" | "heatmap">("histogram");
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack gap={theme.spacing(LAYOUT.MD)}>
|
|
||||||
{statusPage.showCharts && (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
gap={theme.spacing(LAYOUT.SM)}
|
|
||||||
>
|
|
||||||
<Typography>{t("pages.statusPages.monitorsList.chartTypeHeatmap")}</Typography>
|
|
||||||
<SwitchComponent
|
|
||||||
dualOption
|
|
||||||
value={chartType}
|
|
||||||
checked={chartType === "histogram"}
|
|
||||||
onChange={(e) => setChartType(e.target.checked ? "histogram" : "heatmap")}
|
|
||||||
/>
|
|
||||||
<Typography>
|
|
||||||
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{monitors.map((monitor) => (
|
|
||||||
<BaseBox
|
|
||||||
key={monitor.id}
|
|
||||||
padding={theme.spacing(LAYOUT.MD)}
|
|
||||||
>
|
|
||||||
<MonitorHeader
|
|
||||||
monitor={monitor}
|
|
||||||
showURL={showURL}
|
|
||||||
/>
|
|
||||||
<MonitorContent
|
|
||||||
monitor={monitor}
|
|
||||||
statusPage={statusPage}
|
|
||||||
chartType={chartType}
|
|
||||||
/>
|
|
||||||
</BaseBox>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
import {
|
|
||||||
AlertTriangle,
|
|
||||||
CircleCheck,
|
|
||||||
CircleX,
|
|
||||||
Loader,
|
|
||||||
PauseCircle,
|
|
||||||
ShieldAlert,
|
|
||||||
Wrench,
|
|
||||||
} from "lucide-react";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { useTheme } from "@mui/material";
|
|
||||||
import type { Theme } from "@mui/material";
|
|
||||||
import type { Monitor, MonitorStatus } from "@/Types/Monitor";
|
|
||||||
|
|
||||||
interface StatusDisplay {
|
|
||||||
icon: JSX.Element;
|
|
||||||
msg?: string;
|
|
||||||
color?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const getMonitorStatus = (monitors: Monitor[], theme: Theme, t: Function) => {
|
|
||||||
const monitorsStatus: StatusDisplay = {
|
|
||||||
icon: <AlertTriangle size={24} />,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Handle empty monitors array
|
|
||||||
if (monitors.length === 0) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.noMonitors");
|
|
||||||
monitorsStatus.color = theme.palette.warning.main;
|
|
||||||
monitorsStatus.icon = <CircleX size={24} />;
|
|
||||||
return monitorsStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
const allOf = (...statuses: MonitorStatus[]) =>
|
|
||||||
monitors.every((m) => statuses.includes(m.status));
|
|
||||||
const someOf = (...statuses: MonitorStatus[]) =>
|
|
||||||
monitors.some((m) => statuses.includes(m.status));
|
|
||||||
const noneOf = (...statuses: MonitorStatus[]) =>
|
|
||||||
monitors.every((m) => !statuses.includes(m.status));
|
|
||||||
|
|
||||||
// All monitors in a single state
|
|
||||||
if (allOf("up")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.allUp");
|
|
||||||
monitorsStatus.color = theme.palette.success.main;
|
|
||||||
monitorsStatus.icon = <CircleCheck size={24} />;
|
|
||||||
} else if (allOf("breached")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.allBreached");
|
|
||||||
monitorsStatus.color = theme.palette.error.main;
|
|
||||||
monitorsStatus.icon = <ShieldAlert size={24} />;
|
|
||||||
} else if (allOf("maintenance")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.allMaintenance");
|
|
||||||
monitorsStatus.color = theme.palette.warning.main;
|
|
||||||
monitorsStatus.icon = <Wrench size={24} />;
|
|
||||||
} else if (allOf("down")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.allDown");
|
|
||||||
monitorsStatus.color = theme.palette.error.main;
|
|
||||||
monitorsStatus.icon = <CircleX size={24} />;
|
|
||||||
} else if (allOf("paused")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.allPaused");
|
|
||||||
monitorsStatus.color = theme.palette.warning.main;
|
|
||||||
monitorsStatus.icon = <PauseCircle size={24} />;
|
|
||||||
} else if (allOf("initializing")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.allInitializing");
|
|
||||||
monitorsStatus.color = theme.palette.warning.main;
|
|
||||||
monitorsStatus.icon = <Loader size={24} />;
|
|
||||||
|
|
||||||
// Breached takes highest priority in mixed states
|
|
||||||
} else if (someOf("breached") && someOf("down")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.breachedAndDown");
|
|
||||||
monitorsStatus.color = theme.palette.error.main;
|
|
||||||
monitorsStatus.icon = <ShieldAlert size={24} />;
|
|
||||||
} else if (someOf("breached")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.breached");
|
|
||||||
monitorsStatus.color = theme.palette.error.main;
|
|
||||||
monitorsStatus.icon = <ShieldAlert size={24} />;
|
|
||||||
|
|
||||||
// Maintenance combinations
|
|
||||||
} else if (someOf("maintenance") && someOf("down")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.maintenanceAndDown");
|
|
||||||
monitorsStatus.color = theme.palette.error.main;
|
|
||||||
monitorsStatus.icon = <Wrench size={24} />;
|
|
||||||
} else if (someOf("maintenance") && noneOf("down")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.maintenance");
|
|
||||||
monitorsStatus.color = theme.palette.warning.main;
|
|
||||||
monitorsStatus.icon = <Wrench size={24} />;
|
|
||||||
|
|
||||||
// Degraded (some down, no maintenance/breached)
|
|
||||||
} else if (someOf("down")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.degraded");
|
|
||||||
monitorsStatus.color = theme.palette.warning.main;
|
|
||||||
monitorsStatus.icon = <AlertTriangle size={24} />;
|
|
||||||
|
|
||||||
// Some Paused
|
|
||||||
} else if (someOf("paused")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.partiallyPaused");
|
|
||||||
monitorsStatus.color = theme.palette.warning.main;
|
|
||||||
monitorsStatus.icon = <PauseCircle size={24} />;
|
|
||||||
|
|
||||||
// Initializing
|
|
||||||
} else if (someOf("initializing")) {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.initializing");
|
|
||||||
monitorsStatus.color = theme.palette.info.main;
|
|
||||||
monitorsStatus.icon = <Loader size={24} />;
|
|
||||||
} else {
|
|
||||||
monitorsStatus.msg = t("pages.statusPages.statusBar.unknown");
|
|
||||||
monitorsStatus.color = theme.palette.warning.main;
|
|
||||||
}
|
|
||||||
|
|
||||||
return monitorsStatus;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface StatusBarProps {
|
|
||||||
monitors: Monitor[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const StatusBar = ({ monitors }: StatusBarProps) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const monitorsStatus = getMonitorStatus(monitors, theme, t);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
justifyContent="center"
|
|
||||||
gap={theme.spacing(2)}
|
|
||||||
height={theme.spacing(30)}
|
|
||||||
bgcolor={monitorsStatus.color}
|
|
||||||
borderRadius={theme.shape.borderRadius}
|
|
||||||
>
|
|
||||||
{monitorsStatus.icon}
|
|
||||||
<Typography>{monitorsStatus.msg}</Typography>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,18 +1,43 @@
|
|||||||
import { BasePage, BaseFallback } from "@/Components/design-elements";
|
import { BasePage, BaseFallback } from "@/Components/design-elements";
|
||||||
import { StatusBar } from "@/Pages/StatusPage/Status/Components/StatusBar";
|
|
||||||
import { MonitorsList } from "@/Pages/StatusPage/Status/Components/MonitorsList";
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
|
|
||||||
import { useMediaQuery, useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useIsAdmin } from "@/Hooks/useIsAdmin";
|
import { useIsAdmin } from "@/Hooks/useIsAdmin";
|
||||||
import { useLocation, useParams } from "react-router-dom";
|
import { useLocation, useParams } from "react-router-dom";
|
||||||
import { useGet } from "@/Hooks/UseApi";
|
import { useGet } from "@/Hooks/UseApi";
|
||||||
import type { StatusPageResponse } from "@/Types/StatusPage";
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
import { resolveStatusPageTheme } from "@/Types/StatusPage";
|
||||||
|
import {
|
||||||
|
PUBLIC_STATUS_PAGE_PREFIX,
|
||||||
|
type StatusPage,
|
||||||
|
type StatusPageResponse,
|
||||||
|
type StatusPageTheme,
|
||||||
|
} from "@/Types/StatusPage";
|
||||||
import { HeaderStatusPageControls } from "./Components/HeaderStatusPageControls";
|
import { HeaderStatusPageControls } from "./Components/HeaderStatusPageControls";
|
||||||
|
import { StatusPageThemeProvider } from "./themes/StatusPageThemeProvider";
|
||||||
|
import { RefinedStatusPage } from "./themes/refined/RefinedStatusPage";
|
||||||
|
import { ModernStatusPage } from "./themes/modern/ModernStatusPage";
|
||||||
|
import { BoldStatusPage } from "./themes/bold/BoldStatusPage";
|
||||||
|
import { EditorialStatusPage } from "./themes/editorial/EditorialStatusPage";
|
||||||
|
import { BrowserFrame } from "./themes/BrowserFrame";
|
||||||
|
|
||||||
|
type ThemedRendererProps = {
|
||||||
|
statusPage: StatusPage;
|
||||||
|
monitors: (Monitor & { checks?: Monitor["recentChecks"] })[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const THEMED_RENDERERS: Record<
|
||||||
|
StatusPageTheme,
|
||||||
|
React.ComponentType<ThemedRendererProps>
|
||||||
|
> = {
|
||||||
|
refined: RefinedStatusPage,
|
||||||
|
modern: ModernStatusPage,
|
||||||
|
bold: BoldStatusPage,
|
||||||
|
editorial: EditorialStatusPage,
|
||||||
|
};
|
||||||
|
|
||||||
const StatusPageView = () => {
|
const StatusPageView = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -20,8 +45,8 @@ const StatusPageView = () => {
|
|||||||
const { url } = useParams();
|
const { url } = useParams();
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
|
||||||
const isPublic = location.pathname.startsWith("/status/public");
|
const isPublic = location.pathname.startsWith(PUBLIC_STATUS_PAGE_PREFIX);
|
||||||
|
|
||||||
const apiUrl = url ? `/status-page/${url}?type=uptime&type=infrastructure` : null;
|
const apiUrl = url ? `/status-page/${url}?type=uptime&type=infrastructure` : null;
|
||||||
|
|
||||||
@@ -65,48 +90,47 @@ const StatusPageView = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sx: React.CSSProperties = {};
|
const ThemedRenderer = THEMED_RENDERERS[resolveStatusPageTheme(statusPage.theme)];
|
||||||
|
const themedRenderer = (
|
||||||
|
<ThemedRenderer
|
||||||
|
statusPage={statusPage}
|
||||||
|
monitors={monitors}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
// Public route: render directly on the viewport, themed background covers everything.
|
||||||
if (isPublic) {
|
if (isPublic) {
|
||||||
sx.paddingTop = theme.spacing(20);
|
return (
|
||||||
sx.paddingLeft = isSmall ? "5vw" : "20vw";
|
<StatusPageThemeProvider
|
||||||
sx.paddingRight = isSmall ? "5vw" : "20vw";
|
theme={statusPage.theme}
|
||||||
|
themeMode={statusPage.themeMode}
|
||||||
|
paintBody
|
||||||
|
>
|
||||||
|
{themedRenderer}
|
||||||
|
</StatusPageThemeProvider>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const logoSrc = statusPage.logo?.data
|
const publicUrl = `${window.location.origin}${PUBLIC_STATUS_PAGE_PREFIX}/${statusPage.url}`;
|
||||||
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage
|
<BasePage
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
error={error}
|
error={error}
|
||||||
sx={sx}
|
breadcrumbOverride={undefined}
|
||||||
breadcrumbOverride={isPublic ? [] : undefined}
|
sx={{ flex: 1, minHeight: 0 }}
|
||||||
>
|
>
|
||||||
<HeaderStatusPageControls
|
<HeaderStatusPageControls
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
statusPage={statusPage}
|
statusPage={statusPage}
|
||||||
isPublic={isPublic}
|
isPublic={false}
|
||||||
/>
|
|
||||||
{logoSrc && (
|
|
||||||
<Box
|
|
||||||
component="img"
|
|
||||||
src={logoSrc}
|
|
||||||
alignSelf={"flex-start"}
|
|
||||||
alt={statusPage.companyName}
|
|
||||||
sx={{
|
|
||||||
maxHeight: 120,
|
|
||||||
maxWidth: "100%",
|
|
||||||
objectFit: "contain",
|
|
||||||
mb: 2,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<StatusBar monitors={monitors} />
|
|
||||||
<MonitorsList
|
|
||||||
statusPage={statusPage}
|
|
||||||
monitors={monitors}
|
|
||||||
/>
|
/>
|
||||||
|
<StatusPageThemeProvider
|
||||||
|
theme={statusPage.theme}
|
||||||
|
themeMode={statusPage.themeMode}
|
||||||
|
transparent
|
||||||
|
>
|
||||||
|
<BrowserFrame url={publicUrl}>{themedRenderer}</BrowserFrame>
|
||||||
|
</StatusPageThemeProvider>
|
||||||
</BasePage>
|
</BasePage>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import type { ReactNode } from "react";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import { useStatusPageTheme } from "./StatusPageThemeProvider";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
url: string;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BrowserFrame = ({ url, children }: Props) => {
|
||||||
|
const { tokens } = useStatusPageTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: "100%",
|
||||||
|
minHeight: "calc(100vh - 180px)",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
borderRadius: "12px",
|
||||||
|
overflow: "hidden",
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
background: tokens.surface,
|
||||||
|
color: tokens.text,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 1.25,
|
||||||
|
padding: "10px 14px",
|
||||||
|
background: tokens.bg,
|
||||||
|
borderBottom: `1px solid ${tokens.border}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box sx={{ display: "flex", gap: 0.75 }}>
|
||||||
|
<Box
|
||||||
|
sx={{ width: 12, height: 12, borderRadius: "50%", background: "#ff5f57" }}
|
||||||
|
/>
|
||||||
|
<Box
|
||||||
|
sx={{ width: 12, height: 12, borderRadius: "50%", background: "#febc2e" }}
|
||||||
|
/>
|
||||||
|
<Box
|
||||||
|
sx={{ width: 12, height: 12, borderRadius: "50%", background: "#28c840" }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
flex: 1,
|
||||||
|
padding: "4px 12px",
|
||||||
|
marginLeft: 2,
|
||||||
|
borderRadius: "6px",
|
||||||
|
background: tokens.surface,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
fontFamily: "ui-monospace, Menlo, monospace",
|
||||||
|
fontSize: 12,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{url}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ flex: 1, minHeight: 0 }}>{children}</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
import {
|
||||||
|
createContext,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
|
import {
|
||||||
|
DEFAULT_STATUS_PAGE_THEME,
|
||||||
|
resolveStatusPageTheme,
|
||||||
|
resolveStatusPageThemeMode,
|
||||||
|
type StatusPageTheme,
|
||||||
|
type StatusPageThemeMode,
|
||||||
|
} from "@/Types/StatusPage";
|
||||||
|
import { themeTokens, type StatusPageThemeTokens } from "./tokens";
|
||||||
|
|
||||||
|
type ResolvedMode = "light" | "dark";
|
||||||
|
|
||||||
|
interface StatusPageThemeContextValue {
|
||||||
|
theme: StatusPageTheme;
|
||||||
|
mode: ResolvedMode;
|
||||||
|
tokens: StatusPageThemeTokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StatusPageThemeContext = createContext<StatusPageThemeContextValue | null>(null);
|
||||||
|
|
||||||
|
const resolveSystemMode = (): ResolvedMode => {
|
||||||
|
if (typeof window === "undefined" || !window.matchMedia) return "light";
|
||||||
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||||
|
};
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
theme?: StatusPageTheme;
|
||||||
|
themeMode?: StatusPageThemeMode;
|
||||||
|
/**
|
||||||
|
* When true, paint the document body with the theme background so it
|
||||||
|
* covers beyond the provider's wrapper (useful on the public route
|
||||||
|
* where no admin shell sits behind). Defaults to false for admin
|
||||||
|
* previews that already have an app background.
|
||||||
|
*/
|
||||||
|
paintBody?: boolean;
|
||||||
|
/**
|
||||||
|
* When true, the provider's wrapper div does NOT paint its own
|
||||||
|
* background or set a min-height. Use this when the wrapper is
|
||||||
|
* inside a clipped container (e.g. BrowserFrame) that already sets
|
||||||
|
* the visible background, so the wrapper's bg doesn't bleed past the
|
||||||
|
* container's rounded corners.
|
||||||
|
*/
|
||||||
|
transparent?: boolean;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const StatusPageThemeProvider = ({
|
||||||
|
theme,
|
||||||
|
themeMode,
|
||||||
|
paintBody = false,
|
||||||
|
transparent = false,
|
||||||
|
children,
|
||||||
|
}: Props) => {
|
||||||
|
const resolvedTheme = resolveStatusPageTheme(theme);
|
||||||
|
const resolvedThemeMode = resolveStatusPageThemeMode(themeMode);
|
||||||
|
|
||||||
|
const [systemMode, setSystemMode] = useState<ResolvedMode>(resolveSystemMode);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (resolvedThemeMode !== "auto") return;
|
||||||
|
if (typeof window === "undefined" || !window.matchMedia) return;
|
||||||
|
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
|
// Reconcile on first paint whenever we (re-)enter auto mode — only
|
||||||
|
// when it disagrees with the stored value, so we don't trigger an
|
||||||
|
// extra render on the common hot path.
|
||||||
|
const next: ResolvedMode = mq.matches ? "dark" : "light";
|
||||||
|
setSystemMode((prev) => (prev === next ? prev : next));
|
||||||
|
const handler = (e: MediaQueryListEvent) =>
|
||||||
|
setSystemMode(e.matches ? "dark" : "light");
|
||||||
|
mq.addEventListener("change", handler);
|
||||||
|
return () => mq.removeEventListener("change", handler);
|
||||||
|
}, [resolvedThemeMode]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!paintBody || typeof document === "undefined") return;
|
||||||
|
const html = document.documentElement;
|
||||||
|
const body = document.body;
|
||||||
|
const prev = {
|
||||||
|
htmlBg: html.style.background,
|
||||||
|
bodyBg: body.style.background,
|
||||||
|
bodyMargin: body.style.margin,
|
||||||
|
htmlColorScheme: html.style.colorScheme,
|
||||||
|
};
|
||||||
|
const resolvedMode = resolvedThemeMode === "auto" ? systemMode : resolvedThemeMode;
|
||||||
|
const bg = themeTokens[resolvedTheme][resolvedMode].bg;
|
||||||
|
html.style.background = bg;
|
||||||
|
body.style.background = bg;
|
||||||
|
body.style.margin = "0";
|
||||||
|
html.style.colorScheme = resolvedMode;
|
||||||
|
return () => {
|
||||||
|
html.style.background = prev.htmlBg;
|
||||||
|
body.style.background = prev.bodyBg;
|
||||||
|
body.style.margin = prev.bodyMargin;
|
||||||
|
html.style.colorScheme = prev.htmlColorScheme;
|
||||||
|
};
|
||||||
|
}, [paintBody, resolvedTheme, resolvedThemeMode, systemMode]);
|
||||||
|
|
||||||
|
const resolvedMode: ResolvedMode =
|
||||||
|
resolvedThemeMode === "auto" ? systemMode : resolvedThemeMode;
|
||||||
|
const tokens = themeTokens[resolvedTheme][resolvedMode];
|
||||||
|
|
||||||
|
const value = useMemo(
|
||||||
|
() => ({ theme: resolvedTheme, mode: resolvedMode, tokens }),
|
||||||
|
[resolvedTheme, resolvedMode, tokens]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StatusPageThemeContext.Provider value={value}>
|
||||||
|
<div
|
||||||
|
style={
|
||||||
|
transparent
|
||||||
|
? undefined
|
||||||
|
: {
|
||||||
|
background: tokens.bg,
|
||||||
|
minHeight: "100vh",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</StatusPageThemeContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useStatusPageTheme = (): StatusPageThemeContextValue => {
|
||||||
|
const ctx = useContext(StatusPageThemeContext);
|
||||||
|
if (!ctx) {
|
||||||
|
return {
|
||||||
|
theme: DEFAULT_STATUS_PAGE_THEME,
|
||||||
|
mode: resolveSystemMode(),
|
||||||
|
tokens: themeTokens[DEFAULT_STATUS_PAGE_THEME][resolveSystemMode()],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return ctx;
|
||||||
|
};
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
import type { StatusPage } from "@/Types/StatusPage";
|
||||||
|
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
||||||
|
import { ThemedHeatmap } from "../shared/ThemedHeatmap";
|
||||||
|
import { ThemedHistogram } from "../shared/ThemedHistogram";
|
||||||
|
import { ThemedInfrastructure } from "../shared/ThemedInfrastructure";
|
||||||
|
import {
|
||||||
|
monitorBadgeTone,
|
||||||
|
monoFirstChar,
|
||||||
|
resolveOverallStatus,
|
||||||
|
statusBadgeKey,
|
||||||
|
} from "../shared/overallStatus";
|
||||||
|
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
||||||
|
import { boldStyles } from "./styles";
|
||||||
|
|
||||||
|
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
statusPage: StatusPage;
|
||||||
|
monitors: StatusPageMonitor[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BoldStatusPage = ({ statusPage, monitors }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { tokens, mode } = useStatusPageTheme();
|
||||||
|
const styles = useMemo(() => boldStyles(tokens, mode === "dark"), [tokens, mode]);
|
||||||
|
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
||||||
|
|
||||||
|
const overall = resolveOverallStatus(monitors, t, { iconSize: 18 });
|
||||||
|
const logoSrc = statusPage.logo?.data
|
||||||
|
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={styles.page}>
|
||||||
|
<Box
|
||||||
|
component="header"
|
||||||
|
sx={styles.top}
|
||||||
|
>
|
||||||
|
<Box sx={styles.brand}>
|
||||||
|
{logoSrc ? (
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={logoSrc}
|
||||||
|
alt={statusPage.companyName}
|
||||||
|
sx={styles.logoImg}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Box sx={styles.logoConic}>{monoFirstChar(statusPage.companyName)}</Box>
|
||||||
|
)}
|
||||||
|
{statusPage.companyName}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={styles.hero}>
|
||||||
|
<Box
|
||||||
|
component="h1"
|
||||||
|
sx={styles.heroTitle}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.heroCheck(overall.tone)}
|
||||||
|
>
|
||||||
|
{overall.icon}
|
||||||
|
</Box>
|
||||||
|
{overall.message}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.heroSub}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
|
count: monitors.length,
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{statusPage.showCharts && (
|
||||||
|
<Box sx={styles.chartSwitchWrap}>
|
||||||
|
<Box
|
||||||
|
sx={styles.chartSwitch}
|
||||||
|
role="radiogroup"
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={chartMode === "heatmap"}
|
||||||
|
onClick={() => setChartMode("heatmap")}
|
||||||
|
sx={styles.chartSwitchButton(chartMode === "heatmap")}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.monitorsList.chartTypeHeatmap")}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={chartMode === "histogram"}
|
||||||
|
onClick={() => setChartMode("histogram")}
|
||||||
|
sx={styles.chartSwitchButton(chartMode === "histogram")}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
sx={styles.monitorList}
|
||||||
|
>
|
||||||
|
{monitors.map((monitor) => {
|
||||||
|
const isHardware = monitor.type === "hardware";
|
||||||
|
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
||||||
|
const showChart = !isHardware && statusPage.showCharts !== false;
|
||||||
|
const badgeTone = monitorBadgeTone(monitor.status);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
component="li"
|
||||||
|
key={monitor.id}
|
||||||
|
sx={styles.card}
|
||||||
|
>
|
||||||
|
<Box sx={styles.cardRow}>
|
||||||
|
<Box sx={styles.cardLeft}>
|
||||||
|
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
||||||
|
<Box sx={styles.monitorMeta}>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={isHardware ? styles.pillHardware : styles.pill}
|
||||||
|
>
|
||||||
|
{getMonitorTypeLabel(monitor.type, t)}
|
||||||
|
</Box>
|
||||||
|
{monitor.url && (
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.monitorUrl}
|
||||||
|
title={monitor.url}
|
||||||
|
>
|
||||||
|
{monitor.url}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.badge(badgeTone)}
|
||||||
|
>
|
||||||
|
{t(statusBadgeKey[monitor.status])}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{showInfra && (
|
||||||
|
<ThemedInfrastructure
|
||||||
|
monitor={monitor}
|
||||||
|
sxApi={{
|
||||||
|
containerSx: styles.infra,
|
||||||
|
emptySx: styles.infraEmpty,
|
||||||
|
gaugeSx: styles.gauge,
|
||||||
|
gaugeLabelSx: styles.gaugeLabel,
|
||||||
|
gaugeValueSx: styles.gaugeValue,
|
||||||
|
gaugeBarSx: styles.gaugeBar,
|
||||||
|
gaugeFillSx: styles.gaugeFill,
|
||||||
|
gaugeSubSx: styles.gaugeSub,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{showChart &&
|
||||||
|
(chartMode === "heatmap" ? (
|
||||||
|
<ThemedHeatmap
|
||||||
|
checks={monitor.recentChecks ?? []}
|
||||||
|
containerSx={styles.heatmap}
|
||||||
|
cellSx={styles.heatmapCell}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ThemedHistogram
|
||||||
|
checks={monitor.recentChecks ?? []}
|
||||||
|
containerSx={styles.histogram}
|
||||||
|
barSx={styles.bar}
|
||||||
|
statsSx={styles.chartStats}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
component="footer"
|
||||||
|
sx={styles.footer}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.footer.poweredBy")}{" "}
|
||||||
|
<a
|
||||||
|
href="https://checkmate.so"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
Checkmate
|
||||||
|
</a>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,404 @@
|
|||||||
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
|
import type { StatusPageThemeTokens } from "../tokens";
|
||||||
|
import { type OverallTone, toneColor, toneSoft } from "../shared/overallStatus";
|
||||||
|
import { BOLD_SANS_STACK, MONO_STACK } from "../shared/fontStacks";
|
||||||
|
|
||||||
|
export type BoldHeatCell = "fast" | "med" | "slow" | "down" | "empty";
|
||||||
|
export type BoldBarKind = "up" | "down" | "empty";
|
||||||
|
export type BoldGaugeFill = "ok" | "warm" | "hot";
|
||||||
|
|
||||||
|
export interface BoldStyles {
|
||||||
|
page: SxProps<Theme>;
|
||||||
|
top: SxProps<Theme>;
|
||||||
|
brand: SxProps<Theme>;
|
||||||
|
logoConic: SxProps<Theme>;
|
||||||
|
logoImg: SxProps<Theme>;
|
||||||
|
hero: SxProps<Theme>;
|
||||||
|
heroTitle: SxProps<Theme>;
|
||||||
|
heroCheck: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
heroSub: SxProps<Theme>;
|
||||||
|
chartSwitchWrap: SxProps<Theme>;
|
||||||
|
chartSwitch: SxProps<Theme>;
|
||||||
|
chartSwitchButton: (active: boolean) => SxProps<Theme>;
|
||||||
|
monitorList: SxProps<Theme>;
|
||||||
|
card: SxProps<Theme>;
|
||||||
|
cardRow: SxProps<Theme>;
|
||||||
|
cardLeft: SxProps<Theme>;
|
||||||
|
monitorName: SxProps<Theme>;
|
||||||
|
monitorMeta: SxProps<Theme>;
|
||||||
|
pill: SxProps<Theme>;
|
||||||
|
pillHardware: SxProps<Theme>;
|
||||||
|
monitorUrl: SxProps<Theme>;
|
||||||
|
badge: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
heatmap: SxProps<Theme>;
|
||||||
|
heatmapCell: (kind: BoldHeatCell) => SxProps<Theme>;
|
||||||
|
histogram: SxProps<Theme>;
|
||||||
|
bar: (kind: BoldBarKind, heightPct: number) => SxProps<Theme>;
|
||||||
|
chartStats: SxProps<Theme>;
|
||||||
|
infra: SxProps<Theme>;
|
||||||
|
infraEmpty: SxProps<Theme>;
|
||||||
|
gauge: SxProps<Theme>;
|
||||||
|
gaugeLabel: SxProps<Theme>;
|
||||||
|
gaugeValue: SxProps<Theme>;
|
||||||
|
gaugeBar: SxProps<Theme>;
|
||||||
|
gaugeFill: (level: BoldGaugeFill, widthPct: number) => SxProps<Theme>;
|
||||||
|
gaugeSub: SxProps<Theme>;
|
||||||
|
footer: SxProps<Theme>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const boldStyles = (
|
||||||
|
tokens: StatusPageThemeTokens,
|
||||||
|
isDark: boolean
|
||||||
|
): BoldStyles => {
|
||||||
|
const heatCellBg: Record<BoldHeatCell, string> = {
|
||||||
|
fast: tokens.up,
|
||||||
|
med: `color-mix(in srgb, ${tokens.up} 70%, #ffffff 30%)`,
|
||||||
|
slow: tokens.warn,
|
||||||
|
down: tokens.down,
|
||||||
|
empty: tokens.border,
|
||||||
|
};
|
||||||
|
const heatCellShadow: Record<BoldHeatCell, string> = {
|
||||||
|
fast: `0 0 6px color-mix(in srgb, ${tokens.up} 18%, transparent)`,
|
||||||
|
med: `0 0 6px color-mix(in srgb, ${tokens.up} 18%, transparent)`,
|
||||||
|
slow: `0 0 6px color-mix(in srgb, ${tokens.warn} 20%, transparent)`,
|
||||||
|
down: `0 0 6px color-mix(in srgb, ${tokens.down} 20%, transparent)`,
|
||||||
|
empty: "none",
|
||||||
|
};
|
||||||
|
|
||||||
|
const barBg: Record<BoldBarKind, string> = {
|
||||||
|
up: tokens.up,
|
||||||
|
down: tokens.down,
|
||||||
|
empty: tokens.border,
|
||||||
|
};
|
||||||
|
|
||||||
|
const gaugeFillBg: Record<BoldGaugeFill, string> = {
|
||||||
|
ok: `linear-gradient(90deg, ${tokens.up}, color-mix(in srgb, ${tokens.up} 70%, #ffffff 30%))`,
|
||||||
|
warm: `linear-gradient(90deg, ${tokens.warn}, #fbbf24)`,
|
||||||
|
hot: `linear-gradient(90deg, ${tokens.down}, #fb7185)`,
|
||||||
|
};
|
||||||
|
|
||||||
|
const heroBgLight = `linear-gradient(135deg, color-mix(in srgb, ${tokens.up} 8%, transparent), transparent 60%), ${tokens.surface}`;
|
||||||
|
const heroBgDark = `linear-gradient(135deg, color-mix(in srgb, ${tokens.up} 16%, transparent), transparent 60%), ${tokens.surface}`;
|
||||||
|
|
||||||
|
const heroGlowLight = `radial-gradient(400px 200px at 20% 30%, color-mix(in srgb, ${tokens.up} 14%, transparent), transparent 60%), radial-gradient(300px 200px at 90% 80%, color-mix(in srgb, ${tokens.upStrong} 10%, transparent), transparent 60%)`;
|
||||||
|
const heroGlowDark = `radial-gradient(400px 200px at 20% 30%, color-mix(in srgb, ${tokens.up} 32%, transparent), transparent 60%), radial-gradient(300px 200px at 90% 80%, color-mix(in srgb, ${tokens.upStrong} 22%, transparent), transparent 60%)`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
page: {
|
||||||
|
flex: "1 0 auto",
|
||||||
|
maxWidth: 1040,
|
||||||
|
width: "100%",
|
||||||
|
mx: "auto",
|
||||||
|
p: "56px 24px 96px",
|
||||||
|
fontFamily: BOLD_SANS_STACK,
|
||||||
|
fontSize: 14,
|
||||||
|
lineHeight: 1.55,
|
||||||
|
color: tokens.text,
|
||||||
|
WebkitFontSmoothing: "antialiased",
|
||||||
|
},
|
||||||
|
|
||||||
|
top: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
mb: "36px",
|
||||||
|
},
|
||||||
|
brand: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "14px",
|
||||||
|
fontWeight: 700,
|
||||||
|
fontSize: 16,
|
||||||
|
letterSpacing: "-0.01em",
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
logoConic: {
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
borderRadius: "12px",
|
||||||
|
background: `conic-gradient(from 140deg, ${tokens.up}, ${tokens.upStrong}, #0f766e, ${tokens.up})`,
|
||||||
|
display: "grid",
|
||||||
|
placeItems: "center",
|
||||||
|
color: "#05070a",
|
||||||
|
fontWeight: 900,
|
||||||
|
fontSize: 14,
|
||||||
|
boxShadow: `0 8px 24px color-mix(in srgb, ${tokens.up} 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.2)`,
|
||||||
|
},
|
||||||
|
logoImg: { maxHeight: 36, maxWidth: 140, objectFit: "contain" },
|
||||||
|
|
||||||
|
hero: {
|
||||||
|
position: "relative",
|
||||||
|
borderRadius: "22px",
|
||||||
|
padding: "36px 36px 32px",
|
||||||
|
mb: "28px",
|
||||||
|
background: isDark ? heroBgDark : heroBgLight,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
overflow: "hidden",
|
||||||
|
"&::before": {
|
||||||
|
content: '""',
|
||||||
|
position: "absolute",
|
||||||
|
inset: 0,
|
||||||
|
background: isDark ? heroGlowDark : heroGlowLight,
|
||||||
|
pointerEvents: "none",
|
||||||
|
opacity: 0.8,
|
||||||
|
zIndex: 0,
|
||||||
|
...(isDark ? { mixBlendMode: "screen" } : {}),
|
||||||
|
},
|
||||||
|
"& > *": { position: "relative", zIndex: 1 },
|
||||||
|
},
|
||||||
|
heroTitle: {
|
||||||
|
m: 0,
|
||||||
|
fontSize: 34,
|
||||||
|
fontWeight: 800,
|
||||||
|
letterSpacing: "-0.02em",
|
||||||
|
lineHeight: 1.1,
|
||||||
|
color: tokens.text,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "10px",
|
||||||
|
},
|
||||||
|
heroCheck: (tone) => ({
|
||||||
|
display: "inline-grid",
|
||||||
|
placeItems: "center",
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
borderRadius: "50%",
|
||||||
|
background: toneColor(tone, tokens),
|
||||||
|
color: tone === "down" ? "#fff" : "#05070a",
|
||||||
|
flexShrink: 0,
|
||||||
|
boxShadow: `0 0 0 6px ${toneSoft(tone, tokens)}`,
|
||||||
|
}),
|
||||||
|
heroSub: { mt: "10px", mb: 0, color: tokens.textMuted, fontSize: 14 },
|
||||||
|
|
||||||
|
chartSwitchWrap: { display: "flex", justifyContent: "flex-end", mb: "16px" },
|
||||||
|
chartSwitch: {
|
||||||
|
display: "inline-flex",
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: "999px",
|
||||||
|
background: tokens.surface,
|
||||||
|
p: "3px",
|
||||||
|
gap: "2px",
|
||||||
|
},
|
||||||
|
chartSwitchButton: (active) => ({
|
||||||
|
border: 0,
|
||||||
|
background: active ? tokens.upSoft : "transparent",
|
||||||
|
fontFamily: "inherit",
|
||||||
|
fontSize: 11,
|
||||||
|
padding: "8px 18px",
|
||||||
|
cursor: "pointer",
|
||||||
|
color: active ? tokens.up : tokens.textMuted,
|
||||||
|
fontWeight: 700,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.12em",
|
||||||
|
transition: "background 0.2s, color 0.2s",
|
||||||
|
borderRadius: "999px",
|
||||||
|
"&:hover": { color: active ? tokens.up : tokens.text },
|
||||||
|
}),
|
||||||
|
|
||||||
|
monitorList: {
|
||||||
|
listStyle: "none",
|
||||||
|
m: 0,
|
||||||
|
p: 0,
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: "14px",
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
background: tokens.surface,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: "18px",
|
||||||
|
overflow: "hidden",
|
||||||
|
transition: "transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.2s",
|
||||||
|
"&:hover": {
|
||||||
|
transform: "translateY(-3px)",
|
||||||
|
borderColor: `color-mix(in srgb, ${tokens.up} 40%, ${tokens.border})`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cardRow: {
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "1fr auto",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "24px",
|
||||||
|
p: "22px 28px",
|
||||||
|
},
|
||||||
|
cardLeft: { minWidth: 0 },
|
||||||
|
monitorName: {
|
||||||
|
fontWeight: 700,
|
||||||
|
fontSize: 17,
|
||||||
|
letterSpacing: "-0.01em",
|
||||||
|
color: tokens.text,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
},
|
||||||
|
monitorMeta: {
|
||||||
|
display: "flex",
|
||||||
|
gap: "10px",
|
||||||
|
alignItems: "center",
|
||||||
|
mt: "6px",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
},
|
||||||
|
pill: {
|
||||||
|
fontSize: 10,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.1em",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
background: `color-mix(in srgb, ${tokens.surface} 80%, ${tokens.bg})`,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
padding: "3px 10px",
|
||||||
|
borderRadius: "999px",
|
||||||
|
fontWeight: 700,
|
||||||
|
},
|
||||||
|
pillHardware: {
|
||||||
|
fontSize: 10,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.1em",
|
||||||
|
padding: "3px 10px",
|
||||||
|
borderRadius: "999px",
|
||||||
|
fontWeight: 700,
|
||||||
|
color: tokens.up,
|
||||||
|
borderColor: `color-mix(in srgb, ${tokens.up} 40%, transparent)`,
|
||||||
|
border: `1px solid color-mix(in srgb, ${tokens.up} 40%, transparent)`,
|
||||||
|
background: tokens.upSoft,
|
||||||
|
},
|
||||||
|
monitorUrl: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontFamily: MONO_STACK,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
maxWidth: 300,
|
||||||
|
},
|
||||||
|
|
||||||
|
badge: (tone) => ({
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: 800,
|
||||||
|
padding: "6px 14px",
|
||||||
|
borderRadius: "999px",
|
||||||
|
display: "inline-flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "7px",
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.08em",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
background: toneSoft(tone, tokens),
|
||||||
|
color: toneColor(tone, tokens),
|
||||||
|
"&::before": {
|
||||||
|
content: '""',
|
||||||
|
width: 6,
|
||||||
|
height: 6,
|
||||||
|
borderRadius: "50%",
|
||||||
|
background: "currentColor",
|
||||||
|
boxShadow: "0 0 8px currentColor",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
heatmap: {
|
||||||
|
padding: "0 28px 22px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(25, 1fr)",
|
||||||
|
gap: "3px",
|
||||||
|
height: 48,
|
||||||
|
},
|
||||||
|
heatmapCell: (kind) => ({
|
||||||
|
borderRadius: "3px",
|
||||||
|
background: heatCellBg[kind],
|
||||||
|
boxShadow: heatCellShadow[kind],
|
||||||
|
opacity: kind === "empty" ? 0.4 : 1,
|
||||||
|
transition: "transform 0.15s",
|
||||||
|
"&:hover": { transform: "scaleY(1.2)" },
|
||||||
|
}),
|
||||||
|
|
||||||
|
histogram: {
|
||||||
|
padding: "0 28px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(25, 1fr)",
|
||||||
|
gap: "3px",
|
||||||
|
alignItems: "flex-end",
|
||||||
|
height: 48,
|
||||||
|
},
|
||||||
|
bar: (kind, heightPct) => ({
|
||||||
|
background: barBg[kind],
|
||||||
|
borderRadius: "3px",
|
||||||
|
minHeight: 4,
|
||||||
|
opacity: kind === "empty" ? 0.4 : 1,
|
||||||
|
height: `${heightPct}%`,
|
||||||
|
}),
|
||||||
|
chartStats: {
|
||||||
|
padding: "0 28px 22px",
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
fontWeight: 700,
|
||||||
|
letterSpacing: "0.05em",
|
||||||
|
},
|
||||||
|
|
||||||
|
infra: {
|
||||||
|
padding: "18px 28px 26px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: { xs: "1fr", md: "repeat(3, 1fr)" },
|
||||||
|
gap: "16px",
|
||||||
|
},
|
||||||
|
infraEmpty: {
|
||||||
|
padding: "18px 28px 26px",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontSize: 13,
|
||||||
|
},
|
||||||
|
gauge: {
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: "16px",
|
||||||
|
p: "16px 18px",
|
||||||
|
background: `color-mix(in srgb, ${tokens.surface} 80%, ${tokens.bg})`,
|
||||||
|
},
|
||||||
|
gaugeLabel: {
|
||||||
|
fontSize: 10,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.12em",
|
||||||
|
fontWeight: 700,
|
||||||
|
},
|
||||||
|
gaugeValue: {
|
||||||
|
fontSize: 30,
|
||||||
|
fontWeight: 800,
|
||||||
|
letterSpacing: "-0.02em",
|
||||||
|
mt: "6px",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
gaugeBar: {
|
||||||
|
height: 6,
|
||||||
|
background: tokens.border,
|
||||||
|
borderRadius: "3px",
|
||||||
|
overflow: "hidden",
|
||||||
|
mt: "12px",
|
||||||
|
},
|
||||||
|
gaugeFill: (level, widthPct) => ({
|
||||||
|
display: "block",
|
||||||
|
height: "100%",
|
||||||
|
background: gaugeFillBg[level],
|
||||||
|
borderRadius: "3px",
|
||||||
|
transition: "width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1)",
|
||||||
|
width: `${Math.max(0, Math.min(100, widthPct))}%`,
|
||||||
|
}),
|
||||||
|
gaugeSub: {
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
mt: "10px",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
},
|
||||||
|
|
||||||
|
footer: {
|
||||||
|
textAlign: "center",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontSize: 12,
|
||||||
|
mt: "52px",
|
||||||
|
"& a": {
|
||||||
|
color: tokens.up,
|
||||||
|
textDecoration: "underline",
|
||||||
|
textUnderlineOffset: "3px",
|
||||||
|
fontWeight: 800,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
import type { StatusPage } from "@/Types/StatusPage";
|
||||||
|
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
||||||
|
import { ThemedHeatmap } from "../shared/ThemedHeatmap";
|
||||||
|
import { ThemedHistogram } from "../shared/ThemedHistogram";
|
||||||
|
import { ThemedInfrastructure } from "../shared/ThemedInfrastructure";
|
||||||
|
import {
|
||||||
|
monitorBadgeTone,
|
||||||
|
resolveOverallStatus,
|
||||||
|
statusBadgeKey,
|
||||||
|
} from "../shared/overallStatus";
|
||||||
|
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
||||||
|
import { editorialStyles } from "./styles";
|
||||||
|
|
||||||
|
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
statusPage: StatusPage;
|
||||||
|
monitors: StatusPageMonitor[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const EditorialStatusPage = ({ statusPage, monitors }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { tokens } = useStatusPageTheme();
|
||||||
|
const styles = useMemo(() => editorialStyles(tokens), [tokens]);
|
||||||
|
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
||||||
|
|
||||||
|
const todayLabel = useMemo(
|
||||||
|
() =>
|
||||||
|
new Date().toLocaleDateString(undefined, {
|
||||||
|
year: "numeric",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const overall = resolveOverallStatus(monitors, t, {
|
||||||
|
allUpKey: "pages.statusPages.editorial.allUp",
|
||||||
|
});
|
||||||
|
const logoSrc = statusPage.logo?.data
|
||||||
|
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={styles.page}>
|
||||||
|
<Box
|
||||||
|
component="header"
|
||||||
|
sx={styles.top}
|
||||||
|
>
|
||||||
|
<Box sx={styles.brandWrap}>
|
||||||
|
{logoSrc && (
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={logoSrc}
|
||||||
|
alt={statusPage.companyName}
|
||||||
|
sx={styles.logoImg}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Box
|
||||||
|
component="h2"
|
||||||
|
sx={styles.brandEyebrow}
|
||||||
|
>
|
||||||
|
{statusPage.companyName}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="h1"
|
||||||
|
sx={styles.brandTitle}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.editorial.reportTitle")}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.statusLine}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.statusDot(overall.tone)}
|
||||||
|
/>
|
||||||
|
{overall.message}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.dateline}
|
||||||
|
>
|
||||||
|
{todayLabel} ·{" "}
|
||||||
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
|
count: monitors.length,
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{statusPage.showCharts && (
|
||||||
|
<Box sx={styles.chartSwitchWrap}>
|
||||||
|
<Box
|
||||||
|
sx={styles.chartSwitch}
|
||||||
|
role="radiogroup"
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={chartMode === "heatmap"}
|
||||||
|
onClick={() => setChartMode("heatmap")}
|
||||||
|
sx={styles.chartSwitchButton(chartMode === "heatmap")}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.monitorsList.chartTypeHeatmap")}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={chartMode === "histogram"}
|
||||||
|
onClick={() => setChartMode("histogram")}
|
||||||
|
sx={styles.chartSwitchButton(chartMode === "histogram")}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
sx={styles.monitorList}
|
||||||
|
>
|
||||||
|
{monitors.map((monitor) => {
|
||||||
|
const isHardware = monitor.type === "hardware";
|
||||||
|
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
||||||
|
const showChart = !isHardware && statusPage.showCharts !== false;
|
||||||
|
const badgeTone = monitorBadgeTone(monitor.status);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
component="li"
|
||||||
|
key={monitor.id}
|
||||||
|
sx={styles.card}
|
||||||
|
>
|
||||||
|
<Box sx={styles.cardRow}>
|
||||||
|
<Box sx={styles.cardLeft}>
|
||||||
|
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
||||||
|
<Box sx={styles.monitorMeta}>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={isHardware ? styles.pillHardware : styles.pill}
|
||||||
|
>
|
||||||
|
{getMonitorTypeLabel(monitor.type, t)}
|
||||||
|
</Box>
|
||||||
|
{monitor.url && (
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.monitorUrl}
|
||||||
|
title={monitor.url}
|
||||||
|
>
|
||||||
|
{monitor.url}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.badge(badgeTone)}
|
||||||
|
>
|
||||||
|
{t(statusBadgeKey[monitor.status])}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{showInfra && (
|
||||||
|
<ThemedInfrastructure
|
||||||
|
monitor={monitor}
|
||||||
|
sxApi={{
|
||||||
|
containerSx: styles.infra,
|
||||||
|
emptySx: styles.infraEmpty,
|
||||||
|
gaugeSx: styles.gauge,
|
||||||
|
gaugeLabelSx: styles.gaugeLabel,
|
||||||
|
gaugeValueSx: styles.gaugeValue,
|
||||||
|
gaugeBarSx: styles.gaugeBar,
|
||||||
|
gaugeFillSx: styles.gaugeFill,
|
||||||
|
gaugeSubSx: styles.gaugeSub,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{showChart &&
|
||||||
|
(chartMode === "heatmap" ? (
|
||||||
|
<ThemedHeatmap
|
||||||
|
checks={monitor.recentChecks ?? []}
|
||||||
|
containerSx={styles.heatmap}
|
||||||
|
cellSx={styles.heatmapCell}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ThemedHistogram
|
||||||
|
checks={monitor.recentChecks ?? []}
|
||||||
|
containerSx={styles.histogram}
|
||||||
|
barSx={styles.bar}
|
||||||
|
statsSx={styles.chartStats}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
component="footer"
|
||||||
|
sx={styles.footer}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.footer.poweredBy")}{" "}
|
||||||
|
<a
|
||||||
|
href="https://checkmate.so"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
Checkmate
|
||||||
|
</a>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,337 @@
|
|||||||
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
|
import type { StatusPageThemeTokens } from "../tokens";
|
||||||
|
import { type OverallTone, toneColor, toneSoft } from "../shared/overallStatus";
|
||||||
|
import {
|
||||||
|
EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
MONO_STACK,
|
||||||
|
SERIF_STACK,
|
||||||
|
} from "../shared/fontStacks";
|
||||||
|
|
||||||
|
export type EditorialHeatCell = "fast" | "med" | "slow" | "down" | "empty";
|
||||||
|
export type EditorialBarKind = "up" | "down" | "empty";
|
||||||
|
export type EditorialGaugeFill = "ok" | "warm" | "hot";
|
||||||
|
|
||||||
|
export interface EditorialStyles {
|
||||||
|
page: SxProps<Theme>;
|
||||||
|
top: SxProps<Theme>;
|
||||||
|
brandWrap: SxProps<Theme>;
|
||||||
|
logoImg: SxProps<Theme>;
|
||||||
|
brandEyebrow: SxProps<Theme>;
|
||||||
|
brandTitle: SxProps<Theme>;
|
||||||
|
statusLine: SxProps<Theme>;
|
||||||
|
statusDot: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
dateline: SxProps<Theme>;
|
||||||
|
chartSwitchWrap: SxProps<Theme>;
|
||||||
|
chartSwitch: SxProps<Theme>;
|
||||||
|
chartSwitchButton: (active: boolean) => SxProps<Theme>;
|
||||||
|
monitorList: SxProps<Theme>;
|
||||||
|
card: SxProps<Theme>;
|
||||||
|
cardRow: SxProps<Theme>;
|
||||||
|
cardLeft: SxProps<Theme>;
|
||||||
|
monitorName: SxProps<Theme>;
|
||||||
|
monitorMeta: SxProps<Theme>;
|
||||||
|
pill: SxProps<Theme>;
|
||||||
|
pillHardware: SxProps<Theme>;
|
||||||
|
monitorUrl: SxProps<Theme>;
|
||||||
|
badge: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
heatmap: SxProps<Theme>;
|
||||||
|
heatmapCell: (kind: EditorialHeatCell) => SxProps<Theme>;
|
||||||
|
histogram: SxProps<Theme>;
|
||||||
|
bar: (kind: EditorialBarKind, heightPct: number) => SxProps<Theme>;
|
||||||
|
chartStats: SxProps<Theme>;
|
||||||
|
infra: SxProps<Theme>;
|
||||||
|
infraEmpty: SxProps<Theme>;
|
||||||
|
gauge: SxProps<Theme>;
|
||||||
|
gaugeLabel: SxProps<Theme>;
|
||||||
|
gaugeValue: SxProps<Theme>;
|
||||||
|
gaugeBar: SxProps<Theme>;
|
||||||
|
gaugeFill: (level: EditorialGaugeFill, widthPct: number) => SxProps<Theme>;
|
||||||
|
gaugeSub: SxProps<Theme>;
|
||||||
|
footer: SxProps<Theme>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const editorialStyles = (tokens: StatusPageThemeTokens): EditorialStyles => {
|
||||||
|
const heatCellBg: Record<EditorialHeatCell, string> = {
|
||||||
|
fast: tokens.up,
|
||||||
|
med: `color-mix(in srgb, ${tokens.up} 60%, ${tokens.bg})`,
|
||||||
|
slow: tokens.warn,
|
||||||
|
down: tokens.down,
|
||||||
|
empty: tokens.border,
|
||||||
|
};
|
||||||
|
|
||||||
|
const barBg: Record<EditorialBarKind, string> = {
|
||||||
|
up: tokens.up,
|
||||||
|
down: tokens.down,
|
||||||
|
empty: tokens.border,
|
||||||
|
};
|
||||||
|
|
||||||
|
const gaugeFillBg: Record<EditorialGaugeFill, string> = {
|
||||||
|
ok: tokens.up,
|
||||||
|
warm: tokens.warn,
|
||||||
|
hot: tokens.down,
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
page: {
|
||||||
|
flex: "1 0 auto",
|
||||||
|
maxWidth: 760,
|
||||||
|
width: "100%",
|
||||||
|
mx: "auto",
|
||||||
|
p: "64px 24px 96px",
|
||||||
|
fontFamily: SERIF_STACK,
|
||||||
|
fontSize: 15,
|
||||||
|
lineHeight: 1.6,
|
||||||
|
color: tokens.text,
|
||||||
|
WebkitFontSmoothing: "antialiased",
|
||||||
|
},
|
||||||
|
|
||||||
|
top: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "flex-end",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
mb: "48px",
|
||||||
|
borderBottom: `2px solid ${tokens.text}`,
|
||||||
|
pb: "18px",
|
||||||
|
},
|
||||||
|
brandWrap: { display: "flex", flexDirection: "column" },
|
||||||
|
logoImg: { maxHeight: 48, maxWidth: 160, objectFit: "contain", mb: "8px" },
|
||||||
|
brandEyebrow: {
|
||||||
|
m: 0,
|
||||||
|
fontSize: 11,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.3em",
|
||||||
|
fontWeight: 700,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
},
|
||||||
|
brandTitle: {
|
||||||
|
mt: "6px",
|
||||||
|
mb: 0,
|
||||||
|
fontSize: 40,
|
||||||
|
fontWeight: 700,
|
||||||
|
letterSpacing: "-0.02em",
|
||||||
|
lineHeight: 1,
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
|
||||||
|
statusLine: {
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: 400,
|
||||||
|
m: 0,
|
||||||
|
mb: "8px",
|
||||||
|
letterSpacing: "-0.01em",
|
||||||
|
lineHeight: 1.35,
|
||||||
|
color: tokens.text,
|
||||||
|
fontFamily: SERIF_STACK,
|
||||||
|
},
|
||||||
|
statusDot: (tone) => ({
|
||||||
|
display: "inline-block",
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
borderRadius: "50%",
|
||||||
|
background: toneColor(tone, tokens),
|
||||||
|
mr: "10px",
|
||||||
|
verticalAlign: "middle",
|
||||||
|
}),
|
||||||
|
dateline: {
|
||||||
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
fontSize: 11,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.12em",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
m: 0,
|
||||||
|
mb: "56px",
|
||||||
|
},
|
||||||
|
|
||||||
|
chartSwitchWrap: {
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
mb: "20px",
|
||||||
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
},
|
||||||
|
chartSwitch: {
|
||||||
|
display: "inline-flex",
|
||||||
|
border: `1px solid ${tokens.text}`,
|
||||||
|
"& > button + button": { borderLeft: `1px solid ${tokens.text}` },
|
||||||
|
},
|
||||||
|
chartSwitchButton: (active) => ({
|
||||||
|
fontFamily: "inherit",
|
||||||
|
fontSize: 10,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.2em",
|
||||||
|
padding: "6px 14px",
|
||||||
|
border: 0,
|
||||||
|
background: active ? tokens.text : "transparent",
|
||||||
|
color: active ? tokens.bg : tokens.text,
|
||||||
|
cursor: "pointer",
|
||||||
|
fontWeight: 700,
|
||||||
|
}),
|
||||||
|
|
||||||
|
monitorList: {
|
||||||
|
listStyle: "none",
|
||||||
|
m: 0,
|
||||||
|
p: 0,
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
background: "transparent",
|
||||||
|
border: 0,
|
||||||
|
borderBottom: `1px solid ${tokens.border}`,
|
||||||
|
mb: 0,
|
||||||
|
py: "20px",
|
||||||
|
"&:last-of-type": { borderBottom: 0 },
|
||||||
|
},
|
||||||
|
cardRow: {
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "1fr auto",
|
||||||
|
alignItems: "baseline",
|
||||||
|
gap: "20px",
|
||||||
|
},
|
||||||
|
cardLeft: { minWidth: 0 },
|
||||||
|
monitorName: {
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: 700,
|
||||||
|
letterSpacing: "-0.015em",
|
||||||
|
color: tokens.text,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
},
|
||||||
|
monitorMeta: {
|
||||||
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
fontSize: 12,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
mt: "6px",
|
||||||
|
display: "flex",
|
||||||
|
gap: "12px",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
pill: {
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.12em",
|
||||||
|
fontWeight: 700,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
},
|
||||||
|
pillHardware: {
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.12em",
|
||||||
|
fontWeight: 700,
|
||||||
|
color: tokens.up,
|
||||||
|
},
|
||||||
|
monitorUrl: {
|
||||||
|
fontFamily: MONO_STACK,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
maxWidth: 280,
|
||||||
|
fontSize: 12,
|
||||||
|
},
|
||||||
|
|
||||||
|
badge: (tone) => ({
|
||||||
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: 700,
|
||||||
|
padding: "4px 10px",
|
||||||
|
borderRadius: 0,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.15em",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
background: toneSoft(tone, tokens),
|
||||||
|
color: toneColor(tone, tokens),
|
||||||
|
}),
|
||||||
|
|
||||||
|
heatmap: {
|
||||||
|
mt: "16px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(25, 1fr)",
|
||||||
|
gap: "2px",
|
||||||
|
height: 40,
|
||||||
|
},
|
||||||
|
heatmapCell: (kind) => ({
|
||||||
|
background: heatCellBg[kind],
|
||||||
|
opacity: kind === "empty" ? 0.5 : 1,
|
||||||
|
}),
|
||||||
|
|
||||||
|
histogram: {
|
||||||
|
mt: "16px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(25, 1fr)",
|
||||||
|
gap: "2px",
|
||||||
|
alignItems: "flex-end",
|
||||||
|
height: 40,
|
||||||
|
},
|
||||||
|
bar: (kind, heightPct) => ({
|
||||||
|
background: barBg[kind],
|
||||||
|
minHeight: 3,
|
||||||
|
opacity: kind === "empty" ? 0.5 : 1,
|
||||||
|
height: `${heightPct}%`,
|
||||||
|
}),
|
||||||
|
chartStats: {
|
||||||
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.1em",
|
||||||
|
},
|
||||||
|
|
||||||
|
infra: {
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: { xs: "1fr", md: "repeat(3, 1fr)" },
|
||||||
|
gap: "24px",
|
||||||
|
mt: "20px",
|
||||||
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
},
|
||||||
|
infraEmpty: { mt: "20px", color: tokens.textMuted, fontSize: 13 },
|
||||||
|
gauge: {},
|
||||||
|
gaugeLabel: {
|
||||||
|
fontSize: 10,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.18em",
|
||||||
|
fontWeight: 700,
|
||||||
|
},
|
||||||
|
gaugeValue: {
|
||||||
|
fontSize: 28,
|
||||||
|
fontWeight: 700,
|
||||||
|
letterSpacing: "-0.02em",
|
||||||
|
mt: "4px",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
fontFamily: SERIF_STACK,
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
gaugeBar: { height: 2, background: tokens.border, mt: "10px" },
|
||||||
|
gaugeFill: (level, widthPct) => ({
|
||||||
|
display: "block",
|
||||||
|
height: "100%",
|
||||||
|
background: gaugeFillBg[level],
|
||||||
|
transition: "width 0.8s",
|
||||||
|
width: `${Math.max(0, Math.min(100, widthPct))}%`,
|
||||||
|
}),
|
||||||
|
gaugeSub: {
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
mt: "8px",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
},
|
||||||
|
|
||||||
|
footer: {
|
||||||
|
textAlign: "center",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontSize: 11,
|
||||||
|
mt: "56px",
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.2em",
|
||||||
|
fontFamily: EDITORIAL_SECONDARY_SANS_STACK,
|
||||||
|
"& a": {
|
||||||
|
color: tokens.text,
|
||||||
|
textDecoration: "none",
|
||||||
|
borderBottom: `1px solid ${tokens.text}`,
|
||||||
|
pb: "2px",
|
||||||
|
fontWeight: 700,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
import type { StatusPage } from "@/Types/StatusPage";
|
||||||
|
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
||||||
|
import { ThemedHeatmap } from "../shared/ThemedHeatmap";
|
||||||
|
import { ThemedHistogram } from "../shared/ThemedHistogram";
|
||||||
|
import { ThemedInfrastructure } from "../shared/ThemedInfrastructure";
|
||||||
|
import {
|
||||||
|
monitorBadgeTone,
|
||||||
|
monoFirstChar,
|
||||||
|
resolveOverallStatus,
|
||||||
|
statusBadgeKey,
|
||||||
|
} from "../shared/overallStatus";
|
||||||
|
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
||||||
|
import { modernStyles } from "./styles";
|
||||||
|
|
||||||
|
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
statusPage: StatusPage;
|
||||||
|
monitors: StatusPageMonitor[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ModernStatusPage = ({ statusPage, monitors }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { tokens, mode } = useStatusPageTheme();
|
||||||
|
const styles = useMemo(() => modernStyles(tokens, mode === "dark"), [tokens, mode]);
|
||||||
|
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
||||||
|
|
||||||
|
const overall = resolveOverallStatus(monitors, t, { iconSize: 20 });
|
||||||
|
const logoSrc = statusPage.logo?.data
|
||||||
|
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={styles.page}>
|
||||||
|
<Box
|
||||||
|
component="header"
|
||||||
|
sx={styles.top}
|
||||||
|
>
|
||||||
|
<Box sx={styles.brand}>
|
||||||
|
{logoSrc ? (
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={logoSrc}
|
||||||
|
alt={statusPage.companyName}
|
||||||
|
sx={styles.logoImg}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Box sx={styles.logoGrad}>{monoFirstChar(statusPage.companyName)}</Box>
|
||||||
|
)}
|
||||||
|
{statusPage.companyName}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={styles.hero}>
|
||||||
|
<Box sx={styles.pulse(overall.tone)} />
|
||||||
|
<Box sx={styles.statusCopy}>
|
||||||
|
<Box
|
||||||
|
component="h1"
|
||||||
|
sx={styles.heroTitle}
|
||||||
|
>
|
||||||
|
{overall.message}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.heroSub}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
|
count: monitors.length,
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{statusPage.showCharts && (
|
||||||
|
<Box sx={styles.chartSwitchWrap}>
|
||||||
|
<Box
|
||||||
|
sx={styles.chartSwitch}
|
||||||
|
role="radiogroup"
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={chartMode === "heatmap"}
|
||||||
|
onClick={() => setChartMode("heatmap")}
|
||||||
|
sx={styles.chartSwitchButton(chartMode === "heatmap")}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.monitorsList.chartTypeHeatmap")}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={chartMode === "histogram"}
|
||||||
|
onClick={() => setChartMode("histogram")}
|
||||||
|
sx={styles.chartSwitchButton(chartMode === "histogram")}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
sx={styles.monitorList}
|
||||||
|
>
|
||||||
|
{monitors.map((monitor) => {
|
||||||
|
const isHardware = monitor.type === "hardware";
|
||||||
|
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
||||||
|
const showChart = !isHardware && statusPage.showCharts !== false;
|
||||||
|
const badgeTone = monitorBadgeTone(monitor.status);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
component="li"
|
||||||
|
key={monitor.id}
|
||||||
|
sx={styles.card}
|
||||||
|
>
|
||||||
|
<Box sx={styles.cardRow}>
|
||||||
|
<Box sx={styles.cardLeft}>
|
||||||
|
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
||||||
|
<Box sx={styles.monitorMeta}>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={isHardware ? styles.pillHardware : styles.pill}
|
||||||
|
>
|
||||||
|
{getMonitorTypeLabel(monitor.type, t)}
|
||||||
|
</Box>
|
||||||
|
{monitor.url && (
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.monitorUrl}
|
||||||
|
title={monitor.url}
|
||||||
|
>
|
||||||
|
{monitor.url}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.badge(badgeTone)}
|
||||||
|
>
|
||||||
|
{t(statusBadgeKey[monitor.status])}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{showInfra && (
|
||||||
|
<ThemedInfrastructure
|
||||||
|
monitor={monitor}
|
||||||
|
sxApi={{
|
||||||
|
containerSx: styles.infra,
|
||||||
|
emptySx: styles.infraEmpty,
|
||||||
|
gaugeSx: styles.gauge,
|
||||||
|
gaugeLabelSx: styles.gaugeLabel,
|
||||||
|
gaugeValueSx: styles.gaugeValue,
|
||||||
|
gaugeBarSx: styles.gaugeBar,
|
||||||
|
gaugeFillSx: styles.gaugeFill,
|
||||||
|
gaugeSubSx: styles.gaugeSub,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{showChart &&
|
||||||
|
(chartMode === "heatmap" ? (
|
||||||
|
<ThemedHeatmap
|
||||||
|
checks={monitor.recentChecks ?? []}
|
||||||
|
containerSx={styles.heatmap}
|
||||||
|
cellSx={styles.heatmapCell}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ThemedHistogram
|
||||||
|
checks={monitor.recentChecks ?? []}
|
||||||
|
containerSx={styles.histogram}
|
||||||
|
barSx={styles.bar}
|
||||||
|
statsSx={styles.chartStats}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
component="footer"
|
||||||
|
sx={styles.footer}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.footer.poweredBy")}{" "}
|
||||||
|
<a
|
||||||
|
href="https://checkmate.so"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
Checkmate
|
||||||
|
</a>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,428 @@
|
|||||||
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
|
import { keyframes } from "@mui/system";
|
||||||
|
import type { StatusPageThemeTokens } from "../tokens";
|
||||||
|
import { type OverallTone, toneColor, toneSoft } from "../shared/overallStatus";
|
||||||
|
import { MONO_STACK, SANS_STACK } from "../shared/fontStacks";
|
||||||
|
|
||||||
|
export type ModernHeatCell = "fast" | "med" | "slow" | "down" | "empty";
|
||||||
|
export type ModernBarKind = "up" | "down" | "empty";
|
||||||
|
export type ModernGaugeFill = "ok" | "warm" | "hot";
|
||||||
|
|
||||||
|
export interface ModernStyles {
|
||||||
|
page: SxProps<Theme>;
|
||||||
|
top: SxProps<Theme>;
|
||||||
|
brand: SxProps<Theme>;
|
||||||
|
logoGrad: SxProps<Theme>;
|
||||||
|
logoImg: SxProps<Theme>;
|
||||||
|
hero: SxProps<Theme>;
|
||||||
|
pulse: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
statusCopy: SxProps<Theme>;
|
||||||
|
heroTitle: SxProps<Theme>;
|
||||||
|
heroSub: SxProps<Theme>;
|
||||||
|
heroIcon: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
chartSwitchWrap: SxProps<Theme>;
|
||||||
|
chartSwitch: SxProps<Theme>;
|
||||||
|
chartSwitchButton: (active: boolean) => SxProps<Theme>;
|
||||||
|
monitorList: SxProps<Theme>;
|
||||||
|
card: SxProps<Theme>;
|
||||||
|
cardRow: SxProps<Theme>;
|
||||||
|
cardLeft: SxProps<Theme>;
|
||||||
|
monitorName: SxProps<Theme>;
|
||||||
|
monitorMeta: SxProps<Theme>;
|
||||||
|
pill: SxProps<Theme>;
|
||||||
|
pillHardware: SxProps<Theme>;
|
||||||
|
monitorUrl: SxProps<Theme>;
|
||||||
|
badge: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
heatmap: SxProps<Theme>;
|
||||||
|
heatmapCell: (kind: ModernHeatCell) => SxProps<Theme>;
|
||||||
|
histogram: SxProps<Theme>;
|
||||||
|
bar: (kind: ModernBarKind, heightPct: number) => SxProps<Theme>;
|
||||||
|
chartStats: SxProps<Theme>;
|
||||||
|
infra: SxProps<Theme>;
|
||||||
|
infraEmpty: SxProps<Theme>;
|
||||||
|
gauge: SxProps<Theme>;
|
||||||
|
gaugeLabel: SxProps<Theme>;
|
||||||
|
gaugeValue: SxProps<Theme>;
|
||||||
|
gaugeBar: SxProps<Theme>;
|
||||||
|
gaugeFill: (level: ModernGaugeFill, widthPct: number) => SxProps<Theme>;
|
||||||
|
gaugeSub: SxProps<Theme>;
|
||||||
|
footer: SxProps<Theme>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lightShadow =
|
||||||
|
"0 2px 4px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.06)";
|
||||||
|
const darkShadow = "0 2px 6px rgba(0, 0, 0, 0.5), 0 20px 40px rgba(0, 0, 0, 0.4)";
|
||||||
|
const lightShadowHover =
|
||||||
|
"0 4px 8px rgba(16, 24, 40, 0.05), 0 16px 40px rgba(16, 24, 40, 0.08)";
|
||||||
|
const darkShadowHover = "0 4px 10px rgba(0, 0, 0, 0.55), 0 24px 48px rgba(0, 0, 0, 0.45)";
|
||||||
|
|
||||||
|
const pillBase = {
|
||||||
|
fontSize: 10,
|
||||||
|
textTransform: "uppercase" as const,
|
||||||
|
letterSpacing: "0.08em",
|
||||||
|
padding: "3px 9px",
|
||||||
|
borderRadius: "999px",
|
||||||
|
fontWeight: 600,
|
||||||
|
};
|
||||||
|
|
||||||
|
const pulseKeyframes = keyframes`
|
||||||
|
0% { transform: scale(1); opacity: 0.5; }
|
||||||
|
100% { transform: scale(2.4); opacity: 0; }
|
||||||
|
`;
|
||||||
|
|
||||||
|
const fadeInKeyframes = keyframes`
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const modernStyles = (
|
||||||
|
tokens: StatusPageThemeTokens,
|
||||||
|
isDark: boolean
|
||||||
|
): ModernStyles => {
|
||||||
|
const cardShadow = isDark ? darkShadow : lightShadow;
|
||||||
|
const cardHoverShadow = isDark ? darkShadowHover : lightShadowHover;
|
||||||
|
|
||||||
|
const heatCellBg: Record<ModernHeatCell, string> = {
|
||||||
|
fast: `linear-gradient(180deg, ${tokens.up}, ${tokens.upStrong})`,
|
||||||
|
med: `linear-gradient(180deg, color-mix(in srgb, ${tokens.up} 70%, #ffffff 30%), ${tokens.up})`,
|
||||||
|
slow: `linear-gradient(180deg, ${tokens.warn}, ${tokens.degraded})`,
|
||||||
|
down: `linear-gradient(180deg, ${tokens.down}, color-mix(in srgb, ${tokens.down} 70%, #000000 30%))`,
|
||||||
|
empty: tokens.border,
|
||||||
|
};
|
||||||
|
|
||||||
|
const barBg: Record<ModernBarKind, string> = {
|
||||||
|
up: tokens.up,
|
||||||
|
down: tokens.down,
|
||||||
|
empty: tokens.border,
|
||||||
|
};
|
||||||
|
|
||||||
|
const gaugeFillBg: Record<ModernGaugeFill, string> = {
|
||||||
|
ok: `linear-gradient(90deg, ${tokens.up}, ${tokens.upStrong})`,
|
||||||
|
warm: `linear-gradient(90deg, ${tokens.warn}, ${tokens.degraded})`,
|
||||||
|
hot: `linear-gradient(90deg, ${tokens.down}, color-mix(in srgb, ${tokens.down} 70%, #000000 30%))`,
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
page: {
|
||||||
|
flex: "1 0 auto",
|
||||||
|
maxWidth: 980,
|
||||||
|
width: "100%",
|
||||||
|
mx: "auto",
|
||||||
|
p: "56px 20px 80px",
|
||||||
|
fontFamily: SANS_STACK,
|
||||||
|
fontSize: 14,
|
||||||
|
lineHeight: 1.5,
|
||||||
|
color: tokens.text,
|
||||||
|
WebkitFontSmoothing: "antialiased",
|
||||||
|
},
|
||||||
|
|
||||||
|
top: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
mb: "32px",
|
||||||
|
},
|
||||||
|
brand: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "12px",
|
||||||
|
fontWeight: 700,
|
||||||
|
fontSize: 15,
|
||||||
|
letterSpacing: "-0.01em",
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
logoGrad: {
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
borderRadius: "10px",
|
||||||
|
background: `linear-gradient(135deg, ${tokens.up}, ${tokens.upStrong})`,
|
||||||
|
display: "grid",
|
||||||
|
placeItems: "center",
|
||||||
|
color: "#fff",
|
||||||
|
fontWeight: 700,
|
||||||
|
fontSize: 14,
|
||||||
|
boxShadow: `0 4px 10px color-mix(in srgb, ${tokens.up} 40%, transparent)`,
|
||||||
|
},
|
||||||
|
logoImg: { maxHeight: 32, maxWidth: 120, objectFit: "contain" },
|
||||||
|
|
||||||
|
hero: {
|
||||||
|
position: "relative",
|
||||||
|
borderRadius: "20px",
|
||||||
|
padding: "28px 32px",
|
||||||
|
mb: "24px",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "20px",
|
||||||
|
background: tokens.surface,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
boxShadow: cardShadow,
|
||||||
|
},
|
||||||
|
pulse: (tone) => {
|
||||||
|
const c = toneColor(tone, tokens);
|
||||||
|
return {
|
||||||
|
position: "relative",
|
||||||
|
width: 14,
|
||||||
|
height: 14,
|
||||||
|
borderRadius: "50%",
|
||||||
|
background: c,
|
||||||
|
color: c,
|
||||||
|
flexShrink: 0,
|
||||||
|
"&::before, &::after": {
|
||||||
|
content: '""',
|
||||||
|
position: "absolute",
|
||||||
|
inset: 0,
|
||||||
|
borderRadius: "50%",
|
||||||
|
background: "currentColor",
|
||||||
|
opacity: 0.5,
|
||||||
|
animation: `${pulseKeyframes} 2s ease-out infinite`,
|
||||||
|
},
|
||||||
|
"&::after": { animationDelay: "1s" },
|
||||||
|
"@media (prefers-reduced-motion: reduce)": {
|
||||||
|
"&::before, &::after": { animation: "none" },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
statusCopy: { flex: 1, minWidth: 0 },
|
||||||
|
heroTitle: {
|
||||||
|
m: 0,
|
||||||
|
mb: "4px",
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: 700,
|
||||||
|
letterSpacing: "-0.02em",
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
heroSub: { m: 0, color: tokens.textMuted, fontSize: 13 },
|
||||||
|
heroIcon: (tone) => ({
|
||||||
|
color: toneColor(tone, tokens),
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
}),
|
||||||
|
|
||||||
|
chartSwitchWrap: { display: "flex", justifyContent: "flex-end", mb: "14px" },
|
||||||
|
chartSwitch: {
|
||||||
|
display: "inline-flex",
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: "999px",
|
||||||
|
background: tokens.surface,
|
||||||
|
p: "3px",
|
||||||
|
gap: "2px",
|
||||||
|
},
|
||||||
|
chartSwitchButton: (active) => ({
|
||||||
|
border: 0,
|
||||||
|
background: active ? tokens.upSoft : "transparent",
|
||||||
|
fontFamily: "inherit",
|
||||||
|
fontSize: 11,
|
||||||
|
padding: "6px 16px",
|
||||||
|
cursor: "pointer",
|
||||||
|
color: active ? tokens.up : tokens.textMuted,
|
||||||
|
fontWeight: 600,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.08em",
|
||||||
|
transition: "background 0.2s, color 0.2s",
|
||||||
|
borderRadius: "999px",
|
||||||
|
"&:hover": { color: active ? tokens.up : tokens.text },
|
||||||
|
}),
|
||||||
|
|
||||||
|
monitorList: {
|
||||||
|
listStyle: "none",
|
||||||
|
m: 0,
|
||||||
|
p: 0,
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: "14px",
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
background: tokens.surface,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: "16px",
|
||||||
|
boxShadow: cardShadow,
|
||||||
|
overflow: "hidden",
|
||||||
|
transition: "transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s",
|
||||||
|
opacity: 0,
|
||||||
|
transform: "translateY(8px)",
|
||||||
|
animation: `${fadeInKeyframes} 0.5s forwards`,
|
||||||
|
"&:nth-of-type(1)": { animationDelay: "0.05s" },
|
||||||
|
"&:nth-of-type(2)": { animationDelay: "0.1s" },
|
||||||
|
"&:nth-of-type(3)": { animationDelay: "0.15s" },
|
||||||
|
"&:nth-of-type(4)": { animationDelay: "0.2s" },
|
||||||
|
"&:nth-of-type(5)": { animationDelay: "0.25s" },
|
||||||
|
"&:nth-of-type(n+6)": { animationDelay: "0.3s" },
|
||||||
|
"&:hover": { transform: "translateY(-2px)", boxShadow: cardHoverShadow },
|
||||||
|
"@media (prefers-reduced-motion: reduce)": {
|
||||||
|
animation: "none",
|
||||||
|
opacity: 1,
|
||||||
|
transform: "none",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cardRow: {
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "1fr auto",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "20px",
|
||||||
|
p: "18px 24px",
|
||||||
|
},
|
||||||
|
cardLeft: { minWidth: 0 },
|
||||||
|
monitorName: {
|
||||||
|
fontWeight: 600,
|
||||||
|
fontSize: 15,
|
||||||
|
letterSpacing: "-0.005em",
|
||||||
|
color: tokens.text,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
},
|
||||||
|
monitorMeta: {
|
||||||
|
display: "flex",
|
||||||
|
gap: "10px",
|
||||||
|
alignItems: "center",
|
||||||
|
mt: "6px",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
},
|
||||||
|
pill: {
|
||||||
|
...pillBase,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
background: tokens.bg,
|
||||||
|
},
|
||||||
|
pillHardware: {
|
||||||
|
...pillBase,
|
||||||
|
color: tokens.up,
|
||||||
|
background: tokens.upSoft,
|
||||||
|
},
|
||||||
|
monitorUrl: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontFamily: MONO_STACK,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
maxWidth: 280,
|
||||||
|
},
|
||||||
|
|
||||||
|
badge: (tone) => ({
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: 700,
|
||||||
|
padding: "5px 12px",
|
||||||
|
borderRadius: "999px",
|
||||||
|
display: "inline-flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "6px",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
background: toneSoft(tone, tokens),
|
||||||
|
color: toneColor(tone, tokens),
|
||||||
|
"&::before": {
|
||||||
|
content: '""',
|
||||||
|
width: 6,
|
||||||
|
height: 6,
|
||||||
|
borderRadius: "50%",
|
||||||
|
background: "currentColor",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
heatmap: {
|
||||||
|
padding: "0 24px 20px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(25, 1fr)",
|
||||||
|
gap: "3px",
|
||||||
|
height: 46,
|
||||||
|
},
|
||||||
|
heatmapCell: (kind) => ({
|
||||||
|
borderRadius: "3px",
|
||||||
|
background: heatCellBg[kind],
|
||||||
|
opacity: kind === "empty" ? 0.4 : 1,
|
||||||
|
transition: "transform 0.15s",
|
||||||
|
"&:hover": { transform: "scaleY(1.2)" },
|
||||||
|
}),
|
||||||
|
|
||||||
|
histogram: {
|
||||||
|
padding: "0 24px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(25, 1fr)",
|
||||||
|
gap: "3px",
|
||||||
|
alignItems: "flex-end",
|
||||||
|
height: 46,
|
||||||
|
},
|
||||||
|
bar: (kind, heightPct) => ({
|
||||||
|
background: barBg[kind],
|
||||||
|
borderRadius: "3px",
|
||||||
|
minHeight: 4,
|
||||||
|
opacity: kind === "empty" ? 0.4 : 1,
|
||||||
|
height: `${heightPct}%`,
|
||||||
|
transition: "transform 0.15s",
|
||||||
|
"&:hover": { transform: "scaleY(1.08)" },
|
||||||
|
}),
|
||||||
|
chartStats: {
|
||||||
|
padding: "0 24px 20px",
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
|
|
||||||
|
infra: {
|
||||||
|
padding: "16px 24px 22px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: { xs: "1fr", md: "repeat(3, 1fr)" },
|
||||||
|
gap: "14px",
|
||||||
|
},
|
||||||
|
infraEmpty: {
|
||||||
|
padding: "16px 24px 22px",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontSize: 13,
|
||||||
|
},
|
||||||
|
gauge: {
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: "14px",
|
||||||
|
p: "14px 16px",
|
||||||
|
background: `linear-gradient(135deg, ${tokens.bg}, ${tokens.surface})`,
|
||||||
|
},
|
||||||
|
gaugeLabel: {
|
||||||
|
fontSize: 10,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.1em",
|
||||||
|
fontWeight: 700,
|
||||||
|
},
|
||||||
|
gaugeValue: {
|
||||||
|
fontSize: 26,
|
||||||
|
fontWeight: 700,
|
||||||
|
letterSpacing: "-0.02em",
|
||||||
|
mt: "4px",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
gaugeBar: {
|
||||||
|
height: 6,
|
||||||
|
background: tokens.border,
|
||||||
|
borderRadius: "3px",
|
||||||
|
overflow: "hidden",
|
||||||
|
mt: "10px",
|
||||||
|
},
|
||||||
|
gaugeFill: (level, widthPct) => ({
|
||||||
|
display: "block",
|
||||||
|
height: "100%",
|
||||||
|
background: gaugeFillBg[level],
|
||||||
|
borderRadius: "3px",
|
||||||
|
transition: "width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1)",
|
||||||
|
width: `${Math.max(0, Math.min(100, widthPct))}%`,
|
||||||
|
}),
|
||||||
|
gaugeSub: {
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
mt: "8px",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
},
|
||||||
|
|
||||||
|
footer: {
|
||||||
|
textAlign: "center",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontSize: 12,
|
||||||
|
mt: "48px",
|
||||||
|
"& a": {
|
||||||
|
color: tokens.up,
|
||||||
|
textDecoration: "underline",
|
||||||
|
textUnderlineOffset: "3px",
|
||||||
|
fontWeight: 700,
|
||||||
|
"&:hover": { color: tokens.upStrong },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,210 @@
|
|||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
import type { StatusPage } from "@/Types/StatusPage";
|
||||||
|
import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
||||||
|
import { ThemedHeatmap } from "../shared/ThemedHeatmap";
|
||||||
|
import { ThemedHistogram } from "../shared/ThemedHistogram";
|
||||||
|
import { ThemedInfrastructure } from "../shared/ThemedInfrastructure";
|
||||||
|
import {
|
||||||
|
monitorBadgeTone,
|
||||||
|
monoFirstChar,
|
||||||
|
resolveOverallStatus,
|
||||||
|
statusBadgeKey,
|
||||||
|
} from "../shared/overallStatus";
|
||||||
|
import { useStatusPageTheme } from "../StatusPageThemeProvider";
|
||||||
|
import { refinedStyles } from "./styles";
|
||||||
|
|
||||||
|
type StatusPageMonitor = Monitor & { checks?: Monitor["recentChecks"] };
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
statusPage: StatusPage;
|
||||||
|
monitors: StatusPageMonitor[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const RefinedStatusPage = ({ statusPage, monitors }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { tokens } = useStatusPageTheme();
|
||||||
|
const styles = useMemo(() => refinedStyles(tokens), [tokens]);
|
||||||
|
const [chartMode, setChartMode] = useState<"heatmap" | "histogram">("heatmap");
|
||||||
|
|
||||||
|
const overall = resolveOverallStatus(monitors, t);
|
||||||
|
const logoSrc = statusPage.logo?.data
|
||||||
|
? `data:${statusPage.logo.contentType};base64,${statusPage.logo.data}`
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={styles.page}>
|
||||||
|
<Box
|
||||||
|
component="header"
|
||||||
|
sx={styles.top}
|
||||||
|
>
|
||||||
|
<Box sx={styles.brand}>
|
||||||
|
{logoSrc ? (
|
||||||
|
<Box
|
||||||
|
component="img"
|
||||||
|
src={logoSrc}
|
||||||
|
alt={statusPage.companyName}
|
||||||
|
sx={styles.logoImg}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Box sx={styles.logoMono}>{monoFirstChar(statusPage.companyName)}</Box>
|
||||||
|
)}
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.company}
|
||||||
|
>
|
||||||
|
{statusPage.companyName}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={styles.hero}>
|
||||||
|
<Box sx={styles.statusDot(overall.tone)} />
|
||||||
|
<Box sx={styles.statusCopy}>
|
||||||
|
<Box
|
||||||
|
component="h1"
|
||||||
|
sx={styles.heroTitle}
|
||||||
|
>
|
||||||
|
{overall.message}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="p"
|
||||||
|
sx={styles.heroSub}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.statusBar.monitoringSummary", {
|
||||||
|
count: monitors.length,
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box sx={styles.heroIcon(overall.tone)}>{overall.icon}</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{statusPage.showCharts && (
|
||||||
|
<Box sx={styles.chartSwitchWrap}>
|
||||||
|
<Box
|
||||||
|
sx={styles.chartSwitch}
|
||||||
|
role="radiogroup"
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={chartMode === "heatmap"}
|
||||||
|
onClick={() => setChartMode("heatmap")}
|
||||||
|
sx={styles.chartSwitchButton(chartMode === "heatmap")}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.monitorsList.chartTypeHeatmap")}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={chartMode === "histogram"}
|
||||||
|
onClick={() => setChartMode("histogram")}
|
||||||
|
sx={styles.chartSwitchButton(chartMode === "histogram")}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.monitorsList.chartTypeHistogram")}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
sx={styles.monitorList}
|
||||||
|
>
|
||||||
|
{monitors.map((monitor) => {
|
||||||
|
const isHardware = monitor.type === "hardware";
|
||||||
|
const showInfra = isHardware && statusPage.showInfrastructure !== false;
|
||||||
|
const showChart = !isHardware && statusPage.showCharts !== false;
|
||||||
|
const badgeTone = monitorBadgeTone(monitor.status);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
component="li"
|
||||||
|
key={monitor.id}
|
||||||
|
sx={styles.card}
|
||||||
|
>
|
||||||
|
<Box sx={styles.cardRow}>
|
||||||
|
<Box sx={styles.cardLeft}>
|
||||||
|
<Box sx={styles.monitorName}>{monitor.name}</Box>
|
||||||
|
<Box sx={styles.monitorMeta}>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={isHardware ? styles.pillHardware : styles.pill}
|
||||||
|
>
|
||||||
|
{getMonitorTypeLabel(monitor.type, t)}
|
||||||
|
</Box>
|
||||||
|
{monitor.url && (
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.monitorUrl}
|
||||||
|
title={monitor.url}
|
||||||
|
>
|
||||||
|
{monitor.url}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={styles.badge(badgeTone)}
|
||||||
|
>
|
||||||
|
{t(statusBadgeKey[monitor.status])}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{showInfra && (
|
||||||
|
<ThemedInfrastructure
|
||||||
|
monitor={monitor}
|
||||||
|
sxApi={{
|
||||||
|
containerSx: styles.infra,
|
||||||
|
emptySx: styles.infraEmpty,
|
||||||
|
gaugeSx: styles.gauge,
|
||||||
|
gaugeLabelSx: styles.gaugeLabel,
|
||||||
|
gaugeValueSx: styles.gaugeValue,
|
||||||
|
gaugeBarSx: styles.gaugeBar,
|
||||||
|
gaugeFillSx: styles.gaugeFill,
|
||||||
|
gaugeSubSx: styles.gaugeSub,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{showChart &&
|
||||||
|
(chartMode === "heatmap" ? (
|
||||||
|
<ThemedHeatmap
|
||||||
|
checks={monitor.recentChecks ?? []}
|
||||||
|
containerSx={styles.heatmap}
|
||||||
|
cellSx={styles.heatmapCell}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ThemedHistogram
|
||||||
|
checks={monitor.recentChecks ?? []}
|
||||||
|
containerSx={styles.histogram}
|
||||||
|
barSx={styles.bar}
|
||||||
|
statsSx={styles.chartStats}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
component="footer"
|
||||||
|
sx={styles.footer}
|
||||||
|
>
|
||||||
|
{t("pages.statusPages.footer.poweredBy")}{" "}
|
||||||
|
<a
|
||||||
|
href="https://checkmate.so"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
Checkmate
|
||||||
|
</a>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,364 @@
|
|||||||
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
|
import type { StatusPageThemeTokens } from "../tokens";
|
||||||
|
import { type OverallTone, toneColor, toneSoft } from "../shared/overallStatus";
|
||||||
|
import { MONO_STACK, SANS_STACK } from "../shared/fontStacks";
|
||||||
|
|
||||||
|
export type RefinedHeatCell = "fast" | "med" | "slow" | "down" | "empty";
|
||||||
|
export type RefinedBarKind = "up" | "down" | "empty";
|
||||||
|
export type RefinedGaugeFill = "ok" | "warm" | "hot";
|
||||||
|
|
||||||
|
export interface RefinedStyles {
|
||||||
|
page: SxProps<Theme>;
|
||||||
|
top: SxProps<Theme>;
|
||||||
|
brand: SxProps<Theme>;
|
||||||
|
logoMono: SxProps<Theme>;
|
||||||
|
logoImg: SxProps<Theme>;
|
||||||
|
company: SxProps<Theme>;
|
||||||
|
hero: SxProps<Theme>;
|
||||||
|
statusDot: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
statusCopy: SxProps<Theme>;
|
||||||
|
heroTitle: SxProps<Theme>;
|
||||||
|
heroSub: SxProps<Theme>;
|
||||||
|
heroIcon: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
chartSwitchWrap: SxProps<Theme>;
|
||||||
|
chartSwitch: SxProps<Theme>;
|
||||||
|
chartSwitchButton: (active: boolean) => SxProps<Theme>;
|
||||||
|
monitorList: SxProps<Theme>;
|
||||||
|
card: SxProps<Theme>;
|
||||||
|
cardRow: SxProps<Theme>;
|
||||||
|
cardLeft: SxProps<Theme>;
|
||||||
|
monitorName: SxProps<Theme>;
|
||||||
|
monitorMeta: SxProps<Theme>;
|
||||||
|
pill: SxProps<Theme>;
|
||||||
|
pillHardware: SxProps<Theme>;
|
||||||
|
monitorUrl: SxProps<Theme>;
|
||||||
|
badge: (tone: OverallTone) => SxProps<Theme>;
|
||||||
|
heatmap: SxProps<Theme>;
|
||||||
|
heatmapCell: (kind: RefinedHeatCell) => SxProps<Theme>;
|
||||||
|
histogram: SxProps<Theme>;
|
||||||
|
bar: (kind: RefinedBarKind, heightPct: number) => SxProps<Theme>;
|
||||||
|
chartStats: SxProps<Theme>;
|
||||||
|
infra: SxProps<Theme>;
|
||||||
|
infraEmpty: SxProps<Theme>;
|
||||||
|
gauge: SxProps<Theme>;
|
||||||
|
gaugeLabel: SxProps<Theme>;
|
||||||
|
gaugeValue: SxProps<Theme>;
|
||||||
|
gaugeBar: SxProps<Theme>;
|
||||||
|
gaugeFill: (level: RefinedGaugeFill, widthPct: number) => SxProps<Theme>;
|
||||||
|
gaugeSub: SxProps<Theme>;
|
||||||
|
footer: SxProps<Theme>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cardShadow = "0 1px 2px rgba(10, 16, 32, 0.06), 0 6px 18px rgba(10, 16, 32, 0.08)";
|
||||||
|
const cardShadowHover =
|
||||||
|
"0 2px 4px rgba(16, 24, 40, 0.06), 0 10px 24px rgba(16, 24, 40, 0.06)";
|
||||||
|
|
||||||
|
const pillBase = {
|
||||||
|
fontSize: 10,
|
||||||
|
textTransform: "uppercase" as const,
|
||||||
|
letterSpacing: "0.08em",
|
||||||
|
padding: "2px 8px",
|
||||||
|
borderRadius: "999px",
|
||||||
|
fontWeight: 600,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const refinedStyles = (tokens: StatusPageThemeTokens): RefinedStyles => {
|
||||||
|
const heatCellBg: Record<RefinedHeatCell, string> = {
|
||||||
|
fast: tokens.up,
|
||||||
|
med: `color-mix(in srgb, ${tokens.up} 60%, #ffffff 40%)`,
|
||||||
|
slow: tokens.warn,
|
||||||
|
down: tokens.down,
|
||||||
|
empty: tokens.border,
|
||||||
|
};
|
||||||
|
|
||||||
|
const barBg: Record<RefinedBarKind, string> = {
|
||||||
|
up: tokens.up,
|
||||||
|
down: tokens.down,
|
||||||
|
empty: tokens.border,
|
||||||
|
};
|
||||||
|
|
||||||
|
const gaugeFillBg: Record<RefinedGaugeFill, string> = {
|
||||||
|
ok: tokens.up,
|
||||||
|
warm: tokens.warn,
|
||||||
|
hot: tokens.down,
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
page: {
|
||||||
|
flex: "1 0 auto",
|
||||||
|
maxWidth: 960,
|
||||||
|
width: "100%",
|
||||||
|
mx: "auto",
|
||||||
|
p: "48px 20px 80px",
|
||||||
|
fontFamily: SANS_STACK,
|
||||||
|
fontSize: 14,
|
||||||
|
lineHeight: 1.5,
|
||||||
|
color: tokens.text,
|
||||||
|
WebkitFontSmoothing: "antialiased",
|
||||||
|
},
|
||||||
|
|
||||||
|
top: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
mb: "28px",
|
||||||
|
},
|
||||||
|
brand: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "10px",
|
||||||
|
fontWeight: 600,
|
||||||
|
letterSpacing: "-0.01em",
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
logoMono: {
|
||||||
|
width: 28,
|
||||||
|
height: 28,
|
||||||
|
borderRadius: "8px",
|
||||||
|
background: tokens.up,
|
||||||
|
display: "grid",
|
||||||
|
placeItems: "center",
|
||||||
|
color: "#fff",
|
||||||
|
fontWeight: 700,
|
||||||
|
fontSize: 13,
|
||||||
|
},
|
||||||
|
logoImg: { maxHeight: 32, maxWidth: 120, objectFit: "contain" },
|
||||||
|
company: { fontSize: 14 },
|
||||||
|
|
||||||
|
hero: {
|
||||||
|
background: tokens.surface,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: tokens.radius,
|
||||||
|
padding: "22px 24px",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "16px",
|
||||||
|
boxShadow: cardShadow,
|
||||||
|
mb: "20px",
|
||||||
|
},
|
||||||
|
statusDot: (tone) => ({
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
borderRadius: "50%",
|
||||||
|
background: toneColor(tone, tokens),
|
||||||
|
boxShadow: `0 0 0 4px ${toneSoft(tone, tokens)}`,
|
||||||
|
flexShrink: 0,
|
||||||
|
}),
|
||||||
|
statusCopy: { flex: 1, minWidth: 0 },
|
||||||
|
heroTitle: {
|
||||||
|
m: 0,
|
||||||
|
mb: "2px",
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: 600,
|
||||||
|
letterSpacing: "-0.01em",
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
heroSub: { m: 0, color: tokens.textMuted, fontSize: 13 },
|
||||||
|
heroIcon: (tone) => ({
|
||||||
|
color: toneColor(tone, tokens),
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
}),
|
||||||
|
|
||||||
|
chartSwitchWrap: { display: "flex", justifyContent: "flex-end", mb: "12px" },
|
||||||
|
chartSwitch: {
|
||||||
|
display: "inline-flex",
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: "8px",
|
||||||
|
background: tokens.surface,
|
||||||
|
p: "3px",
|
||||||
|
gap: "2px",
|
||||||
|
},
|
||||||
|
chartSwitchButton: (active) => ({
|
||||||
|
border: 0,
|
||||||
|
background: active ? tokens.upSoft : "transparent",
|
||||||
|
fontFamily: "inherit",
|
||||||
|
fontSize: 11,
|
||||||
|
padding: "5px 14px",
|
||||||
|
cursor: "pointer",
|
||||||
|
color: active ? tokens.up : tokens.textMuted,
|
||||||
|
borderRadius: "5px",
|
||||||
|
transition: "background 0.15s ease, color 0.15s ease",
|
||||||
|
fontWeight: active ? 600 : 500,
|
||||||
|
"&:hover": { color: active ? tokens.up : tokens.text },
|
||||||
|
}),
|
||||||
|
|
||||||
|
monitorList: {
|
||||||
|
listStyle: "none",
|
||||||
|
m: 0,
|
||||||
|
p: 0,
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: "12px",
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
background: tokens.surface,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: tokens.radius,
|
||||||
|
boxShadow: cardShadow,
|
||||||
|
overflow: "hidden",
|
||||||
|
position: "relative",
|
||||||
|
transition: "transform 0.15s, box-shadow 0.15s",
|
||||||
|
"&:hover": { transform: "translateY(-1px)", boxShadow: cardShadowHover },
|
||||||
|
},
|
||||||
|
cardRow: {
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "1fr auto",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "16px",
|
||||||
|
p: "16px 20px",
|
||||||
|
},
|
||||||
|
cardLeft: { minWidth: 0 },
|
||||||
|
monitorName: {
|
||||||
|
fontWeight: 600,
|
||||||
|
fontSize: 14,
|
||||||
|
letterSpacing: "-0.005em",
|
||||||
|
color: tokens.text,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
},
|
||||||
|
monitorMeta: {
|
||||||
|
display: "flex",
|
||||||
|
gap: "10px",
|
||||||
|
alignItems: "center",
|
||||||
|
mt: "4px",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
},
|
||||||
|
pill: {
|
||||||
|
...pillBase,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
},
|
||||||
|
pillHardware: {
|
||||||
|
...pillBase,
|
||||||
|
color: tokens.up,
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
background: tokens.upSoft,
|
||||||
|
},
|
||||||
|
monitorUrl: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontFamily: MONO_STACK,
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
maxWidth: 280,
|
||||||
|
},
|
||||||
|
|
||||||
|
badge: (tone) => ({
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: 600,
|
||||||
|
padding: "4px 10px",
|
||||||
|
borderRadius: "999px",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
background: toneSoft(tone, tokens),
|
||||||
|
color: toneColor(tone, tokens),
|
||||||
|
}),
|
||||||
|
|
||||||
|
heatmap: {
|
||||||
|
padding: "0 20px 16px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(25, 1fr)",
|
||||||
|
gap: "3px",
|
||||||
|
height: 42,
|
||||||
|
},
|
||||||
|
heatmapCell: (kind) => ({
|
||||||
|
borderRadius: "2px",
|
||||||
|
background: heatCellBg[kind],
|
||||||
|
opacity: kind === "empty" ? 0.4 : 1,
|
||||||
|
transition: "transform 0.15s",
|
||||||
|
"&:hover": { transform: "scaleY(1.15)" },
|
||||||
|
}),
|
||||||
|
|
||||||
|
histogram: {
|
||||||
|
padding: "0 20px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: "repeat(25, 1fr)",
|
||||||
|
gap: "3px",
|
||||||
|
alignItems: "flex-end",
|
||||||
|
height: 42,
|
||||||
|
},
|
||||||
|
bar: (kind, heightPct) => ({
|
||||||
|
background: barBg[kind],
|
||||||
|
borderRadius: "2px",
|
||||||
|
minHeight: 3,
|
||||||
|
opacity: kind === "empty" ? 0.4 : 1,
|
||||||
|
height: `${heightPct}%`,
|
||||||
|
}),
|
||||||
|
chartStats: {
|
||||||
|
padding: "0 20px 16px",
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
},
|
||||||
|
|
||||||
|
infra: {
|
||||||
|
padding: "14px 20px 18px",
|
||||||
|
display: "grid",
|
||||||
|
gridTemplateColumns: { xs: "1fr", md: "repeat(3, 1fr)" },
|
||||||
|
gap: "12px",
|
||||||
|
},
|
||||||
|
infraEmpty: {
|
||||||
|
padding: "14px 20px 18px",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontSize: 13,
|
||||||
|
},
|
||||||
|
gauge: {
|
||||||
|
border: `1px solid ${tokens.border}`,
|
||||||
|
borderRadius: "10px",
|
||||||
|
p: "12px 14px",
|
||||||
|
background: tokens.bg,
|
||||||
|
},
|
||||||
|
gaugeLabel: {
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: "0.08em",
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
|
gaugeValue: {
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: 600,
|
||||||
|
letterSpacing: "-0.01em",
|
||||||
|
mt: "2px",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
color: tokens.text,
|
||||||
|
},
|
||||||
|
gaugeBar: {
|
||||||
|
height: 4,
|
||||||
|
background: tokens.border,
|
||||||
|
borderRadius: "2px",
|
||||||
|
overflow: "hidden",
|
||||||
|
mt: "8px",
|
||||||
|
},
|
||||||
|
gaugeFill: (level, widthPct) => ({
|
||||||
|
display: "block",
|
||||||
|
height: "100%",
|
||||||
|
background: gaugeFillBg[level],
|
||||||
|
borderRadius: "2px",
|
||||||
|
transition: "width 0.6s",
|
||||||
|
width: `${Math.max(0, Math.min(100, widthPct))}%`,
|
||||||
|
}),
|
||||||
|
gaugeSub: {
|
||||||
|
fontSize: 11,
|
||||||
|
color: tokens.textMuted,
|
||||||
|
mt: "6px",
|
||||||
|
fontVariantNumeric: "tabular-nums",
|
||||||
|
},
|
||||||
|
|
||||||
|
footer: {
|
||||||
|
textAlign: "center",
|
||||||
|
color: tokens.textMuted,
|
||||||
|
fontSize: 12,
|
||||||
|
mt: "40px",
|
||||||
|
"& a": {
|
||||||
|
color: tokens.up,
|
||||||
|
textDecoration: "underline",
|
||||||
|
textUnderlineOffset: "3px",
|
||||||
|
fontWeight: 600,
|
||||||
|
"&:hover": { color: tokens.upStrong || tokens.up },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
import type { RootState } from "@/store";
|
||||||
|
import type { CheckSnapshot } from "@/Types/Check";
|
||||||
|
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
||||||
|
|
||||||
|
const CELLS = 25;
|
||||||
|
|
||||||
|
export type HeatCellKind = "fast" | "med" | "slow" | "down" | "empty";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
checks: CheckSnapshot[];
|
||||||
|
containerSx: SxProps<Theme>;
|
||||||
|
cellSx: (kind: HeatCellKind) => SxProps<Theme>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const classify = (check: CheckSnapshot): Exclude<HeatCellKind, "empty"> => {
|
||||||
|
if (!check.status) return "down";
|
||||||
|
const rt = check.responseTime ?? 0;
|
||||||
|
if (rt > 500) return "slow";
|
||||||
|
if (rt > 250) return "med";
|
||||||
|
return "fast";
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ThemedHeatmap = ({ checks, containerSx, cellSx }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
|
||||||
|
|
||||||
|
const source = checks.slice(0, CELLS).reverse();
|
||||||
|
const padded: (CheckSnapshot | null)[] = [
|
||||||
|
...Array.from({ length: Math.max(0, CELLS - source.length) }, () => null),
|
||||||
|
...source,
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={containerSx}
|
||||||
|
role="img"
|
||||||
|
aria-label={t("pages.statusPages.monitorsList.chart.heatmapAria")}
|
||||||
|
>
|
||||||
|
{padded.map((check, i) => {
|
||||||
|
if (!check) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
key={`empty-${i}`}
|
||||||
|
sx={cellSx("empty")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const kind = classify(check);
|
||||||
|
const tooltipContent = (
|
||||||
|
<Stack gap={0.25}>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
fontWeight={600}
|
||||||
|
>
|
||||||
|
{check.status
|
||||||
|
? `${check.responseTime} ms`
|
||||||
|
: t("pages.statusPages.monitorsList.chart.downTooltip")}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
>
|
||||||
|
{formatDateWithTz(
|
||||||
|
check.createdAt,
|
||||||
|
"ddd, MMMM D, YYYY, HH:mm A",
|
||||||
|
uiTimezone
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
key={check.id ?? i}
|
||||||
|
title={tooltipContent}
|
||||||
|
arrow
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={cellSx(kind)}
|
||||||
|
aria-label={`${check.responseTime} ms, ${check.status ? "up" : "down"}`}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
import type { RootState } from "@/store";
|
||||||
|
import type { CheckSnapshot } from "@/Types/Check";
|
||||||
|
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
||||||
|
|
||||||
|
const CELLS = 25;
|
||||||
|
const MIN_HEIGHT_PCT = 6;
|
||||||
|
|
||||||
|
export type BarKind = "up" | "down" | "empty";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
checks: CheckSnapshot[];
|
||||||
|
containerSx: SxProps<Theme>;
|
||||||
|
barSx: (kind: BarKind, heightPct: number) => SxProps<Theme>;
|
||||||
|
statsSx: SxProps<Theme>;
|
||||||
|
statsGap?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tone = (check: CheckSnapshot): Exclude<BarKind, "empty"> =>
|
||||||
|
check.status ? "up" : "down";
|
||||||
|
|
||||||
|
export const ThemedHistogram = ({
|
||||||
|
checks,
|
||||||
|
containerSx,
|
||||||
|
barSx,
|
||||||
|
statsSx,
|
||||||
|
statsGap = 1,
|
||||||
|
}: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
|
||||||
|
|
||||||
|
const { padded, max, avg, peak } = useMemo(() => {
|
||||||
|
const source = checks.slice(0, CELLS).reverse();
|
||||||
|
const out: (CheckSnapshot | null)[] = [
|
||||||
|
...Array.from({ length: Math.max(0, CELLS - source.length) }, () => null),
|
||||||
|
...source,
|
||||||
|
];
|
||||||
|
const valid = out.filter((c): c is CheckSnapshot => c !== null && c.responseTime > 0);
|
||||||
|
const maxRt = valid.length ? Math.max(...valid.map((c) => c.responseTime)) : 1;
|
||||||
|
const avgRt = valid.length
|
||||||
|
? Math.round(valid.reduce((s, c) => s + c.responseTime, 0) / valid.length)
|
||||||
|
: 0;
|
||||||
|
return { padded: out, max: maxRt, avg: avgRt, peak: valid.length ? maxRt : 0 };
|
||||||
|
}, [checks]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack gap={statsGap}>
|
||||||
|
<Box sx={containerSx}>
|
||||||
|
{padded.map((check, i) => {
|
||||||
|
if (!check) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
key={`empty-${i}`}
|
||||||
|
sx={barSx("empty", MIN_HEIGHT_PCT)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const height = Math.max(
|
||||||
|
MIN_HEIGHT_PCT,
|
||||||
|
Math.round((check.responseTime / max) * 100)
|
||||||
|
);
|
||||||
|
const tooltipContent = (
|
||||||
|
<Stack gap={0.25}>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
fontWeight={600}
|
||||||
|
>
|
||||||
|
{check.status
|
||||||
|
? `${check.responseTime} ms`
|
||||||
|
: t("pages.statusPages.monitorsList.chart.downTooltip")}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
>
|
||||||
|
{formatDateWithTz(
|
||||||
|
check.createdAt,
|
||||||
|
"ddd, MMMM D, YYYY, HH:mm A",
|
||||||
|
uiTimezone
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
key={check.id ?? i}
|
||||||
|
title={tooltipContent}
|
||||||
|
arrow
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={barSx(tone(check), height)}
|
||||||
|
aria-label={`${check.responseTime} ms`}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
sx={statsSx}
|
||||||
|
>
|
||||||
|
<span>{t("pages.statusPages.monitorsList.chart.avg", { value: avg })}</span>
|
||||||
|
<span>{t("pages.statusPages.monitorsList.chart.max", { value: peak })}</span>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import prettyBytes from "pretty-bytes";
|
||||||
|
import type { SxProps, Theme } from "@mui/material/styles";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
|
||||||
|
export type GaugeFillLevel = "ok" | "warm" | "hot";
|
||||||
|
|
||||||
|
export interface InfraSx {
|
||||||
|
containerSx: SxProps<Theme>;
|
||||||
|
emptySx: SxProps<Theme>;
|
||||||
|
gaugeSx: SxProps<Theme>;
|
||||||
|
gaugeLabelSx: SxProps<Theme>;
|
||||||
|
gaugeValueSx: SxProps<Theme>;
|
||||||
|
gaugeBarSx: SxProps<Theme>;
|
||||||
|
gaugeFillSx: (level: GaugeFillLevel, widthPct: number) => SxProps<Theme>;
|
||||||
|
gaugeSubSx: SxProps<Theme>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
monitor: Monitor & { checks?: Monitor["recentChecks"] };
|
||||||
|
sxApi: InfraSx;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Gauge {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
sub: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PCT = 100;
|
||||||
|
|
||||||
|
const heatLevel = (value: number): GaugeFillLevel =>
|
||||||
|
value > 85 ? "hot" : value > 70 ? "warm" : "ok";
|
||||||
|
|
||||||
|
export const ThemedInfrastructure = ({ monitor, sxApi }: Props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const latest = monitor.recentChecks?.[0] ?? monitor.checks?.[0];
|
||||||
|
|
||||||
|
const renderEmpty = () => (
|
||||||
|
<Box sx={sxApi.emptySx}>{t("pages.statusPages.monitorsList.noData")}</Box>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!latest) return renderEmpty();
|
||||||
|
|
||||||
|
const gauges: Gauge[] = [];
|
||||||
|
|
||||||
|
if (typeof latest.cpu?.usage_percent === "number") {
|
||||||
|
const pct = latest.cpu.usage_percent * PCT;
|
||||||
|
gauges.push({
|
||||||
|
key: "cpu",
|
||||||
|
label: t("pages.statusPages.monitorsList.infrastructure.cpu"),
|
||||||
|
value: pct,
|
||||||
|
sub: `${pct.toFixed(0)}%`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof latest.memory?.usage_percent === "number" &&
|
||||||
|
typeof latest.memory?.used_bytes === "number" &&
|
||||||
|
typeof latest.memory?.total_bytes === "number"
|
||||||
|
) {
|
||||||
|
gauges.push({
|
||||||
|
key: "memory",
|
||||||
|
label: t("pages.statusPages.monitorsList.infrastructure.memory"),
|
||||||
|
value: latest.memory.usage_percent * PCT,
|
||||||
|
sub: `${prettyBytes(latest.memory.used_bytes)} / ${prettyBytes(latest.memory.total_bytes)}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (latest.disk && latest.disk.length > 0) {
|
||||||
|
const disks = latest.disk;
|
||||||
|
const avg =
|
||||||
|
(disks.reduce((acc, d) => acc + (d?.usage_percent ?? 0), 0) / disks.length) * PCT;
|
||||||
|
const used = disks.reduce((acc, d) => acc + (d?.used_bytes ?? 0), 0);
|
||||||
|
const total = disks.reduce((acc, d) => acc + (d?.total_bytes ?? 0), 0);
|
||||||
|
gauges.push({
|
||||||
|
key: "disk",
|
||||||
|
label: t("pages.statusPages.monitorsList.infrastructure.disk"),
|
||||||
|
value: avg,
|
||||||
|
sub: `${prettyBytes(used)} / ${prettyBytes(total)}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gauges.length === 0) return renderEmpty();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={sxApi.containerSx}>
|
||||||
|
{gauges.map((g) => (
|
||||||
|
<Box
|
||||||
|
key={g.key}
|
||||||
|
sx={sxApi.gaugeSx}
|
||||||
|
>
|
||||||
|
<Box sx={sxApi.gaugeLabelSx}>{g.label}</Box>
|
||||||
|
<Box sx={sxApi.gaugeValueSx}>{g.value.toFixed(0)}%</Box>
|
||||||
|
<Box sx={sxApi.gaugeBarSx}>
|
||||||
|
<Box sx={sxApi.gaugeFillSx(heatLevel(g.value), Math.min(100, g.value))} />
|
||||||
|
</Box>
|
||||||
|
<Box sx={sxApi.gaugeSubSx}>{g.sub}</Box>
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export const SANS_STACK =
|
||||||
|
'-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif';
|
||||||
|
|
||||||
|
export const BOLD_SANS_STACK = `ui-sans-serif, ${SANS_STACK}`;
|
||||||
|
|
||||||
|
export const SERIF_STACK = 'Georgia, "Iowan Old Style", "Palatino Linotype", serif';
|
||||||
|
|
||||||
|
export const EDITORIAL_SECONDARY_SANS_STACK =
|
||||||
|
'-apple-system, "Helvetica Neue", Arial, sans-serif';
|
||||||
|
|
||||||
|
export const MONO_STACK = "ui-monospace, Menlo, monospace";
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
import type { ReactNode } from "react";
|
||||||
|
import {
|
||||||
|
AlertTriangle,
|
||||||
|
CircleCheck,
|
||||||
|
CircleX,
|
||||||
|
Loader,
|
||||||
|
PauseCircle,
|
||||||
|
ShieldAlert,
|
||||||
|
Wrench,
|
||||||
|
} from "lucide-react";
|
||||||
|
import type { Monitor, MonitorStatus } from "@/Types/Monitor";
|
||||||
|
import type { StatusPageThemeTokens } from "../tokens";
|
||||||
|
|
||||||
|
export type OverallTone = "up" | "warn" | "down";
|
||||||
|
|
||||||
|
export const toneColor = (tone: OverallTone, t: StatusPageThemeTokens): string =>
|
||||||
|
tone === "down" ? t.down : tone === "warn" ? t.warn : t.up;
|
||||||
|
|
||||||
|
export const toneSoft = (tone: OverallTone, t: StatusPageThemeTokens): string =>
|
||||||
|
tone === "down" ? t.downSoft : tone === "warn" ? t.warnSoft : t.upSoft;
|
||||||
|
|
||||||
|
export interface OverallStatus {
|
||||||
|
tone: OverallTone;
|
||||||
|
message: string;
|
||||||
|
icon: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
type StatusPageMonitor = Pick<Monitor, "status">;
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
iconSize?: number;
|
||||||
|
// Optional override for the `allUp` message key (editorial uses a more
|
||||||
|
// formal sentence).
|
||||||
|
allUpKey?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const resolveOverallStatus = (
|
||||||
|
monitors: StatusPageMonitor[],
|
||||||
|
t: (key: string) => string,
|
||||||
|
options: Options = {}
|
||||||
|
): OverallStatus => {
|
||||||
|
const size = options.iconSize ?? 18;
|
||||||
|
const allUpMessage = t(options.allUpKey ?? "pages.statusPages.statusBar.allUp");
|
||||||
|
|
||||||
|
if (monitors.length === 0) {
|
||||||
|
return {
|
||||||
|
tone: "warn",
|
||||||
|
message: t("pages.statusPages.statusBar.noMonitors"),
|
||||||
|
icon: <CircleX size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const allOf = (...statuses: MonitorStatus[]) =>
|
||||||
|
monitors.every((m) => statuses.includes(m.status));
|
||||||
|
const someOf = (...statuses: MonitorStatus[]) =>
|
||||||
|
monitors.some((m) => statuses.includes(m.status));
|
||||||
|
const noneOf = (...statuses: MonitorStatus[]) =>
|
||||||
|
monitors.every((m) => !statuses.includes(m.status));
|
||||||
|
|
||||||
|
if (allOf("up")) {
|
||||||
|
return { tone: "up", message: allUpMessage, icon: <CircleCheck size={size} /> };
|
||||||
|
}
|
||||||
|
if (allOf("breached")) {
|
||||||
|
return {
|
||||||
|
tone: "down",
|
||||||
|
message: t("pages.statusPages.statusBar.allBreached"),
|
||||||
|
icon: <ShieldAlert size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (allOf("maintenance")) {
|
||||||
|
return {
|
||||||
|
tone: "warn",
|
||||||
|
message: t("pages.statusPages.statusBar.allMaintenance"),
|
||||||
|
icon: <Wrench size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (allOf("down")) {
|
||||||
|
return {
|
||||||
|
tone: "down",
|
||||||
|
message: t("pages.statusPages.statusBar.allDown"),
|
||||||
|
icon: <CircleX size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (allOf("paused")) {
|
||||||
|
return {
|
||||||
|
tone: "warn",
|
||||||
|
message: t("pages.statusPages.statusBar.allPaused"),
|
||||||
|
icon: <PauseCircle size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (allOf("initializing")) {
|
||||||
|
return {
|
||||||
|
tone: "warn",
|
||||||
|
message: t("pages.statusPages.statusBar.allInitializing"),
|
||||||
|
icon: <Loader size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (someOf("breached") && someOf("down")) {
|
||||||
|
return {
|
||||||
|
tone: "down",
|
||||||
|
message: t("pages.statusPages.statusBar.breachedAndDown"),
|
||||||
|
icon: <ShieldAlert size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (someOf("breached")) {
|
||||||
|
return {
|
||||||
|
tone: "down",
|
||||||
|
message: t("pages.statusPages.statusBar.breached"),
|
||||||
|
icon: <ShieldAlert size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (someOf("maintenance") && someOf("down")) {
|
||||||
|
return {
|
||||||
|
tone: "down",
|
||||||
|
message: t("pages.statusPages.statusBar.maintenanceAndDown"),
|
||||||
|
icon: <Wrench size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (someOf("maintenance") && noneOf("down")) {
|
||||||
|
return {
|
||||||
|
tone: "warn",
|
||||||
|
message: t("pages.statusPages.statusBar.maintenance"),
|
||||||
|
icon: <Wrench size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (someOf("down")) {
|
||||||
|
return {
|
||||||
|
tone: "warn",
|
||||||
|
message: t("pages.statusPages.statusBar.degraded"),
|
||||||
|
icon: <AlertTriangle size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (someOf("paused")) {
|
||||||
|
return {
|
||||||
|
tone: "warn",
|
||||||
|
message: t("pages.statusPages.statusBar.partiallyPaused"),
|
||||||
|
icon: <PauseCircle size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (someOf("initializing")) {
|
||||||
|
return {
|
||||||
|
tone: "up",
|
||||||
|
message: t("pages.statusPages.statusBar.initializing"),
|
||||||
|
icon: <Loader size={size} />,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
tone: "warn",
|
||||||
|
message: t("pages.statusPages.statusBar.unknown"),
|
||||||
|
icon: <AlertTriangle size={size} />,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const statusBadgeKey: Record<MonitorStatus, string> = {
|
||||||
|
up: "pages.statusPages.monitorsList.status.up",
|
||||||
|
down: "pages.statusPages.monitorsList.status.down",
|
||||||
|
breached: "pages.statusPages.monitorsList.status.breached",
|
||||||
|
maintenance: "pages.statusPages.monitorsList.status.maintenance",
|
||||||
|
paused: "pages.statusPages.monitorsList.status.paused",
|
||||||
|
initializing: "pages.statusPages.monitorsList.status.initializing",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const monoFirstChar = (s?: string): string =>
|
||||||
|
(s?.trim().charAt(0) || "?").toUpperCase();
|
||||||
|
|
||||||
|
export const monitorBadgeTone = (status: MonitorStatus): OverallTone =>
|
||||||
|
status === "up" ? "up" : status === "down" || status === "breached" ? "down" : "warn";
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
import type { StatusPageTheme } from "@/Types/StatusPage";
|
||||||
|
|
||||||
|
export interface StatusPageThemeTokens {
|
||||||
|
bg: string;
|
||||||
|
surface: string;
|
||||||
|
border: string;
|
||||||
|
text: string;
|
||||||
|
textMuted: string;
|
||||||
|
up: string;
|
||||||
|
upStrong: string;
|
||||||
|
upSoft: string;
|
||||||
|
degraded: string;
|
||||||
|
degradedSoft: string;
|
||||||
|
down: string;
|
||||||
|
downSoft: string;
|
||||||
|
warn: string;
|
||||||
|
warnSoft: string;
|
||||||
|
radius: string;
|
||||||
|
fontFamily?: string;
|
||||||
|
headingFontFamily?: string;
|
||||||
|
headingWeight?: number;
|
||||||
|
headingLetterSpacing?: string;
|
||||||
|
chartBarRadius?: string;
|
||||||
|
pulseStatusDot?: boolean;
|
||||||
|
staggeredCardFadeIn?: boolean;
|
||||||
|
conicLogo?: boolean;
|
||||||
|
heroSize?: "default" | "large";
|
||||||
|
cardStyle?: "card" | "hairline";
|
||||||
|
}
|
||||||
|
|
||||||
|
type ThemeVariants = { light: StatusPageThemeTokens; dark: StatusPageThemeTokens };
|
||||||
|
|
||||||
|
const refined: ThemeVariants = {
|
||||||
|
light: {
|
||||||
|
bg: "#f4f6fa",
|
||||||
|
surface: "#ffffff",
|
||||||
|
border: "#dce1ea",
|
||||||
|
text: "#0a1020",
|
||||||
|
textMuted: "#4b5768",
|
||||||
|
up: "#0f8a6d",
|
||||||
|
upStrong: "#0c7359",
|
||||||
|
upSoft: "#d6f1e6",
|
||||||
|
degraded: "#c2630a",
|
||||||
|
degradedSoft: "#fde7bf",
|
||||||
|
down: "#d11f2f",
|
||||||
|
downSoft: "#fdd9dc",
|
||||||
|
warn: "#e08a0b",
|
||||||
|
warnSoft: "#fdebc5",
|
||||||
|
radius: "12px",
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
bg: "#070b11",
|
||||||
|
surface: "#131a24",
|
||||||
|
border: "#253142",
|
||||||
|
text: "#f1f5fb",
|
||||||
|
textMuted: "#9aa7bd",
|
||||||
|
up: "#2fd7a2",
|
||||||
|
upStrong: "#1fb487",
|
||||||
|
upSoft: "rgba(47,215,162,0.15)",
|
||||||
|
degraded: "#e69138",
|
||||||
|
degradedSoft: "rgba(230,145,56,0.18)",
|
||||||
|
down: "#ff5b6b",
|
||||||
|
downSoft: "rgba(255,91,107,0.18)",
|
||||||
|
warn: "#f0a837",
|
||||||
|
warnSoft: "rgba(240,168,55,0.18)",
|
||||||
|
radius: "12px",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const modern: ThemeVariants = {
|
||||||
|
light: {
|
||||||
|
bg: "#fafbfc",
|
||||||
|
surface: "#ffffff",
|
||||||
|
border: "#eceef2",
|
||||||
|
text: "#0b1220",
|
||||||
|
textMuted: "#6b7280",
|
||||||
|
up: "#10a37f",
|
||||||
|
upStrong: "#0b8a6a",
|
||||||
|
upSoft: "#d7f3e9",
|
||||||
|
degraded: "#d97706",
|
||||||
|
degradedSoft: "#fef3c7",
|
||||||
|
down: "#dc2626",
|
||||||
|
downSoft: "#fee2e2",
|
||||||
|
warn: "#f59e0b",
|
||||||
|
warnSoft: "#fef3c7",
|
||||||
|
radius: "16px",
|
||||||
|
pulseStatusDot: true,
|
||||||
|
staggeredCardFadeIn: true,
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
bg: "#0a0d12",
|
||||||
|
surface: "#10151c",
|
||||||
|
border: "#1b2430",
|
||||||
|
text: "#e8edf5",
|
||||||
|
textMuted: "#8a95a8",
|
||||||
|
up: "#10a37f",
|
||||||
|
upStrong: "#0b8a6a",
|
||||||
|
upSoft: "rgba(16,163,127,0.18)",
|
||||||
|
degraded: "#d97706",
|
||||||
|
degradedSoft: "rgba(217,119,6,0.22)",
|
||||||
|
down: "#dc2626",
|
||||||
|
downSoft: "rgba(220,38,38,0.22)",
|
||||||
|
warn: "#f59e0b",
|
||||||
|
warnSoft: "rgba(245,158,11,0.2)",
|
||||||
|
radius: "16px",
|
||||||
|
pulseStatusDot: true,
|
||||||
|
staggeredCardFadeIn: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const bold: ThemeVariants = {
|
||||||
|
light: {
|
||||||
|
bg: "#f5f6f9",
|
||||||
|
surface: "#ffffff",
|
||||||
|
border: "#e6e8ee",
|
||||||
|
text: "#0b1220",
|
||||||
|
textMuted: "#6b7280",
|
||||||
|
up: "#10a37f",
|
||||||
|
upStrong: "#0b8a6a",
|
||||||
|
upSoft: "rgba(16,163,127,0.12)",
|
||||||
|
degraded: "#f59e0b",
|
||||||
|
degradedSoft: "rgba(245,158,11,0.14)",
|
||||||
|
down: "#f43f5e",
|
||||||
|
downSoft: "rgba(244,63,94,0.12)",
|
||||||
|
warn: "#f59e0b",
|
||||||
|
warnSoft: "rgba(245,158,11,0.14)",
|
||||||
|
radius: "18px",
|
||||||
|
heroSize: "large",
|
||||||
|
conicLogo: true,
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
bg: "#05070a",
|
||||||
|
surface: "#0c1117",
|
||||||
|
border: "#1a2330",
|
||||||
|
text: "#eef2f7",
|
||||||
|
textMuted: "#7a8699",
|
||||||
|
up: "#22d3a6",
|
||||||
|
upStrong: "#10a37f",
|
||||||
|
upSoft: "rgba(34,211,166,0.14)",
|
||||||
|
degraded: "#f59e0b",
|
||||||
|
degradedSoft: "rgba(245,158,11,0.14)",
|
||||||
|
down: "#f43f5e",
|
||||||
|
downSoft: "rgba(244,63,94,0.16)",
|
||||||
|
warn: "#f59e0b",
|
||||||
|
warnSoft: "rgba(245,158,11,0.14)",
|
||||||
|
radius: "18px",
|
||||||
|
heroSize: "large",
|
||||||
|
conicLogo: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const editorial: ThemeVariants = {
|
||||||
|
light: {
|
||||||
|
bg: "#fbfaf7",
|
||||||
|
surface: "#ffffff",
|
||||||
|
// Darkened from mockup's #e9e4d8 (~1.3:1 on #fbfaf7) to pass WCAG AA 3:1 for UI borders.
|
||||||
|
border: "#d4cdb8",
|
||||||
|
text: "#1a1a1a",
|
||||||
|
textMuted: "#6b675e",
|
||||||
|
up: "#2c6a4f",
|
||||||
|
upStrong: "#205239",
|
||||||
|
upSoft: "#dfeee4",
|
||||||
|
degraded: "#a46200",
|
||||||
|
degradedSoft: "#f7ecd4",
|
||||||
|
down: "#9a2a2a",
|
||||||
|
downSoft: "#f5dede",
|
||||||
|
warn: "#a46200",
|
||||||
|
warnSoft: "#f7ecd4",
|
||||||
|
radius: "6px",
|
||||||
|
headingFontFamily: 'Georgia, "Iowan Old Style", "Palatino Linotype", serif',
|
||||||
|
cardStyle: "hairline",
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
bg: "#141310",
|
||||||
|
surface: "#1c1a15",
|
||||||
|
border: "#3a352b",
|
||||||
|
text: "#f0ece3",
|
||||||
|
textMuted: "#9e988a",
|
||||||
|
up: "#6fbf96",
|
||||||
|
upStrong: "#4fa37a",
|
||||||
|
upSoft: "rgba(44,106,79,0.22)",
|
||||||
|
degraded: "#d79a3b",
|
||||||
|
degradedSoft: "rgba(164,98,0,0.22)",
|
||||||
|
down: "#d87a7a",
|
||||||
|
downSoft: "rgba(154,42,42,0.22)",
|
||||||
|
warn: "#d79a3b",
|
||||||
|
warnSoft: "rgba(164,98,0,0.22)",
|
||||||
|
radius: "6px",
|
||||||
|
headingFontFamily: 'Georgia, "Iowan Old Style", "Palatino Linotype", serif',
|
||||||
|
cardStyle: "hairline",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const themeTokens: Record<StatusPageTheme, ThemeVariants> = {
|
||||||
|
refined,
|
||||||
|
modern,
|
||||||
|
bold,
|
||||||
|
editorial,
|
||||||
|
};
|
||||||
@@ -11,7 +11,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import type { StatusPage } from "@/Types/StatusPage";
|
import { PUBLIC_STATUS_PAGE_PREFIX, type StatusPage } from "@/Types/StatusPage";
|
||||||
|
|
||||||
interface StatusPagesTableProps {
|
interface StatusPagesTableProps {
|
||||||
data: StatusPage[];
|
data: StatusPage[];
|
||||||
@@ -53,7 +53,7 @@ export const StatusPagesTable = ({
|
|||||||
const handleUrlClick = (e: React.MouseEvent, row: StatusPage) => {
|
const handleUrlClick = (e: React.MouseEvent, row: StatusPage) => {
|
||||||
if (row.isPublished) {
|
if (row.isPublished) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const url = `/status/public/${row.url}`;
|
const url = `${PUBLIC_STATUS_PAGE_PREFIX}/${row.url}`;
|
||||||
window.open(url, "_blank", "noopener,noreferrer");
|
window.open(url, "_blank", "noopener,noreferrer");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,6 +21,25 @@ export const getMonitorTypeLabel = (
|
|||||||
return key ? t(key) : type;
|
return key ? t(key) : type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const STATUS_PAGE_THEMES = ["refined", "modern", "bold", "editorial"] as const;
|
||||||
|
export type StatusPageTheme = (typeof STATUS_PAGE_THEMES)[number];
|
||||||
|
export const DEFAULT_STATUS_PAGE_THEME: StatusPageTheme = "refined";
|
||||||
|
|
||||||
|
export const STATUS_PAGE_THEME_MODES = ["auto", "light", "dark"] as const;
|
||||||
|
export type StatusPageThemeMode = (typeof STATUS_PAGE_THEME_MODES)[number];
|
||||||
|
export const DEFAULT_STATUS_PAGE_THEME_MODE: StatusPageThemeMode = "auto";
|
||||||
|
|
||||||
|
export const resolveStatusPageTheme = (
|
||||||
|
value: string | null | undefined
|
||||||
|
): StatusPageTheme =>
|
||||||
|
STATUS_PAGE_THEMES.find((t) => t === value) ?? DEFAULT_STATUS_PAGE_THEME;
|
||||||
|
|
||||||
|
export const resolveStatusPageThemeMode = (
|
||||||
|
value: string | null | undefined
|
||||||
|
): StatusPageThemeMode =>
|
||||||
|
STATUS_PAGE_THEME_MODES.find((m) => m === value) ?? DEFAULT_STATUS_PAGE_THEME_MODE;
|
||||||
|
export const PUBLIC_STATUS_PAGE_PREFIX = "/status/public";
|
||||||
|
|
||||||
export interface StatusPage {
|
export interface StatusPage {
|
||||||
id: string;
|
id: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
@@ -43,6 +62,8 @@ export interface StatusPage {
|
|||||||
showAdminLoginLink: boolean;
|
showAdminLoginLink: boolean;
|
||||||
showInfrastructure: boolean;
|
showInfrastructure: boolean;
|
||||||
customCSS: string;
|
customCSS: string;
|
||||||
|
theme: StatusPageTheme;
|
||||||
|
themeMode: StatusPageThemeMode;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import { STATUS_PAGE_THEMES, STATUS_PAGE_THEME_MODES } from "@/Types/StatusPage";
|
||||||
|
|
||||||
export const statusPageSchema = z.object({
|
export const statusPageSchema = z.object({
|
||||||
companyName: z
|
companyName: z
|
||||||
@@ -25,6 +26,8 @@ export const statusPageSchema = z.object({
|
|||||||
showAdminLoginLink: z.boolean(),
|
showAdminLoginLink: z.boolean(),
|
||||||
showInfrastructure: z.boolean(),
|
showInfrastructure: z.boolean(),
|
||||||
customCSS: z.string().optional(),
|
customCSS: z.string().optional(),
|
||||||
|
theme: z.enum(STATUS_PAGE_THEMES).optional(),
|
||||||
|
themeMode: z.enum(STATUS_PAGE_THEME_MODES).optional(),
|
||||||
logo: z
|
logo: z
|
||||||
.object({
|
.object({
|
||||||
data: z.string(),
|
data: z.string(),
|
||||||
|
|||||||
@@ -1276,6 +1276,20 @@
|
|||||||
"chartTypeHeatmap": "Heatmap",
|
"chartTypeHeatmap": "Heatmap",
|
||||||
"chartTypeHistogram": "Histogram",
|
"chartTypeHistogram": "Histogram",
|
||||||
"noData": "No data available",
|
"noData": "No data available",
|
||||||
|
"status": {
|
||||||
|
"up": "Operational",
|
||||||
|
"down": "Down",
|
||||||
|
"breached": "Threshold exceeded",
|
||||||
|
"maintenance": "Maintenance",
|
||||||
|
"paused": "Paused",
|
||||||
|
"initializing": "Initializing"
|
||||||
|
},
|
||||||
|
"chart": {
|
||||||
|
"avg": "avg {{value}}ms",
|
||||||
|
"max": "max {{value}}ms",
|
||||||
|
"downTooltip": "Down",
|
||||||
|
"heatmapAria": "Response time heatmap"
|
||||||
|
},
|
||||||
"infrastructure": {
|
"infrastructure": {
|
||||||
"title": "Infrastructure",
|
"title": "Infrastructure",
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
@@ -1292,6 +1306,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"statusBar": {
|
"statusBar": {
|
||||||
|
"monitoringSummary": "Monitoring {{count}} service · Updates every 10 seconds",
|
||||||
|
"monitoringSummary_other": "Monitoring {{count}} services · Updates every 10 seconds",
|
||||||
"allUp": "All systems operational",
|
"allUp": "All systems operational",
|
||||||
"allBreached": "All systems have exceeded thresholds",
|
"allBreached": "All systems have exceeded thresholds",
|
||||||
"allMaintenance": "All systems are under maintenance",
|
"allMaintenance": "All systems are under maintenance",
|
||||||
@@ -1323,6 +1339,13 @@
|
|||||||
"addMonitor": "Add a monitor to get started"
|
"addMonitor": "Add a monitor to get started"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"footer": {
|
||||||
|
"poweredBy": "Powered by"
|
||||||
|
},
|
||||||
|
"editorial": {
|
||||||
|
"reportTitle": "Service Report",
|
||||||
|
"allUp": "All systems are operating normally."
|
||||||
|
},
|
||||||
"form": {
|
"form": {
|
||||||
"access": {
|
"access": {
|
||||||
"title": "Access",
|
"title": "Access",
|
||||||
@@ -1380,6 +1403,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"theme": {
|
||||||
|
"title": "Page theme",
|
||||||
|
"description": "Choose the visual style for your public status page.",
|
||||||
|
"label": "Theme",
|
||||||
|
"options": {
|
||||||
|
"refined": {
|
||||||
|
"name": "Refined",
|
||||||
|
"description": "Clean, professional, close to the classic Checkmate look."
|
||||||
|
},
|
||||||
|
"modern": {
|
||||||
|
"name": "Modern",
|
||||||
|
"description": "SaaS-grade with a pulsing status dot and softly fading cards."
|
||||||
|
},
|
||||||
|
"bold": {
|
||||||
|
"name": "Bold",
|
||||||
|
"description": "Large type and confident spacing. Great for brand-forward pages."
|
||||||
|
},
|
||||||
|
"editorial": {
|
||||||
|
"name": "Editorial",
|
||||||
|
"description": "Serif headings and hairline dividers. Distinctive and calm."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"themeMode": {
|
||||||
|
"label": "Theme mode",
|
||||||
|
"auto": "Auto (follow visitor's device)",
|
||||||
|
"light": "Light only",
|
||||||
|
"dark": "Dark only"
|
||||||
|
},
|
||||||
"features": {
|
"features": {
|
||||||
"title": "Features",
|
"title": "Features",
|
||||||
"description": "Configure what information is displayed on your status page.",
|
"description": "Configure what information is displayed on your status page.",
|
||||||
|
|||||||
@@ -24,3 +24,9 @@ CLIENT_HOST=http://localhost:5173
|
|||||||
# Optional Configuration
|
# Optional Configuration
|
||||||
# ----------------------
|
# ----------------------
|
||||||
ORIGIN=localhost
|
ORIGIN=localhost
|
||||||
|
|
||||||
|
# Feature Flags
|
||||||
|
# -------------
|
||||||
|
# Set to "false" to disable the selectable theme feature on status pages.
|
||||||
|
# When disabled, all status pages render with the default "refined" theme.
|
||||||
|
STATUS_PAGE_THEMES_ENABLED=true
|
||||||
@@ -2878,6 +2878,12 @@
|
|||||||
"url": {
|
"url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Custom URL for the status page"
|
"description": "Custom URL for the status page"
|
||||||
|
},
|
||||||
|
"theme": {
|
||||||
|
"$ref": "#/components/schemas/StatusPageTheme"
|
||||||
|
},
|
||||||
|
"themeMode": {
|
||||||
|
"$ref": "#/components/schemas/StatusPageThemeMode"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2930,6 +2936,12 @@
|
|||||||
"url": {
|
"url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Custom URL for the status page"
|
"description": "Custom URL for the status page"
|
||||||
|
},
|
||||||
|
"theme": {
|
||||||
|
"$ref": "#/components/schemas/StatusPageTheme"
|
||||||
|
},
|
||||||
|
"themeMode": {
|
||||||
|
"$ref": "#/components/schemas/StatusPageThemeMode"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3410,6 +3422,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemas": {
|
"schemas": {
|
||||||
|
"StatusPageTheme": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["refined", "modern", "bold", "editorial"],
|
||||||
|
"description": "Visual theme for the public status page. Defaults to 'refined'."
|
||||||
|
},
|
||||||
|
"StatusPageThemeMode": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["auto", "light", "dark"],
|
||||||
|
"description": "Forces a light/dark mode on the public page. 'auto' follows the visitor's OS preference. Defaults to 'auto'."
|
||||||
|
},
|
||||||
"SuccessResponse": {
|
"SuccessResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["success", "msg"],
|
"required": ["success", "msg"],
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ export const initializeServices = async ({
|
|||||||
incidentsRepository,
|
incidentsRepository,
|
||||||
});
|
});
|
||||||
|
|
||||||
const statusPageService = new StatusPageService(statusPagesRepository);
|
const statusPageService = new StatusPageService(statusPagesRepository, settingsService);
|
||||||
|
|
||||||
const services = {
|
const services = {
|
||||||
settingsService,
|
settingsService,
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class StatusPageController implements IStatusPageController {
|
|||||||
if (req.file) {
|
if (req.file) {
|
||||||
imageValidation.parse(req.file);
|
imageValidation.parse(req.file);
|
||||||
}
|
}
|
||||||
|
|
||||||
const teamId = requireTeamId(req?.user?.teamId);
|
const teamId = requireTeamId(req?.user?.teamId);
|
||||||
const statusPageId = req.params.id as string;
|
const statusPageId = req.params.id as string;
|
||||||
if (!statusPageId) {
|
if (!statusPageId) {
|
||||||
@@ -127,7 +128,10 @@ class StatusPageController implements IStatusPageController {
|
|||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: "Status page retrieved successfully",
|
msg: "Status page retrieved successfully",
|
||||||
data: { statusPage, monitors: normalizedMonitors },
|
data: {
|
||||||
|
statusPage,
|
||||||
|
monitors: normalizedMonitors,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Schema, model, type Types } from "mongoose";
|
import { Schema, model, type Types } from "mongoose";
|
||||||
import type { StatusPage, StatusPageLogoDocument } from "@/types/statusPage.js";
|
import type { StatusPage, StatusPageLogoDocument } from "@/types/statusPage.js";
|
||||||
import { StatusPageTypes } from "@/types/statusPage.js";
|
import { StatusPageTypes, StatusPageThemes, StatusPageThemeModes } from "@/types/statusPage.js";
|
||||||
|
|
||||||
type StatusPageDocumentBase = Omit<
|
type StatusPageDocumentBase = Omit<
|
||||||
StatusPage,
|
StatusPage,
|
||||||
@@ -108,6 +108,16 @@ const StatusPageSchema = new Schema<StatusPageDocument>(
|
|||||||
type: String,
|
type: String,
|
||||||
default: "",
|
default: "",
|
||||||
},
|
},
|
||||||
|
theme: {
|
||||||
|
type: String,
|
||||||
|
enum: StatusPageThemes,
|
||||||
|
default: "refined",
|
||||||
|
},
|
||||||
|
themeMode: {
|
||||||
|
type: String,
|
||||||
|
enum: StatusPageThemeModes,
|
||||||
|
default: "auto",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ class MongoStatusPagesRepository implements IStatusPagesRepository {
|
|||||||
showAdminLoginLink: doc.showAdminLoginLink,
|
showAdminLoginLink: doc.showAdminLoginLink,
|
||||||
showInfrastructure: doc.showInfrastructure,
|
showInfrastructure: doc.showInfrastructure,
|
||||||
customCSS: doc.customCSS,
|
customCSS: doc.customCSS,
|
||||||
|
theme: doc.theme,
|
||||||
|
themeMode: doc.themeMode,
|
||||||
createdAt: this.toDateString(doc.createdAt),
|
createdAt: this.toDateString(doc.createdAt),
|
||||||
updatedAt: this.toDateString(doc.updatedAt),
|
updatedAt: this.toDateString(doc.updatedAt),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { type IStatusPagesRepository } from "@/repositories/index.js";
|
import { type IStatusPagesRepository } from "@/repositories/index.js";
|
||||||
import { StatusPage } from "@/types/index.js";
|
import { ISettingsService } from "@/service/system/settingsService.js";
|
||||||
|
import { DEFAULT_STATUS_PAGE_THEME, DEFAULT_STATUS_PAGE_THEME_MODE, StatusPage } from "@/types/index.js";
|
||||||
|
|
||||||
export interface IStatusPageService {
|
export interface IStatusPageService {
|
||||||
createStatusPage(userId: string, teamId: string, image: Express.Multer.File | undefined, data: Partial<StatusPage>): Promise<StatusPage>;
|
createStatusPage(userId: string, teamId: string, image: Express.Multer.File | undefined, data: Partial<StatusPage>): Promise<StatusPage>;
|
||||||
getStatusPageByUrl(url: string): Promise<StatusPage>;
|
getStatusPageByUrl(url: string): Promise<StatusPage>;
|
||||||
@@ -11,29 +13,52 @@ export interface IStatusPageService {
|
|||||||
|
|
||||||
export class StatusPageService implements IStatusPageService {
|
export class StatusPageService implements IStatusPageService {
|
||||||
private statusPagesRepository: IStatusPagesRepository;
|
private statusPagesRepository: IStatusPagesRepository;
|
||||||
constructor(statusPagesRepository: IStatusPagesRepository) {
|
private settingsService: ISettingsService;
|
||||||
|
constructor(statusPagesRepository: IStatusPagesRepository, settingsService: ISettingsService) {
|
||||||
this.statusPagesRepository = statusPagesRepository;
|
this.statusPagesRepository = statusPagesRepository;
|
||||||
|
this.settingsService = settingsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private withoutThemeFields = (data: Partial<StatusPage>): Partial<StatusPage> => {
|
||||||
|
const { theme: _theme, themeMode: _themeMode, ...rest } = data;
|
||||||
|
return rest;
|
||||||
|
};
|
||||||
|
|
||||||
|
private applyDefaultTheme = (statusPage: StatusPage): StatusPage => ({
|
||||||
|
...statusPage,
|
||||||
|
theme: DEFAULT_STATUS_PAGE_THEME,
|
||||||
|
themeMode: DEFAULT_STATUS_PAGE_THEME_MODE,
|
||||||
|
});
|
||||||
|
|
||||||
|
private normalizeTheme = (statusPage: StatusPage): StatusPage =>
|
||||||
|
this.settingsService.areStatusPageThemesEnabled() ? statusPage : this.applyDefaultTheme(statusPage);
|
||||||
|
|
||||||
|
private normalizeInput = (data: Partial<StatusPage>): Partial<StatusPage> =>
|
||||||
|
this.settingsService.areStatusPageThemesEnabled() ? data : this.withoutThemeFields(data);
|
||||||
|
|
||||||
createStatusPage = async (
|
createStatusPage = async (
|
||||||
userId: string,
|
userId: string,
|
||||||
teamId: string,
|
teamId: string,
|
||||||
image: Express.Multer.File | undefined,
|
image: Express.Multer.File | undefined,
|
||||||
data: Partial<StatusPage>
|
data: Partial<StatusPage>
|
||||||
): Promise<StatusPage> => {
|
): Promise<StatusPage> => {
|
||||||
return await this.statusPagesRepository.create(userId, teamId, image, data);
|
const created = await this.statusPagesRepository.create(userId, teamId, image, this.normalizeInput(data));
|
||||||
|
return this.normalizeTheme(created);
|
||||||
};
|
};
|
||||||
|
|
||||||
getStatusPageByUrl = async (url: string): Promise<StatusPage> => {
|
getStatusPageByUrl = async (url: string): Promise<StatusPage> => {
|
||||||
return await this.statusPagesRepository.findByUrl(url);
|
const statusPage = await this.statusPagesRepository.findByUrl(url);
|
||||||
|
return this.normalizeTheme(statusPage);
|
||||||
};
|
};
|
||||||
|
|
||||||
getStatusPagesByTeamId = async (teamId: string): Promise<StatusPage[]> => {
|
getStatusPagesByTeamId = async (teamId: string): Promise<StatusPage[]> => {
|
||||||
return await this.statusPagesRepository.findByTeamId(teamId);
|
const statusPages = await this.statusPagesRepository.findByTeamId(teamId);
|
||||||
|
return statusPages.map((sp) => this.normalizeTheme(sp));
|
||||||
};
|
};
|
||||||
|
|
||||||
updateStatusPage = async (id: string, teamId: string, image: Express.Multer.File | undefined, data: Partial<StatusPage>): Promise<StatusPage> => {
|
updateStatusPage = async (id: string, teamId: string, image: Express.Multer.File | undefined, data: Partial<StatusPage>): Promise<StatusPage> => {
|
||||||
return await this.statusPagesRepository.updateById(id, teamId, image, data);
|
const updated = await this.statusPagesRepository.updateById(id, teamId, image, this.normalizeInput(data));
|
||||||
|
return this.normalizeTheme(updated);
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteStatusPage = async (statusPageId: string, teamId: string): Promise<StatusPage> => {
|
deleteStatusPage = async (statusPageId: string, teamId: string): Promise<StatusPage> => {
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ export type EnvConfig = {
|
|||||||
clientHost: string;
|
clientHost: string;
|
||||||
dbConnectionString: string;
|
dbConnectionString: string;
|
||||||
dbType: DbType;
|
dbType: DbType;
|
||||||
|
statusPageThemesEnabled: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ISettingsService {
|
export interface ISettingsService {
|
||||||
readonly serviceName: string;
|
readonly serviceName: string;
|
||||||
loadSettings(): EnvConfig;
|
loadSettings(): EnvConfig;
|
||||||
getSettings(): EnvConfig;
|
getSettings(): EnvConfig;
|
||||||
|
areStatusPageThemesEnabled(): boolean;
|
||||||
getDBSettings(): Promise<Settings>;
|
getDBSettings(): Promise<Settings>;
|
||||||
updateDbSettings(newSettings: SettingsUpdate): Promise<Settings>;
|
updateDbSettings(newSettings: SettingsUpdate): Promise<Settings>;
|
||||||
}
|
}
|
||||||
@@ -37,6 +39,7 @@ export class SettingsService implements ISettingsService {
|
|||||||
clientHost: env.CLIENT_HOST,
|
clientHost: env.CLIENT_HOST,
|
||||||
dbConnectionString: env.DB_CONNECTION_STRING,
|
dbConnectionString: env.DB_CONNECTION_STRING,
|
||||||
dbType: env.DB_TYPE,
|
dbType: env.DB_TYPE,
|
||||||
|
statusPageThemesEnabled: env.STATUS_PAGE_THEMES_ENABLED,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +59,10 @@ export class SettingsService implements ISettingsService {
|
|||||||
return this.settings;
|
return this.settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
areStatusPageThemesEnabled() {
|
||||||
|
return this.settings.statusPageThemesEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
private getRepository(): ISettingsRepository {
|
private getRepository(): ISettingsRepository {
|
||||||
if (!this.settingsRepository) {
|
if (!this.settingsRepository) {
|
||||||
throw new AppError({
|
throw new AppError({
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
export const StatusPageTypes = ["uptime", "infrastructure"] as const;
|
export const StatusPageTypes = ["uptime", "infrastructure"] as const;
|
||||||
export type StatusPageType = (typeof StatusPageTypes)[number];
|
export type StatusPageType = (typeof StatusPageTypes)[number];
|
||||||
|
|
||||||
|
export const StatusPageThemes = ["refined", "modern", "bold", "editorial"] as const;
|
||||||
|
export type StatusPageTheme = (typeof StatusPageThemes)[number];
|
||||||
|
export const DEFAULT_STATUS_PAGE_THEME: StatusPageTheme = "refined";
|
||||||
|
|
||||||
|
export const StatusPageThemeModes = ["auto", "light", "dark"] as const;
|
||||||
|
export type StatusPageThemeMode = (typeof StatusPageThemeModes)[number];
|
||||||
|
export const DEFAULT_STATUS_PAGE_THEME_MODE: StatusPageThemeMode = "auto";
|
||||||
|
|
||||||
export interface StatusPageLogo {
|
export interface StatusPageLogo {
|
||||||
data: string;
|
data: string;
|
||||||
contentType: string;
|
contentType: string;
|
||||||
@@ -30,6 +38,8 @@ export interface StatusPage {
|
|||||||
showAdminLoginLink: boolean;
|
showAdminLoginLink: boolean;
|
||||||
showInfrastructure: boolean;
|
showInfrastructure: boolean;
|
||||||
customCSS: string;
|
customCSS: string;
|
||||||
|
theme: StatusPageTheme;
|
||||||
|
themeMode: StatusPageThemeMode;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { DbTypes } from "@/types/settings.js";
|
import { DbTypes } from "@/types/settings.js";
|
||||||
|
import { booleanCoercion } from "./shared.js";
|
||||||
|
|
||||||
const envSchema = z.object({
|
const envSchema = z.object({
|
||||||
// Server Configuration
|
// Server Configuration
|
||||||
@@ -20,6 +21,9 @@ const envSchema = z.object({
|
|||||||
|
|
||||||
// Optional
|
// Optional
|
||||||
ORIGIN: z.string().optional(),
|
ORIGIN: z.string().optional(),
|
||||||
|
|
||||||
|
// Feature flags
|
||||||
|
STATUS_PAGE_THEMES_ENABLED: booleanCoercion.default(true),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type ValidatedEnv = z.infer<typeof envSchema>;
|
export type ValidatedEnv = z.infer<typeof envSchema>;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { booleanCoercion } from "./shared.js";
|
import { booleanCoercion } from "./shared.js";
|
||||||
import { StatusPageTypes } from "@/types/statusPage.js";
|
import { StatusPageTypes, StatusPageThemes, StatusPageThemeModes } from "@/types/statusPage.js";
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
// Status Page Validations
|
// Status Page Validations
|
||||||
@@ -33,6 +33,8 @@ export const createStatusPageBodyValidation = z
|
|||||||
showAdminLoginLink: booleanCoercion.optional(),
|
showAdminLoginLink: booleanCoercion.optional(),
|
||||||
showInfrastructure: booleanCoercion.optional(),
|
showInfrastructure: booleanCoercion.optional(),
|
||||||
removeLogo: z.union([z.literal("true"), z.literal("false")]).optional(),
|
removeLogo: z.union([z.literal("true"), z.literal("false")]).optional(),
|
||||||
|
theme: z.enum(StatusPageThemes).optional(),
|
||||||
|
themeMode: z.enum(StatusPageThemeModes).optional(),
|
||||||
})
|
})
|
||||||
.strip();
|
.strip();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { describe, expect, it, jest } from "@jest/globals";
|
import { describe, expect, it, jest } from "@jest/globals";
|
||||||
import { StatusPageService } from "../../../src/service/business/statusPageService.ts";
|
import { StatusPageService } from "../../../src/service/business/statusPageService.ts";
|
||||||
import type { IStatusPagesRepository } from "../../../src/repositories/status-pages/IStatusPagesRepository.ts";
|
import type { IStatusPagesRepository } from "../../../src/repositories/status-pages/IStatusPagesRepository.ts";
|
||||||
|
import type { ISettingsService } from "../../../src/service/system/settingsService.ts";
|
||||||
import type { StatusPage } from "../../../src/types/index.ts";
|
import type { StatusPage } from "../../../src/types/index.ts";
|
||||||
|
import { DEFAULT_STATUS_PAGE_THEME, DEFAULT_STATUS_PAGE_THEME_MODE } from "../../../src/types/index.ts";
|
||||||
|
|
||||||
// ── Helpers ──────────────────────────────────────────────────────────────────
|
// ── Helpers ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -13,6 +15,8 @@ const makeStatusPage = (overrides?: Partial<StatusPage>): StatusPage =>
|
|||||||
url: "my-status-page",
|
url: "my-status-page",
|
||||||
companyName: "Test Co",
|
companyName: "Test Co",
|
||||||
monitors: ["mon-1"],
|
monitors: ["mon-1"],
|
||||||
|
theme: "modern",
|
||||||
|
themeMode: "dark",
|
||||||
createdAt: "2026-01-01T00:00:00Z",
|
createdAt: "2026-01-01T00:00:00Z",
|
||||||
updatedAt: "2026-01-01T00:00:00Z",
|
updatedAt: "2026-01-01T00:00:00Z",
|
||||||
...overrides,
|
...overrides,
|
||||||
@@ -28,18 +32,24 @@ const createRepo = () =>
|
|||||||
removeMonitorFromStatusPages: jest.fn().mockResolvedValue(1),
|
removeMonitorFromStatusPages: jest.fn().mockResolvedValue(1),
|
||||||
}) as unknown as jest.Mocked<IStatusPagesRepository>;
|
}) as unknown as jest.Mocked<IStatusPagesRepository>;
|
||||||
|
|
||||||
const createService = () => {
|
const createSettingsService = (themesEnabled: boolean) =>
|
||||||
|
({
|
||||||
|
areStatusPageThemesEnabled: jest.fn().mockReturnValue(themesEnabled),
|
||||||
|
}) as unknown as jest.Mocked<ISettingsService>;
|
||||||
|
|
||||||
|
const createService = (themesEnabled = true) => {
|
||||||
const repo = createRepo();
|
const repo = createRepo();
|
||||||
const service = new StatusPageService(repo);
|
const settingsService = createSettingsService(themesEnabled);
|
||||||
return { service, repo };
|
const service = new StatusPageService(repo, settingsService);
|
||||||
|
return { service, repo, settingsService };
|
||||||
};
|
};
|
||||||
|
|
||||||
// ── Tests ────────────────────────────────────────────────────────────────────
|
// ── Tests ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
describe("StatusPageService", () => {
|
describe("StatusPageService", () => {
|
||||||
describe("createStatusPage", () => {
|
describe("createStatusPage", () => {
|
||||||
it("delegates to repository with all parameters", async () => {
|
it("delegates to repository with all parameters when themes enabled", async () => {
|
||||||
const { service, repo } = createService();
|
const { service, repo } = createService(true);
|
||||||
const data = { companyName: "New Co" };
|
const data = { companyName: "New Co" };
|
||||||
const file = { originalname: "logo.png" } as Express.Multer.File;
|
const file = { originalname: "logo.png" } as Express.Multer.File;
|
||||||
|
|
||||||
@@ -50,39 +60,75 @@ describe("StatusPageService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes undefined image when not provided", async () => {
|
it("passes undefined image when not provided", async () => {
|
||||||
const { service, repo } = createService();
|
const { service, repo } = createService(true);
|
||||||
|
|
||||||
await service.createStatusPage("user-1", "team-1", undefined, {});
|
await service.createStatusPage("user-1", "team-1", undefined, {});
|
||||||
|
|
||||||
expect(repo.create).toHaveBeenCalledWith("user-1", "team-1", undefined, {});
|
expect(repo.create).toHaveBeenCalledWith("user-1", "team-1", undefined, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("strips theme fields from input and applies defaults to result when themes disabled", async () => {
|
||||||
|
const { service, repo } = createService(false);
|
||||||
|
const data = { companyName: "New Co", theme: "bold" as const, themeMode: "light" as const };
|
||||||
|
|
||||||
|
const result = await service.createStatusPage("user-1", "team-1", undefined, data);
|
||||||
|
|
||||||
|
expect(repo.create).toHaveBeenCalledWith("user-1", "team-1", undefined, { companyName: "New Co" });
|
||||||
|
expect(result.theme).toBe(DEFAULT_STATUS_PAGE_THEME);
|
||||||
|
expect(result.themeMode).toBe(DEFAULT_STATUS_PAGE_THEME_MODE);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getStatusPageByUrl", () => {
|
describe("getStatusPageByUrl", () => {
|
||||||
it("delegates to repository", async () => {
|
it("delegates to repository", async () => {
|
||||||
const { service, repo } = createService();
|
const { service, repo } = createService(true);
|
||||||
|
|
||||||
const result = await service.getStatusPageByUrl("my-status-page");
|
const result = await service.getStatusPageByUrl("my-status-page");
|
||||||
|
|
||||||
expect(repo.findByUrl).toHaveBeenCalledWith("my-status-page");
|
expect(repo.findByUrl).toHaveBeenCalledWith("my-status-page");
|
||||||
expect(result).toEqual(makeStatusPage());
|
expect(result).toEqual(makeStatusPage());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("applies default theme when themes disabled", async () => {
|
||||||
|
const { service } = createService(false);
|
||||||
|
|
||||||
|
const result = await service.getStatusPageByUrl("my-status-page");
|
||||||
|
|
||||||
|
expect(result.theme).toBe(DEFAULT_STATUS_PAGE_THEME);
|
||||||
|
expect(result.themeMode).toBe(DEFAULT_STATUS_PAGE_THEME_MODE);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getStatusPagesByTeamId", () => {
|
describe("getStatusPagesByTeamId", () => {
|
||||||
it("delegates to repository", async () => {
|
it("delegates to repository", async () => {
|
||||||
const { service, repo } = createService();
|
const { service, repo } = createService(true);
|
||||||
|
|
||||||
const result = await service.getStatusPagesByTeamId("team-1");
|
const result = await service.getStatusPagesByTeamId("team-1");
|
||||||
|
|
||||||
expect(repo.findByTeamId).toHaveBeenCalledWith("team-1");
|
expect(repo.findByTeamId).toHaveBeenCalledWith("team-1");
|
||||||
expect(result).toEqual([makeStatusPage()]);
|
expect(result).toEqual([makeStatusPage()]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("applies default theme to every result when themes disabled", async () => {
|
||||||
|
const { service, repo } = createService(false);
|
||||||
|
(repo.findByTeamId as jest.Mock).mockResolvedValue([
|
||||||
|
makeStatusPage({ id: "sp-1", theme: "bold" }),
|
||||||
|
makeStatusPage({ id: "sp-2", theme: "editorial" }),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await service.getStatusPagesByTeamId("team-1");
|
||||||
|
|
||||||
|
expect(result).toHaveLength(2);
|
||||||
|
for (const sp of result) {
|
||||||
|
expect(sp.theme).toBe(DEFAULT_STATUS_PAGE_THEME);
|
||||||
|
expect(sp.themeMode).toBe(DEFAULT_STATUS_PAGE_THEME_MODE);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("updateStatusPage", () => {
|
describe("updateStatusPage", () => {
|
||||||
it("delegates to repository with all parameters", async () => {
|
it("delegates to repository with all parameters", async () => {
|
||||||
const { service, repo } = createService();
|
const { service, repo } = createService(true);
|
||||||
const updated = makeStatusPage({ companyName: "Updated Co" });
|
const updated = makeStatusPage({ companyName: "Updated Co" });
|
||||||
(repo.updateById as jest.Mock).mockResolvedValue(updated);
|
(repo.updateById as jest.Mock).mockResolvedValue(updated);
|
||||||
const file = { originalname: "new-logo.png" } as Express.Multer.File;
|
const file = { originalname: "new-logo.png" } as Express.Multer.File;
|
||||||
@@ -92,11 +138,31 @@ describe("StatusPageService", () => {
|
|||||||
expect(repo.updateById).toHaveBeenCalledWith("sp-1", "team-1", file, { companyName: "Updated Co" });
|
expect(repo.updateById).toHaveBeenCalledWith("sp-1", "team-1", file, { companyName: "Updated Co" });
|
||||||
expect(result).toBe(updated);
|
expect(result).toBe(updated);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("passes theme and themeMode through to the repository when themes enabled", async () => {
|
||||||
|
const { service, repo } = createService(true);
|
||||||
|
const patch = { theme: "modern" as const, themeMode: "dark" as const };
|
||||||
|
|
||||||
|
await service.updateStatusPage("sp-1", "team-1", undefined, patch);
|
||||||
|
|
||||||
|
expect(repo.updateById).toHaveBeenCalledWith("sp-1", "team-1", undefined, patch);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("strips theme fields from input and applies defaults to result when themes disabled", async () => {
|
||||||
|
const { service, repo } = createService(false);
|
||||||
|
const patch = { companyName: "Updated Co", theme: "modern" as const, themeMode: "dark" as const };
|
||||||
|
|
||||||
|
const result = await service.updateStatusPage("sp-1", "team-1", undefined, patch);
|
||||||
|
|
||||||
|
expect(repo.updateById).toHaveBeenCalledWith("sp-1", "team-1", undefined, { companyName: "Updated Co" });
|
||||||
|
expect(result.theme).toBe(DEFAULT_STATUS_PAGE_THEME);
|
||||||
|
expect(result.themeMode).toBe(DEFAULT_STATUS_PAGE_THEME_MODE);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("deleteStatusPage", () => {
|
describe("deleteStatusPage", () => {
|
||||||
it("delegates to repository and returns deleted page", async () => {
|
it("delegates to repository and returns deleted page", async () => {
|
||||||
const { service, repo } = createService();
|
const { service, repo } = createService(true);
|
||||||
|
|
||||||
const result = await service.deleteStatusPage("sp-1", "team-1");
|
const result = await service.deleteStatusPage("sp-1", "team-1");
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user