You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/02/22 16:14:33 UTC
[airavata-django-portal] 01/03: AIRAVATA-2685 List of users for
group loaded from UserProfileService
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 362af100e7e61ad7c39fb0547c26e5b0bc328a8d
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Thu Feb 22 10:53:36 2018 -0500
AIRAVATA-2685 List of users for group loaded from UserProfileService
---
django_airavata/apps/api/serializers.py | 7 ++
.../api/static/django_airavata_api/js/index.js | 2 +
.../django_airavata_api/js/models/UserProfile.js | 50 ++++++++++
.../django_airavata_api/js/models/UserStatus.js | 20 ++++
.../js/services/UserProfileService.js | 17 ++++
django_airavata/apps/api/urls.py | 2 +
django_airavata/apps/api/views.py | 10 ++
.../js/groups_components/GroupCreate.vue | 104 +++++++++++----------
8 files changed, 162 insertions(+), 50 deletions(-)
diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index 8ca2aa1..da2a10b 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -24,6 +24,7 @@ from airavata.model.experiment.ttypes import (ExperimentModel,
from airavata.model.group.ttypes import GroupModel
from airavata.model.job.ttypes import JobModel
from airavata.model.status.ttypes import ExperimentStatus
+from airavata.model.user.ttypes import UserProfile
from airavata.model.workspace.ttypes import Project
from . import datastore
@@ -384,3 +385,9 @@ class ExperimentSummarySerializer(
statusUpdateTime = UTCPosixTimestampDateTimeField()
url = FullyEncodedHyperlinkedIdentityField(view_name='django_airavata_api:experiment-detail', lookup_field='experimentId', lookup_url_kwarg='experiment_id')
project = FullyEncodedHyperlinkedIdentityField(view_name='django_airavata_api:project-detail', lookup_field='projectId', lookup_url_kwarg='project_id')
+
+
+class UserProfileSerializer(
+ thrift_utils.create_serializer_class(UserProfile)):
+ creationTime = UTCPosixTimestampDateTimeField()
+ lastAccessTime = UTCPosixTimestampDateTimeField()
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/index.js b/django_airavata/apps/api/static/django_airavata_api/js/index.js
index 352dec1..b9f4b42 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/index.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/index.js
@@ -17,6 +17,7 @@ import ExperimentSearchService from './services/ExperimentSearchService'
import FullExperimentService from './services/FullExperimentService'
import ProjectService from './services/ProjectService'
import GroupService from './services/GroupService'
+import UserProfileService from './services/UserProfileService'
import FetchUtils from './utils/FetchUtils'
import PaginationIterator from './utils/PaginationIterator'
@@ -42,6 +43,7 @@ exports.services = {
FullExperimentService,
ProjectService,
GroupService,
+ UserProfileService,
}
exports.utils = {
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
new file mode 100644
index 0000000..3130ce7
--- /dev/null
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/UserProfile.js
@@ -0,0 +1,50 @@
+import BaseModel from './BaseModel'
+import UserStatus from './UserStatus'
+
+const FIELDS = [
+ 'userModelVersion',
+ 'airavataInternalUserId',
+ 'userId',
+ 'gatewayId',
+ 'emails',
+ 'firstName',
+ 'lastName',
+ 'middleName',
+ 'namePrefix',
+ 'nameSuffix',
+ 'orcidId',
+ 'phones',
+ 'country',
+ 'nationality',
+ 'homeOrganization',
+ 'orginationAffiliation',
+ {
+ name: 'creationTime',
+ type: 'date',
+ },
+ {
+ name: 'lastAccessTime',
+ type: 'date',
+ },
+ 'validUntil',
+ {
+ name: 'State',
+ type: UserStatus,
+ },
+ 'comments',
+ 'labeledURI',
+ 'gpgKey',
+ 'timeZone',
+ 'nsfDemographics',
+ 'customDashboard',
+];
+
+export default class UserProfile extends BaseModel {
+ constructor(data = {}) {
+ super(FIELDS, data);
+ }
+
+ get email() {
+ return (emails != null && emails.length > 0) ? emails[0] : null;
+ }
+}
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/UserStatus.js b/django_airavata/apps/api/static/django_airavata_api/js/models/UserStatus.js
new file mode 100644
index 0000000..9740e3a
--- /dev/null
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/UserStatus.js
@@ -0,0 +1,20 @@
+import BaseEnum from './BaseEnum'
+
+export default class UserStatus extends BaseEnum {
+}
+UserStatus.init([
+ 'ACTIVE',
+ 'CONFIRMED',
+ 'APPROVED',
+ 'DELETED',
+ 'DUPLICATE',
+ 'GRACE_PERIOD',
+ 'INVITED',
+ 'DENIED',
+ 'PENDING',
+ 'PENDING_APPROVAL',
+ 'PENDING_CONFIRMATION',
+ 'SUSPENDED',
+ 'DECLINED',
+ 'EXPIRED',
+]);
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/services/UserProfileService.js b/django_airavata/apps/api/static/django_airavata_api/js/services/UserProfileService.js
new file mode 100644
index 0000000..23daf7e
--- /dev/null
+++ b/django_airavata/apps/api/static/django_airavata_api/js/services/UserProfileService.js
@@ -0,0 +1,17 @@
+
+import UserProfile from '../models/UserProfile'
+import FetchUtils from '../utils/FetchUtils'
+
+class UserProfileService {
+ list(data = null) {
+ if (data) {
+ return Promise.resolve(data.map(result => new UserProfile(result)));
+ } else {
+ return FetchUtils.get('/api/user-profiles/')
+ .then(results => results.map(result => new UserProfile(result)));
+ }
+ }
+}
+
+// Export as a singleton
+export default new UserProfileService();
\ No newline at end of file
diff --git a/django_airavata/apps/api/urls.py b/django_airavata/apps/api/urls.py
index bc63c5a..113cf28 100644
--- a/django_airavata/apps/api/urls.py
+++ b/django_airavata/apps/api/urls.py
@@ -18,6 +18,8 @@ router.register(r'new/application/module', views.RegisterApplicationModule, base
router.register(r'application-interfaces', views.ApplicationInterfaceViewSet, base_name='application-interface')
router.register(r'applications', views.ApplicationModuleViewSet, base_name='application')
router.register(r'application-deployments', views.ApplicationDeploymentViewSet, base_name='application-deployment')
+router.register(r'user-profiles', views.UserProfileViewSet,
+ base_name='user-profile')
app_name = 'django_airavata_api'
urlpatterns = [
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 0c4db23..2aa0c47 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -674,3 +674,13 @@ def download_file(request):
return response
except ObjectDoesNotExist as e:
raise Http404(str(e)) from e
+
+
+class UserProfileViewSet(mixins.ListModelMixin, GenericAPIBackedViewSet):
+
+ serializer_class = serializers.UserProfileSerializer
+
+ def get_list(self):
+ user_profile_client = self.request.profile_service['user_profile']
+ return user_profile_client.getAllUserProfilesInGateway(
+ self.authz_token, self.gateway_id, 0, -1)
diff --git a/django_airavata/apps/groups/static/django_airavata_groups/js/groups_components/GroupCreate.vue b/django_airavata/apps/groups/static/django_airavata_groups/js/groups_components/GroupCreate.vue
index b15d7cb..c0b7505 100644
--- a/django_airavata/apps/groups/static/django_airavata_groups/js/groups_components/GroupCreate.vue
+++ b/django_airavata/apps/groups/static/django_airavata_groups/js/groups_components/GroupCreate.vue
@@ -32,56 +32,60 @@ import { models, services } from 'django-airavata-api'
import Autocomplete from './Autocomplete.vue'
export default {
- data () {
- return {
- selection: '',
- suggestions: [
- { id: 1, name: 'Stephen' },
- { id: 2, name: 'marcus@seagrid' },
- { id: 3, name: 'marlonpierce@seagrid' },
- { id: 4, name: 'Suresh' },
- { id: 5, name: 'Eroma' },
- { id: 6, name: 'Sachin' },
- { id: 7, name: 'Jerrin' },
- { id: 8, name: 'Eldho' },
- { id: 9, name: 'Dimuthu' },
- { id: 10, name: 'Ameya' },
- { id: 11, name: 'Sneha' },
- ],
- newGroup: new models.Group(),
- show: true,
- selected: [],
- showDismissibleAlert: {'variant':'success', 'message':'no data', 'dismissable':false},
- }
- },
- components: {
- Autocomplete
- },
- methods: {
- submitForm () {
- var temp = [];
- for(var i=0;i<this.selected.length;i++) {
- temp.push(this.selected[i].name);
- }
- this.newGroup.members = temp;
- console.log(JSON.stringify(this.newGroup));
- services.GroupService.create(this.newGroup)
- .then(result => {
- console.log(result.json());
- this.showDismissibleAlert.dismissable = true;
- this.showDismissibleAlert.message = "Successfully created a new group";
- this.showDismissibleAlert.variant = "success";
- this.newGroup = new models.Group();
- })
- .catch(error => {
- this.showDismissibleAlert.dismissable = true;
- this.showDismissibleAlert.message = "Error: "+error.data;
- this.showDismissibleAlert.variant = "danger";
- });
+ data () {
+ return {
+ selection: '',
+ newGroup: new models.Group(),
+ show: true,
+ selected: [],
+ showDismissibleAlert: {'variant':'success', 'message':'no data', 'dismissable':false},
+ userProfiles: [],
+ }
+ },
+ components: {
+ Autocomplete
+ },
+ methods: {
+ submitForm () {
+ var temp = [];
+ for(var i=0;i<this.selected.length;i++) {
+ temp.push(this.selected[i].id);
+ }
+ this.newGroup.members = temp;
+ console.log(JSON.stringify(this.newGroup));
+ services.GroupService.create(this.newGroup)
+ .then(result => {
+ console.log(result.json());
+ this.showDismissibleAlert.dismissable = true;
+ this.showDismissibleAlert.message = "Successfully created a new group";
+ this.showDismissibleAlert.variant = "success";
+ this.newGroup = new models.Group();
+ })
+ .catch(error => {
+ this.showDismissibleAlert.dismissable = true;
+ this.showDismissibleAlert.message = "Error: "+error.data;
+ this.showDismissibleAlert.variant = "danger";
+ });
+ },
+ updateSelectedValue(data) {
+ this.selected = data;
+ },
+ },
+ computed: {
+ suggestions: function() {
+ return this.userProfiles.map(userProfile => {
+ return {
+ id: userProfile.airavataInternalUserId,
+ name: userProfile.firstName + ' ' + userProfile.lastName + ' (' + userProfile.userId + ')'
+ }
+ })
+ }
+ },
+ mounted: function () {
+ services.UserProfileService.list()
+ .then(userProfiles => {
+ this.userProfiles = userProfiles;
+ });
},
- updateSelectedValue(data) {
- this.selected = data;
- }
- }
}
</script>
--
To stop receiving notification emails like this one, please contact
machristie@apache.org.