diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2021-12-13 11:54:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-13 11:54:04 -0800 |
commit | b1c85864410e5a5515124125e387518d2fbb4c07 (patch) | |
tree | 1a16186e52de3eb7f1ddd72551dedd5586b60562 | |
parent | 9c77651692468ba68f631e03b22a6227b5759240 (diff) | |
parent | 0121fa8036caaa1f7136564a06da0e5aab697813 (diff) | |
download | homer-b1c85864410e5a5515124125e387518d2fbb4c07.tar.gz homer-b1c85864410e5a5515124125e387518d2fbb4c07.tar.zst homer-b1c85864410e5a5515124125e387518d2fbb4c07.zip |
Merge pull request #329 from Panzer1119/main
Add Lidarr service
-rw-r--r-- | docs/customservices.md | 10 | ||||
-rw-r--r-- | src/components/services/Lidarr.vue | 150 |
2 files changed, 155 insertions, 5 deletions
diff --git a/docs/customservices.md b/docs/customservices.md index 6850bbb..7d47542 100644 --- a/docs/customservices.md +++ b/docs/customservices.md | |||
@@ -63,18 +63,18 @@ Two lines are needed in the config.yml : | |||
63 | The url must be the root url of Medusa application. | 63 | The url must be the root url of Medusa application. |
64 | The Medusa API key can be found in General configuration > Interface. It is needed to access Medusa API. | 64 | The Medusa API key can be found in General configuration > Interface. It is needed to access Medusa API. |
65 | 65 | ||
66 | ## Sonarr/Radarr | 66 | ## Lidarr, Sonarr and Radarr |
67 | 67 | ||
68 | This service displays Activity (blue), Warning (orange) or Error (red) notifications bubbles from the Radarr/Sonarr application. | 68 | This service displays Activity (blue), Warning (orange) or Error (red) notifications bubbles from the Lidarr, Radarr or Sonarr application. |
69 | Two lines are needed in the config.yml : | 69 | Two lines are needed in the config.yml : |
70 | 70 | ||
71 | ```yaml | 71 | ```yaml |
72 | type: "Radarr" or "Sonarr" | 72 | type: "Lidarr", "Radarr" or "Sonarr" |
73 | apikey: "01234deb70424befb1f4ef6a23456789" | 73 | apikey: "01234deb70424befb1f4ef6a23456789" |
74 | ``` | 74 | ``` |
75 | 75 | ||
76 | The url must be the root url of Radarr/Sonarr application. | 76 | The url must be the root url of Lidarr, Radarr or Sonarr application. |
77 | The Radarr/Sonarr API key can be found in Settings > General. It is needed to access the API. | 77 | The Lidarr, Radarr or Sonarr API key can be found in Settings > General. It is needed to access the API. |
78 | 78 | ||
79 | ## PaperlessNG | 79 | ## PaperlessNG |
80 | 80 | ||
diff --git a/src/components/services/Lidarr.vue b/src/components/services/Lidarr.vue new file mode 100644 index 0000000..f5d3434 --- /dev/null +++ b/src/components/services/Lidarr.vue | |||
@@ -0,0 +1,150 @@ | |||
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 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> | ||
53 | |||
54 | <script> | ||
55 | export default { | ||
56 | name: "Lidarr", | ||
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/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) => { | ||
83 | this.warnings = 0; | ||
84 | this.errors = 0; | ||
85 | for (var i = 0; i < health.length; i++) { | ||
86 | if (health[i].type == "warning") { | ||
87 | this.warnings++; | ||
88 | } else if (health[i].type == "error") { | ||
89 | this.errors++; | ||
90 | } | ||
91 | } | ||
92 | }) | ||
93 | .catch((e) => { | ||
94 | console.error(e); | ||
95 | this.serverError = true; | ||
96 | }); | ||
97 | fetch(`${this.item.url}/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) => { | ||
107 | this.activity = queue.totalCount; | ||
108 | }) | ||
109 | .catch((e) => { | ||
110 | console.error(e); | ||
111 | this.serverError = true; | ||
112 | }); | ||
113 | }, | ||
114 | }, | ||
115 | }; | ||
116 | </script> | ||
117 | |||
118 | <style scoped lang="scss"> | ||
119 | .media-left img { | ||
120 | max-height: 100%; | ||
121 | } | ||
122 | .notifs { | ||
123 | position: absolute; | ||
124 | color: white; | ||
125 | font-family: sans-serif; | ||
126 | top: 0.3em; | ||
127 | right: 0.5em; | ||
128 | } | ||
129 | .notif { | ||
130 | padding-right: 0.35em; | ||
131 | padding-left: 0.35em; | ||
132 | padding-top: 0.2em; | ||
133 | padding-bottom: 0.2em; | ||
134 | border-radius: 0.25em; | ||
135 | position: relative; | ||
136 | margin-left: 0.3em; | ||
137 | font-size: 0.8em; | ||
138 | } | ||
139 | .activity { | ||
140 | background-color: #4fb5d6; | ||
141 | } | ||
142 | |||
143 | .warnings { | ||
144 | background-color: #d08d2e; | ||
145 | } | ||
146 | |||
147 | .errors { | ||
148 | background-color: #e51111; | ||
149 | } | ||
150 | </style> | ||