From d1b7b3a553ce74b34c696f9ec11e12e9b0fcd2ce Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Wed, 19 Aug 2015 21:39:05 -0400 Subject: [PATCH] reinstituted modularization to be more inline with the inventory scripts management jobs --- .../add.controller.js} | 0 .../{permissions-add => add}/main.js | 6 ++-- .../team-add.route.js} | 2 +- .../user-add.route.js} | 2 +- .../edit.controller.js} | 0 .../{permissions-edit => edit}/main.js | 6 ++-- .../team-edit.route.js} | 2 +- .../user-edit.route.js} | 2 +- .../list.controller.js} | 0 .../{permissions-list => list}/main.js | 6 ++-- .../team-list.route.js} | 2 +- .../user-list.route.js} | 2 +- awx/ui/client/src/permissions/main.js | 22 +++++++++----- .../category-change.factory.js} | 0 .../get-choices.factory.js} | 13 ++------ .../permissions/shared/get-labels.factory.js | 26 ++++++++++++++++ .../shared/get-search-select.factory.js | 30 +++++++++++++++++++ .../permissions.form.js} | 0 .../permissions.list.js} | 0 .../team-permissions.partial.html | 0 .../user-permissions.partial.html | 0 21 files changed, 88 insertions(+), 33 deletions(-) rename awx/ui/client/src/permissions/{permissions-add/permissions-add.controller.js => add/add.controller.js} (100%) rename awx/ui/client/src/permissions/{permissions-add => add}/main.js (78%) rename awx/ui/client/src/permissions/{permissions-add/permissions-team-add.route.js => add/team-add.route.js} (88%) rename awx/ui/client/src/permissions/{permissions-add/permissions-user-add.route.js => add/user-add.route.js} (88%) rename awx/ui/client/src/permissions/{permissions-edit/permissions-edit.controller.js => edit/edit.controller.js} (100%) rename awx/ui/client/src/permissions/{permissions-edit => edit}/main.js (78%) rename awx/ui/client/src/permissions/{permissions-edit/permissions-team-edit.route.js => edit/team-edit.route.js} (88%) rename awx/ui/client/src/permissions/{permissions-edit/permissions-user-edit.route.js => edit/user-edit.route.js} (88%) rename awx/ui/client/src/permissions/{permissions-list/permissions-list.controller.js => list/list.controller.js} (100%) rename awx/ui/client/src/permissions/{permissions-list => list}/main.js (78%) rename awx/ui/client/src/permissions/{permissions-list/permissions-team-list.route.js => list/team-list.route.js} (88%) rename awx/ui/client/src/permissions/{permissions-list/permissions-user-list.route.js => list/user-list.route.js} (88%) rename awx/ui/client/src/permissions/{permissions-category-change.factory.js => shared/category-change.factory.js} (100%) rename awx/ui/client/src/permissions/{permissions-labels.factory.js => shared/get-choices.factory.js} (73%) create mode 100644 awx/ui/client/src/permissions/shared/get-labels.factory.js create mode 100644 awx/ui/client/src/permissions/shared/get-search-select.factory.js rename awx/ui/client/src/permissions/{permissions-form.js => shared/permissions.form.js} (100%) rename awx/ui/client/src/permissions/{permissions-list.js => shared/permissions.list.js} (100%) rename awx/ui/client/src/permissions/{ => shared}/team-permissions.partial.html (100%) rename awx/ui/client/src/permissions/{ => shared}/user-permissions.partial.html (100%) diff --git a/awx/ui/client/src/permissions/permissions-add/permissions-add.controller.js b/awx/ui/client/src/permissions/add/add.controller.js similarity index 100% rename from awx/ui/client/src/permissions/permissions-add/permissions-add.controller.js rename to awx/ui/client/src/permissions/add/add.controller.js diff --git a/awx/ui/client/src/permissions/permissions-add/main.js b/awx/ui/client/src/permissions/add/main.js similarity index 78% rename from awx/ui/client/src/permissions/permissions-add/main.js rename to awx/ui/client/src/permissions/add/main.js index 3ddff82526..ad86ab1801 100644 --- a/awx/ui/client/src/permissions/permissions-add/main.js +++ b/awx/ui/client/src/permissions/add/main.js @@ -4,9 +4,9 @@ * All Rights Reserved *************************************************/ -import userRoute from './permissions-user-add.route'; -import teamRoute from './permissions-team-add.route'; -import controller from './permissions-add.controller'; +import userRoute from './user-add.route'; +import teamRoute from './team-add.route'; +import controller from './add.controller'; export default angular.module('permissionsAdd', []) diff --git a/awx/ui/client/src/permissions/permissions-add/permissions-team-add.route.js b/awx/ui/client/src/permissions/add/team-add.route.js similarity index 88% rename from awx/ui/client/src/permissions/permissions-add/permissions-team-add.route.js rename to awx/ui/client/src/permissions/add/team-add.route.js index a2729cc329..706d273f79 100644 --- a/awx/ui/client/src/permissions/permissions-add/permissions-team-add.route.js +++ b/awx/ui/client/src/permissions/add/team-add.route.js @@ -9,7 +9,7 @@ import {templateUrl} from '../../shared/template-url/template-url.factory'; export default { name: 'teamPermissionsAdd', route: '/teams/:team_id/permissions/add', - templateUrl: templateUrl('permissions/team-permissions'), + templateUrl: templateUrl('permissions/shared/team-permissions'), controller: 'addController', resolve: { features: ['FeaturesService', function(FeaturesService) { diff --git a/awx/ui/client/src/permissions/permissions-add/permissions-user-add.route.js b/awx/ui/client/src/permissions/add/user-add.route.js similarity index 88% rename from awx/ui/client/src/permissions/permissions-add/permissions-user-add.route.js rename to awx/ui/client/src/permissions/add/user-add.route.js index b67d866a7e..877be6c20c 100644 --- a/awx/ui/client/src/permissions/permissions-add/permissions-user-add.route.js +++ b/awx/ui/client/src/permissions/add/user-add.route.js @@ -9,7 +9,7 @@ import {templateUrl} from '../../shared/template-url/template-url.factory'; export default { name: 'userPermissionsAdd', route: '/users/:user_id/permissions/add', - templateUrl: templateUrl('permissions/user-permissions'), + templateUrl: templateUrl('permissions/shared/user-permissions'), controller: 'addController', resolve: { features: ['FeaturesService', function(FeaturesService) { diff --git a/awx/ui/client/src/permissions/permissions-edit/permissions-edit.controller.js b/awx/ui/client/src/permissions/edit/edit.controller.js similarity index 100% rename from awx/ui/client/src/permissions/permissions-edit/permissions-edit.controller.js rename to awx/ui/client/src/permissions/edit/edit.controller.js diff --git a/awx/ui/client/src/permissions/permissions-edit/main.js b/awx/ui/client/src/permissions/edit/main.js similarity index 78% rename from awx/ui/client/src/permissions/permissions-edit/main.js rename to awx/ui/client/src/permissions/edit/main.js index cc5d838070..9f36428267 100644 --- a/awx/ui/client/src/permissions/permissions-edit/main.js +++ b/awx/ui/client/src/permissions/edit/main.js @@ -4,9 +4,9 @@ * All Rights Reserved *************************************************/ -import userRoute from './permissions-user-edit.route'; -import teamRoute from './permissions-team-edit.route'; -import controller from './permissions-edit.controller'; +import userRoute from './user-edit.route'; +import teamRoute from './team-edit.route'; +import controller from './edit.controller'; export default angular.module('permissionsEdit', []) diff --git a/awx/ui/client/src/permissions/permissions-edit/permissions-team-edit.route.js b/awx/ui/client/src/permissions/edit/team-edit.route.js similarity index 88% rename from awx/ui/client/src/permissions/permissions-edit/permissions-team-edit.route.js rename to awx/ui/client/src/permissions/edit/team-edit.route.js index e82d7f544d..9b3582fcdd 100644 --- a/awx/ui/client/src/permissions/permissions-edit/permissions-team-edit.route.js +++ b/awx/ui/client/src/permissions/edit/team-edit.route.js @@ -9,7 +9,7 @@ import {templateUrl} from '../../shared/template-url/template-url.factory'; export default { name: 'teamPermissionsEdit', route: '/teams/:team_id/permissions/:permission_id', - templateUrl: templateUrl('permissions/team-permissions'), + templateUrl: templateUrl('permissions/shared/team-permissions'), controller: 'editController', resolve: { features: ['FeaturesService', function(FeaturesService) { diff --git a/awx/ui/client/src/permissions/permissions-edit/permissions-user-edit.route.js b/awx/ui/client/src/permissions/edit/user-edit.route.js similarity index 88% rename from awx/ui/client/src/permissions/permissions-edit/permissions-user-edit.route.js rename to awx/ui/client/src/permissions/edit/user-edit.route.js index c0431a2a1d..fac38923f7 100644 --- a/awx/ui/client/src/permissions/permissions-edit/permissions-user-edit.route.js +++ b/awx/ui/client/src/permissions/edit/user-edit.route.js @@ -9,7 +9,7 @@ import {templateUrl} from '../../shared/template-url/template-url.factory'; export default { name: 'userPermissionsEdit', route: '/users/:user_id/permissions/:permission_id', - templateUrl: templateUrl('permissions/user-permissions'), + templateUrl: templateUrl('permissions/shared/user-permissions'), controller: 'editController', resolve: { features: ['FeaturesService', function(FeaturesService) { diff --git a/awx/ui/client/src/permissions/permissions-list/permissions-list.controller.js b/awx/ui/client/src/permissions/list/list.controller.js similarity index 100% rename from awx/ui/client/src/permissions/permissions-list/permissions-list.controller.js rename to awx/ui/client/src/permissions/list/list.controller.js diff --git a/awx/ui/client/src/permissions/permissions-list/main.js b/awx/ui/client/src/permissions/list/main.js similarity index 78% rename from awx/ui/client/src/permissions/permissions-list/main.js rename to awx/ui/client/src/permissions/list/main.js index bd29db4966..beed341e5b 100644 --- a/awx/ui/client/src/permissions/permissions-list/main.js +++ b/awx/ui/client/src/permissions/list/main.js @@ -4,9 +4,9 @@ * All Rights Reserved *************************************************/ -import userRoute from './permissions-user-list.route'; -import teamRoute from './permissions-team-list.route'; -import controller from './permissions-list.controller'; +import userRoute from './user-list.route'; +import teamRoute from './team-list.route'; +import controller from './list.controller'; export default angular.module('permissionsList', []) diff --git a/awx/ui/client/src/permissions/permissions-list/permissions-team-list.route.js b/awx/ui/client/src/permissions/list/team-list.route.js similarity index 88% rename from awx/ui/client/src/permissions/permissions-list/permissions-team-list.route.js rename to awx/ui/client/src/permissions/list/team-list.route.js index cbe4527b5f..bd93ebf2e5 100644 --- a/awx/ui/client/src/permissions/permissions-list/permissions-team-list.route.js +++ b/awx/ui/client/src/permissions/list/team-list.route.js @@ -9,7 +9,7 @@ import {templateUrl} from '../../shared/template-url/template-url.factory'; export default { name: 'teamPermissionsList', route: '/teams/:team_id/permissions', - templateUrl: templateUrl('permissions/team-permissions'), + templateUrl: templateUrl('permissions/shared/team-permissions'), controller: 'permissionsListController', resolve: { features: ['FeaturesService', function(FeaturesService) { diff --git a/awx/ui/client/src/permissions/permissions-list/permissions-user-list.route.js b/awx/ui/client/src/permissions/list/user-list.route.js similarity index 88% rename from awx/ui/client/src/permissions/permissions-list/permissions-user-list.route.js rename to awx/ui/client/src/permissions/list/user-list.route.js index ac73c54451..586b000d69 100644 --- a/awx/ui/client/src/permissions/permissions-list/permissions-user-list.route.js +++ b/awx/ui/client/src/permissions/list/user-list.route.js @@ -9,7 +9,7 @@ import {templateUrl} from '../../shared/template-url/template-url.factory'; export default { name: 'userPermissionsList', route: '/users/:user_id/permissions', - templateUrl: templateUrl('permissions/user-permissions'), + templateUrl: templateUrl('permissions/shared/user-permissions'), controller: 'permissionsListController', resolve: { features: ['FeaturesService', function(FeaturesService) { diff --git a/awx/ui/client/src/permissions/main.js b/awx/ui/client/src/permissions/main.js index 24cac3b898..fef273cfa6 100644 --- a/awx/ui/client/src/permissions/main.js +++ b/awx/ui/client/src/permissions/main.js @@ -4,13 +4,17 @@ * All Rights Reserved *************************************************/ -import permissionsList from './permissions-list/main'; -import permissionsAdd from './permissions-add/main'; -import permissionsEdit from './permissions-edit/main'; -import list from './permissions-list'; -import form from './permissions-form'; -import permissionsCategoryChange from './permissions-category-change.factory'; -import permissionsLabel from './permissions-labels.factory'; +import permissionsList from './list/main'; +import permissionsAdd from './add/main'; +import permissionsEdit from './edit/main'; + +import list from './shared/permissions.list'; +import form from './shared/permissions.form'; + +import permissionsCategoryChange from './shared/category-change.factory'; +import permissionsChoices from './shared/get-choices.factory'; +import permissionsLabel from './shared/get-labels.factory'; +import permissionsSearchSelect from './shared/get-search-select.factory'; export default angular.module('permissions', [ @@ -21,4 +25,6 @@ export default .factory('permissionsList', list) .factory('permissionsForm', form) .factory('permissionsCategoryChange', permissionsCategoryChange) - .factory('permissionsLabel', permissionsLabel); + .factory('permissionsChoices', permissionsChoices) + .factory('permissionsLabel', permissionsLabel) + .factory('permissionsSearchSelect', permissionsSearchSelect); diff --git a/awx/ui/client/src/permissions/permissions-category-change.factory.js b/awx/ui/client/src/permissions/shared/category-change.factory.js similarity index 100% rename from awx/ui/client/src/permissions/permissions-category-change.factory.js rename to awx/ui/client/src/permissions/shared/category-change.factory.js diff --git a/awx/ui/client/src/permissions/permissions-labels.factory.js b/awx/ui/client/src/permissions/shared/get-choices.factory.js similarity index 73% rename from awx/ui/client/src/permissions/permissions-labels.factory.js rename to awx/ui/client/src/permissions/shared/get-choices.factory.js index 98bce85aea..57e14433f4 100644 --- a/awx/ui/client/src/permissions/permissions-labels.factory.js +++ b/awx/ui/client/src/permissions/shared/get-choices.factory.js @@ -24,17 +24,10 @@ .then(function (data) { data = data.data; var choices = data.actions.GET.permission_type.choices; - - // convert the choices from the API from the format - // [["read", "Read Inventory"], ...] to - // {read: "Read Inventory", ...} - choices = choices.reduce(function(obj, kvp) { - obj[kvp[0]] = kvp[1]; - return obj; - }, {}); - + // manually add the adhoc label to the choices object - choices['adhoc'] = data.actions.GET.run_ad_hoc_commands.label; + choices.push(["adhoc", + data.actions.GET.run_ad_hoc_commands.label]); return choices; }) diff --git a/awx/ui/client/src/permissions/shared/get-labels.factory.js b/awx/ui/client/src/permissions/shared/get-labels.factory.js new file mode 100644 index 0000000000..2b20ca70bb --- /dev/null +++ b/awx/ui/client/src/permissions/shared/get-labels.factory.js @@ -0,0 +1,26 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + + /** + * @ngdoc function + * @name helpers.function:Permissions + * @description + * Gets permission type labels from the API and sets them as the permissions labels on the relevant radio buttons + * + */ + + export default + [function() { + return function (params) { + // convert the choices from the API from the format + // [["read", "Read Inventory"], ...] to + // {read: "Read Inventory", ...} + return params.choices.reduce(function(obj, kvp) { + obj[kvp[0]] = kvp[1]; + return obj; + }, {}); + }; + }]; diff --git a/awx/ui/client/src/permissions/shared/get-search-select.factory.js b/awx/ui/client/src/permissions/shared/get-search-select.factory.js new file mode 100644 index 0000000000..ca2e459c14 --- /dev/null +++ b/awx/ui/client/src/permissions/shared/get-search-select.factory.js @@ -0,0 +1,30 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + + /** + * @ngdoc function + * @name helpers.function:Permissions + * @description + * Gets permission type labels from the API and sets them as the permissions labels on the relevant radio buttons + * + */ + + export default + [function() { + return function (params) { + // convert the choices from the API from the format + // [["read", "Read Inventory"], ...] to + // {name: "read", value: "Read Inventory", ...} + return params.choices.reduce(function(obj, kvp) { + // for now, remove adhoc from those choices + if (kvp[0] !== adhoc) { + return {name: kvp[0], value: kvp[1]}; + } else { + return null; + } + }, {}); + }; + }]; diff --git a/awx/ui/client/src/permissions/permissions-form.js b/awx/ui/client/src/permissions/shared/permissions.form.js similarity index 100% rename from awx/ui/client/src/permissions/permissions-form.js rename to awx/ui/client/src/permissions/shared/permissions.form.js diff --git a/awx/ui/client/src/permissions/permissions-list.js b/awx/ui/client/src/permissions/shared/permissions.list.js similarity index 100% rename from awx/ui/client/src/permissions/permissions-list.js rename to awx/ui/client/src/permissions/shared/permissions.list.js diff --git a/awx/ui/client/src/permissions/team-permissions.partial.html b/awx/ui/client/src/permissions/shared/team-permissions.partial.html similarity index 100% rename from awx/ui/client/src/permissions/team-permissions.partial.html rename to awx/ui/client/src/permissions/shared/team-permissions.partial.html diff --git a/awx/ui/client/src/permissions/user-permissions.partial.html b/awx/ui/client/src/permissions/shared/user-permissions.partial.html similarity index 100% rename from awx/ui/client/src/permissions/user-permissions.partial.html rename to awx/ui/client/src/permissions/shared/user-permissions.partial.html