mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Adds prompting to workflow schedules when a survey is present on the wfjt
This commit is contained in:
@@ -8,10 +8,13 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
'$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath',
|
'$scope', '$rootScope', 'CreateSelect2', 'ParseTypeChange', 'GetBasePath',
|
||||||
'Rest', 'ParentObject', 'JobTemplateModel', '$q', 'Empty', 'SchedulePost',
|
'Rest', 'ParentObject', 'JobTemplateModel', '$q', 'Empty', 'SchedulePost',
|
||||||
'ProcessErrors', 'SchedulerInit', '$location', 'PromptService', 'RRuleToAPI', 'moment',
|
'ProcessErrors', 'SchedulerInit', '$location', 'PromptService', 'RRuleToAPI', 'moment',
|
||||||
|
'WorkflowJobTemplateModel',
|
||||||
function($filter, $state, $stateParams, $http, Wait,
|
function($filter, $state, $stateParams, $http, Wait,
|
||||||
$scope, $rootScope, CreateSelect2, ParseTypeChange, GetBasePath,
|
$scope, $rootScope, CreateSelect2, ParseTypeChange, GetBasePath,
|
||||||
Rest, ParentObject, JobTemplate, $q, Empty, SchedulePost,
|
Rest, ParentObject, JobTemplate, $q, Empty, SchedulePost,
|
||||||
ProcessErrors, SchedulerInit, $location, PromptService, RRuleToAPI, moment) {
|
ProcessErrors, SchedulerInit, $location, PromptService, RRuleToAPI, moment,
|
||||||
|
WorkflowJobTemplate
|
||||||
|
) {
|
||||||
|
|
||||||
var base = $scope.base || $location.path().replace(/^\//, '').split('/')[0],
|
var base = $scope.base || $location.path().replace(/^\//, '').split('/')[0],
|
||||||
scheduler,
|
scheduler,
|
||||||
@@ -200,22 +203,74 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else if ($state.current.name === 'workflowJobTemplateSchedules.add'){
|
||||||
else if ($state.current.name === 'workflowJobTemplateSchedules.add'){
|
let workflowJobTemplate = new WorkflowJobTemplate();
|
||||||
$scope.parseType = 'yaml';
|
|
||||||
// grab any existing extra_vars from parent workflow_job_template
|
$q.all([workflowJobTemplate.optionsLaunch(ParentObject.id), workflowJobTemplate.getLaunch(ParentObject.id)])
|
||||||
let defaultUrl = GetBasePath('workflow_job_templates') + $stateParams.id + '/';
|
.then((responses) => {
|
||||||
Rest.setUrl(defaultUrl);
|
let launchConf = responses[1].data;
|
||||||
Rest.get().then(function(res){
|
|
||||||
var data = res.data.extra_vars;
|
let watchForPromptChanges = () => {
|
||||||
$scope.extraVars = data === '' ? '---' : data;
|
$scope.$watch('missingSurveyValue', function() {
|
||||||
ParseTypeChange({
|
$scope.promptModalMissingReqFields = $scope.missingSurveyValue ? true : false;
|
||||||
scope: $scope,
|
});
|
||||||
variable: 'extraVars',
|
};
|
||||||
parse_variable: 'parseType',
|
|
||||||
field_id: 'SchedulerForm-extraVars'
|
if(!launchConf.survey_enabled) {
|
||||||
|
$scope.showPromptButton = false;
|
||||||
|
} else {
|
||||||
|
$scope.showPromptButton = true;
|
||||||
|
|
||||||
|
if(launchConf.survey_enabled) {
|
||||||
|
// go out and get the survey questions
|
||||||
|
workflowJobTemplate.getSurveyQuestions(ParentObject.id)
|
||||||
|
.then((surveyQuestionRes) => {
|
||||||
|
|
||||||
|
let processed = PromptService.processSurveyQuestions({
|
||||||
|
surveyQuestions: surveyQuestionRes.data.spec
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.missingSurveyValue = processed.missingSurveyValue;
|
||||||
|
|
||||||
|
$scope.promptData = {
|
||||||
|
launchConf: responses[1].data,
|
||||||
|
launchOptions: responses[0].data,
|
||||||
|
surveyQuestions: processed.surveyQuestions,
|
||||||
|
template: ParentObject.id,
|
||||||
|
prompts: PromptService.processPromptValues({
|
||||||
|
launchConf: responses[1].data,
|
||||||
|
launchOptions: responses[0].data
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.$watch('promptData.surveyQuestions', () => {
|
||||||
|
let missingSurveyValue = false;
|
||||||
|
_.each($scope.promptData.surveyQuestions, (question) => {
|
||||||
|
if(question.required && (Empty(question.model) || question.model === [])) {
|
||||||
|
missingSurveyValue = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$scope.missingSurveyValue = missingSurveyValue;
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
watchForPromptChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$scope.promptData = {
|
||||||
|
launchConf: responses[1].data,
|
||||||
|
launchOptions: responses[0].data,
|
||||||
|
template: ParentObject.id,
|
||||||
|
prompts: PromptService.processPromptValues({
|
||||||
|
launchConf: responses[1].data,
|
||||||
|
launchOptions: responses[0].data
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
watchForPromptChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else if ($state.current.name === 'projectSchedules.add'){
|
else if ($state.current.name === 'projectSchedules.add'){
|
||||||
$scope.noVars = true;
|
$scope.noVars = true;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
export default ['$filter', '$state', '$stateParams', 'Wait', '$scope', 'moment',
|
export default ['$filter', '$state', '$stateParams', 'Wait', '$scope', 'moment',
|
||||||
'$rootScope', '$http', 'CreateSelect2', 'ParseTypeChange', 'ParentObject', 'ProcessErrors', 'Rest',
|
'$rootScope', '$http', 'CreateSelect2', 'ParseTypeChange', 'ParentObject', 'ProcessErrors', 'Rest',
|
||||||
'GetBasePath', 'SchedulerInit', 'SchedulePost', 'JobTemplateModel', '$q', 'Empty', 'PromptService', 'RRuleToAPI',
|
'GetBasePath', 'SchedulerInit', 'SchedulePost', 'JobTemplateModel', '$q', 'Empty', 'PromptService', 'RRuleToAPI',
|
||||||
|
'WorkflowJobTemplateModel',
|
||||||
function($filter, $state, $stateParams, Wait, $scope, moment,
|
function($filter, $state, $stateParams, Wait, $scope, moment,
|
||||||
$rootScope, $http, CreateSelect2, ParseTypeChange, ParentObject, ProcessErrors, Rest,
|
$rootScope, $http, CreateSelect2, ParseTypeChange, ParentObject, ProcessErrors, Rest,
|
||||||
GetBasePath, SchedulerInit, SchedulePost, JobTemplate, $q, Empty, PromptService, RRuleToAPI) {
|
GetBasePath, SchedulerInit, SchedulePost, JobTemplate, $q, Empty, PromptService, RRuleToAPI,
|
||||||
|
WorkflowJobTemplate
|
||||||
|
) {
|
||||||
|
|
||||||
let schedule, scheduler, scheduleCredentials = [];
|
let schedule, scheduler, scheduleCredentials = [];
|
||||||
|
|
||||||
@@ -396,6 +399,75 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if ($state.current.name === 'workflowJobTemplateSchedules.edit') {
|
||||||
|
let workflowJobTemplate = new WorkflowJobTemplate();
|
||||||
|
|
||||||
|
$q.all([workflowJobTemplate.optionsLaunch(ParentObject.id), workflowJobTemplate.getLaunch(ParentObject.id)])
|
||||||
|
.then((responses) => {
|
||||||
|
let launchOptions = responses[0].data,
|
||||||
|
launchConf = responses[1].data;
|
||||||
|
|
||||||
|
let watchForPromptChanges = () => {
|
||||||
|
$scope.$watch('missingSurveyValue', function() {
|
||||||
|
$scope.promptModalMissingReqFields = $scope.missingSurveyValue ? true : false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let prompts = PromptService.processPromptValues({
|
||||||
|
launchConf: responses[1].data,
|
||||||
|
launchOptions: responses[0].data,
|
||||||
|
currentValues: data
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!launchConf.survey_enabled) {
|
||||||
|
$scope.showPromptButton = false;
|
||||||
|
} else {
|
||||||
|
$scope.showPromptButton = true;
|
||||||
|
|
||||||
|
if(responses[1].data.survey_enabled) {
|
||||||
|
// go out and get the survey questions
|
||||||
|
workflowJobTemplate.getSurveyQuestions(ParentObject.id)
|
||||||
|
.then((surveyQuestionRes) => {
|
||||||
|
|
||||||
|
let processed = PromptService.processSurveyQuestions({
|
||||||
|
surveyQuestions: surveyQuestionRes.data.spec,
|
||||||
|
extra_data: _.cloneDeep(data.extra_data)
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.missingSurveyValue = processed.missingSurveyValue;
|
||||||
|
|
||||||
|
$scope.promptData = {
|
||||||
|
launchConf: launchConf,
|
||||||
|
launchOptions: launchOptions,
|
||||||
|
prompts: prompts,
|
||||||
|
surveyQuestions: surveyQuestionRes.data.spec,
|
||||||
|
template: ParentObject.id
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.$watch('promptData.surveyQuestions', () => {
|
||||||
|
let missingSurveyValue = false;
|
||||||
|
_.each($scope.promptData.surveyQuestions, (question) => {
|
||||||
|
if(question.required && (Empty(question.model) || question.model === [])) {
|
||||||
|
missingSurveyValue = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$scope.missingSurveyValue = missingSurveyValue;
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
watchForPromptChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$scope.promptData = {
|
||||||
|
launchConf: launchConf,
|
||||||
|
launchOptions: launchOptions,
|
||||||
|
prompts: prompts,
|
||||||
|
template: ParentObject.id
|
||||||
|
};
|
||||||
|
watchForPromptChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// extra_data field is not manifested in the UI when scheduling a Management Job
|
// extra_data field is not manifested in the UI when scheduling a Management Job
|
||||||
|
|||||||
Reference in New Issue
Block a user