From e49204381919fbbb3ed2770169d58add1b5f1305 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Mon, 2 Apr 2018 13:57:56 -0400 Subject: [PATCH] utilize new list on projects template list --- .../features/templates/index.controller.js | 12 ++ awx/ui/client/features/templates/index.js | 2 - .../client/features/templates/index.view.html | 10 ++ .../routes/projectsTemplatesList.route.js | 55 +++++++++ .../templatesList.route.js} | 23 ++-- ...troller.js => templatesList.controller.js} | 0 .../templates/templatesList.view.html | 114 ++++++++++++++++++ awx/ui/client/src/projects/main.js | 3 +- .../templates/labels/labelsList.directive.js | 6 +- awx/ui/client/src/templates/main.js | 2 +- 10 files changed, 211 insertions(+), 16 deletions(-) create mode 100644 awx/ui/client/features/templates/index.controller.js create mode 100644 awx/ui/client/features/templates/index.view.html create mode 100644 awx/ui/client/features/templates/routes/projectsTemplatesList.route.js rename awx/ui/client/features/templates/{list.route.js => routes/templatesList.route.js} (72%) rename awx/ui/client/features/templates/{list-templates.controller.js => templatesList.controller.js} (100%) create mode 100644 awx/ui/client/features/templates/templatesList.view.html diff --git a/awx/ui/client/features/templates/index.controller.js b/awx/ui/client/features/templates/index.controller.js new file mode 100644 index 0000000000..fd0850d582 --- /dev/null +++ b/awx/ui/client/features/templates/index.controller.js @@ -0,0 +1,12 @@ +function IndexTemplatesController (strings, dataset) { + let vm = this; + vm.strings = strings; + vm.count = dataset.data.count; +} + +IndexTemplatesController.$inject = [ + 'TemplatesStrings', + 'Dataset' +]; + +export default IndexTemplatesController; diff --git a/awx/ui/client/features/templates/index.js b/awx/ui/client/features/templates/index.js index a2f6ab25a4..fd0a49b45a 100644 --- a/awx/ui/client/features/templates/index.js +++ b/awx/ui/client/features/templates/index.js @@ -1,11 +1,9 @@ import TemplatesStrings from './templates.strings'; -import ListController from './list-templates.controller'; const MODULE_NAME = 'at.features.templates'; angular .module(MODULE_NAME, []) - .controller('ListController', ListController) .service('TemplatesStrings', TemplatesStrings); export default MODULE_NAME; diff --git a/awx/ui/client/features/templates/index.view.html b/awx/ui/client/features/templates/index.view.html new file mode 100644 index 0000000000..6323fd8129 --- /dev/null +++ b/awx/ui/client/features/templates/index.view.html @@ -0,0 +1,10 @@ +
+ + + {{:: vm.strings.get('list.PANEL_TITLE') }} +
+ {{ vm.count }} +
+
+
+
diff --git a/awx/ui/client/features/templates/routes/projectsTemplatesList.route.js b/awx/ui/client/features/templates/routes/projectsTemplatesList.route.js new file mode 100644 index 0000000000..2fa97411b8 --- /dev/null +++ b/awx/ui/client/features/templates/routes/projectsTemplatesList.route.js @@ -0,0 +1,55 @@ +import { N_ } from '../../../src/i18n'; +import templatesListController from '../templatesList.controller'; + +const templatesListTemplate = require('~features/templates/templatesList.view.html'); + +export default { + url: "/templates", + name: 'projects.edit.templates', + params: { + template_search: { + dynamic: true, + value: { + }, + } + }, + ncyBreadcrumb: { + label: N_("JOB TEMPLATES") + }, + views: { + 'related': { + 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, { + jobtemplate__project: $stateParams.project_id }); + + Wait('start'); + return qs.search(searchPath, searchParam) + .finally(() => Wait('stop')); + } + ], + } +}; diff --git a/awx/ui/client/features/templates/list.route.js b/awx/ui/client/features/templates/routes/templatesList.route.js similarity index 72% rename from awx/ui/client/features/templates/list.route.js rename to awx/ui/client/features/templates/routes/templatesList.route.js index e08b2fc863..8a912776cc 100644 --- a/awx/ui/client/features/templates/list.route.js +++ b/awx/ui/client/features/templates/routes/templatesList.route.js @@ -1,16 +1,14 @@ -import ListController from './list-templates.controller'; -const listTemplate = require('~features/templates/list.view.html'); -import { N_ } from '../../src/i18n'; +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 { name: 'templates', route: '/templates', ncyBreadcrumb: { - // TODO: this would be best done with our - // strings file pattern, but it's not possible to - // get a handle on this route within a DI based - // on the state tree generation as present in - // src/templates currently label: N_("TEMPLATES") }, data: { @@ -33,8 +31,13 @@ export default { searchPrefix: 'template', views: { '@': { - controller: ListController, - templateUrl: listTemplate, + templateUrl: indexTemplate, + controller: indexController, + controllerAs: 'vm' + }, + 'templatesList@templates': { + controller: templatesListController, + templateUrl: templatesListTemplate, controllerAs: 'vm', } }, diff --git a/awx/ui/client/features/templates/list-templates.controller.js b/awx/ui/client/features/templates/templatesList.controller.js similarity index 100% rename from awx/ui/client/features/templates/list-templates.controller.js rename to awx/ui/client/features/templates/templatesList.controller.js diff --git a/awx/ui/client/features/templates/templatesList.view.html b/awx/ui/client/features/templates/templatesList.view.html new file mode 100644 index 0000000000..9b344955a9 --- /dev/null +++ b/awx/ui/client/features/templates/templatesList.view.html @@ -0,0 +1,114 @@ + +
+ + +
+ + +
+
+ + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
+
+ + +
diff --git a/awx/ui/client/src/projects/main.js b/awx/ui/client/src/projects/main.js index 94eee1de34..8f186e5458 100644 --- a/awx/ui/client/src/projects/main.js +++ b/awx/ui/client/src/projects/main.js @@ -13,7 +13,8 @@ import { N_ } from '../i18n'; import GetProjectPath from './factories/get-project-path.factory'; import GetProjectIcon from './factories/get-project-icon.factory'; import GetProjectToolTip from './factories/get-project-tool-tip.factory'; -import ProjectsTemplatesRoute from './projects-templates.route'; + +import ProjectsTemplatesRoute from '~features/templates/routes/projectsTemplatesList.route'; import ProjectsStrings from './projects.strings'; export default diff --git a/awx/ui/client/src/templates/labels/labelsList.directive.js b/awx/ui/client/src/templates/labels/labelsList.directive.js index 8402a14dd2..3763998427 100644 --- a/awx/ui/client/src/templates/labels/labelsList.directive.js +++ b/awx/ui/client/src/templates/labels/labelsList.directive.js @@ -93,8 +93,10 @@ export default }; if (scope.$parent.$parent.template) { - scope.labels = scope.$parent.$parent.template.summary_fields.labels.results.slice(0, 5); - scope.count = scope.$parent.$parent.template.summary_fields.labels.count; + if (_.has(scope, '$parent.$parent.template.summary_fields.labels.results')) { + scope.labels = scope.$parent.$parent.template.summary_fields.labels.results.slice(0, 5); + scope.count = scope.$parent.$parent.template.summary_fields.labels.count; + } } else if (scope.$parent.$parent.job) { if (_.has(scope, '$parent.$parent.job.summary_fields.labels.results')) { scope.labels = scope.$parent.$parent.job.summary_fields.labels.results.slice(0, 5); diff --git a/awx/ui/client/src/templates/main.js b/awx/ui/client/src/templates/main.js index f9280252a0..35f8cd5965 100644 --- a/awx/ui/client/src/templates/main.js +++ b/awx/ui/client/src/templates/main.js @@ -19,7 +19,7 @@ import WorkflowForm from './workflows.form'; import InventorySourcesList from './inventory-sources.list'; import TemplateList from './templates.list'; import TemplatesStrings from './templates.strings'; -import listRoute from '~features/templates/list.route.js'; +import listRoute from '~features/templates/routes/templatesList.route.js'; import templateCompletedJobsRoute from '~features/jobs/routes/templateCompletedJobs.route.js'; export default