X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2Fservices%2FPiHole.vue;h=87f7090d4ad8b16f47b5a2285db872f8102074ba;hb=33d60aa76a975f26733e45f7652a03088f32c812;hp=c08e1fab44788b44ce8e35c18e8798d05992029f;hpb=9a14de007e7c8d04ce708f8df1300ac8070d85df;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/services/PiHole.vue b/src/components/services/PiHole.vue index c08e1fa..87f7090 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,31 @@ 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, { + credentials: "include", + }) + .then((response) => response.json()) + .catch((e) => console.log(e)); }, }, }; @@ -66,13 +85,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 {