diff options
Diffstat (limited to 'src/components/services/Radarr.vue')
-rw-r--r-- | src/components/services/Radarr.vue | 156 |
1 files changed, 63 insertions, 93 deletions
diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue index a9cdedf..5c40aaa 100644 --- a/src/components/services/Radarr.vue +++ b/src/components/services/Radarr.vue | |||
@@ -1,62 +1,43 @@ | |||
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 Radarr 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 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> | 23 | </template> |
53 | 24 | ||
54 | <script> | 25 | <script> |
26 | import service from "@/mixins/service.js"; | ||
27 | import Generic from "./Generic.vue"; | ||
28 | |||
29 | const V3_API = "/api/v3"; | ||
30 | const LEGACY_API = "/api"; | ||
31 | |||
55 | export default { | 32 | export default { |
56 | name: "Radarr", | 33 | name: "Radarr", |
34 | mixins: [service], | ||
57 | props: { | 35 | props: { |
58 | item: Object, | 36 | item: Object, |
59 | }, | 37 | }, |
38 | components: { | ||
39 | Generic, | ||
40 | }, | ||
60 | data: () => { | 41 | data: () => { |
61 | return { | 42 | return { |
62 | activity: null, | 43 | activity: null, |
@@ -68,17 +49,14 @@ export default { | |||
68 | created: function () { | 49 | created: function () { |
69 | this.fetchConfig(); | 50 | this.fetchConfig(); |
70 | }, | 51 | }, |
52 | computed: { | ||
53 | apiPath() { | ||
54 | return this.item.legacyApi ? LEGACY_API : V3_API; | ||
55 | }, | ||
56 | }, | ||
71 | methods: { | 57 | methods: { |
72 | fetchConfig: function () { | 58 | fetchConfig: function () { |
73 | fetch(`${this.item.url}/api/health?apikey=${this.item.apikey}`, { | 59 | this.fetch(`${this.apiPath}/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) => { | 60 | .then((health) => { |
83 | this.warnings = 0; | 61 | this.warnings = 0; |
84 | this.errors = 0; | 62 | this.errors = 0; |
@@ -94,21 +72,18 @@ export default { | |||
94 | console.error(e); | 72 | console.error(e); |
95 | this.serverError = true; | 73 | this.serverError = true; |
96 | }); | 74 | }); |
97 | fetch(`${this.item.url}/api/queue?apikey=${this.item.apikey}`, { | 75 | this.fetch(`${this.apiPath}/queue?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) => { | 76 | .then((queue) => { |
107 | this.activity = 0; | 77 | this.activity = 0; |
108 | for (var i = 0; i < queue.length; i++) { | 78 | |
109 | if (queue[i].movie) { | 79 | if (this.item.legacyApi) { |
110 | this.activity++; | 80 | for (var i = 0; i < queue.length; i++) { |
81 | if (queue[i].movie) { | ||
82 | this.activity++; | ||
83 | } | ||
111 | } | 84 | } |
85 | } else { | ||
86 | this.activity = queue.totalRecords; | ||
112 | } | 87 | } |
113 | }) | 88 | }) |
114 | .catch((e) => { | 89 | .catch((e) => { |
@@ -121,35 +96,30 @@ export default { | |||
121 | </script> | 96 | </script> |
122 | 97 | ||
123 | <style scoped lang="scss"> | 98 | <style scoped lang="scss"> |
124 | .media-left img { | ||
125 | max-height: 100%; | ||
126 | } | ||
127 | .notifs { | 99 | .notifs { |
128 | position: absolute; | 100 | position: absolute; |
129 | color: white; | 101 | color: white; |
130 | font-family: sans-serif; | 102 | font-family: sans-serif; |
131 | top: 0.3em; | 103 | top: 0.3em; |
132 | right: 0.5em; | 104 | right: 0.5em; |
133 | } | 105 | .notif { |
134 | .notif { | 106 | display: inline-block; |
135 | padding-right: 0.35em; | 107 | padding: 0.2em 0.35em; |
136 | padding-left: 0.35em; | 108 | border-radius: 0.25em; |
137 | padding-top: 0.2em; | 109 | position: relative; |
138 | padding-bottom: 0.2em; | 110 | margin-left: 0.3em; |
139 | border-radius: 0.25em; | 111 | font-size: 0.8em; |
140 | position: relative; | 112 | &.activity { |
141 | margin-left: 0.3em; | 113 | background-color: #4fb5d6; |
142 | font-size: 0.8em; | 114 | } |
143 | } | ||
144 | .activity { | ||
145 | background-color: #4fb5d6; | ||
146 | } | ||
147 | 115 | ||
148 | .warnings { | 116 | &.warnings { |
149 | background-color: #d08d2e; | 117 | background-color: #d08d2e; |
150 | } | 118 | } |
151 | 119 | ||
152 | .errors { | 120 | &.errors { |
153 | background-color: #e51111; | 121 | background-color: #e51111; |
122 | } | ||
123 | } | ||
154 | } | 124 | } |
155 | </style> | 125 | </style> |