aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/services/AdGuardHome.vue
diff options
context:
space:
mode:
authorAndreas Waschinski <25221082+waschinski@users.noreply.github.com>2021-07-10 09:58:17 +0200
committerAndreas Waschinski <25221082+waschinski@users.noreply.github.com>2021-07-10 09:58:17 +0200
commitbebb6953cb1e5b61be000b3f2d76a27256bff3d9 (patch)
treed6087f6fe81b755debaad7c17875129022007e81 /src/components/services/AdGuardHome.vue
parent3832025b0c404498c798148f1e7c52f34dce372a (diff)
downloadhomer-bebb6953cb1e5b61be000b3f2d76a27256bff3d9.tar.gz
homer-bebb6953cb1e5b61be000b3f2d76a27256bff3d9.tar.zst
homer-bebb6953cb1e5b61be000b3f2d76a27256bff3d9.zip
Adding status "unknown"
Changing code as per linter
Diffstat (limited to 'src/components/services/AdGuardHome.vue')
-rw-r--r--src/components/services/AdGuardHome.vue48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/components/services/AdGuardHome.vue b/src/components/services/AdGuardHome.vue
index 0c689b9..9aeaf39 100644
--- a/src/components/services/AdGuardHome.vue
+++ b/src/components/services/AdGuardHome.vue
@@ -25,12 +25,8 @@
25 </template> 25 </template>
26 </p> 26 </p>
27 </div> 27 </div>
28 <div 28 <div v-if="!item.subtitle" class="status" :class="protection">
29 v-if="status" 29 {{ protection }}
30 class="status"
31 v-bind:class="status.protection_enabled ? 'enabled' : 'disabled'"
32 >
33 {{ status.protection_enabled ? 'enabled' : 'disabled' }}
34 </div> 30 </div>
35 </div> 31 </div>
36 <div class="tag" :class="item.tagstyle" v-if="item.tag"> 32 <div class="tag" :class="item.tagstyle" v-if="item.tag">
@@ -57,10 +53,18 @@ export default {
57 computed: { 53 computed: {
58 percentage: function () { 54 percentage: function () {
59 if (this.stats) { 55 if (this.stats) {
60 return (this.stats.num_blocked_filtering * 100 / this.stats.num_dns_queries).toFixed(2); 56 return (
57 (this.stats.num_blocked_filtering * 100) /
58 this.stats.num_dns_queries
59 ).toFixed(2);
61 } 60 }
62 return ""; 61 return "";
63 }, 62 },
63 protection: function () {
64 if (this.status) {
65 return this.status.protection_enabled ? "enabled" : "disabled";
66 } else return "unknown";
67 },
64 }, 68 },
65 created: function () { 69 created: function () {
66 this.fetchStatus(); 70 this.fetchStatus();
@@ -70,22 +74,18 @@ export default {
70 }, 74 },
71 methods: { 75 methods: {
72 fetchStatus: async function () { 76 fetchStatus: async function () {
73 this.status = await fetch( 77 this.status = await fetch(`${this.item.url}/control/status`, {
74 `${this.item.url}/control/status`, 78 credentials: "include",
75 { 79 })
76 credentials: 'include' 80 .then((response) => response.json())
77 } 81 .catch((e) => console.log(e));
78 ).then((response) => response.json())
79 .catch((e) => console.log(e));
80 }, 82 },
81 fetchStats: async function () { 83 fetchStats: async function () {
82 this.stats = await fetch( 84 this.stats = await fetch(`${this.item.url}/control/stats`, {
83 `${this.item.url}/control/stats`, 85 credentials: "include",
84 { 86 })
85 credentials: 'include' 87 .then((response) => response.json())
86 } 88 .catch((e) => console.log(e));
87 ).then((response) => response.json())
88 .catch((e) => console.log(e));
89 }, 89 },
90 }, 90 },
91}; 91};
@@ -111,6 +111,12 @@ export default {
111 box-shadow: 0px 0px 4px 1px #c9404d; 111 box-shadow: 0px 0px 4px 1px #c9404d;
112 } 112 }
113 113
114 &.unknown:before {
115 background-color: #c9c740;
116 border-color: #ccc935;
117 box-shadow: 0px 0px 4px 1px #c9c740;
118 }
119
114 &:before { 120 &:before {
115 content: " "; 121 content: " ";
116 display: inline-block; 122 display: inline-block;