]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Show/Hide Grafana tabs according to user role
authorKanika Murarka <kmurarka@redhat.com>
Mon, 19 Nov 2018 08:13:52 +0000 (13:43 +0530)
committerKanika Murarka <kmurarka@redhat.com>
Mon, 19 Nov 2018 08:13:52 +0000 (13:43 +0530)
Fixes: http://tracker.ceph.com/issues/36655
Signed-off-by: Kanika Murarka <kmurarka@redhat.com>
25 files changed:
src/pybind/mgr/dashboard/controllers/grafana.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-details/host-details.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-details/host-details.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.spec.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.ts [new file with mode: 0755]
src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts [deleted file]
src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.ts [deleted file]
src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/grafana/grafana.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/models/permissions.ts

index a18dd9c18534b48f9bcf961cab1f5a4053c08db0..e24c0cc161b76723117a4042d75b0de2ba799420 100644 (file)
@@ -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
 
index 974068b972b2a688889d7d44db6166cb29ee027e..0449b299cc9ca54f176e67064ace36f53a1060d3 100644 (file)
@@ -41,6 +41,7 @@
     </cd-cephfs-clients>
   </tab>
   <tab i18n-heading
+       *ngIf="grafanaPermission.read"
        heading="Performance Details">
     <cd-grafana [grafanaPath]="'rRfFzWtik/mds-performance?var-mds_servers=mds.' + grafanaId"
                 grafanaStyle="one">
index a5ef1733c69d8e9818f503619a2eb36020f7272c..1db21cedac6d85a82a76c141c5cb593df3a30190 100644 (file)
@@ -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) {
index 2f26bf7d46f39c3381f0042ab1a4139024493d1c..ca992c9f16b32e63751a90a28c8d6b5fee1fe14b 100644 (file)
@@ -1,4 +1,4 @@
-<tabset *ngIf="selection.hasSingleSelection">
+<tabset *ngIf="selection.hasSingleSelection && grafanaPermission.read">
   <tab i18n-heading
        heading="Performance Details">
     <cd-grafana [grafanaPath]="'7IGu2Ttmz/host-details?'"
index f72b7b2b959478af089a9f3403d915627f2d4667..dfd3c16f31d54c743a173adc042a5c200e851a6d 100644 (file)
@@ -1,6 +1,8 @@
 import { Component, Input, OnChanges } from '@angular/core';
 
 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-host-details',
@@ -8,11 +10,14 @@ import { CdTableSelection } from '../../../../shared/models/cd-table-selection';
   styleUrls: ['./host-details.component.scss']
 })
 export class HostDetailsComponent implements OnChanges {
+  grafanaPermission: Permission;
   @Input()
   selection: CdTableSelection;
   host: any;
 
-  constructor() {}
+  constructor(private authStorageService: AuthStorageService) {
+    this.grafanaPermission = this.authStorageService.getPermissions().grafana;
+  }
 
   ngOnChanges() {
     if (this.selection.hasSelection) {
index 614f172cc8bc9295218beb50c89e0438f26603f8..e514b610ed0dbd0791c74f6008df79b749a9ef8d 100644 (file)
@@ -25,6 +25,7 @@
     </cd-table>
   </tab>
   <tab i18n-heading
+       *ngIf="permissions.grafana.read"
        heading="Overall Performance">
     <cd-grafana [grafanaPath]="'lxnjcTAmk/host-overview?'"
                 grafanaStyle="two">
index c037ebac55d55ef478a6ec08faab0e02fe48b386..a7238b7a3e9b535c4fb1def9c9454726fa3d1c35 100644 (file)
@@ -42,6 +42,7 @@
     </div>
   </tab>
   <tab i18n-heading
+       *ngIf="grafanaPermission.read"
        heading="Performance Details">
     <cd-grafana [grafanaPath]="'MKj_9ipiz/osd-device-details?var-osd_id=' + osd['id']"
                 grafanaStyle="GrafanaStyles.two">
index d4ace9fb3775a93e15e473bd36488ef380c5acb5..766fc2dbc24efb5dd601f8cea5583d30caacb6ca 100644 (file)
@@ -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 = {
index dffa66292daad4d076c90524f8510fda1531dfd9..88a711023293935225b1f0a430d0af99ff614e22 100644 (file)
@@ -8,7 +8,7 @@
               (updateSelection)="updateSelection($event)"
               [updateSelectionOnRefresh]="'never'">
       <div class="table-actions btn-toolbar">
-        <cd-table-actions [permission]="permission"
+        <cd-table-actions [permission]="permissions.osd"
                           [selection]="selection"
                           class="btn-group"
                           [tableActions]="tableActions">
@@ -46,6 +46,7 @@
     </ng-template>
   </tab>
   <tab i18n-heading
+       *ngIf="permissions.grafana.read"
        heading="Overall Performance">
     <cd-grafana [grafanaPath]="'lo02I1Aiz/osd-overview?'"
                 grafanaStyle="three">
index 53fb10e29a319b1943e8a034b59a39c89821ae15..7288cee3e26efbe2e08b7aede081b84e2eb7de69 100644 (file)
@@ -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 = {
index 1aadc0219ebe066f1cc3a5a18ed1a2b2c766b479..e685e1de85a85f31ac6ff25af33eccc79db34dbb 100644 (file)
@@ -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<any>;
 
-  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'),
index 7b5ec49d5ebe3722efc7f962a7c37744e0767a24..3dea670f77771fd14b0988d66227739826c0bd46 100644 (file)
@@ -10,7 +10,7 @@
               selectionType="single"
               (updateSelection)="updateSelection($event)">
       <cd-table-actions class="table-actions"
-                        [permission]="permission"
+                        [permission]="permissions.pool"
                         [selection]="selection"
                         [tableActions]="tableActions">
       </cd-table-actions>
@@ -23,6 +23,7 @@
           </cd-table-key-value>
         </tab>
         <tab i18n-heading
+             *ngIf="permissions.grafana.read"
              heading="Performance Details">
           <cd-grafana [grafanaPath]="'8ypfkWpik/ceph-pool-detail?var-pool_name='
                       + selection.first()['pool_name']"
@@ -34,6 +35,7 @@
   </tab>
 
   <tab i18n-heading
+       *ngIf="permissions.grafana.read"
        heading="Overall Performance">
     <cd-grafana [grafanaPath]="'z99hzWtmk/ceph-pools-overview?'"
                 grafanaStyle="two">
index 52c6674bdacaf882063f3da554371fbdb93c2d99..c24138b98cfe2d7e83832640ffdd3559d850ffd7 100644 (file)
@@ -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();
   });
index 83b9774d43bf84c083e6f38c40d3ba93e067072e..12d094b06c44d5592f128455b59a44ee63a14314 100644 (file)
@@ -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',
index 2881e958c1c42d8874d72650037d97640b94a548..93a0c17e2c64f3da4d2d26457720b46b24ab3043 100644 (file)
@@ -12,6 +12,7 @@
     </cd-table-performance-counter>
   </tab>
   <tab i18n-heading
+       *ngIf="grafanaPermission.read"
        heading="Performance Details">
     <cd-grafana [grafanaPath]="'x5ARzZtmk/rgw-instance-detail?var-rgw_servers=rgw.' + this.selection.first().id"
                 grafanaStyle="one">
index 4c6135accfe564618be0de6fc60eb07760f0bf64..ff9badf3d8977d14932ec283c66f48f73f5324f9 100644 (file)
@@ -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.
index 73fbc0f233a8c86bee0a7f0e7739b3783cf95eaf..ee417def63ab7643b963ab4b08cc3ee19122459c 100644 (file)
@@ -12,6 +12,7 @@
   </tab>
 
   <tab i18n-heading
+       *ngIf="grafanaPermission.read"
        heading="Overall Performance">
     <cd-grafana [grafanaPath]="'WAkugZpiz/rgw-overview?'"
                 grafanaStyle="two">
index d0eaaac9d4390fe537b36fc4303ff143d9c3cd23..7f689615527821602682b6fbd7eaf99a6a4338ad 100644 (file)
@@ -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/grafana.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.spec.ts
new file mode 100644 (file)
index 0000000..4deecf4
--- /dev/null
@@ -0,0 +1,34 @@
+import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
+import { TestBed } from '@angular/core/testing';
+
+import { configureTestBed } from '../../../testing/unit-test-helper';
+import { GrafanaService } from './grafana.service';
+
+describe('GrafanaService', () => {
+  let service: GrafanaService;
+  let httpTesting: HttpTestingController;
+
+  configureTestBed({
+    providers: [GrafanaService],
+    imports: [HttpClientTestingModule]
+  });
+
+  beforeEach(() => {
+    service = TestBed.get(GrafanaService);
+    httpTesting = TestBed.get(HttpTestingController);
+  });
+
+  afterEach(() => {
+    httpTesting.verify();
+  });
+
+  it('should be created', () => {
+    expect(service).toBeTruthy();
+  });
+
+  it('should get protocol', () => {
+    service.getGrafanaApiUrl().subscribe();
+    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/grafana.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/grafana.service.ts
new file mode 100755 (executable)
index 0000000..6a37c21
--- /dev/null
@@ -0,0 +1,15 @@
+import { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+
+import { ApiModule } from './api.module';
+
+@Injectable({
+  providedIn: ApiModule
+})
+export class GrafanaService {
+  constructor(private http: HttpClient) {}
+
+  getGrafanaApiUrl() {
+    return this.http.get('api/grafana/url');
+  }
+}
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/settings.service.spec.ts
deleted file mode 100644 (file)
index ef96ac1..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
-import { TestBed } from '@angular/core/testing';
-
-import { configureTestBed } from '../../../testing/unit-test-helper';
-import { SettingsService } from './settings.service';
-
-describe('SettingsService', () => {
-  let service: SettingsService;
-  let httpTesting: HttpTestingController;
-
-  configureTestBed({
-    providers: [SettingsService],
-    imports: [HttpClientTestingModule]
-  });
-
-  beforeEach(() => {
-    service = TestBed.get(SettingsService);
-    httpTesting = TestBed.get(HttpTestingController);
-  });
-
-  afterEach(() => {
-    httpTesting.verify();
-  });
-
-  it('should be created', () => {
-    expect(service).toBeTruthy();
-  });
-
-  it('should get protocol', () => {
-    service.getGrafanaApiUrl().subscribe();
-    const req = httpTesting.expectOne('api/settings/GRAFANA_API_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/settings.service.ts
deleted file mode 100755 (executable)
index db52c96..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-import { HttpClient } from '@angular/common/http';
-import { Injectable } from '@angular/core';
-
-import { ApiModule } from './api.module';
-
-@Injectable({
-  providedIn: ApiModule
-})
-export class SettingsService {
-  constructor(private http: HttpClient) {}
-
-  getGrafanaApiUrl() {
-    return this.http.get('api/settings/GRAFANA_API_URL');
-  }
-}
index 8bdca309858e1e0e64d7832f3e0355e9ac08fb54..a295049e02f0c138295cf21e0ebddd00c046c8ac 100644 (file)
@@ -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(() => {
index 00fd332981a79bf84dbd9e626a0b2c095e248fa5..77dcfa232eeac88645f6da1c8eb155cc848428ee 100644 (file)
@@ -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;
index e8a50e9e42b9295ee2e0ee9a5e7c1d158c945c0b..0938e264b652b0a321c52d6ff7185d36a38c43d4 100644 (file)
@@ -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']);
   }
 }