X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2Fservices%2FRadarr.vue;h=5c40aaa389c71ef59a8099355eadf0867efdce04;hb=c6ec28f1c52ef529cfda508b3ce3d972591d50b6;hp=a8c97c1992cbd0e448b3b8884a37c2e5656c6686;hpb=cb154a6818cd25a36298e307cb415b11e9bd2247;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue index a8c97c1..5c40aaa 100644 --- a/src/components/services/Radarr.vue +++ b/src/components/services/Radarr.vue @@ -26,6 +26,9 @@ import service from "@/mixins/service.js"; import Generic from "./Generic.vue"; +const V3_API = "/api/v3"; +const LEGACY_API = "/api"; + export default { name: "Radarr", mixins: [service], @@ -46,9 +49,14 @@ export default { created: function () { this.fetchConfig(); }, + computed: { + apiPath() { + return this.item.legacyApi ? LEGACY_API : V3_API; + }, + }, methods: { fetchConfig: function () { - this.fetch(`/api/v3/health?apikey=${this.item.apikey}`) + this.fetch(`${this.apiPath}/health?apikey=${this.item.apikey}`) .then((health) => { this.warnings = 0; this.errors = 0; @@ -64,13 +72,18 @@ export default { console.error(e); this.serverError = true; }); - this.fetch(`/api/v3/queue?apikey=${this.item.apikey}`) + this.fetch(`${this.apiPath}/queue?apikey=${this.item.apikey}`) .then((queue) => { this.activity = 0; - for (var i = 0; i < queue.length; i++) { - if (queue[i].movie) { - this.activity++; + + if (this.item.legacyApi) { + for (var i = 0; i < queue.length; i++) { + if (queue[i].movie) { + this.activity++; + } } + } else { + this.activity = queue.totalRecords; } }) .catch((e) => {