]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: update grafana api url when switching cluster 56297/head
authorNizamudeen A <nia@redhat.com>
Tue, 19 Mar 2024 15:09:09 +0000 (20:39 +0530)
committerNizamudeen A <nia@redhat.com>
Fri, 22 Mar 2024 09:09:29 +0000 (14:39 +0530)
do a force refresh on the settings service so it picks up the new api
url of grafana

Fixes: https://tracker.ceph.com/issues/65052
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts

index 8973843872bc95bf3373170a113b6d8dd9f186c7..de8b0a267db82b6573ce9c184d4a00c68def8c77 100644 (file)
@@ -4,6 +4,7 @@ import { Router } from '@angular/router';
 import * as _ from 'lodash';
 import { Subscription } from 'rxjs';
 import { MultiClusterService } from '~/app/shared/api/multi-cluster.service';
+import { SettingsService } from '~/app/shared/api/settings.service';
 
 import { Icons } from '~/app/shared/enum/icons.enum';
 import { MultiCluster } from '~/app/shared/models/multi-cluster';
@@ -58,7 +59,8 @@ export class NavigationComponent implements OnInit, OnDestroy {
     private telemetryNotificationService: TelemetryNotificationService,
     public prometheusAlertService: PrometheusAlertService,
     private motdNotificationService: MotdNotificationService,
-    private cookieService: CookiesService
+    private cookieService: CookiesService,
+    private settingsService: SettingsService
   ) {
     this.permissions = this.authStorageService.getPermissions();
     this.enabledFeature$ = this.featureToggles.get();
@@ -212,6 +214,14 @@ export class NavigationComponent implements OnInit, OnDestroy {
       () => {
         this.multiClusterService.refresh();
         this.summaryService.refresh();
+
+        // force refresh grafana api url to get the correct url for the selected cluster
+        this.settingsService.ifSettingConfigured(
+          'api/grafana/url',
+          () => {},
+          () => {},
+          true
+        );
         const currentRoute = this.router.url.split('?')[0];
         if (currentRoute.includes('dashboard')) {
           this.router.navigateByUrl('/pool', { skipLocationChange: true }).then(() => {
index 1e53fa064930e018ebce8a79275b2173e8a2db76..9aeb79906c9fe98d3bd3be1efe019aca7c9c2d87 100644 (file)
@@ -35,9 +35,14 @@ export class SettingsService {
     );
   }
 
-  ifSettingConfigured(url: string, fn: (value?: string) => void, elseFn?: () => void): void {
+  ifSettingConfigured(
+    url: string,
+    fn: (value?: string) => void,
+    elseFn?: () => void,
+    forceRefresh = false
+  ): void {
     const setting = this.settings[url];
-    if (setting === undefined) {
+    if (forceRefresh || setting === undefined) {
       this.http.get(url).subscribe(
         (data: any) => {
           this.settings[url] = this.getSettingsValue(data);