diff options
Diffstat (limited to 'src/components/services/AdGuardHome.vue')
-rw-r--r-- | src/components/services/AdGuardHome.vue | 98 |
1 files changed, 61 insertions, 37 deletions
diff --git a/src/components/services/AdGuardHome.vue b/src/components/services/AdGuardHome.vue index d4a2b89..16881fa 100644 --- a/src/components/services/AdGuardHome.vue +++ b/src/components/services/AdGuardHome.vue | |||
@@ -1,59 +1,77 @@ | |||
1 | <template> | 1 | <template> |
2 | <div> | 2 | <Generic :item="item"> |
3 | <div class="card" :class="item.class"> | 3 | <template #content> |
4 | <a :href="item.url" :target="item.target" rel="noreferrer"> | 4 | <p class="title is-4">{{ item.name }}</p> |
5 | <div class="card-content"> | 5 | <p class="subtitle is-6"> |
6 | <div class="media"> | 6 | <template v-if="item.subtitle"> |
7 | <div v-if="item.logo" class="media-left"> | 7 | {{ item.subtitle }} |
8 | <figure class="image is-48x48"> | 8 | </template> |
9 | <img :src="item.logo" :alt="`${item.name} logo`" /> | 9 | <template v-else-if="stats"> |
10 | </figure> | 10 | {{ percentage }}% blocked |
11 | </div> | 11 | </template> |
12 | <div v-if="item.icon" class="media-left"> | 12 | </p> |
13 | <figure class="image is-48x48"> | 13 | </template> |
14 | <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i> | 14 | <template #indicator> |
15 | </figure> | 15 | <div class="status" :class="protection"> |
16 | </div> | 16 | {{ protection }} |
17 | <div class="media-content"> | 17 | </div> |
18 | <p class="title is-4">{{ item.name }}</p> | 18 | </template> |
19 | <p class="subtitle is-6">{{ item.subtitle }}</p> | 19 | </Generic> |
20 | </div> | ||
21 | <div | ||
22 | v-if="status" | ||
23 | class="status" | ||
24 | v-bind:class="status.protection_enabled ? 'enabled' : 'disabled'" | ||
25 | > | ||
26 | {{ status.protection_enabled }} | ||
27 | </div> | ||
28 | </div> | ||
29 | <div class="tag" :class="item.tagstyle" v-if="item.tag"> | ||
30 | <strong class="tag-text">#{{ item.tag }}</strong> | ||
31 | </div> | ||
32 | </div> | ||
33 | </a> | ||
34 | </div> | ||
35 | </div> | ||
36 | </template> | 20 | </template> |
37 | 21 | ||
38 | <script> | 22 | <script> |
23 | import Generic from "./Generic.vue"; | ||
24 | |||
39 | export default { | 25 | export default { |
40 | name: "AdGuardHome", | 26 | name: "AdGuardHome", |
41 | props: { | 27 | props: { |
42 | item: Object, | 28 | item: Object, |
43 | }, | 29 | }, |
30 | components: { | ||
31 | Generic, | ||
32 | }, | ||
44 | data: () => { | 33 | data: () => { |
45 | return { | 34 | return { |
46 | status: null, | 35 | status: null, |
36 | stats: null, | ||
47 | }; | 37 | }; |
48 | }, | 38 | }, |
39 | computed: { | ||
40 | percentage: function () { | ||
41 | if (this.stats) { | ||
42 | return ( | ||
43 | (this.stats.num_blocked_filtering * 100) / | ||
44 | this.stats.num_dns_queries | ||
45 | ).toFixed(2); | ||
46 | } | ||
47 | return ""; | ||
48 | }, | ||
49 | protection: function () { | ||
50 | if (this.status) { | ||
51 | return this.status.protection_enabled ? "enabled" : "disabled"; | ||
52 | } else return "unknown"; | ||
53 | }, | ||
54 | }, | ||
49 | created: function () { | 55 | created: function () { |
50 | this.fetchStatus(); | 56 | this.fetchStatus(); |
57 | if (!this.item.subtitle) { | ||
58 | this.fetchStats(); | ||
59 | } | ||
51 | }, | 60 | }, |
52 | methods: { | 61 | methods: { |
53 | fetchStatus: async function () { | 62 | fetchStatus: async function () { |
54 | this.status = await fetch(`${this.item.url}/control/status`).then( | 63 | this.status = await fetch(`${this.item.url}/control/status`, { |
55 | (response) => response.json() | 64 | credentials: "include", |
56 | ); | 65 | }) |
66 | .then((response) => response.json()) | ||
67 | .catch((e) => console.log(e)); | ||
68 | }, | ||
69 | fetchStats: async function () { | ||
70 | this.stats = await fetch(`${this.item.url}/control/stats`, { | ||
71 | credentials: "include", | ||
72 | }) | ||
73 | .then((response) => response.json()) | ||
74 | .catch((e) => console.log(e)); | ||
57 | }, | 75 | }, |
58 | }, | 76 | }, |
59 | }; | 77 | }; |
@@ -79,6 +97,12 @@ export default { | |||
79 | box-shadow: 0px 0px 4px 1px #c9404d; | 97 | box-shadow: 0px 0px 4px 1px #c9404d; |
80 | } | 98 | } |
81 | 99 | ||
100 | &.unknown:before { | ||
101 | background-color: #c9c740; | ||
102 | border-color: #ccc935; | ||
103 | box-shadow: 0px 0px 4px 1px #c9c740; | ||
104 | } | ||
105 | |||
82 | &:before { | 106 | &:before { |
83 | content: " "; | 107 | content: " "; |
84 | display: inline-block; | 108 | display: inline-block; |