]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Fix UptimeKuma status message when all sites are down #503
authorBastien Wirtz <bastien.wirtz@gmail.com>
Sun, 18 Sep 2022 14:29:55 +0000 (16:29 +0200)
committerBastien Wirtz <bastien.wirtz@gmail.com>
Sun, 18 Sep 2022 14:30:32 +0000 (16:30 +0200)
src/App.vue
src/components/services/UptimeKuma.vue

index 5ab5c0d81e6b5da5fbc590cececf25ba8db3e5ba..f2089ee0290d92b2061c4d297c3c15859bba0503 100644 (file)
@@ -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) {
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));