Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 a6a704669 -> 1a93b30d2


AMBARI-6340. Hosts page. Incorrect total number of hosts after filtering by 
installed component. (akovalenko)


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

Branch: refs/heads/branch-1.6.1
Commit: 1a93b30d298b283e1accf1158bea20cd338513af
Parents: a6a7046
Author: Aleksandr Kovalenko <[email protected]>
Authored: Tue Jul 1 21:27:14 2014 +0300
Committer: Aleksandr Kovalenko <[email protected]>
Committed: Tue Jul 1 21:27:14 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/utils/db.js        | 22 +++++++++++++++++++++-
 ambari-web/app/views/main/host.js |  6 ++++--
 2 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1a93b30d/ambari-web/app/utils/db.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/db.js b/ambari-web/app/utils/db.js
index ffa149c..d994393 100644
--- a/ambari-web/app/utils/db.js
+++ b/ambari-web/app/utils/db.js
@@ -26,7 +26,8 @@ var InitialData =  {
       'filterConditions': {},
       'displayLength': {},
       'startIndex': {},
-      'sortingConditions': {}
+      'sortingConditions': {},
+      'selectedItems': {}
     }
   },
 
@@ -208,6 +209,16 @@ App.db.setSortingStatuses = function(name, 
sortingConditions) {
   localStorage.setObject('ambari', App.db.data);
 };
 
+App.db.setSelectedHosts = function(name, selectedHosts) {
+  console.log('TRACE: Entering db:setSelectedHosts function');
+  App.db.data = localStorage.getObject('ambari');
+  if (!App.db.data.app.tables.selectedItems) {
+    App.db.data.app.tables.selectedItems = {};
+  }
+  App.db.data.app.tables.selectedItems[name] = selectedHosts;
+  localStorage.setObject('ambari', App.db.data);
+};
+
 App.db.setAllHostNames = function (hostNames) {
   console.log('TRACE: Entering db:setAllHostNames function');
   App.db.data = localStorage.getObject('ambari');
@@ -584,6 +595,15 @@ App.db.getSortingStatuses = function(name) {
   return null;
 };
 
+App.db.getSelectedHosts = function(name) {
+  console.log('TRACE: Entering db:getSelectedHosts function');
+  App.db.data = localStorage.getObject('ambari');
+  if (App.db.data.app.tables.selectedItems[name]) {
+    return App.db.data.app.tables.selectedItems[name];
+  }
+  return [];
+};
+
 /**
  * Return current step for specified Wizard Type
  * @param wizardType

http://git-wip-us.apache.org/repos/asf/ambari/blob/1a93b30d/ambari-web/app/views/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host.js 
b/ambari-web/app/views/main/host.js
index 8de4434..987ddb1 100644
--- a/ambari-web/app/views/main/host.js
+++ b/ambari-web/app/views/main/host.js
@@ -52,7 +52,8 @@ App.MainHostView = 
App.TableView.extend(App.TableServerProvider, {
    * @type {Array}
    */
   content: function () {
-    var selectedHosts = this.getSelectedFilter();
+    var controllerName = this.get('controller.name');
+    var selectedHosts = App.db.getSelectedHosts(controllerName);
     if (this.get('controller')) {
       return this.get('controller.content').filter(function (host) {
         host.set('selected', selectedHosts.contains(host.get('hostName')));
@@ -276,7 +277,8 @@ App.MainHostView = 
App.TableView.extend(App.TableServerProvider, {
     }
     this.combineSelectedFilter();
     //10 is an index of selected column
-    this.saveFilterConditions(10, this.get('selectedHosts'), 'multiple', true);
+    var controllerName = this.get('controller.name');
+    App.db.setSelectedHosts(controllerName, this.get('selectedHosts'));
 
     this.addObserver('selectAllHosts', this, this.toggleAllHosts);
   },

Reply via email to