Skip to content

Commit

Permalink
fix(api): use contextual path/headers for Grafana datasource/dashboar…
Browse files Browse the repository at this point in the history
…d requests
  • Loading branch information
andrewazores committed Feb 3, 2025
1 parent 0bdaad0 commit ab639d0
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,8 @@ export class ApiService {
}

private testHealth() {
const getDatasourceURL: Observable<GrafanaDashboardUrlGetResponse> = this.ctx
.url('/api/v4/grafana_datasource_url')
.pipe(
concatMap((u) => fromFetch(u)),
concatMap((resp) => from(resp.json())),
);
const getDashboardURL: Observable<GrafanaDashboardUrlGetResponse> = this.ctx
.url('/api/v4/grafana_dashboard_url')
.pipe(
concatMap((u) => fromFetch(u)),
concatMap((resp) => from(resp.json())),
);
const datasourceURL: Observable<GrafanaDashboardUrlGetResponse> = this.doGet('/grafana_datasource_url', 'v4');
const dashboardURL: Observable<GrafanaDashboardUrlGetResponse> = this.doGet('/grafana_dashboard_url', 'v4');
const health: Observable<HealthGetResponse> = this.doGet('/health', 'unversioned');

health
Expand All @@ -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');
}
Expand All @@ -136,7 +126,7 @@ export class ApiService {
}
if (jsonResp.dashboardConfigured) {
if (jsonResp.dashboardAvailable) {
toFetch.push(getDashboardURL);
toFetch.push(dashboardURL);
} else {
unavailable.push('dashboard URL');
}
Expand Down

0 comments on commit ab639d0

Please sign in to comment.