Properly pass path to error message

This commit is contained in:
mabashian
2019-02-27 12:46:18 -05:00
committed by Jeff Bradberry
parent 03c07c0843
commit cc3f2e0819

View File

@@ -39,101 +39,113 @@ function atLaunchTemplateCtrl (
if (vm.template.type === 'job_template') { if (vm.template.type === 'job_template') {
const selectedJobTemplate = jobTemplate.create(); const selectedJobTemplate = jobTemplate.create();
const preLaunchPromises = [ const preLaunchPromises = [
selectedJobTemplate.getLaunch(vm.template.id), selectedJobTemplate.getLaunch(vm.template.id)
selectedJobTemplate.optionsLaunch(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) Promise.all(preLaunchPromises)
.then(([launchData, launchOptions]) => { .then(([launchData, launchOptions]) => {
if (selectedJobTemplate.canLaunchWithoutPrompt()) { // If we don't get both of these things then one of the
selectedJobTemplate // promises was rejected
.postLaunch({ id: vm.template.id }) if (launchData && launchOptions) {
.then(({ data }) => { if (selectedJobTemplate.canLaunchWithoutPrompt()) {
/* Slice Jobs: Redirect to WF Details page if returned selectedJobTemplate
job type is a WF job */ .postLaunch({ id: vm.template.id })
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)
.then(({ data }) => { .then(({ data }) => {
const processed = PromptService.processSurveyQuestions({ /* Slice Jobs: Redirect to WF Details page if returned
surveyQuestions: data.spec job type is a WF job */
}); if (data.type === 'workflow_job' && data.workflow_job !== null) {
promptData.surveyQuestions = processed.surveyQuestions; $state.go('workflowResults', { id: data.workflow_job }, { reload: true });
vm.promptData = promptData; } 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 { } 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') { } else if (vm.template.type === 'workflow_job_template') {
const selectedWorkflowJobTemplate = workflowTemplate.create(); const selectedWorkflowJobTemplate = workflowTemplate.create();
const preLaunchPromises = [ const preLaunchPromises = [
selectedWorkflowJobTemplate.request('get', vm.template.id), selectedWorkflowJobTemplate.request('get', vm.template.id)
selectedWorkflowJobTemplate.getLaunch(vm.template.id), .catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}`, 'GET')),
selectedWorkflowJobTemplate.optionsLaunch(vm.template.id), 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) Promise.all(preLaunchPromises)
.then(([wfjtData, launchData, launchOptions]) => { .then(([wfjtData, launchData, launchOptions]) => {
if (selectedWorkflowJobTemplate.canLaunchWithoutPrompt()) { // If we don't get all of these things then one of the
selectedWorkflowJobTemplate // promises was rejected
.postLaunch({ id: vm.template.id }) if (wfjtData && launchData && launchOptions) {
.then(({ data }) => { if (selectedWorkflowJobTemplate.canLaunchWithoutPrompt()) {
$state.go('workflowResults', { id: data.workflow_job }, { reload: true }); selectedWorkflowJobTemplate
}) .postLaunch({ id: vm.template.id })
.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)
.then(({ data }) => { .then(({ data }) => {
const processed = PromptService.processSurveyQuestions({ $state.go('workflowResults', { id: data.workflow_job }, { reload: true });
surveyQuestions: data.spec })
}); .catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}/launch`, 'POST'));
promptData.surveyQuestions = processed.surveyQuestions;
vm.promptData = promptData;
});
} else { } 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 { } else {
Alert(templatesStrings.get('error.UNKNOWN'), templatesStrings.get('alert.UNKNOWN_LAUNCH')); Alert(templatesStrings.get('error.UNKNOWN'), templatesStrings.get('alert.UNKNOWN_LAUNCH'));
} }
@@ -168,14 +180,14 @@ function atLaunchTemplateCtrl (
} else { } else {
$state.go('output', { id: launchRes.data.job, type: 'playbook' }, { reload: true }); $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') { } else if (vm.promptData.templateType === 'workflow_job_template') {
workflowTemplate.create().postLaunch({ workflowTemplate.create().postLaunch({
id: vm.promptData.template, id: vm.promptData.template,
launchData: jobLaunchData launchData: jobLaunchData
}).then((launchRes) => { }).then((launchRes) => {
$state.go('workflowResults', { id: launchRes.data.workflow_job }, { reload: true }); $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'));
} }
}; };
} }