This is an automated email from the ASF dual-hosted git repository. akovalenko pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push: new 903a3de AMBARI-23003. NN Federation Wizard: implement step1 (akovalenko) 903a3de is described below commit 903a3dee897a6c9f121429a0db9c0db79b0f0ee5 Author: Aleksandr Kovalenko <akovale...@apache.org> AuthorDate: Thu Feb 15 17:14:55 2018 +0200 AMBARI-23003. NN Federation Wizard: implement step1 (akovalenko) --- .../main/admin/federation/step1_controller.js | 13 ++++++++- .../main/admin/federation/wizard_controller.js | 10 +++++++ .../highAvailability/nameNode/step1_controller.js | 3 ++- ambari-web/app/messages.js | 4 +++ .../app/routes/namenode_federation_routes.js | 2 ++ .../app/templates/main/admin/federation/step1.hbs | 31 +++++++++++++++++++++- ambari-web/app/utils/validator.js | 7 ++++- .../app/views/main/admin/federation/step1_view.js | 9 ++++++- ambari-web/test/utils/validator_test.js | 24 +++++++++++++++++ 9 files changed, 98 insertions(+), 5 deletions(-) diff --git a/ambari-web/app/controllers/main/admin/federation/step1_controller.js b/ambari-web/app/controllers/main/admin/federation/step1_controller.js index af39d3c..eb3655e 100644 --- a/ambari-web/app/controllers/main/admin/federation/step1_controller.js +++ b/ambari-web/app/controllers/main/admin/federation/step1_controller.js @@ -17,8 +17,19 @@ */ var App = require('app'); +var validator = require('utils/validator'); App.NameNodeFederationWizardStep1Controller = Em.Controller.extend({ - name: "nameNodeFederationWizardStep1Controller" + name: "nameNodeFederationWizardStep1Controller", + + isNameServiceIdValid: function () { + return validator.isValidNameServiceId(this.get('content.nameServiceId')); + }.property('content.nameServiceId'), + + next: function () { + if (this.get('isNameServiceIdValid')) { + App.router.send('next'); + } + } }); diff --git a/ambari-web/app/controllers/main/admin/federation/wizard_controller.js b/ambari-web/app/controllers/main/admin/federation/wizard_controller.js index 9e8347f..da14f0a 100644 --- a/ambari-web/app/controllers/main/admin/federation/wizard_controller.js +++ b/ambari-web/app/controllers/main/admin/federation/wizard_controller.js @@ -95,6 +95,16 @@ App.NameNodeFederationWizardController = App.WizardController.extend({ }); }, + saveNameServiceId: function (nameServiceId) { + this.setDBProperty('nameServiceId', nameServiceId); + this.set('content.nameServiceId', nameServiceId); + }, + + loadNameServiceId: function () { + var nameServiceId = this.getDBProperty('nameServiceId'); + this.set('content.nameServiceId', nameServiceId); + }, + /** * Save hosts for users selected hosts to local db and <code>controller.content</code> * @param selectedHosts diff --git a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step1_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step1_controller.js index 9bc7cdd..7811e57 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step1_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step1_controller.js @@ -17,6 +17,7 @@ */ var App = require('app'); +var validator = require('utils/validator'); require('controllers/main/admin/serviceAccounts_controller'); @@ -26,7 +27,7 @@ App.HighAvailabilityWizardStep1Controller = Em.Controller.extend({ isHawqInstalled: false, isNameServiceIdValid: function () { - return /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])$/.test(this.get('content.nameServiceId')); + return validator.isValidNameServiceId(this.get('content.nameServiceId')); }.property('content.nameServiceId'), setHawqInstalled: function() { diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 36185a1..ea1158f 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1651,6 +1651,10 @@ Em.I18n.translations = { 'admin.nameNodeFederation.button.enable':'Add New HDFS Namespace', 'admin.nameNodeFederation.wizard.header': 'Add New HDFS Namespace', 'admin.nameNodeFederation.wizard.step1.header': 'Get Started', + 'admin.nameNodeFederation.wizard.step1.body':'This wizard will walk you through the process of setting up a new Highly Available NameNode pair that will be used to create a new HDFS namespace, allowing you to use Ambari to manage multiple HDFS namespaces and take advantage of HDFS Federation.', + 'admin.nameNodeFederation.wizard.step1.alert':'If you have HBase running, please exit this wizard and stop HBase first.', + 'admin.nameNodeFederation.wizard.step1.nameserviceid':'New Nameservice ID', + 'admin.nameNodeFederation.wizard.step1.nameserviceid.error':'Must consist of letters, numbers, and hyphens. Cannot begin or end with a hyphen.', 'admin.nameNodeFederation.wizard.step2.header': 'Select Hosts', 'admin.nameNodeFederation.wizard.step3.header': 'Review', 'admin.nameNodeFederation.wizard.step4.header': 'Configure Components', diff --git a/ambari-web/app/routes/namenode_federation_routes.js b/ambari-web/app/routes/namenode_federation_routes.js index 2535e4a..21b31b2 100644 --- a/ambari-web/app/routes/namenode_federation_routes.js +++ b/ambari-web/app/routes/namenode_federation_routes.js @@ -91,6 +91,8 @@ module.exports = App.WizardRoute.extend({ return false; }, next: function (router) { + var controller = router.get('nameNodeFederationWizardController'); + controller.saveNameServiceId(router.get('nameNodeFederationWizardStep1Controller.content.nameServiceId')); router.transitionTo('step2'); } }), diff --git a/ambari-web/app/templates/main/admin/federation/step1.hbs b/ambari-web/app/templates/main/admin/federation/step1.hbs index 840d461..568f150 100644 --- a/ambari-web/app/templates/main/admin/federation/step1.hbs +++ b/ambari-web/app/templates/main/admin/federation/step1.hbs @@ -15,8 +15,37 @@ * See the License for the specific language governing permissions and * limitations under the License. }} +<div class="wizard-content col-md-9"> + <h4 class="step-title">{{t admin.nameNodeFederation.wizard.step1.header}}</h4> + <div class="step-description"> + <p>{{t admin.nameNodeFederation.wizard.step1.body}}</p> + <div class="alert alert-warning"> + {{t admin.nameNodeFederation.wizard.step1.alert}} + </div> + </div> + <div class="panel panel-default"> + <div class="panel-body"> + <div {{bindAttr class=":form-group view.showInputError:has-error :form-horizontal"}}> + <div class="row"> + <div class="col-md-2"> + <label class="control-label">{{t admin.nameNodeFederation.wizard.step1.nameserviceid}}:</label> + </div> + <div class="col-md-3"> + {{view Ember.TextField valueBinding="content.nameServiceId" classNames="form-control"}} + </div> + <div class="col-md-7"> + <span {{bindAttr class=":help-block :validation-block view.showInputError::hidden"}}> + {{t admin.nameNodeFederation.wizard.step1.nameserviceid.error}} + </span> + </div> + </div> + </div> + </div> + </div> +</div> <div class="wizard-footer col-md-12"> <div class="btn-area"> - <button class="btn btn-success pull-right" {{action next}}>{{t common.next}} →</button> + <a {{bindAttr class=":btn controller.isNameServiceIdValid::disabled :btn-success :pull-right"}} {{action next target="controller"}}>{{t common.next}} →</a> </div> </div> + diff --git a/ambari-web/app/utils/validator.js b/ambari-web/app/utils/validator.js index 4c7255d..a0c64e7 100644 --- a/ambari-web/app/utils/validator.js +++ b/ambari-web/app/utils/validator.js @@ -343,6 +343,11 @@ module.exports = { isValidLdapsURL: function(value) { var ldapsUrlRegex = /^(ldaps):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900 [...] return ldapsUrlRegex.test(value); - } + }, + + isValidNameServiceId: function (value) { + var nameSarviceIdRegex = /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])$/; + return nameSarviceIdRegex.test(value); + }, }; diff --git a/ambari-web/app/views/main/admin/federation/step1_view.js b/ambari-web/app/views/main/admin/federation/step1_view.js index c44e43c..a988f78 100644 --- a/ambari-web/app/views/main/admin/federation/step1_view.js +++ b/ambari-web/app/views/main/admin/federation/step1_view.js @@ -20,6 +20,13 @@ var App = require('app'); App.NameNodeFederationWizardStep1View = Em.View.extend({ - templateName: require('templates/main/admin/federation/step1') + templateName: require('templates/main/admin/federation/step1'), + + didInsertElement: function() { + //todo: provide tooltip with correct message + // App.popover($("input[type=text]"), {'placement': 'right', 'trigger': 'hover', 'title': this.t('admin.highAvailability.wizard.step1.nameserviceid.tooltip.title'), 'content': this.t('admin.highAvailability.wizard.step1.nameserviceid.tooltip.content')}); + }, + + showInputError: Em.computed.and('!controller.isNameServiceIdValid', 'controller.content.nameServiceId.length') }); diff --git a/ambari-web/test/utils/validator_test.js b/ambari-web/test/utils/validator_test.js index aada441..4351222 100644 --- a/ambari-web/test/utils/validator_test.js +++ b/ambari-web/test/utils/validator_test.js @@ -544,4 +544,28 @@ describe('validator', function () { }); + describe('#isValidAlertName', function () { + + [ + {v: '', e: false}, + {v: 'test', e: true}, + {v: 'Test', e: true}, + {v: 'TEST', e: true}, + {v: 'te-st', e: true}, + {v: '-test', e: false}, + {v: 'test-', e: false}, + {v: '1', e: true}, + {v: 'test1', e: true}, + {v: '1-test', e: true} + ].forEach(function (test) { + + it(test.m || test.v, function () { + expect(validator.isValidNameServiceId(test.v)).to.be.equal(test.e); + }) + + }); + + + }); + }); -- To stop receiving notification emails like this one, please contact akovale...@apache.org.