mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 02:19:58 -03:30
Properly pass path to error message
This commit is contained in:
parent
03c07c0843
commit
cc3f2e0819
@ -39,101 +39,113 @@ function atLaunchTemplateCtrl (
|
||||
if (vm.template.type === 'job_template') {
|
||||
const selectedJobTemplate = jobTemplate.create();
|
||||
const preLaunchPromises = [
|
||||
selectedJobTemplate.getLaunch(vm.template.id),
|
||||
selectedJobTemplate.optionsLaunch(vm.template.id),
|
||||
selectedJobTemplate.getLaunch(vm.template.id)
|
||||
.catch(createErrorHandler(`/api/v2/job_templates/${vm.template.id}/launch`, 'GET')),
|
||||
selectedJobTemplate.optionsLaunch(vm.template.id)
|
||||
.catch(createErrorHandler(`/api/v2/job_templates/${vm.template.id}/launch`, 'OPTIONS'))
|
||||
];
|
||||
|
||||
Promise.all(preLaunchPromises)
|
||||
.then(([launchData, launchOptions]) => {
|
||||
if (selectedJobTemplate.canLaunchWithoutPrompt()) {
|
||||
selectedJobTemplate
|
||||
.postLaunch({ id: vm.template.id })
|
||||
.then(({ data }) => {
|
||||
/* Slice Jobs: Redirect to WF Details page if returned
|
||||
job type is a WF job */
|
||||
if (data.type === 'workflow_job' && data.workflow_job !== null) {
|
||||
$state.go('workflowResults', { id: data.workflow_job }, { reload: true });
|
||||
} else {
|
||||
$state.go('output', { id: data.job, type: 'playbook' }, { reload: true });
|
||||
}
|
||||
})
|
||||
.catch(createErrorHandler('launch job template', 'POST'));
|
||||
} else {
|
||||
const promptData = {
|
||||
launchConf: launchData.data,
|
||||
launchOptions: launchOptions.data,
|
||||
template: vm.template.id,
|
||||
templateType: vm.template.type,
|
||||
prompts: PromptService.processPromptValues({
|
||||
launchConf: launchData.data,
|
||||
launchOptions: launchOptions.data
|
||||
}),
|
||||
triggerModalOpen: true
|
||||
};
|
||||
|
||||
if (launchData.data.survey_enabled) {
|
||||
selectedJobTemplate.getSurveyQuestions(vm.template.id)
|
||||
// If we don't get both of these things then one of the
|
||||
// promises was rejected
|
||||
if (launchData && launchOptions) {
|
||||
if (selectedJobTemplate.canLaunchWithoutPrompt()) {
|
||||
selectedJobTemplate
|
||||
.postLaunch({ id: vm.template.id })
|
||||
.then(({ data }) => {
|
||||
const processed = PromptService.processSurveyQuestions({
|
||||
surveyQuestions: data.spec
|
||||
});
|
||||
promptData.surveyQuestions = processed.surveyQuestions;
|
||||
vm.promptData = promptData;
|
||||
/* Slice Jobs: Redirect to WF Details page if returned
|
||||
job type is a WF job */
|
||||
if (data.type === 'workflow_job' && data.workflow_job !== null) {
|
||||
$state.go('workflowResults', { id: data.workflow_job }, { reload: true });
|
||||
} else {
|
||||
$state.go('output', { id: data.job, type: 'playbook' }, { reload: true });
|
||||
}
|
||||
})
|
||||
.catch(createErrorHandler('get survey questions', 'GET'));
|
||||
.catch(createErrorHandler(`/api/v2/job_templates/${vm.template.id}/launch`, 'POST'));
|
||||
} else {
|
||||
vm.promptData = promptData;
|
||||
const promptData = {
|
||||
launchConf: launchData.data,
|
||||
launchOptions: launchOptions.data,
|
||||
template: vm.template.id,
|
||||
templateType: vm.template.type,
|
||||
prompts: PromptService.processPromptValues({
|
||||
launchConf: launchData.data,
|
||||
launchOptions: launchOptions.data
|
||||
}),
|
||||
triggerModalOpen: true
|
||||
};
|
||||
|
||||
if (launchData.data.survey_enabled) {
|
||||
selectedJobTemplate.getSurveyQuestions(vm.template.id)
|
||||
.then(({ data }) => {
|
||||
const processed = PromptService.processSurveyQuestions({
|
||||
surveyQuestions: data.spec
|
||||
});
|
||||
promptData.surveyQuestions = processed.surveyQuestions;
|
||||
vm.promptData = promptData;
|
||||
})
|
||||
.catch(createErrorHandler(`/api/v2/job_templates/${vm.template.id}/survey_spec`, 'GET'));
|
||||
} else {
|
||||
vm.promptData = promptData;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(createErrorHandler('get launch options', 'GET'));
|
||||
});
|
||||
} else if (vm.template.type === 'workflow_job_template') {
|
||||
const selectedWorkflowJobTemplate = workflowTemplate.create();
|
||||
const preLaunchPromises = [
|
||||
selectedWorkflowJobTemplate.request('get', vm.template.id),
|
||||
selectedWorkflowJobTemplate.getLaunch(vm.template.id),
|
||||
selectedWorkflowJobTemplate.optionsLaunch(vm.template.id),
|
||||
selectedWorkflowJobTemplate.request('get', vm.template.id)
|
||||
.catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}`, 'GET')),
|
||||
selectedWorkflowJobTemplate.getLaunch(vm.template.id)
|
||||
.catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}/launch`, 'GET')),
|
||||
selectedWorkflowJobTemplate.optionsLaunch(vm.template.id)
|
||||
.catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}/launch`, 'OPTIONS')),
|
||||
];
|
||||
|
||||
Promise.all(preLaunchPromises)
|
||||
.then(([wfjtData, launchData, launchOptions]) => {
|
||||
if (selectedWorkflowJobTemplate.canLaunchWithoutPrompt()) {
|
||||
selectedWorkflowJobTemplate
|
||||
.postLaunch({ id: vm.template.id })
|
||||
.then(({ data }) => {
|
||||
$state.go('workflowResults', { id: data.workflow_job }, { reload: true });
|
||||
})
|
||||
.catch(createErrorHandler('launch workflow job template', 'POST'));
|
||||
} else {
|
||||
launchData.data.defaults.extra_vars = wfjtData.data.extra_vars;
|
||||
|
||||
const promptData = {
|
||||
launchConf: selectedWorkflowJobTemplate.getLaunchConf(),
|
||||
launchOptions: launchOptions.data,
|
||||
template: vm.template.id,
|
||||
templateType: vm.template.type,
|
||||
prompts: PromptService.processPromptValues({
|
||||
launchConf: selectedWorkflowJobTemplate.getLaunchConf(),
|
||||
launchOptions: launchOptions.data
|
||||
}),
|
||||
triggerModalOpen: true,
|
||||
};
|
||||
|
||||
if (launchData.data.survey_enabled) {
|
||||
selectedWorkflowJobTemplate.getSurveyQuestions(vm.template.id)
|
||||
// If we don't get all of these things then one of the
|
||||
// promises was rejected
|
||||
if (wfjtData && launchData && launchOptions) {
|
||||
if (selectedWorkflowJobTemplate.canLaunchWithoutPrompt()) {
|
||||
selectedWorkflowJobTemplate
|
||||
.postLaunch({ id: vm.template.id })
|
||||
.then(({ data }) => {
|
||||
const processed = PromptService.processSurveyQuestions({
|
||||
surveyQuestions: data.spec
|
||||
});
|
||||
promptData.surveyQuestions = processed.surveyQuestions;
|
||||
vm.promptData = promptData;
|
||||
});
|
||||
$state.go('workflowResults', { id: data.workflow_job }, { reload: true });
|
||||
})
|
||||
.catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}/launch`, 'POST'));
|
||||
} else {
|
||||
vm.promptData = promptData;
|
||||
launchData.data.defaults.extra_vars = wfjtData.data.extra_vars;
|
||||
|
||||
const promptData = {
|
||||
launchConf: selectedWorkflowJobTemplate.getLaunchConf(),
|
||||
launchOptions: launchOptions.data,
|
||||
template: vm.template.id,
|
||||
templateType: vm.template.type,
|
||||
prompts: PromptService.processPromptValues({
|
||||
launchConf: selectedWorkflowJobTemplate.getLaunchConf(),
|
||||
launchOptions: launchOptions.data
|
||||
}),
|
||||
triggerModalOpen: true,
|
||||
};
|
||||
|
||||
if (launchData.data.survey_enabled) {
|
||||
selectedWorkflowJobTemplate.getSurveyQuestions(vm.template.id)
|
||||
.then(({ data }) => {
|
||||
const processed = PromptService.processSurveyQuestions({
|
||||
surveyQuestions: data.spec
|
||||
});
|
||||
promptData.surveyQuestions = processed.surveyQuestions;
|
||||
vm.promptData = promptData;
|
||||
})
|
||||
.catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}/survey_spec`, 'GET'));
|
||||
} else {
|
||||
vm.promptData = promptData;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(createErrorHandler('get launch options', 'GET'));
|
||||
});
|
||||
} else {
|
||||
Alert(templatesStrings.get('error.UNKNOWN'), templatesStrings.get('alert.UNKNOWN_LAUNCH'));
|
||||
}
|
||||
@ -168,14 +180,14 @@ function atLaunchTemplateCtrl (
|
||||
} else {
|
||||
$state.go('output', { id: launchRes.data.job, type: 'playbook' }, { reload: true });
|
||||
}
|
||||
}).catch(createErrorHandler('launch job template', 'POST'));
|
||||
}).catch(createErrorHandler(`/api/v2/job_templates/${vm.template.id}/launch`, 'POST'));
|
||||
} else if (vm.promptData.templateType === 'workflow_job_template') {
|
||||
workflowTemplate.create().postLaunch({
|
||||
id: vm.promptData.template,
|
||||
launchData: jobLaunchData
|
||||
}).then((launchRes) => {
|
||||
$state.go('workflowResults', { id: launchRes.data.workflow_job }, { reload: true });
|
||||
}).catch(createErrorHandler('launch workflow job template', 'POST'));
|
||||
}).catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}/launch`, 'POST'));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user