You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/09/30 16:45:35 UTC

[15/50] [abbrv] ambari git commit: AMBARI-13235. Incorrect Hosts table filtering after navigating back from Host Summary (rzang)

AMBARI-13235. Incorrect Hosts table filtering after navigating back from Host Summary (rzang)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 9a7ceb54ec7503f4f1fcad77b7a0a6a6f22b166c
Parents: 80e2f20
Author: Richard Zang <rz...@apache.org>
Authored: Fri Sep 25 11:25:11 2015 -0700
Committer: Richard Zang <rz...@apache.org>
Committed: Fri Sep 25 11:25:11 2015 -0700

----------------------------------------------------------------------
 ambari-web/app/mappers/hosts_mapper.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9a7ceb54/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 53f536c..3fcf295 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -94,6 +94,13 @@ App.hostsMapper = App.QuickDataMapper.create({
       var clusterName = App.get('clusterName');
       var advancedHostComponents = [];
 
+      // Create a map for quick access on existing hosts
+      var hosts = App.Host.find().toArray();
+      var hostsMap = {};
+      for (var p = 0; p < hosts.length; p++) {
+        hostsMap[hosts[p].get('hostName')] = hosts[p];
+      }
+
       // Use normal for loop instead of foreach to enhance performance
       for (var index = 0; index < json.items.length; index++) {
         var item = json.items[index];
@@ -153,10 +160,9 @@ App.hostsMapper = App.QuickDataMapper.create({
         var alertsSummary = item.alerts_summary;
         item.critical_warning_alerts_count = alertsSummary ? (alertsSummary.CRITICAL || 0) + (alertsSummary.WARNING || 0) : 0;
         item.cluster_id = clusterName;
-        var existingHost = App.Host.find().findProperty('hostName', component.host_name);
-        var fromHostDetail = App.router.get('currentState.parentState.name') == 'hostDetails';
+        var existingHost = hostsMap[component.host_name];
         // There is no need to override existing index in host detail view since old model(already have indexes) will not be cleared.
-        item.index = (existingHost && fromHostDetail)? existingHost.get('index'): index;
+        item.index = (existingHost && !json.itemTotal)? existingHost.get('index'): index;
 
         if (stackUpgradeSupport) {
           this.config = $.extend(this.config, {