3120 remove URL's from data when they are supposed to be disabled
This commit is contained in:
1 parent
5c14c68899
commit
fb3795bd70
2 files changed
+13
-8
No files matched your search
@@ -83,7 +83,7 @@ export const initializeServices = async ({ logger, envSettings, settingsService
|
|||||||
// Create DB
|
// Create DB
|
||||||
const checkModule = new CheckModule({ logger, Check, Monitor, User });
|
const checkModule = new CheckModule({ logger, Check, Monitor, User });
|
||||||
const inviteModule = new InviteModule({ InviteToken, crypto, stringService });
|
const inviteModule = new InviteModule({ InviteToken, crypto, stringService });
|
||||||
const statusPageModule = new StatusPageModule({ StatusPage, NormalizeData, stringService });
|
const statusPageModule = new StatusPageModule({ StatusPage, NormalizeData, stringService, AppSettings });
|
||||||
const userModule = new UserModule({ User, Team, GenerateAvatarImage, ParseBoolean, stringService });
|
const userModule = new UserModule({ User, Team, GenerateAvatarImage, ParseBoolean, stringService });
|
||||||
const maintenanceWindowModule = new MaintenanceWindowModule({ MaintenanceWindow });
|
const maintenanceWindowModule = new MaintenanceWindowModule({ MaintenanceWindow });
|
||||||
const monitorModule = new MonitorModule({
|
const monitorModule = new MonitorModule({
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// import StatusPage from "../../models/StatusPage.js";
|
|
||||||
// import { NormalizeData } from "../../../utils/dataUtils.js";
|
// import { NormalizeData } from "../../../utils/dataUtils.js";
|
||||||
// import ServiceRegistry from "../../../service/system/serviceRegistry.js";
|
// import ServiceRegistry from "../../../service/system/serviceRegistry.js";
|
||||||
// import StringService from "../../../service/system/stringService.js";
|
// import StringService from "../../../service/system/stringService.js";
|
||||||
@@ -6,10 +5,11 @@
|
|||||||
const SERVICE_NAME = "statusPageModule";
|
const SERVICE_NAME = "statusPageModule";
|
||||||
|
|
||||||
class StatusPageModule {
|
class StatusPageModule {
|
||||||
constructor({ StatusPage, NormalizeData, stringService }) {
|
constructor({ StatusPage, NormalizeData, stringService, AppSettings }) {
|
||||||
this.StatusPage = StatusPage;
|
this.StatusPage = StatusPage;
|
||||||
this.NormalizeData = NormalizeData;
|
this.NormalizeData = NormalizeData;
|
||||||
this.stringService = stringService;
|
this.stringService = stringService;
|
||||||
|
this.AppSettings = AppSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
createStatusPage = async ({ statusPageData, image, userId, teamId }) => {
|
createStatusPage = async ({ statusPageData, image, userId, teamId }) => {
|
||||||
@@ -217,7 +217,7 @@ class StatusPageModule {
|
|||||||
showUptimePercentage: 1,
|
showUptimePercentage: 1,
|
||||||
timezone: 1,
|
timezone: 1,
|
||||||
showAdminLoginLink: 1,
|
showAdminLoginLink: 1,
|
||||||
url: 1,
|
url: { $cond: [{ $eq: ["$statusPage.showMonitorUrl", true] }, "$monitors.url", "$$REMOVE"] },
|
||||||
},
|
},
|
||||||
monitors: {
|
monitors: {
|
||||||
_id: 1,
|
_id: 1,
|
||||||
@@ -260,11 +260,16 @@ class StatusPageModule {
|
|||||||
|
|
||||||
const { statusPage, monitors } = statusPageQuery[0];
|
const { statusPage, monitors } = statusPageQuery[0];
|
||||||
|
|
||||||
|
const appSettings = await this.AppSettings.findOne({ singleton: true }).lean();
|
||||||
|
const showURL = appSettings?.showURL === true;
|
||||||
|
|
||||||
const normalizedMonitors = monitors.map((monitor) => {
|
const normalizedMonitors = monitors.map((monitor) => {
|
||||||
return {
|
const normalizedChecks = this.NormalizeData(monitor.checks, 10, 100);
|
||||||
...monitor,
|
if (showURL !== true) {
|
||||||
checks: this.NormalizeData(monitor.checks, 10, 100),
|
const { url, ...rest } = monitor;
|
||||||
};
|
return { ...rest, checks: normalizedChecks };
|
||||||
|
}
|
||||||
|
return { ...monitor, checks: normalizedChecks };
|
||||||
});
|
});
|
||||||
|
|
||||||
return { statusPage, monitors: normalizedMonitors };
|
return { statusPage, monitors: normalizedMonitors };
|
||||||
|
|||||||
Reference in new issue
Block a user