Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72EFB17CE9 for ; Fri, 25 Sep 2015 18:29:34 +0000 (UTC) Received: (qmail 28652 invoked by uid 500); 25 Sep 2015 18:29:31 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 28621 invoked by uid 500); 25 Sep 2015 18:29:31 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 28612 invoked by uid 99); 25 Sep 2015 18:29:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Sep 2015 18:29:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 125B5E0332; Fri, 25 Sep 2015 18:29:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rzang@apache.org To: commits@ambari.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) 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 Authored: Fri Sep 25 11:25:11 2015 -0700 Committer: Richard Zang 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, {