From 18c74a8020f0ea2629d5151875d497c2cca7adbe Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Fri, 3 Jun 2016 14:46:07 -0400 Subject: [PATCH 1/3] Added owners column to the credentials list --- awx/ui/client/src/app.js | 2 ++ awx/ui/client/src/credentials/main.js | 11 +++++++++++ .../client/src/credentials/ownerList.directive.js | 13 +++++++++++++ .../client/src/credentials/ownerList.partial.html | 3 +++ awx/ui/client/src/lists/Credentials.js | 11 +++++++++-- awx/ui/client/src/shared/generator-helpers.js | 10 +++++++++- 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 awx/ui/client/src/credentials/main.js create mode 100644 awx/ui/client/src/credentials/ownerList.directive.js create mode 100644 awx/ui/client/src/credentials/ownerList.partial.html diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 4fd0f98fc4..a03666f5ce 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -52,6 +52,7 @@ import activityStream from './activity-stream/main'; import standardOut from './standard-out/main'; import JobTemplates from './job-templates/main'; import search from './search/main'; +import credentials from './credentials/main'; import {ProjectsList, ProjectsAdd, ProjectsEdit} from './controllers/Projects'; import OrganizationsList from './organizations/list/organizations-list.controller'; import OrganizationsAdd from './organizations/add/organizations-add.controller'; @@ -109,6 +110,7 @@ var tower = angular.module('Tower', [ JobTemplates.name, portalMode.name, search.name, + credentials.name, 'ngToast', 'templates', 'Utilities', diff --git a/awx/ui/client/src/credentials/main.js b/awx/ui/client/src/credentials/main.js new file mode 100644 index 0000000000..faee3f5093 --- /dev/null +++ b/awx/ui/client/src/credentials/main.js @@ -0,0 +1,11 @@ +/************************************************* + * Copyright (c) 2016 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import ownerList from './ownerList.directive'; + +export default + angular.module('credentials', []) + .directive('ownerList', ownerList); diff --git a/awx/ui/client/src/credentials/ownerList.directive.js b/awx/ui/client/src/credentials/ownerList.directive.js new file mode 100644 index 0000000000..a5178bc69b --- /dev/null +++ b/awx/ui/client/src/credentials/ownerList.directive.js @@ -0,0 +1,13 @@ +export default + [ 'templateUrl', + function(templateUrl) { + return { + restrict: 'E', + scope: false, + templateUrl: templateUrl('credentials/ownerList'), + link: function(scope) { + scope.owners_list = scope.credential.summary_fields.owners && scope.credential.summary_fields.owners.length > 0 ? scope.credential.summary_fields.owners : []; + } + }; + } + ]; diff --git a/awx/ui/client/src/credentials/ownerList.partial.html b/awx/ui/client/src/credentials/ownerList.partial.html new file mode 100644 index 0000000000..63dff4423e --- /dev/null +++ b/awx/ui/client/src/credentials/ownerList.partial.html @@ -0,0 +1,3 @@ +
+ {{ owner.name }}{{$last ? '' : ', '}} +
diff --git a/awx/ui/client/src/lists/Credentials.js b/awx/ui/client/src/lists/Credentials.js index 1dd42d6244..74a75c6ef9 100644 --- a/awx/ui/client/src/lists/Credentials.js +++ b/awx/ui/client/src/lists/Credentials.js @@ -39,7 +39,14 @@ export default searchOptions: [], // will be set by Options call to credentials resource excludeModal: true, nosort: true, - columnClass: 'col-md-3 hidden-sm hidden-xs' + columnClass: 'col-md-2 hidden-sm hidden-xs' + }, + owners: { + label: 'Owners', + type: 'owners', + nosort: true, + excludeModal: true, + columnClass: 'col-md-2 hidden-sm hidden-xs' } }, @@ -55,7 +62,7 @@ export default fieldActions: { - columnClass: 'col-md-3 col-sm-3 col-xs-3', + columnClass: 'col-md-2 col-sm-3 col-xs-3', edit: { ngClick: "editCredential(credential.id)", diff --git a/awx/ui/client/src/shared/generator-helpers.js b/awx/ui/client/src/shared/generator-helpers.js index 7a0c517a58..e701b2b782 100644 --- a/awx/ui/client/src/shared/generator-helpers.js +++ b/awx/ui/client/src/shared/generator-helpers.js @@ -482,7 +482,15 @@ angular.module('GeneratorHelpers', [systemStatus.name]) `; - } else if (field.type === 'badgeCount') { + } else if (field.type === 'owners') { + classList = (field.columnClass) ? + Attr(field, 'columnClass') : ""; + html += ` + + + + `; + }else if (field.type === 'badgeCount') { html = BadgeCount(params); } else if (field.type === 'badgeOnly') { html = Badge(field); From ae06286a01b96a1aa3c5788074ad47196415fc3e Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Mon, 6 Jun 2016 16:22:37 -0400 Subject: [PATCH 2/3] Added 'type' to credential serializer owner summary fields --- awx/api/serializers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 582d39630d..4ae7260592 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1659,6 +1659,7 @@ class CredentialSerializer(BaseSerializer): for user in obj.owner_role.members.all(): summary_dict['owners'].append({ 'id': user.pk, + 'type': 'user', 'name': user.username, 'description': ' '.join([user.first_name, user.last_name]), 'url': reverse('api:user_detail', args=(user.pk,)), @@ -1667,6 +1668,7 @@ class CredentialSerializer(BaseSerializer): for parent in obj.owner_role.parents.exclude(object_id__isnull=True).all(): summary_dict['owners'].append({ 'id': parent.content_object.pk, + 'type': camelcase_to_underscore(parent.content_object.__class__.__name__), 'name': parent.content_object.name, 'description': parent.content_object.description, 'url': parent.content_object.get_absolute_url(), From 731e2384bb34dfc556144cf97069f80b5eb02501 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 6 Jun 2016 17:01:16 -0400 Subject: [PATCH 3/3] Handle the three different owner types (organization, user, team) with separate links --- awx/ui/client/src/credentials/ownerList.partial.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/awx/ui/client/src/credentials/ownerList.partial.html b/awx/ui/client/src/credentials/ownerList.partial.html index 63dff4423e..1ed46c081b 100644 --- a/awx/ui/client/src/credentials/ownerList.partial.html +++ b/awx/ui/client/src/credentials/ownerList.partial.html @@ -1,3 +1,5 @@
- {{ owner.name }}{{$last ? '' : ', '}} + {{ owner.name }}{{$last ? '' : ', '}} + {{ owner.name }}{{$last ? '' : ', '}} + {{ owner.name }}{{$last ? '' : ', '}}