File
Implements
Metadata
selector |
cd-mirroring-daemons |
styleUrls |
./daemon-list.component.scss |
templateUrl |
./daemon-list.component.html |
Constructor
constructor(rbdMirroringService: RbdMirroringService, cephShortVersionPipe: CephShortVersionPipe, i18n: I18n)
|
|
Parameters :
Name |
Type |
Optional |
rbdMirroringService |
RbdMirroringService
|
No
|
cephShortVersionPipe |
CephShortVersionPipe
|
No
|
i18n |
I18n
|
No
|
|
Methods
ngOnDestroy
|
ngOnDestroy()
|
|
|
columns
|
Type : literal type
|
|
healthTmpl
|
Type : TemplateRef<any>
|
Decorators :
@ViewChild('healthTmpl')
|
|
import { Component, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { I18n } from '@ngx-translate/i18n-polyfill';
import { Subscription } from 'rxjs';
import { RbdMirroringService } from '../../../../shared/api/rbd-mirroring.service';
import { CephShortVersionPipe } from '../../../../shared/pipes/ceph-short-version.pipe';
@Component({
selector: 'cd-mirroring-daemons',
templateUrl: './daemon-list.component.html',
styleUrls: ['./daemon-list.component.scss']
})
export class DaemonListComponent implements OnInit, OnDestroy {
@ViewChild('healthTmpl')
healthTmpl: TemplateRef<any>;
subs: Subscription;
data: [];
columns: {};
constructor(
private rbdMirroringService: RbdMirroringService,
private cephShortVersionPipe: CephShortVersionPipe,
private i18n: I18n
) {}
ngOnInit() {
this.columns = [
{ prop: 'instance_id', name: this.i18n('Instance'), flexGrow: 2 },
{ prop: 'id', name: this.i18n('ID'), flexGrow: 2 },
{ prop: 'server_hostname', name: this.i18n('Hostname'), flexGrow: 2 },
{
prop: 'version',
name: this.i18n('Version'),
pipe: this.cephShortVersionPipe,
flexGrow: 2
},
{
prop: 'health',
name: this.i18n('Health'),
cellTemplate: this.healthTmpl,
flexGrow: 1
}
];
this.subs = this.rbdMirroringService.subscribeSummary((data: any) => {
if (!data) {
return;
}
this.data = data.content_data.daemons;
});
}
ngOnDestroy(): void {
this.subs.unsubscribe();
}
refresh() {
this.rbdMirroringService.refresh();
}
}
<cd-table [data]="data"
columnMode="flex"
[columns]="columns"
[autoReload]="0"
(fetchData)="refresh()">
</cd-table>
<ng-template #healthTmpl
let-row="row"
let-value="value">
<span [ngClass]="row.health_color | mirrorHealthColor">{{ value }}</span>
</ng-template>
Legend
Html element with directive