]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mds-summary.pipe.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / dashboard / mds-summary.pipe.ts
1 import { Pipe, PipeTransform } from '@angular/core';
2
3 import _ from 'lodash';
4
5 @Pipe({
6 name: 'mdsSummary'
7 })
8 export class MdsSummaryPipe implements PipeTransform {
9 transform(value: any): any {
10 if (!value) {
11 return '';
12 }
13
14 let contentLine1 = '';
15 let contentLine2 = '';
16 let standbys = 0;
17 let active = 0;
18 let standbyReplay = 0;
19 _.each(value.standbys, () => {
20 standbys += 1;
21 });
22
23 if (value.standbys && !value.filesystems) {
24 contentLine1 = `${standbys} ${$localize`up`}`;
25 contentLine2 = $localize`no filesystems`;
26 } else if (value.filesystems.length === 0) {
27 contentLine1 = $localize`no filesystems`;
28 } else {
29 _.each(value.filesystems, (fs) => {
30 _.each(fs.mdsmap.info, (mds) => {
31 if (mds.state === 'up:standby-replay') {
32 standbyReplay += 1;
33 } else {
34 active += 1;
35 }
36 });
37 });
38
39 contentLine1 = `${active} ${$localize`active`}`;
40 contentLine2 = `${standbys + standbyReplay} ${$localize`standby`}`;
41 }
42 const standbyHoverText = value.standbys.map((s: any): string => s.name).join(', ');
43 const standbyTitleText = !standbyHoverText
44 ? ''
45 : `${$localize`standby daemons`}: ${standbyHoverText}`;
46 const fsLength = value.filesystems ? value.filesystems.length : 0;
47 const infoObject = fsLength > 0 ? value.filesystems[0].mdsmap.info : {};
48 const activeHoverText = Object.values(infoObject)
49 .map((info: any): string => info.name)
50 .join(', ');
51 let activeTitleText = !activeHoverText ? '' : `${$localize`active daemon`}: ${activeHoverText}`;
52 // There is always one standbyreplay to replace active daemon, if active one is down
53 if (!active && fsLength > 0) {
54 activeTitleText = `${standbyReplay} ${$localize`standbyReplay`}`;
55 }
56 const mgrSummary = [
57 {
58 content: contentLine1,
59 class: 'popover-info',
60 titleText: activeTitleText
61 }
62 ];
63 if (contentLine2) {
64 mgrSummary.push({
65 content: '',
66 class: 'card-text-line-break',
67 titleText: ''
68 });
69 mgrSummary.push({
70 content: contentLine2,
71 class: 'popover-info',
72 titleText: standbyTitleText
73 });
74 }
75
76 return mgrSummary;
77 }
78 }