From f81dc6f4888dbb64c7f86972016c1a7cb750fe99 Mon Sep 17 00:00:00 2001 From: Bram Ceulemans Date: Thu, 10 Dec 2020 00:05:30 +0100 Subject: Fixed wrongly removed computed property --- src/components/services/PiHole.vue | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/services/PiHole.vue b/src/components/services/PiHole.vue index 10d5ece..03d3ae3 100644 --- a/src/components/services/PiHole.vue +++ b/src/components/services/PiHole.vue @@ -21,7 +21,7 @@ {{ item.subtitle }}

@@ -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)); }, }, }; -- cgit v1.2.3