X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcomponents%2Fservices%2FPiHole.vue;h=a9fd369c2a87ba30bc048f352aeab276f4dac187;hb=90d6bc67c0cabf9950a21e798af5e2cf604541e7;hp=10d5ece9e25327341e8a0df5cc70fbd750b1dd68;hpb=273a268ac4b9637e28522e2a9f6d543c43761380;p=github%2Fbastienwirtz%2Fhomer.git
diff --git a/src/components/services/PiHole.vue b/src/components/services/PiHole.vue
index 10d5ece..a9fd369 100644
--- a/src/components/services/PiHole.vue
+++ b/src/components/services/PiHole.vue
@@ -20,13 +20,13 @@
{{ item.subtitle }}
-
- {{ percentage }}% blocked
+
+ {{ percentage }}% blocked
-
- {{ status.status }}
+
+ {{ api.status }}
@@ -44,27 +44,29 @@ export default {
props: {
item: Object,
},
- data: () => {
- return {
- status: null,
- };
- },
+ data: () => ({
+ api: {
+ status: "",
+ ads_percentage_today: 0,
+ },
+ }),
computed: {
- blocked: function () {
- if (this.status) {
- return this.status.dns_queries_today.toFixed(0);
+ percentage: function () {
+ 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)
+ .then((response) => response.json())
+ .catch((e) => console.log(e));
},
},
};