<a ngbNavLink
i18n>Devices</a>
<ng-template ngbNavContent>
- <cd-device-list *ngIf="osd.loaded && osd.id !== null"
- [osdId]="osd.id"></cd-device-list>
+ <cd-device-list [osdId]="osd?.id"></cd-device-list>
</ng-template>
</li>
<li ngbNavItem>
<a ngbNavLink
i18n>Attributes (OSD map)</a>
<ng-template ngbNavContent>
- <cd-table-key-value *ngIf="osd.loaded"
- [data]="osd.details.osd_map">
+ <cd-table-key-value [data]="osd?.details?.osd_map">
</cd-table-key-value>
</ng-template>
</li>
<a ngbNavLink
i18n>Metadata</a>
<ng-template ngbNavContent>
- <cd-table-key-value *ngIf="osd.loaded && osd.details.osd_metadata; else noMetaData"
+ <cd-table-key-value *ngIf="osd?.details?.osd_metadata; else noMetaData"
(fetchData)="refresh()"
- [data]="osd.details.osd_metadata">
+ [data]="osd?.details?.osd_metadata">
</cd-table-key-value>
<ng-template #noMetaData>
<cd-alert-panel type="warning"
<a ngbNavLink
i18n>Device health</a>
<ng-template ngbNavContent>
- <cd-smart-list [osdId]="osd.id"></cd-smart-list>
+ <cd-smart-list [osdId]="osd?.id"></cd-smart-list>
</ng-template>
</li>
<li ngbNavItem>
<a ngbNavLink
i18n>Performance counter</a>
<ng-template ngbNavContent>
- <cd-table-performance-counter *ngIf="osd.loaded"
+ <cd-table-performance-counter *ngIf="osd?.details"
serviceType="osd"
- [serviceId]="osd.id">
+ [serviceId]="osd?.id">
</cd-table-performance-counter>
</ng-template>
</li>
<a ngbNavLink
i18n>Histogram</a>
<ng-template ngbNavContent>
- <cd-alert-panel *ngIf="osd.loaded && osd.histogram_failed"
+ <cd-alert-panel *ngIf="osd?.histogram_failed"
type="warning"
- i18n>Histogram not available: {{ osd.histogram_failed }}</cd-alert-panel>
+ i18n>Histogram not available: {{ osd?.histogram_failed }}</cd-alert-panel>
<div class="row"
- *ngIf="osd.loaded && osd.details.histogram">
+ *ngIf="osd?.details?.histogram">
<div class="col-md-6">
<h4 i18n>Writes</h4>
- <cd-osd-performance-histogram [histogram]="osd.details.histogram.osd.op_w_latency_in_bytes_histogram">
+ <cd-osd-performance-histogram [histogram]="osd?.details?.histogram?.osd?.op_w_latency_in_bytes_histogram">
</cd-osd-performance-histogram>
</div>
<div class="col-md-6">
<h4 i18n>Reads</h4>
- <cd-osd-performance-histogram [histogram]="osd.details.histogram.osd.op_r_latency_out_bytes_histogram">
+ <cd-osd-performance-histogram [histogram]="osd?.details?.histogram?.osd?.op_r_latency_out_bytes_histogram">
</cd-osd-performance-histogram>
</div>
</div>
import { DatePipe } from '@angular/common';
-import { Component, Input, OnInit, TemplateRef, ViewChild } from '@angular/core';
+import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { I18n } from '@ngx-translate/i18n-polyfill';
templateUrl: './device-list.component.html',
styleUrls: ['./device-list.component.scss']
})
-export class DeviceListComponent implements OnInit {
+export class DeviceListComponent implements OnChanges, OnInit {
@Input()
hostname = '';
@Input()
) {}
ngOnInit() {
- const updateDevicesFn = (devices: CdDevice[]) => (this.devices = devices);
- if (this.hostname) {
- this.hostService.getDevices(this.hostname).subscribe(updateDevicesFn);
- } else if (this.osdId !== null) {
- this.osdService.getDevices(this.osdId).subscribe(updateDevicesFn);
- }
this.columns = [
{ prop: 'devid', name: this.i18n('Device ID'), minWidth: 200 },
{
{ prop: 'readableDaemons', name: this.i18n('Daemons') }
];
}
+
+ ngOnChanges() {
+ const updateDevicesFn = (devices: CdDevice[]) => (this.devices = devices);
+ if (this.hostname) {
+ this.hostService.getDevices(this.hostname).subscribe(updateDevicesFn);
+ } else if (this.osdId !== null) {
+ this.osdService.getDevices(this.osdId).subscribe(updateDevicesFn);
+ }
+ }
}