airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 03/10: AIRAVATA-2711 Switch to using ServiceFactory for groups
Date Thu, 15 Nov 2018 16:13:16 GMT
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 76083c6ea8f61f36fa84c7b20a29085ad308c05d
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Wed Nov 7 11:51:31 2018 -0500

    AIRAVATA-2711 Switch to using ServiceFactory for groups
---
 .../api/static/django_airavata_api/js/index.js     |  3 +-
 .../static/django_airavata_api/js/models/Group.js  |  1 +
 .../js/services/GroupService.js                    | 63 ----------------------
 .../js/containers/GroupEditContainer.vue           |  2 +-
 .../js/containers/GroupsManageContainer.vue        |  2 +-
 .../js/group_components/GroupEditor.vue            |  4 +-
 .../js/group_components/GroupListItem.vue          |  2 +-
 .../static/common/js/components/ShareButton.vue    |  4 +-
 8 files changed, 9 insertions(+), 72 deletions(-)

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 7a04bee..9cfa626 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
@@ -33,7 +33,6 @@ import ExperimentService from "./services/ExperimentService";
 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 CloudJobSubmissionService from "./services/CloudJobSubmissionService";
 import GlobusJobSubmissionService from "./services/GlobusJobSubmissionService";
@@ -99,7 +98,7 @@ exports.services = {
   GlobusJobSubmissionService,
   GridFTPDataMovementService,
   GroupResourceProfileService: ServiceFactory.service("GroupResourceProfiles"),
-  GroupService,
+  GroupService: ServiceFactory.service("Groups"),
   LocaJobSubmissionService,
   ProjectService,
   SCPDataMovementService,
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 54afe01..7b6fb42 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
@@ -6,6 +6,7 @@ const FIELDS = [
     'ownerId',
     'description',
     'members',
+    'admins',
     'isOwner',
     'isAdmin',
     'isMember',
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/services/GroupService.js
b/django_airavata/apps/api/static/django_airavata_api/js/services/GroupService.js
deleted file mode 100644
index 3a7685e..0000000
--- a/django_airavata/apps/api/static/django_airavata_api/js/services/GroupService.js
+++ /dev/null
@@ -1,63 +0,0 @@
-
-import Group from '../models/Group'
-import PaginationIterator from '../utils/PaginationIterator'
-import FetchUtils from '../utils/FetchUtils'
-
-class GroupService {
-
-    list(data={}) {
-      if (data && data.results) {
-          return Promise.resolve(new PaginationIterator(data, Group));
-      } else {
-          return fetch('/api/groups/', {
-              credentials: 'include'
-          })
-          .then(response => response.json())
-          .then(json => new PaginationIterator(json, Group));
-      }
-    }
-
-    create(group) {
-        return FetchUtils.post('/api/groups/', JSON.stringify(group))
-            .then(result => new Group(result))
-    }
-
-    update(group) {
-        return FetchUtils.put('/api/groups/' + encodeURIComponent(group.id) + '/', JSON.stringify(group))
-            .then(result => new Group(result));
-    }
-
-    get(groupId, data = null) {
-        if (data) {
-            return Promise.resolve(new Group(data));
-        } else {
-            return FetchUtils.get('/api/groups/'
-                    + encodeURIComponent(groupId) + '/')
-                .then(result => new Group(result));
-        }
-    }
-
-    delete(groupId) {
-        return FetchUtils.delete('/api/groups/'
-                                 + encodeURIComponent(groupId) + '/');
-    }
-
-    // adminIds is an array of sharing user ids, for example:
-    //   ['user1@test-domain', 'user2@test-domain']
-    addAdmins(groupId, adminIds) {
-        return FetchUtils.post('/api/groups/'
-                                 + encodeURIComponent(groupId) + '/add_admins/',
-                               JSON.stringify(adminIds));
-    }
-
-    // adminIds is an array of sharing user ids, for example:
-    //   ['user1@test-domain', 'user2@test-domain']
-    removeAdmins(groupId, adminIds) {
-        return FetchUtils.post('/api/groups/'
-                                 + encodeURIComponent(groupId) + '/remove_admins/',
-                               JSON.stringify(adminIds));
-    }
-}
-
-// Export as a singleton
-export default new GroupService();
diff --git a/django_airavata/apps/groups/static/django_airavata_groups/js/containers/GroupEditContainer.vue
b/django_airavata/apps/groups/static/django_airavata_groups/js/containers/GroupEditContainer.vue
index 152a33e..66b036d 100644
--- a/django_airavata/apps/groups/static/django_airavata_groups/js/containers/GroupEditContainer.vue
+++ b/django_airavata/apps/groups/static/django_airavata_groups/js/containers/GroupEditContainer.vue
@@ -33,7 +33,7 @@ export default {
     computed: {
     },
     mounted: function () {
-        services.GroupService.get(this.groupId)
+        services.GroupService.retrieve({lookup: this.groupId})
             .then(group => this.group = group);
     },
 }
diff --git a/django_airavata/apps/groups/static/django_airavata_groups/js/containers/GroupsManageContainer.vue
b/django_airavata/apps/groups/static/django_airavata_groups/js/containers/GroupsManageContainer.vue
index a5a7637..e296ccf 100755
--- a/django_airavata/apps/groups/static/django_airavata_groups/js/containers/GroupsManageContainer.vue
+++ b/django_airavata/apps/groups/static/django_airavata_groups/js/containers/GroupsManageContainer.vue
@@ -55,7 +55,7 @@ export default {
         },
     },
     beforeMount: function () {
-        services.GroupService.list(this.groupsDataOwners)
+        services.GroupService.list()
             .then(result => this.groupPaginator = result);
     },
 }
diff --git a/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupEditor.vue
b/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupEditor.vue
index b573eb9..5f7f205 100644
--- a/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupEditor.vue
+++ b/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupEditor.vue
@@ -52,8 +52,8 @@ export default {
     methods: {
         submitForm () {
             let saveOperation = (this.localGroup.id)
-                ? services.GroupService.update(this.localGroup)
-                : services.GroupService.create(this.localGroup);
+                ? services.GroupService.update({lookup: this.localGroup.id, data: this.localGroup})
+                : services.GroupService.create({data: this.localGroup});
             saveOperation
                 .then(group => {
                     this.$emit('saved', group);
diff --git a/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupListItem.vue
b/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupListItem.vue
index 6357d9f..c8de521 100644
--- a/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupListItem.vue
+++ b/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupListItem.vue
@@ -58,7 +58,7 @@ export default {
     methods: {
       deleteGroup(id) {
           this.deleting = true;
-          services.GroupService.delete(id)
+          services.GroupService.delete({lookup: id})
               .then(result => {
                   this.$emit('deleteSuccess','Group Deleted Successfully!');
                   this.show = false;
diff --git a/django_airavata/static/common/js/components/ShareButton.vue b/django_airavata/static/common/js/components/ShareButton.vue
index 5231c3e..2a8f2de 100644
--- a/django_airavata/static/common/js/components/ShareButton.vue
+++ b/django_airavata/static/common/js/components/ShareButton.vue
@@ -108,7 +108,7 @@ export default {
         !this.defaultGatewayUsersGroup
       ) {
         promises.push(
-          services.ServiceFactory.service("Groups")
+          services.GroupService
             .list({ limit: -1 })
             .then(groups => {
               this.groups = groups;
@@ -188,7 +188,7 @@ export default {
           .then(users => (this.users = users));
       }
       if (!this.groups) {
-        services.ServiceFactory.service("Groups")
+        services.GroupService
           .list({ limit: -1 })
           .then(groups => {
             this.groups = groups;


Mime
View raw message