]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - src/components/services/PiHole.vue
Update AdGuardHome.vue
[github/bastienwirtz/homer.git] / src / components / services / PiHole.vue
index 47b1261d0164e59c54956492abd958ac6cc88ad6..ce0b68928afffa11aad883e342afce099b58e420 100644 (file)
                 <template v-if="item.subtitle">
                   {{ item.subtitle }}
                 </template>
-                <template v-else-if="status">
-                  {{ percentage }}% blocked
+                <template v-else-if="api">
+                  {{ percentage }}&percnt; blocked
                 </template>
               </p>
             </div>
-            <div v-if="status" class="status" :class="status.status">
-              {{ status.status }}
+            <div v-if="api" class="status" :class="api.status">
+              {{ api.status }}
             </div>
           </div>
           <div class="tag" :class="item.tagstyle" v-if="item.tag">
@@ -44,33 +44,31 @@ export default {
   props: {
     item: Object,
   },
-  data: () => {
-    return {
-      status: null,
-    };
-  },
+  data: () => ({
+    api: {
+      status: "",
+      ads_percentage_today: 0,
+    },
+  }),
   computed: {
     percentage: function () {
-      if (this.status) {
-        return this.status.ads_percentage_today.toFixed(1);
-      }
-      return "";
-    },
-    blocked: function () {
-      if (this.status) {
-        return this.status.dns_queries_today.toFixed(0);
+      if (this.api) {
+        return this.api.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.api = await fetch(url{
+        credentials: 'include'
+      })
+        .then((response) => response.json())
+        .catch((e) => console.log(e));
     },
   },
 };
@@ -87,13 +85,13 @@ export default {
   &.enabled:before {
     background-color: #94e185;
     border-color: #78d965;
-    box-shadow: 0 0 4px 1px #94e185;
+    box-shadow: 0 0 5px 1px #94e185;
   }
 
   &.disabled:before {
     background-color: #c9404d;
     border-color: #c42c3b;
-    box-shadow: 0 0 4px 1px #c9404d;
+    box-shadow: 0 0 5px 1px #c9404d;
   }
 
   &:before {