You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/10/08 18:48:59 UTC
[1/2] ambari git commit: AMBARI-13360. Redundant links to Ganglia Web
UI
Repository: ambari
Updated Branches:
refs/heads/branch-2.1 3c5d1ee74 -> c5075f016
AMBARI-13360. Redundant links to Ganglia Web UI
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c5075f01
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c5075f01
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c5075f01
Branch: refs/heads/branch-2.1
Commit: c5075f016c8ef0704d9f3f232e018c83d75c782a
Parents: b6a31c5
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Oct 8 19:46:51 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Oct 8 19:48:52 2015 +0300
----------------------------------------------------------------------
ambari-web/app/messages.js | 1 -
.../app/templates/main/dashboard/widgets.hbs | 7 -
ambari-web/app/templates/main/host/summary.hbs | 9 -
.../app/templates/main/service/info/summary.hbs | 3 -
.../main/dashboard/cluster_metrics/memory.js | 10 +-
ambari-web/app/views/main/dashboard/widgets.js | 7 -
ambari-web/app/views/main/host/summary.js | 6 -
.../app/views/main/service/info/summary.js | 19 --
.../app/views/main/service/services/flume.js | 2 -
.../dashboard/cluster_metrics/memory_test.js | 197 +++----------------
.../test/views/main/dashboard/widgets_test.js | 13 --
11 files changed, 29 insertions(+), 245 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index f4134a9..74d569d 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2378,7 +2378,6 @@ Em.I18n.translations = {
'dashboard.button.switch': 'Switch to classic dashboard',
'dashboard.button.switchShort': 'Switch',
'dashboard.button.reset': 'Reset all widgets to default ',
- 'dashboard.button.gangliaLink': 'View metrics in Ganglia',
'dashboard.widgets.actions.title': 'Metric Actions',
'dashboard.widgets.create': 'Create Widget',
'dashboard.widgets.actions.browse': 'Browse Widgets',
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/templates/main/dashboard/widgets.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/widgets.hbs b/ambari-web/app/templates/main/dashboard/widgets.hbs
index f55b9b9..57ab38d 100644
--- a/ambari-web/app/templates/main/dashboard/widgets.hbs
+++ b/ambari-web/app/templates/main/dashboard/widgets.hbs
@@ -35,13 +35,6 @@
<i class="icon-refresh"></i> {{t dashboard.button.reset}}
</a>
</li>
- {{#if App.router.clusterController.isGangliaInstalled}}
- <li>
- <a target="_blank" {{bindAttr href="view.gangliaUrl"}}>
- <i class="icon-share"></i> {{t dashboard.button.gangliaLink}}
- </a>
- </li>
- {{/if}}
</ul>
</li>
</ul>
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/templates/main/host/summary.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs
index dace65a..681154d 100644
--- a/ambari-web/app/templates/main/host/summary.hbs
+++ b/ambari-web/app/templates/main/host/summary.hbs
@@ -174,15 +174,6 @@
<div class="box">
<div class="box-header">
<h4>{{t hosts.host.summary.hostMetrics}}</h4>
- {{#if App.router.clusterController.isGangliaInstalled}}
- <div class="btn-group">
- {{#if App.router.clusterController.isGangliaUrlLoaded}}
- <a class="btn" rel="tooltip" title="Go to Ganglia" {{action "showGangliaCharts" target="view"}}><i class="icon-link"></i></a>
- {{else}}
- <div class="spinner"></div>
- {{/if}}
- </div>
- {{/if}}
{{view view.timeRangeListView}}
</div>
<div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/templates/main/service/info/summary.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/info/summary.hbs b/ambari-web/app/templates/main/service/info/summary.hbs
index 9326623..af8078d 100644
--- a/ambari-web/app/templates/main/service/info/summary.hbs
+++ b/ambari-web/app/templates/main/service/info/summary.hbs
@@ -160,9 +160,6 @@
<i class="pull-left icon-caret-toggle"></i>
<span>{{collapsedSection.header}}</span>
</span>
- <a class="btn pull-right" {{bindAttr href="collapsedSection.url"}} target="_blank">
- <i class="icon-link"></i>
- </a>
<div class="clearfix"></div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js b/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
index 510c6b0..db1988e 100644
--- a/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
+++ b/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
@@ -38,20 +38,14 @@ App.ChartClusterMetricsMemory = App.ChartLinearTimeView.extend({
transformToSeries: function (jsonData) {
var seriesArray = [];
if (jsonData && jsonData.metrics && jsonData.metrics.memory) {
- var isAmbariMetricsAvailable = App.StackService.find().someProperty('serviceName', 'AMBARI_METRICS');
- var isAmbariMetricsInstalled = App.Service.find().someProperty('serviceName', 'AMBARI_METRICS');
- var isGangliaInstalled = App.Service.find().someProperty('serviceName', 'GANGLIA');
- var shouldConvertToBytes = isAmbariMetricsInstalled || isAmbariMetricsAvailable && !isGangliaInstalled;
var KB = Math.pow(2, 10);
for ( var name in jsonData.metrics.memory) {
var displayName = name;
var seriesData = jsonData.metrics.memory[name];
if (seriesData) {
var s = this.transformData(seriesData, displayName);
- if (shouldConvertToBytes) {
- for (var i = 0; i < s.data.length; i++) {
- s.data[i].y *= KB;
- }
+ for (var i = 0; i < s.data.length; i++) {
+ s.data[i].y *= KB;
}
seriesArray.push(s);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/views/main/dashboard/widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js
index 264fda7..f98c619 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -514,13 +514,6 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
});
},
- /**
- * @type {string}
- */
- gangliaUrl: function () {
- return App.router.get('clusterController.gangliaUrl') + "/?r=hour&cs=&ce=&m=&s=by+name&c=HDPSlaves&tab=m&vn=";
- }.property('App.router.clusterController.gangliaUrl'),
-
showAlertsPopup: Em.K
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/views/main/host/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js
index a01df69..59cfd1a 100644
--- a/ambari-web/app/views/main/host/summary.js
+++ b/ambari-web/app/views/main/host/summary.js
@@ -53,12 +53,6 @@ App.MainHostSummaryView = Em.View.extend(App.TimeRangeMixin, {
return App.router.get('mainHostDetailsController.content');
}.property('App.router.mainHostDetailsController.content'),
- showGangliaCharts: function () {
- var name = this.get('content.hostName');
- var gangliaMobileUrl = App.router.get('clusterController.gangliaUrl') + "/mobile_helper.php?show_host_metrics=1&h=" + name + "&c=HDPSlaves&r=hour&cs=&ce=";
- window.open(gangliaMobileUrl);
- },
-
/**
* Host metrics panel not displayed when Metrics service (ex:Ganglia) is not in stack definition.
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/views/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/summary.js b/ambari-web/app/views/main/service/info/summary.js
index 0eb2d7c..1a73eb1 100644
--- a/ambari-web/app/views/main/service/info/summary.js
+++ b/ambari-web/app/views/main/service/info/summary.js
@@ -545,25 +545,6 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, App.TimeRangeMixin
return !App.get('services.serviceMetrics').length;
}.property('App.services.serviceMetrics'),
- gangliaUrl:function () {
- var gangliaUrl = App.router.get('clusterController.gangliaUrl');
- if (!gangliaUrl) return null;
- var svcName = this.get('service.serviceName');
- if (svcName) {
- switch (svcName.toLowerCase()) {
- case 'hdfs':
- gangliaUrl += "/?r=hour&cs=&ce=&m=&s=by+name&c=HDPSlaves&tab=m&vn=";
- break;
- case 'hbase':
- gangliaUrl += "?r=hour&cs=&ce=&m=&s=by+name&c=HDPHBaseMaster&tab=m&vn=";
- break;
- default:
- break;
- }
- }
- return gangliaUrl;
- }.property('App.router.clusterController.gangliaUrl', 'service.serviceName'),
-
didInsertElement: function () {
var svcName = this.get('controller.content.serviceName');
this.set('service', this.getServiceModel(svcName));
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/app/views/main/service/services/flume.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/services/flume.js b/ambari-web/app/views/main/service/services/flume.js
index 013a10b..1ab89f9 100644
--- a/ambari-web/app/views/main/service/services/flume.js
+++ b/ambari-web/app/views/main/service/services/flume.js
@@ -153,7 +153,6 @@ App.MainDashboardServiceFlumeView = App.TableView.extend(App.MainDashboardServic
var metricType = Em.I18n.t('services.service.info.metrics.flume.' + metricTypeKey).format(Em.I18n.t('common.metrics'));
return metricType + ' - ' + hostName;
};
- var gangliaUrlTpl = App.router.get('clusterController.gangliaUrl') + '/?r=hour&cs=&ce=&m=load_one&s=by+name&c=HDPFlumeServer&h={0}&host_regex=&max_graphs=0&tab=m&vn=&sh=1&z=small&hc=4';
var agentHostMock = host.get('hostName');
var mockMetricData = [
{
@@ -183,7 +182,6 @@ App.MainDashboardServiceFlumeView = App.TableView.extend(App.MainDashboardServic
];
mockMetricData.forEach(function(mockData, index) {
mockData.header = getMetricTitle(mockData.header, agentHostMock);
- mockData.url = gangliaUrlTpl.format(agentHostMock);
mockData.id = 'metric' + index;
mockData.toggleIndex = '#' + mockData.id;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js b/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js
index 2512166..5e7bc516 100644
--- a/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js
+++ b/ambari-web/test/views/main/dashboard/cluster_metrics/memory_test.js
@@ -30,147 +30,7 @@ describe('App.ChartClusterMetricsMemory', function () {
describe('#transformToSeries', function () {
- var cases = [
- {
- isAmbariMetricsInstalled: true,
- seriesData: [
- [
- {
- x: 1000000000,
- y: 262144
- },
- {
- x: 1000001000,
- y: 524288
- }
- ],
- [
- {
- x: 1100000000,
- y: 1048576
- },
- {
- x: 1100001000,
- y: 2097152
- }
- ]
- ],
- title: 'Ambari Metrics is installed'
- },
- {
- isAmbariMetricsInstalled: false,
- isAmbariMetricsAvailable: true,
- isGangliaInstalled: false,
- seriesData: [
- [
- {
- x: 1000000000,
- y: 262144
- },
- {
- x: 1000001000,
- y: 524288
- }
- ],
- [
- {
- x: 1100000000,
- y: 1048576
- },
- {
- x: 1100001000,
- y: 2097152
- }
- ]
- ],
- title: 'Ganglia is not installed, Ambari Metrics is available'
- },
- {
- isAmbariMetricsInstalled: false,
- isAmbariMetricsAvailable: true,
- isGangliaInstalled: true,
- seriesData: [
- [
- {
- x: 1000000000,
- y: 256
- },
- {
- x: 1000001000,
- y: 512
- }
- ],
- [
- {
- x: 1100000000,
- y: 1024
- },
- {
- x: 1100001000,
- y: 2048
- }
- ]
- ],
- title: 'Ganglia is installed, Ambari Metrics is available'
- },
- {
- isAmbariMetricsInstalled: false,
- isAmbariMetricsAvailable: false,
- isGangliaInstalled: true,
- seriesData: [
- [
- {
- x: 1000000000,
- y: 256
- },
- {
- x: 1000001000,
- y: 512
- }
- ],
- [
- {
- x: 1100000000,
- y: 1024
- },
- {
- x: 1100001000,
- y: 2048
- }
- ]
- ],
- title: 'Ganglia is installed, Ambari Metrics is not available'
- },
- {
- isAmbariMetricsInstalled: false,
- isAmbariMetricsAvailable: false,
- isGangliaInstalled: false,
- seriesData: [
- [
- {
- x: 1000000000,
- y: 256
- },
- {
- x: 1000001000,
- y: 512
- }
- ],
- [
- {
- x: 1100000000,
- y: 1024
- },
- {
- x: 1100001000,
- y: 2048
- }
- ]
- ],
- title: 'Ganglia is not installed, Ambari Metrics is not available'
- }
- ],
- jsonData = {
+ var jsonData = {
metrics: {
memory: {
Buffer: [
@@ -184,38 +44,35 @@ describe('App.ChartClusterMetricsMemory', function () {
}
}
},
- names = ['Buffer', 'Total'];
-
- afterEach(function () {
- App.StackService.find.restore();
- App.Service.find.restore();
- });
+ seriesData = [
+ [
+ {
+ x: 1000000000,
+ y: 262144
+ },
+ {
+ x: 1000001000,
+ y: 524288
+ }
+ ],
+ [
+ {
+ x: 1100000000,
+ y: 1048576
+ },
+ {
+ x: 1100001000,
+ y: 2097152
+ }
+ ]
+ ],
+ names = ['Buffer', 'Total'],
+ title = 'should transform data to series';
- cases.forEach(function (item) {
- it(item.title, function () {
- var stackServices = [],
- services = [];
- if (item.isAmbariMetricsAvailable) {
- stackServices.push({
- serviceName: 'AMBARI_METRICS'
- });
- }
- if (item.isAmbariMetricsInstalled) {
- services.push({
- serviceName: 'AMBARI_METRICS'
- });
- }
- if (item.isGangliaInstalled) {
- services.push({
- serviceName: 'GANGLIA'
- });
- }
- sinon.stub(App.StackService, 'find').returns(stackServices);
- sinon.stub(App.Service, 'find').returns(services);
+ it(title, function () {
var series = view.transformToSeries(jsonData);
expect(series.mapProperty('name')).to.eql(names);
- expect(series.mapProperty('data')).to.eql(item.seriesData);
- });
+ expect(series.mapProperty('data')).to.eql(seriesData);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/c5075f01/ambari-web/test/views/main/dashboard/widgets_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets_test.js b/ambari-web/test/views/main/dashboard/widgets_test.js
index 0768c77..b0e2f14 100644
--- a/ambari-web/test/views/main/dashboard/widgets_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets_test.js
@@ -454,19 +454,6 @@ describe('App.MainDashboardWidgetsView', function () {
});
});
- describe("#gangliaUrl", function () {
- before(function () {
- sinon.stub(App.router, 'get').withArgs('clusterController.gangliaUrl').returns('url');
- });
- after(function () {
- App.router.get.restore();
- });
- it("", function () {
- view.propertyDidChange('gangliaUrl');
- expect(view.get('gangliaUrl')).to.equal('url/?r=hour&cs=&ce=&m=&s=by+name&c=HDPSlaves&tab=m&vn=');
- });
- });
-
describe('#checkServicesChange', function () {
var emptyCurrentPref = {
[2/2] ambari git commit: AMBARI-13359. Export formats dropdown menu
on graph thumbnail is open after downloading data from detailed view popup
Posted by al...@apache.org.
AMBARI-13359. Export formats dropdown menu on graph thumbnail is open after downloading data from detailed view popup
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b6a31c5d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b6a31c5d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b6a31c5d
Branch: refs/heads/branch-2.1
Commit: b6a31c5d97cf47fd07c713866192e1a6c8b8caaf
Parents: 3c5d1ee
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Oct 8 19:33:09 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Oct 8 19:48:52 2015 +0300
----------------------------------------------------------------------
.../common/widgets/export_metrics_mixin.js | 11 +++--
.../app/templates/common/chart/linear_time.hbs | 5 +--
.../templates/common/export_metrics_menu.hbs | 22 +++++++++
.../templates/common/widget/graph_widget.hbs | 5 +--
.../app/templates/main/charts/linear_time.hbs | 5 +--
.../main/dashboard/widgets/cluster_metrics.hbs | 5 +--
ambari-web/app/utils/file_utils.js | 2 -
ambari-web/app/views.js | 1 +
.../app/views/common/chart/linear_time.js | 10 +++--
.../views/common/export_metrics_menu_view.js | 27 +++++++++++
.../views/common/widget/graph_widget_view.js | 7 +--
.../dashboard/widgets/cluster_metrics_widget.js | 3 +-
.../common/widgets/export_metrics_mixin_test.js | 47 ++++++++++++++++----
13 files changed, 110 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/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 395557e..e49d7bc 100644
--- a/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/export_metrics_mixin.js
@@ -18,22 +18,27 @@
var App = require('app');
+require('views/common/export_metrics_menu_view');
var stringUtils = require('utils/string_utils');
var fileUtils = require('utils/file_utils');
App.ExportMetricsMixin = Em.Mixin.create({
/**
- * Used as argument passed from template to indicate that resulting format is CSV, not JSON
+ * Used as argument passed from template to indicate that resulting format is CSV instead of JSON
*/
exportToCSVArgument: true,
+ isMenuHidden: true,
+
+ exportMetricsMenuView: App.ExportMetricsMenuView.extend(),
+
toggleFormatsList: function () {
- this.$('.export-graph-list').toggle();
+ this.toggleProperty('isMenuHidden');
},
exportGraphData: function () {
- this.toggleFormatsList();
+ this.set('isMenuHidden', true);
},
exportGraphDataSuccessCallback: function (response, request, params) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/templates/common/chart/linear_time.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/chart/linear_time.hbs b/ambari-web/app/templates/common/chart/linear_time.hbs
index 35a3f3f..1dd6f5f 100644
--- a/ambari-web/app/templates/common/chart/linear_time.hbs
+++ b/ambari-web/app/templates/common/chart/linear_time.hbs
@@ -23,10 +23,7 @@
<a class="corner-icon pull-right" href="#" {{action toggleFormatsList target="view"}}>
<i class="icon-save"></i>
</a>
- <ul class="export-graph-list pull-right dropdown-menu">
- <li><a {{action exportGraphData view.parentView.graph.exportToCSVArgument target="view"}}>{{t common.csv}}</a></li>
- <li><a {{action exportGraphData target="view"}}>{{t common.json}}</a></li>
- </ul>
+ {{view view.exportMetricsMenuView}}
{{/if}}
</div>
{{#if view.isTimePagingEnable}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/templates/common/export_metrics_menu.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/export_metrics_menu.hbs b/ambari-web/app/templates/common/export_metrics_menu.hbs
new file mode 100644
index 0000000..c48065a
--- /dev/null
+++ b/ambari-web/app/templates/common/export_metrics_menu.hbs
@@ -0,0 +1,22 @@
+{{!
+* 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.
+}}
+
+<ul class="export-graph-list pull-right dropdown-menu">
+ <li><a {{action exportGraphData view.parentView.exportToCSVArgument target="view.parentView"}}>{{t common.csv}}</a></li>
+ <li><a {{action exportGraphData target="view.parentView"}}>{{t common.json}}</a></li>
+</ul>
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/templates/common/widget/graph_widget.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/widget/graph_widget.hbs b/ambari-web/app/templates/common/widget/graph_widget.hbs
index 6632db8..05a4e40 100644
--- a/ambari-web/app/templates/common/widget/graph_widget.hbs
+++ b/ambari-web/app/templates/common/widget/graph_widget.hbs
@@ -32,10 +32,7 @@
<a class="corner-icon pull-right" href="#" {{action toggleFormatsList target="view"}}>
<i class="icon-save"></i>
</a>
- <ul class="export-graph-list pull-right dropdown-menu">
- <li><a {{action exportGraphData view.exportToCSVArgument target="view"}}>{{t common.csv}}</a></li>
- <li><a {{action exportGraphData target="view"}}>{{t common.json}}</a></li>
- </ul>
+ {{view view.exportMetricsMenuView}}
{{/isAccessible}}
<div class="content"> {{view view.graphView}}</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/templates/main/charts/linear_time.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/charts/linear_time.hbs b/ambari-web/app/templates/main/charts/linear_time.hbs
index f91f149..f95c5de 100644
--- a/ambari-web/app/templates/main/charts/linear_time.hbs
+++ b/ambari-web/app/templates/main/charts/linear_time.hbs
@@ -34,10 +34,7 @@
<i class="icon-save"></i>
</a>
<div class="export-graph-list-top"></div>
- <ul class="export-graph-list pull-right dropdown-menu">
- <li><a {{action exportGraphData view.exportToCSVArgument target="view"}}>{{t common.csv}}</a></li>
- <li><a {{action exportGraphData target="view"}}>{{t common.json}}</a></li>
- </ul>
+ {{view view.exportMetricsMenuView}}
{{/if}}
{{/unless}}
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/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 6feeb86..5b5bea1 100644
--- a/ambari-web/app/templates/main/dashboard/widgets/cluster_metrics.hbs
+++ b/ambari-web/app/templates/main/dashboard/widgets/cluster_metrics.hbs
@@ -28,10 +28,7 @@
<a class="corner-icon span1" href="#" {{action toggleFormatsList target="view"}}>
<i class="icon-save"></i>
</a>
- <ul class="export-graph-list pull-right dropdown-menu">
- <li><a {{action exportGraphData view.exportToCSVArgument target="view"}}>{{t common.csv}}</a></li>
- <li><a {{action exportGraphData target="view"}}>{{t common.json}}</a></li>
- </ul>
+ {{view view.exportMetricsMenuView}}
{{/if}}
{{/if}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/utils/file_utils.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/file_utils.js b/ambari-web/app/utils/file_utils.js
index 59a9416..93e73ed 100644
--- a/ambari-web/app/utils/file_utils.js
+++ b/ambari-web/app/utils/file_utils.js
@@ -16,8 +16,6 @@
* limitations under the License.
*/
-var stringUtils = require('utils/string_utils');
-
module.exports = {
fileTypeMap: {
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 9a424c0..fccac10 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -84,6 +84,7 @@ require('views/common/widget/number_widget_view');
require('views/common/widget/heatmap_widget_view');
require('views/common/assign_master_components_view');
require('views/common/chosen_plugin');
+require('views/common/export_metrics_menu_view');
require('views/login');
require('views/main');
require('views/main/menu');
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/views/common/chart/linear_time.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/chart/linear_time.js b/ambari-web/app/views/common/chart/linear_time.js
index 5ffc628..8e903d6 100644
--- a/ambari-web/app/views/common/chart/linear_time.js
+++ b/ambari-web/app/views/common/chart/linear_time.js
@@ -161,10 +161,11 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
}.property('_containerSelector', 'popupSuffix'),
didInsertElement: function () {
+ var self = this;
this.loadData();
this.registerGraph();
this.$().parent().on('mouseleave', function () {
- $(this).find('.export-graph-list').hide();
+ self.set('isMenuHidden', true);
});
App.tooltip(this.$("[rel='ZoomInTooltip']"), {
placement: 'left',
@@ -407,7 +408,7 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
}
else {
graph_container.children().each(function () {
- if (!($(this).is('.export-graph-list, .corner-icon'))) {
+ if (!($(this).is('.export-graph-list-container, .corner-icon'))) {
$(this).children().remove();
}
});
@@ -751,12 +752,13 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
}.property('parentView.graph.isPopupReady'),
didInsertElement: function () {
+ var popupBody = this;
App.tooltip(this.$('.corner-icon > .icon-save'), {
title: Em.I18n.t('common.export')
});
this.$().closest('.modal').on('click', function (event) {
- if (!($(event.target).is('.corner-icon, .icon-save, .export-graph-list, .export-graph-list *'))) {
- $(this).find('.export-graph-list').hide();
+ if (!($(event.target).is('.corner-icon, .icon-save, .export-graph-list-container, .export-graph-list-container *'))) {
+ popupBody.set('isMenuHidden', true);
}
});
$('#modal').addClass('modal-graph-line');
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/views/common/export_metrics_menu_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/export_metrics_menu_view.js b/ambari-web/app/views/common/export_metrics_menu_view.js
new file mode 100644
index 0000000..84a6e6d
--- /dev/null
+++ b/ambari-web/app/views/common/export_metrics_menu_view.js
@@ -0,0 +1,27 @@
+/**
+ * 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');
+
+App.ExportMetricsMenuView = Em.View.extend({
+
+ classNameBindings: ['parentView.isMenuHidden::open', ':export-graph-list-container'],
+
+ templateName: require('templates/common/export_metrics_menu')
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/app/views/common/widget/graph_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/widget/graph_widget_view.js b/ambari-web/app/views/common/widget/graph_widget_view.js
index 3ad0419..9f550e9 100644
--- a/ambari-web/app/views/common/widget/graph_widget_view.js
+++ b/ambari-web/app/views/common/widget/graph_widget_view.js
@@ -288,8 +288,9 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, App.ExportMetricsMixin, {
},
didInsertElement: function () {
+ var self = this;
this.$().closest('.graph-widget').on('mouseleave', function () {
- $(this).find('.export-graph-list').hide();
+ self.set('parentView.isMenuHidden', true);
});
this.setYAxisFormatter();
this.loadData();
@@ -307,10 +308,6 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, App.ExportMetricsMixin, {
}.observes('parentView.data')
}),
- toggleFormatsList: function () {
- this.get('childViews.firstObject').$().closest('.graph-widget').find('.export-graph-list').toggle();
- },
-
exportGraphData: function (event) {
this._super();
var data,
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/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 69bf666..58dfecb 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
@@ -23,8 +23,9 @@ App.ClusterMetricsDashboardWidgetView = App.DashboardWidgetView.extend(App.Expor
templateName: require('templates/main/dashboard/widgets/cluster_metrics'),
didInsertElement: function () {
+ var self = this;
this.$().on('mouseleave', function () {
- $(this).find('.export-graph-list').hide();
+ self.set('isMenuHidden', true);
});
App.tooltip(this.$('.corner-icon > .icon-save'), {
title: Em.I18n.t('common.export')
http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a31c5d/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js b/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js
index 79fbfdb..01928d8 100644
--- a/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js
+++ b/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js
@@ -29,19 +29,48 @@ describe('App.ExportMetricsMixin', function () {
obj = Em.Object.create(App.ExportMetricsMixin);
});
- describe('#exportGraphData', function () {
+ describe('#toggleFormatsList', function () {
- beforeEach(function () {
- sinon.stub(obj, 'toggleFormatsList', Em.K);
- });
+ var cases = [
+ {
+ isMenuHidden: true,
+ title: 'menu should be visible'
+ },
+ {
+ isMenuHidden: false,
+ title: 'menu should be hidden'
+ }
+ ];
- afterEach(function () {
- obj.toggleFormatsList.restore();
+ cases.forEach(function (item) {
+ it(item.title, function () {
+ obj.set('isMenuHidden', !item.isMenuHidden);
+ obj.toggleFormatsList();
+ expect(obj.get('isMenuHidden')).to.equal(item.isMenuHidden);
+ });
});
- it('should toggle formats menu', function () {
- obj.exportGraphData();
- expect(obj.toggleFormatsList.calledOnce).to.be.true;
+ });
+
+ describe('#exportGraphData', function () {
+
+ var cases = [
+ {
+ isMenuHidden: true,
+ title: 'menu should remain hidden'
+ },
+ {
+ isMenuHidden: false,
+ title: 'menu should become hidden'
+ }
+ ];
+
+ cases.forEach(function (item) {
+ it(item.title, function () {
+ obj.set('isMenuHidden', item.isMenuHidden);
+ obj.exportGraphData();
+ expect(obj.get('isMenuHidden')).to.be.true;
+ });
});
});