]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / iscsi / iscsi.component.ts
1 import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
2
3 import { I18n } from '@ngx-translate/i18n-polyfill';
4
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';
9
10 @Component({
11 selector: 'cd-iscsi',
12 templateUrl: './iscsi.component.html',
13 styleUrls: ['./iscsi.component.scss']
14 })
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>;
22
23 gateways: any[] = [];
24 gatewaysColumns: any;
25 images: any[] = [];
26 imagesColumns: any;
27
28 constructor(
29 private iscsiService: IscsiService,
30 private dimlessPipe: DimlessPipe,
31 private iscsiBackstorePipe: IscsiBackstorePipe,
32 private i18n: I18n
33 ) {}
34
35 ngOnInit() {
36 this.gatewaysColumns = [
37 {
38 name: this.i18n('Name'),
39 prop: 'name'
40 },
41 {
42 name: this.i18n('State'),
43 prop: 'state',
44 flexGrow: 1,
45 cellTransformation: CellTemplate.badge,
46 customTemplateConfig: {
47 map: {
48 up: { class: 'badge-success' },
49 down: { class: 'badge-danger' }
50 }
51 }
52 },
53 {
54 name: this.i18n('# Targets'),
55 prop: 'num_targets'
56 },
57 {
58 name: this.i18n('# Sessions'),
59 prop: 'num_sessions'
60 }
61 ];
62 this.imagesColumns = [
63 {
64 name: this.i18n('Pool'),
65 prop: 'pool'
66 },
67 {
68 name: this.i18n('Image'),
69 prop: 'image'
70 },
71 {
72 name: this.i18n('Backstore'),
73 prop: 'backstore',
74 pipe: this.iscsiBackstorePipe
75 },
76 {
77 name: this.i18n('Read Bytes'),
78 prop: 'stats_history.rd_bytes',
79 cellTemplate: this.iscsiSparklineTpl
80 },
81 {
82 name: this.i18n('Write Bytes'),
83 prop: 'stats_history.wr_bytes',
84 cellTemplate: this.iscsiSparklineTpl
85 },
86 {
87 name: this.i18n('Read Ops'),
88 prop: 'stats.rd',
89 pipe: this.dimlessPipe,
90 cellTemplate: this.iscsiPerSecondTpl
91 },
92 {
93 name: this.i18n('Write Ops'),
94 prop: 'stats.wr',
95 pipe: this.dimlessPipe,
96 cellTemplate: this.iscsiPerSecondTpl
97 },
98 {
99 name: this.i18n('A/O Since'),
100 prop: 'optimized_since',
101 cellTemplate: this.iscsiRelativeDateTpl
102 }
103 ];
104 }
105
106 refresh() {
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]);
114 }
115 image.cdIsBinary = true;
116 return image;
117 });
118 });
119 }
120 }