]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { Component, Input, OnChanges } from '@angular/core'; |
2 | ||
3 | import * as _ from 'lodash'; | |
4 | ||
5 | import { OsdService } from '../../../../shared/api/osd.service'; | |
11fdf7f2 TL |
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() | |
e306af50 | 16 | selection: any; |
11fdf7f2 | 17 | |
9f95a23c TL |
18 | osd: { |
19 | id?: number; | |
9f95a23c TL |
20 | details?: any; |
21 | histogram_failed?: string; | |
22 | tree?: any; | |
23 | }; | |
11fdf7f2 TL |
24 | grafanaPermission: Permission; |
25 | ||
26 | constructor(private osdService: OsdService, private authStorageService: AuthStorageService) { | |
27 | this.grafanaPermission = this.authStorageService.getPermissions().grafana; | |
28 | } | |
29 | ||
30 | ngOnChanges() { | |
f6b5b4d7 | 31 | if (_.get(this, 'osd.id') !== _.get(this, 'selection.id')) { |
e306af50 | 32 | this.osd = this.selection; |
f6b5b4d7 TL |
33 | } |
34 | ||
35 | if (_.isNumber(_.get(this, 'osd.id'))) { | |
11fdf7f2 TL |
36 | this.refresh(); |
37 | } | |
38 | } | |
39 | ||
40 | refresh() { | |
9f95a23c | 41 | this.osdService.getDetails(this.osd.id).subscribe((data) => { |
11fdf7f2 TL |
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 | } | |
11fdf7f2 TL |
48 | }); |
49 | } | |
50 | } |