X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2Fservices%2FPiHole.vue;h=a9fd369c2a87ba30bc048f352aeab276f4dac187;hb=551e32e2035c58dd1be0d5f57a648772819f66de;hp=47b1261d0164e59c54956492abd958ac6cc88ad6;hpb=c5eab80d765ab03155399ce669c25cc17eb736c9;p=github%2Fbastienwirtz%2Fhomer.git
diff --git a/src/components/services/PiHole.vue b/src/components/services/PiHole.vue
index 47b1261..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,33 +44,29 @@ 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)
+ .then((response) => response.json())
+ .catch((e) => console.log(e));
},
},
};