]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { Component, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core'; |
2 | ||
3 | import { I18n } from '@ngx-translate/i18n-polyfill'; | |
4 | import { Subscription } from 'rxjs'; | |
5 | ||
6 | import { RbdMirroringService } from '../../../../shared/api/rbd-mirroring.service'; | |
7 | import { CephShortVersionPipe } from '../../../../shared/pipes/ceph-short-version.pipe'; | |
8 | ||
9 | @Component({ | |
10 | selector: 'cd-mirroring-daemons', | |
11 | templateUrl: './daemon-list.component.html', | |
12 | styleUrls: ['./daemon-list.component.scss'] | |
13 | }) | |
14 | export class DaemonListComponent implements OnInit, OnDestroy { | |
9f95a23c | 15 | @ViewChild('healthTmpl', { static: true }) |
11fdf7f2 TL |
16 | healthTmpl: TemplateRef<any>; |
17 | ||
18 | subs: Subscription; | |
19 | ||
20 | data: []; | |
21 | columns: {}; | |
22 | ||
23 | constructor( | |
24 | private rbdMirroringService: RbdMirroringService, | |
25 | private cephShortVersionPipe: CephShortVersionPipe, | |
26 | private i18n: I18n | |
27 | ) {} | |
28 | ||
29 | ngOnInit() { | |
30 | this.columns = [ | |
31 | { prop: 'instance_id', name: this.i18n('Instance'), flexGrow: 2 }, | |
32 | { prop: 'id', name: this.i18n('ID'), flexGrow: 2 }, | |
33 | { prop: 'server_hostname', name: this.i18n('Hostname'), flexGrow: 2 }, | |
34 | { | |
35 | prop: 'version', | |
36 | name: this.i18n('Version'), | |
37 | pipe: this.cephShortVersionPipe, | |
38 | flexGrow: 2 | |
39 | }, | |
40 | { | |
41 | prop: 'health', | |
42 | name: this.i18n('Health'), | |
43 | cellTemplate: this.healthTmpl, | |
44 | flexGrow: 1 | |
45 | } | |
46 | ]; | |
47 | ||
f6b5b4d7 | 48 | this.subs = this.rbdMirroringService.subscribeSummary((data) => { |
11fdf7f2 TL |
49 | this.data = data.content_data.daemons; |
50 | }); | |
51 | } | |
52 | ||
53 | ngOnDestroy(): void { | |
54 | this.subs.unsubscribe(); | |
55 | } | |
56 | ||
57 | refresh() { | |
58 | this.rbdMirroringService.refresh(); | |
59 | } | |
60 | } |