@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
</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">
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',
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) {
-<tabset *ngIf="selection.hasSingleSelection">
+<tabset *ngIf="selection.hasSingleSelection && grafanaPermission.read">
<tab i18n-heading
heading="Performance Details">
<cd-grafana [grafanaPath]="'7IGu2Ttmz/host-details?'"
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',
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) {
</cd-table>
</tab>
<tab i18n-heading
+ *ngIf="permissions.grafana.read"
heading="Overall Performance">
<cd-grafana [grafanaPath]="'lxnjcTAmk/host-overview?'"
grafanaStyle="two">
</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">
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',
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 = {
(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">
</ng-template>
</tab>
<tab i18n-heading
+ *ngIf="permissions.grafana.read"
heading="Overall Performance">
<cd-grafana [grafanaPath]="'lo02I1Aiz/osd-overview?'"
grafanaStyle="three">
component.selection.selected = selection;
component.selection.update();
component.osds = data;
+ component.permissions = fakeAuthStorageService.getPermissions();
};
const openActionModal = (actionName) => {
};
beforeEach(() => {
- permissionHelper = new PermissionHelper(component.permission, () =>
+ permissionHelper = new PermissionHelper(component.permissions.osd, () =>
getTableActionComponent()
);
scenario = {
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';
@ViewChild('safeToDestroyBodyTpl')
safeToDestroyBodyTpl: TemplateRef<any>;
- permission: Permission;
+ permissions: Permissions;
tableActions: CdTableAction[];
bsModalRef: BsModalRef;
columns: CdTableColumn[];
private modalService: BsModalService,
private i18n: I18n
) {
- this.permission = this.authStorageService.getPermissions().osd;
+ this.permissions = this.authStorageService.getPermissions();
this.tableActions = [
{
name: this.i18n('Scrub'),
selectionType="single"
(updateSelection)="updateSelection($event)">
<cd-table-actions class="table-actions"
- [permission]="permission"
+ [permission]="permissions.pool"
[selection]="selection"
[tableActions]="tableActions">
</cd-table-actions>
</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']"
</tab>
<tab i18n-heading
+ *ngIf="permissions.grafana.read"
heading="Overall Performance">
<cd-grafana [grafanaPath]="'z99hzWtmk/ceph-pools-overview?'"
grafanaStyle="two">
beforeEach(() => {
fixture = TestBed.createComponent(PoolListComponent);
component = fixture.componentInstance;
- component.permission.read = true;
+ component.permissions.pool.read = true;
poolService = TestBed.get(PoolService);
fixture.detectChanges();
});
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';
selection = new CdTableSelection();
modalRef: BsModalRef;
executingTasks: ExecutingTask[] = [];
- permission: Permission;
+ permissions: Permissions;
tableActions: CdTableAction[];
viewCacheStatusList: any[];
private modalService: BsModalService,
private i18n: I18n
) {
- this.permission = this.authStorageService.getPermissions().pool;
+ this.permissions = this.authStorageService.getPermissions();
this.tableActions = [
{
permission: 'create',
</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">
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',
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.
</tab>
<tab i18n-heading
+ *ngIf="grafanaPermission.read"
heading="Overall Performance">
<cd-grafana [grafanaPath]="'WAkugZpiz/rgw-overview?'"
grafanaStyle="two">
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',
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'),
--- /dev/null
+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');
+ });
+});
--- /dev/null
+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');
+ }
+}
+++ /dev/null
-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');
- });
-});
+++ /dev/null
-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');
- }
-}
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';
configureTestBed({
declarations: [GrafanaComponent, InfoPanelComponent, LoadingPanelComponent],
imports: [AlertModule.forRoot(), HttpClientTestingModule, RouterTestingModule],
- providers: [CephReleaseNamePipe, SettingsService, SummaryService, i18nProviders]
+ providers: [CephReleaseNamePipe, GrafanaService, SummaryService, i18nProviders]
});
beforeEach(() => {
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',
constructor(
private summaryService: SummaryService,
private sanitizer: DomSanitizer,
- private settingsService: SettingsService,
+ private grafanaService: GrafanaService,
private cephReleaseNamePipe: CephReleaseNamePipe
) {}
}, 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;
manager: Permission;
log: Permission;
user: Permission;
+ grafana: Permission;
constructor(serverPermissions: any) {
this.hosts = new Permission(serverPermissions['hosts']);
this.manager = new Permission(serverPermissions['manager']);
this.log = new Permission(serverPermissions['log']);
this.user = new Permission(serverPermissions['user']);
+ this.grafana = new Permission(serverPermissions['grafana']);
}
}