1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

remove the rest of templates list code and update organization tempaltes list to using new code

This commit is contained in:
John Mitchell 2018-04-02 17:09:08 -04:00
parent e492043819
commit a1b7d86981
No known key found for this signature in database
GPG Key ID: FE6A9B5BD4EB5C94
4 changed files with 73 additions and 134 deletions

View File

@ -0,0 +1,65 @@
import { N_ } from '../../../src/i18n';
import templatesListController from '../templatesList.controller';
import indexController from '../index.controller';
const indexTemplate = require('~features/templates/index.view.html');
const templatesListTemplate = require('~features/templates/templatesList.view.html');
export default {
url: "/:organization_id/job_templates",
name: 'organizations.job_templates',
params: {
template_search: {
dynamic: true,
value: {
type: 'workflow_job_template,job_template',
},
}
},
ncyBreadcrumb: {
label: N_("JOB TEMPLATES")
},
views: {
'form': {
templateUrl: indexTemplate,
controller: indexController,
controllerAs: 'vm'
},
'templatesList@organizations.job_templates': {
controller: templatesListController,
templateUrl: templatesListTemplate,
controllerAs: 'vm',
}
},
resolve: {
resolvedModels: [
'JobTemplateModel',
'WorkflowJobTemplateModel',
(JobTemplate, WorkflowJobTemplate) => {
const models = [
new JobTemplate(['options']),
new WorkflowJobTemplate(['options']),
];
return Promise.all(models);
},
],
Dataset: [
'$stateParams',
'Wait',
'GetBasePath',
'QuerySet',
($stateParams, Wait, GetBasePath, qs) => {
const searchPath = GetBasePath('unified_job_templates');
const searchParam = _.assign($stateParams.template_search, {
or__project__organization: $stateParams.organization_id,
or__jobtemplate__inventory__organization: $stateParams.organization_id,
});
Wait('start');
return qs.search(searchPath, searchParam)
.finally(() => Wait('stop'));
}
],
}
};

View File

@ -10,6 +10,7 @@ export default {
template_search: {
dynamic: true,
value: {
type: 'workflow_job_template,job_template',
},
}
},

View File

@ -4,15 +4,16 @@
* All Rights Reserved
*************************************************/
import OrganizationsJobTemplatesRoute from '~features/templates/routes/organizationsTemplatesList.route';
import OrganizationsAdmins from './controllers/organizations-admins.controller';
import OrganizationsInventories from './controllers/organizations-inventories.controller';
import OrganizationsJobTemplates from './controllers/organizations-job-templates.controller';
import OrganizationsProjects from './controllers/organizations-projects.controller';
import OrganizationsTeams from './controllers/organizations-teams.controller';
import OrganizationsUsers from './controllers/organizations-users.controller';
import { N_ } from '../../i18n';
export default [{
let lists = [{
name: 'organizations.users',
url: '/:organization_id/users',
searchPrefix: 'user',
@ -215,78 +216,6 @@ export default [{
}
]
}
}, {
name: 'organizations.job_templates',
url: '/:organization_id/job_templates',
searchPrefix: 'job_template',
views: {
'form': {
controller: OrganizationsJobTemplates,
templateProvider: function(OrgJobTemplateList, generateList) {
let html = generateList.build({
list: OrgJobTemplateList,
mode: 'edit',
cancelButton: true
});
return generateList.wrapPanel(html);
},
},
},
params: {
template_search: {
value: {
or__project__organization: null,
or__inventory__organization: null,
page_size: 20
},
dynamic: true
}
},
data: {
activityStream: true,
activityStreamTarget: 'organization',
socket: {
"groups": {
"jobs": ["status_changed"]
}
}
},
ncyBreadcrumb: {
parent: "organizations.edit",
label: N_("JOB TEMPLATES")
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}],
OrgJobTemplateList: ['TemplateList', 'GetBasePath', '$stateParams', function(TemplateList) {
let list = _.cloneDeep(TemplateList);
delete list.actions;
// @issue Why is the delete action unavailable in this view?
delete list.fieldActions.delete;
delete list.fields.type;
list.listTitle = N_('Job Templates') + ` | {{ name }}`;
list.emptyListText = "This list is populated by job templates added from the&nbsp;<a ui-sref='templates.addJobTemplate'>Job Templates</a>&nbsp;section";
list.iterator = 'template';
list.name = 'job_templates';
list.basePath = "job_templates";
list.fields.smart_status.ngInclude = "'/static/partials/organizations-job-template-smart-status.html'";
list.fields.name.ngHref = '#/templates/job_template/{{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.template_search.or__project__organization = $stateParams.organization_id;
$stateParams.template_search.or__inventory__organization = $stateParams.organization_id;
return qs.search(path, $stateParams.template_search);
}
]
}
}, {
name: 'organizations.admins',
url: '/:organization_id/admins',
@ -355,3 +284,7 @@ export default [{
}]
}
}];
lists.push(OrganizationsJobTemplatesRoute);
export default lists;

View File

@ -1,60 +0,0 @@
import { N_ } from '../i18n';
export default {
url: "/templates",
name: 'projects.edit.templates',
params: {
template_search: {
value: {
page_size: '20',
project: '',
order_by: "-id"
}
}
},
ncyBreadcrumb: {
label: N_("JOB TEMPLATES")
},
views: {
// TODO: this controller was removed and replaced
// with the new features/templates controller
// this view should be updated with the new
// expanded list
'related': {
templateProvider: function(FormDefinition, GenerateForm) {
let html = GenerateForm.buildCollection({
mode: 'edit',
related: 'templates',
form: typeof(FormDefinition) === 'function' ?
FormDefinition() : FormDefinition
});
return html;
},
controller: 'TemplatesListController'
}
},
resolve: {
ListDefinition: ['TemplateList', '$transition$', (TemplateList, $transition$) => {
let id = $transition$.params().project_id;
TemplateList.actions.add.ngClick = `$state.go('templates.addJobTemplate', {project_id: ${id}})`;
TemplateList.basePath = 'job_templates';
return TemplateList;
}],
Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope',
(list, qs, $stateParams, GetBasePath, $interpolate, $rootScope) => {
// allow related list definitions to use interpolated $rootScope / $stateParams in basePath field
let path, interpolator;
if (GetBasePath(list.basePath)) {
path = GetBasePath(list.basePath);
} else {
interpolator = $interpolate(list.basePath);
path = interpolator({ $rootScope: $rootScope, $stateParams: $stateParams });
}
let project_id = $stateParams.project_id;
$stateParams[`${list.iterator}_search`].project = project_id;
path = GetBasePath('job_templates');
return qs.search(path, $stateParams[`${list.iterator}_search`]);
}
]
}
};