Updated Branches: refs/heads/trunk 02ecc4d18 -> cd0517afb
AMBARI-3535. skip "Customize Services" step for services that can't be customized. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/cd0517af Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/cd0517af Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/cd0517af Branch: refs/heads/trunk Commit: cd0517afb0715fd1fd577a48c0a7fd3096ab2add Parents: 02ecc4d Author: Oleg Nechiporenko <[email protected]> Authored: Thu Oct 17 17:28:12 2013 +0300 Committer: Oleg Nechiporenko <[email protected]> Committed: Thu Oct 17 17:33:07 2013 +0300 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../controllers/main/service/add_controller.js | 49 +++++++- ambari-web/app/controllers/wizard.js | 7 +- .../app/controllers/wizard/step7_controller.js | 4 + ambari-web/app/routes/add_service_routes.js | 20 ++- .../main/service/add_controller_test.js | 122 +++++++++++++++++++ 6 files changed, 196 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd0517af/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 b69b77b..014bf9f 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -35,6 +35,7 @@ require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_cpuWaitIO_t require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_diskspaceused_test'); require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_memoryused_test'); require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed_test'); +require('test/controllers/main/service/add_controller_test'); require('test/controllers/main/service/reassign_controller_test'); require('test/controllers/main/dashboard_test'); require('test/controllers/main/host_test'); http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd0517af/ambari-web/app/controllers/main/service/add_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js index 92f0f05..04f34cb 100644 --- a/ambari-web/app/controllers/main/service/add_controller.js +++ b/ambari-web/app/controllers/main/service/add_controller.js @@ -18,11 +18,12 @@ var App = require('app'); - App.AddServiceController = App.WizardController.extend({ name: 'addServiceController', + serviceConfigs:require('data/service_configs'), + totalSteps: 7, /** @@ -122,6 +123,9 @@ App.AddServiceController = App.WizardController.extend({ console.log('selected services ', serviceNames); this.set('content.skipSlavesStep', !serviceNames.contains('MAPREDUCE') && !serviceNames.contains('HBASE')); + if (this.get('content.skipSlavesStep')) { + this.get('isStepDisabled').findProperty('step', 3).set('value', this.get('content.skipSlavesStep')); + } }, /** @@ -139,6 +143,9 @@ App.AddServiceController = App.WizardController.extend({ console.log('AddServiceController.selectedServiceNames:', serviceNames); this.set('content.skipSlavesStep', !serviceNames.contains('MAPREDUCE') && !serviceNames.contains('HBASE')); + if (this.get('content.skipSlavesStep')) { + this.get('isStepDisabled').findProperty('step', 3).set('value', this.get('content.skipSlavesStep')); + } }, /** @@ -165,6 +172,7 @@ App.AddServiceController = App.WizardController.extend({ this.set('content.masterComponentHosts', masterComponentHosts); this.set('content.skipMasterStep', this.get('content.masterComponentHosts').everyProperty('isInstalled', true)); + this.get('isStepDisabled').findProperty('step', 2).set('value', this.get('content.skipMasterStep')); }, /** @@ -187,6 +195,45 @@ App.AddServiceController = App.WizardController.extend({ console.log("AddServiceController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts); this.set('content.skipMasterStep', this.get('content.masterComponentHosts').everyProperty('isInstalled', true)); + this.get('isStepDisabled').findProperty('step', 2).set('value', this.get('content.skipMasterStep')); + }, + + /** + * Does service have any configs + * @param {string} serviceName + * @returns {boolean} + */ + isServiceConfigurable: function(serviceName) { + return this.get('serviceConfigs').mapProperty('serviceName').contains(serviceName); + }, + + /** + * Should Config Step be skipped (based on selected services list) + * @returns {boolean} + */ + skipConfigStep: function() { + var skipConfigStep = true; + var selectedServices = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName'); + selectedServices.map(function(serviceName) { + skipConfigStep = skipConfigStep && !this.isServiceConfigurable(serviceName); + }, this); + return skipConfigStep; + }, + + loadServiceConfigProperties: function() { + this._super(); + if (this.get('currentStep') > 1) { + this.set('content.skipConfigStep', this.skipConfigStep()); + this.get('isStepDisabled').findProperty('step', 4).set('value', this.get('content.skipConfigStep')); + } + }, + + saveServiceConfigProperties: function(stepController) { + this._super(stepController); + if (this.get('currentStep') > 1) { + this.set('content.skipConfigStep', this.skipConfigStep()); + this.get('isStepDisabled').findProperty('step', 4).set('value', this.get('content.skipConfigStep')); + } }, /** http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd0517af/ambari-web/app/controllers/wizard.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js index 45ec81f..2488c4c 100644 --- a/ambari-web/app/controllers/wizard.js +++ b/ambari-web/app/controllers/wizard.js @@ -26,19 +26,16 @@ App.WizardController = Em.Controller.extend({ init: function () { this.set('isStepDisabled', []); this.clusters = App.Cluster.find(); - this.isStepDisabled.pushObject(Ember.Object.create({ + this.get('isStepDisabled').pushObject(Ember.Object.create({ step: 1, value: false })); for (var i = 2; i <= this.get('totalSteps'); i++) { - this.isStepDisabled.pushObject(Ember.Object.create({ + this.get('isStepDisabled').pushObject(Ember.Object.create({ step: i, value: true })); } - // window.onbeforeunload = function () { - // return "You have not saved your document yet. If you continue, your work will not be saved." - //} }, setStepsEnable: function () { http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd0517af/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index b46e6eb..ce4a4bc 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -97,6 +97,10 @@ App.WizardStep7Controller = Em.Controller.extend({ this.set('stepConfigs', serviceConfigs); this.activateSpecialConfigs(); this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0)); + + if (this.get('content.skipConfigStep')) { + App.router.send('next'); + } }, /** http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd0517af/ambari-web/app/routes/add_service_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js index 95242b9..df71498 100644 --- a/ambari-web/app/routes/add_service_routes.js +++ b/ambari-web/app/routes/add_service_routes.js @@ -217,7 +217,25 @@ module.exports = Em.Route.extend({ controller.connectOutlet('wizardStep8', controller.get('content')); }) }, - back: Em.Router.transitionTo('step4'), + back: function(router){ + var controller = router.get('addServiceController'); + if(!controller.get('content.skipConfigStep')) { + router.transitionTo('step4'); + } + else { + if(!controller.get('content.skipSlavesStep')) { + router.transitionTo('step3'); + } + else { + if(!controller.get('content.skipMasterStep')) { + router.transitionTo('step2'); + } + else { + router.transitionTo('step1'); + } + } + } + }, next: function (router) { var addServiceController = router.get('addServiceController'); var wizardStep8Controller = router.get('wizardStep8Controller'); http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/cd0517af/ambari-web/test/controllers/main/service/add_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js new file mode 100644 index 0000000..2a2caaa --- /dev/null +++ b/ambari-web/test/controllers/main/service/add_controller_test.js @@ -0,0 +1,122 @@ +/** + * 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('controllers/wizard'); +require('controllers/main/service/add_controller'); + +describe('App.AddServiceController', function() { + + describe('#isServiceConfigurable', function() { + var tests = [ + { + services: [ + {serviceName: 'HDFS'}, + {serviceName: 'MAPREDUCE'}, + {serviceName: 'NAGIOS'} + ], + service: 'HDFS', + m: 'Service is configurable', + e: true + }, + { + services: [ + {serviceName: 'HDFS'}, + {serviceName: 'MAPREDUCE'}, + {serviceName: 'NAGIOS'} + ], + service: 'PIG', + m: 'Service is not configurable', + e: false + }, + { + services: [], + service: 'HDFS', + m: 'No services', + e: false + } + ]; + tests.forEach(function(test) { + var controller = App.AddServiceController.create({serviceConfigs: test.services}); + it('', function() { + expect(controller.isServiceConfigurable(test.service)).to.equal(test.e); + }); + }); + }); + + describe('#skipConfigStep', function() { + var tests = [ + { + content: { + services:[ + {serviceName: 'HDFS', isInstalled: true, isSelected: true}, + {serviceName: 'PIG', isInstalled: false, isSelected: true}, + {serviceName: 'MAPREDUCE', isInstalled: true, isSelected: true} + ] + }, + serviceConfigs: [ + {serviceName: 'HDFS'}, + {serviceName: 'MAPREDUCE'}, + {serviceName: 'NAGIOS'} + ], + m: '2 installed services and 1 new that can\'t be configured', + e: true + }, + { + content: { + services:[ + {serviceName: 'HDFS', isInstalled: true, isSelected: true}, + {serviceName: 'NAGIOS', isInstalled: false, isSelected: true}, + {serviceName: 'MAPREDUCE', isInstalled: true, isSelected: true} + ] + }, + serviceConfigs: [ + {serviceName: 'HDFS'}, + {serviceName: 'MAPREDUCE'}, + {serviceName: 'NAGIOS'} + ], + m: '2 installed services and 1 new that can be configured', + e: false + }, + { + content: { + services:[ + {serviceName: 'HDFS', isInstalled: true, isSelected: true}, + {serviceName: 'PIG', isInstalled: false, isSelected: true}, + {serviceName: 'SQOOP', isInstalled: false, isSelected: true}, + {serviceName: 'MAPREDUCE', isInstalled: true, isSelected: true} + ] + }, + serviceConfigs: [ + {serviceName: 'HDFS'}, + {serviceName: 'MAPREDUCE'}, + {serviceName: 'NAGIOS'} + ], + m: '2 installed services and 2 new that can\'t be configured', + e: true + } + ]; + tests.forEach(function(test) { + var controller = App.AddServiceController.create({content:{services: test.content.services}, serviceConfigs: test.serviceConfigs}); + it(test.m, function() { + expect(controller.skipConfigStep()).to.equal(test.e); + }) + }); + }); + +});
