From 4797047571366cb6345cfee8ea0722f481f576b0 Mon Sep 17 00:00:00 2001 From: royto Date: Sun, 6 Aug 2023 23:18:02 +0200 Subject: [PATCH] feat: add missing notif for sonarr --- docs/customservices.md | 2 +- src/components/services/Sonarr.vue | 38 +++++++++++++++++------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/docs/customservices.md b/docs/customservices.md index fbd25d3..0299091 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -104,7 +104,7 @@ The Medusa API key can be found in General configuration > Interface. It is need ## Lidarr, Prowlarr, Sonarr, Readarr and Radarr This service displays Activity (blue), Warning (orange) or Error (red) notifications bubbles from the Lidarr, Readarr, Radarr or Sonarr application. -Readarr display also a Missing (purple) notification bubbles. +Readarr and Sonarr display also a Missing (purple) notification bubbles. Two lines are needed in the config.yml : ```yaml diff --git a/src/components/services/Sonarr.vue b/src/components/services/Sonarr.vue index bb83b6b..c52c939 100644 --- a/src/components/services/Sonarr.vue +++ b/src/components/services/Sonarr.vue @@ -5,6 +5,9 @@ {{ activity }} + + {{ missing }} + {{ warnings }} @@ -47,6 +50,7 @@ export default { data: () => { return { activity: null, + missing: null, warnings: null, errors: null, serverError: false, @@ -57,22 +61,16 @@ export default { }, methods: { fetchConfig: function () { + const handleError = (e) => { + console.error(e); + this.serverError = true; + }; this.fetch(`${this.apiPath}/health?apikey=${this.item.apikey}`) .then((health) => { - this.warnings = 0; - this.errors = 0; - for (var i = 0; i < health.length; i++) { - if (health[i].type == "warning") { - this.warnings++; - } else if (health[i].type == "error") { - this.errors++; - } - } + this.warnings = health.filter((h) => h.type === "warning").length; + this.errors = health.filter((h) => h.type === "errors").length; }) - .catch((e) => { - console.error(e); - this.serverError = true; - }); + .catch(handleError); this.fetch(`${this.apiPath}/queue?apikey=${this.item.apikey}`) .then((queue) => { this.activity = 0; @@ -86,10 +84,12 @@ export default { this.activity = queue.totalRecords; } }) - .catch((e) => { - console.error(e); - this.serverError = true; - }); + .catch(handleError); + this.fetch(`${this.apiPath}/wanted/missing?apikey=${this.item.apikey}`) + .then((missing) => { + this.missing = missing.totalRecords; + }) + .catch(handleError); }, }, }; @@ -115,6 +115,10 @@ export default { background-color: #4fb5d6; } + &.missing { + background-color: #9d00ff; + } + &.warnings { background-color: #d08d2e; }