ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rz...@apache.org
Subject ambari git commit: AMBARI-16721 - Host Filters : 'Alerts' value for 'HOST STATUS' filter is absent (rzang)
Date Wed, 18 May 2016 18:57:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 61617dce3 -> 671db5fb1


AMBARI-16721 - Host Filters : 'Alerts' value for 'HOST STATUS' filter is absent (rzang)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/671db5fb
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/671db5fb
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/671db5fb

Branch: refs/heads/branch-2.4
Commit: 671db5fb18dae67d02c18dca0801d5bef1d473f8
Parents: 61617dc
Author: Richard Zang <rzang@apache.org>
Authored: Wed May 18 11:53:33 2016 -0700
Committer: Richard Zang <rzang@apache.org>
Committed: Wed May 18 11:54:38 2016 -0700

----------------------------------------------------------------------
 .../controllers/main/host/combo_search_box.js   |  4 ++
 ambari-web/app/data/host/categories.js          | 11 +++
 .../mixins/common/table_server_view_mixin.js    | 38 +---------
 .../app/views/main/host/combo_search_box.js     | 75 ++++++++++++++++++--
 4 files changed, 87 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/671db5fb/ambari-web/app/controllers/main/host/combo_search_box.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/combo_search_box.js b/ambari-web/app/controllers/main/host/combo_search_box.js
index 2fa4479..4ab3b7c 100644
--- a/ambari-web/app/controllers/main/host/combo_search_box.js
+++ b/ambari-web/app/controllers/main/host/combo_search_box.js
@@ -56,6 +56,10 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
     return App.HostComponent.find().filterProperty('componentName', facet).length > 0;
   },
 
+  isComplexHealthStatusFacet: function(facet) {
+    return ['health-status-WITH-ALERTS', 'health-status-RESTART', 'health-status-PASSIVE_STATE'].contains(facet);
+  },
+
   generateQueryParam: function(param) {
     var expressions = param.key;
     var pHash = this.createComboParamHash(param);

http://git-wip-us.apache.org/repos/asf/ambari/blob/671db5fb/ambari-web/app/data/host/categories.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/host/categories.js b/ambari-web/app/data/host/categories.js
index 03e2fee..7e010d5 100644
--- a/ambari-web/app/data/host/categories.js
+++ b/ambari-web/app/data/host/categories.js
@@ -54,6 +54,17 @@ module.exports = [
     healthClass: 'health-status-DEAD-YELLOW'
   },
   {
+    value: Em.I18n.t('hosts.host.alerts.label'),
+    hostProperty: 'criticalWarningAlertsCount',
+    class: 'icon-exclamation-sign',
+    isHealthStatus: false,
+    healthClass: 'health-status-WITH-ALERTS',
+    healthStatus: 'health-status-WITH-ALERTS',
+    column: 7,
+    type: 'custom',
+    filterValue: ['>0', '>0']
+  },
+  {
     value: Em.I18n.t('common.restart'),
     hostProperty: 'componentsWithStaleConfigsCount',
     class: 'icon-refresh',

http://git-wip-us.apache.org/repos/asf/ambari/blob/671db5fb/ambari-web/app/mixins/common/table_server_view_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/table_server_view_mixin.js b/ambari-web/app/mixins/common/table_server_view_mixin.js
index 66f886a..4e982d7 100644
--- a/ambari-web/app/mixins/common/table_server_view_mixin.js
+++ b/ambari-web/app/mixins/common/table_server_view_mixin.js
@@ -87,44 +87,10 @@ App.TableServerViewMixin = Em.Mixin.create({
     return true;
   },
 
-  updateComboFilter: function(searchCollection) {
-    var self = this;
-    var comboController = App.router.get('mainHostComboSearchBoxController');
+  updateComboFilter: function(filterConditions) {
     clearTimeout(this.get('timeOut'));
     this.set('controller.resetStartIndex', true);
-    this.set('filterConditions', []);
-    searchCollection.models.forEach(function (model) {
-      var tag = model.attributes;
-      var map = App.router.get('mainHostController.labelValueMap');
-      var category = map[tag.category] || tag.category;
-      var value = map[tag.value] || tag.value;
-      var isComponentState = comboController.isComponentStateFacet(category);
-      var iColumn = App.router.get('mainHostController').get('colPropAssoc').indexOf(isComponentState?
'componentState' : category);
-      var filterCondition = self.get('filterConditions').findProperty('iColumn', iColumn);
-      var filterValue = isComponentState? (category + ':' + value) : value;
-      if (filterCondition) {
-        if (typeof filterCondition.value == 'string') {
-          filterCondition.value = [filterCondition.value, filterValue];
-        } else if (Em.isArray(filterCondition.value) && filterCondition.value.indexOf(filterValue)
== -1) {
-          filterCondition.value.push(filterValue);
-        }
-      } else {
-        var type = 'string';
-        if (category === 'cpu') {
-          type = 'number';
-        }
-        if (category === 'memoryFormatted') {
-          type = 'ambari-bandwidth';
-        }
-        filterCondition = {
-          skipFilter: false,
-          iColumn: iColumn,
-          value: filterValue,
-          type: type
-        };
-        self.get('filterConditions').push(filterCondition);
-      }
-    });
+    this.set('filterConditions', filterConditions);
     this.saveAllFilterConditions();
     this.refresh();
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/671db5fb/ambari-web/app/views/main/host/combo_search_box.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/combo_search_box.js b/ambari-web/app/views/main/host/combo_search_box.js
index caf200f..c6ac3bd 100644
--- a/ambari-web/app/views/main/host/combo_search_box.js
+++ b/ambari-web/app/views/main/host/combo_search_box.js
@@ -20,6 +20,8 @@ var App = require('app');
 
 App.MainHostComboSearchBoxView = Em.View.extend({
   templateName: require('templates/main/host/combo_search_box'),
+  healthStatusCategories: require('data/host/categories'),
+
   didInsertElement: function () {
     this.initVS();
     this.restoreComboFilterQuery();
@@ -109,6 +111,68 @@ App.MainHostComboSearchBoxView = Em.View.extend({
     map['Maintenance Mode Off'] = 'OFF';
   },
 
+  createFilterConditions: function(searchCollection) {
+    var self = this;
+    var mainHostController = App.router.get('mainHostController');
+    var filterConditions = Em.A();
+    searchCollection.models.forEach(function (model) {
+      var tag = model.attributes;
+      var map = mainHostController.get('labelValueMap');
+      var category = map[tag.category] || tag.category;
+      var value = map[tag.value] || tag.value;
+
+      var iColumn = self.getFilterColumn(category, value);
+      var filterValue = self.getFilterValue(category, value);
+      var condition = filterConditions.findProperty('iColumn', iColumn);
+      if (condition) {
+        // handle multiple facets with same category
+        if (typeof condition.value == 'string') {
+          condition.value = [condition.value, filterValue];
+        } else if (Em.isArray(condition.value) && condition.value.indexOf(filterValue)
== -1) {
+          condition.value.push(filterValue);
+        }
+      } else {
+        var type = 'string';
+        if (category === 'cpu') {
+          type = 'number';
+        }
+        if (category === 'memoryFormatted') {
+          type = 'ambari-bandwidth';
+        }
+        condition = {
+          skipFilter: false,
+          iColumn: iColumn,
+          value: filterValue,
+          type: type
+        };
+        filterConditions.push(condition);
+      }
+    });
+    return filterConditions;
+  },
+
+  getFilterColumn: function(category, value) {
+    var iColumn = -1;
+    if (this.get('controller').isComponentStateFacet(category)) {
+      iColumn = App.router.get('mainHostController').get('colPropAssoc').indexOf('componentState');
+    } else if (this.get('controller').isComplexHealthStatusFacet(value)) {
+      iColumn = this.get('healthStatusCategories').findProperty('healthStatus', value).column;
+    } else {
+      iColumn = App.router.get('mainHostController').get('colPropAssoc').indexOf(category);
+    }
+    return iColumn;
+  },
+
+  getFilterValue: function(category, value) {
+    var filterValue = value;
+    if (this.get('controller').isComponentStateFacet(category)) {
+      filterValue = category + ':' + value;
+    } else if (this.get('controller').isComplexHealthStatusFacet(value)) {
+      filterValue = this.get('healthStatusCategories').findProperty('healthStatus', value).filterValue;
+    }
+    return filterValue;
+  },
+
   initVS: function() {
     var self = this;
     var controller = App.router.get('mainHostComboSearchBoxController');
@@ -126,7 +190,8 @@ App.MainHostComboSearchBoxView = Em.View.extend({
         search: function (query, searchCollection) {
           var tableView = self.get('parentView').get('parentView');
           App.db.setComboSearchQuery(tableView.get('controller.name'), query);
-          tableView.updateComboFilter(searchCollection);
+          var filterConditions = self.createFilterConditions(searchCollection);
+          tableView.updateComboFilter(filterConditions);
         },
 
         facetMatches: function (callback) {
@@ -186,16 +251,16 @@ App.MainHostComboSearchBoxView = Em.View.extend({
                 map[App.HostStackVersion.formatStatus(status)] = status;
                 return App.HostStackVersion.formatStatus(status);
               }).reject(function (item) {
-                return visualSearch.searchQuery.values(facet).indexOf(item.value) >= 0;
+                return visualSearch.searchQuery.values(facet).indexOf(item) >= 0;
               }));
               break;
             case 'healthClass':
-              var category_mocks = require('data/host/categories');
+              var category_mocks = self.healthStatusCategories;
               callback(category_mocks.slice(1).map(function (category) {
                 map[category.value] = category.healthStatus;
                 return category.value;
               }).reject(function (item) {
-                return visualSearch.searchQuery.values(facet).indexOf(item.value) >= 0;
+                return visualSearch.searchQuery.values(facet).indexOf(item) >= 0;
               }), {preserveOrder: true});
               break;
             case 'services':
@@ -203,7 +268,7 @@ App.MainHostComboSearchBoxView = Em.View.extend({
                 map[App.format.role(service.get('serviceName'), true)] = service.get('serviceName');
                 return App.format.role(service.get('serviceName'), true);
               }).reject(function (item) {
-                return visualSearch.searchQuery.values(facet).indexOf(item.value) >= 0;
+                return visualSearch.searchQuery.values(facet).indexOf(item) >= 0;
               }), {preserveOrder: true});
               break;
             case 'componentState':


Mime
View raw message