Переглянути джерело

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

Aleksandr Kovalenko 11 роки тому
батько
коміт
c477ba061d
2 змінених файлів з 25 додано та 3 видалено
  1. 21 1
      ambari-web/app/utils/db.js
  2. 4 2
      ambari-web/app/views/main/host.js

+ 21 - 1
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

+ 4 - 2
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);
   },