Przeglądaj źródła

AMBARI-8381. Alerts UI: Alerts summary Add "Pending" filter for status. (onechiporenko)

Oleg Nechiporenko 10 lat temu
rodzic
commit
46e4d943b1

+ 11 - 1
ambari-web/app/views/common/filter_view.js

@@ -596,9 +596,19 @@ module.exports = {
       case 'alert_status':
       case 'alert_status':
         /**
         /**
          * origin - alertDefinition.summary
          * origin - alertDefinition.summary
-         * compareValue - "OK|WARN..."
+         * compareValue - "OK|WARNING|CRITICAL|UNKNOWN|PENDING"
+         * PENDING means that OK is 0, WARNING is 0, CRITICAL is 0 and UNKNOWN is 0
          */
          */
         return function (origin, compareValue) {
         return function (origin, compareValue) {
+          if ('PENDING' === compareValue) {
+            var isPending = true;
+            Em.keys(origin).forEach(function(state) {
+              if (origin[state] && origin[state] > 0) {
+                isPending = false;
+              }
+            });
+            return isPending;
+          }
           return !!origin[compareValue] && origin[compareValue] > 0;
           return !!origin[compareValue] && origin[compareValue] > 0;
         };
         };
         break;
         break;

+ 4 - 4
ambari-web/app/views/main/alert_definitions_view.js

@@ -119,13 +119,13 @@ App.MainAlertDefinitionsView = App.TableView.extend({
         value: 'CRITICAL',
         value: 'CRITICAL',
         label: 'CRITICAL'
         label: 'CRITICAL'
       },
       },
-      {
-        value: 'DISABLED',
-        label: 'DISABLED'
-      },
       {
       {
         value: 'UNKNOWN',
         value: 'UNKNOWN',
         label: 'UNKNOWN'
         label: 'UNKNOWN'
+      },
+      {
+        value: 'PENDING',
+        label: 'PENDING'
       }
       }
     ],
     ],
     onChangeValue: function () {
     onChangeValue: function () {

+ 15 - 0
ambari-web/test/views/common/filter_view_test.js

@@ -484,6 +484,21 @@ describe('filters.getFilterByType', function () {
         origin: {WARN: 0},
         origin: {WARN: 0},
         compareValue: 'WARN',
         compareValue: 'WARN',
         e: false
         e: false
+      },
+      {
+        origin: {OK: 0, WARN: 0},
+        compareValue: 'PENDING',
+        e: true
+      },
+      {
+        origin: {},
+        compareValue: 'PENDING',
+        e: true
+      },
+      {
+        origin: {OK: 1},
+        compareValue: 'PENDING',
+        e: false
       }
       }
     ]).forEach(function(test, i) {
     ]).forEach(function(test, i) {
         it('test #' + (i + 1), function() {
         it('test #' + (i + 1), function() {

+ 1 - 1
ambari-web/test/views/main/dashboard/widgets_test.js

@@ -118,7 +118,7 @@ describe('App.MainDashboardWidgetsView', function() {
           yarn_model: {}
           yarn_model: {}
         },
         },
         e: {
         e: {
-          visibleL: total_widgets_count - 1,
+          visibleL: total_widgets_count,
           hiddenL: 1
           hiddenL: 1
         },
         },
         m: 'All models are not null'
         m: 'All models are not null'