ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-13384. Unable to export metrics data from dashboard during the first visit of this page
Date Mon, 12 Oct 2015 09:29:03 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 fadc4f709 -> e2bfb331a


AMBARI-13384. Unable to export metrics data from dashboard during the first visit of this
page


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e2bfb331
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e2bfb331
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e2bfb331

Branch: refs/heads/branch-2.1
Commit: e2bfb331a4a33da2b6dc056077e77db721d2b337
Parents: fadc4f7
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Mon Oct 12 12:20:03 2015 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Mon Oct 12 12:28:58 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |  1 +
 .../main/dashboard/widgets/cluster_metrics.hbs  |  2 +-
 .../dashboard/widgets/cluster_metrics_widget.js |  4 +-
 .../widgets/cluster_metrics_widget_test.js      | 88 ++++++++++++++++++++
 4 files changed, 92 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e2bfb331/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 6d3ffe3..dfb9c91 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -237,6 +237,7 @@ var files = ['test/init_model_test',
   'test/views/main/dashboard/widgets/links_widget_test',
   'test/views/main/dashboard/widgets/pie_chart_widget_test',
   'test/views/main/dashboard/widgets/namenode_cpu_test',
+  'test/views/main/dashboard/widgets/cluster_metrics_widget_test',
   'test/views/main/host/details_test',
   'test/views/main/host/summary_test',
   'test/views/main/host/menu_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/e2bfb331/ambari-web/app/templates/main/dashboard/widgets/cluster_metrics.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/widgets/cluster_metrics.hbs b/ambari-web/app/templates/main/dashboard/widgets/cluster_metrics.hbs
index 5b5bea1..ac5ab3a 100644
--- a/ambari-web/app/templates/main/dashboard/widgets/cluster_metrics.hbs
+++ b/ambari-web/app/templates/main/dashboard/widgets/cluster_metrics.hbs
@@ -24,7 +24,7 @@
       </a>
       <div class="caption span10">{{view.title}}</div>
       {{#if view.isDataLoaded}}
-        {{#if view.childViews.firstObject.hasData}}
+        {{#if view.childViews.lastObject.hasData}}
           <a class="corner-icon span1" href="#" {{action toggleFormatsList target="view"}}>
             <i class="icon-save"></i>
           </a>

http://git-wip-us.apache.org/repos/asf/ambari/blob/e2bfb331/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js b/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js
index 58dfecb..a3d7f84 100644
--- a/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js
+++ b/ambari-web/app/views/main/dashboard/widgets/cluster_metrics_widget.js
@@ -34,10 +34,10 @@ App.ClusterMetricsDashboardWidgetView = App.DashboardWidgetView.extend(App.Expor
 
   exportGraphData: function (event) {
     this._super();
-    var ajaxIndex = this.get('childViews.firstObject.ajaxIndex');
+    var ajaxIndex = this.get('childViews.lastObject.ajaxIndex');
     App.ajax.send({
       name: ajaxIndex,
-      data: $.extend(this.get('childViews.firstObject').getDataForAjaxRequest(), {
+      data: $.extend(this.get('childViews.lastObject').getDataForAjaxRequest(), {
         isCSV: !!event.context
       }),
       sender: this,

http://git-wip-us.apache.org/repos/asf/ambari/blob/e2bfb331/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js b/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js
new file mode 100644
index 0000000..1471aac
--- /dev/null
+++ b/ambari-web/test/views/main/dashboard/widgets/cluster_metrics_widget_test.js
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+require('views/main/dashboard/widgets/cluster_metrics_widget');
+
+describe('App.ClusterMetricsDashboardWidgetView', function () {
+
+  var view;
+
+  beforeEach(function () {
+    view = App.ClusterMetricsDashboardWidgetView.create();
+  });
+
+  describe('#exportGraphData', function () {
+
+    beforeEach(function () {
+      sinon.stub(App.ajax, 'send', Em.K);
+      view.get('childViews').pushObjects([
+        {
+          ajaxIndex: 'ai0',
+          getDataForAjaxRequest: function () {
+            return {
+              p0: 'v0'
+            }
+          }
+        },
+        {
+          ajaxIndex: 'ai1',
+          getDataForAjaxRequest: function () {
+            return {
+              p1: 'v1'
+            }
+          }
+        }
+      ]);
+    });
+
+    afterEach(function () {
+      App.ajax.send.restore();
+    });
+
+    var cases = [
+      {
+        event: {},
+        isCSV: false,
+        title: 'JSON export'
+      },
+      {
+        event: {
+          context: true
+        },
+        isCSV: true,
+        title: 'CSV export'
+      }
+    ];
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        view.exportGraphData(item.event);
+        expect(App.ajax.send.calledOnce).to.be.true;
+        expect(App.ajax.send.firstCall.args[0].name).to.equal('ai1');
+        expect(App.ajax.send.firstCall.args[0].data).to.eql({
+          p1: 'v1',
+          isCSV: item.isCSV
+        });
+      });
+    });
+
+  });
+
+});


Mime
View raw message