aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2021-12-13 21:07:30 +0100
committerBastien Wirtz <bastien.wirtz@gmail.com>2021-12-13 21:07:30 +0100
commit8283b8da5a93c1141a247c3835678b4e2a2eba16 (patch)
tree2de980da39b95cc962bd177b7d139f3ef63ffe8f /src/components
parentb1c85864410e5a5515124125e387518d2fbb4c07 (diff)
downloadhomer-8283b8da5a93c1141a247c3835678b4e2a2eba16.tar.gz
homer-8283b8da5a93c1141a247c3835678b4e2a2eba16.tar.zst
homer-8283b8da5a93c1141a247c3835678b4e2a2eba16.zip
Make Lidaar component use the Generic base component
Diffstat (limited to 'src/components')
-rw-r--r--src/components/services/Lidarr.vue140
1 files changed, 50 insertions, 90 deletions
diff --git a/src/components/services/Lidarr.vue b/src/components/services/Lidarr.vue
index f5d3434..cbe5516 100644
--- a/src/components/services/Lidarr.vue
+++ b/src/components/services/Lidarr.vue
@@ -1,62 +1,40 @@
1<template> 1<template>
2 <div> 2 <Generic :item="item">
3 <div class="card" :class="item.class"> 3 <template #indicator>
4 <a :href="item.url" :target="item.target" rel="noreferrer"> 4 <div class="notifs">
5 <div class="card-content"> 5 <strong v-if="activity > 0" class="notif activity" title="Activity">
6 <div class="media"> 6 {{ activity }}
7 <div v-if="item.logo" class="media-left"> 7 </strong>
8 <figure class="image is-48x48"> 8 <strong v-if="warnings > 0" class="notif warnings" title="Warning">
9 <img :src="item.logo" :alt="`${item.name} logo`" /> 9 {{ warnings }}
10 </figure> 10 </strong>
11 </div> 11 <strong v-if="errors > 0" class="notif errors" title="Error">
12 <div v-if="item.icon" class="media-left"> 12 {{ errors }}
13 <figure class="image is-48x48"> 13 </strong>
14 <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i> 14 <strong
15 </figure> 15 v-if="serverError"
16 </div> 16 class="notif errors"
17 <div class="media-content"> 17 title="Connection error to Lidarr API, check url and apikey in config.yml"
18 <p class="title is-4">{{ item.name }}</p> 18 >?</strong
19 <p class="subtitle is-6">{{ item.subtitle }}</p> 19 >
20 </div> 20 </div>
21 <div class="notifs"> 21 </template>
22 <strong 22 </Generic>
23 v-if="activity > 0"
24 class="notif activity"
25 title="Activity"
26 >{{ activity }}</strong
27 >
28 <strong
29 v-if="warnings > 0"
30 class="notif warnings"
31 title="Warning"
32 >{{ warnings }}</strong
33 >
34 <strong v-if="errors > 0" class="notif errors" title="Error">{{
35 errors
36 }}</strong>
37 <strong
38 v-if="serverError"
39 class="notif errors"
40 title="Connection error to Lidarr API, check url and apikey in config.yml"
41 >?</strong
42 >
43 </div>
44 </div>
45 <div class="tag" :class="item.tagstyle" v-if="item.tag">
46 <strong class="tag-text">#{{ item.tag }}</strong>
47 </div>
48 </div>
49 </a>
50 </div>
51 </div>
52</template> 23</template>
53 24
54<script> 25<script>
26import service from "@/mixins/service.js";
27import Generic from "./Generic.vue";
28
55export default { 29export default {
56 name: "Lidarr", 30 name: "Lidarr",
31 mixins: [service],
57 props: { 32 props: {
58 item: Object, 33 item: Object,
59 }, 34 },
35 components: {
36 Generic,
37 },
60 data: () => { 38 data: () => {
61 return { 39 return {
62 activity: null, 40 activity: null,
@@ -70,15 +48,7 @@ export default {
70 }, 48 },
71 methods: { 49 methods: {
72 fetchConfig: function () { 50 fetchConfig: function () {
73 fetch(`${this.item.url}/api/v1/health?apikey=${this.item.apikey}`, { 51 this.fetch(`/api/v1/health?apikey=${this.item.apikey}`)
74 credentials: "include",
75 })
76 .then((response) => {
77 if (response.status != 200) {
78 throw new Error(response.statusText);
79 }
80 return response.json();
81 })
82 .then((health) => { 52 .then((health) => {
83 this.warnings = 0; 53 this.warnings = 0;
84 this.errors = 0; 54 this.errors = 0;
@@ -94,15 +64,7 @@ export default {
94 console.error(e); 64 console.error(e);
95 this.serverError = true; 65 this.serverError = true;
96 }); 66 });
97 fetch(`${this.item.url}/api/v1/queue/status?apikey=${this.item.apikey}`, { 67 this.fetch(`/api/v1/queue/status?apikey=${this.item.apikey}`)
98 credentials: "include",
99 })
100 .then((response) => {
101 if (response.status != 200) {
102 throw new Error(response.statusText);
103 }
104 return response.json();
105 })
106 .then((queue) => { 68 .then((queue) => {
107 this.activity = queue.totalCount; 69 this.activity = queue.totalCount;
108 }) 70 })
@@ -116,35 +78,33 @@ export default {
116</script> 78</script>
117 79
118<style scoped lang="scss"> 80<style scoped lang="scss">
119.media-left img {
120 max-height: 100%;
121}
122.notifs { 81.notifs {
123 position: absolute; 82 position: absolute;
124 color: white; 83 color: white;
125 font-family: sans-serif; 84 font-family: sans-serif;
126 top: 0.3em; 85 top: 0.3em;
127 right: 0.5em; 86 right: 0.5em;
128} 87 .notif {
129.notif { 88 display: inline-block;
130 padding-right: 0.35em; 89 padding-right: 0.35em;
131 padding-left: 0.35em; 90 padding-left: 0.35em;
132 padding-top: 0.2em; 91 padding-top: 0.2em;
133 padding-bottom: 0.2em; 92 padding-bottom: 0.2em;
134 border-radius: 0.25em; 93 border-radius: 0.25em;
135 position: relative; 94 position: relative;
136 margin-left: 0.3em; 95 margin-left: 0.3em;
137 font-size: 0.8em; 96 font-size: 0.8em;
138} 97 &.activity {
139.activity { 98 background-color: #4fb5d6;
140 background-color: #4fb5d6; 99 }
141}
142 100
143.warnings { 101 &.warnings {
144 background-color: #d08d2e; 102 background-color: #d08d2e;
145} 103 }
146 104
147.errors { 105 &.errors {
148 background-color: #e51111; 106 background-color: #e51111;
107 }
108 }
149} 109}
150</style> 110</style>