wire client

This commit is contained in:
Alex Holliday committed 2026-08-17 14:56:53 -07:00
1 parent 506133af29
commit c15d6e0851
11 files changed
+189 -116

No files matched your search

@@ -87,6 +87,16 @@ const StatusPageView = () => {
const location = useLocation();
const [searchParams, setSearchParams] = useSearchParams();
const onRangeChange = (next: StatusPageRange) => {
const updated = new URLSearchParams(searchParams);
if (next === "latest") {
updated.delete("range");
} else {
updated.set("range", next);
}
setSearchParams(updated, { replace: true });
};
const onCustomDomainHost = isCustomDomainHost();
const isPublic =
onCustomDomainHost || location.pathname.startsWith(PUBLIC_STATUS_PAGE_PREFIX);
@@ -160,6 +170,9 @@ const StatusPageView = () => {
statusPage={statusPage}
monitors={monitors}
config={themeConfig}
range={range}
onRangeChange={onRangeChange}
bucketTimezone={data.bucketTimezone ?? "Etc/UTC"}
/>
</StatusPageThemeProvider>
);
@@ -4,8 +4,10 @@ import { type OverallTone, toneColor, toneSoft } from "../shared/overallStatus";
import { BOLD_SANS_STACK, MONO_STACK } from "../shared/fontStacks";
import { MAX_RECENT_CHECKS } from "@/Types/Monitor";
export type BoldHeatCell = "fast" | "med" | "slow" | "down" | "empty";
export type BoldBarKind = "up" | "down" | "empty";
import type { BarKind, HeatCellKind } from "../shared/ChartCells";
export type BoldHeatCell = HeatCellKind;
export type BoldBarKind = BarKind;
export type BoldGaugeFill = "ok" | "warm" | "hot";
export interface BoldStyles {
@@ -55,6 +57,7 @@ export const boldStyles = (
fast: tokens.up,
med: `color-mix(in srgb, ${tokens.up} 70%, #ffffff 30%)`,
slow: tokens.warn,
degraded: tokens.degraded,
down: tokens.down,
empty: tokens.border,
};
@@ -62,12 +65,14 @@ export const boldStyles = (
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)`,
degraded: `0 0 6px color-mix(in srgb, ${tokens.degraded} 20%, transparent)`,
down: `0 0 6px color-mix(in srgb, ${tokens.down} 20%, transparent)`,
empty: "none",
};
const barBg: Record<BoldBarKind, string> = {
up: tokens.up,
degraded: tokens.degraded,
down: tokens.down,
empty: tokens.border,
};
@@ -8,8 +8,10 @@ import {
} from "../shared/fontStacks";
import { MAX_RECENT_CHECKS } from "@/Types/Monitor";
export type EditorialHeatCell = "fast" | "med" | "slow" | "down" | "empty";
export type EditorialBarKind = "up" | "down" | "empty";
import type { BarKind, HeatCellKind } from "../shared/ChartCells";
export type EditorialHeatCell = HeatCellKind;
export type EditorialBarKind = BarKind;
export type EditorialGaugeFill = "ok" | "warm" | "hot";
export interface EditorialStyles {
@@ -59,12 +61,14 @@ export const editorialStyles = (
fast: tokens.up,
med: `color-mix(in srgb, ${tokens.up} 60%, ${tokens.bg})`,
slow: tokens.warn,
degraded: tokens.degraded,
down: tokens.down,
empty: tokens.border,
};
const barBg: Record<EditorialBarKind, string> = {
up: tokens.up,
degraded: tokens.degraded,
down: tokens.down,
empty: tokens.border,
};
@@ -5,8 +5,10 @@ import { type OverallTone, toneColor, toneSoft } from "../shared/overallStatus";
import { MONO_STACK, SANS_STACK } from "../shared/fontStacks";
import { MAX_RECENT_CHECKS } from "@/Types/Monitor";
export type ModernHeatCell = "fast" | "med" | "slow" | "down" | "empty";
export type ModernBarKind = "up" | "down" | "empty";
import type { BarKind, HeatCellKind } from "../shared/ChartCells";
export type ModernHeatCell = HeatCellKind;
export type ModernBarKind = BarKind;
export type ModernGaugeFill = "ok" | "warm" | "hot";
export interface ModernStyles {
@@ -86,12 +88,14 @@ export const modernStyles = (
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})`,
degraded: `linear-gradient(180deg, ${tokens.degraded}, color-mix(in srgb, ${tokens.degraded} 70%, #000000 30%))`,
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,
degraded: tokens.degraded,
down: tokens.down,
empty: tokens.border,
};
@@ -3,8 +3,10 @@ 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";
import type { BarKind, HeatCellKind } from "../shared/ChartCells";
export type RefinedHeatCell = HeatCellKind;
export type RefinedBarKind = BarKind;
export type RefinedGaugeFill = "ok" | "warm" | "hot";
import { MAX_RECENT_CHECKS } from "@/Types/Monitor";
@@ -71,12 +73,14 @@ export const refinedStyles = (
fast: tokens.up,
med: `color-mix(in srgb, ${tokens.up} 60%, #ffffff 40%)`,
slow: tokens.warn,
degraded: tokens.degraded,
down: tokens.down,
empty: tokens.border,
};
const barBg: Record<RefinedBarKind, string> = {
up: tokens.up,
degraded: tokens.degraded,
down: tokens.down,
empty: tokens.border,
};
@@ -4,17 +4,15 @@ import Stack from "@mui/material/Stack";
import { useTranslation } from "react-i18next";
import type { SxProps, Theme } from "@mui/material/styles";
import type { Monitor } from "@/Types/Monitor";
import type { StatusPage } from "@/Types/StatusPage";
import { getMonitorTypeLabel } from "@/Types/StatusPage";
import type { StatusPage, StatusPageRange } from "@/Types/StatusPage";
import {
getMonitorTypeLabel,
STATUS_PAGE_RANGE_DAYS,
STATUS_PAGE_RANGES,
} from "@/Types/StatusPage";
import type { StatusPageThemeTokens } from "@/Pages/StatusPage/Status/themes/tokens";
import {
ThemedHeatmap,
type HeatCellKind,
} from "@/Pages/StatusPage/Status/themes/shared/ThemedHeatmap";
import {
ThemedHistogram,
type BarKind,
} from "@/Pages/StatusPage/Status/themes/shared/ThemedHistogram";
import { ThemedHeatmap } from "@/Pages/StatusPage/Status/themes/shared/ThemedHeatmap";
import { ThemedHistogram } from "@/Pages/StatusPage/Status/themes/shared/ThemedHistogram";
import {
ThemedInfrastructure,
type GaugeFillLevel,
@@ -28,6 +26,12 @@ import {
} from "@/Pages/StatusPage/Status/themes/shared/overallStatus";
import { useStatusPageTheme } from "@/Pages/StatusPage/Status/themes/StatusPageThemeProvider";
import { formatPercentage } from "@/Utils/FormatUtils";
import {
checksToCells,
dailyBucketsToCells,
type BarKind,
type HeatCellKind,
} from "@/Pages/StatusPage/Status/themes/shared/ChartCells";
type StatusPageMonitor = Monitor;
@@ -82,9 +86,19 @@ interface Props {
statusPage: StatusPage;
monitors: StatusPageMonitor[];
config: ThemeConfig<any>;
range: StatusPageRange;
onRangeChange: (range: StatusPageRange) => void;
bucketTimezone: string;
}
export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
export const BaseStatusPage = ({
statusPage,
monitors,
config,
range,
onRangeChange,
bucketTimezone,
}: Props) => {
const { t } = useTranslation();
const { tokens, mode } = useStatusPageTheme();
const styles = useMemo(
@@ -126,33 +140,56 @@ export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
/>
{statusPage.showCharts && (
<Box sx={styles.chartSwitchWrap}>
<Box
sx={styles.chartSwitch}
role="radiogroup"
>
<Stack>
<Box sx={styles.chartSwitchWrap}>
<Box
component="button"
type="button"
role="radio"
aria-checked={chartMode === "heatmap"}
onClick={() => setChartMode("heatmap")}
sx={styles.chartSwitchButton(chartMode === "heatmap")}
sx={styles.chartSwitch}
role="radiogroup"
>
{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
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>
</Box>
<Box sx={styles.chartSwitchWrap}>
<Box
sx={styles.chartSwitch}
role="radiogroup"
aria-label={t("pages.statusPages.rangeSelectorAria")}
>
{STATUS_PAGE_RANGES.map((value) => (
<Box
component="button"
type="button"
role="radio"
key={value}
aria-checked={range === value}
onClick={() => onRangeChange(value)}
sx={styles.chartSwitchButton(range === value)}
>
{t(`pages.statusPages.range.${value}`)}
</Box>
))}
</Box>
</Box>
</Stack>
)}
<Stack
@@ -166,6 +203,16 @@ export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
const badgeTone = monitorBadgeTone(monitor.status);
const uptimePercentage = formatPercentage(monitor.uptimePercentage ?? 0);
const cells =
range === "latest"
? checksToCells(monitor.recentChecks ?? [], t)
: dailyBucketsToCells(
monitor.dailyChecks ?? [],
STATUS_PAGE_RANGE_DAYS[range],
bucketTimezone,
t
);
return (
<Box
component="li"
@@ -226,13 +273,13 @@ export const BaseStatusPage = ({ statusPage, monitors, config }: Props) => {
{showChart &&
(chartMode === "heatmap" ? (
<ThemedHeatmap
checks={monitor.recentChecks ?? []}
cells={cells}
containerSx={styles.heatmap}
cellSx={styles.heatmapCell}
/>
) : (
<ThemedHistogram
checks={monitor.recentChecks ?? []}
cells={cells}
containerSx={styles.histogram}
barSx={styles.bar}
statsSx={styles.chartStats}
@@ -2,65 +2,48 @@ import Tooltip from "@mui/material/Tooltip";
import Box from "@mui/material/Box";
import type { SxProps, Theme } from "@mui/material/styles";
import { useTranslation } from "react-i18next";
import type { CheckSnapshot } from "@/Types/Check";
import { MAX_RECENT_CHECKS } from "@/Types/Monitor";
import { ThemedChartTooltip } from "@/Pages/StatusPage/Status/themes/shared/ThemedChartTooltip";
import { formatMs } from "@/Utils/TimeUtils";
const CELLS = MAX_RECENT_CHECKS;
export type HeatCellKind = "fast" | "med" | "slow" | "down" | "empty";
import type {
ChartCell,
HeatCellKind,
} from "@/Pages/StatusPage/Status/themes/shared/ChartCells";
interface Props {
checks: CheckSnapshot[];
cells: ChartCell[];
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) => {
export const ThemedHeatmap = ({ cells, containerSx, cellSx }: Props) => {
const { t } = useTranslation();
const source = checks.slice(-CELLS);
const padded: (CheckSnapshot | null)[] = [
...source,
...Array.from({ length: Math.max(0, CELLS - source.length) }, () => null),
];
return (
<Box
sx={containerSx}
sx={[
...(Array.isArray(containerSx) ? containerSx : [containerSx]),
{ gridTemplateColumns: `repeat(${cells.length}, 1fr)` },
]}
role="img"
aria-label={t("pages.statusPages.monitorsList.chart.heatmapAria")}
>
{padded.map((check, i) => {
if (!check) {
{cells.map((cell) => {
if (cell.heatKind === "empty") {
return (
<Box
key={`empty-${i}`}
key={cell.key}
sx={cellSx("empty")}
/>
);
}
const kind = classify(check);
const tooltipContent = <ThemedChartTooltip check={check} />;
return (
<Tooltip
key={check.id ?? i}
title={tooltipContent}
key={cell.key}
title={cell.tooltip}
arrow
placement="top"
>
<Box
sx={cellSx(kind)}
aria-label={`${formatMs(check.responseTime)}, ${check.status ? "up" : "down"}`}
sx={cellSx(cell.heatKind)}
aria-label={cell.ariaLabel}
/>
</Tooltip>
);
@@ -5,17 +5,14 @@ import Stack from "@mui/material/Stack";
import type { SxProps, Theme } from "@mui/material/styles";
import { useTranslation } from "react-i18next";
import type { CheckSnapshot } from "@/Types/Check";
import { MAX_RECENT_CHECKS } from "@/Types/Monitor";
import { computeBarHeights } from "@/Utils/DataUtils";
import { formatMs } from "@/Utils/TimeUtils";
import { ThemedChartTooltip } from "@/Pages/StatusPage/Status/themes/shared/ThemedChartTooltip";
const CELLS = MAX_RECENT_CHECKS;
const MIN_HEIGHT_PCT = 6;
export type BarKind = "up" | "down" | "empty";
import type {
BarKind,
ChartCell,
} from "@/Pages/StatusPage/Status/themes/shared/ChartCells";
interface Props {
checks: CheckSnapshot[];
cells: ChartCell[];
containerSx: SxProps<Theme>;
barSx: (kind: BarKind, heightPct: number) => SxProps<Theme>;
statsSx: SxProps<Theme>;
@@ -26,7 +23,7 @@ const tone = (check: CheckSnapshot): Exclude<BarKind, "empty"> =>
check.status ? "up" : "down";
export const ThemedHistogram = ({
checks,
cells,
containerSx,
barSx,
statsSx,
@@ -34,45 +31,42 @@ export const ThemedHistogram = ({
}: Props) => {
const { t } = useTranslation();
const { padded, heights, avg, peak } = useMemo(() => {
const source = checks.slice(-CELLS);
const out: (CheckSnapshot | null)[] = [
...source,
...Array.from({ length: Math.max(0, CELLS - source.length) }, () => null),
];
const heights = computeBarHeights(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)) : 0;
const { avg, peak } = useMemo(() => {
const valid = cells.filter((cell) => cell.responseTime > 0);
const maxRt = valid.length ? Math.max(...valid.map((cell) => cell.responseTime)) : 0;
const avgRt = valid.length
? valid.reduce((s, c) => s + c.responseTime, 0) / valid.length
? valid.reduce((sum, cell) => sum + cell.responseTime, 0) / valid.length
: 0;
return { padded: out, heights, avg: formatMs(avgRt), peak: formatMs(maxRt) };
}, [checks]);
return { avg: formatMs(avgRt), peak: formatMs(maxRt) };
}, [cells]);
return (
<Stack gap={statsGap}>
<Box sx={containerSx}>
{padded.map((check, i) => {
if (!check) {
<Box
sx={[
...(Array.isArray(containerSx) ? containerSx : [containerSx]),
{ gridTemplateColumns: `repeat(${cells.length}, 1fr)` },
]}
>
{cells.map((cell) => {
if (cell.barKind === "empty") {
return (
<Box
key={`empty-${i}`}
sx={barSx("empty", MIN_HEIGHT_PCT)}
key={cell.key}
sx={barSx("empty", cell.heightPct)}
/>
);
}
const height = heights[i] ?? MIN_HEIGHT_PCT;
const tooltipContent = <ThemedChartTooltip check={check} />;
return (
<Tooltip
key={check.id ?? i}
title={tooltipContent}
key={cell.key}
title={cell.tooltip}
arrow
placement="top"
>
<Box
sx={barSx(tone(check), height)}
aria-label={formatMs(check.responseTime)}
sx={barSx(cell.barKind, cell.heightPct)}
aria-label={cell.ariaLabel}
/>
</Tooltip>
);
+7 -1
View File
@@ -1,4 +1,9 @@
import type { GroupedCheck, CheckSnapshot, GroupedUptimeCheck } from "@/Types/Check";
import type {
GroupedCheck,
CheckSnapshot,
GroupedUptimeCheck,
DailyCheckBucket,
} from "@/Types/Check";
import type { PageSpeedGroupedCheck } from "@/Types/Check";
import type { GeoContinent } from "@/Types/GeoCheck";
export type { GeoContinent } from "@/Types/GeoCheck";
@@ -149,6 +154,7 @@ export interface Monitor {
dnsServer?: string;
dnsRecordType?: DnsRecordType;
recentChecks: CheckSnapshot[];
dailyChecks?: DailyCheckBucket[];
createdAt: string;
updatedAt: string;
}
+11 -5
View File
@@ -24,13 +24,16 @@ 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 STATUS_PAGE_RANGES = ["latest", "30d", "60d", "90d"] as const;
export const STATUS_PAGE_DAY_RANGES = ["30d", "60d", "90d"] as const;
export type StatusPageDayRange = (typeof STATUS_PAGE_DAY_RANGES)[number];
export const STATUS_PAGE_RANGES = ["latest", ...STATUS_PAGE_DAY_RANGES] as const;
export type StatusPageRange = (typeof STATUS_PAGE_RANGES)[number];
export const STATUS_PAGE_RANGE_DAYS: Record<
Exclude<StatusPageRange, "latest">,
number
> = { "30d": 30, "60d": 60, "90d": 90 };
export const STATUS_PAGE_RANGE_DAYS: Record<StatusPageDayRange, number> = {
"30d": 30,
"60d": 60,
"90d": 90,
};
export const isStatusPageRange = (value: string | null): value is StatusPageRange =>
STATUS_PAGE_RANGES.some((range) => range === value);
@@ -78,4 +81,7 @@ export interface StatusPage {
export interface StatusPageResponse {
statusPage: StatusPage;
monitors: Monitor[];
range?: StatusPageDayRange; // present only when range !== "latest"
bucketTimezone?: string;
checkTTLDays?: number;
}
+7
View File
@@ -1442,6 +1442,13 @@
},
"statusPages": {
"deleteSuccess": "Status page deleted successfully",
"rangeSelectorAria": "History range",
"range": {
"latest": "Latest",
"30d": "30 days",
"60d": "60 days",
"90d": "90 days"
},
"fallback": {
"title": "No status pages yet",
"description": "Publish a public page that shows real-time uptime and incident history to your customers and stakeholders.",