mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Adding Password option for survey's
I'm adding the UI side of the password option for surveys, which should show up in the job summary as a masked string.
This commit is contained in:
parent
f4dc7a1373
commit
f46a34e079
@ -142,6 +142,27 @@ export default
|
||||
editRequired: true,
|
||||
column: 2
|
||||
},
|
||||
password_options: {
|
||||
realName: 'answer_options',
|
||||
type: 'custom',
|
||||
control:'<div class="row">'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="password_min"><span class="label-text">Minimum Length</span></label><input id="password_min" type="number" name="password_min" ng-model="password_min" min=0 aw-min="0" aw-max="password_max" class="form-control" integer />'+
|
||||
'<div class="error" ng-show="survey_question_form.password_min.$error.number">The minimum length you entered is not a number. Please enter a number.</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.password_min.$error.awMax">The minimium length is too high. Please enter a lower number.</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.password_min.$error.awMin">The minimum length is too low. Please enter a positive number.</div>'+
|
||||
'</div>'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="password_max"><span class="label-text">Maximum Length</span></label><input id="password_max" type="number" name="password_max" ng-model="password_max" aw-min="password_min || 0" min=0 class="form-control" integer >'+
|
||||
'<div class="error" ng-show="survey_question_form.password_max.$error.number">The maximum length you entered is not a number. Please enter a number.</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.password_max.$error.awMin">The maximum length is too low. Please enter a number larger than the minimum length you set.</div>'+
|
||||
'</div>'+
|
||||
'</div>',
|
||||
ngShow: 'type.type==="password" ',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
column: 2
|
||||
},
|
||||
int_options: {
|
||||
realName: 'answer_options',
|
||||
type: 'custom',
|
||||
@ -189,7 +210,7 @@ export default
|
||||
control: '<div class="form-group" >'+
|
||||
'<label for="default"><span class="label-text">Default Answer</span></label>'+
|
||||
'<div>'+
|
||||
'<input type="text" ng-model="default" name="default" id="default" class="form-control ng-valid ng-dirty">'+
|
||||
'<input type="text" ng-model="default" name="default" id="default" class="form-control">'+
|
||||
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="invalidChoice">Please enter an answer for the choices listed.</div>' +
|
||||
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="minTextError">The answer is shorter than the minimium length. Please make the answer longer. </div>' +
|
||||
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="maxTextError">The answer is longer than the maximum length. Please make the answer shorter. </div>' +
|
||||
@ -197,7 +218,7 @@ export default
|
||||
'</div>'+
|
||||
'</div>',
|
||||
column: 2,
|
||||
ngHide: 'type.type === "textarea" || type.type === "multiselect" || type.type === "integer" || type.type === "float" '
|
||||
ngShow: 'type.type === "text" || type.type === "multiplechoice" '
|
||||
},
|
||||
default_multiselect: {
|
||||
realName: 'default_answer' ,
|
||||
@ -243,7 +264,7 @@ export default
|
||||
control: '<div class="form-group">'+
|
||||
'<label for="default_textarea"><span class="label-text">Default Answer</span></label>'+
|
||||
'<div>'+
|
||||
'<textarea rows="3" ng-model="default_textarea" name="default_textarea" class="form-control ng-valid ng-dirty" id="default_textarea" aw-watch=""></textarea>'+
|
||||
'<textarea rows="3" ng-model="default_textarea" name="default_textarea" class="form-control ng-valid ng-dirty" id="default_textarea"></textarea>'+
|
||||
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="minTextError">The answer is shorter than the minimium length. Please make the answer longer. </div>' +
|
||||
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="maxTextError">The answer is longer than the maximum length. Please make the answer shorter. </div>' +
|
||||
'<div class="error api-error ng-binding" id="survey_question-default_textarea-api-error" ng-bind="default_textarea_api_error"></div>'+
|
||||
@ -252,6 +273,23 @@ export default
|
||||
column : 2,
|
||||
ngShow: 'type.type === "textarea" '
|
||||
},
|
||||
default_password: {
|
||||
realName: 'default_answer' ,
|
||||
type: 'custom' ,
|
||||
control: '<div class="form-group" >'+
|
||||
'<label for="default"><span class="label-text">Default Password</span></label>'+
|
||||
'<div>'+
|
||||
'<input type="password" ng-model="default_password" name="default_password" id="default_password" class="form-control" ng-hide="pwcheckbox">'+
|
||||
'<input type="text" ng-model="default_password" name="default_password" id="default_password" class="form-control" ng-show="pwcheckbox">'+
|
||||
'<label style="font-weight:normal"><input type="checkbox" ng-model="pwcheckbox" name="pwcheckbox" id="survey_question_pwcheckbox" ng-checked="false"> <span>Show Password</span></label>'+
|
||||
'<div class="error ng-hide" id=survey_question-default-duplicate-error" ng-show="minTextError">The answer is shorter than the minimium length. Please make the answer longer. </div>' +
|
||||
'<div class="error ng-hide" id=survey_question-default-password-duplicate-error" ng-show="maxTextError">The answer is longer than the maximum length. Please make the answer shorter. </div>' +
|
||||
'<div class="error api-error ng-binding" id="survey_question-default-password-api-error" ng-bind="default_api_error"></div>'+
|
||||
'</div>'+
|
||||
'</div>',
|
||||
column: 2,
|
||||
ngShow: 'type.type === "password" '
|
||||
},
|
||||
required: {
|
||||
realName: 'required_answer',
|
||||
label: 'Required',
|
||||
|
||||
@ -473,7 +473,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
relatedSets = {},
|
||||
buttons, url, form_scope;
|
||||
|
||||
var form_scope =
|
||||
form_scope =
|
||||
generator.inject(HostForm, { mode: 'edit', id: 'host-modal-dialog', breadCrumbs: false, related: false, scope: scope });
|
||||
generator.reset();
|
||||
|
||||
@ -1307,4 +1307,3 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
|
||||
@ -556,7 +556,32 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
'job_launch_form.'+question.variable+'.$error.maxlength\">Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.</div>'+
|
||||
'<div class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></div>';
|
||||
}
|
||||
if(question.type === 'password' ){
|
||||
minlength = (!Empty(question.min)) ? Number(question.min) : "";
|
||||
maxlength =(!Empty(question.max)) ? Number(question.max) : "" ;
|
||||
html+='<input type="password" id="'+question.variable+'_password" ng-model="'+question.variable+'" '+
|
||||
'name=" '+question.variable+' " ' +
|
||||
'ng-hide="'+question.variable+'_pwcheckbox" ' +
|
||||
'ng-minlength="'+minlength+'" ng-maxlength="'+maxlength+'" '+
|
||||
'class="form-control" ng-required='+question.required+'>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$dirty && ' +
|
||||
'job_launch_form.'+question.variable+'.$error.required\">Please enter an answer.</div>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$error.minlength || ' +
|
||||
'job_launch_form.'+question.variable+'.$error.maxlength\">Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.</div>'+
|
||||
'<div class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></div>';
|
||||
html+='<input type="text" id="'+question.variable+'_text" ng-model="'+question.variable+'" '+
|
||||
'name=" '+question.variable+' " ' +
|
||||
'ng-show="'+question.variable+'_pwcheckbox"'+
|
||||
'ng-minlength="'+minlength+'" ng-maxlength="'+maxlength+'" '+
|
||||
'class="form-control" ng-required='+question.required+'>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$dirty && ' +
|
||||
'job_launch_form.'+question.variable+'.$error.required\">Please enter an answer.</div>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$error.minlength || ' +
|
||||
'job_launch_form.'+question.variable+'.$error.maxlength\">Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.</div>'+
|
||||
'<div class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></div>';
|
||||
html+= '<label style="font-weight:normal"><input type="checkbox" ng-model="'+question.variable+'_pwcheckbox" name="pwcheckbox" id="'+question.variable+'_pwcheckbox" ng-checked="false"> <span>Show Password</span></label>';
|
||||
|
||||
}
|
||||
if(question.type === 'multiplechoice'){
|
||||
choices = question.choices.split(/\n/);
|
||||
element = (question.type==="multiselect") ? "checkbox" : 'radio';
|
||||
|
||||
@ -324,6 +324,17 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
if(question.type === 'password'){
|
||||
defaultValue = (question.default) ? question.default : "";
|
||||
defaultValue = defaultValue.replace(/</g, "<");
|
||||
defaultValue = defaultValue.replace(/>/g, ">");
|
||||
defaultValue = scope.serialize(defaultValue);
|
||||
html+='<div class="row">'+
|
||||
'<div class="col-xs-8">'+
|
||||
'<input type="password" value="'+defaultValue+'" class="form-control ng-pristine ng-invalid-required ng-invalid final" required="" readonly>'+
|
||||
'</div></div>';
|
||||
}
|
||||
|
||||
if(question.type === 'integer'){
|
||||
min = (!Empty(question.min)) ? question.min : "";
|
||||
max = (!Empty(question.max)) ? question.max : "" ;
|
||||
@ -430,6 +441,9 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
scope.int_max = null;
|
||||
scope.float_min = null;
|
||||
scope.float_max = null;
|
||||
scope.password_min = null;
|
||||
scope.password_max = null;
|
||||
scope.pwcheckbox = false;
|
||||
|
||||
if (scope.removeFillQuestionForm) {
|
||||
scope.removeFillQuestionForm();
|
||||
@ -455,6 +469,11 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
scope.textarea_max = question.max;
|
||||
scope.default_textarea= question.default;
|
||||
}
|
||||
if(question.type === 'password'){
|
||||
scope.password_min = question.min;
|
||||
scope.password_max = question.max;
|
||||
scope.default_password = question.default;
|
||||
}
|
||||
if( question.type === 'integer'){
|
||||
scope.int_min = question.min;
|
||||
scope.int_max = question.max;
|
||||
@ -501,6 +520,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
scope.answer_types=[
|
||||
{name: 'Text' , type: 'text'},
|
||||
{name: 'Textarea', type: 'textarea'},
|
||||
{name: 'Password', type: 'password'},
|
||||
{name: 'Multiple Choice (single select)', type: 'multiplechoice'},
|
||||
{name: 'Multiple Choice (multiple select)', type: 'multiselect'},
|
||||
{name: 'Integer', type: 'integer'},
|
||||
@ -738,6 +758,8 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
scope.text_max = "" ;
|
||||
scope.textarea_min = "";
|
||||
scope.textarea_max = "" ;
|
||||
scope.password_min = "" ;
|
||||
scope.password_max = "" ;
|
||||
scope.int_min = "";
|
||||
scope.int_max = "";
|
||||
scope.float_min = "";
|
||||
@ -747,6 +769,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
scope.survey_question_form.default_float.$setPristine();
|
||||
scope.survey_question_form.default_int.$setPristine();
|
||||
scope.survey_question_form.default_textarea.$setPristine();
|
||||
scope.survey_question_form.default_password.$setPristine();
|
||||
scope.survey_question_form.choices.$setPristine();
|
||||
scope.survey_question_form.int_min.$setPristine();
|
||||
scope.survey_question_form.int_max.$setPristine();
|
||||
@ -758,7 +781,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
choiceArray,
|
||||
answerArray,
|
||||
key, elementID;
|
||||
// Wait('start');
|
||||
scope.invalidChoice = false;
|
||||
scope.duplicate = false;
|
||||
scope.minTextError = false;
|
||||
@ -786,6 +808,17 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
}
|
||||
}
|
||||
|
||||
if(scope.type.type==="password"){
|
||||
if(scope.default_password.trim() !== ""){
|
||||
if(scope.default_password.trim().length < scope.password_min && scope.password_min !== "" ){
|
||||
scope.minTextError = true;
|
||||
}
|
||||
if(scope.password_max < scope.default_password.trim().length && scope.password_max !== "" ){
|
||||
scope.maxTextError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(scope.type.type==="multiselect" && scope.default_multiselect.trim() !== ""){
|
||||
choiceArray = scope.choices.split(/\n/);
|
||||
answerArray = scope.default_multiselect.split(/\n/);
|
||||
@ -844,7 +877,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
}
|
||||
|
||||
if(scope.duplicate===true || scope.invalidChoice===true || scope.minTextError === true || scope.maxTextError === true){
|
||||
// Wait('stop');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -855,9 +887,9 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
|
||||
data.required = scope.required;
|
||||
data.type = scope.type.type;
|
||||
data.variable = scope.variable;
|
||||
data.min = (scope.type.type === 'text') ? scope.text_min : (scope.type.type === 'textarea') ? scope.textarea_min : (scope.type.type === "float") ? scope.float_min : (scope.type.type==="integer") ? scope.int_min : "" ;
|
||||
data.max = (scope.type.type === 'text') ? scope.text_max : (scope.type.type === 'textarea') ? scope.textarea_max : (scope.type.type === "float") ? scope.float_max : (scope.type.type==="integer") ? scope.int_max : "" ;
|
||||
data.default = (scope.type.type === 'textarea') ? scope.default_textarea : (scope.type.type === "float") ? scope.default_float : (scope.type.type==="integer") ? scope.default_int : (scope.type.type === "multiselect") ? scope.default_multiselect : (scope.default) ? scope.default : "" ;
|
||||
data.min = (scope.type.type === 'text') ? scope.text_min : (scope.type.type === 'textarea') ? scope.textarea_min : (scope.type.type === 'password') ? scope.password_min : (scope.type.type === "float") ? scope.float_min : (scope.type.type==="integer") ? scope.int_min : "" ;
|
||||
data.max = (scope.type.type === 'text') ? scope.text_max : (scope.type.type === 'textarea') ? scope.textarea_max : (scope.type.type === 'password') ? scope.password_max : (scope.type.type === "float") ? scope.float_max : (scope.type.type==="integer") ? scope.int_max : "" ;
|
||||
data.default = (scope.type.type === 'textarea') ? scope.default_textarea : (scope.type.type === "float") ? scope.default_float : (scope.type.type==="integer") ? scope.default_int : (scope.type.type === "multiselect") ? scope.default_multiselect : (scope.type.type === "password") ? scope.default_password : (scope.default) ? scope.default : "" ;
|
||||
data.choices = (scope.type.type === "multiplechoice") ? scope.choices : (scope.type.type === 'multiselect') ? scope.choices : "" ;
|
||||
|
||||
Wait('stop');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user