X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=src%2Fcomponents%2Fservices%2FRadarr.vue;h=55896f573c1f68fbe6798d8e9188a2b4fcf018a5;hb=f7f4ebdf667db848509f93d470cd46c648bb2439;hp=a57c895f0e0e9bc9e10b48f5ef5c08c3df837e1b;hpb=9c77651692468ba68f631e03b22a6227b5759240;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue index a57c895..55896f5 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/health?apikey=${this.item.apikey}`) + this.fetch(`${this.apiPath}/health?apikey=${this.item.apikey}`) .then((health) => { this.warnings = 0; this.errors = 0; @@ -64,12 +72,21 @@ export default { console.error(e); this.serverError = true; }); - this.fetch(`/api/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].series) { + this.activity++; + } + } + } else { + for (const record of queue.records) { + if (record.movieId) { + this.activity++; + } } } })