diff --git a/awx/ui/client/features/templates/routes/portalModeTemplatesList.route.js b/awx/ui/client/features/templates/routes/portalModeTemplatesList.route.js new file mode 100644 index 0000000000..55187b5a98 --- /dev/null +++ b/awx/ui/client/features/templates/routes/portalModeTemplatesList.route.js @@ -0,0 +1,79 @@ +import { templateUrl } from '../../../src/shared/template-url/template-url.factory'; +import { N_ } from '../../../src/i18n'; +import templatesListController from '../templatesList.controller'; + +const templatesListTemplate = require('~features/templates/templatesList.view.html'); + +export default { + name: 'portalMode', + url: '/portal', + reloadOnSearch: true, + ncyBreadcrumb: { + label: N_('MY VIEW') + }, + data: { + socket: { + "groups": { + "jobs": ["status_changed"] + } + } + }, + params: { + template_search: { + dynamic: true, + value: { + type: 'workflow_job_template,job_template', + }, + } + }, + searchPrefix: 'template', + views: { + '@': { + templateUrl: templateUrl('portal-mode/portal-mode-layout'), + controller: ['$scope', '$state', + function($scope, $state) { + + $scope.filterUser = function() { + $state.go('portalMode.myJobs'); + }; + + $scope.filterAll = function() { + $state.go('portalMode.allJobs'); + }; + } + ] + }, + 'templates@portalMode': { + templateUrl: templatesListTemplate, + controller: templatesListController, + 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 searchParam = $stateParams.template_search; + const searchPath = GetBasePath('unified_job_templates'); + + Wait('start'); + return qs.search(searchPath, searchParam) + .finally(() => Wait('stop')); + } + ], + } +}; diff --git a/awx/ui/client/src/portal-mode/main.js b/awx/ui/client/src/portal-mode/main.js index e4e1dc2a2c..d74c97ddd9 100644 --- a/awx/ui/client/src/portal-mode/main.js +++ b/awx/ui/client/src/portal-mode/main.js @@ -4,16 +4,14 @@ * All Rights Reserved *************************************************/ -import route from './portal-mode.route'; +// import route from './portal-mode.route'; +import templatesRoute from '~features/templates/routes/portalModeTemplatesList.route.js'; import myJobsRoute from '~features/jobs/routes/portalModeMyJobs.route.js'; import allJobsRoute from '~features/jobs/routes/portalModeAllJobs.route.js'; -import PortalJobTemplateList from './portal-job-templates.list'; - export default angular.module('portalMode', []) - .factory('PortalJobTemplateList', PortalJobTemplateList) .run(['$stateExtender', function($stateExtender){ - $stateExtender.addState(route); + $stateExtender.addState(templatesRoute); $stateExtender.addState(myJobsRoute); $stateExtender.addState(allJobsRoute); }]); diff --git a/awx/ui/client/src/portal-mode/portal-job-templates.list.js b/awx/ui/client/src/portal-mode/portal-job-templates.list.js deleted file mode 100644 index c966a2da3f..0000000000 --- a/awx/ui/client/src/portal-mode/portal-job-templates.list.js +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************* - * Copyright (c) 2015 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - - -export default ['i18n', function(i18n) { - return { - - name: 'job_templates', - iterator: 'job_template', - editTitle: i18n._('JOB TEMPLATES'), - listTitle: i18n._('JOB TEMPLATES'), - index: false, - hover: true, - well: true, - emptyListText: i18n._('There are no job templates to display at this time'), - searchBarFullWidth: true, - fields: { - name: { - key: true, - label: i18n._('Name'), - columnClass: 'col-lg-5 col-md-5 col-sm-9 col-xs-8', - linkTo: '/#/templates/job_template/{{job_template.id}}', - awToolTip: '{{job_template.description | sanitize}}', - dataPlacement: 'top' - } - }, - - actions: { - }, - - fieldActions: { - submit: { - // uses the at-launch-template directive - launch: true - } - } - };}]; diff --git a/awx/ui/client/src/portal-mode/portal-mode-job-templates.controller.js b/awx/ui/client/src/portal-mode/portal-mode-job-templates.controller.js deleted file mode 100644 index 14293871dc..0000000000 --- a/awx/ui/client/src/portal-mode/portal-mode-job-templates.controller.js +++ /dev/null @@ -1,15 +0,0 @@ -/************************************************* - * Copyright (c) 2016 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - -export function PortalModeJobTemplatesController($scope, PortalJobTemplateList, Dataset) { - var list = PortalJobTemplateList; - // search init - $scope.list = list; - $scope[`${list.iterator}_dataset`] = Dataset.data; - $scope[list.name] = $scope[`${list.iterator}_dataset`].results; -} - -PortalModeJobTemplatesController.$inject = ['$scope','PortalJobTemplateList', 'job_templatesDataset']; diff --git a/awx/ui/client/src/portal-mode/portal-mode-layout.partial.html b/awx/ui/client/src/portal-mode/portal-mode-layout.partial.html index d9eade91b0..417e97e1bc 100644 --- a/awx/ui/client/src/portal-mode/portal-mode-layout.partial.html +++ b/awx/ui/client/src/portal-mode/portal-mode-layout.partial.html @@ -1,9 +1,18 @@