From a842400294ee8e471970d1ee9ba430e47d6a1d17 Mon Sep 17 00:00:00 2001 From: Matt Bentley Date: Sat, 24 Jun 2023 10:41:54 -0400 Subject: [PATCH] Added download rate & added dummy-data for SABnzbd Signed-off-by: Matt Bentley --- docs/customservices.md | 3 +- dummy-data/SABnzbd/api | 59 +++++++++++++++++++++++++++++ src/components/services/SABnzbd.vue | 36 +++++++++++++++++- 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 dummy-data/SABnzbd/api diff --git a/docs/customservices.md b/docs/customservices.md index 665c6f5..0258e8c 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -381,7 +381,8 @@ the "Config" > "General" section of the SABnzbd config in the SABnzbd web UI. url: "http://192.168.0.151:8080" type: "SABnzbd" apikey: "MY-SUPER-SECRET-API-KEY" - downloadInterval: 5000 # (Optional) Interval (in ms) for updating the download count + downloadInterval: 5000 # (Optional) Interval (in ms) for updating the stats + rateDisabled: false ``` ## OctoPrint/Moonraker diff --git a/dummy-data/SABnzbd/api b/dummy-data/SABnzbd/api new file mode 100644 index 0000000..80557c3 --- /dev/null +++ b/dummy-data/SABnzbd/api @@ -0,0 +1,59 @@ +{ + "queue": { + "version": "4.0.2", + "paused": false, + "pause_int": "0", + "paused_all": false, + "diskspace1": "900.28", + "diskspace2": "900.28", + "diskspace1_norm": "900.3 G", + "diskspace2_norm": "900.3 G", + "diskspacetotal1": "901.23", + "diskspacetotal2": "901.23", + "speedlimit": "1", + "speedlimit_abs": "1310720", + "have_warnings": "0", + "finishaction": null, + "quota": "0 ", + "have_quota": false, + "left_quota": "0 ", + "cache_art": "16", + "cache_size": "10.9 MB", + "kbpersec": "1286.74", + "speed": "1.3 M", + "mbleft": "9492.27", + "mb": "11629.75", + "sizeleft": "9.3 GB", + "size": "11.4 GB", + "noofslots_total": 1, + "noofslots": 1, + "start": 0, + "limit": 0, + "finish": 0, + "status": "Downloading", + "timeleft": "2:05:54", + "slots": [ + { + "index": 0, + "nzo_id": "SABnzbd_nzo_nviz7k64", + "unpackopts": "3", + "priority": "Force", + "script": "None", + "filename": "test_download_10GB", + "labels": [], + "password": "", + "cat": "*", + "mbleft": "9492.27", + "mb": "11629.75", + "size": "11.4 GB", + "sizeleft": "9.3 GB", + "percentage": "18", + "mbmissing": "0.00", + "direct_unpack": null, + "status": "Downloading", + "timeleft": "2:05:54", + "avg_age": "335d" + } + ] + } +} diff --git a/src/components/services/SABnzbd.vue b/src/components/services/SABnzbd.vue index 2f93c71..e10780a 100644 --- a/src/components/services/SABnzbd.vue +++ b/src/components/services/SABnzbd.vue @@ -12,7 +12,21 @@ + +
+ + {{ downRate }}B/s + +
@@ -43,9 +57,24 @@ export default { } return this.stats.noofslots; }, + downRate: function() { + if (!this.stats) { + return ""; + } + return this.stats.speed; + }, }, created() { const downloadInterval = parseInt(this.item.downloadInterval, 10) || 0; + const apikey = this.item.apikey; + + if (!apikey) { + console.error( + "apikey is not present in config.yml for the SABnzbd entry!" + ); + return; + } + if (downloadInterval > 0) { setInterval(() => this.fetchStatus(), downloadInterval); } @@ -70,6 +99,11 @@ export default {