mirror of
https://github.com/ansible/awx.git
synced 2026-05-22 08:17:39 -02:30
Properly pass path to error message
This commit is contained in:
committed by
Jeff Bradberry
parent
03c07c0843
commit
cc3f2e0819
@@ -39,12 +39,17 @@ 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 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 })
|
||||
@@ -57,7 +62,7 @@ function atLaunchTemplateCtrl (
|
||||
$state.go('output', { id: data.job, type: 'playbook' }, { reload: true });
|
||||
}
|
||||
})
|
||||
.catch(createErrorHandler('launch job template', 'POST'));
|
||||
.catch(createErrorHandler(`/api/v2/job_templates/${vm.template.id}/launch`, 'POST'));
|
||||
} else {
|
||||
const promptData = {
|
||||
launchConf: launchData.data,
|
||||
@@ -80,30 +85,36 @@ function atLaunchTemplateCtrl (
|
||||
promptData.surveyQuestions = processed.surveyQuestions;
|
||||
vm.promptData = promptData;
|
||||
})
|
||||
.catch(createErrorHandler('get survey questions', 'GET'));
|
||||
.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 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 }) => {
|
||||
$state.go('workflowResults', { id: data.workflow_job }, { reload: true });
|
||||
})
|
||||
.catch(createErrorHandler('launch workflow job template', 'POST'));
|
||||
.catch(createErrorHandler(`/api/v2/workflow_job_templates/${vm.template.id}/launch`, 'POST'));
|
||||
} else {
|
||||
launchData.data.defaults.extra_vars = wfjtData.data.extra_vars;
|
||||
|
||||
@@ -127,13 +138,14 @@ function atLaunchTemplateCtrl (
|
||||
});
|
||||
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'));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user