fix status page

This commit is contained in:
Alex Holliday committed 2025-06-26 09:09:41 +08:00
1 parent 6a079704bb
commit 58b102b921
5 files changed
+49 -2

No files matched your search

+1 -1
View File
@@ -246,7 +246,7 @@ const CreateStatusPage = () => {
color="accent"
onClick={handleSubmit}
>
{t("settingsSave")}
{t("statusPageCreate.buttonSave")}
</Button>
</Stack>
</Stack>
+1 -1
View File
@@ -62,7 +62,7 @@ const PublicStatus = () => {
return <SkeletonLayout />;
}
if (monitors.length === 0) {
if (monitors?.length === 0) {
return (
<GenericFallback>
<Typography
+3
View File
@@ -835,5 +835,8 @@
"selectEnabled": "Enabled",
"title": "Monitor IP/URL on Status Page"
}
},
"statusPageCreate": {
"buttonSave": "Save"
}
}
+5
View File
@@ -147,6 +147,7 @@ MonitorSchema.pre("findOneAndDelete", async function (next) {
MonitorSchema.pre("deleteMany", async function (next) {
const filter = this.getFilter();
const monitors = await this.model.find(filter).select(["_id", "type"]).lean();
for (const monitor of monitors) {
if (monitor.type === "pagespeed") {
await PageSpeedCheck.deleteMany({ monitorId: monitor._id });
@@ -155,6 +156,10 @@ MonitorSchema.pre("deleteMany", async function (next) {
} else {
await Check.deleteMany({ monitorId: monitor._id });
}
await StatusPage.updateMany(
{ monitors: monitor._id },
{ $pull: { monitors: monitor._id } }
);
await MonitorStats.deleteMany({ monitorId: monitor._id.toString() });
}
next();
@@ -90,6 +90,45 @@ const getStatusPage = async (url) => {
const stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
try {
const preliminaryStatusPage = await StatusPage.findOne({ url });
if (!preliminaryStatusPage) {
const error = new Error(stringService.statusPageNotFound);
error.status = 404;
throw error;
}
if (!preliminaryStatusPage.monitors || preliminaryStatusPage.monitors.length === 0) {
const {
_id,
color,
companyName,
isPublished,
logo,
originalMonitors,
showCharts,
showUptimePercentage,
timezone,
showAdminLoginLink,
url,
} = preliminaryStatusPage;
return {
statusPage: {
_id,
color,
companyName,
isPublished,
logo,
originalMonitors,
showCharts,
showUptimePercentage,
timezone,
showAdminLoginLink,
url,
},
monitors: [],
};
}
const statusPageQuery = await StatusPage.aggregate([
{ $match: { url: url } },
{