blob: 77758b71d3d572f6bcdeccd172eff2418776bb40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import { Pipe, PipeTransform } from '@angular/core';
import _ from 'lodash';
@Pipe({
name: 'mdsSummary'
})
export class MdsSummaryPipe implements PipeTransform {
transform(value: any): any {
if (!value) {
return {
success: 0,
info: 0,
total: 0
};
}
let activeCount = 0;
let standbyCount = 0;
let standbys = 0;
let active = 0;
let standbyReplay = 0;
_.each(value.standbys, () => {
standbys += 1;
});
if (value.standbys && !value.filesystems) {
standbyCount = standbys;
activeCount = 0;
} else if (value.filesystems.length === 0) {
activeCount = 0;
} else {
_.each(value.filesystems, (fs) => {
_.each(fs.mdsmap.info, (mds) => {
if (mds.state === 'up:standby-replay') {
standbyReplay += 1;
} else {
active += 1;
}
});
});
activeCount = active;
standbyCount = standbys + standbyReplay;
}
const totalCount = activeCount + standbyCount;
const mdsSummary = {
success: activeCount,
info: standbyCount,
total: totalCount
};
return mdsSummary;
}
}
|