]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts
import 15.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / osd / osd-details / osd-details.component.ts
1 import { Component, Input, OnChanges } from '@angular/core';
2
3 import * as _ from 'lodash';
4
5 import { OsdService } from '../../../../shared/api/osd.service';
6 import { Permission } from '../../../../shared/models/permissions';
7 import { AuthStorageService } from '../../../../shared/services/auth-storage.service';
8
9 @Component({
10 selector: 'cd-osd-details',
11 templateUrl: './osd-details.component.html',
12 styleUrls: ['./osd-details.component.scss']
13 })
14 export class OsdDetailsComponent implements OnChanges {
15 @Input()
16 selection: any;
17
18 osd: {
19 id?: number;
20 details?: any;
21 histogram_failed?: string;
22 tree?: any;
23 };
24 grafanaPermission: Permission;
25
26 constructor(private osdService: OsdService, private authStorageService: AuthStorageService) {
27 this.grafanaPermission = this.authStorageService.getPermissions().grafana;
28 }
29
30 ngOnChanges() {
31 if (_.get(this, 'osd.id') !== _.get(this, 'selection.id')) {
32 this.osd = this.selection;
33 }
34
35 if (_.isNumber(_.get(this, 'osd.id'))) {
36 this.refresh();
37 }
38 }
39
40 refresh() {
41 this.osdService.getDetails(this.osd.id).subscribe((data) => {
42 this.osd.details = data;
43 this.osd.histogram_failed = '';
44 if (!_.isObject(data.histogram)) {
45 this.osd.histogram_failed = data.histogram;
46 this.osd.details.histogram = undefined;
47 }
48 });
49 }
50 }