1 import { Pipe, PipeTransform } from '@angular/core';
3 import _ from 'lodash';
8 export class MdsSummaryPipe implements PipeTransform {
9 transform(value: any): any {
14 let contentLine1 = '';
15 let contentLine2 = '';
18 let standbyReplay = 0;
19 _.each(value.standbys, () => {
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`;
29 _.each(value.filesystems, (fs) => {
30 _.each(fs.mdsmap.info, (mds) => {
31 if (mds.state === 'up:standby-replay') {
39 contentLine1 = `${active} ${$localize`active`}`;
40 contentLine2 = `${standbys + standbyReplay} ${$localize`standby`}`;
42 const standbyHoverText = value.standbys.map((s: any): string => s.name).join(', ');
43 const standbyTitleText = !standbyHoverText
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)
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`}`;
58 content: contentLine1,
59 class: 'popover-info',
60 titleText: activeTitleText
66 class: 'card-text-line-break',
70 content: contentLine2,
71 class: 'popover-info',
72 titleText: standbyTitleText