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 fb3e0e42e562f5b34045a5e942c2af0f71c8f327
Author: Marcus Christie <machr...@iu.edu>
AuthorDate: Tue Jul 10 17:38:51 2018 -0400

    AIRAVATA-2835 Sharing modal with group management
---
 .../GroupComputeResourcePreference.vue             |  3 +-
 .../api/static/django_airavata_api/js/index.js     | 13 ++--
 .../js/services/ServiceFactory.js                  |  1 +
 .../static/common/js/components/ShareButton.vue    | 72 +++++++++++++++++++---
 4 files changed, 73 insertions(+), 16 deletions(-)

diff --git 
a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
 
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
index 337ebdf..af956ea 100644
--- 
a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
+++ 
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
@@ -79,7 +79,8 @@
       this.fetchGroup(this.value.groupResourceProfileId);
       if (this.value.groupResourceProfileId) {
         
DjangoAiravataAPI.services.ServiceFactory.service("SharedEntities").retrieve({lookup:
 this.value.groupResourceProfileId})
-          .then(sharedEntity => this.sharedEntity = sharedEntity);
+          // TODO: once ServiceFactory supports model classes, won't need to 
do this conversion
+          .then(sharedEntity => this.sharedEntity = new 
DjangoAiravataAPI.models.SharedEntity(sharedEntity));
       }
     },
     data: function () {
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 cf101d4..5181ad9 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
@@ -1,14 +1,16 @@
+
 import ApplicationInterfaceDefinition from 
'./models/ApplicationInterfaceDefinition'
 import ApplicationModule from './models/ApplicationModule'
 import DataType from './models/DataType'
 import Experiment from './models/Experiment'
 import ExperimentState from './models/ExperimentState'
-import InputDataObjectType from './models/InputDataObjectType'
-import OutputDataObjectType from './models/OutputDataObjectType'
-import Project from './models/Project'
 import FullExperiment from './models/FullExperiment'
 import Group from './models/Group'
 import GroupResourceProfile from './models/GroupResourceProfile'
+import InputDataObjectType from './models/InputDataObjectType'
+import OutputDataObjectType from './models/OutputDataObjectType'
+import Project from './models/Project'
+import ResourcePermissionType from './models/ResourcePermissionType'
 import SharedEntity from './models/SharedEntity'
 
 import ApplicationDeploymentService from 
'./services/ApplicationDeploymentService'
@@ -41,11 +43,12 @@ exports.models = {
     Experiment,
     ExperimentState,
     FullExperiment,
+    Group,
+    GroupResourceProfile,
     InputDataObjectType,
     OutputDataObjectType,
     Project,
-    Group,
-    GroupResourceProfile,
+    ResourcePermissionType,
     SharedEntity,
 }
 
diff --git 
a/django_airavata/apps/api/static/django_airavata_api/js/services/ServiceFactory.js
 
b/django_airavata/apps/api/static/django_airavata_api/js/services/ServiceFactory.js
index 2d51f4e..fd43220 100644
--- 
a/django_airavata/apps/api/static/django_airavata_api/js/services/ServiceFactory.js
+++ 
b/django_airavata/apps/api/static/django_airavata_api/js/services/ServiceFactory.js
@@ -171,6 +171,7 @@ class ServiceFactory {
                     }
                 };
                 switch (config.requestType.toLowerCase()) {
+                    // TODO: convert response to instances of model class
                     case postKey:
                         return FetchUtils.post(url, bodyParams, 
queryParams).then(paginationHandler);
                     case getKey:
diff --git a/django_airavata/static/common/js/components/ShareButton.vue 
b/django_airavata/static/common/js/components/ShareButton.vue
index cc7b643..03b2928 100644
--- a/django_airavata/static/common/js/components/ShareButton.vue
+++ b/django_airavata/static/common/js/components/ShareButton.vue
@@ -1,8 +1,24 @@
 <template>
-    <b-button :variant="'outline-primary'" :title="title">
-        Share
-        <b-badge>{{ totalCount }}</b-badge>
-    </b-button>
+    <div id="share-button">
+        <b-button v-b-modal.modal-share-settings :variant="'outline-primary'" 
:title="title">
+            Share
+            <b-badge>{{ totalCount }}</b-badge>
+        </b-button>
+        <b-modal id="modal-share-settings" title="Sharing Settings">
+            <h5>Currently Shared With</h5>
+            <b-table id="modal-group-table" hover 
:items="sharedEntity.groupPermissions" :fields="groupFields">
+                <template slot="name" slot-scope="data">
+                    {{data.item.group.name}}
+                </template>
+                <template slot="permission" slot-scope="data">
+                    <b-form-select v-model="data.item.permissionType" 
:options="permissionOptions"/>
+                </template>
+                <template slot="remove" slot-scope="data">
+                    <a href="#" 
@click.prevent="removeGroup(data.item.group)"><span class="fa 
fa-trash"></span></a>
+                </template>
+            </b-table>
+        </b-modal>
+    </div>
 </template>
 
 <script>
@@ -14,6 +30,16 @@ export default {
         value: models.SharedEntity,
         // TODO: add gatewayGroups
     },
+    data: function() {
+        return {
+            sharedEntity: this.value ? this.value.clone() : new 
models.SharedEntity(),
+            groupFields: [
+                {key: 'name', label: 'Group Name'},
+                {key: 'permission', label: 'Permission Settings'},
+                {key: 'remove', label: 'Remove'},
+            ],
+        }
+    },
     computed: {
         title: function() {
             return "Shared with " + this.groupsCount + " groups"
@@ -22,24 +48,46 @@ export default {
                 + (this.usersCount > 0 ? " (" + this.userNames.join(", ") + 
")" : "");
         },
         usersCount: function() {
-            return this.value ? this.value.userPermissions.length : 0;
+            return this.sharedEntity ? 
this.sharedEntity.userPermissions.length : 0;
         },
         userNames: function() {
-            return this.value
-                ? this.value.userPermissions.map(userPerm => 
userPerm.user.firstName + " " + userPerm.user.lastName)
+            return this.sharedEntity
+                ? this.sharedEntity.userPermissions.map(userPerm => 
userPerm.user.firstName + " " + userPerm.user.lastName)
                 : null;
         },
         groupNames: function() {
-            return this.value
-                ? this.value.groupPermissions.map(groupPerm => 
groupPerm.group.name)
+            return this.sharedEntity
+                ? this.sharedEntity.groupPermissions.map(groupPerm => 
groupPerm.group.name)
                 : null;
         },
         groupsCount: function() {
-            return this.value ? this.value.groupPermissions.length: 0;
+            return this.sharedEntity ? 
this.sharedEntity.groupPermissions.length: 0;
         },
         totalCount: function() {
             return this.usersCount + this.groupsCount;
         },
+        permissionOptions: function() {
+            return [models.ResourcePermissionType.READ,
+                    models.ResourcePermissionType.WRITE].map(perm => {
+                return {
+                    value: perm,
+                    text: perm.name,
+                }
+            })
+        }
+    },
+    methods: {
+        /**
+         * Merge the given persisted SharedEntity with the local SharedEntity
+         * instance and save it, returning a Promise.
+         */
+        merge: function(sharedEntity) {
+            // TODO: implement this
+        },
+        removeGroup: function(group) {
+            this.sharedEntity.groupPermissions = 
this.sharedEntity.groupPermissions.filter(
+                groupPermission => groupPermission.group.id !== group.id);
+        }
     }
 }
 </script>
@@ -48,4 +96,8 @@ export default {
 button {
     background-color: white;
 }
+#share-button >>> #modal-share-settings .modal-body {
+    max-height: 50vh;
+    overflow: auto;
+}
 </style>
\ No newline at end of file

Reply via email to