Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62AF4DC31 for ; Fri, 15 Mar 2013 18:46:46 +0000 (UTC) Received: (qmail 95993 invoked by uid 500); 15 Mar 2013 18:46:44 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 95945 invoked by uid 500); 15 Mar 2013 18:46:44 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 95902 invoked by uid 99); 15 Mar 2013 18:46:44 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Mar 2013 18:46:44 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9521518DFB; Fri, 15 Mar 2013 18:46:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bfederle@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [49/50] git commit: refs/heads/Health-Check-UI - CLOUDSTACK-1044: Fix duplicate listCapacity call on dashboard Message-Id: <20130315184644.9521518DFB@tyr.zones.apache.org> Date: Fri, 15 Mar 2013 18:46:44 +0000 (UTC) CLOUDSTACK-1044: Fix duplicate listCapacity call on dashboard Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/42d33fc3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/42d33fc3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/42d33fc3 Branch: refs/heads/Health-Check-UI Commit: 42d33fc3ffe3821eea2b23c0db605ca201e2b7ee Parents: e74dd13 Author: Brian Federle Authored: Thu Mar 14 16:20:53 2013 -0700 Committer: Brian Federle Committed: Fri Mar 15 10:48:49 2013 -0700 ---------------------------------------------------------------------- ui/scripts/dashboard.js | 71 +++++++---------------------------------- 1 files changed, 12 insertions(+), 59 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/42d33fc3/ui/scripts/dashboard.js ---------------------------------------------------------------------- diff --git a/ui/scripts/dashboard.js b/ui/scripts/dashboard.js index 88c3cd1..845ae52 100644 --- a/ui/scripts/dashboard.js +++ b/ui/scripts/dashboard.js @@ -91,7 +91,7 @@ var netTotal = json.listnetworksresponse.count ? json.listnetworksresponse.count : 0; - $.ajax({ + $.ajax({ url: createURL('listPublicIpAddresses'), success: function(json) { var ipTotal = json.listpublicipaddressesresponse.count ? @@ -102,7 +102,7 @@ ipTotal: ipTotal })); } - }); + }); } }); } @@ -128,7 +128,7 @@ } } }, - + dataProvider: function(args) { var dataFns = { zones: function(data) { @@ -142,71 +142,24 @@ }); }, capacity: function(data) { - var latestData =null; - if(window.fetchLatestflag == 1) - { + var latestData =null; + if(window.fetchLatestflag == 1) + { latestData = { - fetchLatest:true - } + fetchLatest:true + } } - else + else { latestData = { fetchLatest:false - } + } } - window.fetchLatestflag = 0; - if (data.zones) { - $.ajax({ - url: createURL('listCapacity'), - data: latestData, - success: function(json) { - var capacities = json.listcapacityresponse.capacity; - var capacity = function(id, converter) { - var result = $.grep(capacities, function(capacity) { - return capacity.type == id; - }); - return result[0] ? result[0] : { - capacityused: 0, - capacitytotal: 0, - percentused: 0 - }; - }; + window.fetchLatestflag = 0; - dataFns.alerts($.extend(data, { - publicIPAllocated: capacity(8).capacityused, - publicIPTotal: capacity(8).capacitytotal, - publicIPPercentage: parseInt(capacity(8).percentused), - privateIPAllocated: capacity(5).capacityused, - privateIPTotal: capacity(5).capacitytotal, - privateIPPercentage: parseInt(capacity(8).percentused), - memoryAllocated: cloudStack.converters.convertBytes(capacity(0).capacityused), - memoryTotal: cloudStack.converters.convertBytes(capacity(0).capacitytotal), - memoryPercentage: parseInt(capacity(0).percentused), - cpuAllocated: cloudStack.converters.convertHz(capacity(1).capacityused), - cpuTotal: cloudStack.converters.convertHz(capacity(1).capacitytotal), - cpuPercentage: parseInt(capacity(1).percentused) - })); - } - }); - } else { - dataFns.alerts($.extend(data, { - publicIPAllocated: 0, - publicIPTotal: 0, - publicIPPercentage: 0, - privateIPAllocated: 0, - privateIPTotal: 0, - privateIPPercentage: 0, - memoryAllocated: 0, - memoryTotal: 0, - memoryPercentage: 0, - cpuAllocated: 0, - cpuTotal: 0, - cpuPercentage: 0 - })); - } + dataFns.alerts(data); }, alerts: function(data) {