]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { Component, Input, OnChanges } from '@angular/core'; |
2 | ||
f67539c2 | 3 | import _ from 'lodash'; |
11fdf7f2 | 4 | |
f67539c2 TL |
5 | import { OsdService } from '~/app/shared/api/osd.service'; |
6 | import { Permission } from '~/app/shared/models/permissions'; | |
7 | import { AuthStorageService } from '~/app/shared/services/auth-storage.service'; | |
11fdf7f2 TL |
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 | 20 | details?: any; |
9f95a23c TL |
21 | tree?: any; |
22 | }; | |
11fdf7f2 TL |
23 | grafanaPermission: Permission; |
24 | ||
25 | constructor(private osdService: OsdService, private authStorageService: AuthStorageService) { | |
26 | this.grafanaPermission = this.authStorageService.getPermissions().grafana; | |
27 | } | |
28 | ||
29 | ngOnChanges() { | |
f67539c2 | 30 | if (this.osd?.id !== this.selection?.id) { |
e306af50 | 31 | this.osd = this.selection; |
f6b5b4d7 TL |
32 | } |
33 | ||
f67539c2 | 34 | if (_.isNumber(this.osd?.id)) { |
11fdf7f2 TL |
35 | this.refresh(); |
36 | } | |
37 | } | |
38 | ||
39 | refresh() { | |
9f95a23c | 40 | this.osdService.getDetails(this.osd.id).subscribe((data) => { |
11fdf7f2 | 41 | this.osd.details = data; |
11fdf7f2 TL |
42 | }); |
43 | } | |
44 | } |