1 import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
3 import { I18n } from '@ngx-translate/i18n-polyfill';
5 import { IscsiService } from '../../../shared/api/iscsi.service';
6 import { CellTemplate } from '../../../shared/enum/cell-template.enum';
7 import { DimlessPipe } from '../../../shared/pipes/dimless.pipe';
8 import { IscsiBackstorePipe } from '../../../shared/pipes/iscsi-backstore.pipe';
12 templateUrl: './iscsi.component.html',
13 styleUrls: ['./iscsi.component.scss']
15 export class IscsiComponent implements OnInit {
16 @ViewChild('iscsiSparklineTpl', { static: true })
17 iscsiSparklineTpl: TemplateRef<any>;
18 @ViewChild('iscsiPerSecondTpl', { static: true })
19 iscsiPerSecondTpl: TemplateRef<any>;
20 @ViewChild('iscsiRelativeDateTpl', { static: true })
21 iscsiRelativeDateTpl: TemplateRef<any>;
29 private iscsiService: IscsiService,
30 private dimlessPipe: DimlessPipe,
31 private iscsiBackstorePipe: IscsiBackstorePipe,
36 this.gatewaysColumns = [
38 name: this.i18n('Name'),
42 name: this.i18n('State'),
45 cellTransformation: CellTemplate.badge,
46 customTemplateConfig: {
48 up: { class: 'badge-success' },
49 down: { class: 'badge-danger' }
54 name: this.i18n('# Targets'),
58 name: this.i18n('# Sessions'),
62 this.imagesColumns = [
64 name: this.i18n('Pool'),
68 name: this.i18n('Image'),
72 name: this.i18n('Backstore'),
74 pipe: this.iscsiBackstorePipe
77 name: this.i18n('Read Bytes'),
78 prop: 'stats_history.rd_bytes',
79 cellTemplate: this.iscsiSparklineTpl
82 name: this.i18n('Write Bytes'),
83 prop: 'stats_history.wr_bytes',
84 cellTemplate: this.iscsiSparklineTpl
87 name: this.i18n('Read Ops'),
89 pipe: this.dimlessPipe,
90 cellTemplate: this.iscsiPerSecondTpl
93 name: this.i18n('Write Ops'),
95 pipe: this.dimlessPipe,
96 cellTemplate: this.iscsiPerSecondTpl
99 name: this.i18n('A/O Since'),
100 prop: 'optimized_since',
101 cellTemplate: this.iscsiRelativeDateTpl
107 this.iscsiService.overview().subscribe((overview: object) => {
108 this.gateways = overview['gateways'];
109 this.images = overview['images'];
110 this.images.map((image) => {
111 if (image.stats_history) {
112 image.stats_history.rd_bytes = image.stats_history.rd_bytes.map((i: any) => i[1]);
113 image.stats_history.wr_bytes = image.stats_history.wr_bytes.map((i: any) => i[1]);
115 image.cdIsBinary = true;