summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/mds-summary.pipe.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/mds-summary.pipe.ts')
-rw-r--r--src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/mds-summary.pipe.ts55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/mds-summary.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/mds-summary.pipe.ts
new file mode 100644
index 000000000..77758b71d
--- /dev/null
+++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/mds-summary.pipe.ts
@@ -0,0 +1,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;
+ }
+}