Merge pull request #5214 from mabashian/5135-org-job-templates

Fixed up organizations/job templates list
This commit is contained in:
Michael Abashian 2017-02-08 11:59:20 -05:00 committed by GitHub
commit 56303c144c
3 changed files with 34 additions and 16 deletions

View File

@ -6,11 +6,11 @@
export default ['$scope', '$rootScope', '$location', '$log',
'$stateParams', 'Rest', 'Alert', 'Prompt', 'ReturnToCaller', 'ClearScope', 'ProcessErrors',
'GetBasePath', 'JobTemplateForm', 'InitiatePlaybookRun', 'Wait',
'GetBasePath', 'JobTemplateForm', 'InitiatePlaybookRun', 'Wait', 'TemplateCopyService',
'$compile', '$state', 'OrgJobTemplateList', 'OrgJobTemplateDataset', 'QuerySet',
function($scope, $rootScope, $location, $log,
$stateParams, Rest, Alert, Prompt, ReturnToCaller, ClearScope, ProcessErrors,
GetBasePath, JobTemplateForm, InitiatePlaybookRun, Wait,
GetBasePath, JobTemplateForm, InitiatePlaybookRun, Wait, TemplateCopyService,
$compile, $state, OrgJobTemplateList, Dataset, qs) {
var list = OrgJobTemplateList,
@ -71,12 +71,8 @@ export default ['$scope', '$rootScope', '$location', '$log',
});
}
$scope.addJobTemplate = function() {
$state.go('jobTemplates.add');
};
$scope.editJobTemplate = function(id) {
$state.go('jobTemplates.edit', { id: id });
$state.go('templates.editJobTemplate', { job_template_id: id });
};
$scope.submitJob = function(id) {
@ -87,8 +83,23 @@ export default ['$scope', '$rootScope', '$location', '$log',
$state.go('jobTemplateSchedules', { id: id });
};
$scope.formCancel = function() {
$state.go('organizations');
$scope.copyTemplate = function(id) {
Wait('start');
TemplateCopyService.get(id)
.success(function(res){
TemplateCopyService.set(res)
.success(function(res){
Wait('stop');
if(res.type && res.type === 'job_template') {
$state.go('templates.editJobTemplate', {job_template_id: res.id}, {reload: true});
}
});
})
.error(function(res, status){
ProcessErrors($rootScope, res, status, null, {hdr: 'Error!',
msg: 'Call failed. Return status: '+ status});
});
};
}

View File

@ -267,7 +267,7 @@ export default [{
},
},
params: {
job_template_search: {
template_search: {
value: {
project__organization: null
}
@ -295,20 +295,27 @@ export default [{
delete list.actions;
// @issue Why is the delete action unavailable in this view?
delete list.fieldActions.delete;
list.emptyListText = "This list is populated by job templates added from the&nbsp;<a ui-sref='jobTemplates.add'>Job Templates</a>&nbsp;section";
delete list.fields.type;
list.listTitle = N_('Job Templates');
list.emptyListText = "This list is populated by job templates added from the&nbsp;<a ui-sref='templates.addJobTemplate'>Job Templates</a>&nbsp;section";
list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12";
list.iterator = 'job_template';
list.iterator = 'template';
list.name = 'job_templates';
list.basePath = "job_templates";
list.fields.type.ngBind = "job_template.type_label";
list.fields.smart_status.ngInclude = "'/static/partials/organizations-job-template-smart-status.html'";
list.fields.name.ngHref = '#/templates/job_template/{{template.id}}';
list.fieldActions.submit.ngClick = 'submitJob(template.id)';
list.fieldActions.schedule.ngClick = 'scheduleJob(template.id)';
list.fieldActions.copy.ngClick = 'copyTemplate(template.id)';
list.fieldActions.edit.ngClick = "editJobTemplate(template.id)";
list.fieldActions.view.ngClick = "editJobTemplate(template.id)";
return list;
}],
OrgJobTemplateDataset: ['OrgJobTemplateList', 'QuerySet', '$stateParams', 'GetBasePath',
function(list, qs, $stateParams, GetBasePath) {
let path = GetBasePath(list.name);
$stateParams.job_template_search.project__organization = $stateParams.organization_id;
return qs.search(path, $stateParams.job_template_search);
$stateParams.template_search.project__organization = $stateParams.organization_id;
return qs.search(path, $stateParams.template_search);
}
]
}

View File

@ -1 +1 @@
<aw-smart-status jobs="job_template.summary_fields.recent_jobs"></aw-smart-status>
<aw-smart-status jobs="template.summary_fields.recent_jobs"></aw-smart-status>