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
|
||||
const checkModule = new CheckModule({ logger, Check, Monitor, User });
|
||||
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 maintenanceWindowModule = new MaintenanceWindowModule({ MaintenanceWindow });
|
||||
const monitorModule = new MonitorModule({
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// import StatusPage from "../../models/StatusPage.js";
|
||||
// import { NormalizeData } from "../../../utils/dataUtils.js";
|
||||
// import ServiceRegistry from "../../../service/system/serviceRegistry.js";
|
||||
// import StringService from "../../../service/system/stringService.js";
|
||||
@@ -6,10 +5,11 @@
|
||||
const SERVICE_NAME = "statusPageModule";
|
||||
|
||||
class StatusPageModule {
|
||||
constructor({ StatusPage, NormalizeData, stringService }) {
|
||||
constructor({ StatusPage, NormalizeData, stringService, AppSettings }) {
|
||||
this.StatusPage = StatusPage;
|
||||
this.NormalizeData = NormalizeData;
|
||||
this.stringService = stringService;
|
||||
this.AppSettings = AppSettings;
|
||||
}
|
||||
|
||||
createStatusPage = async ({ statusPageData, image, userId, teamId }) => {
|
||||
@@ -217,7 +217,7 @@ class StatusPageModule {
|
||||
showUptimePercentage: 1,
|
||||
timezone: 1,
|
||||
showAdminLoginLink: 1,
|
||||
url: 1,
|
||||
url: { $cond: [{ $eq: ["$statusPage.showMonitorUrl", true] }, "$monitors.url", "$$REMOVE"] },
|
||||
},
|
||||
monitors: {
|
||||
_id: 1,
|
||||
@@ -260,11 +260,16 @@ class StatusPageModule {
|
||||
|
||||
const { statusPage, monitors } = statusPageQuery[0];
|
||||
|
||||
const appSettings = await this.AppSettings.findOne({ singleton: true }).lean();
|
||||
const showURL = appSettings?.showURL === true;
|
||||
|
||||
const normalizedMonitors = monitors.map((monitor) => {
|
||||
return {
|
||||
...monitor,
|
||||
checks: this.NormalizeData(monitor.checks, 10, 100),
|
||||
};
|
||||
const normalizedChecks = this.NormalizeData(monitor.checks, 10, 100);
|
||||
if (showURL !== true) {
|
||||
const { url, ...rest } = monitor;
|
||||
return { ...rest, checks: normalizedChecks };
|
||||
}
|
||||
return { ...monitor, checks: normalizedChecks };
|
||||
});
|
||||
|
||||
return { statusPage, monitors: normalizedMonitors };
|
||||
|
||||
Reference in new issue
Block a user