X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2Fservices%2FSonarr.vue;h=bb83b6b00a485055f747d934d51ef72b2ab94756;hb=5cd802d157a687224949a0f0cc9f93413aefaaf2;hp=f8dd0d1ac4e0e0db80bc19645161f6d79987b9d6;hpb=9c77651692468ba68f631e03b22a6227b5759240;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/services/Sonarr.vue b/src/components/services/Sonarr.vue index f8dd0d1..bb83b6b 100644 --- a/src/components/services/Sonarr.vue +++ b/src/components/services/Sonarr.vue @@ -27,6 +27,9 @@ import service from "@/mixins/service.js"; import Generic from "./Generic.vue"; +const V3_API = "/api/v3"; +const LEGACY_API = "/api"; + export default { name: "Sonarr", mixins: [service], @@ -36,6 +39,11 @@ export default { components: { Generic, }, + computed: { + apiPath() { + return this.item.legacyApi ? LEGACY_API : V3_API; + }, + }, data: () => { return { activity: null, @@ -49,7 +57,7 @@ export default { }, 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; @@ -65,13 +73,17 @@ 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].series) { - this.activity++; + if (this.item.legacyApi) { + for (var i = 0; i < queue.length; i++) { + if (queue[i].series) { + this.activity++; + } } + } else { + this.activity = queue.totalRecords; } }) .catch((e) => {