-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvm.component.ts
More file actions
47 lines (40 loc) · 838 Bytes
/
vm.component.ts
File metadata and controls
47 lines (40 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { OnInit } from '@angular/core';
import { VMService } from "./vm.service";
import { VM } from "./vm";
export abstract class VMComponent implements OnInit {
vmService !: VMService;
errorMessage: string;
vms: VM[];
constructor() {
this.vms = [];
}
getVMs(): void {
this.vmService
.getVMs()
.toPromise()
.then(
vms => {
this.vms = vms;
}
);
}
deleteVM(vm: VM): void {
this.vmService
.deleteVM(vm)
.toPromise();
}
refreshVMs(period: number): void {
this.vmService
.refreshVMs(period)
.subscribe(
vms => {
this.vms = vms;
},
error => this.errorMessage = <any>error
);
}
ngOnInit() {
this.getVMs();
this.refreshVMs(5000);
}
}