]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / iscsi / iscsi.component.ts
CommitLineData
11fdf7f2
TL
1import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
2
f67539c2
TL
3import { IscsiService } from '~/app/shared/api/iscsi.service';
4import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
5import { DimlessPipe } from '~/app/shared/pipes/dimless.pipe';
6import { IscsiBackstorePipe } from '~/app/shared/pipes/iscsi-backstore.pipe';
11fdf7f2
TL
7
8@Component({
9 selector: 'cd-iscsi',
10 templateUrl: './iscsi.component.html',
11 styleUrls: ['./iscsi.component.scss']
12})
13export class IscsiComponent implements OnInit {
9f95a23c 14 @ViewChild('iscsiSparklineTpl', { static: true })
11fdf7f2 15 iscsiSparklineTpl: TemplateRef<any>;
9f95a23c 16 @ViewChild('iscsiPerSecondTpl', { static: true })
11fdf7f2 17 iscsiPerSecondTpl: TemplateRef<any>;
9f95a23c 18 @ViewChild('iscsiRelativeDateTpl', { static: true })
11fdf7f2
TL
19 iscsiRelativeDateTpl: TemplateRef<any>;
20
9f95a23c 21 gateways: any[] = [];
11fdf7f2 22 gatewaysColumns: any;
9f95a23c 23 images: any[] = [];
11fdf7f2
TL
24 imagesColumns: any;
25
26 constructor(
27 private iscsiService: IscsiService,
28 private dimlessPipe: DimlessPipe,
f67539c2 29 private iscsiBackstorePipe: IscsiBackstorePipe
11fdf7f2
TL
30 ) {}
31
32 ngOnInit() {
33 this.gatewaysColumns = [
34 {
f67539c2 35 name: $localize`Name`,
11fdf7f2
TL
36 prop: 'name'
37 },
38 {
f67539c2 39 name: $localize`State`,
11fdf7f2 40 prop: 'state',
9f95a23c
TL
41 flexGrow: 1,
42 cellTransformation: CellTemplate.badge,
43 customTemplateConfig: {
44 map: {
45 up: { class: 'badge-success' },
46 down: { class: 'badge-danger' }
47 }
48 }
11fdf7f2
TL
49 },
50 {
f67539c2 51 name: $localize`# Targets`,
11fdf7f2
TL
52 prop: 'num_targets'
53 },
54 {
f67539c2 55 name: $localize`# Sessions`,
11fdf7f2
TL
56 prop: 'num_sessions'
57 }
58 ];
59 this.imagesColumns = [
60 {
f67539c2 61 name: $localize`Pool`,
11fdf7f2
TL
62 prop: 'pool'
63 },
64 {
f67539c2 65 name: $localize`Image`,
11fdf7f2
TL
66 prop: 'image'
67 },
68 {
f67539c2 69 name: $localize`Backstore`,
11fdf7f2
TL
70 prop: 'backstore',
71 pipe: this.iscsiBackstorePipe
72 },
73 {
f67539c2 74 name: $localize`Read Bytes`,
11fdf7f2
TL
75 prop: 'stats_history.rd_bytes',
76 cellTemplate: this.iscsiSparklineTpl
77 },
78 {
f67539c2 79 name: $localize`Write Bytes`,
11fdf7f2
TL
80 prop: 'stats_history.wr_bytes',
81 cellTemplate: this.iscsiSparklineTpl
82 },
83 {
f67539c2 84 name: $localize`Read Ops`,
11fdf7f2
TL
85 prop: 'stats.rd',
86 pipe: this.dimlessPipe,
87 cellTemplate: this.iscsiPerSecondTpl
88 },
89 {
f67539c2 90 name: $localize`Write Ops`,
11fdf7f2
TL
91 prop: 'stats.wr',
92 pipe: this.dimlessPipe,
93 cellTemplate: this.iscsiPerSecondTpl
94 },
95 {
f67539c2 96 name: $localize`A/O Since`,
11fdf7f2
TL
97 prop: 'optimized_since',
98 cellTemplate: this.iscsiRelativeDateTpl
99 }
100 ];
101 }
102
103 refresh() {
9f95a23c 104 this.iscsiService.overview().subscribe((overview: object) => {
11fdf7f2
TL
105 this.gateways = overview['gateways'];
106 this.images = overview['images'];
107 this.images.map((image) => {
108 if (image.stats_history) {
9f95a23c
TL
109 image.stats_history.rd_bytes = image.stats_history.rd_bytes.map((i: any) => i[1]);
110 image.stats_history.wr_bytes = image.stats_history.wr_bytes.map((i: any) => i[1]);
11fdf7f2
TL
111 }
112 image.cdIsBinary = true;
113 return image;
114 });
115 });
116 }
117}