Repository: ambari Updated Branches: refs/heads/trunk f83d95df7 -> fd73398b1
AMBARI-5507. Refactor of Flume service view related to metrics. (Denys Buzhor via alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fd73398b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fd73398b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fd73398b Branch: refs/heads/trunk Commit: fd73398b19c2e419ad8e9572865a06a380fbe472 Parents: f83d95d Author: Alex Antonenko <[email protected]> Authored: Fri Apr 18 15:56:55 2014 +0300 Committer: Alex Antonenko <[email protected]> Committed: Fri Apr 18 15:56:55 2014 +0300 ---------------------------------------------------------------------- .../app/templates/main/service/info/summary.hbs | 18 +++--- .../app/views/main/service/info/summary.js | 62 +++----------------- .../app/views/main/service/services/flume.js | 36 ++++++++++++ 3 files changed, 54 insertions(+), 62 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fd73398b/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 e488656..a64993e 100644 --- a/ambari-web/app/templates/main/service/info/summary.hbs +++ b/ambari-web/app/templates/main/service/info/summary.hbs @@ -123,26 +123,26 @@ </div> </div> -{{#if view.collapsedMetrics}} +{{#if view.collapsedSections}} <div class="row-fluid"> <div class="span12 metrics-collapsed-graphs"> - {{#each collapsedMetric in view.collapsedMetrics}} - <div {{bindAttr class=":accordion collapsedMetric.toggleIndex"}}> + {{#each collapsedSection in view.collapsedSections}} + <div {{bindAttr class=":accordion collapsedSection.toggleIndex"}}> <div class="accordion-group box"> <div class="accordion-heading box-header"> - <span class="pull-left accordion-toggle" data-toggle="collapse" {{bindAttr dataParent="collapsedMetric.toggleIndex" href="collapsedMetric.toggleIndex"}}> + <span class="pull-left accordion-toggle" data-toggle="collapse" {{bindAttr dataParent="collapsedSection.toggleIndex" href="collapsedSection.toggleIndex"}}> <i class="pull-left icon-caret-toggle"></i> - <span>{{collapsedMetric.header}}</span> + <span>{{collapsedSection.header}}</span> </span> - <a class="btn pull-right" {{bindAttr href="collapsedMetric.url"}} target="_blank"> + <a class="btn pull-right" {{bindAttr href="collapsedSection.url"}} target="_blank"> <i class="icon-link"></i> </a> <div class="clearfix"></div> </div> - <div class="accordion-body collapse in" {{bindAttr id="collapsedMetric.id"}}> + <div class="accordion-body collapse in" {{bindAttr id="collapsedSection.id"}}> <div class="accordion-inner"> - {{#if collapsedMetric.metricView}} - {{view collapsedMetric.metricView}} + {{#if collapsedSection.metricView}} + {{view collapsedSection.metricView}} {{/if}} </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/fd73398b/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 6592f8f..dd7ce7f 100644 --- a/ambari-web/app/views/main/service/info/summary.js +++ b/ambari-web/app/views/main/service/info/summary.js @@ -54,8 +54,14 @@ App.MainServiceInfoSummaryView = Em.View.extend({ pig :false, sqoop: false }, - /** @property collapsedMetrics {array} - metrics list for collapsed view **/ - collapsedMetrics: null, + /** @property collapsedMetrics {object[]} - metrics list for collapsed section + * structure of element from list: + * @property {string} header - title for section + * @property {string} id - id of section for toggling, like: metric1 + * @property {string} toggleIndex - passed to `data-parent` attribute, like: #metric1 + * @property {Em.View} metricView - metric view class + */ + collapsedSections: null, servicesHaveClients: ["OOZIE", "ZOOKEEPER", "HIVE", "MAPREDUCE2", "TEZ", "SQOOP", "PIG","FALCON"], @@ -520,56 +526,6 @@ App.MainServiceInfoSummaryView = Em.View.extend({ }); return names.length ? names.join(', ') : false; - }.property('clientComponents'), - /** - * Show metric by related info. - * - * @method setMetric - * @param {object} context - data related to metric - */ - setMetric: function(context) { - switch (this.get('service.serviceName')) { - case 'FLUME': - this.setFlumeAgentMetric(context); - break; - default: - break; - } - }, - /** - * Show Flume agent metric. - * - * @method setFlumeAgentMetric - * @param {object} agent - DS.model of agent - */ - setFlumeAgentMetric: function(agent) { - var getMetricTitle = function(metricTypeKey, hostName) { - 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 = 'localhost'; // @todo change to agent hostname - var mockMetricData = [ - { - header: 'sinkName', - metricView: App.ChartServiceMetricsFlume_SinkDrainSuccessCount.extend() - }, - { - header: 'sourceName', - metricView: App.ChartServiceMetricsFlume_SourceAcceptedCount.extend() - }, - { - header: 'channelName', - metricView: App.ChartServiceMetricsFlume_ChannelSize.extend() - } - ]; - mockMetricData.forEach(function(mockData, index) { - mockData.header = getMetricTitle(mockData.header, agentHostMock); - mockData.url = gangliaUrlTpl.format(agentHostMock); - mockData.id = 'metric' + index; - mockData.toggleIndex = '#' + mockData.id; - }); - this.set('collapsedMetrics', mockMetricData); - } + }.property('clientComponents') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/fd73398b/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 a42d074..4e24545 100644 --- a/ambari-web/app/views/main/service/services/flume.js +++ b/ambari-web/app/views/main/service/services/flume.js @@ -115,6 +115,7 @@ App.MainDashboardServiceFlumeView = App.TableView.extend({ var agent = event.context; this.set('controller.selectedFlumeAgent', agent); this.toggleHighlight($(event.currentTarget)); + this.setAgentMetrics(event.context); this.get('parentView').setMetric(agent); }, /** @@ -126,5 +127,40 @@ App.MainDashboardServiceFlumeView = App.TableView.extend({ toggleHighlight: function(element) { element.parent().find('.highlight').removeClass('highlight'); element.addClass('highlight'); + }, + /** + * Show Flume agent metric. + * + * @method setFlumeAgentMetric + * @param {object} agent - DS.model of agent + */ + setAgentMetrics: function(agent) { + var getMetricTitle = function(metricTypeKey, hostName) { + 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 = 'localhost'; // @todo change to agent hostname + var mockMetricData = [ + { + header: 'sinkName', + metricView: App.ChartServiceMetricsFlume_SinkDrainSuccessCount.extend() + }, + { + header: 'sourceName', + metricView: App.ChartServiceMetricsFlume_SourceAcceptedCount.extend() + }, + { + header: 'channelName', + metricView: App.ChartServiceMetricsFlume_ChannelSize.extend() + } + ]; + mockMetricData.forEach(function(mockData, index) { + mockData.header = getMetricTitle(mockData.header, agentHostMock); + mockData.url = gangliaUrlTpl.format(agentHostMock); + mockData.id = 'metric' + index; + mockData.toggleIndex = '#' + mockData.id; + }); + this.set('parentView.collapsedSections', mockMetricData); } });
