From 80e7400185e88101e198533dde132a23fb9b8cae Mon Sep 17 00:00:00 2001 From: Gero Gerke Date: Tue, 26 Jul 2022 13:47:23 +0200 Subject: [PATCH] Updates --- server/model/group.js | 4 ++-- server/model/status_page.js | 12 ++++++++++-- server/routers/status-page-router.js | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/server/model/group.js b/server/model/group.js index 3f3b3b12..32e3cc39 100644 --- a/server/model/group.js +++ b/server/model/group.js @@ -9,12 +9,12 @@ class Group extends BeanModel { * @param {boolean} [showTags=false] Should the JSON include monitor tags * @returns {Object} */ - async toPublicJSON(showTags = false) { + async toPublicJSON(showTags = false, showStatus = false) { let monitorBeanList = await this.getMonitorList(); let monitorList = []; for (let bean of monitorBeanList) { - monitorList.push(await bean.toPublicJSON(showTags)); + monitorList.push(await bean.toPublicJSON(showTags, showStatus)); } return { diff --git a/server/model/status_page.js b/server/model/status_page.js index 5ac398c3..b9e661d3 100644 --- a/server/model/status_page.js +++ b/server/model/status_page.js @@ -73,8 +73,9 @@ class StatusPage extends BeanModel { * Get all status page data in one call * @param {StatusPage} statusPage * @param {boolean} includeStatus whether each monitor should include the status of the monitor ("up" or "down") + * @param {boolean} includeConfig whether the config for the status paghe should be included in the returned JSON */ - static async getStatusPageData(statusPage, includeStatus = false) { + static async getStatusPageData(statusPage, includeStatus = false, includeConfig = true) { // Incident let incident = await R.findOne("incident", " pin = 1 AND active = 1 AND status_page_id = ? ", [ statusPage.id, @@ -97,9 +98,16 @@ class StatusPage extends BeanModel { publicGroupList.push(monitorGroup); } + let config = {}; + if (includeConfig) { + config = { + config: await statusPage.toPublicJSON() + } + } + // Response return { - config: await statusPage.toPublicJSON(), + ...config, incident, publicGroupList }; diff --git a/server/routers/status-page-router.js b/server/routers/status-page-router.js index 95bd9eac..5a24962f 100644 --- a/server/routers/status-page-router.js +++ b/server/routers/status-page-router.js @@ -41,7 +41,7 @@ router.get("/api/status-page/:slug/summary", cache("5 minutes"), async (request, return null; } - let statusPageData = await StatusPage.getStatusPageData(statusPage, true); + let statusPageData = await StatusPage.getStatusPageData(statusPage, true, false); if (!statusPageData) { response.statusCode = 404;