]>
Commit | Line | Data |
---|---|---|
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"> | |
14 | <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i> | |
15 | </figure> | |
16 | </div> | |
17 | <div class="media-content"> | |
18 | <p class="title is-4">{{ item.name }}</p> | |
19 | <p class="subtitle is-6"> | |
20 | <template v-if="item.subtitle"> | |
21 | {{ item.subtitle }} | |
22 | </template> | |
23 | <template v-else-if="api"> | |
24 | {{ percentage }}% blocked | |
25 | </template> | |
26 | </p> | |
27 | </div> | |
28 | <div v-if="api" class="status" :class="api.status"> | |
29 | {{ api.status }} | |
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 | }, | |
47 | data: () => ({ | |
48 | api: { | |
49 | status: "", | |
50 | ads_percentage_today: 0, | |
51 | }, | |
52 | }), | |
53 | computed: { | |
54 | percentage: function () { | |
55 | if (this.api) { | |
56 | return this.api.ads_percentage_today.toFixed(1); | |
57 | } | |
58 | return ""; | |
59 | }, | |
60 | }, | |
61 | created() { | |
62 | this.fetchStatus(); | |
63 | }, | |
64 | methods: { | |
65 | fetchStatus: async function () { | |
66 | const url = `${this.item.url}/api.php`; | |
67 | this.api = await fetch(url) | |
68 | .then((response) => response.json()) | |
69 | .catch((e) => console.log(e)); | |
70 | }, | |
71 | }, | |
72 | }; | |
73 | </script> | |
74 | ||
75 | <style scoped lang="scss"> | |
76 | .media-left img { | |
77 | max-height: 100%; | |
78 | } | |
79 | .status { | |
80 | font-size: 0.8rem; | |
81 | color: var(--text-title); | |
82 | ||
83 | &.enabled:before { | |
84 | background-color: #94e185; | |
85 | border-color: #78d965; | |
86 | box-shadow: 0 0 5px 1px #94e185; | |
87 | } | |
88 | ||
89 | &.disabled:before { | |
90 | background-color: #c9404d; | |
91 | border-color: #c42c3b; | |
92 | box-shadow: 0 0 5px 1px #c9404d; | |
93 | } | |
94 | ||
95 | &:before { | |
96 | content: " "; | |
97 | display: inline-block; | |
98 | width: 7px; | |
99 | height: 7px; | |
100 | margin-right: 10px; | |
101 | border: 1px solid #000; | |
102 | border-radius: 7px; | |
103 | } | |
104 | } | |
105 | </style> |