aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Bentley <mbentley@mbentley.net>2022-11-19 10:14:22 -0500
committerGitHub <noreply@github.com>2022-11-19 07:14:22 -0800
commit98fe0a393970070fa04b5f37dbbb7a4c3ef82beb (patch)
tree23750120d98818d037e5f52f44a07f5a3f1debcb
parentf62972f65932a486ec0355cd61df3372fca371f3 (diff)
downloadhomer-98fe0a393970070fa04b5f37dbbb7a4c3ef82beb.tar.gz
homer-98fe0a393970070fa04b5f37dbbb7a4c3ef82beb.tar.zst
homer-98fe0a393970070fa04b5f37dbbb7a4c3ef82beb.zip
Adds SABnzbd custom service; fixes #494 (#555)
* Adds SABnzbd custom service; fixes #494
-rw-r--r--docs/customservices.md16
-rw-r--r--src/components/services/SABnzbd.vue99
2 files changed, 115 insertions, 0 deletions
diff --git a/docs/customservices.md b/docs/customservices.md
index 7448a8c..5bb08ff 100644
--- a/docs/customservices.md
+++ b/docs/customservices.md
@@ -30,6 +30,7 @@ within Homer:
30 - [CopyToClipboard](#copy-to-clipboard) 30 - [CopyToClipboard](#copy-to-clipboard)
31 - [Speedtest Tracker](#SpeedtestTracker) 31 - [Speedtest Tracker](#SpeedtestTracker)
32 - [What's Up Docker](#whats-up-docker) 32 - [What's Up Docker](#whats-up-docker)
33 - [SABnzbd](#sabnzbd)
33 34
34If you experiencing any issue, please have a look to the [troubleshooting](troubleshooting.md) page. 35If you experiencing any issue, please have a look to the [troubleshooting](troubleshooting.md) page.
35 36
@@ -361,3 +362,18 @@ The following configuration is available for the WUD service.
361 url: "http://192.168.1.12:3001" 362 url: "http://192.168.1.12:3001"
362 type: "WUD" 363 type: "WUD"
363``` 364```
365
366## SABnzbd
367
368The SABnzbd service can allow you to show the number of currently active
369downloads on your SABnzbd instance. An API key is required, and can be obtained from
370the "Config" > "General" section of the SABnzbd config in the SABnzbd web UI.
371
372```yaml
373- name: "SABnzbd"
374 logo: "assets/tools/sample.png"
375 url: "http://192.168.0.151:8080"
376 type: "SABnzbd"
377 apikey: "MY-SUPER-SECRET-API-KEY"
378 downloadInterval: 5000 # (Optional) Interval (in ms) for updating the download count
379```
diff --git a/src/components/services/SABnzbd.vue b/src/components/services/SABnzbd.vue
new file mode 100644
index 0000000..2f93c71
--- /dev/null
+++ b/src/components/services/SABnzbd.vue
@@ -0,0 +1,99 @@
1<template>
2 <Generic :item="item">
3 <template #indicator>
4 <div class="notifs">
5 <strong
6 v-if="downloads > 0"
7 class="notif downloading"
8 :title="`${downloads} active download${downloads > 1 ? 's' : ''}`"
9 >
10 {{ downloads }}
11 </strong>
12 <i
13 v-if="error"
14 class="notif error fa-solid fa-triangle-exclamation"
15 title="Unable to fetch current status"
16 ></i>
17 </div>
18 </template>
19 </Generic>
20</template>
21
22<script>
23import service from "@/mixins/service.js";
24import Generic from "./Generic.vue";
25
26export default {
27 name: "SABnzbd",
28 mixins: [service],
29 props: {
30 item: Object,
31 },
32 components: {
33 Generic,
34 },
35 data: () => ({
36 stats: null,
37 error: false,
38 }),
39 computed: {
40 downloads: function () {
41 if (!this.stats) {
42 return "";
43 }
44 return this.stats.noofslots;
45 },
46 },
47 created() {
48 const downloadInterval = parseInt(this.item.downloadInterval, 10) || 0;
49 if (downloadInterval > 0) {
50 setInterval(() => this.fetchStatus(), downloadInterval);
51 }
52
53 this.fetchStatus();
54 },
55 methods: {
56 fetchStatus: async function () {
57 try {
58 const response = await this.fetch(
59 `/api?output=json&apikey=${this.item.apikey}&mode=queue`
60 );
61 this.error = false;
62 this.stats = response.queue;
63 } catch (e) {
64 this.error = true;
65 console.error(e);
66 }
67 },
68 },
69};
70</script>
71
72<style scoped lang="scss">
73.notifs {
74 position: absolute;
75 color: white;
76 font-family: sans-serif;
77 top: 0.3em;
78 right: 0.5em;
79
80 .notif {
81 display: inline-block;
82 padding: 0.2em 0.35em;
83 border-radius: 0.25em;
84 position: relative;
85 margin-left: 0.3em;
86 font-size: 0.8em;
87
88 &.downloading {
89 background-color: #4fb5d6;
90 }
91
92 &.error {
93 border-radius: 50%;
94 aspect-ratio: 1;
95 background-color: #e51111;
96 }
97 }
98}
99</style>