]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/monitor/monitor.component.ts
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / monitor / monitor.component.ts
1 import { Component } from '@angular/core';
2
3 import _ from 'lodash';
4
5 import { MonitorService } from '~/app/shared/api/monitor.service';
6 import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
7
8 @Component({
9 selector: 'cd-monitor',
10 templateUrl: './monitor.component.html',
11 styleUrls: ['./monitor.component.scss']
12 })
13 export class MonitorComponent {
14 mon_status: any;
15 inQuorum: any;
16 notInQuorum: any;
17
18 interval: any;
19
20 constructor(private monitorService: MonitorService) {
21 this.inQuorum = {
22 columns: [
23 { prop: 'name', name: $localize`Name`, cellTransformation: CellTemplate.routerLink },
24 { prop: 'rank', name: $localize`Rank` },
25 { prop: 'public_addr', name: $localize`Public Address` },
26 {
27 prop: 'cdOpenSessions',
28 name: $localize`Open Sessions`,
29 cellTransformation: CellTemplate.sparkline,
30 comparator: (dataA: any, dataB: any) => {
31 // We get the last value of time series to compare:
32 const lastValueA = _.last(dataA);
33 const lastValueB = _.last(dataB);
34
35 if (!lastValueA || !lastValueB || lastValueA === lastValueB) {
36 return 0;
37 }
38
39 return lastValueA > lastValueB ? 1 : -1;
40 }
41 }
42 ]
43 };
44
45 this.notInQuorum = {
46 columns: [
47 { prop: 'name', name: $localize`Name`, cellTransformation: CellTemplate.routerLink },
48 { prop: 'rank', name: $localize`Rank` },
49 { prop: 'public_addr', name: $localize`Public Address` }
50 ]
51 };
52 }
53
54 refresh() {
55 this.monitorService.getMonitor().subscribe((data: any) => {
56 data.in_quorum.map((row: any) => {
57 row.cdOpenSessions = row.stats.num_sessions.map((i: string) => i[1]);
58 row.cdLink = '/perf_counters/mon/' + row.name;
59 row.cdParams = { fromLink: '/monitor' };
60 return row;
61 });
62
63 data.out_quorum.map((row: any) => {
64 row.cdLink = '/perf_counters/mon/' + row.name;
65 row.cdParams = { fromLink: '/monitor' };
66 return row;
67 });
68
69 this.inQuorum.data = [...data.in_quorum];
70 this.notInQuorum.data = [...data.out_quorum];
71 this.mon_status = data.mon_status;
72 });
73 }
74 }