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:32 UTC

[airavata-django-portal] branch master updated (8308b7f -> f9d053c)

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git.


    from 8308b7f  AIRAVATA-2631 Copy app outputs to experiment
     new 362af10  AIRAVATA-2685 List of users for group loaded from UserProfileService
     new efbd654  AIRAVATA-2685 Fix assigning group id for newly created group
     new f9d053c  AIRAVATA-2685 Redirect to group listing when group created

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 django_airavata/apps/api/serializers.py            |   7 ++
 .../api/static/django_airavata_api/js/index.js     |   2 +
 .../static/django_airavata_api/js/models/Group.js  |   9 --
 .../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                  |  16 +++-
 .../js/groups_components/GroupCreate.vue           | 101 +++++++++++----------
 9 files changed, 162 insertions(+), 62 deletions(-)
 create mode 100644 django_airavata/apps/api/static/django_airavata_api/js/models/UserProfile.js
 create mode 100644 django_airavata/apps/api/static/django_airavata_api/js/models/UserStatus.js
 create mode 100644 django_airavata/apps/api/static/django_airavata_api/js/services/UserProfileService.js

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

[airavata-django-portal] 02/03: AIRAVATA-2685 Fix assigning group id for newly created group

Posted by ma...@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 efbd6549f0a9ce41bad3a62ed0f807a9fb2a11e4
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Thu Feb 22 11:13:56 2018 -0500

    AIRAVATA-2685 Fix assigning group id for newly created group
---
 django_airavata/apps/api/views.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 2aa0c47..971be73 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -209,16 +209,16 @@ class GroupViewSet(APIBackedViewSet):
         return GroupResultsIterator()
 
     def get_instance(self, lookup_value):
-        return self.request.airavata_client.getGroup(self.authz_token, self.gateway_id, lookup_value)
+        return self.request.profile_service['group_manager'].getGroup(self.authz_token, lookup_value)
 
     def perform_create(self, serializer):
         group = serializer.save()
         group_id = self.request.profile_service['group_manager'].createGroup(self.authz_token, group)
-        group.groupID = group_id
+        group.id = group_id
 
     def perform_update(self, serializer):
         group = serializer.save()
-        self.request.airavata_client.updateGroup(self.authz_token, group)
+        self.request.profile_service['group_manager'].updateGroup(self.authz_token, group)
 
 
 class ProjectViewSet(APIBackedViewSet):

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

[airavata-django-portal] 03/03: AIRAVATA-2685 Redirect to group listing when group created

Posted by ma...@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 f9d053c98dad05037332a37a17505399c28624a4
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Thu Feb 22 11:14:21 2018 -0500

    AIRAVATA-2685 Redirect to group listing when group created
---
 .../apps/api/static/django_airavata_api/js/models/Group.js       | 9 ---------
 .../django_airavata_groups/js/groups_components/GroupCreate.vue  | 7 ++-----
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/Group.js b/django_airavata/apps/api/static/django_airavata_api/js/models/Group.js
index 3b7a127..f570c2e 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/Group.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/Group.js
@@ -24,13 +24,4 @@ export default class Group extends BaseModel {
         }
         return null;
     }
-
-    toJSONForCreate() {
-        // Remaining fields just get defaulted
-        return JSON.stringify(this, ["name", "description", "members"]);
-    }
-
-    toJSONForUpdate() {
-        return JSON.stringify(this, ["id", "name", "description"]);
-    }
 }
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 c0b7505..90dbadc 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
@@ -55,11 +55,8 @@ export default {
             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();
+                // TODO: redirect to the group view page
+                window.location.assign("/groups/");
             })
             .catch(error => {
                 this.showDismissibleAlert.dismissable = true;

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

[airavata-django-portal] 01/03: AIRAVATA-2685 List of users for group loaded from UserProfileService

Posted by ma...@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 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.