diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index a79460b0ea..b3a2802df3 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -716,6 +716,66 @@ var tower = angular.module('Tower', [ }); }; + $rootScope.deletePermissionFromUser = function (userId, userName, roleName, roleType, url) { + var action = function () { + $('#prompt-modal').modal('hide'); + Wait('start'); + Rest.setUrl(url); + Rest.post({"disassociate": true, "id": userId}) + .success(function () { + Wait('stop'); + $rootScope.$broadcast("refreshList", "permission"); + }) + .error(function (data, status) { + ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', + msg: 'Could not disassociate user from role. Call to ' + url + ' failed. DELETE returned status: ' + status }); + }); + }; + + Prompt({ + hdr: `Remove role`, + body: ` +
---\n" + '
somevar: somevalue
password: magic
View JSON examples at www.json.org
' + - 'View YAML examples at docs.ansible.com
', + 'View YAML examples at docs.ansible.com
', } }, buttons: { @@ -74,4 +74,4 @@ export default function(){ } } }; -}; \ No newline at end of file +} diff --git a/awx/ui/client/src/dashboard/hosts/dashboard-hosts.list.js b/awx/ui/client/src/dashboard/hosts/dashboard-hosts.list.js index 4731155cbb..9ad52a7899 100644 --- a/awx/ui/client/src/dashboard/hosts/dashboard-hosts.list.js +++ b/awx/ui/client/src/dashboard/hosts/dashboard-hosts.list.js @@ -89,5 +89,5 @@ export default function(){ actions: { } - } -}; + }; +} diff --git a/awx/ui/client/src/dashboard/hosts/dashboard-hosts.route.js b/awx/ui/client/src/dashboard/hosts/dashboard-hosts.route.js index 84f31ad981..4b8b95b0a6 100644 --- a/awx/ui/client/src/dashboard/hosts/dashboard-hosts.route.js +++ b/awx/ui/client/src/dashboard/hosts/dashboard-hosts.route.js @@ -29,13 +29,13 @@ var dashboardHostsList = { var defaultUrl = GetBasePath('hosts') + '?page_size=10'; Rest.setUrl(defaultUrl); return Rest.get().then(function(res){ - var results = _.map(res.data.results, function(value, key){ + var results = _.map(res.data.results, function(value){ value.inventory_name = value.summary_fields.inventory.name; value.inventory_id = value.summary_fields.inventory.id; return value; }); res.data.results = results; - return res.data + return res.data; }); }] } @@ -61,4 +61,4 @@ var dashboardHostsEdit = { } }; -export {dashboardHostsList, dashboardHostsEdit}; \ No newline at end of file +export {dashboardHostsList, dashboardHostsEdit}; diff --git a/awx/ui/client/src/forms/Teams.js b/awx/ui/client/src/forms/Teams.js index 471cda62c4..4d56a75f7e 100644 --- a/awx/ui/client/src/forms/Teams.js +++ b/awx/ui/client/src/forms/Teams.js @@ -59,11 +59,10 @@ export default }, related: { - /* - permissions: { + access_list: { basePath: 'teams/:id/access_list/', type: 'collection', - title: 'Permissions', + title: 'Users', iterator: 'permission', index: false, open: false, @@ -76,148 +75,59 @@ export default actionClass: 'btn List-buttonSubmit', buttonContent: '+ ADD' } - } - }, - */ - - - credentials: { - type: 'collection', - title: 'Credentials', - iterator: 'credential', - open: false, - index: false, - - actions: { - add: { - ngClick: "add('credentials')", - label: 'Add', - add: 'Add a new credential', - actionClass: 'btn List-buttonSubmit', - buttonContent: '+ ADD' - } - }, - - fields: { - name: { - key: true, - label: 'Name' - }, - description: { - label: 'Description' - } - }, - - fieldActions: { - edit: { - label: 'Edit', - ngClick: "edit('credentials', credential.id, credential.name)", - icon: 'icon-edit', - awToolTip: 'Modify the credential', - 'class': 'btn btn-default' - }, - "delete": { - label: 'Delete', - ngClick: "delete('credentials', credential.id, credential.name, 'credential')", - icon: 'icon-trash', - "class": 'btn-danger', - awToolTip: 'Remove the credential' - } - } - }, - - projects: { - type: 'collection', - title: 'Projects', - iterator: 'project', - open: false, - index: false, - - actions: { - add: { - ngClick: "add('projects')", - label: 'Add', - actionClass: 'btn List-buttonSubmit', - buttonContent: '+ ADD' - } - }, - - fields: { - name: { - key: true, - label: 'Name' - }, - description: { - label: 'Description' - } - }, - - fieldActions: { - edit: { - label: 'Edit', - ngClick: "edit('projects', project.id, project.name)", - icon: 'icon-edit', - awToolTip: 'Modify the project', - 'class': 'btn btn-default' - }, - "delete": { - label: 'Delete', - ngClick: "delete('projects', project.id, project.name, 'project')", - icon: 'icon-trash', - "class": 'btn-danger', - awToolTip: 'Remove the project' - } - } - }, - - users: { - type: 'collection', - title: 'Users', - iterator: 'user', - open: false, - index: false, - - actions: { - add: { - ngClick: "add('users')", - label: 'Add', - awToolTip: 'Add a user', - actionClass: 'btn List-buttonSubmit', - buttonContent: '+ ADD' - } }, fields: { username: { key: true, - label: 'Username' + label: 'User', + linkBase: 'users', + class: 'col-lg-3 col-md-3 col-sm-3 col-xs-4' }, - first_name: { - label: 'First Name' - }, - last_name: { - label: 'Last Name' - } - }, - - fieldActions: { - edit: { - label: 'Edit', - ngClick: "edit('users', user.id, user.username)", - icon: 'icon-edit', - awToolTip: 'Edit user', - 'class': 'btn btn-default' - }, - "delete": { - label: 'Delete', - ngClick: "delete('users', user.id, user.username, 'user')", - icon: 'icon-terash', - "class": 'btn-danger', - awToolTip: 'Remove user' + role: { + label: 'Role', + type: 'role', + noSort: true, + class: 'col-lg-9 col-md-9 col-sm-9 col-xs-8' } } + }, + roles: { + type: 'collection', + title: 'Permissions', + iterator: 'role', + open: false, + index: false, + actions: {}, + + fields: { + name: { + label: 'Name', + ngBind: 'role.summary_fields.resource_name', + linkTo: '{{convertApiUrl(role.related[role.summary_fields.resource_type])}}', + noSort: true + }, + type: { + label: 'Type', + ngBind: 'role.summary_fields.resource_type_display_name', + noSort: true + }, + role: { + label: 'Role', + ngBind: 'role.name', + noSort: true + } + }, + fieldActions: { + "delete": { + label: 'Remove', + ngClick: 'deletePermissionFromTeam(team_id, team_obj.name, role.name, role.summary_fields.resource_name, role.related.teams)', + class: "List-actionButton--delete", + iconClass: 'fa fa-times', + awToolTip: 'Dissasociate permission from team' + } + }, + hideOnSuperuser: true } - - } - + }, }); //InventoryForm diff --git a/awx/ui/client/src/forms/Users.js b/awx/ui/client/src/forms/Users.js index d1c2c2613f..954a61225b 100644 --- a/awx/ui/client/src/forms/Users.js +++ b/awx/ui/client/src/forms/Users.js @@ -115,71 +115,6 @@ export default }, related: { - /* - permissions: { - basePath: 'teams/:id/access_list/', - 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' - } - } - }, - */ - - credentials: { - type: 'collection', - title: 'Credentials', - iterator: 'credential', - open: false, - index: false, - - actions: { - add: { - ngClick: "add('credentials')", - label: 'Add', - awToolTip: 'Add a credential for this user', - actionClass: 'btn List-buttonSubmit', - buttonContent: '+ ADD' - } - }, - - fields: { - name: { - key: true, - label: 'Name' - }, - description: { - label: 'Description' - } - }, - - fieldActions: { - edit: { - label: 'Edit', - ngClick: "edit('credentials', credential.id, credential.name)", - icon: 'icon-edit', - awToolTip: 'Edit the credential', - 'class': 'btn btn-default' - }, - "delete": { - label: 'Delete', - ngClick: "delete('credentials', credential.id, credential.name, 'credential')", - icon: 'icon-trash', - "class": 'btn-danger', - awToolTip: 'Delete the credential' - } - } - }, organizations: { type: 'collection', title: 'Organizations', @@ -197,9 +132,9 @@ export default description: { label: 'Description' } - } + }, + hideOnSuperuser: true }, - teams: { type: 'collection', title: 'Teams', @@ -217,8 +152,44 @@ export default description: { label: 'Description' } - } + }, + hideOnSuperuser: true + }, + roles: { + hideSearchAndActions: true, + type: 'collection', + title: 'Permissions', + iterator: 'permission', + open: false, + index: false, + fields: { + name: { + label: 'Name', + ngBind: 'permission.summary_fields.resource_name', + linkTo: '{{convertApiUrl(permission.related[permission.summary_fields.resource_type])}}', + noSort: true + }, + type: { + label: 'Type', + ngBind: 'permission.summary_fields.resource_type_display_name', + noSort: true + }, + role: { + label: 'Role', + ngBind: 'permission.name', + noSort: true + }, + }, + fieldActions: { + "delete": { + label: 'Remove', + ngClick: 'deletePermissionFromUser(user_id, username, permission.name, permission.summary_fields.resource_name, permission.related.users)', + iconClass: 'fa fa-times', + awToolTip: 'Dissasociate permission from user' + } + }, + hideOnSuperuser: true } } - }); //UserForm + }); diff --git a/awx/ui/client/src/search/getSearchHtml.service.js b/awx/ui/client/src/search/getSearchHtml.service.js index b7da64f702..f64e5a12bf 100644 --- a/awx/ui/client/src/search/getSearchHtml.service.js +++ b/awx/ui/client/src/search/getSearchHtml.service.js @@ -16,6 +16,7 @@ export default ['GetBasePath', function(GetBasePath) { delete f[i].ngClass; delete f[i].ngClick; delete f[i].icon; + delete f[i].linkTo; return {[i]: f[i]}; }).reduce(function (acc, i) { var key = Object.keys(i); diff --git a/awx/ui/client/src/search/tagSearch.service.js b/awx/ui/client/src/search/tagSearch.service.js index eb004a2e39..fc8111e8ed 100644 --- a/awx/ui/client/src/search/tagSearch.service.js +++ b/awx/ui/client/src/search/tagSearch.service.js @@ -35,7 +35,7 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu obj.value = value; obj.label = label; obj.type = type; - obj.basePath = field['basePath'] || null; + obj.basePath = field.basePath || null; // return the built option if (type === 'select') { @@ -81,7 +81,7 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu Rest.setUrl(needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath); Rest.options() .success(function (data) { - try { + try { var options = data.actions.GET; needsRequest = needsRequest .map(function (option) { diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index d5d44b0be2..ade9b3d79e 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -1462,7 +1462,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += (options.mode === 'edit') ? this.form.editTitle : this.form.addTitle; if(this.form.name === "user"){ html+= "Admin"; + "ng-if=is_superuser>System Administrator"; } html += "\n"; html += "| # | \n" : ""; for (fld in collection.fields) { html += "\n";
- html += " \n";
+ html += `
+
+ `;
html += " ";
html += " ";
html += "
|
|---|