]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory.component.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / inventory / inventory.component.ts
1 import { Component, Input, OnChanges, OnInit } from '@angular/core';
2
3 import { OrchestratorService } from '../../../shared/api/orchestrator.service';
4 import { Icons } from '../../../shared/enum/icons.enum';
5 import { InventoryDevice } from './inventory-devices/inventory-device.model';
6
7 @Component({
8 selector: 'cd-inventory',
9 templateUrl: './inventory.component.html',
10 styleUrls: ['./inventory.component.scss']
11 })
12 export class InventoryComponent implements OnChanges, OnInit {
13 // Display inventory page only for this hostname, ignore to display all.
14 @Input() hostname?: string;
15
16 icons = Icons;
17
18 hasOrchestrator = false;
19 docsUrl: string;
20
21 devices: Array<InventoryDevice> = [];
22
23 constructor(private orchService: OrchestratorService) {}
24
25 ngOnInit() {
26 this.orchService.status().subscribe((status) => {
27 this.hasOrchestrator = status.available;
28 if (status.available) {
29 this.getInventory();
30 }
31 });
32 }
33
34 ngOnChanges() {
35 if (this.hasOrchestrator) {
36 this.devices = [];
37 this.getInventory();
38 }
39 }
40
41 getInventory() {
42 if (this.hostname === '') {
43 return;
44 }
45 this.orchService.inventoryDeviceList(this.hostname).subscribe(
46 (devices: InventoryDevice[]) => {
47 this.devices = devices;
48 },
49 () => {
50 this.devices = [];
51 }
52 );
53 }
54
55 refresh() {
56 this.getInventory();
57 }
58 }