From ab639d04f4959565561bc3fa61ebc06e79828415 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 3 Feb 2025 16:08:00 -0500 Subject: [PATCH] fix(api): use contextual path/headers for Grafana datasource/dashboard requests --- src/app/Shared/Services/Api.service.tsx | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/app/Shared/Services/Api.service.tsx b/src/app/Shared/Services/Api.service.tsx index 5fc866520..47b46d9ce 100644 --- a/src/app/Shared/Services/Api.service.tsx +++ b/src/app/Shared/Services/Api.service.tsx @@ -100,18 +100,8 @@ export class ApiService { } private testHealth() { - const getDatasourceURL: Observable = this.ctx - .url('/api/v4/grafana_datasource_url') - .pipe( - concatMap((u) => fromFetch(u)), - concatMap((resp) => from(resp.json())), - ); - const getDashboardURL: Observable = this.ctx - .url('/api/v4/grafana_dashboard_url') - .pipe( - concatMap((u) => fromFetch(u)), - concatMap((resp) => from(resp.json())), - ); + const datasourceURL: Observable = this.doGet('/grafana_datasource_url', 'v4'); + const dashboardURL: Observable = this.doGet('/grafana_dashboard_url', 'v4'); const health: Observable = this.doGet('/health', 'unversioned'); health @@ -127,7 +117,7 @@ export class ApiService { // if both configured and available then display nothing and just retrieve the URLs if (jsonResp.datasourceConfigured) { if (jsonResp.datasourceAvailable) { - toFetch.push(getDatasourceURL); + toFetch.push(datasourceURL); } else { unavailable.push('datasource URL'); } @@ -136,7 +126,7 @@ export class ApiService { } if (jsonResp.dashboardConfigured) { if (jsonResp.dashboardAvailable) { - toFetch.push(getDashboardURL); + toFetch.push(dashboardURL); } else { unavailable.push('dashboard URL'); }