From 8ede30411ed1726ed3885fd617364924e677abc2 Mon Sep 17 00:00:00 2001 From: Duy NGUYEN Date: Tue, 1 Feb 2022 17:05:23 +0100 Subject: Radarr and Sonarr V3 api support optional --- src/components/services/Radarr.vue | 12 ++++++++++-- src/components/services/Sonarr.vue | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src/components/services') diff --git a/src/components/services/Radarr.vue b/src/components/services/Radarr.vue index a8c97c1..13f6d68 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,7 +72,7 @@ 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++) { diff --git a/src/components/services/Sonarr.vue b/src/components/services/Sonarr.vue index 972a1c9..3e5c49f 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/v3/health?apikey=${this.item.apikey}`) + this.fetch(`${this.apiPath}/health?apikey=${this.item.apikey}`) .then((health) => { this.warnings = 0; this.errors = 0; @@ -65,7 +73,7 @@ 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++) { -- cgit v1.2.3