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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { IscsiService } from '~/app/shared/api/iscsi.service';
import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
import { DimlessPipe } from '~/app/shared/pipes/dimless.pipe';
import { IscsiBackstorePipe } from '~/app/shared/pipes/iscsi-backstore.pipe';
@Component({
selector: 'cd-iscsi',
templateUrl: './iscsi.component.html',
styleUrls: ['./iscsi.component.scss']
})
export class IscsiComponent implements OnInit {
@ViewChild('iscsiSparklineTpl', { static: true })
iscsiSparklineTpl: TemplateRef<any>;
@ViewChild('iscsiPerSecondTpl', { static: true })
iscsiPerSecondTpl: TemplateRef<any>;
@ViewChild('iscsiRelativeDateTpl', { static: true })
iscsiRelativeDateTpl: TemplateRef<any>;
gateways: any[] = [];
gatewaysColumns: any;
images: any[] = [];
imagesColumns: any;
constructor(
private iscsiService: IscsiService,
private dimlessPipe: DimlessPipe,
private iscsiBackstorePipe: IscsiBackstorePipe
) {}
ngOnInit() {
this.gatewaysColumns = [
{
name: $localize`Name`,
prop: 'name'
},
{
name: $localize`State`,
prop: 'state',
flexGrow: 1,
cellTransformation: CellTemplate.badge,
customTemplateConfig: {
map: {
up: { class: 'badge-success' },
down: { class: 'badge-danger' }
}
}
},
{
name: $localize`# Targets`,
prop: 'num_targets'
},
{
name: $localize`# Sessions`,
prop: 'num_sessions'
}
];
this.imagesColumns = [
{
name: $localize`Pool`,
prop: 'pool'
},
{
name: $localize`Image`,
prop: 'image'
},
{
name: $localize`Backstore`,
prop: 'backstore',
pipe: this.iscsiBackstorePipe
},
{
name: $localize`Read Bytes`,
prop: 'stats_history.rd_bytes',
cellTemplate: this.iscsiSparklineTpl
},
{
name: $localize`Write Bytes`,
prop: 'stats_history.wr_bytes',
cellTemplate: this.iscsiSparklineTpl
},
{
name: $localize`Read Ops`,
prop: 'stats.rd',
pipe: this.dimlessPipe,
cellTemplate: this.iscsiPerSecondTpl
},
{
name: $localize`Write Ops`,
prop: 'stats.wr',
pipe: this.dimlessPipe,
cellTemplate: this.iscsiPerSecondTpl
},
{
name: $localize`A/O Since`,
prop: 'optimized_since',
cellTemplate: this.iscsiRelativeDateTpl
}
];
}
refresh() {
this.iscsiService.overview().subscribe((overview: object) => {
this.gateways = overview['gateways'];
this.images = overview['images'];
this.images.map((image) => {
if (image.stats_history) {
image.stats_history.rd_bytes = image.stats_history.rd_bytes.map((i: any) => i[1]);
image.stats_history.wr_bytes = image.stats_history.wr_bytes.map((i: any) => i[1]);
}
image.cdIsBinary = true;
return image;
});
});
}
}
|