Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 3f47421f4 -> 86fbfce4a


AMBARI-6337. 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/86fbfce4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/86fbfce4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/86fbfce4

Branch: refs/heads/branch-1.6.1
Commit: 86fbfce4a24ddf81de124655dcb6980aa541c45d
Parents: 3f47421
Author: Aleksandr Kovalenko <[email protected]>
Authored: Tue Jul 1 20:35:55 2014 +0300
Committer: Aleksandr Kovalenko <[email protected]>
Committed: Tue Jul 1 20:35:55 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/global/update_controller.js | 8 +++++++-
 ambari-web/app/controllers/main/host.js                | 4 ++++
 ambari-web/app/mappers/hosts_mapper.js                 | 8 ++++++--
 3 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/86fbfce4/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js 
b/ambari-web/app/controllers/global/update_controller.js
index 44e86cb..97012c5 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -226,8 +226,14 @@ App.UpdateController = Em.Controller.extend({
     var preLoadKeys = this.get('hostsPreLoadKeys');
     var queryParams = this.get('queryParams.Hosts');
     var hostNames = data.items.mapProperty('Hosts.host_name');
-    var skipCall = hostNames.length === 0;
 
+    var itemTotal = parseInt(data.itemTotal);
+    if (!isNaN(itemTotal) && itemTotal!==undefined && itemTotal!==null) {
+      App.router.set('mainHostController.filteredCount', itemTotal);
+      App.router.set('mainHostController.setFilteredCount', false);
+    }
+
+    var skipCall = hostNames.length === 0;
     if (skipCall) {
       params.callback(skipCall);
     } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/86fbfce4/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 9a30c10..407b183 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -27,6 +27,10 @@ App.MainHostController = Em.ArrayController.extend({
   clearFilters: null,
 
   filteredCount: 0,
+
+  // either set <code>filteredCount</code> property in hosts mapper, or it 
will be set in <code>getHostByHostComponentsSuccessCallback</code>
+  setFilteredCount: true,
+
   resetStartIndex: false,
   /**
    * flag responsible for updating status counters of hosts

http://git-wip-us.apache.org/repos/asf/ambari/blob/86fbfce4/ambari-web/app/mappers/hosts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/hosts_mapper.js 
b/ambari-web/app/mappers/hosts_mapper.js
index 4347be0..90a8b5d 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -107,11 +107,15 @@ App.hostsMapper = App.QuickDataMapper.create({
       App.store.commit();
       App.store.loadMany(App.HostComponent, components);
       App.store.loadMany(App.Host, hostsWithFullInfo);
+
+      // check if <code>mainHostController.filteredCount</code> is already set 
in <code>getHostByHostComponentsSuccessCallback</code>
+      var setFilteredCount = 
App.router.get('mainHostController.setFilteredCount');
       var itemTotal = parseInt(json.itemTotal);
-      if (!isNaN(itemTotal) && itemTotal!==undefined && itemTotal!==null) {
+      if (setFilteredCount && !isNaN(itemTotal) && itemTotal!==undefined && 
itemTotal!==null) {
         App.router.set('mainHostController.filteredCount', itemTotal);
+      } else {
+        App.router.set('mainHostController.setFilteredCount', true);
       }
-      App.router.set('mainHostController.filteringComplete', true);      
     }
     console.timeEnd('App.hostsMapper execution time');
   }

Reply via email to