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-13235. Incorrect Hosts table filtering after navigating back from Host Summary (rzang)
Date Fri, 25 Sep 2015 18:29:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1.2 eb65b2f8d -> 5876b40b6


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

Branch: refs/heads/branch-2.1.2
Commit: 5876b40b6dcb8bcb5777517ad1db77a365342ea9
Parents: eb65b2f
Author: Richard Zang <rzang@apache.org>
Authored: Fri Sep 25 11:25:11 2015 -0700
Committer: Richard Zang <rzang@apache.org>
Committed: Fri Sep 25 11:28:50 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/5876b40b/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, {


Mime
View raw message