From 2f8b668ef914785e913aa313b3c9ded235b18c4c Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Mon, 9 Jul 2018 13:53:46 -0400 Subject: [PATCH] fix portal mode issues --- awx/ui/client/features/_index.less | 3 +- awx/ui/client/features/index.js | 4 +- .../client/features/jobs/index.controller.js | 2 +- .../features/jobs/jobsList.controller.js | 4 ++ .../client/features/jobs/jobsList.view.html | 7 +-- .../portalMode/_index.less} | 15 ++++++ .../features/portalMode/index.controller.js | 27 ++++++++++ awx/ui/client/features/portalMode/index.js | 18 +++++++ .../features/portalMode/index.view.html | 54 +++++++++++++++++++ .../features/portalMode/portalMode.strings.js | 15 ++++++ .../routes/portalModeAllJobs.route.js | 2 +- .../routes/portalModeMyJobs.route.js | 2 +- .../routes/portalModeTemplatesList.route.js | 25 +++------ .../features/templates/index.controller.js | 2 +- .../templates/templatesList.controller.js | 4 ++ .../templates/templatesList.view.html | 11 ++-- awx/ui/client/lib/theme/index.less | 1 - awx/ui/client/src/app.js | 2 - awx/ui/client/src/portal-mode/main.js | 17 ------ .../portal-mode-layout.partial.html | 52 ------------------ 20 files changed, 164 insertions(+), 103 deletions(-) rename awx/ui/client/{src/portal-mode/portal-mode.block.less => features/portalMode/_index.less} (81%) create mode 100644 awx/ui/client/features/portalMode/index.controller.js create mode 100644 awx/ui/client/features/portalMode/index.js create mode 100644 awx/ui/client/features/portalMode/index.view.html create mode 100644 awx/ui/client/features/portalMode/portalMode.strings.js rename awx/ui/client/features/{jobs => portalMode}/routes/portalModeAllJobs.route.js (95%) rename awx/ui/client/features/{jobs => portalMode}/routes/portalModeMyJobs.route.js (95%) rename awx/ui/client/features/{templates => portalMode}/routes/portalModeTemplatesList.route.js (70%) delete mode 100644 awx/ui/client/src/portal-mode/main.js delete mode 100644 awx/ui/client/src/portal-mode/portal-mode-layout.partial.html diff --git a/awx/ui/client/features/_index.less b/awx/ui/client/features/_index.less index 04be5b31bb..1c03282f81 100644 --- a/awx/ui/client/features/_index.less +++ b/awx/ui/client/features/_index.less @@ -1,2 +1,3 @@ +@import 'portalMode/_index'; @import 'output/_index'; -@import 'users/tokens/_index'; +@import 'users/tokens/_index'; \ No newline at end of file diff --git a/awx/ui/client/features/index.js b/awx/ui/client/features/index.js index 0a6ec3864c..f206a206bc 100644 --- a/awx/ui/client/features/index.js +++ b/awx/ui/client/features/index.js @@ -8,6 +8,7 @@ import atFeaturesOutput from '~features/output'; import atFeaturesTemplates from '~features/templates'; import atFeaturesUsers from '~features/users'; import atFeaturesJobs from '~features/jobs'; +import atFeaturesPortalMode from '~features/portalMode'; const MODULE_NAME = 'at.features'; @@ -21,7 +22,8 @@ angular.module(MODULE_NAME, [ atFeaturesUsers, atFeaturesJobs, atFeaturesOutput, - atFeaturesTemplates + atFeaturesTemplates, + atFeaturesPortalMode, ]); export default MODULE_NAME; diff --git a/awx/ui/client/features/jobs/index.controller.js b/awx/ui/client/features/jobs/index.controller.js index 3cdf3026cb..3a2f0b34b1 100644 --- a/awx/ui/client/features/jobs/index.controller.js +++ b/awx/ui/client/features/jobs/index.controller.js @@ -3,7 +3,7 @@ function IndexJobsController ($scope, strings, dataset) { vm.strings = strings; vm.count = dataset.data.count; - $scope.$on('updateDataset', (e, { count }) => { + $scope.$on('updateCount', (e, count) => { if (count) { vm.count = count; } diff --git a/awx/ui/client/features/jobs/jobsList.controller.js b/awx/ui/client/features/jobs/jobsList.controller.js index 2780e63ce1..6284bae7bd 100644 --- a/awx/ui/client/features/jobs/jobsList.controller.js +++ b/awx/ui/client/features/jobs/jobsList.controller.js @@ -35,9 +35,11 @@ function ListJobsController ( $scope.collection = { iterator, basePath: 'unified_jobs' }; $scope[key] = Dataset.data; $scope[name] = Dataset.data.results; + $scope.$emit('updateCount', Dataset.data.count, 'jobs'); $scope.$on('updateDataset', (e, dataset) => { $scope[key] = dataset; $scope[name] = dataset.results; + $scope.$emit('updateCount', dataset.count, 'jobs'); }); $scope.$on('ws-jobs', () => { if (!launchModalOpen) { @@ -60,6 +62,8 @@ function ListJobsController ( vm.emptyListReason = strings.get('list.NO_RUNNING'); } + vm.isPortalMode = $state.includes('portalMode'); + vm.jobTypes = mapChoices(unifiedJob.options('actions.GET.type.choices')); vm.getSref = ({ type, id }) => { diff --git a/awx/ui/client/features/jobs/jobsList.view.html b/awx/ui/client/features/jobs/jobsList.view.html index 72d40c6130..67103ea2da 100644 --- a/awx/ui/client/features/jobs/jobsList.view.html +++ b/awx/ui/client/features/jobs/jobsList.view.html @@ -9,7 +9,8 @@ dataset="job_dataset" collection="collection" search-tags="searchTags" - query-set="querySet"> + query-set="querySet" + search-bar-full-width="vm.isPortalMode"> @@ -74,7 +75,7 @@ ng-show="job.summary_fields.user_capabilities.start"> diff --git a/awx/ui/client/src/portal-mode/portal-mode.block.less b/awx/ui/client/features/portalMode/_index.less similarity index 81% rename from awx/ui/client/src/portal-mode/portal-mode.block.less rename to awx/ui/client/features/portalMode/_index.less index 7a8fb934d8..ffaae6acfe 100644 --- a/awx/ui/client/src/portal-mode/portal-mode.block.less +++ b/awx/ui/client/features/portalMode/_index.less @@ -27,6 +27,21 @@ .OnePlusOne-panelHeader; } + +.PortalMode-headerContainer { + display: flex; + align-items: center; + margin-bottom: 20px; + + .at-Panel-heading { + margin-bottom: 0; + } + + .FormToggle-container { + padding-bottom: 0; + } +} + .PortalMode-filterHolder { position: absolute; right: 1px; diff --git a/awx/ui/client/features/portalMode/index.controller.js b/awx/ui/client/features/portalMode/index.controller.js new file mode 100644 index 0000000000..05889bf1a5 --- /dev/null +++ b/awx/ui/client/features/portalMode/index.controller.js @@ -0,0 +1,27 @@ +function IndexTemplatesController ($scope, $state, strings) { + const vm = this; + vm.strings = strings; + + $scope.filterUser = () => { + $state.go('portalMode.myJobs'); + }; + $scope.filterAll = () => { + $state.go('portalMode.allJobs'); + }; + + $scope.$on('updateCount', (e, count, resource) => { + if (resource === 'jobs') { + vm.jobsCount = count; + } else if (resource === 'templates') { + vm.templatesCount = count; + } + }); +} + +IndexTemplatesController.$inject = [ + '$scope', + '$state', + 'PortalModeStrings', +]; + +export default IndexTemplatesController; diff --git a/awx/ui/client/features/portalMode/index.js b/awx/ui/client/features/portalMode/index.js new file mode 100644 index 0000000000..e09c6e35e1 --- /dev/null +++ b/awx/ui/client/features/portalMode/index.js @@ -0,0 +1,18 @@ +import PortalModeStrings from './portalMode.strings'; + +import templatesRoute from './routes/portalModeTemplatesList.route'; +import myJobsRoute from './routes/portalModeMyJobs.route'; +import allJobsRoute from './routes/portalModeAllJobs.route'; + +const MODULE_NAME = 'at.features.portalMode'; + +angular + .module(MODULE_NAME, []) + .service('PortalModeStrings', PortalModeStrings) + .run(['$stateExtender', ($stateExtender) => { + $stateExtender.addState(templatesRoute); + $stateExtender.addState(myJobsRoute); + $stateExtender.addState(allJobsRoute); + }]); + +export default MODULE_NAME; diff --git a/awx/ui/client/features/portalMode/index.view.html b/awx/ui/client/features/portalMode/index.view.html new file mode 100644 index 0000000000..2bb9da50b1 --- /dev/null +++ b/awx/ui/client/features/portalMode/index.view.html @@ -0,0 +1,54 @@ +
+
+
+ +
+ + +
+
+
+
+ +
+
+ + +
+
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
+
+
diff --git a/awx/ui/client/features/portalMode/portalMode.strings.js b/awx/ui/client/features/portalMode/portalMode.strings.js new file mode 100644 index 0000000000..c1cdd893fd --- /dev/null +++ b/awx/ui/client/features/portalMode/portalMode.strings.js @@ -0,0 +1,15 @@ +function PortalModeStrings (BaseString) { + BaseString.call(this, 'portalMode'); + + const { t } = this; + const ns = this.portalMode; + + ns.list = { + TEMPLATES_PANEL_TITLE: t.s('JOB TEMPLATES'), + JOBS_PANEL_TITLE: t.s('JOBS'), + }; +} + +PortalModeStrings.$inject = ['BaseStringService']; + +export default PortalModeStrings; diff --git a/awx/ui/client/features/jobs/routes/portalModeAllJobs.route.js b/awx/ui/client/features/portalMode/routes/portalModeAllJobs.route.js similarity index 95% rename from awx/ui/client/features/jobs/routes/portalModeAllJobs.route.js rename to awx/ui/client/features/portalMode/routes/portalModeAllJobs.route.js index cada35d56b..4d2c23e2ea 100644 --- a/awx/ui/client/features/jobs/routes/portalModeAllJobs.route.js +++ b/awx/ui/client/features/portalMode/routes/portalModeAllJobs.route.js @@ -1,4 +1,4 @@ -import jobsListController from '../jobsList.controller'; +import jobsListController from '../../jobs/jobsList.controller'; const jobsListTemplate = require('~features/jobs/jobsList.view.html'); diff --git a/awx/ui/client/features/jobs/routes/portalModeMyJobs.route.js b/awx/ui/client/features/portalMode/routes/portalModeMyJobs.route.js similarity index 95% rename from awx/ui/client/features/jobs/routes/portalModeMyJobs.route.js rename to awx/ui/client/features/portalMode/routes/portalModeMyJobs.route.js index 4d0909d66b..487fffb998 100644 --- a/awx/ui/client/features/jobs/routes/portalModeMyJobs.route.js +++ b/awx/ui/client/features/portalMode/routes/portalModeMyJobs.route.js @@ -1,4 +1,4 @@ -import jobsListController from '../jobsList.controller'; +import jobsListController from '../../jobs/jobsList.controller'; const jobsListTemplate = require('~features/jobs/jobsList.view.html'); diff --git a/awx/ui/client/features/templates/routes/portalModeTemplatesList.route.js b/awx/ui/client/features/portalMode/routes/portalModeTemplatesList.route.js similarity index 70% rename from awx/ui/client/features/templates/routes/portalModeTemplatesList.route.js rename to awx/ui/client/features/portalMode/routes/portalModeTemplatesList.route.js index 55187b5a98..8255cfb169 100644 --- a/awx/ui/client/features/templates/routes/portalModeTemplatesList.route.js +++ b/awx/ui/client/features/portalMode/routes/portalModeTemplatesList.route.js @@ -1,8 +1,9 @@ -import { templateUrl } from '../../../src/shared/template-url/template-url.factory'; import { N_ } from '../../../src/i18n'; -import templatesListController from '../templatesList.controller'; +import templatesListController from '../../templates/templatesList.controller'; +import indexController from '../index.controller'; const templatesListTemplate = require('~features/templates/templatesList.view.html'); +const indexTemplate = require('~features/portalMode/index.view.html'); export default { name: 'portalMode', @@ -13,8 +14,8 @@ export default { }, data: { socket: { - "groups": { - "jobs": ["status_changed"] + groups: { + jobs: ['status_changed'] } } }, @@ -29,19 +30,9 @@ export default { 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'); - }; - } - ] + templateUrl: indexTemplate, + controller: indexController, + controllerAs: 'vm' }, 'templates@portalMode': { templateUrl: templatesListTemplate, diff --git a/awx/ui/client/features/templates/index.controller.js b/awx/ui/client/features/templates/index.controller.js index 06723a6ed5..42eb2e8749 100644 --- a/awx/ui/client/features/templates/index.controller.js +++ b/awx/ui/client/features/templates/index.controller.js @@ -3,7 +3,7 @@ function IndexTemplatesController ($scope, strings, dataset) { vm.strings = strings; vm.count = dataset.data.count; - $scope.$on('updateDataset', (e, { count }) => { + $scope.$on('updateCount', (e, count) => { if (count) { vm.count = count; } diff --git a/awx/ui/client/features/templates/templatesList.controller.js b/awx/ui/client/features/templates/templatesList.controller.js index fe0a8d31af..87cb639350 100644 --- a/awx/ui/client/features/templates/templatesList.controller.js +++ b/awx/ui/client/features/templates/templatesList.controller.js @@ -61,6 +61,7 @@ function ListTemplatesController( }; $scope.template_dataset = Dataset.data; $scope.templates = Dataset.data.results; + $scope.$emit('updateCount', Dataset.data.count, 'templates'); $scope.$watch('$state.params', function(newValue, oldValue) { const job_template_id = _.get($state.params, 'job_template_id'); @@ -74,6 +75,7 @@ function ListTemplatesController( $scope.$on('updateDataset', (e, dataset) => { $scope.template_dataset = dataset; $scope.templates = dataset.results; + $scope.$emit('updateCount', dataset.count, 'templates'); }); $scope.$on(`ws-jobs`, () => { @@ -101,6 +103,8 @@ function ListTemplatesController( } }; + vm.isPortalMode = $state.includes('portalMode'); + vm.scheduleTemplate = template => { if (!template) { Alert(strings.get('error.SCHEDULE'), strings.get('alert.MISSING_PARAMETER')); diff --git a/awx/ui/client/features/templates/templatesList.view.html b/awx/ui/client/features/templates/templatesList.view.html index e047b02ab6..63f5f667ca 100644 --- a/awx/ui/client/features/templates/templatesList.view.html +++ b/awx/ui/client/features/templates/templatesList.view.html @@ -9,9 +9,10 @@ dataset="template_dataset" collection="collection" search-tags="searchTags" - query-set="querySet"> + query-set="querySet" + search-bar-full-width="vm.isPortalMode"> -
+
diff --git a/awx/ui/client/lib/theme/index.less b/awx/ui/client/lib/theme/index.less index caf02e2882..00cc8ddb47 100644 --- a/awx/ui/client/lib/theme/index.less +++ b/awx/ui/client/lib/theme/index.less @@ -90,7 +90,6 @@ @import '../../src/notifications/notifications.block.less'; @import '../../src/organizations/linkout/addUsers/addUsers.block.less'; @import '../../src/organizations/orgcards.block.less'; -@import '../../src/portal-mode/portal-mode.block.less'; @import '../../src/scheduler/repeatFrequencyOptions.block.less'; @import '../../src/scheduler/schedulerForm.block.less'; @import '../../src/scheduler/schedulerFormDetail.block.less'; diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 828bd1fc7f..257851337d 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -10,7 +10,6 @@ if ($basePath) { } import start from './app.start'; -import portalMode from './portal-mode/main'; import systemTracking from './system-tracking/main'; import inventoriesHosts from './inventories-hosts/main'; import inventoryScripts from './inventory-scripts/main'; @@ -86,7 +85,6 @@ angular jobSubmission.name, notifications.name, Templates.name, - portalMode.name, teams.name, users.name, projects.name, diff --git a/awx/ui/client/src/portal-mode/main.js b/awx/ui/client/src/portal-mode/main.js deleted file mode 100644 index d74c97ddd9..0000000000 --- a/awx/ui/client/src/portal-mode/main.js +++ /dev/null @@ -1,17 +0,0 @@ -/************************************************* - * Copyright (c) 2016 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - -// 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'; -export default - angular.module('portalMode', []) - .run(['$stateExtender', function($stateExtender){ - $stateExtender.addState(templatesRoute); - $stateExtender.addState(myJobsRoute); - $stateExtender.addState(allJobsRoute); - }]); 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 deleted file mode 100644 index 417e97e1bc..0000000000 --- a/awx/ui/client/src/portal-mode/portal-mode-layout.partial.html +++ /dev/null @@ -1,52 +0,0 @@ -
-
-
-
-
-
-
-
JOB TEMPLATES
-
-
-
-
-
-
-
-
-
-
-
JOBS
-
-
-
-
-
- - -
-
-
- -
-
-
-
-
-
-
-
-