]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - src/components/services/UptimeKuma.vue
Fix UptimeKuma status message when all sites are down #503
[github/bastienwirtz/homer.git] / src / components / services / UptimeKuma.vue
index 5117a059671e4b536e93a3188a51c38ad819a06d..55232af3ffc094e0c0568dd1561b6580d90d303a 100644 (file)
@@ -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));