]>
Commit | Line | Data |
---|---|---|
0211da26 | 1 | <template> |
9c776516 BW |
2 | <Generic :item="item"> |
3 | <template #indicator> | |
4 | <div class="notifs"> | |
5 | <strong v-if="activity > 0" class="notif activity" title="Activity"> | |
6 | {{ activity }} | |
7 | </strong> | |
8 | <strong v-if="warnings > 0" class="notif warnings" title="Warning"> | |
9 | {{ warnings }} | |
10 | </strong> | |
11 | <strong v-if="errors > 0" class="notif errors" title="Error"> | |
12 | {{ errors }} | |
13 | </strong> | |
14 | <strong | |
15 | v-if="serverError" | |
16 | class="notif errors" | |
17 | title="Connection error to Radarr API, check url and apikey in config.yml" | |
18 | >?</strong | |
19 | > | |
20 | </div> | |
21 | </template> | |
22 | </Generic> | |
0211da26 | 23 | </template> |
24 | ||
25 | <script> | |
9c776516 BW |
26 | import service from "@/mixins/service.js"; |
27 | import Generic from "./Generic.vue"; | |
28 | ||
8ede3041 DN |
29 | const V3_API = "/api/v3"; |
30 | const LEGACY_API = "/api"; | |
31 | ||
0211da26 | 32 | export default { |
33 | name: "Radarr", | |
9c776516 | 34 | mixins: [service], |
0211da26 | 35 | props: { |
36 | item: Object, | |
37 | }, | |
9c776516 BW |
38 | components: { |
39 | Generic, | |
40 | }, | |
0211da26 | 41 | data: () => { |
42 | return { | |
43 | activity: null, | |
44 | warnings: null, | |
45 | errors: null, | |
46 | serverError: false, | |
47 | }; | |
48 | }, | |
49 | created: function () { | |
50 | this.fetchConfig(); | |
51 | }, | |
8ede3041 DN |
52 | computed: { |
53 | apiPath() { | |
54 | return this.item.legacyApi ? LEGACY_API : V3_API; | |
55 | }, | |
56 | }, | |
0211da26 | 57 | methods: { |
58 | fetchConfig: function () { | |
8ede3041 | 59 | this.fetch(`${this.apiPath}/health?apikey=${this.item.apikey}`) |
0211da26 | 60 | .then((health) => { |
61 | this.warnings = 0; | |
62 | this.errors = 0; | |
63 | for (var i = 0; i < health.length; i++) { | |
64 | if (health[i].type == "warning") { | |
65 | this.warnings++; | |
66 | } else if (health[i].type == "error") { | |
67 | this.errors++; | |
68 | } | |
69 | } | |
70 | }) | |
71 | .catch((e) => { | |
72 | console.error(e); | |
73 | this.serverError = true; | |
74 | }); | |
8ede3041 | 75 | this.fetch(`${this.apiPath}/queue?apikey=${this.item.apikey}`) |
0211da26 | 76 | .then((queue) => { |
77 | this.activity = 0; | |
f7f4ebdf DN |
78 | |
79 | if (this.item.legacyApi) { | |
80 | for (var i = 0; i < queue.length; i++) { | |
6c8f9f1c | 81 | if (queue[i].movie) { |
f7f4ebdf DN |
82 | this.activity++; |
83 | } | |
84 | } | |
85 | } else { | |
c6ec28f1 | 86 | this.activity = queue.totalRecords; |
0211da26 | 87 | } |
88 | }) | |
89 | .catch((e) => { | |
90 | console.error(e); | |
91 | this.serverError = true; | |
92 | }); | |
93 | }, | |
94 | }, | |
95 | }; | |
96 | </script> | |
97 | ||
98 | <style scoped lang="scss"> | |
0211da26 | 99 | .notifs { |
100 | position: absolute; | |
101 | color: white; | |
102 | font-family: sans-serif; | |
103 | top: 0.3em; | |
104 | right: 0.5em; | |
9c776516 BW |
105 | .notif { |
106 | display: inline-block; | |
107 | padding: 0.2em 0.35em; | |
108 | border-radius: 0.25em; | |
109 | position: relative; | |
110 | margin-left: 0.3em; | |
111 | font-size: 0.8em; | |
112 | &.activity { | |
113 | background-color: #4fb5d6; | |
114 | } | |
0211da26 | 115 | |
9c776516 BW |
116 | &.warnings { |
117 | background-color: #d08d2e; | |
118 | } | |
0211da26 | 119 | |
9c776516 BW |
120 | &.errors { |
121 | background-color: #e51111; | |
122 | } | |
123 | } | |
0211da26 | 124 | } |
125 | </style> |