From commits-return-19442-archive-asf-public=cust-asf.ponee.io@airavata.apache.org Wed Jul 11 19:10:06 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1184718078F for ; Wed, 11 Jul 2018 19:10:05 +0200 (CEST) Received: (qmail 61720 invoked by uid 500); 11 Jul 2018 17:10:05 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 61711 invoked by uid 99); 11 Jul 2018 17:10:05 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Jul 2018 17:10:05 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 11CD881E15; Wed, 11 Jul 2018 17:10:04 +0000 (UTC) Date: Wed, 11 Jul 2018 17:10:08 +0000 To: "commits@airavata.apache.org" Subject: [airavata-django-portal] 05/05: AIRAVATA-2835 User management in ShareButton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: machristie@apache.org In-Reply-To: <153132900372.24903.12571865907377342241@gitbox.apache.org> References: <153132900372.24903.12571865907377342241@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: airavata-django-portal X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: a790c3eb1a6b659b97ab2b68d62eb02c4ec96e71 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20180711171004.11CD881E15@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git commit a790c3eb1a6b659b97ab2b68d62eb02c4ec96e71 Author: Marcus Christie AuthorDate: Wed Jul 11 13:09:39 2018 -0400 AIRAVATA-2835 User management in ShareButton --- .../django_airavata_api/js/models/UserProfile.js | 2 +- .../django_airavata_api/js/service_config.js | 8 +++ .../common/js/components/AutocompleteTextInput.vue | 3 +- .../static/common/js/components/ShareButton.vue | 66 ++++++++++++++++++++-- 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/UserProfile.js b/django_airavata/apps/api/static/django_airavata_api/js/models/UserProfile.js index 3130ce7..82288a7 100644 --- a/django_airavata/apps/api/static/django_airavata_api/js/models/UserProfile.js +++ b/django_airavata/apps/api/static/django_airavata_api/js/models/UserProfile.js @@ -45,6 +45,6 @@ export default class UserProfile extends BaseModel { } get email() { - return (emails != null && emails.length > 0) ? emails[0] : null; + return (this.emails != null && this.emails.length > 0) ? this.emails[0] : null; } } diff --git a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js index d26953a..ef77613 100644 --- a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js +++ b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js @@ -1,5 +1,6 @@ import Group from './models/Group' import SharedEntity from './models/SharedEntity' +import UserProfile from './models/UserProfile' const post = "post"; const get = "get"; @@ -61,4 +62,11 @@ export default { queryParams: ['limit', 'offset'], modelClass: Group, }, + "UserProfiles": { + url: "/api/user-profiles", + viewSet: [{ + name: "list" + }], + modelClass: UserProfile, + }, } \ No newline at end of file diff --git a/django_airavata/static/common/js/components/AutocompleteTextInput.vue b/django_airavata/static/common/js/components/AutocompleteTextInput.vue index ca8dd20..30ef009 100644 --- a/django_airavata/static/common/js/components/AutocompleteTextInput.vue +++ b/django_airavata/static/common/js/components/AutocompleteTextInput.vue @@ -45,7 +45,8 @@ export default { computed: { filtered () { return this.suggestions.filter((data) => { - return data.name.indexOf(this.searchValue) >= 0 + // Case insensitive search + return data.name.toLowerCase().indexOf(this.searchValue.toLowerCase()) >= 0 }) }, }, diff --git a/django_airavata/static/common/js/components/ShareButton.vue b/django_airavata/static/common/js/components/ShareButton.vue index f161cbc..fa04c15 100644 --- a/django_airavata/static/common/js/components/ShareButton.vue +++ b/django_airavata/static/common/js/components/ShareButton.vue @@ -5,19 +5,38 @@ {{ totalCount }} - + -
Currently Shared With
- +
Currently Shared With
+ + + + + + + @@ -48,11 +67,18 @@ export default { data: function() { return { sharedEntity: this.value ? this.value.clone() : new models.SharedEntity(), + userFields: [ + {key: 'name', label: 'User Name'}, + {key: 'email', label: 'Email'}, + {key: 'permission', label: 'Permission'}, + {key: 'remove', label: 'Remove'}, + ], groupFields: [ {key: 'name', label: 'Group Name'}, - {key: 'permission', label: 'Permission Settings'}, + {key: 'permission', label: 'Permission'}, {key: 'remove', label: 'Remove'}, ], + users: [], groups: [], } }, @@ -103,6 +129,23 @@ export default { type: 'group', } }); + }, + userSuggestions: function() { + // filter out already selected users + const currentUserIds = this.sharedEntity.userPermissions.map(userPerm => userPerm.user.airavataInternalUserId); + return this.users + .filter(user => currentUserIds.indexOf(user.airavataInternalUserId) < 0) + .map(user => { + return { + id: user.airavataInternalUserId, + name: user.firstName + ' ' + user.lastName + ' (' + user.userId + ') ' + user.email, + user: user, + type: 'user', + } + }); + }, + usersAndGroupsSuggestions: function() { + return this.userSuggestions.concat(this.groupSuggestions); } }, methods: { @@ -113,6 +156,10 @@ export default { merge: function(sharedEntity) { // TODO: implement this }, + removeUser: function(user) { + this.sharedEntity.userPermissions = this.sharedEntity.userPermissions.filter( + userPermission => userPermission.user.airavataInternalUserId !== user.airavataInternalUserId); + }, removeGroup: function(group) { this.sharedEntity.groupPermissions = this.sharedEntity.groupPermissions.filter( groupPermission => groupPermission.group.id !== group.id); @@ -124,12 +171,19 @@ export default { 'group': group, 'permissionType': models.ResourcePermissionType.READ })); + } else if (suggestion.type === 'user') { + const user = this.users.find(user => user.airavataInternalUserId === suggestion.id); + this.sharedEntity.userPermissions.push(new models.UserPermission({ + 'user': user, + 'permissionType': models.ResourcePermissionType.READ + })); } } }, mounted: function() { - // Load all of the groups + // Load all of the groups and users services.ServiceFactory.service("Groups").list({limit: -1}).then(groups => this.groups = groups); + services.ServiceFactory.service("UserProfiles").list().then(users => this.users = users); } }