]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Fixed wrongly removed computed property
authorBram Ceulemans <bramceulemans@me.com>
Wed, 9 Dec 2020 23:05:30 +0000 (00:05 +0100)
committerBram Ceulemans <bramceulemans@me.com>
Wed, 9 Dec 2020 23:05:30 +0000 (00:05 +0100)
src/components/services/PiHole.vue

index 10d5ece9e25327341e8a0df5cc70fbd750b1dd68..03d3ae30e1d90495858bb59d6eb87b066f1d6d92 100644 (file)
@@ -21,7 +21,7 @@
                   {{ item.subtitle }}
                 </template>
                 <template v-else-if="status">
-                  {{ percentage }}% blocked
+                  {{ percentage }}&percnt; blocked
                 </template>
               </p>
             </div>
@@ -44,27 +44,29 @@ export default {
   props: {
     item: Object,
   },
-  data: () => {
-    return {
-      status: null,
-    };
-  },
+  data: () => ({
+    status: {
+      status: "",
+      ads_percentage_today: 0,
+    },
+  }),
   computed: {
-    blocked: function () {
+    percentage: function () {
       if (this.status) {
-        return this.status.dns_queries_today.toFixed(0);
+        return this.status.ads_percentage_today.toFixed(1);
       }
       return "";
     },
   },
-  created: function () {
+  created() {
     this.fetchStatus();
   },
   methods: {
     fetchStatus: async function () {
-      this.status = await fetch(`${this.item.url}/api.php`).then((response) =>
-        response.json()
-      );
+      const url = `${this.item.url}/api.php`;
+      this.status = await fetch(url)
+        .then((response) => response.json())
+        .catch((e) => console.log(e));
     },
   },
 };