From a84bed27b51f0b14431e5138a526190f39e2d558 Mon Sep 17 00:00:00 2001 From: Kanika Murarka Date: Mon, 19 Nov 2018 13:43:52 +0530 Subject: [PATCH] mgr/dashboard: Show/Hide Grafana tabs according to user role Fixes: http://tracker.ceph.com/issues/36655 Signed-off-by: Kanika Murarka --- src/pybind/mgr/dashboard/controllers/grafana.py | 8 ++------ .../cephfs-detail/cephfs-detail.component.html | 1 + .../cephfs/cephfs-detail/cephfs-detail.component.ts | 8 +++++++- .../hosts/host-details/host-details.component.html | 2 +- .../hosts/host-details/host-details.component.ts | 7 ++++++- .../src/app/ceph/cluster/hosts/hosts.component.html | 1 + .../osd/osd-details/osd-details.component.html | 1 + .../cluster/osd/osd-details/osd-details.component.ts | 7 ++++++- .../cluster/osd/osd-list/osd-list.component.html | 3 ++- .../cluster/osd/osd-list/osd-list.component.spec.ts | 3 ++- .../ceph/cluster/osd/osd-list/osd-list.component.ts | 6 +++--- .../app/ceph/pool/pool-list/pool-list.component.html | 4 +++- .../ceph/pool/pool-list/pool-list.component.spec.ts | 2 +- .../app/ceph/pool/pool-list/pool-list.component.ts | 6 +++--- .../rgw-daemon-details.component.html | 1 + .../rgw-daemon-details.component.ts | 10 +++++++++- .../rgw-daemon-list/rgw-daemon-list.component.html | 1 + .../rgw/rgw-daemon-list/rgw-daemon-list.component.ts | 5 +++++ ...tings.service.spec.ts => grafana.service.spec.ts} | 12 ++++++------ .../api/{settings.service.ts => grafana.service.ts} | 4 ++-- .../components/grafana/grafana.component.spec.ts | 5 +++-- .../shared/components/grafana/grafana.component.ts | 12 ++++++------ .../frontend/src/app/shared/models/permissions.ts | 2 ++ 23 files changed, 74 insertions(+), 37 deletions(-) rename src/pybind/mgr/dashboard/frontend/src/app/shared/api/{settings.service.spec.ts => grafana.service.spec.ts} (71%) rename src/pybind/mgr/dashboard/frontend/src/app/shared/api/{settings.service.ts => grafana.service.ts} (73%) diff --git a/src/pybind/mgr/dashboard/controllers/grafana.py b/src/pybind/mgr/dashboard/controllers/grafana.py index a18dd9c18534..e24c0cc161b7 100644 --- a/src/pybind/mgr/dashboard/controllers/grafana.py +++ b/src/pybind/mgr/dashboard/controllers/grafana.py @@ -89,12 +89,8 @@ class Grafana(BaseController): @Endpoint() @ReadPermission - def status(self): - grafana = GrafanaRestClient.instance() - available, msg = grafana.is_service_online() - response = {'available': available} - if msg: - response['message'] = msg + def url(self): + response = {'instance': Settings.GRAFANA_API_URL} return response diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.html index 974068b972b2..0449b299cc9c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.html @@ -41,6 +41,7 @@ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts index a5ef1733c69d..1db21cedac6d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts @@ -5,8 +5,10 @@ import * as _ from 'lodash'; import { CephfsService } from '../../../shared/api/cephfs.service'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; +import { Permission } from '../../../shared/models/permissions'; import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; +import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @Component({ selector: 'cd-cephfs-detail', @@ -32,16 +34,20 @@ export class CephfsDetailComponent implements OnChanges, OnInit { clientCount: number; mdsCounters = {}; grafanaId: any; + grafanaPermission: Permission; objectValues = Object.values; clientsSelect = false; constructor( + private authStorageService: AuthStorageService, private cephfsService: CephfsService, private dimlessBinary: DimlessBinaryPipe, private dimless: DimlessPipe, private i18n: I18n - ) {} + ) { + this.grafanaPermission = this.authStorageService.getPermissions().grafana; + } ngOnChanges() { if (this.selection.hasSelection) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-details/host-details.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-details/host-details.component.html index 2f26bf7d46f3..ca992c9f16b3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-details/host-details.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-details/host-details.component.html @@ -1,4 +1,4 @@ - + diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html index c037ebac55d5..a7238b7a3e9b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html @@ -42,6 +42,7 @@ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts index d4ace9fb3775..766fc2dbc24e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts @@ -4,6 +4,8 @@ import * as _ from 'lodash'; import { OsdService } from '../../../../shared/api/osd.service'; import { CdTableSelection } from '../../../../shared/models/cd-table-selection'; +import { Permission } from '../../../../shared/models/permissions'; +import { AuthStorageService } from '../../../../shared/services/auth-storage.service'; @Component({ selector: 'cd-osd-details', @@ -15,8 +17,11 @@ export class OsdDetailsComponent implements OnChanges { selection: CdTableSelection; osd: any; + grafanaPermission: Permission; - constructor(private osdService: OsdService) {} + constructor(private osdService: OsdService, private authStorageService: AuthStorageService) { + this.grafanaPermission = this.authStorageService.getPermissions().grafana; + } ngOnChanges() { this.osd = { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html index dffa66292daa..88a711023293 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html @@ -8,7 +8,7 @@ (updateSelection)="updateSelection($event)" [updateSelectionOnRefresh]="'never'">
- @@ -46,6 +46,7 @@ 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 53fb10e29a31..7288cee3e26e 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 @@ -51,6 +51,7 @@ describe('OsdListComponent', () => { component.selection.selected = selection; component.selection.update(); component.osds = data; + component.permissions = fakeAuthStorageService.getPermissions(); }; const openActionModal = (actionName) => { @@ -110,7 +111,7 @@ describe('OsdListComponent', () => { }; beforeEach(() => { - permissionHelper = new PermissionHelper(component.permission, () => + permissionHelper = new PermissionHelper(component.permissions.osd, () => getTableActionComponent() ); scenario = { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts index 1aadc0219ebe..e685e1de85a8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts @@ -12,7 +12,7 @@ import { CellTemplate } from '../../../../shared/enum/cell-template.enum'; import { CdTableAction } from '../../../../shared/models/cd-table-action'; import { CdTableColumn } from '../../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../../shared/models/cd-table-selection'; -import { Permission } from '../../../../shared/models/permissions'; +import { Permissions } from '../../../../shared/models/permissions'; import { DimlessBinaryPipe } from '../../../../shared/pipes/dimless-binary.pipe'; import { AuthStorageService } from '../../../../shared/services/auth-storage.service'; import { OsdFlagsModalComponent } from '../osd-flags-modal/osd-flags-modal.component'; @@ -40,7 +40,7 @@ export class OsdListComponent implements OnInit { @ViewChild('safeToDestroyBodyTpl') safeToDestroyBodyTpl: TemplateRef; - permission: Permission; + permissions: Permissions; tableActions: CdTableAction[]; bsModalRef: BsModalRef; columns: CdTableColumn[]; @@ -59,7 +59,7 @@ export class OsdListComponent implements OnInit { private modalService: BsModalService, private i18n: I18n ) { - this.permission = this.authStorageService.getPermissions().osd; + this.permissions = this.authStorageService.getPermissions(); this.tableActions = [ { name: this.i18n('Scrub'), diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html index 7b5ec49d5ebe..3dea670f7777 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html @@ -10,7 +10,7 @@ selectionType="single" (updateSelection)="updateSelection($event)"> @@ -23,6 +23,7 @@ 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 52c6674bdaca..c24138b98cfe 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 @@ -37,7 +37,7 @@ describe('PoolListComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(PoolListComponent); component = fixture.componentInstance; - component.permission.read = true; + component.permissions.pool.read = true; poolService = TestBed.get(PoolService); fixture.detectChanges(); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts index 83b9774d43bf..12d094b06c44 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts @@ -13,7 +13,7 @@ import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { ExecutingTask } from '../../../shared/models/executing-task'; import { FinishedTask } from '../../../shared/models/finished-task'; -import { Permission } from '../../../shared/models/permissions'; +import { Permissions } from '../../../shared/models/permissions'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; import { TaskListService } from '../../../shared/services/task-list.service'; import { TaskWrapperService } from '../../../shared/services/task-wrapper.service'; @@ -34,7 +34,7 @@ export class PoolListComponent implements OnInit { selection = new CdTableSelection(); modalRef: BsModalRef; executingTasks: ExecutingTask[] = []; - permission: Permission; + permissions: Permissions; tableActions: CdTableAction[]; viewCacheStatusList: any[]; @@ -46,7 +46,7 @@ export class PoolListComponent implements OnInit { private modalService: BsModalService, private i18n: I18n ) { - this.permission = this.authStorageService.getPermissions().pool; + this.permissions = this.authStorageService.getPermissions(); this.tableActions = [ { permission: 'create', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.html index 2881e958c1c4..93a0c17e2c64 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.html @@ -12,6 +12,7 @@ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts index 4c6135accfe5..ff9badf3d897 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts @@ -4,6 +4,8 @@ import * as _ from 'lodash'; import { RgwDaemonService } from '../../../shared/api/rgw-daemon.service'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; +import { Permission } from '../../../shared/models/permissions'; +import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @Component({ selector: 'cd-rgw-daemon-details', @@ -13,11 +15,17 @@ import { CdTableSelection } from '../../../shared/models/cd-table-selection'; export class RgwDaemonDetailsComponent implements OnChanges { metadata: any; serviceId = ''; + grafanaPermission: Permission; @Input() selection: CdTableSelection; - constructor(private rgwDaemonService: RgwDaemonService) {} + constructor( + private rgwDaemonService: RgwDaemonService, + private authStorageService: AuthStorageService + ) { + this.grafanaPermission = this.authStorageService.getPermissions().grafana; + } ngOnChanges() { // Get the service id of the first selected row. diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html index 73fbc0f233a8..ee417def63ab 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html @@ -12,6 +12,7 @@ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts index d0eaaac9d439..7f6896155278 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts @@ -6,7 +6,9 @@ import { RgwDaemonService } from '../../../shared/api/rgw-daemon.service'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; +import { Permission } from '../../../shared/models/permissions'; import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe'; +import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @Component({ selector: 'cd-rgw-daemon-list', @@ -17,12 +19,15 @@ export class RgwDaemonListComponent { columns: CdTableColumn[] = []; daemons: object[] = []; selection: CdTableSelection = new CdTableSelection(); + grafanaPermission: Permission; constructor( private rgwDaemonService: RgwDaemonService, + private authStorageService: AuthStorageService, cephShortVersionPipe: CephShortVersionPipe, private i18n: I18n ) { + this.grafanaPermission = this.authStorageService.getPermissions().grafana; this.columns = [ { name: this.i18n('ID'), diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.spec.ts similarity index 71% rename from src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts rename to src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.spec.ts index ef96ac1e4b2a..4deecf42177a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.spec.ts @@ -2,19 +2,19 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/ import { TestBed } from '@angular/core/testing'; import { configureTestBed } from '../../../testing/unit-test-helper'; -import { SettingsService } from './settings.service'; +import { GrafanaService } from './grafana.service'; -describe('SettingsService', () => { - let service: SettingsService; +describe('GrafanaService', () => { + let service: GrafanaService; let httpTesting: HttpTestingController; configureTestBed({ - providers: [SettingsService], + providers: [GrafanaService], imports: [HttpClientTestingModule] }); beforeEach(() => { - service = TestBed.get(SettingsService); + service = TestBed.get(GrafanaService); httpTesting = TestBed.get(HttpTestingController); }); @@ -28,7 +28,7 @@ describe('SettingsService', () => { it('should get protocol', () => { service.getGrafanaApiUrl().subscribe(); - const req = httpTesting.expectOne('api/settings/GRAFANA_API_URL'); + const req = httpTesting.expectOne('api/grafana/url'); expect(req.request.method).toBe('GET'); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.ts similarity index 73% rename from src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts rename to src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.ts index db52c968ba56..6a37c2179ed1 100755 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.ts @@ -6,10 +6,10 @@ import { ApiModule } from './api.module'; @Injectable({ providedIn: ApiModule }) -export class SettingsService { +export class GrafanaService { constructor(private http: HttpClient) {} getGrafanaApiUrl() { - return this.http.get('api/settings/GRAFANA_API_URL'); + return this.http.get('api/grafana/url'); } } 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 8bdca309858e..a295049e02f0 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 @@ -5,7 +5,8 @@ import { RouterTestingModule } from '@angular/router/testing'; import { AlertModule } from 'ngx-bootstrap/alert'; import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper'; -import { SettingsService } from '../../../shared/api/settings.service'; +import { GrafanaService } from '../../../shared/api/grafana.service'; + import { SummaryService } from '../../../shared/services/summary.service'; import { CephReleaseNamePipe } from '../../pipes/ceph-release-name.pipe'; import { InfoPanelComponent } from '../info-panel/info-panel.component'; @@ -19,7 +20,7 @@ describe('GrafanaComponent', () => { configureTestBed({ declarations: [GrafanaComponent, InfoPanelComponent, LoadingPanelComponent], imports: [AlertModule.forRoot(), HttpClientTestingModule, RouterTestingModule], - providers: [CephReleaseNamePipe, SettingsService, SummaryService, i18nProviders] + providers: [CephReleaseNamePipe, GrafanaService, SummaryService, i18nProviders] }); 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 00fd332981a7..77dcfa232eea 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 @@ -3,9 +3,9 @@ import { Component, Input, OnChanges, OnInit } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { SafeUrl } from '@angular/platform-browser'; -import { SettingsService } from '../../api/settings.service'; -import { CephReleaseNamePipe } from '../../pipes/ceph-release-name.pipe'; -import { SummaryService } from '../../services/summary.service'; +import { GrafanaService } from '../../../shared/api/grafana.service'; +import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe'; +import { SummaryService } from '../../../shared/services/summary.service'; @Component({ selector: 'cd-grafana', @@ -38,7 +38,7 @@ export class GrafanaComponent implements OnInit, OnChanges { constructor( private summaryService: SummaryService, private sanitizer: DomSanitizer, - private settingsService: SettingsService, + private grafanaService: GrafanaService, private cephReleaseNamePipe: CephReleaseNamePipe ) {} @@ -64,8 +64,8 @@ export class GrafanaComponent implements OnInit, OnChanges { }, 0); }); - this.settingsService.getGrafanaApiUrl().subscribe((data: any) => { - this.grafanaUrl = data.value; + this.grafanaService.getGrafanaApiUrl().subscribe((data: any) => { + this.grafanaUrl = data.instance; if (this.grafanaUrl === '') { this.grafanaExist = false; return; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/permissions.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/permissions.ts index e8a50e9e42b9..0938e264b652 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/permissions.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/permissions.ts @@ -26,6 +26,7 @@ export class Permissions { manager: Permission; log: Permission; user: Permission; + grafana: Permission; constructor(serverPermissions: any) { this.hosts = new Permission(serverPermissions['hosts']); @@ -41,5 +42,6 @@ export class Permissions { this.manager = new Permission(serverPermissions['manager']); this.log = new Permission(serverPermissions['log']); this.user = new Permission(serverPermissions['user']); + this.grafana = new Permission(serverPermissions['grafana']); } } -- 2.47.3