From ad17e733c88927fce8b7762513d715b4fdd247f8 Mon Sep 17 00:00:00 2001 From: Kanika Murarka Date: Mon, 8 Oct 2018 14:59:31 +0530 Subject: [PATCH] mgr/dashboard: Adds dynamic documentation link Fixes: https://tracker.ceph.com/issues/24999 Signed-off-by: Kanika Murarka --- .../osd/osd-list/osd-list.component.spec.ts | 4 +++- .../pool-list/pool-list.component.spec.ts | 3 ++- .../rgw-daemon-list.component.spec.ts | 9 ++++++- .../components/grafana/grafana.component.html | 5 +++- .../grafana/grafana.component.spec.ts | 7 ++++-- .../components/grafana/grafana.component.ts | 24 ++++++++++++++++++- 6 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts index 30dba9a77beb2..b073f2ee9f579 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts @@ -1,6 +1,7 @@ import { HttpClientModule } from '@angular/common/http'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; +import { RouterTestingModule } from '@angular/router/testing'; import { TabsModule } from 'ngx-bootstrap/tabs'; @@ -35,7 +36,8 @@ describe('OsdListComponent', () => { TabsModule.forRoot(), DataTableModule, ComponentsModule, - SharedModule + SharedModule, + RouterTestingModule ], declarations: [OsdListComponent, OsdDetailsComponent, OsdPerformanceHistogramComponent], providers: [ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts index 27db3d0d96529..4eae55d21cf6a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts @@ -1,5 +1,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { TabsModule } from 'ngx-bootstrap/tabs/tabs.module'; @@ -13,7 +14,7 @@ describe('PoolListComponent', () => { configureTestBed({ declarations: [PoolListComponent], - imports: [SharedModule, TabsModule.forRoot(), HttpClientTestingModule] + imports: [SharedModule, TabsModule.forRoot(), HttpClientTestingModule, RouterTestingModule] }); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.spec.ts index 34ca733aa12d6..5f4422c67492c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.spec.ts @@ -1,5 +1,6 @@ import { HttpClientModule } from '@angular/common/http'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { TabsModule } from 'ngx-bootstrap/tabs'; @@ -15,7 +16,13 @@ describe('RgwDaemonListComponent', () => { configureTestBed({ declarations: [RgwDaemonListComponent, RgwDaemonDetailsComponent], - imports: [HttpClientModule, TabsModule.forRoot(), PerformanceCounterModule, SharedModule] + imports: [ + HttpClientModule, + TabsModule.forRoot(), + PerformanceCounterModule, + SharedModule, + RouterTestingModule + ] }); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.html index 34ff02c737a76..a96e4774645ec 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.html @@ -5,7 +5,10 @@ - Please consult the documentation on how to configure and enable the monitoring functionality. + Please consult the + documentation + on how to configure and enable the monitoring functionality.
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.spec.ts index 18ac00823a598..0a77ece38f9d6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.spec.ts @@ -1,11 +1,14 @@ import { HttpClientModule } from '@angular/common/http'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { AlertModule } from 'ngx-bootstrap'; import { configureTestBed } from '../../../../testing/unit-test-helper'; import { SettingsService } from '../../../shared/api/settings.service'; +import { SummaryService } from '../../../shared/services/summary.service'; +import { CephReleaseNamePipe } from '../../pipes/ceph-release-name.pipe'; import { InfoPanelComponent } from '../info-panel/info-panel.component'; import { LoadingPanelComponent } from '../loading-panel/loading-panel.component'; import { GrafanaComponent } from './grafana.component'; @@ -16,8 +19,8 @@ describe('GrafanaComponent', () => { configureTestBed({ declarations: [GrafanaComponent, InfoPanelComponent, LoadingPanelComponent], - imports: [AlertModule.forRoot(), HttpClientModule], - providers: [SettingsService] + imports: [AlertModule.forRoot(), HttpClientModule, RouterTestingModule], + providers: [CephReleaseNamePipe, SettingsService, SummaryService] }); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts index d71c3780dac88..47b80a08a02ba 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts @@ -4,6 +4,8 @@ import { DomSanitizer } from '@angular/platform-browser'; import { SafeUrl } from '@angular/platform-browser'; import { SettingsService } from '../../../shared/api/settings.service'; +import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe'; +import { SummaryService } from '../../../shared/services/summary.service'; @Component({ selector: 'cd-grafana', @@ -31,8 +33,14 @@ export class GrafanaComponent implements OnInit, OnChanges { @Input() grafanaStyle: string; grafanaUrl: any; + docsUrl: string; - constructor(private sanitizer: DomSanitizer, private settingsService: SettingsService) {} + constructor( + private summaryService: SummaryService, + private sanitizer: DomSanitizer, + private settingsService: SettingsService, + private cephReleaseNamePipe: CephReleaseNamePipe + ) {} ngOnInit() { this.styles = { @@ -40,6 +48,20 @@ export class GrafanaComponent implements OnInit, OnChanges { two: 'grafana_two', three: 'grafana_three' }; + + const subs = this.summaryService.subscribe((summary: any) => { + if (!summary) { + return; + } + + const releaseName = this.cephReleaseNamePipe.transform(summary.version); + this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/mgr/dashboard/`; + + setTimeout(() => { + subs.unsubscribe(); + }, 0); + }); + this.settingsService.getGrafanaApiUrl().subscribe((data: any) => { this.grafanaUrl = data.value; if (this.grafanaUrl === '') { -- 2.39.5