mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 22:46:01 -03:30
Merge pull request #1525 from mabashian/schedule-extra-vars-fixes
Populate JT schedule add with default extra vars when promptable.
This commit is contained in:
@@ -91,7 +91,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
// 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
|
||||||
if ($state.current.name === 'jobTemplateSchedules.add'){
|
if ($state.current.name === 'jobTemplateSchedules.add'){
|
||||||
$scope.parseType = 'yaml';
|
$scope.parseType = 'yaml';
|
||||||
$scope.extraVars = '---';
|
$scope.extraVars = ParentObject.extra_vars === '' ? '---' : ParentObject.extra_vars;
|
||||||
|
|
||||||
ParseTypeChange({
|
ParseTypeChange({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
@@ -116,20 +116,20 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
|
|
||||||
$scope.$watchGroup(promptValuesToWatch, function() {
|
$scope.$watchGroup(promptValuesToWatch, function() {
|
||||||
let missingPromptValue = false;
|
let missingPromptValue = false;
|
||||||
if($scope.missingSurveyValue) {
|
if ($scope.missingSurveyValue) {
|
||||||
missingPromptValue = true;
|
missingPromptValue = true;
|
||||||
} else if(!$scope.promptData.prompts.inventory.value || !$scope.promptData.prompts.inventory.value.id) {
|
} else if (!$scope.promptData.prompts.inventory.value || !$scope.promptData.prompts.inventory.value.id) {
|
||||||
missingPromptValue = true;
|
missingPromptValue = true;
|
||||||
}
|
}
|
||||||
$scope.promptModalMissingReqFields = missingPromptValue;
|
$scope.promptModalMissingReqFields = missingPromptValue;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!launchConf.ask_variables_on_launch) {
|
if (!launchConf.ask_variables_on_launch) {
|
||||||
$scope.noVars = true;
|
$scope.noVars = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!launchConf.survey_enabled &&
|
if (!launchConf.survey_enabled &&
|
||||||
!launchConf.ask_inventory_on_launch &&
|
!launchConf.ask_inventory_on_launch &&
|
||||||
!launchConf.ask_credential_on_launch &&
|
!launchConf.ask_credential_on_launch &&
|
||||||
!launchConf.ask_verbosity_on_launch &&
|
!launchConf.ask_verbosity_on_launch &&
|
||||||
@@ -151,11 +151,11 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
// Promptable variables will happen in the schedule form
|
// Promptable variables will happen in the schedule form
|
||||||
launchConf.ignore_ask_variables = true;
|
launchConf.ignore_ask_variables = true;
|
||||||
|
|
||||||
if(launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory')) {
|
if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory')) {
|
||||||
$scope.promptModalMissingReqFields = true;
|
$scope.promptModalMissingReqFields = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(launchConf.survey_enabled) {
|
if (launchConf.survey_enabled) {
|
||||||
// go out and get the survey questions
|
// go out and get the survey questions
|
||||||
jobTemplate.getSurveyQuestions(ParentObject.id)
|
jobTemplate.getSurveyQuestions(ParentObject.id)
|
||||||
.then((surveyQuestionRes) => {
|
.then((surveyQuestionRes) => {
|
||||||
@@ -180,7 +180,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
$scope.$watch('promptData.surveyQuestions', () => {
|
$scope.$watch('promptData.surveyQuestions', () => {
|
||||||
let missingSurveyValue = false;
|
let missingSurveyValue = false;
|
||||||
_.each($scope.promptData.surveyQuestions, (question) => {
|
_.each($scope.promptData.surveyQuestions, (question) => {
|
||||||
if(question.required && (Empty(question.model) || question.model === [])) {
|
if (question.required && (Empty(question.model) || question.model === [])) {
|
||||||
missingSurveyValue = true;
|
missingSurveyValue = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -189,8 +189,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
|
|
||||||
watchForPromptChanges();
|
watchForPromptChanges();
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$scope.promptData = {
|
$scope.promptData = {
|
||||||
launchConf: responses[1].data,
|
launchConf: responses[1].data,
|
||||||
launchOptions: responses[0].data,
|
launchOptions: responses[0].data,
|
||||||
@@ -274,18 +273,18 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if ($state.current.name === 'projectSchedules.add'){
|
|
||||||
$scope.noVars = true;
|
if ($state.current.name === 'workflowJobTemplateSchedules.add' ||
|
||||||
}
|
$state.current.name === 'projectSchedules.add' ||
|
||||||
else if ($state.current.name === 'inventories.edit.inventory_sources.edit.schedules.add'){
|
$state.current.name === 'inventories.edit.inventory_sources.edit.schedules.add'
|
||||||
|
){
|
||||||
$scope.noVars = true;
|
$scope.noVars = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
job_type = $scope.parentObject.job_type;
|
job_type = $scope.parentObject.job_type;
|
||||||
if (!Empty($stateParams.id) && base !== 'system_job_templates' && base !== 'inventories' && !schedule_url) {
|
if (!Empty($stateParams.id) && base !== 'system_job_templates' && base !== 'inventories' && !schedule_url) {
|
||||||
schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/';
|
schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/';
|
||||||
}
|
} else if (base === "inventories"){
|
||||||
else if(base === "inventories"){
|
|
||||||
if (!schedule_url){
|
if (!schedule_url){
|
||||||
Rest.setUrl(GetBasePath('groups') + $stateParams.id + '/');
|
Rest.setUrl(GetBasePath('groups') + $stateParams.id + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
@@ -299,10 +298,9 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
} else if (base === 'system_job_templates') {
|
||||||
else if (base === 'system_job_templates') {
|
|
||||||
schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/';
|
schedule_url = GetBasePath(base) + $stateParams.id + '/schedules/';
|
||||||
if(job_type === "cleanup_facts"){
|
if (job_type === "cleanup_facts"){
|
||||||
$scope.isFactCleanup = true;
|
$scope.isFactCleanup = true;
|
||||||
$scope.keep_unit_choices = [{
|
$scope.keep_unit_choices = [{
|
||||||
"label" : "Days",
|
"label" : "Days",
|
||||||
@@ -332,8 +330,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
$scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1);
|
$scope.prompt_for_days_facts_form.granularity_keep_amount.$setViewValue(1);
|
||||||
$scope.keep_unit = $scope.keep_unit_choices[0];
|
$scope.keep_unit = $scope.keep_unit_choices[0];
|
||||||
$scope.granularity_keep_unit = $scope.granularity_keep_unit_choices[1];
|
$scope.granularity_keep_unit = $scope.granularity_keep_unit_choices[1];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$scope.cleanupJob = true;
|
$scope.cleanupJob = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -352,15 +349,14 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
|||||||
});
|
});
|
||||||
$scope.scheduleTimeChange();
|
$scope.scheduleTimeChange();
|
||||||
});
|
});
|
||||||
if($scope.schedulerUTCTime) {
|
if ($scope.schedulerUTCTime) {
|
||||||
// The UTC time is already set
|
// The UTC time is already set
|
||||||
processSchedulerEndDt();
|
processSchedulerEndDt();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// We need to wait for it to be set by angular-scheduler because the following function depends
|
// We need to wait for it to be set by angular-scheduler because the following function depends
|
||||||
// on it
|
// on it
|
||||||
var schedulerUTCTimeWatcher = $scope.$watch('schedulerUTCTime', function(newVal) {
|
var schedulerUTCTimeWatcher = $scope.$watch('schedulerUTCTime', function(newVal) {
|
||||||
if(newVal) {
|
if (newVal) {
|
||||||
// Remove the watcher
|
// Remove the watcher
|
||||||
schedulerUTCTimeWatcher();
|
schedulerUTCTimeWatcher();
|
||||||
processSchedulerEndDt();
|
processSchedulerEndDt();
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
$scope.extraVars = (data.extra_data === '' || _.isEmpty(data.extra_data)) ? '---' : '---\n' + jsyaml.safeDump(data.extra_data);
|
$scope.extraVars = (data.extra_data === '' || _.isEmpty(data.extra_data)) ? '---' : '---\n' + jsyaml.safeDump(data.extra_data);
|
||||||
|
|
||||||
if(schedule.extra_data.hasOwnProperty('granularity')){
|
if (schedule.extra_data.hasOwnProperty('granularity')){
|
||||||
$scope.isFactCleanup = true;
|
$scope.isFactCleanup = true;
|
||||||
}
|
}
|
||||||
if (schedule.extra_data.hasOwnProperty('days')){
|
if (schedule.extra_data.hasOwnProperty('days')){
|
||||||
@@ -198,16 +198,15 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
scheduler.setRRule(schedule.rrule);
|
scheduler.setRRule(schedule.rrule);
|
||||||
scheduler.setName(schedule.name);
|
scheduler.setName(schedule.name);
|
||||||
|
|
||||||
if($scope.isFactCleanup || $scope.cleanupJob){
|
if ($scope.isFactCleanup || $scope.cleanupJob){
|
||||||
var a,b, prompt_for_days,
|
var a,b, prompt_for_days,
|
||||||
keep_unit,
|
keep_unit,
|
||||||
granularity,
|
granularity,
|
||||||
granularity_keep_unit;
|
granularity_keep_unit;
|
||||||
|
|
||||||
if($scope.cleanupJob){
|
if ($scope.cleanupJob){
|
||||||
$scope.schedulerPurgeDays = Number(schedule.extra_data.days);
|
$scope.schedulerPurgeDays = Number(schedule.extra_data.days);
|
||||||
}
|
} else if ($scope.isFactCleanup){
|
||||||
else if($scope.isFactCleanup){
|
|
||||||
$scope.keep_unit_choices = [{
|
$scope.keep_unit_choices = [{
|
||||||
"label" : "Days",
|
"label" : "Days",
|
||||||
"value" : "d"
|
"value" : "d"
|
||||||
@@ -274,9 +273,9 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
$scope.$watchGroup(promptValuesToWatch, function() {
|
$scope.$watchGroup(promptValuesToWatch, function() {
|
||||||
let missingPromptValue = false;
|
let missingPromptValue = false;
|
||||||
if($scope.missingSurveyValue) {
|
if ($scope.missingSurveyValue) {
|
||||||
missingPromptValue = true;
|
missingPromptValue = true;
|
||||||
} else if(!$scope.promptData.prompts.inventory.value || !$scope.promptData.prompts.inventory.value.id) {
|
} else if (!$scope.promptData.prompts.inventory.value || !$scope.promptData.prompts.inventory.value.id) {
|
||||||
missingPromptValue = true;
|
missingPromptValue = true;
|
||||||
}
|
}
|
||||||
$scope.promptModalMissingReqFields = missingPromptValue;
|
$scope.promptModalMissingReqFields = missingPromptValue;
|
||||||
@@ -294,8 +293,8 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
const credentialHasScheduleOverride = (templateDefaultCred) => {
|
const credentialHasScheduleOverride = (templateDefaultCred) => {
|
||||||
let credentialHasOverride = false;
|
let credentialHasOverride = false;
|
||||||
scheduleCredentials.forEach((scheduleCred) => {
|
scheduleCredentials.forEach((scheduleCred) => {
|
||||||
if(templateDefaultCred.credential_type === scheduleCred.credential_type) {
|
if (templateDefaultCred.credential_type === scheduleCred.credential_type) {
|
||||||
if(
|
if (
|
||||||
(!templateDefaultCred.vault_id && !scheduleCred.inputs.vault_id) ||
|
(!templateDefaultCred.vault_id && !scheduleCred.inputs.vault_id) ||
|
||||||
(templateDefaultCred.vault_id && scheduleCred.inputs.vault_id && templateDefaultCred.vault_id === scheduleCred.inputs.vault_id)
|
(templateDefaultCred.vault_id && scheduleCred.inputs.vault_id && templateDefaultCred.vault_id === scheduleCred.inputs.vault_id)
|
||||||
) {
|
) {
|
||||||
@@ -307,9 +306,9 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
return credentialHasOverride;
|
return credentialHasOverride;
|
||||||
};
|
};
|
||||||
|
|
||||||
if(_.has(launchConf, 'defaults.credentials')) {
|
if (_.has(launchConf, 'defaults.credentials')) {
|
||||||
launchConf.defaults.credentials.forEach((defaultCred) => {
|
launchConf.defaults.credentials.forEach((defaultCred) => {
|
||||||
if(!credentialHasScheduleOverride(defaultCred)) {
|
if (!credentialHasScheduleOverride(defaultCred)) {
|
||||||
defaultCredsWithoutOverrides.push(defaultCred);
|
defaultCredsWithoutOverrides.push(defaultCred);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -317,11 +316,11 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
prompts.credentials.value = defaultCredsWithoutOverrides.concat(scheduleCredentials);
|
prompts.credentials.value = defaultCredsWithoutOverrides.concat(scheduleCredentials);
|
||||||
|
|
||||||
if(!launchConf.ask_variables_on_launch) {
|
if (!launchConf.ask_variables_on_launch) {
|
||||||
$scope.noVars = true;
|
$scope.noVars = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!launchConf.survey_enabled &&
|
if (!launchConf.survey_enabled &&
|
||||||
!launchConf.ask_inventory_on_launch &&
|
!launchConf.ask_inventory_on_launch &&
|
||||||
!launchConf.ask_credential_on_launch &&
|
!launchConf.ask_credential_on_launch &&
|
||||||
!launchConf.ask_verbosity_on_launch &&
|
!launchConf.ask_verbosity_on_launch &&
|
||||||
@@ -343,11 +342,11 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
// Promptable variables will happen in the schedule form
|
// Promptable variables will happen in the schedule form
|
||||||
launchConf.ignore_ask_variables = true;
|
launchConf.ignore_ask_variables = true;
|
||||||
|
|
||||||
if(launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory') && !_.has(data, 'summary_fields.inventory')) {
|
if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory') && !_.has(data, 'summary_fields.inventory')) {
|
||||||
$scope.promptModalMissingReqFields = true;
|
$scope.promptModalMissingReqFields = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(responses[1].data.survey_enabled) {
|
if (responses[1].data.survey_enabled) {
|
||||||
// go out and get the survey questions
|
// go out and get the survey questions
|
||||||
jobTemplate.getSurveyQuestions(ParentObject.id)
|
jobTemplate.getSurveyQuestions(ParentObject.id)
|
||||||
.then((surveyQuestionRes) => {
|
.then((surveyQuestionRes) => {
|
||||||
@@ -380,7 +379,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
$scope.$watch('promptData.surveyQuestions', () => {
|
$scope.$watch('promptData.surveyQuestions', () => {
|
||||||
let missingSurveyValue = false;
|
let missingSurveyValue = false;
|
||||||
_.each($scope.promptData.surveyQuestions, (question) => {
|
_.each($scope.promptData.surveyQuestions, (question) => {
|
||||||
if(question.required && (Empty(question.model) || question.model === [])) {
|
if (question.required && (Empty(question.model) || question.model === [])) {
|
||||||
missingSurveyValue = true;
|
missingSurveyValue = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -389,8 +388,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
watchForPromptChanges();
|
watchForPromptChanges();
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$scope.promptData = {
|
$scope.promptData = {
|
||||||
launchConf: launchConf,
|
launchConf: launchConf,
|
||||||
launchOptions: launchOptions,
|
launchOptions: launchOptions,
|
||||||
@@ -474,13 +472,12 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
|||||||
|
|
||||||
// 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
|
||||||
if ($state.current.name !== 'managementJobsList.schedule.add' && $state.current.name !== 'managementJobsList.schedule.edit'){
|
if ($state.current.name !== 'managementJobsList.schedule.add' && $state.current.name !== 'managementJobsList.schedule.edit'){
|
||||||
if ($state.current.name === 'projectSchedules.edit'){
|
if ($state.current.name === 'projectSchedules.edit' ||
|
||||||
|
$state.current.name === 'inventories.edit.inventory_sources.edit.schedules.edit' ||
|
||||||
|
$state.current.name === 'workflowJobTemplateSchedules.add'
|
||||||
|
){
|
||||||
$scope.noVars = true;
|
$scope.noVars = true;
|
||||||
}
|
} else {
|
||||||
else if ($state.current.name === 'inventories.edit.inventory_sources.edit.schedules.edit'){
|
|
||||||
$scope.noVars = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ParseTypeChange({
|
ParseTypeChange({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
variable: 'extraVars',
|
variable: 'extraVars',
|
||||||
|
|||||||
Reference in New Issue
Block a user