ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [11/41] ambari git commit: AMBARI-19110. "Cluster Load" widget in ambari-dashboard, download as CSV is not working (alexantonenko)
Date Wed, 07 Dec 2016 21:17:56 GMT
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 <hiveww@gmail.com>
Authored: Tue Dec 6 18:29:00 2016 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
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) {


Mime
View raw message