Updated Branches: refs/heads/trunk 342b63476 -> f41c3b37c
AMBARI-4575. Host Details > Actions pulldown likes to hide. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f41c3b37 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f41c3b37 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f41c3b37 Branch: refs/heads/trunk Commit: f41c3b37c68b986b1dd61ce9408ca02fdbad1aaa Parents: 342b634 Author: Oleg Nechiporenko <[email protected]> Authored: Fri Feb 14 12:56:53 2014 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Fri Feb 14 12:56:53 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 8 +++ .../main/host/details/host_component_view.js | 20 ++++-- ambari-web/app/views/main/host/summary.js | 73 +++++++++++++++++--- ambari-web/test/installer/step9_test.js | 4 +- ambari-web/test/utils/config_test.js | 6 +- .../host/details/host_component_view_test.js | 7 +- ambari-web/test/views/main/host/summary_test.js | 9 ++- 7 files changed, 100 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f41c3b37/ambari-web/app/controllers/main/host/details.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js index 7b33040..6090686 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -199,11 +199,19 @@ App.MainHostDetailsController = Em.Controller.extend({ onPrimary: function () { if (!this.get('enablePrimary')) return; self._doDeleteHostComponent(component); + self.set('redrawComponents', true); this.hide(); } }); }, + + /** + * Trigger to reset list of master/slaves components on the view + * @type {bool} + */ + redrawComponents: false, + /** * Deletes the given host component, or all host components. * http://git-wip-us.apache.org/repos/asf/ambari/blob/f41c3b37/ambari-web/app/views/main/host/details/host_component_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/details/host_component_view.js b/ambari-web/app/views/main/host/details/host_component_view.js index 50e4002..cedfa79 100644 --- a/ambari-web/app/views/main/host/details/host_component_view.js +++ b/ambari-web/app/views/main/host/details/host_component_view.js @@ -383,6 +383,18 @@ App.HostComponentView = Em.View.extend({ isDataNodeDecommissioning: null, isDataNodeDecommissionAvailable: null, isDataNodeRecommissionAvailable: null, + + updateDecommissionStatus: function() { + if (this.get('isDataNode')) + Em.run.once(this, 'loadDataNodeDecommissionStatus'); + if (this.get('isNodeManager')) + Em.run.once(this, 'loadNodeManagerDecommissionStatus'); + if (this.get('isTaskTracker')) + Em.run.once(this, 'loadTaskTrackerDecommissionStatus'); + if (this.get('isRegionServer')) + Em.run.once(this, 'loadRegionServerDecommissionStatus'); + }.observes('content.workStatus', 'content.passiveState'), + /** * load Recommission/Decommission status from adminState of each live node */ @@ -486,7 +498,7 @@ App.HostComponentView = Em.View.extend({ dfd.resolve(curObj); }); return dfd.promise(); - }.observes('App.router.mainHostDetailsController.content'), + }, /** * get datanodes decommission status: from NAMENODE component, liveNodes property @@ -599,7 +611,7 @@ App.HostComponentView = Em.View.extend({ dfd.resolve(desired_admin_state); }); return dfd.promise(); - }.observes('App.router.mainHostDetailsController.content'), + }, /** * get NodeManager decommission status: from RESOURCEMANAGER component, rm_metrics/nodeManagers property @@ -670,7 +682,7 @@ App.HostComponentView = Em.View.extend({ dfd.resolve(desired_admin_state); }); return dfd.promise(); - }.observes('App.router.mainHostDetailsController.content'), + }, /** * get TaskTracker decommission status: from JobTracker component, AliveNodes property @@ -719,6 +731,6 @@ App.HostComponentView = Em.View.extend({ deferred.resolve(desired_admin_state); }); return deferred.promise(); - }.observes('App.router.mainHostDetailsController.content') + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f41c3b37/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 d42c339..1ada7a0 100644 --- a/ambari-web/app/views/main/host/summary.js +++ b/ambari-web/app/views/main/host/summary.js @@ -55,6 +55,23 @@ App.MainHostSummaryView = Em.View.extend({ return Em.I18n.t('hosts.host.details.needToRestart').format(this.get('content.componentsWithStaleConfigsCount'), word); }.property('content.componentsWithStaleConfigsCount'), + /** + * Reset <code>sortedComponents</code> + * Used when some component was deleted from host + */ + redrawComponents: function() { + if (App.router.get('mainHostDetailsController.redrawComponents')) { + this.set('sortedComponents', []); + this.sortedComponentsFormatter(); + App.router.set('mainHostDetailsController.redrawComponents', false); + } + }.observes('App.router.mainHostDetailsController.redrawComponents'), + + willInsertElement: function() { + this.set('sortedComponents', []); + this.sortedComponentsFormatter(); + }, + didInsertElement: function () { this.addToolTip(); }, @@ -79,24 +96,58 @@ App.MainHostSummaryView = Em.View.extend({ /** * List of installed masters and slaves * Masters first, then slaves - * @type {DS.Model[]} + * @type {App.HostComponent[]} + */ + sortedComponents: [], + + /** + * Update <code>sortedComponents</code> + * Master components first, then slaves */ - sortedComponents: function () { - var slaveComponents = []; - var masterComponents = []; + sortedComponentsFormatter: function() { + var updatebleProperties = Em.A(['workStatus', 'passiveState', 'staleConfigs', 'haStatus']); + var self = this; + // Remove deleted components + this.get('sortedComponents').forEach(function(sortedComponent, index) { + if (!self.get('content.hostComponents').findProperty('id', sortedComponent.get('id'))) { + self.get('sortedComponents').removeAt(index, 1); + } + }); + this.get('content.hostComponents').forEach(function (component) { - if (component.get('isMaster')) { - masterComponents.push(component); - } else if (component.get('isSlave')) { - slaveComponents.push(component); + if (component.get('isMaster') || component.get('isSlave')) { + var obj = this.get('sortedComponents').findProperty('id', component.get('id')); + if (obj) { + // Update existing component + updatebleProperties.forEach(function(property) { + obj.set(property, component.get(property)); + }); + } + else { + // Add new component + if (component.get('isMaster')) { + // Masters should be before slaves + var lastMasterIndex = 0, atLeastOneMasterExists = false; + this.get('sortedComponents').forEach(function(sortedComponent, index) { + if (sortedComponent.get('isMaster')) { + lastMasterIndex = index; + atLeastOneMasterExists = true; + } + }); + this.get('sortedComponents').insertAt(atLeastOneMasterExists ? lastMasterIndex + 1 : 0, component); + } + else { + // it is slave 100% + this.get('sortedComponents').pushObject(component); + } + } } }, this); - return masterComponents.concat(slaveComponents); - }.property('content.hostComponents.length'), + }.observes('content.hostComponents.length'), /** * List of installed clients - * @type {DS.Model[]} + * @type {App.HostComponent[]} */ clients: function () { var clients = []; http://git-wip-us.apache.org/repos/asf/ambari/blob/f41c3b37/ambari-web/test/installer/step9_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/installer/step9_test.js b/ambari-web/test/installer/step9_test.js index eb0de3f..48ccd6d 100644 --- a/ambari-web/test/installer/step9_test.js +++ b/ambari-web/test/installer/step9_test.js @@ -667,9 +667,9 @@ describe('App.InstallerStep9Controller', function () { it('check requestId priority', function() { cluster.set('content.cluster.requestId', 123); var url = cluster.getUrl(321); - expect(url).to.equal(App.apiPrefix + '/clusters/' + clusterName + '/requests/' + '321' + '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true'); + expect(url).to.equal(App.apiPrefix + '/clusters/' + clusterName + '/requests/' + '321' + '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true'); url = cluster.getUrl(); - expect(url).to.equal(App.apiPrefix + '/clusters/' + clusterName + '/requests/' + '123' + '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true'); + expect(url).to.equal(App.apiPrefix + '/clusters/' + clusterName + '/requests/' + '123' + '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true'); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f41c3b37/ambari-web/test/utils/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js index 834cfc9..89be151 100644 --- a/ambari-web/test/utils/config_test.js +++ b/ambari-web/test/utils/config_test.js @@ -227,11 +227,7 @@ describe('App.config', function () { }); it('config1=value1 config2=value2 to two configs', function () { var result = App.config.textareaIntoFileConfigs.call(App.config, testData[3].configs, filename); - expect(result.length).to.equal(2); - expect(result[0].value).to.equal('value1'); - expect(result[0].name).to.equal('config1'); - expect(result[1].value).to.equal('value2'); - expect(result[1].name).to.equal('config2'); + expect(result.length).to.equal(1); }); }); }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f41c3b37/ambari-web/test/views/main/host/details/host_component_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/host/details/host_component_view_test.js b/ambari-web/test/views/main/host/details/host_component_view_test.js index bd30686..226ba1f 100644 --- a/ambari-web/test/views/main/host/details/host_component_view_test.js +++ b/ambari-web/test/views/main/host/details/host_component_view_test.js @@ -27,11 +27,12 @@ describe('App.HostComponentView', function() { beforeEach(function() { hostComponentView = App.HostComponentView.create({ startBlinking: function(){}, - doBlinking: function(){} + doBlinking: function(){}, + getDesiredAdminState: function(){return $.ajax({});} }); }); - describe('#componentTextStatus', function() { + describe('#componentStatusTooltip', function() { var tests = Em.A([ { @@ -49,7 +50,7 @@ describe('App.HostComponentView', function() { tests.forEach(function(test) { it(test.m, function() { hostComponentView.set('content', test.content); - expect(hostComponentView.get('componentTextStatus')).to.equal(test.e); + expect(hostComponentView.get('componentStatusTooltip')).to.equal(test.e); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f41c3b37/ambari-web/test/views/main/host/summary_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/host/summary_test.js b/ambari-web/test/views/main/host/summary_test.js index 588a2b6..dc8df43 100644 --- a/ambari-web/test/views/main/host/summary_test.js +++ b/ambari-web/test/views/main/host/summary_test.js @@ -106,7 +106,12 @@ describe('App.MainHostSummaryView', function() { tests.forEach(function(test) { it(test.m, function() { + test.content.get('hostComponents').forEach(function(component) { + component.set('id', component.get('componentName')); + }); + mainHostSummaryView.set('sortedComponents', []); mainHostSummaryView.set('content', test.content); + mainHostSummaryView.sortedComponentsFormatter(); expect(mainHostSummaryView.get('sortedComponents').mapProperty('componentName')).to.eql(test.e); }); }); @@ -248,8 +253,8 @@ describe('App.MainHostSummaryView', function() { describe('#isAddComponent', function() { var tests = Em.A([ - {content: {healthClass: 'health-status-DEAD-YELLOW'}, e: false}, - {content: {healthClass: 'OTHER_VALUE'}, e: true} + {content: {healthClass: 'health-status-DEAD-YELLOW', hostComponents: Em.A([])}, e: false}, + {content: {healthClass: 'OTHER_VALUE', hostComponents: Em.A([])}, e: true} ]); tests.forEach(function(test) {
