aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/services/Radarr.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/services/Radarr.vue')
-rw-r--r--src/components/services/Radarr.vue151
1 files changed, 151 insertions, 0 deletions
diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue
new file mode 100644
index 0000000..9d38292
--- /dev/null
+++ b/src/components/services/Radarr.vue
@@ -0,0 +1,151 @@
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">{{ item.subtitle }}</p>
20 </div>
21 <div class="notifs">
22 <strong
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 Radarr 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>
53
54<script>
55export default {
56 name: "Radarr",
57 props: {
58 item: Object,
59 },
60 data: () => {
61 return {
62 activity: null,
63 warnings: null,
64 errors: null,
65 serverError: false,
66 };
67 },
68 created: function () {
69 this.fetchConfig();
70 },
71 methods: {
72 fetchConfig: function () {
73 fetch(`${this.item.url}/api/health?apikey=${this.item.apikey}`)
74 .then((response) => {
75 if (response.status != 200) {
76 throw new Error(response.statusText);
77 }
78 return response.json();
79 })
80 .then((health) => {
81 this.warnings = 0;
82 this.errors = 0;
83 for (var i = 0; i < health.length; i++) {
84 if (health[i].type == "warning") {
85 this.warnings++;
86 } else if (health[i].type == "error") {
87 this.errors++;
88 }
89 }
90 })
91 .catch((e) => {
92 console.error(e);
93 this.serverError = true;
94 });
95 fetch(`${this.item.url}/api/queue?apikey=${this.item.apikey}`)
96 .then((response) => {
97 if (response.status != 200) {
98 throw new Error(response.statusText);
99 }
100 return response.json();
101 })
102 .then((queue) => {
103 this.activity = 0;
104 for (var i = 0; i < queue.length; i++) {
105 if (queue[i].movie) {
106 this.activity++;
107 }
108 }
109 })
110 .catch((e) => {
111 console.error(e);
112 this.serverError = true;
113 });
114 },
115 },
116};
117</script>
118
119<style scoped lang="scss">
120.media-left img {
121 max-height: 100%;
122}
123.notifs {
124 position: absolute;
125 color: white;
126 font-family: sans-serif;
127 top: 0.3em;
128 right: 0.5em;
129}
130.notif {
131 padding-right: 0.35em;
132 padding-left: 0.35em;
133 padding-top: 0.2em;
134 padding-bottom: 0.2em;
135 border-radius: 0.25em;
136 position: relative;
137 margin-left: 0.3em;
138 font-size: 0.8em;
139}
140.activity {
141 background-color: #4fb5d6;
142}
143
144.warnings {
145 background-color: #d08d2e;
146}
147
148.errors {
149 background-color: #e51111;
150}
151</style>