X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2Fservices%2FPiHole.vue;h=7042a7b2a5055662e7434bead008af4036a6e934;hb=1ed0a2f387ebe3f0d0aef590087e351b9534efc0;hp=c08e1fab44788b44ce8e35c18e8798d05992029f;hpb=5b727eee020b9d734f60fd37f840ea47f83fb23e;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/services/PiHole.vue b/src/components/services/PiHole.vue index c08e1fa..7042a7b 100644 --- a/src/components/services/PiHole.vue +++ b/src/components/services/PiHole.vue @@ -11,15 +11,22 @@
- +

{{ item.name }}

-

{{ item.subtitle }}

+

+ + +

-
- {{ status.status }} +
+ {{ api.status }}
@@ -37,19 +44,29 @@ export default { props: { item: Object, }, - data: () => { - return { - status: null, - }; + data: () => ({ + api: { + status: "", + ads_percentage_today: 0, + }, + }), + computed: { + 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)); }, }, }; @@ -66,13 +83,13 @@ export default { &.enabled:before { background-color: #94e185; border-color: #78d965; - box-shadow: 0px 0px 4px 1px #94e185; + box-shadow: 0 0 5px 1px #94e185; } &.disabled:before { background-color: #c9404d; border-color: #c42c3b; - box-shadow: 0px 0px 4px 1px #c9404d; + box-shadow: 0 0 5px 1px #c9404d; } &:before {