airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [05/10] airavata-php-gateway git commit: large restructuring of sharing utilities
Date Wed, 13 Jul 2016 16:36:55 GMT
large restructuring of sharing utilities


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/067e41d8
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/067e41d8
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/067e41d8

Branch: refs/heads/grouper-integration
Commit: 067e41d8345c2e51c1a6bc0a12289252d696a7b2
Parents: 7d4787a
Author: Jeff Kinnison <jeffdkinnison@gmail.com>
Authored: Tue Jul 12 15:46:01 2016 -0400
Committer: Jeff Kinnison <jeffdkinnison@gmail.com>
Committed: Tue Jul 12 15:46:01 2016 -0400

----------------------------------------------------------------------
 app/controllers/ExperimentController.php        | 13 ++--
 app/controllers/GroupController.php             | 20 ++++--
 app/controllers/ProjectController.php           | 49 +++++++++++----
 app/libraries/GrouperUtilities.php              |  2 +-
 app/libraries/SharingUtilities.php              |  9 +--
 .../partials/sharing-display-body.blade.php     | 24 ++++++++
 app/views/partials/sharing-form-body.blade.php  | 17 ++++++
 app/views/partials/sharing-form-modal.blade.php | 18 ++++++
 app/views/project/create.blade.php              | 21 +------
 app/views/project/edit.blade.php                | 18 +++++-
 app/views/project/summary.blade.php             | 21 +++++--
 public/js/sharing/share.js                      | 64 +++-----------------
 12 files changed, 167 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index 3e0bc1e..ede47af 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -25,13 +25,7 @@ class ExperimentController extends BaseController
     public function createView()
     {
         Session::forget('exp_create_continue');
-        $uids = GrouperUtilities::getAllGatewayUsers();
-        $users = array();
-        foreach ($uids as $uid) {
-            if ($uid !== Session::get('username') && WSIS::usernameExists($uid))
{
-                $users[$uid] = WSIS::getUserProfile($uid);
-            }
-        }
+        $users = SharingUtilities::getAllUserProfiles();
         return View::make('experiment/create', array("users" => json_encode($users)));
     }
 
@@ -249,7 +243,10 @@ class ExperimentController extends BaseController
             'cloning' => true,
             'advancedOptions' => Config::get('pga_config.airavata')["advanced-experiment-options"]
         );
-        return View::make("experiment/edit", array("expInputs" => $experimentInputs));
+
+        $users = SharingUtilities::getAllUserProfiles($_GET['expId'], ResourceType::EXPERIMENT);
+
+        return View::make("experiment/edit", array("expInputs" => $experimentInputs, "users"
=> $users));
     }
 
     public function cloneExperiment()

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/controllers/GroupController.php
----------------------------------------------------------------------
diff --git a/app/controllers/GroupController.php b/app/controllers/GroupController.php
index 0972d8c..6a70b3a 100644
--- a/app/controllers/GroupController.php
+++ b/app/controllers/GroupController.php
@@ -19,6 +19,13 @@ class GroupController extends BaseController {
         // TODO: Create the new group
         // TODO: Get users to add
         // TODO: Update membership of users in list
+        if (isset($_POST['save'])) {
+            $groupId = GroupUtilities::create_group();
+            return Redirect::to('group/summary?groupId=' . $groupId);
+        }
+        else {
+            return Redirect::to('group/create');
+        }
     }
 
     public function editSubmit()
@@ -34,13 +41,14 @@ class GroupController extends BaseController {
         // TODO: If not a member, load a page that says they cannot see the group
         // TODO: If a standard member, display group name, description, members, projects(?)
and experiments (?)
         // TODO: If owner, display buttons to allow adding and removing members
+        if (Input::has('groupId')) {
+            Session::put('groupId', Input::get('groupId'));
+            return View::make('group/summary', array('groupId' => $groupId));
+        }
+        else {
+            return Redirect::to('home');
+        }
     }
-
-    protected function updateMembership() {
-        // TODO: Get users to update
-        // TODO: Update membership for selected users
-    }
-
 }
 
 ?>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/controllers/ProjectController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ProjectController.php b/app/controllers/ProjectController.php
index 7492102..5557675 100755
--- a/app/controllers/ProjectController.php
+++ b/app/controllers/ProjectController.php
@@ -1,6 +1,6 @@
 <?php
 
-
+use Airavata\Model\Group\ResourceType;
 
 class ProjectController extends BaseController
 {
@@ -25,15 +25,9 @@ class ProjectController extends BaseController
 
     public function createView()
     {
-        $uids = GrouperUtilities::getAllGatewayUsers();
-        $users = array();
-        foreach ($uids as $uid) {
-            if ($uid !== Session::get('username') && WSIS::usernameExists($uid))
{
-                $users[$uid] = WSIS::getUserProfile($uid);
-            }
-        }
+        $users = SharingUtilities::getAllUserProfiles();
         //var_dump($users);exit;
-        return View::make("project/create", array("users" => json_encode($users), "shared"
=> array()));
+        return View::make("project/create", array("users" => json_encode($users)));
     }
 
     public function createSubmit()
@@ -50,8 +44,11 @@ class ProjectController extends BaseController
     {
         if (Input::has("projId")) {
             Session::put("projId", Input::get("projId"));
+
+            $users = SharingUtilities::getProfilesForSharedUsers(Input::get('projId'), ResourceType::PROJECT);
+
             return View::make("project/summary",
-                array("projectId" => Input::get("projId")));
+                array("projectId" => Input::get("projId"), "users" => json_encode($users)));
         } else
             return Redirect::to("home");
     }
@@ -59,9 +56,12 @@ class ProjectController extends BaseController
     public function editView()
     {
         if (Input::has("projId")) {
+            $users = SharingUtilities::getAllUserProfiles(Input::get('projId'), ResourceType::PROJECT);
+
             return View::make("project/edit",
                 array("projectId" => Input::get("projId"),
-                    "project" => ProjectUtilities::get_project($_GET['projId'])
+                    "project" => ProjectUtilities::get_project($_GET['projId']),
+                     "users" => json_encode($users)
                 ));
         } else
             return Redirect::to("home");
@@ -110,6 +110,33 @@ class ProjectController extends BaseController
         ));
     }
 
+    /**
+     * Generate JSON containing permissions information for this project.
+     *
+     * This function retrieves the user profile and permissions for every user
+     * other than the client that has access to the project. In the event that
+     * the project does not exist, return an error message.
+     */
+    public function sharedUsers()
+    {
+        $response = array();
+        if (Input::has('projId')) {
+            return Response::json(SharingUtilities::getProfilesForSharedUsers());
+        }
+        else {
+            return Response::json(array("error" => "Error: No project specified"));
+        }
+    }
+
+    public function unsharedUsers()
+    {
+        if (Input::has('projId')) {
+            return Response::json(SharingUtilities::getProfilesForUnsharedUsers);
+        }
+        else {
+            return Response::json(array("error" => "Error: No project specified"));
+        }
+    }
 }
 
 ?>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/libraries/GrouperUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/GrouperUtilities.php b/app/libraries/GrouperUtilities.php
index ebe7e6f..e156e4b 100644
--- a/app/libraries/GrouperUtilities.php
+++ b/app/libraries/GrouperUtilities.php
@@ -74,4 +74,4 @@ class GrouperUtilities
 
         return $userList;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/libraries/SharingUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php
index 27e9f00..cba9bd5 100644
--- a/app/libraries/SharingUtilities.php
+++ b/app/libraries/SharingUtilities.php
@@ -94,8 +94,9 @@ class SharingUtilities {
         $perms = SharingUtilities::getAllUserPermissions($resourceId, $dataResourceType);
         $profs = SharingUtilities::getUserProfiles(array_keys($perms));
 
-        foreach ($profs as $uid) {
-            $profs[$uid]['access'] = $perms[$uid];
+        foreach ($profs as $uid => $prof) {
+            $prof["access"] = $perms[$uid];
+            $profs[$uid] = $prof;
         }
 
         return $profs;
@@ -109,7 +110,7 @@ class SharingUtilities {
      * @return An array [uid => [firstname => string, lastname => string, email
=> string]] of all users without access
      */
     public static function getProfilesForUnsharedUsers($resourceId, $dataResourceType) {
-        $users = GrouperUtilities::getAllUsersInGateway();
+        $users = GrouperUtilities::getAllGatewayUsers();
         $read = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::READ);
 
         $unshared = array_diff_key($users, $read);
@@ -127,7 +128,7 @@ class SharingUtilities {
      *         with access only defined for users with permissions.
      */
     public static function getAllUserProfiles($resourceId=null, $dataResourceType=null) {
-        $profs = SharingUtilities::getUserProfiles(GrouperUtilities::getAllUsersInGateway());
+        $profs = SharingUtilities::getUserProfiles(GrouperUtilities::getAllGatewayUsers());
         if ($resourceId) {
             $perms = SharingUtilities::getAllUserPermissions($resourceId, $dataResourceType);
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/views/partials/sharing-display-body.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/sharing-display-body.blade.php b/app/views/partials/sharing-display-body.blade.php
new file mode 100644
index 0000000..1b4a340
--- /dev/null
+++ b/app/views/partials/sharing-display-body.blade.php
@@ -0,0 +1,24 @@
+@if($form)
+<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 />
+@else
+<h3>Sharing Settings</h3>
+@endif
+<!-- <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>
+    <option value="lastfirst">Last, First Name</option>
+    <option value="email">Email</option>
+</select>
+<div id="shared-users" class="text-align-center">
+    <p>This project has not been shared</p>
+</div>
+@if($form)
+<input id="share-settings" name="share-settings" type="hidden" value="" />
+@endif

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/views/partials/sharing-form-body.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/sharing-form-body.blade.php b/app/views/partials/sharing-form-body.blade.php
new file mode 100644
index 0000000..d6387d0
--- /dev/null
+++ b/app/views/partials/sharing-form-body.blade.php
@@ -0,0 +1,17 @@
+<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>
+<select class="order-results-selector">
+    <option value="username">Username</option>
+    <option value="firstlast">First, Last Name</option>
+    <option value="lastfirst">Last, First Name</option>
+    <option value="email">Email</option>
+</select>
+<ul id="share-box-users" class="form-control"></ul>
+<label>Set permissions with the drop-down menu on each user, or click the x to cancel
sharing.</label>
+<ul id="share-box-share" class="form-control"></ul>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/views/partials/sharing-form-modal.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/sharing-form-modal.blade.php b/app/views/partials/sharing-form-modal.blade.php
new file mode 100644
index 0000000..b66a666
--- /dev/null
+++ b/app/views/partials/sharing-form-modal.blade.php
@@ -0,0 +1,18 @@
+<!-- Reusable modal dialog for sharing UI -->
+<div id="share-box" class="modal-fade" tabindex="-1" role="dialog">
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" id="share-box-x" class="close" data-dismiss="modal"
aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                <h3 class="modal-title">Share this project</h3>
+            </div>
+            <div class="modal-body">
+                @include('partials/sharing-form-body')
+            </div>
+            <div class="modal-footer">
+                <button type="button" id="share-box-button" class="btn btn-primary">Save</button>
+                <button type="button" id="share-box-close" class="btn btn-default" data-dismiss="modal">Cancel</button>
+            </div>
+        </div>
+    </div>
+</div>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/views/project/create.blade.php
----------------------------------------------------------------------
diff --git a/app/views/project/create.blade.php b/app/views/project/create.blade.php
index 4f9147d..230d53a 100755
--- a/app/views/project/create.blade.php
+++ b/app/views/project/create.blade.php
@@ -26,24 +26,7 @@
         </div>
 
         <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>
-            <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>
-                <option value="lastfirst">Last, First Name</option>
-                <option value="email">Email</option>
-            </select>
-            <div id="shared-users" class="text-align-center">
-                <p>This project has not been shared</p>
-            </div>
-            <input id="share-settings" name="share-settings" type="hidden" value="" />
+            @include('partials/sharing-display-body', array('form' => true))
         </div>
 
         <input name="save" type="submit" class="btn btn-primary create-project" value="Save">
@@ -53,6 +36,8 @@
 
 </div>
 
+@include('partials/sharing-form-modal')
+
 {{ HTML::image("assets/Profile_avatar_placeholder_large.png", 'placeholder image', array('class'
=> 'baseimage')) }}
 
 @stop

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/views/project/edit.blade.php
----------------------------------------------------------------------
diff --git a/app/views/project/edit.blade.php b/app/views/project/edit.blade.php
index a3beec6..37f6c70 100755
--- a/app/views/project/edit.blade.php
+++ b/app/views/project/edit.blade.php
@@ -2,6 +2,7 @@
 
 @section('page-header')
 @parent
+{{ HTML::style('css/sharing.css') }}
 @stop
 
 @section('content')
@@ -37,6 +38,10 @@
             <input type="hidden" name="projectId" value="{{ Input::get('projId') }}"/>
         </div>
 
+        <div class="form-group">
+            @include('partials/sharing-display-body', array('form' => true))
+        </div>
+
         <div class="btn-toolbar">
             <input name="save" type="submit" class="btn" value="Save">
         </div>
@@ -47,4 +52,15 @@
 
 </div>
 
-@stop
\ No newline at end of file
+@include('partials/sharing-form-modal')
+
+@stop
+
+@section('scripts')
+@parent
+<script>
+    var users = {{ $users }};
+</script>
+{{ HTML::script('js/sharing/sharing_utils.js') }}
+{{ HTML::script('js/sharing/share.js') }}
+@stop

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/app/views/project/summary.blade.php
----------------------------------------------------------------------
diff --git a/app/views/project/summary.blade.php b/app/views/project/summary.blade.php
index d65008f..d52c284 100755
--- a/app/views/project/summary.blade.php
+++ b/app/views/project/summary.blade.php
@@ -2,6 +2,7 @@
 
 @section('page-header')
 @parent
+{{ HTML::style('css/sharing.css') }}
 @stop
 
 @section('content')
@@ -19,7 +20,7 @@
     </h1>
     <div>
         <div>
-            <h3>{{ $project->name }} 
+            <h3>{{ $project->name }}
                 <a href="edit?projId={{ $project->projectID }}" title="Edit">
                     <span class="glyphicon glyphicon-pencil"></span>
                 </a>
@@ -39,13 +40,13 @@
                     <th>Job Status</th>
 
                 </tr>
-                <?php 
+                <?php
 
                 foreach ($experiments as $experiment) {
                     $expValues = ExperimentUtilities::get_experiment_values($experiment,
true);
                     $expValues["jobState"] = ExperimentUtilities::get_job_status($experiment);
                     $applicationInterface = AppUtilities::get_application_interface($experiment->executionId);
-                    
+
                     try {
                         $cr = CRUtilities::get_compute_resource($experiment->userConfigurationData->computationalResourceScheduling->resourceHostId);
                         if (!empty($cr)) {
@@ -57,9 +58,9 @@
                     ?>
 
                 <tr>
-                    <td> 
+                    <td>
                         <a href="{{URL::to('/')}}/experiment/summary?expId={{$experiment->experimentId}}">
-                        {{ $experiment->experimentName }} 
+                        {{ $experiment->experimentName }}
                         </a>
                         @if( $expValues['editable'])
                             <a href="{{URL::to('/')}}/experiment/edit?expId={{$experiment->experimentId}}"
title="Edit"><span class="glyphicon glyphicon-pencil"></span></a>
@@ -96,10 +97,18 @@
             </table>
         </div>
     </div>
+    <div style="margin-top: 10%;">
+        @include('partials/sharing-display-body', array('form' => false))
+    </div>
 </div>
 
 @stop
 @section('scripts')
 @parent
 {{ HTML::script('js/time-conversion.js')}}
-@stop
\ No newline at end of file
+<script>
+    var users = {{ $users }};
+</script>
+{{ HTML::script('js/sharing/sharing_utils.js') }}
+{{ HTML::script('js/sharing/share.js') }}
+@stop

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/067e41d8/public/js/sharing/share.js
----------------------------------------------------------------------
diff --git a/public/js/sharing/share.js b/public/js/sharing/share.js
index 90e52e3..0686ced 100755
--- a/public/js/sharing/share.js
+++ b/public/js/sharing/share.js
@@ -98,61 +98,11 @@ $(function() {
 
     /* Share box functions */
 
-    /**
-     * Create the popup containing sharing functionality
-     *
-     * @param id The id of the resource being shared
-     * @return The share box JQuery element.
-     */
-    var createShareBox = function(resource_id) {
-        var $share_box, $user_section, $share_section, $button_section;
-        if (($('#share-box')).length === 0) {
-            $share_box = $('<div id="share-box" class="modal-fade" tabindex="-1" role="dialog">
\
-                <div class="modal-dialog modal-lg"> \
-                    <div class="modal-content"> \
-                        <div class="modal-header"> \
-                            <button type="button" id="share-box-x" class="close" data-dismiss="modal"
aria-label="Close"><span aria-hidden="true">&times;</span></button>
\
-                            <h3 class="modal-title">Share this project</h3> \
-                        </div> \
-                        <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> \
-                            <select class="order-results-selector"> \
-                                <option value="username">Username</option> \
-                                <option value="firstlast">First, Last Name</option>
\
-                                <option value="lastfirst">Last, First Name</option>
\
-                                <option value="email">Email</option> \
-                            </select> \
-                            <ul id="share-box-users" class="form-control"></ul>
\
-                            <label>Set permissions with the drop-down menu on each
user, or click the x to cancel sharing.</label> \
-                            <ul id="share-box-share" class="form-control"></ul>
\
-                        </div> \
-                        <div class="modal-footer"> \
-                            <button type="button" id="share-box-button" class="btn btn-primary">Save</button>
\
-                            <button type="button" id="share-box-close" class="btn btn-default"
data-dismiss="modal">Cancel</button> \
-                        </div> \
-                    </div> \
-                </div> \
-            </div>');
-
-            if (resource_id) {
-                $share_box.data({'resource_id': resource_id});
-            }
-        }
-        return $share_box;
-    }
-
     var createTestData = function () {
         var $users, $share, $user, data, access;
 
         $users = $('#share-box-users');
-        $share = $('#share-box-share');
+        $share = $('#shared-users');
 
         for (var user in users) {
             if (users.hasOwnProperty(user)) {
@@ -167,9 +117,16 @@ $(function() {
                     }
                 }
                 $user = createThumbnail(user, data.firstname, data.lastname, data.email,
access);
+
                 $user.addClass('user-thumbnail');
-                $user.addClass('share-box-users-item');
-                $users.append($user);
+                if (access == access_enum.NONE) {
+                    $user.addClass('share-box-users-item');
+                    $users.append($user);
+                }
+                else {
+                    $user.addClass('share-box-share-item');
+                    $share.append($user);
+                }
             }
         }
 
@@ -385,6 +342,5 @@ $(function() {
 
 
     /* Set up the sharing interface */
-    createShareBox();
     createTestData();
 });


Mime
View raw message