Procházet zdrojové kódy

AMBARI-6112 Filter by alerts fails on Hosts table. (atkach)

atkach před 11 roky
rodič
revize
749f658898

+ 5 - 2
ambari-web/app/controllers/global/update_controller.js

@@ -66,7 +66,7 @@ App.UpdateController = Em.Controller.extend({
 
     queryParams.forEach(function (param) {
       switch (param.type) {
-        case 'PLAIN':
+        case 'EQUAL':
           params += param.key + '=' + param.value;
           break;
         case 'LESS':
@@ -84,7 +84,10 @@ App.UpdateController = Em.Controller.extend({
         case 'SORT':
           params += 'sortBy=' + param.key + '.' + param.value;
           break;
-        case 'CRITICAL_ALERTS':
+        case 'CUSTOM':
+          param.value.forEach(function(item, index){
+            param.key = param.key.replace('{' + index + '}', item);
+          }, this);
           params += param.key;
           break;
       }

+ 17 - 10
ambari-web/app/controllers/main/host.js

@@ -73,6 +73,13 @@ App.MainHostController = Em.ArrayController.extend({
     return this.get('dataSource').filterProperty('isRequested');
   }.property('dataSource.@each.isRequested'),
 
+  /**
+   * filterProperties support follow types of filter:
+   * MATCH - match of RegExp
+   * EQUAL - equality "="
+   * MULTIPLE - multiple values to compare
+   * CUSTOM - substitute values with keys "{#}" in alias
+   */
   filterProperties: [
     {
       key: 'publicHostName',
@@ -87,17 +94,17 @@ App.MainHostController = Em.ArrayController.extend({
     {
       key: 'cpu',
       alias: 'Hosts/cpu_count',
-      type: 'PLAIN'
+      type: 'EQUAL'
     },
     {
       key: 'memoryFormatted',
       alias: 'Hosts/total_mem',
-      type: 'PLAIN'
+      type: 'EQUAL'
     },
     {
       key: 'loadAvg',
       alias: 'metrics/load/load_one',
-      type: 'PLAIN'
+      type: 'EQUAL'
     },
     {
       key: 'hostComponents',
@@ -107,22 +114,22 @@ App.MainHostController = Em.ArrayController.extend({
     {
       key: 'healthClass',
       alias: 'Hosts/host_status',
-      type: 'PLAIN'
+      type: 'EQUAL'
     },
     {
       key: 'criticalAlertsCount',
-      alias: 'alerts/summary/CRITICAL>0|alerts/summary/WARNING>0',
-      type: 'CRITICAL_ALERTS'
+      alias: 'alerts/summary/CRITICAL{0}|alerts/summary/WARNING{1}',
+      type: 'CUSTOM'
     },
     {
       key: 'componentsWithStaleConfigsCount',
       alias: 'host_components/HostRoles/stale_configs',
-      type: 'PLAIN'
+      type: 'EQUAL'
     },
     {
       key: 'componentsInPassiveStateCount',
       alias: 'host_components/HostRoles/maintenance_state',
-      type: 'PLAIN'
+      type: 'EQUAL'
     },
     {
       key: 'selected',
@@ -210,7 +217,7 @@ App.MainHostController = Em.ArrayController.extend({
       queryParams.push({
         key: property.get('alias'),
         value: property.getValue(this),
-        type: 'PLAIN'
+        type: 'EQUAL'
       })
     }, this);
 
@@ -345,7 +352,7 @@ App.MainHostController = Em.ArrayController.extend({
    */
   getComparisonType: function (value) {
     var comparisonChar = value.charAt(0);
-    var result = 'PLAIN';
+    var result = 'EQUAL';
     if (isNaN(comparisonChar)) {
       switch (comparisonChar) {
         case '>':

+ 4 - 4
ambari-web/app/data/host/categories.js

@@ -61,8 +61,8 @@ module.exports = [
     healthClass: 'health-status-WITH-ALERTS',
     healthStatus: 'health-status-WITH-ALERTS',
     column: 7,
-    type: 'number',
-    filterValue: '>0'
+    type: 'custom',
+    filterValue: ['>0', '>0']
   },
   {
     value: Em.I18n.t('common.restart'),
@@ -72,7 +72,7 @@ module.exports = [
     healthClass: 'health-status-RESTART',
     healthStatus: 'health-status-RESTART',
     column: 8,
-    type: 'number',
+    type: 'string',
     filterValue: 'true'
   },
   {
@@ -83,7 +83,7 @@ module.exports = [
     healthClass: 'health-status-PASSIVE_STATE',
     healthStatus: 'health-status-PASSIVE_STATE',
     column: 9,
-    type: 'number',
+    type: 'string',
     filterValue: 'ON'
   }
 ];