add missing api fields

This commit is contained in:
Jake McDermott 2018-11-10 22:44:09 -05:00
parent 2bd25b1fba
commit 38fbcf8ee6
No known key found for this signature in database
GPG Key ID: 9A6F084352C3A0B7
3 changed files with 27 additions and 43 deletions

View File

@ -4418,6 +4418,7 @@ class JobLaunchSerializer(BaseSerializer):
class WorkflowJobLaunchSerializer(BaseSerializer):
can_start_without_user_input = serializers.BooleanField(read_only=True)
defaults = serializers.SerializerMethodField()
variables_needed_to_start = serializers.ReadOnlyField()
survey_enabled = serializers.SerializerMethodField()
extra_vars = VerbatimField(required=False, write_only=True)
@ -4429,16 +4430,27 @@ class WorkflowJobLaunchSerializer(BaseSerializer):
class Meta:
model = WorkflowJobTemplate
fields = ('can_start_without_user_input', 'extra_vars', 'inventory',
'survey_enabled', 'variables_needed_to_start',
fields = ('ask_inventory_on_launch', 'can_start_without_user_input', 'defaults', 'extra_vars',
'inventory', 'survey_enabled', 'variables_needed_to_start',
'node_templates_missing', 'node_prompts_rejected',
'workflow_job_template_data')
'workflow_job_template_data', 'survey_enabled')
read_only_fields = ('ask_inventory_on_launch',)
def get_survey_enabled(self, obj):
if obj:
return obj.survey_enabled and 'spec' in obj.survey_spec
return False
def get_defaults(self, obj):
defaults ={
'inventory': {
'name': getattrd(obj, 'inventory.name', None),
'id': getattrd(obj, 'inventory.pk', None)
}
}
return defaults
def get_workflow_job_template_data(self, obj):
return dict(name=obj.name, id=obj.id, description=obj.description)

View File

@ -93,9 +93,8 @@ function atLaunchTemplateCtrl (
$state.go('workflowResults', { id: data.workflow_job }, { reload: true });
});
} else {
launchData.data.defaults = {
extra_vars: wfjtData.data.extra_vars
};
launchData.data.defaults.extra_vars = wfjtData.data.extra_vars;
const promptData = {
launchConf: selectedWorkflowJobTemplate.getLaunchConf(),
launchOptions: launchOptions.data,

View File

@ -1,7 +1,6 @@
/* eslint camelcase: 0 */
let Base;
let $http;
let $q;
function optionsLaunch (id) {
const req = {
@ -13,19 +12,16 @@ function optionsLaunch (id) {
}
function getLaunch (id) {
const urls = [
`${this.path}${id}/`,
`${this.path}${id}/launch/`,
];
const req = {
method: 'GET',
url: `${this.path}${id}/launch/`
};
const promises = urls.map(url => $http({ method: 'GET', url }));
return $http(req)
.then(res => {
this.model.launch.GET = res.data;
return $q.all(promises)
.then(([res, launchRes]) => {
this.model.GET = res.data;
this.model.launch.GET = launchRes.data;
return launchRes;
return res;
});
}
@ -52,28 +48,7 @@ function getSurveyQuestions (id) {
}
function getLaunchConf () {
// We may need api updates to align /:id/launch data with what is returned for job templates.
// For now, we splice values from the different endpoints to get the launchData we need.
const {
ask_inventory_on_launch,
ask_variables_on_launch,
survey_enabled,
} = this.model.GET;
const {
can_start_without_user_input,
variables_needed_to_start,
} = this.model.launch.GET;
const launchConf = {
ask_inventory_on_launch,
ask_variables_on_launch,
can_start_without_user_input,
survey_enabled,
variables_needed_to_start,
};
return launchConf;
return this.model.launch.GET;
}
function canLaunchWithoutPrompt () {
@ -104,10 +79,9 @@ function WorkflowJobTemplateModel (method, resource, config) {
return this.create(method, resource, config);
}
function WorkflowJobTemplateModelLoader (BaseModel, _$http_, _$q_) {
function WorkflowJobTemplateModelLoader (BaseModel, _$http_) {
Base = BaseModel;
$http = _$http_;
$q = _$q_;
return WorkflowJobTemplateModel;
}
@ -115,7 +89,6 @@ function WorkflowJobTemplateModelLoader (BaseModel, _$http_, _$q_) {
WorkflowJobTemplateModelLoader.$inject = [
'BaseModel',
'$http',
'$q',
];
export default WorkflowJobTemplateModelLoader;