diff --git a/awx/ui/client/src/controllers/Credentials.js b/awx/ui/client/src/controllers/Credentials.js index 7b9a75acd8..2ed862b4c9 100644 --- a/awx/ui/client/src/controllers/Credentials.js +++ b/awx/ui/client/src/controllers/Credentials.js @@ -329,7 +329,8 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, form = CredentialForm, base = $location.path().replace(/^\//, '').split('/')[0], master = {}, - id = $stateParams.credential_id; + id = $stateParams.credential_id, + relatedSets = {}; generator.inject(form, { mode: 'edit', related: true, scope: $scope }); generator.reset(); @@ -378,6 +379,10 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $scope.removeCredentialLoaded(); } $scope.removeCredentialLoaded = $scope.$on('credentialLoaded', function () { + var set; + for (set in relatedSets) { + $scope.search(relatedSets[set].iterator); + } var orgUrl = ($rootScope.current_user.is_superuser) ? GetBasePath("organizations") : $rootScope.current_user.url + "admin_of_organizations?"; @@ -421,6 +426,13 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, Rest.setUrl(defaultUrl + ':id/'); Rest.get({ params: { id: id } }) .success(function (data) { + if (data && data.summary_fields && + data.summary_fields.organization && + data.summary_fields.organization.id) { + $scope.needsRoleList = true; + } else { + $scope.needsRoleList = false; + } $scope.credential_name = data.name; @@ -439,6 +451,7 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField]; } } + relatedSets = form.relatedSets(data.related); if (!Empty($scope.user)) { $scope.owner = 'user'; @@ -509,6 +522,17 @@ export function CredentialsEdit($scope, $rootScope, $compile, $location, $log, $scope.subscription_id = data.username; } + $scope.credential_obj = data; + + RelatedSearchInit({ + scope: $scope, + form: form, + relatedSets: relatedSets + }); + RelatedPaginateInit({ + scope: $scope, + relatedSets: relatedSets + }); $scope.$emit('credentialLoaded'); }) diff --git a/awx/ui/client/src/forms/Credentials.js b/awx/ui/client/src/forms/Credentials.js index 51131430b7..5435eddcec 100644 --- a/awx/ui/client/src/forms/Credentials.js +++ b/awx/ui/client/src/forms/Credentials.js @@ -364,6 +364,47 @@ export default } }, - related: {} + related: { + permissions: { + type: 'collection', + title: 'Permissions', + iterator: 'permission', + index: false, + open: false, + searchType: 'select', + actions: { + add: { + ngClick: "addPermission", + label: 'Add', + awToolTip: 'Add a permission', + actionClass: 'btn List-buttonSubmit', + buttonContent: '+ ADD' + } + }, + fields: { + username: { + key: true, + label: 'User', + linkBase: 'users', + class: 'col-lg-3 col-md-3 col-sm-3 col-xs-4' + }, + role: { + label: 'Role', + type: 'role', + noSort: true, + class: 'col-lg-9 col-md-9 col-sm-9 col-xs-8' + } + } + } + }, + + relatedSets: function(urls) { + return { + permissions: { + iterator: 'permission', + url: urls.access_list + } + }; + } }); diff --git a/awx/ui/client/src/forms/Inventories.js b/awx/ui/client/src/forms/Inventories.js index 746c8a49a9..928de33a91 100644 --- a/awx/ui/client/src/forms/Inventories.js +++ b/awx/ui/client/src/forms/Inventories.js @@ -150,6 +150,38 @@ export default awToolTip: 'Delete the scan job template' } } + }, + permissions: { + type: 'collection', + title: 'Permissions', + iterator: 'permission', + index: false, + open: false, + searchType: 'select', + actions: { + add: { + ngClick: "addPermission", + label: 'Add', + awToolTip: 'Add a permission', + actionClass: 'btn List-buttonSubmit', + buttonContent: '+ ADD' + } + }, + + fields: { + username: { + key: true, + label: 'User', + linkBase: 'users', + class: 'col-lg-3 col-md-3 col-sm-3 col-xs-4' + }, + role: { + label: 'Role', + type: 'role', + noSort: true, + class: 'col-lg-9 col-md-9 col-sm-9 col-xs-8' + } + } } }, @@ -158,6 +190,10 @@ export default scan_job_templates: { iterator: 'scan_job_template', url: urls.scan_job_templates + }, + permissions: { + iterator: 'permission', + url: urls.access_list } }; } diff --git a/awx/ui/client/src/forms/JobTemplates.js b/awx/ui/client/src/forms/JobTemplates.js index 36fce67368..55d8e34f27 100644 --- a/awx/ui/client/src/forms/JobTemplates.js +++ b/awx/ui/client/src/forms/JobTemplates.js @@ -369,6 +369,38 @@ export default }, "completed_jobs": { include: "CompletedJobsList" + }, + permissions: { + type: 'collection', + title: 'Permissions', + iterator: 'permission', + index: false, + open: false, + searchType: 'select', + actions: { + add: { + ngClick: "addPermission", + label: 'Add', + awToolTip: 'Add a permission', + actionClass: 'btn List-buttonSubmit', + buttonContent: '+ ADD' + } + }, + + fields: { + username: { + key: true, + label: 'User', + linkBase: 'users', + class: 'col-lg-3 col-md-3 col-sm-3 col-xs-4' + }, + role: { + label: 'Role', + type: 'role', + noSort: true, + class: 'col-lg-9 col-md-9 col-sm-9 col-xs-8' + } + } } }, @@ -381,6 +413,10 @@ export default schedules: { iterator: 'schedule', url: urls.schedules + }, + permissions: { + iterator: 'permission', + url: urls.access_list } }; } diff --git a/awx/ui/client/src/forms/Organizations.js b/awx/ui/client/src/forms/Organizations.js index 0f32733c89..14b0a5d9e1 100644 --- a/awx/ui/client/src/forms/Organizations.js +++ b/awx/ui/client/src/forms/Organizations.js @@ -139,8 +139,48 @@ export default awToolTip: 'Remove administrator' } } + }, + permissions: { + type: 'collection', + title: 'Permissions', + iterator: 'permission', + index: false, + open: false, + searchType: 'select', + actions: { + add: { + ngClick: "addPermission", + label: 'Add', + awToolTip: 'Add a permission', + actionClass: 'btn List-buttonSubmit', + buttonContent: '+ ADD' + } + }, + + fields: { + username: { + key: true, + label: 'User', + linkBase: 'users', + class: 'col-lg-3 col-md-3 col-sm-3 col-xs-4' + }, + role: { + label: 'Role', + type: 'role', + noSort: true, + class: 'col-lg-9 col-md-9 col-sm-9 col-xs-8' + } + } } + }, + relatedSets: function(urls) { + return { + permissions: { + iterator: 'permission', + url: urls.access_list + } + }; } }); //OrganizationForm diff --git a/awx/ui/client/src/helpers/JobTemplates.js b/awx/ui/client/src/helpers/JobTemplates.js index 44a4604bca..8613341836 100644 --- a/awx/ui/client/src/helpers/JobTemplates.js +++ b/awx/ui/client/src/helpers/JobTemplates.js @@ -76,6 +76,7 @@ angular.module('JobTemplatesHelper', ['Utilities']) Rest.setUrl(defaultUrl + id); Rest.get() .success(function (data) { + scope.job_template_obj = data; var fld, i; for (fld in form.fields) { if (fld !== 'variables' && data[fld] !== null && data[fld] !== undefined) { diff --git a/awx/ui/client/src/inventories/edit/inventory-edit.controller.js b/awx/ui/client/src/inventories/edit/inventory-edit.controller.js index f7cb6f2601..e956793cc0 100644 --- a/awx/ui/client/src/inventories/edit/inventory-edit.controller.js +++ b/awx/ui/client/src/inventories/edit/inventory-edit.controller.js @@ -103,6 +103,9 @@ function InventoriesEdit($scope, $rootScope, $compile, $location, field: 'organization', input_type: 'radio' }); + + $scope.inventory_obj = data; + $scope.$emit('inventoryLoaded'); }) .error(function (data, status) { diff --git a/awx/ui/client/src/organizations/edit/organizations-edit.controller.js b/awx/ui/client/src/organizations/edit/organizations-edit.controller.js index f9178a1fb1..7f39e57cb1 100644 --- a/awx/ui/client/src/organizations/edit/organizations-edit.controller.js +++ b/awx/ui/client/src/organizations/edit/organizations-edit.controller.js @@ -66,9 +66,12 @@ export default ['$scope', '$rootScope', '$compile', '$location', }; } } + angular.extend(relatedSets, form + .relatedSets(data.related)); // Initialize related search functions. Doing it here to make sure relatedSets object is populated. RelatedSearchInit({ scope: $scope, form: form, relatedSets: relatedSets }); RelatedPaginateInit({ scope: $scope, relatedSets: relatedSets }); + $scope.organization_obj = data; $scope.$emit('organizationLoaded'); }) .error(function (data, status) { diff --git a/awx/ui/client/src/organizations/list/organizations-list.controller.js b/awx/ui/client/src/organizations/list/organizations-list.controller.js index 7316f145b9..0b5145efec 100644 --- a/awx/ui/client/src/organizations/list/organizations-list.controller.js +++ b/awx/ui/client/src/organizations/list/organizations-list.controller.js @@ -33,6 +33,8 @@ export default ['$stateParams', '$scope', '$rootScope', '$location', url: defaultUrl, }); + $scope.list = list; + $scope.search(list.iterator); $scope.PaginateWidget = PaginateWidget({ diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 0f3ea7445a..7771d76efb 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -205,7 +205,8 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat this.scope.mode = options.mode; } - if(options.mode === 'edit' && this.form.tabs){ + if(options.mode === 'edit' && this.form.related && + !_.isEmpty(this.form.related)){ var tabs = [this.form.name], that = this; tabs.push(Object.keys(this.form.related)); tabs = _.flatten(tabs);