fix: refactoring changes and adding type migration to statusPageType
This commit is contained in:
1 parent
be1ca4ac28
commit
a9e9097a1f
7 files changed
+307
-176
No files matched your search
@@ -302,35 +302,35 @@ const CreateMonitorPage = () => {
|
|||||||
>
|
>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="http"
|
value="http"
|
||||||
label={t("pages.createMonitor.form.type.optionHttp")}
|
label={t("pages.common.monitors.monitorTypes.optionHttp")}
|
||||||
description={t(
|
description={t(
|
||||||
"pages.createMonitor.form.type.optionHttpDescription"
|
"pages.createMonitor.form.type.optionHttpDescription"
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="ping"
|
value="ping"
|
||||||
label={t("pages.createMonitor.form.type.optionPing")}
|
label={t("pages.common.monitors.monitorTypes.optionPing")}
|
||||||
description={t(
|
description={t(
|
||||||
"pages.createMonitor.form.type.optionPingDescription"
|
"pages.createMonitor.form.type.optionPingDescription"
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="docker"
|
value="docker"
|
||||||
label={t("pages.createMonitor.form.type.optionDocker")}
|
label={t("pages.common.monitors.monitorTypes.optionDocker")}
|
||||||
description={t(
|
description={t(
|
||||||
"pages.createMonitor.form.type.optionDockerDescription"
|
"pages.createMonitor.form.type.optionDockerDescription"
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="port"
|
value="port"
|
||||||
label={t("pages.createMonitor.form.type.optionPort")}
|
label={t("pages.common.monitors.monitorTypes.optionPort")}
|
||||||
description={t(
|
description={t(
|
||||||
"pages.createMonitor.form.type.optionPortDescription"
|
"pages.createMonitor.form.type.optionPortDescription"
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<RadioWithDescription
|
<RadioWithDescription
|
||||||
value="game"
|
value="game"
|
||||||
label={t("pages.createMonitor.form.type.optionGame")}
|
label={t("pages.common.monitors.monitorTypes.optionGame")}
|
||||||
description={t(
|
description={t(
|
||||||
"pages.createMonitor.form.type.optionGameDescription"
|
"pages.createMonitor.form.type.optionGameDescription"
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -330,7 +330,9 @@ const CreateStatusPage = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<GripVertical size={20} />
|
<GripVertical size={20} />
|
||||||
<Typography flexGrow={1}>{monitor.name}</Typography>
|
<Typography
|
||||||
|
flexGrow={1}
|
||||||
|
>{`${monitor.name} (${t(`pages.common.monitors.monitorTypes.option${monitor?.type.charAt(0).toUpperCase() + monitor?.type.slice(1)}`)})`}</Typography>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { useTheme } from "@mui/material/styles";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import prettyBytes from "pretty-bytes";
|
import prettyBytes from "pretty-bytes";
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
|
import Grid from "@mui/material/Grid";
|
||||||
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
|
||||||
interface StatusPageMonitor extends Monitor {
|
interface StatusPageMonitor extends Monitor {
|
||||||
checks?: Monitor["recentChecks"];
|
checks?: Monitor["recentChecks"];
|
||||||
@@ -13,34 +16,62 @@ interface StatusPageMonitor extends Monitor {
|
|||||||
infrastructureDisk?: number;
|
infrastructureDisk?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MetricItemProps {
|
interface MetricDetailRowProps {
|
||||||
label: string;
|
label: string;
|
||||||
progress: number;
|
value: string;
|
||||||
upperLabel?: string;
|
|
||||||
upperValue?: string;
|
|
||||||
lowerLabel?: string;
|
|
||||||
lowerValue?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const MetricItem = ({
|
const MetricDetailRow = ({ label, value }: MetricDetailRowProps) => {
|
||||||
label,
|
|
||||||
progress,
|
|
||||||
upperLabel,
|
|
||||||
upperValue,
|
|
||||||
lowerLabel,
|
|
||||||
lowerValue,
|
|
||||||
}: MetricItemProps) => {
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems="center"
|
justifyContent="space-between"
|
||||||
gap={`${theme.spacing(4)} ${theme.spacing(10)}`}
|
|
||||||
flex={1}
|
|
||||||
>
|
>
|
||||||
<Stack
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2">{value}</Typography>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
interface MetricItemProps {
|
||||||
|
label: string;
|
||||||
|
progress: number;
|
||||||
|
details?: MetricDetailRowProps[];
|
||||||
|
}
|
||||||
|
|
||||||
|
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(2),
|
||||||
|
padding: theme.spacing(2),
|
||||||
|
paddingBottom: theme.spacing(4),
|
||||||
|
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(2),
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
display="flex"
|
||||||
|
flexDirection="column"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
spacing={theme.spacing(2)}
|
|
||||||
>
|
>
|
||||||
<Gauge
|
<Gauge
|
||||||
progress={progress}
|
progress={progress}
|
||||||
@@ -48,44 +79,22 @@ const MetricItem = ({
|
|||||||
strokeWidth={12}
|
strokeWidth={12}
|
||||||
/>
|
/>
|
||||||
<Typography variant="body2">{label}</Typography>
|
<Typography variant="body2">{label}</Typography>
|
||||||
</Stack>
|
</Box>
|
||||||
{(upperLabel || lowerLabel) && (
|
{details && details.length > 0 && (
|
||||||
<Stack
|
<Box
|
||||||
spacing={theme.spacing(1)}
|
width="100%"
|
||||||
flex={1}
|
paddingX={theme.spacing(10)}
|
||||||
paddingBottom={theme.spacing(10)}
|
|
||||||
>
|
>
|
||||||
{upperLabel && (
|
{details.map((detail) => (
|
||||||
<Stack
|
<MetricDetailRow
|
||||||
direction="row"
|
key={detail.label}
|
||||||
justifyContent="space-between"
|
label={detail.label}
|
||||||
>
|
value={detail.value}
|
||||||
<Typography
|
/>
|
||||||
variant="body2"
|
))}
|
||||||
color="text.secondary"
|
</Box>
|
||||||
>
|
|
||||||
{upperLabel}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2">{upperValue}</Typography>
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
{lowerLabel && (
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
justifyContent="space-between"
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
variant="body2"
|
|
||||||
color="text.secondary"
|
|
||||||
>
|
|
||||||
{lowerLabel}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body2">{lowerValue}</Typography>
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Grid>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -99,54 +108,93 @@ export const InfrastructureMetrics = ({ monitor }: { monitor: StatusPageMonitor
|
|||||||
return (
|
return (
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="body2"
|
||||||
color="text.secondary"
|
color={theme.palette.text.secondary}
|
||||||
>
|
>
|
||||||
{t("pages.statusPages.monitorsList.noData")}
|
{t("pages.statusPages.monitorsList.noData")}
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cpuUsage = (latestCheck?.cpu?.usage_percent || 0) * 100;
|
const metrics = [
|
||||||
const memoryUsage = (latestCheck?.memory?.usage_percent || 0) * 100;
|
{
|
||||||
const memoryUsed = latestCheck?.memory?.used_bytes || 0;
|
key: t("pages.statusPages.monitorsList.infrastructure.cpu"),
|
||||||
const memoryTotal = latestCheck?.memory?.total_bytes || 0;
|
labelKey: t("pages.statusPages.monitorsList.infrastructure.cpu"),
|
||||||
|
hasData: latestCheck.cpu && typeof latestCheck.cpu.usage_percent === "number",
|
||||||
const disks = latestCheck?.disk ?? [];
|
progress: latestCheck.cpu?.usage_percent ? latestCheck.cpu.usage_percent * 100 : 0,
|
||||||
const totalDiskUsage = disks.reduce((acc, disk) => acc + (disk?.usage_percent || 0), 0);
|
details: [
|
||||||
const diskCount = disks.length || 1;
|
{
|
||||||
const diskUsage = (totalDiskUsage / diskCount) * 100;
|
label: t("pages.statusPages.monitorsList.infrastructure.usage"),
|
||||||
const diskUsed = disks.reduce((acc, disk) => acc + (disk?.used_bytes || 0), 0);
|
value: `${((latestCheck.cpu?.usage_percent || 0) * 100).toFixed(2)}%`,
|
||||||
const diskTotal = disks.reduce((acc, disk) => acc + (disk?.total_bytes || 0), 0);
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: t("pages.statusPages.monitorsList.infrastructure.memoryText"),
|
||||||
|
labelKey: t("pages.statusPages.monitorsList.infrastructure.memory"),
|
||||||
|
hasData:
|
||||||
|
latestCheck.memory &&
|
||||||
|
typeof latestCheck.memory.usage_percent === "number" &&
|
||||||
|
typeof latestCheck.memory.used_bytes === "number" &&
|
||||||
|
typeof latestCheck.memory.total_bytes === "number",
|
||||||
|
progress: latestCheck.memory?.usage_percent
|
||||||
|
? latestCheck.memory.usage_percent * 100
|
||||||
|
: 0,
|
||||||
|
details: [
|
||||||
|
{
|
||||||
|
label: t("pages.statusPages.monitorsList.infrastructure.used"),
|
||||||
|
value: prettyBytes(latestCheck.memory?.used_bytes || 0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("pages.statusPages.monitorsList.infrastructure.total"),
|
||||||
|
value: prettyBytes(latestCheck.memory?.total_bytes || 0),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: t("pages.statusPages.monitorsList.infrastructure.disk"),
|
||||||
|
labelKey: t("pages.statusPages.monitorsList.infrastructure.disk"),
|
||||||
|
hasData: latestCheck.disk && latestCheck.disk.length > 0,
|
||||||
|
progress: latestCheck.disk
|
||||||
|
? (latestCheck.disk.reduce((acc, disk) => acc + (disk?.usage_percent || 0), 0) /
|
||||||
|
latestCheck.disk.length) *
|
||||||
|
100
|
||||||
|
: 0,
|
||||||
|
details: [
|
||||||
|
{
|
||||||
|
label: t("pages.statusPages.monitorsList.infrastructure.used"),
|
||||||
|
value: prettyBytes(
|
||||||
|
latestCheck?.disk?.reduce((acc, disk) => acc + (disk?.used_bytes || 0), 0) ??
|
||||||
|
0
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("pages.statusPages.monitorsList.infrastructure.total"),
|
||||||
|
value: prettyBytes(
|
||||||
|
latestCheck?.disk?.reduce((acc, disk) => acc + (disk?.total_bytes || 0), 0) ??
|
||||||
|
0
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Grid
|
||||||
direction={{ xs: "column", sm: "row" }}
|
container
|
||||||
gap={theme.spacing(10)}
|
alignItems="center"
|
||||||
columnGap={theme.spacing(15)}
|
padding={theme.spacing(4)}
|
||||||
padding={theme.spacing(8)}
|
|
||||||
>
|
>
|
||||||
<MetricItem
|
{metrics.map(
|
||||||
label={t("pages.statusPages.monitorsList.infrastructure.cpu")}
|
({ key, labelKey, hasData, progress, details }) =>
|
||||||
progress={cpuUsage}
|
hasData && (
|
||||||
upperLabel={t("pages.statusPages.monitorsList.infrastructure.usage")}
|
<MetricItem
|
||||||
upperValue={`${cpuUsage.toFixed(1)}%`}
|
key={key}
|
||||||
/>
|
label={t(labelKey)}
|
||||||
<MetricItem
|
progress={progress}
|
||||||
label={t("pages.statusPages.monitorsList.infrastructure.memory")}
|
details={details}
|
||||||
progress={memoryUsage}
|
/>
|
||||||
upperLabel={t("pages.statusPages.monitorsList.infrastructure.used")}
|
)
|
||||||
upperValue={prettyBytes(memoryUsed)}
|
)}
|
||||||
lowerLabel={t("pages.statusPages.monitorsList.infrastructure.total")}
|
</Grid>
|
||||||
lowerValue={prettyBytes(memoryTotal)}
|
|
||||||
/>
|
|
||||||
<MetricItem
|
|
||||||
label={t("pages.statusPages.monitorsList.infrastructure.disk")}
|
|
||||||
progress={diskUsage}
|
|
||||||
upperLabel={t("pages.statusPages.monitorsList.infrastructure.used")}
|
|
||||||
upperValue={prettyBytes(diskUsed)}
|
|
||||||
lowerLabel={t("pages.statusPages.monitorsList.infrastructure.total")}
|
|
||||||
lowerValue={prettyBytes(diskTotal)}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -7,7 +7,7 @@ import { StatusLabel, BaseBox } from "@/Components/design-elements";
|
|||||||
import { SwitchComponent } from "@/Components/inputs";
|
import { SwitchComponent } from "@/Components/inputs";
|
||||||
import { InfrastructureMetrics } from "@/Pages/StatusPage/Status/Components/InfrastructureMetrics";
|
import { InfrastructureMetrics } from "@/Pages/StatusPage/Status/Components/InfrastructureMetrics";
|
||||||
|
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme, type Theme } from "@mui/material/styles";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import type { Monitor } from "@/Types/Monitor";
|
import type { Monitor } from "@/Types/Monitor";
|
||||||
@@ -23,6 +23,87 @@ interface MonitorsListProps {
|
|||||||
monitors: StatusPageMonitor[];
|
monitors: StatusPageMonitor[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getMonitorBadgeStyles = (monitorType: string, theme: Theme) => {
|
||||||
|
// for future: specific badge styles can be defined here based on monitor type
|
||||||
|
const badgeConfig: Record<string, { color: string; bg: string }> = {
|
||||||
|
hardware: {
|
||||||
|
color: theme.palette.background.paper,
|
||||||
|
bg: theme.palette.info.light,
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
color: theme.palette.background.paper,
|
||||||
|
bg: theme.palette.success.light,
|
||||||
|
},
|
||||||
|
ping: {
|
||||||
|
color: theme.palette.background.paper,
|
||||||
|
bg: theme.palette.success.light,
|
||||||
|
},
|
||||||
|
port: {
|
||||||
|
color: theme.palette.background.paper,
|
||||||
|
bg: theme.palette.success.light,
|
||||||
|
},
|
||||||
|
docker: {
|
||||||
|
color: theme.palette.background.paper,
|
||||||
|
bg: theme.palette.success.light,
|
||||||
|
},
|
||||||
|
pagespeed: {
|
||||||
|
color: theme.palette.background.paper,
|
||||||
|
bg: theme.palette.success.light,
|
||||||
|
},
|
||||||
|
game: {
|
||||||
|
color: theme.palette.background.paper,
|
||||||
|
bg: theme.palette.success.light,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const config = badgeConfig[monitorType] ?? badgeConfig.http;
|
||||||
|
return {
|
||||||
|
backgroundColor: config.bg,
|
||||||
|
color: config.color,
|
||||||
|
padding: `${theme.spacing(1)} ${theme.spacing(2)}`,
|
||||||
|
borderRadius: theme.shape.borderRadius,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Extracted component for monitor content below the header row
|
||||||
|
const MonitorContent = ({
|
||||||
|
monitor,
|
||||||
|
statusPage,
|
||||||
|
chartType,
|
||||||
|
}: {
|
||||||
|
monitor: Monitor & { checks?: Monitor["recentChecks"] };
|
||||||
|
statusPage: StatusPage;
|
||||||
|
chartType: string;
|
||||||
|
}) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const isInfrastructureMonitor = monitor?.type === "hardware";
|
||||||
|
|
||||||
|
if (isInfrastructureMonitor) {
|
||||||
|
if (statusPage.showInfrastructure === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return <InfrastructureMetrics monitor={monitor} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statusPage.showCharts === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={{ overflow: "hidden", minWidth: 0, flex: 1, mb: theme.spacing(2) }}>
|
||||||
|
{chartType === "histogram" ? (
|
||||||
|
<HistogramResponseTime
|
||||||
|
height={{ xs: 50, md: 100 }}
|
||||||
|
gap={{ xs: theme.spacing(1), md: theme.spacing(5) }}
|
||||||
|
checks={monitor?.checks?.slice().reverse() ?? []}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<HeatmapResponseTime checks={monitor?.checks?.slice().reverse() ?? []} />
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const MonitorsList = ({ statusPage, monitors }: MonitorsListProps) => {
|
export const MonitorsList = ({ statusPage, monitors }: MonitorsListProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -55,7 +136,6 @@ export const MonitorsList = ({ statusPage, monitors }: MonitorsListProps) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{monitors?.map((monitor) => {
|
{monitors?.map((monitor) => {
|
||||||
const isInfrastructureMonitor = monitor?.type === "hardware";
|
|
||||||
return (
|
return (
|
||||||
<BaseBox
|
<BaseBox
|
||||||
key={monitor.id}
|
key={monitor.id}
|
||||||
@@ -87,27 +167,22 @@ export const MonitorsList = ({ statusPage, monitors }: MonitorsListProps) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
variant="caption"
|
variant="caption"
|
||||||
sx={{
|
sx={getMonitorBadgeStyles(monitor?.type ?? "", theme)}
|
||||||
backgroundColor:
|
|
||||||
monitor?.type === "hardware"
|
|
||||||
? theme.palette.info.light
|
|
||||||
: theme.palette.success.light,
|
|
||||||
color:
|
|
||||||
monitor?.type === "hardware"
|
|
||||||
? theme.palette.info.dark
|
|
||||||
: theme.palette.success.dark,
|
|
||||||
padding: `${theme.spacing(0.5)} ${theme.spacing(1.5)}`,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
fontWeight: 600,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{t(`pages.statusPages.monitorsList.badge.${monitor?.type}`)}
|
{t(
|
||||||
|
`pages.common.monitors.monitorTypes.option${monitor?.type.charAt(0).toUpperCase() + monitor?.type.slice(1)}`
|
||||||
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
{showURL && monitor?.url && (
|
{showURL && monitor?.url && (
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="body2"
|
||||||
color="text.secondary"
|
color={theme.palette.text.secondary}
|
||||||
|
sx={{
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{monitor.url}
|
{monitor.url}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -115,48 +190,11 @@ export const MonitorsList = ({ statusPage, monitors }: MonitorsListProps) => {
|
|||||||
</Box>
|
</Box>
|
||||||
<StatusLabel status={monitor?.status} />
|
<StatusLabel status={monitor?.status} />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
<MonitorContent
|
||||||
{!isInfrastructureMonitor && (
|
monitor={monitor}
|
||||||
<>
|
statusPage={statusPage}
|
||||||
{statusPage.showCharts !== false && (
|
chartType={chartType}
|
||||||
<Box
|
/>
|
||||||
sx={{
|
|
||||||
overflow: "hidden",
|
|
||||||
minWidth: 0,
|
|
||||||
flex: 1,
|
|
||||||
mb: theme.spacing(2),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{chartType === "histogram" ? (
|
|
||||||
<HistogramResponseTime
|
|
||||||
height={{ xs: 50, md: 100 }}
|
|
||||||
gap={{ xs: theme.spacing(0.5), md: theme.spacing(5) }}
|
|
||||||
checks={monitor?.checks?.slice().reverse() ?? []}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<HeatmapResponseTime
|
|
||||||
checks={monitor?.checks?.slice().reverse() ?? []}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{isInfrastructureMonitor && statusPage.showInfrastructure !== false && (
|
|
||||||
<BaseBox
|
|
||||||
key={monitor.id}
|
|
||||||
padding={theme.spacing(4)}
|
|
||||||
>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
alignItems="center"
|
|
||||||
justifyContent="space-between"
|
|
||||||
gap={theme.spacing(8)}
|
|
||||||
></Stack>
|
|
||||||
<InfrastructureMetrics monitor={monitor} />
|
|
||||||
</BaseBox>
|
|
||||||
)}
|
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
+12
-16
@@ -407,6 +407,17 @@
|
|||||||
"paused": "paused",
|
"paused": "paused",
|
||||||
"total": "total",
|
"total": "total",
|
||||||
"up": "up"
|
"up": "up"
|
||||||
|
},
|
||||||
|
"monitorTypes": {
|
||||||
|
"optionDocker": "Docker",
|
||||||
|
"optionGame": "Game",
|
||||||
|
"optionHttp": "HTTP(S)",
|
||||||
|
"optionPing": "Ping",
|
||||||
|
"optionPort": "Port",
|
||||||
|
"optionPagespeed": "PageSpeed",
|
||||||
|
"optionHardware": "Infrastructure",
|
||||||
|
"optionGrpc": "gRPC",
|
||||||
|
"optionWebSocket": "WebSocket"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -534,19 +545,12 @@
|
|||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"description": "Select the type of check to perform",
|
"description": "Select the type of check to perform",
|
||||||
"optionDocker": "Docker",
|
|
||||||
"optionDockerDescription": "Use Docker to monitor if a container is running.",
|
"optionDockerDescription": "Use Docker to monitor if a container is running.",
|
||||||
"optionGame": "Game",
|
|
||||||
"optionGameDescription": "Monitor if a specific game server is online.",
|
"optionGameDescription": "Monitor if a specific game server is online.",
|
||||||
"optionGrpc": "gRPC",
|
|
||||||
"optionGrpcDescription": "Monitor gRPC services using the standard Health Checking Protocol.",
|
"optionGrpcDescription": "Monitor gRPC services using the standard Health Checking Protocol.",
|
||||||
"optionWebSocket": "WebSocket",
|
|
||||||
"optionWebSocketDescription": "Monitor WebSocket endpoints for connection health and response time.",
|
"optionWebSocketDescription": "Monitor WebSocket endpoints for connection health and response time.",
|
||||||
"optionHttp": "HTTP(S)",
|
|
||||||
"optionHttpDescription": "Use HTTP(S) to monitor your website or API endpoint.",
|
"optionHttpDescription": "Use HTTP(S) to monitor your website or API endpoint.",
|
||||||
"optionPing": "Ping",
|
|
||||||
"optionPingDescription": "Use ICMP Ping to monitor if a server is online.",
|
"optionPingDescription": "Use ICMP Ping to monitor if a server is online.",
|
||||||
"optionPort": "Port",
|
|
||||||
"optionPortDescription": "Monitor if a specific port on a server is open.",
|
"optionPortDescription": "Monitor if a specific port on a server is open.",
|
||||||
"title": "Type"
|
"title": "Type"
|
||||||
},
|
},
|
||||||
@@ -1184,6 +1188,7 @@
|
|||||||
"title": "Infrastructure",
|
"title": "Infrastructure",
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
"memory": "RAM",
|
"memory": "RAM",
|
||||||
|
"memoryText": "Memory",
|
||||||
"disk": "Disk",
|
"disk": "Disk",
|
||||||
"usage": "Usage",
|
"usage": "Usage",
|
||||||
"used": "Used",
|
"used": "Used",
|
||||||
@@ -1192,15 +1197,6 @@
|
|||||||
"uptime": {
|
"uptime": {
|
||||||
"title": "Uptime",
|
"title": "Uptime",
|
||||||
"responseTime": "Response time"
|
"responseTime": "Response time"
|
||||||
},
|
|
||||||
"badge": {
|
|
||||||
"http": "HTTP",
|
|
||||||
"ping": "Ping",
|
|
||||||
"port": "Port",
|
|
||||||
"docker": "Docker",
|
|
||||||
"pagespeed": "PageSpeed",
|
|
||||||
"hardware": "Infrastructure",
|
|
||||||
"game": "Game"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"statusBar": {
|
"statusBar": {
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import mongoose from "mongoose";
|
||||||
|
import { logger } from "@/utils/logger.js";
|
||||||
|
import StatusPageModel from "../models/StatusPage.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migration: Convert StatusPage `type` field from string to array of strings
|
||||||
|
*
|
||||||
|
* Old format: { type: "uptime" }
|
||||||
|
* New format: { type: ["uptime"] }
|
||||||
|
*/
|
||||||
|
export async function migrateStatusPageTypeToArray(): Promise<void> {
|
||||||
|
const SERVICE_NAME = "Migration:MigrateStatusPageTypeToArray";
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.info({ service: SERVICE_NAME, message: "Starting migration of StatusPage type field from string to array" });
|
||||||
|
|
||||||
|
const db = mongoose.connection.db;
|
||||||
|
if (!db) {
|
||||||
|
throw new Error("Database connection is not initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find all status pages where `type` is a string (not yet migrated)
|
||||||
|
const result = await StatusPageModel.updateMany({ type: { $type: "string" } }, [
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
type: ["$type"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (result.modifiedCount === 0) {
|
||||||
|
logger.info({ service: SERVICE_NAME, message: "No StatusPage documents needed migration" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info({
|
||||||
|
service: SERVICE_NAME,
|
||||||
|
message: `Migration complete. Converted ${result.modifiedCount} StatusPage document(s) from string type to array type`,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
|
logger.error({ service: SERVICE_NAME, message: `Error during StatusPage type migration: ${errorMessage}` });
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { convertChecksToTimeSeries } from "./0002_convertChecksToTimeSeries.js";
|
|||||||
import { cleanupDuplicateMonitorStats } from "./0003_cleanupDuplicateMonitorStats.js";
|
import { cleanupDuplicateMonitorStats } from "./0003_cleanupDuplicateMonitorStats.js";
|
||||||
import { fixInfrastructureThresholds } from "./0004_fixInfrastructureThresholds.js";
|
import { fixInfrastructureThresholds } from "./0004_fixInfrastructureThresholds.js";
|
||||||
import MigrationModel from "../models/Migration.js";
|
import MigrationModel from "../models/Migration.js";
|
||||||
|
import { migrateStatusPageTypeToArray } from "./0005_migrateStatusPageTypeToArray.js";
|
||||||
|
|
||||||
type MigrationEntry = {
|
type MigrationEntry = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -14,6 +15,7 @@ const migrations: MigrationEntry[] = [
|
|||||||
{ name: "0002_convertChecksToTimeSeries", execute: convertChecksToTimeSeries },
|
{ name: "0002_convertChecksToTimeSeries", execute: convertChecksToTimeSeries },
|
||||||
{ name: "0003_cleanupDuplicateMonitorStats", execute: cleanupDuplicateMonitorStats },
|
{ name: "0003_cleanupDuplicateMonitorStats", execute: cleanupDuplicateMonitorStats },
|
||||||
{ name: "0004_fixInfrastructureThresholds", execute: fixInfrastructureThresholds },
|
{ name: "0004_fixInfrastructureThresholds", execute: fixInfrastructureThresholds },
|
||||||
|
{ name: "0005_migrateStatusPageTypeToArray", execute: migrateStatusPageTypeToArray },
|
||||||
];
|
];
|
||||||
|
|
||||||
const runMigrations = async (logger?: { info: Function; error: Function }) => {
|
const runMigrations = async (logger?: { info: Function; error: Function }) => {
|
||||||
|
|||||||
Reference in new issue
Block a user