mirror of
https://github.com/ceph/ceph
synced 2025-02-23 11:07:35 +00:00
mgr/dashboard: update grafana api url when switching cluster
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>
This commit is contained in:
parent
625e312e86
commit
93974820ce
@ -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(() => {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user