From 5418c6291a39d27aeee471673adba742080e1ccb Mon Sep 17 00:00:00 2001 From: Bastien Wirtz Date: Sun, 18 Sep 2022 16:29:55 +0200 Subject: Fix UptimeKuma status message when all sites are down #503 --- src/App.vue | 4 +++- src/components/services/UptimeKuma.vue | 24 +++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/App.vue b/src/App.vue index 5ab5c0d..f2089ee 100644 --- a/src/App.vue +++ b/src/App.vue @@ -207,7 +207,9 @@ export default { this.currentPage = window.location.hash.substring(1) || "default"; if (this.currentPage !== "default") { - let pageConfig = await this.getConfig(`assets/${this.currentPage}.yml`); + let pageConfig = await this.getConfig( + `assets/${this.currentPage}.yml` + ); config = Object.assign(config, pageConfig); } } catch (error) { diff --git a/src/components/services/UptimeKuma.vue b/src/components/services/UptimeKuma.vue index 5117a05..55232af 100644 --- a/src/components/services/UptimeKuma.vue +++ b/src/components/services/UptimeKuma.vue @@ -85,9 +85,22 @@ export default { if (this.incident.incident) { return this.incident.incident.title; } - return this.pageStatus == "warn" - ? "Partially Degraded Service" - : "All Systems Operational"; + + let message = ""; + switch (this.pageStatus) { + case "good": + message = "All Systems Operational"; + break; + case "warn": + message = "Partially Degraded Service"; + break; + case "bad": + message = "Degraded Service"; + break; + default: + message = "Unknown service status"; + } + return message; }, uptime: function () { if (!this.heartbeat) { @@ -105,12 +118,13 @@ export default { }, methods: { fetchStatus: function () { - this.fetch(`/api/status-page/${this.dashboard}?cachebust=${Date.now()}`) + const now = Date.now() + this.fetch(`/api/status-page/${this.dashboard}?cachebust=${now}`) .catch((e) => console.error(e)) .then((resp) => (this.incident = resp)); this.fetch( - `/api/status-page/heartbeat/${this.dashboard}?cachebust=${Date.now()}` + `/api/status-page/heartbeat/${this.dashboard}?cachebust=${now}` ) .catch((e) => console.error(e)) .then((resp) => (this.heartbeat = resp)); -- cgit v1.2.3