Repository: ambari Updated Branches: refs/heads/trunk fbcf24f71 -> 7ff9bd429
AMBARI-20377. Usability: Hostname hover of master is not discoverable in Summary section (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7ff9bd42 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7ff9bd42 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7ff9bd42 Branch: refs/heads/trunk Commit: 7ff9bd429a1273074d6b8c1edf8b170d3f77ee0d Parents: 647ff84 Author: Alex Antonenko <hiv...@gmail.com> Authored: Thu Mar 9 15:00:54 2017 +0200 Committer: Alex Antonenko <hiv...@gmail.com> Committed: Thu Mar 9 17:11:37 2017 +0200 ---------------------------------------------------------------------- .../service/info/summary/master_components.hbs | 2 +- .../main/service/info/components_list_view.js | 23 ++++++----- ambari-web/app/views/main/service/service.js | 12 ++---- .../app/views/main/service/services/hdfs.js | 17 +++------ .../service/info/component_list_view_test.js | 29 ++++++-------- .../views/main/service/services/hdfs_test.js | 40 +++----------------- 6 files changed, 40 insertions(+), 83 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7ff9bd42/ambari-web/app/templates/main/service/info/summary/master_components.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/service/info/summary/master_components.hbs b/ambari-web/app/templates/main/service/info/summary/master_components.hbs index be388c5..5b7b47b 100644 --- a/ambari-web/app/templates/main/service/info/summary/master_components.hbs +++ b/ambari-web/app/templates/main/service/info/summary/master_components.hbs @@ -19,7 +19,7 @@ {{#each comp in view.mastersComp}} <div {{bindAttr class="comp.isSubComponent:component-small :component comp.componentName :row"}}> <div {{bindAttr class=":col-md-6 :summary-label comp.summaryLabelClassName"}}> - <a href="#" {{action showDetails comp.host}} title="{{unbound comp.publicHostName}}" rel="UsageTooltip"> + <a href="#" {{action showDetails comp.host}} data-original-title="{{unbound comp.publicHostName}}" rel="UsageTooltip"> {{#if comp.displayNameAdvanced}} {{comp.displayNameAdvanced}} {{else}} http://git-wip-us.apache.org/repos/asf/ambari/blob/7ff9bd42/ambari-web/app/views/main/service/info/components_list_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/info/components_list_view.js b/ambari-web/app/views/main/service/info/components_list_view.js index c0a9922..2d01d83 100644 --- a/ambari-web/app/views/main/service/info/components_list_view.js +++ b/ambari-web/app/views/main/service/info/components_list_view.js @@ -20,25 +20,24 @@ var App = require('app'); App.SummaryMasterComponentsView = Em.View.extend({ templateName: require('templates/main/service/info/summary/master_components'), - mastersCurrentLength: 0, + mastersComp: [], + mastersCompWillChange: function() { - this.removeTooltips(); + Em.run.next(() => this.removeTooltips()); }.observesBefore('mastersComp.length'), + mastersCompDidChange: function() { - this.attachTooltip(); + Em.run.next(() => this.attachTooltip()); }.observes('mastersComp.length'), removeTooltips: function() { - if ($('[rel=SummaryComponentHealthTooltip]').length) { - $('[rel=SummaryComponentHealthTooltip]').tooltip('destroy'); - } + $('.tooltip').remove(); + $(App.SummaryMasterComponentsView.tooltipsSelector).tooltip('destroy'); }, attachTooltip: function() { - if ($('[rel=SummaryComponentHealthTooltip]').length) { - App.tooltip($('[rel=SummaryComponentHealthTooltip]')); - } + App.tooltip($(App.SummaryMasterComponentsView.tooltipsSelector)); }, didInsertElement: function() { @@ -46,10 +45,14 @@ App.SummaryMasterComponentsView = Em.View.extend({ }, willDestroyElement: function() { - $('[rel=SummaryComponentHealthTooltip]').tooltip('destroy'); + this.removeTooltips(); } }); +App.SummaryMasterComponentsView.reopenClass({ + tooltipsSelector: '[rel=SummaryComponentHealthTooltip], [rel=UsageTooltip]' +}); + App.SummaryClientComponentsView = Em.View.extend({ templateName: require('templates/main/service/info/summary/client_components'), clientsObj: [] http://git-wip-us.apache.org/repos/asf/ambari/blob/7ff9bd42/ambari-web/app/views/main/service/service.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/service.js b/ambari-web/app/views/main/service/service.js index 466ccdc..74319f5 100644 --- a/ambari-web/app/views/main/service/service.js +++ b/ambari-web/app/views/main/service/service.js @@ -19,6 +19,7 @@ var App = require('app'); var uiEffects = require('utils/ui_effects'); var numberUtils = require('utils/number_utils'); +require('views/main/service/info/components_list_view'); App.MainDashboardServiceHealthView = Em.View.extend({ classNameBindings: ["healthStatus", "healthStatusClass"], @@ -131,15 +132,8 @@ App.MainDashboardServiceView = Em.View.extend(App.MainDashboardServiceViewWrappe return this.get('controller.data.' + this.get('serviceName')); }.property('controller.data'), - dashboardMasterComponentView: Em.View.extend({ - didInsertElement: function() { - App.tooltip($('[rel=SummaryComponentHealthTooltip]')); - }, - templateName: require('templates/main/service/info/summary/master_components'), - mastersComp: Em.computed.alias('parentView.parentView.mastersObj'), - willDestroyElement: function() { - $('[rel=SummaryComponentHealthTooltip]').tooltip('destroy'); - } + dashboardMasterComponentView: App.SummaryMasterComponentsView.extend({ + mastersComp: Em.computed.alias('parentView.parentView.mastersObj') }), alertsCount: Em.computed.alias('service.alertsCount'), http://git-wip-us.apache.org/repos/asf/ambari/blob/7ff9bd42/ambari-web/app/views/main/service/services/hdfs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/services/hdfs.js b/ambari-web/app/views/main/service/services/hdfs.js index f85e095..79208b9 100644 --- a/ambari-web/app/views/main/service/services/hdfs.js +++ b/ambari-web/app/views/main/service/services/hdfs.js @@ -49,16 +49,13 @@ App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({ }.property('service.capacityUsed', 'service.capacityTotal') }), - dashboardMasterComponentView: Em.View.extend({ - didInsertElement: function() { - App.tooltip($('[rel=healthTooltip]')); - }, - templateName: require('templates/main/service/info/summary/master_components'), + dashboardMasterComponentView: App.SummaryMasterComponentsView.extend({ mastersComp: function() { var masterComponents = []; - var zkfcs = this.get('parentView.service.hostComponents').filterProperty('componentName', 'ZKFC'); + var hostComponents = this.get('parentView.service.hostComponents'); + var zkfcs = hostComponents.filterProperty('componentName', 'ZKFC'); - this.get('parentView.service.hostComponents').forEach(function (comp) { + hostComponents.forEach(function (comp) { if (comp.get('isMaster') && comp.get('componentName') !== 'JOURNALNODE') { masterComponents.push(comp); var zkfc = zkfcs.findProperty('hostName', comp.get('hostName')); @@ -69,10 +66,8 @@ App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({ } }); return masterComponents; - }.property('parentView.service.hostComponents.length'), - willDestroyElement: function() { - $('[rel=healthTooltip]').tooltip('destroy') - } + }.property('parentView.service.hostComponents.length') + }), metricsNotAvailableObserver: function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/7ff9bd42/ambari-web/test/views/main/service/info/component_list_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/info/component_list_view_test.js b/ambari-web/test/views/main/service/info/component_list_view_test.js index 1537f2b..af7d7e8 100644 --- a/ambari-web/test/views/main/service/info/component_list_view_test.js +++ b/ambari-web/test/views/main/service/info/component_list_view_test.js @@ -33,9 +33,11 @@ describe('App.SummaryMasterComponentsView', function () { describe("#mastersCompWillChange", function() { beforeEach(function() { + sinon.stub(Em.run, 'next', Em.clb); sinon.stub(view, 'removeTooltips'); }); afterEach(function() { + Em.run.next.restore(); view.removeTooltips.restore(); }); @@ -48,9 +50,11 @@ describe('App.SummaryMasterComponentsView', function () { describe("#mastersCompDidChange", function() { beforeEach(function() { + sinon.stub(Em.run, 'next', Em.clb); sinon.stub(view, 'attachTooltip'); }); afterEach(function() { + Em.run.next.restore(); view.attachTooltip.restore(); }); @@ -76,7 +80,10 @@ describe('App.SummaryMasterComponentsView', function () { }); describe("#willDestroyElement", function() { - var mock = {tooltip: Em.K}; + var mock = { + tooltip: Em.K, + remove: Em.K + }; beforeEach(function() { sinon.spy(mock, 'tooltip'); @@ -95,7 +102,8 @@ describe('App.SummaryMasterComponentsView', function () { describe("#removeTooltips", function() { var mock = { - tooltip: Em.K + tooltip: Em.K, + remove: Em.K }; beforeEach(function() { @@ -108,21 +116,15 @@ describe('App.SummaryMasterComponentsView', function () { }); it("tooltip should be called", function() { - mock.length = 1; view.removeTooltips(); expect(mock.tooltip.calledWith('destroy')).to.be.true; }); - - it("tooltip should not be called", function() { - mock.length = 0; - view.removeTooltips(); - expect(mock.tooltip.called).to.be.false; - }); }); describe("#attachTooltip", function() { var mock = { - tooltip: Em.K + tooltip: Em.K, + remove: Em.K }; beforeEach(function() { @@ -135,16 +137,9 @@ describe('App.SummaryMasterComponentsView', function () { }); it("tooltip should be called", function() { - mock.length = 1; view.attachTooltip(); expect(App.tooltip.calledOnce).to.be.true; }); - - it("tooltip should not be called", function() { - mock.length = 0; - view.attachTooltip(); - expect(App.tooltip.called).to.be.false; - }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7ff9bd42/ambari-web/test/views/main/service/services/hdfs_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/services/hdfs_test.js b/ambari-web/test/views/main/service/services/hdfs_test.js index efa0e3b..4de5f0b 100644 --- a/ambari-web/test/views/main/service/services/hdfs_test.js +++ b/ambari-web/test/views/main/service/services/hdfs_test.js @@ -60,7 +60,11 @@ describe('App.MainDashboardServiceHdfsView', function () { beforeEach(function() { dashboardMasterComponentView = view.get('dashboardMasterComponentView').create({ - parentView: Em.Object.create() + parentView: Em.Object.create({ + service: Em.Object.create({ + hostComponents: [] + }) + }) }); }); @@ -88,40 +92,6 @@ describe('App.MainDashboardServiceHdfsView', function () { }); }); - describe("#didInsertElement()", function() { - - beforeEach(function() { - sinon.stub(App, 'tooltip'); - }); - afterEach(function() { - App.tooltip.restore(); - }); - - it("App.tooltip should be called", function() { - dashboardMasterComponentView.didInsertElement(); - expect(App.tooltip.calledOnce).to.be.true; - }); - }); - - describe("#willDestroyElement()", function() { - var mock = { - tooltip: Em.K - }; - - beforeEach(function() { - sinon.stub(mock, 'tooltip'); - sinon.stub(window, '$').returns(mock); - }); - afterEach(function() { - mock.tooltip.restore(); - window.$.restore(); - }); - - it("tooltip destroy should be called", function() { - dashboardMasterComponentView.willDestroyElement(); - expect(mock.tooltip.calledWith('destroy')).to.be.true; - }); - }); }); describe("#metricsNotAvailableObserver()", function() {