]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.ts
import 15.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / shared / device-list / device-list.component.ts
index d16ee7cbe8d38d7d7328d80af5417b508b6bf3de..949b8acf14a26682125ad65b4d09ccb7c19e300f 100644 (file)
@@ -1,5 +1,6 @@
 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';
 import { HostService } from '../../../shared/api/host.service';
 import { OsdService } from '../../../shared/api/osd.service';
@@ -12,7 +13,7 @@ import { CdDevice } from '../../../shared/models/devices';
   templateUrl: './device-list.component.html',
   styleUrls: ['./device-list.component.scss']
 })
-export class DeviceListComponent implements OnInit {
+export class DeviceListComponent implements OnChanges, OnInit {
   @Input()
   hostname = '';
   @Input()
@@ -40,12 +41,6 @@ export class DeviceListComponent implements OnInit {
   ) {}
 
   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 },
       {
@@ -79,4 +74,13 @@ export class DeviceListComponent implements OnInit {
       { 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);
+    }
+  }
 }