diff --git a/server/model/status_page.js b/server/model/status_page.js index 2bdfc8d30..202d085de 100644 --- a/server/model/status_page.js +++ b/server/model/status_page.js @@ -9,7 +9,16 @@ const { Feed } = require("feed"); const config = require("../config"); const { setting } = require("../util-server"); -const { STATUS_PAGE_ALL_DOWN, STATUS_PAGE_ALL_UP, STATUS_PAGE_MAINTENANCE, STATUS_PAGE_PARTIAL_DOWN, UP, MAINTENANCE, DOWN, INCIDENT_PAGE_SIZE } = require("../../src/util"); +const { + STATUS_PAGE_ALL_DOWN, + STATUS_PAGE_ALL_UP, + STATUS_PAGE_MAINTENANCE, + STATUS_PAGE_PARTIAL_DOWN, + UP, + MAINTENANCE, + DOWN, + INCIDENT_PAGE_SIZE, +} = require("../../src/util"); class StatusPage extends BeanModel { /** @@ -300,10 +309,12 @@ class StatusPage extends BeanModel { const config = await statusPage.toPublicJSON(); // All active incidents - let incidents = await R.find("incident", " pin = 1 AND active = 1 AND status_page_id = ? ORDER BY created_date DESC", [ - statusPage.id, - ]); - incidents = incidents.map(i => i.toPublicJSON()); + let incidents = await R.find( + "incident", + " pin = 1 AND active = 1 AND status_page_id = ? ORDER BY created_date DESC", + [statusPage.id] + ); + incidents = incidents.map((i) => i.toPublicJSON()); let maintenanceList = await StatusPage.getMaintenanceList(statusPage.id); @@ -500,18 +511,19 @@ class StatusPage extends BeanModel { static async getIncidentHistory(statusPageId, page, isPublic = true) { const offset = (page - 1) * INCIDENT_PAGE_SIZE; - const incidents = await R.find("incident", - " status_page_id = ? ORDER BY created_date DESC LIMIT ? OFFSET ? ", - [ statusPageId, INCIDENT_PAGE_SIZE, offset ] - ); + const incidents = await R.find("incident", " status_page_id = ? ORDER BY created_date DESC LIMIT ? OFFSET ? ", [ + statusPageId, + INCIDENT_PAGE_SIZE, + offset, + ]); - const total = await R.count("incident", " status_page_id = ? ", [ statusPageId ]); + const total = await R.count("incident", " status_page_id = ? ", [statusPageId]); return { - incidents: incidents.map(i => isPublic ? i.toPublicJSON() : i.toJSON()), + incidents: incidents.map((i) => (isPublic ? i.toPublicJSON() : i.toJSON())), total, page, - totalPages: Math.ceil(total / INCIDENT_PAGE_SIZE) + totalPages: Math.ceil(total / INCIDENT_PAGE_SIZE), }; } diff --git a/server/routers/status-page-router.js b/server/routers/status-page-router.js index 47753f32d..7d80175c8 100644 --- a/server/routers/status-page-router.js +++ b/server/routers/status-page-router.js @@ -159,7 +159,7 @@ router.get("/api/status-page/:slug/incident-history", cache("5 minutes"), async const result = await StatusPage.getIncidentHistory(statusPageID, page, true); response.json({ ok: true, - ...result + ...result, }); } catch (error) { sendHttpError(response, error.message); diff --git a/server/socket-handlers/status-page-socket-handler.js b/server/socket-handlers/status-page-socket-handler.js index 45bed41c0..848441d9a 100644 --- a/server/socket-handlers/status-page-socket-handler.js +++ b/server/socket-handlers/status-page-socket-handler.js @@ -111,7 +111,7 @@ module.exports.statusPageSocketHandler = (socket) => { const result = await StatusPage.getIncidentHistory(statusPageID, page, false); callback({ ok: true, - ...result + ...result, }); } catch (error) { callback({ @@ -131,7 +131,7 @@ module.exports.statusPageSocketHandler = (socket) => { const result = await StatusPage.getIncidentHistory(statusPageID, page, true); callback({ ok: true, - ...result + ...result, }); } catch (error) { callback({ @@ -150,17 +150,17 @@ module.exports.statusPageSocketHandler = (socket) => { callback({ ok: false, msg: "slug is not found", - msgi18n: true + msgi18n: true, }); return; } - let bean = await R.findOne("incident", " id = ? AND status_page_id = ? ", [ incidentID, statusPageID ]); + let bean = await R.findOne("incident", " id = ? AND status_page_id = ? ", [incidentID, statusPageID]); if (!bean) { callback({ ok: false, msg: "Incident not found or access denied", - msgi18n: true + msgi18n: true, }); return; } @@ -171,12 +171,12 @@ module.exports.statusPageSocketHandler = (socket) => { callback({ ok: false, msg: e.message, - msgi18n: true + msgi18n: true, }); return; } - const validStyles = [ "info", "warning", "danger", "primary", "light", "dark" ]; + const validStyles = ["info", "warning", "danger", "primary", "light", "dark"]; if (!validStyles.includes(incident.style)) { incident.style = "warning"; } @@ -213,17 +213,17 @@ module.exports.statusPageSocketHandler = (socket) => { callback({ ok: false, msg: "slug is not found", - msgi18n: true + msgi18n: true, }); return; } - let bean = await R.findOne("incident", " id = ? AND status_page_id = ? ", [ incidentID, statusPageID ]); + let bean = await R.findOne("incident", " id = ? AND status_page_id = ? ", [incidentID, statusPageID]); if (!bean) { callback({ ok: false, msg: "Incident not found or access denied", - msgi18n: true + msgi18n: true, }); return; } @@ -253,17 +253,17 @@ module.exports.statusPageSocketHandler = (socket) => { callback({ ok: false, msg: "slug is not found", - msgi18n: true + msgi18n: true, }); return; } - let bean = await R.findOne("incident", " id = ? AND status_page_id = ? ", [ incidentID, statusPageID ]); + let bean = await R.findOne("incident", " id = ? AND status_page_id = ? ", [incidentID, statusPageID]); if (!bean) { callback({ ok: false, msg: "Incident not found or access denied", - msgi18n: true + msgi18n: true, }); return; } diff --git a/src/components/IncidentEditForm.vue b/src/components/IncidentEditForm.vue index c8ecbaf07..08597dfb3 100644 --- a/src/components/IncidentEditForm.vue +++ b/src/components/IncidentEditForm.vue @@ -51,12 +51,36 @@ {{ $t("Style") }}: {{ $t(modelValue.style) }}
@@ -72,15 +96,15 @@ export default { required: true, }, }, - emits: [ "update:modelValue", "post", "cancel" ], + emits: ["update:modelValue", "post", "cancel"], methods: { updateField(field, value) { this.$emit("update:modelValue", { ...this.modelValue, - [field]: value + [field]: value, }); - } - } + }, + }, }; diff --git a/src/components/IncidentHistory.vue b/src/components/IncidentHistory.vue index 0a599ef15..8931bd8ee 100644 --- a/src/components/IncidentHistory.vue +++ b/src/components/IncidentHistory.vue @@ -15,7 +15,7 @@ v-for="incident in incidents" :key="incident.id" class="incident-item" - :class="{ 'resolved': !incident.active }" + :class="{ resolved: !incident.active }" >