]>
Commit | Line | Data |
---|---|---|
9a14de00 BW |
1 | <template> |
2 | <div> | |
3 | <div class="card" :class="item.class"> | |
4 | <a :href="item.url" :target="item.target" rel="noreferrer"> | |
5 | <div class="card-content"> | |
6 | <div class="media"> | |
7 | <div v-if="item.logo" class="media-left"> | |
8 | <figure class="image is-48x48"> | |
9 | <img :src="item.logo" :alt="`${item.name} logo`" /> | |
10 | </figure> | |
11 | </div> | |
12 | <div v-if="item.icon" class="media-left"> | |
13 | <figure class="image is-48x48"> | |
c5eab80d | 14 | <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i> |
9a14de00 BW |
15 | </figure> |
16 | </div> | |
17 | <div class="media-content"> | |
18 | <p class="title is-4">{{ item.name }}</p> | |
c5eab80d BC |
19 | <p class="subtitle is-6"> |
20 | <template v-if="item.subtitle"> | |
21 | {{ item.subtitle }} | |
22 | </template> | |
4ce53b68 | 23 | <template v-else-if="api"> |
f81dc6f4 | 24 | {{ percentage }}% blocked |
c5eab80d BC |
25 | </template> |
26 | </p> | |
9a14de00 | 27 | </div> |
4ce53b68 BC |
28 | <div v-if="api" class="status" :class="api.status"> |
29 | {{ api.status }} | |
9a14de00 BW |
30 | </div> |
31 | </div> | |
32 | <div class="tag" :class="item.tagstyle" v-if="item.tag"> | |
33 | <strong class="tag-text">#{{ item.tag }}</strong> | |
34 | </div> | |
35 | </div> | |
36 | </a> | |
37 | </div> | |
38 | </div> | |
39 | </template> | |
40 | ||
41 | <script> | |
42 | export default { | |
43 | name: "PiHole", | |
44 | props: { | |
45 | item: Object, | |
46 | }, | |
f81dc6f4 | 47 | data: () => ({ |
4ce53b68 | 48 | api: { |
f81dc6f4 BC |
49 | status: "", |
50 | ads_percentage_today: 0, | |
51 | }, | |
52 | }), | |
c5eab80d | 53 | computed: { |
f81dc6f4 | 54 | percentage: function () { |
4ce53b68 BC |
55 | if (this.api) { |
56 | return this.api.ads_percentage_today.toFixed(1); | |
c5eab80d BC |
57 | } |
58 | return ""; | |
59 | }, | |
60 | }, | |
f81dc6f4 | 61 | created() { |
9a14de00 BW |
62 | this.fetchStatus(); |
63 | }, | |
64 | methods: { | |
65 | fetchStatus: async function () { | |
f81dc6f4 | 66 | const url = `${this.item.url}/api.php`; |
ecec6952 C |
67 | this.api = await fetch(url{ |
68 | credentials: 'include' | |
69 | }) | |
f81dc6f4 BC |
70 | .then((response) => response.json()) |
71 | .catch((e) => console.log(e)); | |
9a14de00 BW |
72 | }, |
73 | }, | |
74 | }; | |
75 | </script> | |
76 | ||
77 | <style scoped lang="scss"> | |
78 | .media-left img { | |
79 | max-height: 100%; | |
80 | } | |
81 | .status { | |
82 | font-size: 0.8rem; | |
83 | color: var(--text-title); | |
84 | ||
85 | &.enabled:before { | |
86 | background-color: #94e185; | |
87 | border-color: #78d965; | |
3a8fa151 | 88 | box-shadow: 0 0 5px 1px #94e185; |
9a14de00 BW |
89 | } |
90 | ||
91 | &.disabled:before { | |
92 | background-color: #c9404d; | |
93 | border-color: #c42c3b; | |
3a8fa151 | 94 | box-shadow: 0 0 5px 1px #c9404d; |
9a14de00 BW |
95 | } |
96 | ||
97 | &:before { | |
98 | content: " "; | |
99 | display: inline-block; | |
100 | width: 7px; | |
101 | height: 7px; | |
102 | margin-right: 10px; | |
103 | border: 1px solid #000; | |
104 | border-radius: 7px; | |
105 | } | |
106 | } | |
107 | </style> |