]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/mds-summary.pipe.ts
update sources to ceph Nautilus 14.2.1
[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 { I18n } from '@ngx-translate/i18n-polyfill';
4 import * as _ from 'lodash';
5
6 @Pipe({
7 name: 'mdsSummary'
8 })
9 export class MdsSummaryPipe implements PipeTransform {
10 constructor(private i18n: I18n) {}
11
12 transform(value: any): any {
13 if (!value) {
14 return '';
15 }
16
17 let contentLine1 = '';
18 let contentLine2 = '';
19 let standbys = 0;
20 let active = 0;
21 let standbyReplay = 0;
22 _.each(value.standbys, () => {
23 standbys += 1;
24 });
25
26 if (value.standbys && !value.filesystems) {
27 contentLine1 = `${standbys} ${this.i18n('up')}`;
28 contentLine2 = this.i18n('no filesystems');
29 } else if (value.filesystems.length === 0) {
30 contentLine1 = this.i18n('no filesystems');
31 } else {
32 _.each(value.filesystems, (fs) => {
33 _.each(fs.mdsmap.info, (mds) => {
34 if (mds.state === 'up:standby-replay') {
35 standbyReplay += 1;
36 } else {
37 active += 1;
38 }
39 });
40 });
41
42 contentLine1 = `${active} ${this.i18n('active')}`;
43 contentLine2 = `${standbys + standbyReplay} ${this.i18n('standby')}`;
44 }
45
46 const mgrSummary = [
47 {
48 content: contentLine1,
49 class: ''
50 }
51 ];
52
53 if (contentLine2) {
54 mgrSummary.push({
55 content: '',
56 class: 'card-text-line-break'
57 });
58 mgrSummary.push({
59 content: contentLine2,
60 class: ''
61 });
62 }
63
64 return mgrSummary;
65 }
66 }