airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [3/4] airavata-php-gateway git commit: fully integrated project sharing
Date Mon, 11 Jul 2016 19:09:46 GMT
fully integrated project sharing


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/460fa7f8
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/460fa7f8
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/460fa7f8

Branch: refs/heads/grouper-integration
Commit: 460fa7f88eca09a4969a8dc41ea53ef312b4969a
Parents: 5c0b259
Author: Jeff Kinnison <jeffdkinnison@gmail.com>
Authored: Mon Jul 11 14:07:35 2016 -0400
Committer: Jeff Kinnison <jeffdkinnison@gmail.com>
Committed: Mon Jul 11 14:07:35 2016 -0400

----------------------------------------------------------------------
 app/controllers/ProjectController.php |  8 +--
 app/libraries/ProjectUtilities.php    | 26 ++++-----
 app/views/project/create.blade.php    |  4 +-
 public/js/sharing/share.js            | 85 ++++++++++++++----------------
 public/js/sharing/sharing_utils.js    | 35 +++++++++---
 5 files changed, 86 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/460fa7f8/app/controllers/ProjectController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ProjectController.php b/app/controllers/ProjectController.php
index eba7035..dbeb668 100755
--- a/app/controllers/ProjectController.php
+++ b/app/controllers/ProjectController.php
@@ -27,10 +27,12 @@ class ProjectController extends BaseController
     {
         $uids = GrouperUtilities::getAllGatewayUsers();
         $users = array();
-        for ($i = 0; $i < count($uids); $i++) {
-            $string = $uids[$i] . '@' . Config::get('pga_config.wsis')['tenant-domain'];
-            $users[$i] = WSIS::getUserProfile($string);
+        foreach ($uids as $uid) {
+            if (WSIS::usernameExists($uid)) {
+                $users[$uid] = WSIS::getUserProfile($uid);
+            }
         }
+        //var_dump($users);exit;
         return View::make("project/create", array("users" => json_encode($users)));
     }
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/460fa7f8/app/libraries/ProjectUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ProjectUtilities.php b/app/libraries/ProjectUtilities.php
index acb9ed3..6bb3c67 100644
--- a/app/libraries/ProjectUtilities.php
+++ b/app/libraries/ProjectUtilities.php
@@ -106,21 +106,15 @@ class ProjectUtilities
         $project->gatewayId = Config::get('pga_config.airavata')['gateway-id'];
 
         $share = $_POST['share-settings'];
+        $share = json_decode($share);
+        var_dump($share);
+        exit;
 
         $projectId = null;
 
         try {
             $projectId = Airavata::createProject(Session::get('authz-token'), Config::get('pga_config.airavata')['gateway-id'],
$project);
 
-            $add = array();
-            $revoke = array();
-
-            $share = json_decode($share);
-
-            if (json_last_error() === JSON_ERROR_NONE) {
-                $this->share_project($projectId, $share);
-            }
-
             if ($projectId) {
                 CommonUtilities::print_success_message("<p>Project {$_POST['project-name']}
created!</p>" .
                     '<p>You will be redirected to the summary page shortly, or you
can
@@ -136,6 +130,8 @@ class ProjectUtilities
             CommonUtilities::print_error_message('AiravataSystemException!<br><br>'
. $ase->getMessage());
         }
 
+        $this->share_project($projectId, ResourceType::Project, json_decode($share));
+
         return $projectId;
     }
 
@@ -293,18 +289,18 @@ class ProjectUtilities
                 $wrevoke[$user] = ResourcePermissionType::WRITE;
             }
 
-            GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::Project, $wadd);
-            GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project::Project,
$wrevoke);
-
             if ($perms['read']) {
                 $radd[$user] = ResourcePermissionType::READ;
             }
             else {
                 $rrevoke[$user] = ResourcePermissionType::READ;
             }
-
-            GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::Project, $radd);
-            GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project::Project,
$rrevoke);
         }
+
+        GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::Project, $wadd);
+        GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project::Project,
$wrevoke);
+
+        GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::Project, $radd);
+        GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType.Project::Project,
$rrevoke);
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/460fa7f8/app/views/project/create.blade.php
----------------------------------------------------------------------
diff --git a/app/views/project/create.blade.php b/app/views/project/create.blade.php
index 94348af..4f9147d 100755
--- a/app/views/project/create.blade.php
+++ b/app/views/project/create.blade.php
@@ -28,11 +28,11 @@
         <div class="form-group">
             <label for="project-share">Sharing Settings</label><br />
             <button class="btn btn-default" name="project-share" id="project-share">Share
With Other Users</button><br />
-            <label>Show</label>
+            <!-- <label>Show</label>
             <div id="show-results-group" class="btn-group" role="group" aria-label="Show
Groups or Users">
                 <button type="button" class="show-groups show-results-btn btn btn-primary">Groups</button>
                 <button type="button" class="show-users show-results-btn btn btn-default">Users</button>
-            </div>
+            </div> -->
             <label>Order By</label>
             <select class="order-results-selector">
                 <option value="username">Username</option>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/460fa7f8/public/js/sharing/share.js
----------------------------------------------------------------------
diff --git a/public/js/sharing/share.js b/public/js/sharing/share.js
index 0be74e5..b417b7c 100755
--- a/public/js/sharing/share.js
+++ b/public/js/sharing/share.js
@@ -6,10 +6,8 @@
 
 var access_enum = {
     NONE: '0',
-    VIEW: '1',
-    RUN: '2',
-    EDIT: '3',
-    ADMIN: '4'
+    READ: '1',
+    WRITE: '2'
 };
 
 var dummy_user_data = [
@@ -119,12 +117,12 @@ $(function() {
                         <div class="modal-body"> \
                             <label>Click on the users you would like to share with.</label>
\
                             <input id="share-box-filter" class="form-control" type="text"
placeholder="Filter the user list" /> \
-                            <label>Show</label> \
-                            <div id="show-results-group" class="btn-group" role="group"
aria-label="Show Groups or Users">\
-                                <button type="button" class="show-groups show-results-btn
btn btn-primary">Groups</button> \
-                                <button type="button" class="show-users show-results-btn
btn btn-default">Users</button> \
-                            </div> \
-                            <label>Order By</label> \
+                            <label>Show</label>' //\
+                            // <div id="show-results-group" class="btn-group" role="group"
aria-label="Show Groups or Users">\
+                            //     <button type="button" class="show-groups show-results-btn
btn btn-primary">Groups</button> \
+                            //     <button type="button" class="show-users show-results-btn
btn btn-default">Users</button> \
+                            // </div> \
+                            + '<label>Order By</label> \
                             <select class="order-results-selector"> \
                                 <option value="username">Username</option> \
                                 <option value="firstlast">First, Last Name</option>
\
@@ -156,44 +154,36 @@ $(function() {
         $users = $('#share-box-users');
         $share = $('#share-box-share');
 
-        for (var user in dummy_user_data) {
-            if (dummy_user_data.hasOwnProperty(user)) {
-                data = dummy_user_data[user];
-                $user = createThumbnail(data.username, data.firstname, data.lastname, data.email,
data.access);
+        for (var user in users) {
+            if (users.hasOwnProperty(user)) {
+                data = users[user];
+                $user = createThumbnail(user, data.firstname, data.lastname, data.email,
access_enum.NONE);
                 $user.addClass('user-thumbnail');
-                if (data.access === access_enum.NONE) {
-                    $user.addClass('share-box-users-item');
-                    $users.append($user);
-                }
-                else {
-                    $user.addClass('share-box-share-item');
-                    $user.find('.sharing-thumbnail-access').prop("disabled", false).show();
-                    $user.find('.sharing-thumbnail-unshare').show();
-                    $share.append($user);
-                }
-            }
-        }
-
-        for (var group in dummy_group_data) {
-            if (dummy_group_data.hasOwnProperty(group)) {
-                data = dummy_group_data[group];
-                $group = createThumbnail(data.username, data.firstname, data.lastname, data.email,
data.access);
-                $group.addClass('group-thumbnail');
-                if (data.access === access_enum.NONE) {
-                    $group.addClass('share-box-users-item');
-                    $users.append($group);
-                }
-                else {
-                    $group.addClass('share-box-share-item');
-                    $group.find('.sharing-thumbnail-access').prop("disabled", false).show();
-                    $group.find('.sharing-thumbnail-unshare').show();
-                    $share.append($group);
-                }
+                $user.addClass('share-box-users-item');
+                $users.append($user);
             }
         }
 
-        $('.user-thumbnail').hide();
-        $('.group-thumbnail').show();
+        // for (var group in dummy_group_data) {
+        //     if (dummy_group_data.hasOwnProperty(group)) {
+        //         data = dummy_group_data[group];
+        //         $group = createThumbnail(data.username, data.firstname, data.lastname,
data.email, data.access);
+        //         $group.addClass('group-thumbnail');
+        //         if (data.access === access_enum.NONE) {
+        //             $group.addClass('share-box-users-item');
+        //             $users.append($group);
+        //         }
+        //         else {
+        //             $group.addClass('share-box-share-item');
+        //             $group.find('.sharing-thumbnail-access').prop("disabled", false).show();
+        //             $group.find('.sharing-thumbnail-unshare').show();
+        //             $share.append($group);
+        //         }
+        //     }
+        // }
+
+        $('.user-thumbnail').show();
+        //$('.group-thumbnail').show();
     }
 
 
@@ -295,11 +285,12 @@ $(function() {
 
     // Save the sharing permissions of each selected user
     $('body').on('click', '#share-box-button', function(e) {
-        var data, resource_id, $share_list;
+        var data, resource_id, $share_list, share_settings;
         e.stopPropagation();
         e.preventDefault();
         data = $("#share-box").data()
         $share_list = $("#share-box-share").children();
+        share_settings = {};
         if (data.hasOwnProperty('resource_id')) {
             resource_id = data.resource_id;
             updateUserPrivileges(resource_id, $share_list);
@@ -309,16 +300,18 @@ $(function() {
             if ($share_list.filter('.sharing-thumbnail').length > 0) {
                 $share_list.sort(comparator_map.username);
                 $share_list.each(function(index, element) {
-                    var $e, data;
+                    var $e, data, settings;
                     $e = $(element);
                     data = $e.data();
                     if (data.hasOwnProperty('currentaccess')) {
                         data.access = data.currentaccess;
                         $e.data(data);
                     }
+                    share_settings[data.username] = data.access;
                     $e.find('.sharing-thumbnail-access').prop('disabled', true);
                     $e.find('.sharing-thumbnail-unshare').hide();
                 });
+                $('#share-settings').val(JSON.stringify(share_settings));
                 $('#shared-users').removeClass('text-align-center');
                 $share_list.detach().appendTo($('#shared-users'));
             }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/460fa7f8/public/js/sharing/sharing_utils.js
----------------------------------------------------------------------
diff --git a/public/js/sharing/sharing_utils.js b/public/js/sharing/sharing_utils.js
index 2261d66..46bee1b 100644
--- a/public/js/sharing/sharing_utils.js
+++ b/public/js/sharing/sharing_utils.js
@@ -6,20 +6,36 @@ var createThumbnail = function(username, firstname, lastname, email, access
= ac
       firstname: firstname,
       lastname: lastname,
       email: email,
-      access: access
+      access: {
+          read: false,
+          write: false
+      },
+      currentaccess: {
+          read: false,
+          write: false
+      }
   };
 
+  if (access === access_enum.READ) {
+      data.access.read = true;
+      data.currentaccess.read = true;
+  }
+  else if (access === access_enum.WRITE) {
+      data.access.read = true;
+      data.access.write = true;
+      data.currentaccess.read = true;
+      data.currentaccess.write = true;
+  }
+
   select = '';
 
   if (share) {
       select = '<select class="sharing-thumbnail-access" style="display: none;" disabled>';
 
       options = '';
-      options += '<option value="' + access_enum.NONE + '"' + (access === access_enum.NONE
? "selected" : "") + ' style="display: none;">Can View</option>';
-      options += '<option value="' + access_enum.VIEW + '"' + (access === access_enum.VIEW
? "selected" : "") + '>Can View</option>';
-      options += '<option value="' + access_enum.RUN + '"' + (access === access_enum.RUN
? "selected" : "") + '>Can Run</option>';
-      options += '<option value="' + access_enum.EDIT + '"' + (access === access_enum.EDIT
? "selected" : "") + '>Can Edit</option>';
-      options += '<option value="' + access_enum.ADMIN + '"' + (access === access_enum.ADMIN
? "selected" : "") + '>All Privileges</option>';
+      options += '<option value="' + access_enum.NONE + '"' + (access === access_enum.NONE
? "selected" : "") + ' style="display: none;">No Permissions</option>';
+      options += '<option value="' + access_enum.READ + '"' + (access === access_enum.VIEW
? "selected" : "") + '>Can Read</option>';
+      options += '<option value="' + access_enum.WRITE + '"' + (access === access_enum.RUN
? "selected" : "") + '>Can Write</option>';
 
       select += options;
       select += '</select>';
@@ -48,10 +64,14 @@ var createThumbnail = function(username, firstname, lastname, email, access
= ac
 }
 
 var changeShareState = function($target) {
+    var data;
+    data = $target.data();
     // If the user has sharing privileges, revoke them
     if ($target.hasClass('share-box-users-item')) {
         console.log("Sharing");
         $target.find('.sharing-thumbnail-access').val('1').prop("disabled", false).show();
+        data.access.read = true;
+        $target.data(data);
         $target.find('.sharing-thumbnail-unshare').show();
         $target.detach().prependTo('#share-box-share').show();
     }
@@ -59,6 +79,9 @@ var changeShareState = function($target) {
     else if ($target.hasClass('share-box-share-item')) {
         console.log("Revoking share");
         $target.find('select').val('0').prop("disabled", true).hide();
+        data.access.read = true;
+        data.access.write = true;
+        $target.data(data);
         $target.find('.sharing-thumbnail-unshare').hide();
         $target.detach().appendTo('#share-box-users');
         $('#share-box-filter').trigger('keydown');


Mime
View raw message