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-15074 Combo Search: Implement "host" related filters (Joe Wang via rzang)
Date Wed, 17 Feb 2016 21:57:18 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 4761fe7c4 -> f11d76db2


AMBARI-15074 Combo Search: Implement "host" related filters (Joe Wang via rzang)


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

Branch: refs/heads/trunk
Commit: f11d76db25714e0bea2b52f907051664ee160aaa
Parents: 4761fe7
Author: Richard Zang <rzang@apache.org>
Authored: Wed Feb 17 13:51:07 2016 -0800
Committer: Richard Zang <rzang@apache.org>
Committed: Wed Feb 17 13:51:07 2016 -0800

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host.js         | 18 +++++++
 .../controllers/main/host/combo_search_box.js   | 28 +---------
 .../app/views/main/host/combo_search_box.js     | 55 +++++++++++++++++++-
 3 files changed, 74 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f11d76db/ambari-web/app/controllers/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js
index a38b2db..d3574b2 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -100,6 +100,21 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin,
{
       type: 'MULTIPLE'
     },
     {
+      name: 'hostComponents2',
+      key: 'host_components/HostRoles/component_name',
+      type: 'MATCH'
+    },
+    {
+      name: 'services',
+      key: 'host_components/HostRoles/service_name',
+      type: 'MATCH'
+    },
+    {
+      name: 'state',
+      key: 'host_components/HostRoles/state',
+      type: 'MATCH'
+    },
+    {
       name: 'healthClass',
       key: 'Hosts/host_status',
       type: 'EQUAL'
@@ -544,6 +559,9 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin,
{
     associations[10] = 'selected';
     associations[11] = 'hostStackVersion';
     associations[12] = 'rack';
+    associations[13] = 'services';
+    associations[14] = 'state';
+    associations[15] = 'hostComponents2';
     return associations;
   }.property()
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f11d76db/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 f4cc50f..0aeb31b 100644
--- a/ambari-web/app/controllers/main/host/combo_search_box.js
+++ b/ambari-web/app/controllers/main/host/combo_search_box.js
@@ -24,23 +24,6 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
   page_size: 10,
 
   VSCallbacks : {
-    search: function (query, searchCollection) {
-      var $query = $('#search_query');
-      var count = searchCollection.size();
-      $query.stop().animate({opacity: 1}, {duration: 300, queue: false});
-      $query.html('<span class="raquo">&raquo;</span> You searched for: '
+
-      '<b>' + (query || '<i>nothing</i>') + '</b>. ' +
-      '(' + count + ' facet' + (count == 1 ? '' : 's') + ')');
-      clearTimeout(window.queryHideDelay);
-      window.queryHideDelay = setTimeout(function () {
-        $query.animate({
-          opacity: 0
-        }, {
-          duration: 1000,
-          queue: false
-        });
-      }, 2000);
-    },
 
     facetMatches: function (callback) {
       callback([
@@ -57,6 +40,7 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
 
     valueMatches: function (facet, searchTerm, callback) {
       var controller = App.router.get('mainHostComboSearchBoxController');
+      var category_mocks = require('data/host/categories');
       switch (facet) {
         case 'host_name':
         case 'ip':
@@ -71,15 +55,7 @@ App.MainHostComboSearchBoxController = Em.Controller.extend({
           callback(App.StackVersion.find().toArray().mapProperty('name'));
           break;
         case 'health':
-          callback([
-            Em.I18n.t('hosts.host.healthStatusCategory.green'),
-            Em.I18n.t('hosts.host.healthStatusCategory.red'),
-            Em.I18n.t('hosts.host.healthStatusCategory.orange'),
-            Em.I18n.t('hosts.host.healthStatusCategory.yellow'),
-            Em.I18n.t('hosts.host.alerts.label'),
-            Em.I18n.t('common.restart'),
-            Em.I18n.t('common.passive_state')
-          ]);
+          callback(category_mocks.slice(1).mapProperty('healthStatus'), {preserveOrder: true});
           break;
         case 'service':
           callback(App.Service.find().toArray().mapProperty('serviceName'), {preserveOrder:
true});

http://git-wip-us.apache.org/repos/asf/ambari/blob/f11d76db/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 0ab6029..93c2b9b 100644
--- a/ambari-web/app/views/main/host/combo_search_box.js
+++ b/ambari-web/app/views/main/host/combo_search_box.js
@@ -25,6 +25,59 @@ App.MainHostComboSearchBoxView = Em.View.extend({
   },
 
   initVS: function() {
+    var self = this;
+
+    var callbacks = this.get('controller').VSCallbacks;
+    callbacks.search = function (query, searchCollection) {
+
+      searchCollection.models.forEach(function (data) {
+        var query = data.attributes;
+
+        switch (query.category) {
+          case 'health':
+            self.get('parentView').get('parentView').updateFilter(0, query.value, 'string');
+            break;
+          case 'host_name':
+            self.get('parentView').get('parentView').updateFilter(1, query.value, 'string');
+            break;
+          case 'ip':
+            self.get('parentView').get('parentView').updateFilter(2, query.value, 'string');
+            break;
+          case 'rack':
+            self.get('parentView').get('parentView').updateFilter(12, query.value, 'string');
+            break;
+          case 'version':
+            self.get('parentView').get('parentView').updateFilter(11, query.value, 'string');
+            break;
+          case 'component':
+            self.get('parentView').get('parentView').updateFilter(15, query.value, 'string');
+            break;
+          case 'service':
+            self.get('parentView').get('parentView').updateFilter(13, query.value, 'string');
+            break;
+          case 'state':
+            self.get('parentView').get('parentView').updateFilter(14, query.value, 'string');
+            break;
+        }
+      });
+
+      var $query = $('#search_query');
+      var count = searchCollection.size();
+      $query.stop().animate({opacity: 1}, {duration: 300, queue: false});
+      $query.html('<span class="raquo">&raquo;</span> You searched for: '
+
+          '<b>' + (query || '<i>nothing</i>') + '</b>. ' +
+          '(' + count + ' facet' + (count == 1 ? '' : 's') + ')');
+      clearTimeout(window.queryHideDelay);
+      window.queryHideDelay = setTimeout(function () {
+        $query.animate({
+          opacity: 0
+        }, {
+          duration: 1000,
+          queue: false
+        });
+      }, 2000);
+    };
+
     window.visualSearch = VS.init({
       container: $('#combo_search_box'),
       query: '',
@@ -33,7 +86,7 @@ App.MainHostComboSearchBoxView = Em.View.extend({
       unquotable: [
         'text'
       ],
-      callbacks: this.get('controller').VSCallbacks
+      callbacks: callbacks
     });
   }
 });
\ No newline at end of file


Mime
View raw message