]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Added extended PiHole statistics
authorBram Ceulemans <bramceulemans@me.com>
Tue, 8 Dec 2020 12:20:26 +0000 (13:20 +0100)
committerBram Ceulemans <bramceulemans@me.com>
Tue, 8 Dec 2020 12:26:18 +0000 (13:26 +0100)
docs/configuration.md
src/components/services/PiHole.vue

index 681d62a3ece637cc6290779aec94f4a5527f082b..a43d7f1d99f8eff942b0df0d30789c5adf0cd840 100644 (file)
@@ -109,7 +109,7 @@ services:
     items:
       - name: "Pi-hole"
         logo: "assets/tools/sample.png"
-        subtitle: "Network-wide Ad Blocking"
+        # subtitle: "Network-wide Ad Blocking" # optional, if no subtitle is defined, PiHole statistics will be shown
         tag: "other"
         url: "http://192.168.0.151/admin"
         type: "PiHole" # optional, loads a specific component that provides extra features. MUST MATCH a file name (without file extension) available in `src/components/services`
index c08e1fab44788b44ce8e35c18e8798d05992029f..47b1261d0164e59c54956492abd958ac6cc88ad6 100644 (file)
             </div>
             <div v-if="item.icon" class="media-left">
               <figure class="image is-48x48">
-                <i style="font-size: 35px;" :class="['fa-fw', item.icon]"></i>
+                <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i>
               </figure>
             </div>
             <div class="media-content">
               <p class="title is-4">{{ item.name }}</p>
-              <p class="subtitle is-6">{{ item.subtitle }}</p>
+              <p class="subtitle is-6">
+                <template v-if="item.subtitle">
+                  {{ item.subtitle }}
+                </template>
+                <template v-else-if="status">
+                  {{ percentage }}% blocked
+                </template>
+              </p>
             </div>
             <div v-if="status" class="status" :class="status.status">
               {{ status.status }}
@@ -42,6 +49,20 @@ export default {
       status: null,
     };
   },
+  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);
+      }
+      return "";
+    },
+  },
   created: function () {
     this.fetchStatus();
   },
@@ -66,13 +87,13 @@ export default {
   &.enabled:before {
     background-color: #94e185;
     border-color: #78d965;
-    box-shadow: 0px 0px 4px 1px #94e185;
+    box-shadow: 0 0 4px 1px #94e185;
   }
 
   &.disabled:before {
     background-color: #c9404d;
     border-color: #c42c3b;
-    box-shadow: 0px 0px 4px 1px #c9404d;
+    box-shadow: 0 0 4px 1px #c9404d;
   }
 
   &:before {