Repository: ambari Updated Branches: refs/heads/branch-2.5 e1a354b7d -> c21009a6b
AMBARI-20141. Workflow Manager-mapred action contains duplicates in editor if user saves and reopens editor. (Padma Priya N via gauravn7) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c21009a6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c21009a6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c21009a6 Branch: refs/heads/branch-2.5 Commit: c21009a6b5daa1bfbea0812f02c340df468d9e44 Parents: e1a354b Author: Gaurav Nagar <grv...@gmail.com> Authored: Fri Feb 24 16:51:59 2017 +0530 Committer: Gaurav Nagar <grv...@gmail.com> Committed: Fri Feb 24 16:51:59 2017 +0530 ---------------------------------------------------------------------- .../resources/ui/app/components/hive-action.js | 26 ++++---- .../resources/ui/app/components/hive2-action.js | 26 ++++---- .../resources/ui/app/components/java-action.js | 24 ++++--- .../resources/ui/app/components/sqoop-action.js | 66 ++++++++++++++++---- .../resources/ui/app/components/ssh-action.js | 14 ++++- .../ui/app/templates/components/hive-action.hbs | 23 +++---- .../app/templates/components/hive2-action.hbs | 41 ++++++------ .../ui/app/templates/components/java-action.hbs | 19 +++--- .../app/templates/components/sqoop-action.hbs | 40 +++++++++--- .../ui/app/templates/components/ssh-action.hbs | 7 ++- .../resources/ui/app/validators/arg-length.js | 46 ++++++++++++++ 11 files changed, 237 insertions(+), 95 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/components/hive-action.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/hive-action.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/hive-action.js index ac85a9a..3c9ee63 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/components/hive-action.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/hive-action.js @@ -35,13 +35,6 @@ const Validations = buildValidations({ }) }); export default Ember.Component.extend(Validations, { - hiveOptionObserver : Ember.observer('isScript',function(){ - if(this.get('isScript')){ - this.set("actionModel.query", undefined); - }else{ - this.set("actionModel.script", undefined); - } - }), setUp : function(){ if(this.get('actionModel.script')){ this.set('isScript', true); @@ -78,12 +71,20 @@ export default Ember.Component.extend(Validations, { this.on('fileSelected',function(fileName){ this.set(this.get('filePathModel'), fileName); }.bind(this)); + this.send('setIsScript', this.get('isScript')); }.on('didInsertElement'), observeError :function(){ if(this.$('#collapseOne label.text-danger').length > 0 && !this.$('#collapseOne').hasClass("in")){ this.$('#collapseOne').collapse('show'); } }.on('didUpdate'), + onDestroy : function(){ + if(this.get('isScript')){ + this.set('actionModel.query', undefined); + }else{ + this.set("actionModel.script", undefined); + } + }.on('willDestroyElement'), actions : { openFileBrowser(model, context){ if(undefined === context){ @@ -95,11 +96,14 @@ export default Ember.Component.extend(Validations, { register (name, context){ this.sendAction('register',name , context); }, - onHiveOptionChange(value){ - if(value === "script"){ - this.set('isScript', true); + setIsScript(value){ + this.set('isScript', value); + if(value){ + this.$('#query-option').hide(); + this.$('#script-option').show(); }else{ - this.set('isScript', false); + this.$('#script-option').hide(); + this.$('#query-option').show(); } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/components/hive2-action.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/hive2-action.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/hive2-action.js index f23cca7..b4c6409 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/components/hive2-action.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/hive2-action.js @@ -40,13 +40,6 @@ const Validations = buildValidations({ }); export default Ember.Component.extend(Validations,{ - hiveOptionObserver : Ember.observer('isScript',function(){ - if(this.get('isScript')){ - this.set("actionModel.query", undefined); - }else{ - this.set("actionModel.script", undefined); - } - }), setUp : function(){ if(this.get('actionModel.script')){ this.set('isScript', true); @@ -83,12 +76,20 @@ export default Ember.Component.extend(Validations,{ this.on('fileSelected',function(fileName){ this.set(this.get('filePathModel'), fileName); }.bind(this)); + this.send('setIsScript', this.get('isScript')); }.on('didInsertElement'), observeError :function(){ if(this.$('#collapseOne label.text-danger').length > 0 && !this.$('#collapseOne').hasClass("in")){ this.$('#collapseOne').collapse('show'); } }.on('didUpdate'), + onDestroy : function(){ + if(this.get('isScript')){ + this.set('actionModel.query', undefined); + }else{ + this.set("actionModel.script", undefined); + } + }.on('willDestroyElement'), actions : { openFileBrowser(model, context){ if(undefined === context){ @@ -100,11 +101,14 @@ export default Ember.Component.extend(Validations,{ register (name, context){ this.sendAction('register',name , context); }, - onHiveOptionChange(value){ - if(value === "script"){ - this.set('isScript',true); + setIsScript(value){ + this.set('isScript', value); + if(value){ + this.$('#query-option').hide(); + this.$('#script-option').show(); }else{ - this.set('isScript',false); + this.$('#script-option').hide(); + this.$('#query-option').show(); } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/components/java-action.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/java-action.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/java-action.js index 18a3702..c0a311f 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/components/java-action.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/java-action.js @@ -21,9 +21,6 @@ import { validator, buildValidations } from 'ember-cp-validations'; const Validations = buildValidations({ 'actionModel.mainClass': validator('presence', { presence : true - }), - 'actionModel.jobTracker': validator('presence', { - presence : true }) }); @@ -65,12 +62,20 @@ export default Ember.Component.extend(Validations, { this.set(this.get('filePathModel'), fileName); }.bind(this)); this.sendAction('register','javaAction', this); + this.send('setIsSingle', this.get('isSingle')); }.on('didInsertElement'), observeError :function(){ if(this.$('#collapseOne label.text-danger').length > 0 && !this.$('#collapseOne').hasClass("in")){ this.$('#collapseOne').collapse('show'); } }.on('didUpdate'), + onDestroy : function(){ + if(this.get('isSingle')){ + this.set('actionModel.javaOpt', Ember.A([])); + }else{ + this.set("actionModel.javaOpts", undefined); + } + }.on('willDestroyElement'), actions : { openFileBrowser(model, context){ if(undefined === context){ @@ -82,13 +87,14 @@ export default Ember.Component.extend(Validations, { register (name, context){ this.sendAction('register',name , context); }, - onJavaOptChange(value){ - if(value === "single"){ - this.set('isSingle',true); - this.set("actionModel.javaOpt", Ember.A([])); + setIsSingle(value){ + this.set('isSingle', value); + if(this.get('isSingle')){ + this.$('#single-option').show(); + this.$('#arg-option').hide(); }else{ - this.set('isSingle',false); - this.set("actionModel.javaOpts", undefined); + this.$('#single-option').hide(); + this.$('#arg-option').show(); } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/components/sqoop-action.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/sqoop-action.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/sqoop-action.js index 2756700..67ba85a 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/components/sqoop-action.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/sqoop-action.js @@ -16,15 +16,30 @@ */ import Ember from 'ember'; - -export default Ember.Component.extend({ - sqoopSendType : Ember.observer('isArg',function(){ - if(this.get('isArg')){ - this.set("actionModel.command", undefined); - }else{ - this.set("actionModel.arg", Ember.A([])); - } +import { validator, buildValidations } from 'ember-cp-validations'; +const Validations = buildValidations({ + 'actionModel.command': validator('presence', { + presence : true, + disabled(model, attribute) { + return model.get('isArg'); + }, + dependentKeys : ['isArg'] }), + 'actionModel.arg': { + validators: [ + validator('arg-length', { + min : 1, + dependentKeys: ['isArg','actionModel.arg.@each.value'], + message : 'At least one arg should be non-empty', + disabled(model, attribute) { + return !model.get('isArg'); + } + }) + ] + } +}); + +export default Ember.Component.extend(Validations, { initialize : function(){ this.sendAction('register','sqoopAction', this); this.on('fileSelected',function(fileName){ @@ -60,6 +75,19 @@ export default Ember.Component.extend({ this.$('#collapseOne').collapse('show'); } }.on('didUpdate'), + elementsInserted : function(){ + this.send('setIsArg', this.get('isArg')); + }.on('didInsertElement'), + onDestroy : function(){ + if(this.get('isArg')){ + this.set('actionModel.command', undefined); + if(Ember.isBlank(this.get('actionModel.arg').get('lastObject').value)){ + this.get('actionModel.arg').removeAt(this.get('actionModel.arg').length - 1); + } + }else{ + this.set("actionModel.arg", Ember.A([])); + } + }.on('willDestroyElement'), actions : { openFileBrowser(model, context){ if(undefined === context){ @@ -69,14 +97,28 @@ export default Ember.Component.extend({ this.sendAction('openFileBrowser', model, context); }, register (name, context){ + this.get('childComponents').set(name, context); this.sendAction('register',name , context); }, - onSendTypeChange(value){ - if(value === "arg"){ - this.set('isArg',true); + setIsArg(value){ + this.set('isArg', value); + if(value){ + this.$('#command-option').hide(); + this.$('#arg-option').show(); + if(!this.get("actionModel.arg") || this.get('actionModel.arg').length === 0){ + this.set("actionModel.arg", Ember.A([])); + this.get("actionModel.arg").pushObject({value : ""}) + } }else{ - this.set('isArg',false); + this.$('#arg-option').hide(); + this.$('#command-option').show(); } + }, + addArg () { + this.get("actionModel.arg").pushObject({value : ""}) + }, + deleteArg (index) { + this.get('actionModel.arg').removeAt(index); } } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/components/ssh-action.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/components/ssh-action.js b/contrib/views/wfmanager/src/main/resources/ui/app/components/ssh-action.js index 8da7eef..b987542 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/components/ssh-action.js +++ b/contrib/views/wfmanager/src/main/resources/ui/app/components/ssh-action.js @@ -46,12 +46,20 @@ export default Ember.Component.extend(Validations, { this.set(this.get('filePathModel'), fileName); }.bind(this)); this.sendAction('register','sshAction', this); + this.send('argTypeChanged', this.get('useArg')); }.on('didInsertElement'), observeError :function(){ if(this.$('#collapseOne label.text-danger').length > 0 && !this.$('#collapseOne').hasClass("in")){ this.$('#collapseOne').collapse('show'); } }.on('didUpdate'), + onDestroy : function(){ + if(this.get('useArg')){ + this.set("actionModel.args", Ember.A([])); + }else{ + this.set("actionModel.arg", Ember.A([])); + } + }.on('willDestroyElement'), actions : { openFileBrowser(model, context){ if(undefined === context){ @@ -66,9 +74,11 @@ export default Ember.Component.extend(Validations, { argTypeChanged(useArg){ this.set('useArg', useArg); if(useArg){ - this.set("actionModel.args", Ember.A([])); + this.$('#args-option').hide(); + this.$('#arg-option').show(); }else{ - this.set("actionModel.arg", Ember.A([])); + this.$('#arg-option').hide(); + this.$('#args-option').show(); } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive-action.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive-action.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive-action.hbs index 3d59e23..1efb527 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive-action.hbs +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive-action.hbs @@ -20,13 +20,13 @@ <div class="form-group padding10"> <label class="control-label col-xs-2">Hive Option</label> <div class="col-xs-2"> - <input type="radio" name="hiveOption" checked={{if (eq isScript true) 'checked'}} {{action "onHiveOptionChange" "script" preventDefault=false on="change"}}> Script + <input type="radio" name="hiveOption" checked={{if (eq isScript true) 'checked'}} {{action "setIsScript" true preventDefault=false on="change"}}> Script </div> <div class="col-xs-2"> - <input type="radio" name="hiveOption" checked={{if (eq isScript false) 'checked'}} {{action "onHiveOptionChange" "query" preventDefault=false on="change"}}> Query + <input type="radio" name="hiveOption" checked={{if (eq isScript false) 'checked'}} {{action "setIsScript" false preventDefault=false on="change"}}> Query </div> </div> - {{#if isScript}} + <div id="script-option"> <div class="form-group padding10"> <label class="control-label col-xs-2">Script<span class="requiredField"> *</span></label> <div class="col-xs-7"> @@ -39,17 +39,18 @@ {{field-error model=this field='actionModel.script' showErrorMessage=showErrorMessage}} </div> </div> - {{else}} - <div class="form-group padding10"> - <label class="control-label col-xs-2">Query<span class="requiredField"> *</span></label> - <div class="col-xs-7"> - <div class="input-group"> - {{textarea class="form-control" name="query" class="query-text-area" value=actionModel.query placeholder="hive query"}} + </div> + <div id="query-option"> + <div class="form-group padding10"> + <label class="control-label col-xs-2">Query<span class="requiredField"> *</span></label> + <div class="col-xs-7"> + <div class="input-group"> + {{textarea class="form-control" name="query" class="query-text-area" value=actionModel.query placeholder="hive query"}} + </div> + {{field-error model=this field='actionModel.query' showErrorMessage=showErrorMessage}} </div> - {{field-error model=this field='actionModel.query' showErrorMessage=showErrorMessage}} </div> </div> - {{/if}} {{#jobxml-config jobXml=actionModel.jobXml openFileBrowser="openFileBrowser" register="register"}}{{/jobxml-config}} {{#arg-config args=actionModel.params register="register" title="Param"}}{{/arg-config}} </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive2-action.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive2-action.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive2-action.hbs index 8adf64c..299dded 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive2-action.hbs +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/hive2-action.hbs @@ -21,36 +21,37 @@ <div class="form-group padding10"> <label class="control-label col-xs-2">Hive Option</label> <div class="col-xs-2"> - <input type="radio" name="hiveOption" checked={{if (eq isScript true) 'checked'}} {{action "onHiveOptionChange" "script" preventDefault=false on="change"}}> Script + <input type="radio" name="hiveOption" checked={{if (eq isScript true) 'checked'}} {{action "setIsScript" true preventDefault=false on="change"}}> Script </div> <div class="col-xs-2"> - <input type="radio" name="hiveOption" checked={{if (eq isScript false) 'checked'}} {{action "onHiveOptionChange" "query" preventDefault=false on="change"}}> Query + <input type="radio" name="hiveOption" checked={{if (eq isScript false) 'checked'}} {{action "setIsScript" false preventDefault=false on="change"}}> Query </div> </div> - {{#if isScript}} - <div class="form-group padding10"> - <label class="control-label col-xs-2">Script<span class="requiredField"> *</span></label> - <div class="col-xs-7"> - <div class="input-group"> - {{input type="text" class="form-control" name="script" value=actionModel.script placeholder="hive.hql"}} - <span class="input-group-btn"> - <button class="btn btn-secondary" type="button" {{action "openFileBrowser" "actionModel.script"}}>Browse</button> - </span> + <div id="script-option"> + <div class="form-group padding10"> + <label class="control-label col-xs-2">Script<span class="requiredField"> *</span></label> + <div class="col-xs-7"> + <div class="input-group"> + {{input type="text" class="form-control" name="script" value=actionModel.script placeholder="hive.hql"}} + <span class="input-group-btn"> + <button class="btn btn-secondary" type="button" {{action "openFileBrowser" "actionModel.script"}}>Browse</button> + </span> + </div> + {{field-error model=this field='actionModel.script' showErrorMessage=showErrorMessage}} </div> - {{field-error model=this field='actionModel.script' showErrorMessage=showErrorMessage}} </div> </div> - {{else}} - <div class="form-group padding10"> - <label class="control-label col-xs-2">Query<span class="requiredField"> *</span></label> - <div class="col-xs-7"> - <div class="input-group"> - {{textarea class="form-control" name="query" class="query-text-area" value=actionModel.query placeholder="hive query"}} + <div id="query-option"> + <div class="form-group padding10"> + <label class="control-label col-xs-2">Query<span class="requiredField"> *</span></label> + <div class="col-xs-7"> + <div class="input-group"> + {{textarea class="form-control" name="query" class="query-text-area" value=actionModel.query placeholder="hive query"}} + </div> + {{field-error model=this field='actionModel.query' showErrorMessage=showErrorMessage}} </div> - {{field-error model=this field='actionModel.query' showErrorMessage=showErrorMessage}} </div> </div> - {{/if}} <div class="form-group"> <label class="control-label col-xs-2">jdbc-url<span class="requiredField"> *</span></label> <div class="col-xs-7"> http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/java-action.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/java-action.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/java-action.hbs index 3de5677..40272dd 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/java-action.hbs +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/java-action.hbs @@ -29,22 +29,23 @@ <div class="form-group"> <label class="control-label col-xs-2">Java Options</label> <div class="col-xs-3"> - <input type="radio" name="javaOpt" checked={{if (eq isSingle false) 'checked'}} {{action "onJavaOptChange" "multiple" preventDefault=false on="change"}}> Java Option List + <input type="radio" name="javaOpt" checked={{if (eq isSingle false) 'checked'}} {{action "setIsSingle" false preventDefault=false on="change"}}> Java Option List </div> <div class="col-xs-3"> - <input type="radio" name="javaOpt" checked={{if (eq isSingle true) 'checked'}} {{action "onJavaOptChange" "single" preventDefault=false on="change"}}> Java Options + <input type="radio" name="javaOpt" checked={{if (eq isSingle true) 'checked'}} {{action "setIsSingle" true preventDefault=false on="change"}}> Java Options </div> </div> - {{#if isSingle}} - <div class="form-group"> - <label for="inputPassword" class="control-label col-xs-2 visibility-hidden">Java opts</label> - <div class="col-xs-7"> - {{input type="text" class="form-control" value=actionModel.javaOpts name="java-opts" placeholder="Java opts"}} + <div id="single-option"> + <div class="form-group"> + <label for="inputPassword" class="control-label col-xs-2 visibility-hidden">Java opts</label> + <div class="col-xs-7"> + {{input type="text" class="form-control" value=actionModel.javaOpts name="java-opts" placeholder="Java opts"}} + </div> </div> </div> - {{else}} + <div id="arg-option"> {{#arg-config args=actionModel.javaOpt register="register" title="Java Opt" hideLabel="false"}}{{/arg-config}} - {{/if}} + </div> {{#jobxml-config jobXml=actionModel.jobXml openFileBrowser="openFileBrowser" register="register"}}{{/jobxml-config}} <div class="form-group"> <label for="inputPassword" class="control-label col-xs-2">Capture output</label> http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sqoop-action.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sqoop-action.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sqoop-action.hbs index db69864..610d1e1 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sqoop-action.hbs +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/sqoop-action.hbs @@ -20,22 +20,48 @@ <div class="form-group padding10"> <label class="control-label col-xs-2">Send As</label> <div class="col-xs-2"> - <input type="radio" name="sendType" checked={{if (eq isArg false) 'checked'}} {{action "onSendTypeChange" "command" preventDefault=false on="change"}}> Command + <input type="radio" name="sendType" checked={{if (eq isArg false) 'checked'}} {{action "setIsArg" false preventDefault=false on="change"}}> Command </div> <div class="col-xs-2"> - <input type="radio" name="sendType" checked={{if (eq isArg true) 'checked'}} {{action "onSendTypeChange" "arg" preventDefault=false on="change"}}> Args + <input type="radio" name="sendType" checked={{if (eq isArg true) 'checked'}} {{action "setIsArg" true preventDefault=false on="change"}}> Args </div> </div> - {{#if isArg}} - {{#arg-config args=actionModel.arg register="register" title="arg"}}{{/arg-config}} - {{else}} + <div id="arg-option"> + {{#each actionModel.arg as |arg index|}} + <div class="form-group"> + <label class="control-label col-xs-2 {{if (or (not-eq index 0) hideLabel) 'visibility-hidden'}}">Arg<span class="requiredField"> *</span></label> + <div class=" col-xs-7"> + {{input type="text" class="form-control" value=arg.value placeholder=title}} + </div> + {{#if (eq arg actionModel.arg.lastObject)}} + <div class="col-xs-1"> + <input class="form-control btn btn-secondary" type="button" value="+" {{action "addArg"}}> + </div> + {{else}} + <div class="col-xs-1"> + <input class="form-control btn btn-danger" type="button" {{action "deleteArg" index}} value="-"> + </div> + {{/if}} + </div> + {{/each}} + {{#if validations.attrs.actionModel.arg.isInvalid}} + <div class="form-group"> + <label class="control-label col-xs-2"></label> + <div class=" col-xs-7"> + {{field-error model=this field='actionModel.arg' showErrorMessage=showErrorMessage}} + </div> + </div> + {{/if}} + </div> + <div id="command-option"> <div class="form-group padding10"> - <label for="inputEmail" class="control-label col-xs-2">Command</label> + <label for="inputEmail" class="control-label col-xs-2">Command<span class="requiredField"> *</span></label> <div class="col-xs-7"> {{input type="text" class="form-control" name="command" value=actionModel.command placeholder="Command" title="eg. import --connect jdbc:hsqldb:file:db.hsqldb --table TT --target-dir /user/${wf:user()}/output-data/sqoop -m 1"}} + {{field-error model=this field='actionModel.command' showErrorMessage=showErrorMessage}} </div> </div> - {{/if}} + </div> {{#jobxml-config jobXml=actionModel.jobXml openFileBrowser="openFileBrowser" register="register"}}{{/jobxml-config}} </div> <div class="panel panel-default"> http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/ssh-action.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/ssh-action.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/ssh-action.hbs index a29a2ec..f889d08 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/ssh-action.hbs +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/ssh-action.hbs @@ -42,11 +42,12 @@ <input type="radio" name="arg" checked={{if (eq useArg true) 'checked'}} {{action "argTypeChanged" true on="change"}}> Arg </div> </div> - {{#if useArg}} + <div id="arg-option"> {{#arg-config args=actionModel.arg register="register" title="Arg"}}{{/arg-config}} - {{else}} + </div> + <div id="args-option"> {{#arg-config args=actionModel.args register="register" title="Args"}}{{/arg-config}} - {{/if}} + </div> <div class="form-group"> <label class="control-label col-xs-2">Capture output</label> <div class="col-xs-8"> http://git-wip-us.apache.org/repos/asf/ambari/blob/c21009a6/contrib/views/wfmanager/src/main/resources/ui/app/validators/arg-length.js ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/validators/arg-length.js b/contrib/views/wfmanager/src/main/resources/ui/app/validators/arg-length.js new file mode 100644 index 0000000..14bd5e3 --- /dev/null +++ b/contrib/views/wfmanager/src/main/resources/ui/app/validators/arg-length.js @@ -0,0 +1,46 @@ +/* +* 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. +*/ + +import BaseValidator from 'ember-cp-validations/validators/base'; + +const OperandLength = BaseValidator.extend({ + validate(value, options, model, attribute) { + if (options.min && value && value.length >= options.min && !Ember.isBlank(value.get('firstObject').value)) { + return true; + }else{ + if(options.message){ + return options.message; + } + return "At least one arg should be non-empty"; + } + } +}); + +OperandLength.reopenClass({ + /** + * Define attribute specific dependent keys for your validator + * + * @param {String} attribute The attribute being evaluated + * @param {Unknown} options Options passed into your validator + * @return {Array} + */ + getDependentsFor(/* attribute, options */) { + return []; + } +}); + +export default OperandLength;