fix status page
This commit is contained in:
1 parent
6a079704bb
commit
58b102b921
5 files changed
+49
-2
No files matched your search
@@ -246,7 +246,7 @@ const CreateStatusPage = () => {
|
|||||||
color="accent"
|
color="accent"
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
>
|
>
|
||||||
{t("settingsSave")}
|
{t("statusPageCreate.buttonSave")}
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const PublicStatus = () => {
|
|||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitors.length === 0) {
|
if (monitors?.length === 0) {
|
||||||
return (
|
return (
|
||||||
<GenericFallback>
|
<GenericFallback>
|
||||||
<Typography
|
<Typography
|
||||||
|
|||||||
@@ -835,5 +835,8 @@
|
|||||||
"selectEnabled": "Enabled",
|
"selectEnabled": "Enabled",
|
||||||
"title": "Monitor IP/URL on Status Page"
|
"title": "Monitor IP/URL on Status Page"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"statusPageCreate": {
|
||||||
|
"buttonSave": "Save"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,6 +147,7 @@ MonitorSchema.pre("findOneAndDelete", async function (next) {
|
|||||||
MonitorSchema.pre("deleteMany", async function (next) {
|
MonitorSchema.pre("deleteMany", async function (next) {
|
||||||
const filter = this.getFilter();
|
const filter = this.getFilter();
|
||||||
const monitors = await this.model.find(filter).select(["_id", "type"]).lean();
|
const monitors = await this.model.find(filter).select(["_id", "type"]).lean();
|
||||||
|
|
||||||
for (const monitor of monitors) {
|
for (const monitor of monitors) {
|
||||||
if (monitor.type === "pagespeed") {
|
if (monitor.type === "pagespeed") {
|
||||||
await PageSpeedCheck.deleteMany({ monitorId: monitor._id });
|
await PageSpeedCheck.deleteMany({ monitorId: monitor._id });
|
||||||
@@ -155,6 +156,10 @@ MonitorSchema.pre("deleteMany", async function (next) {
|
|||||||
} else {
|
} else {
|
||||||
await Check.deleteMany({ monitorId: monitor._id });
|
await Check.deleteMany({ monitorId: monitor._id });
|
||||||
}
|
}
|
||||||
|
await StatusPage.updateMany(
|
||||||
|
{ monitors: monitor._id },
|
||||||
|
{ $pull: { monitors: monitor._id } }
|
||||||
|
);
|
||||||
await MonitorStats.deleteMany({ monitorId: monitor._id.toString() });
|
await MonitorStats.deleteMany({ monitorId: monitor._id.toString() });
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -90,6 +90,45 @@ const getStatusPage = async (url) => {
|
|||||||
const stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
|
const stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
|
||||||
|
|
||||||
try {
|
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([
|
const statusPageQuery = await StatusPage.aggregate([
|
||||||
{ $match: { url: url } },
|
{ $match: { url: url } },
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user