Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 04615200BE3 for ; Wed, 7 Dec 2016 22:17:49 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0305D160B38; Wed, 7 Dec 2016 21:17:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4BDDF160B2F for ; Wed, 7 Dec 2016 22:17:48 +0100 (CET) Received: (qmail 91010 invoked by uid 500); 7 Dec 2016 21:17:47 -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 90748 invoked by uid 99); 7 Dec 2016 21:17:47 -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; Wed, 07 Dec 2016 21:17:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0C218F2154; Wed, 7 Dec 2016 21:17:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jonathanhurley@apache.org To: commits@ambari.apache.org Date: Wed, 07 Dec 2016 21:17:56 -0000 Message-Id: In-Reply-To: <3f732510822b405bae3800d507c38404@git.apache.org> References: <3f732510822b405bae3800d507c38404@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/41] ambari git commit: AMBARI-19110. "Cluster Load" widget in ambari-dashboard, download as CSV is not working (alexantonenko) archived-at: Wed, 07 Dec 2016 21:17:49 -0000 AMBARI-19110. "Cluster Load" widget in ambari-dashboard, download as CSV is not working (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0f297510 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0f297510 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0f297510 Branch: refs/heads/branch-feature-AMBARI-18456 Commit: 0f297510640f24db5c11bfbabaa390bb29e619a6 Parents: 2cd12ce Author: Alex Antonenko Authored: Tue Dec 6 18:29:00 2016 +0200 Committer: Alex Antonenko Committed: Tue Dec 6 19:04:30 2016 +0200 ---------------------------------------------------------------------- .../common/widgets/export_metrics_mixin.js | 28 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0f297510/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js b/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js index 7517efd..aa4f77c 100644 --- a/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js +++ b/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js @@ -85,6 +85,7 @@ App.ExportMetricsMixin = Em.Mixin.create({ ticksNumber, metricsNumber, metricsArray; + this.checkGraphDataForValidity(data); titles = data.map(function (item) { return displayUnit ? item.name + ' (' + displayUnit + ')' : item.name; }, this); @@ -95,12 +96,35 @@ App.ExportMetricsMixin = Em.Mixin.create({ for (var i = 0; i < ticksNumber; i++) { metricsArray.push([data[0].data[i][1]]); for (var j = 0; j < metricsNumber; j++) { - metricsArray[i + 1].push(data[j].data[i][0]); + metricsArray[i + 1].push(data[j].data[i][0]); }; - } + }; return stringUtils.arrayToCSV(metricsArray); }, + checkGraphDataForValidity: function (data) { + data.sort(function (a, b) { + return b.data.length - a.data.length + }); + + var maxLength = data[0].data.length; + + for (var i = 1; i < data.length; i ++) { + if (data[i].data.length !== maxLength) this.fillGraphDataArrayWithMockedData(data[i], maxLength); + } + }, + + fillGraphDataArrayWithMockedData: function (dataArray, neededLength) { + var startIndex = dataArray.data.length, + timestampInterval = dataArray.data[2][1] - dataArray.data[1][1]; + + for (var i = startIndex; i < neededLength; i++) { + var previousTimestamp = dataArray.data[i - 1][1]; + + dataArray.data.push([null, previousTimestamp + timestampInterval]); + } + }, + jsonReplacer: function () { var displayUnit = this.get('targetView.displayUnit'); return function (key, value) {