airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [24/50] [abbrv] airavata-php-gateway git commit: make permissions editing more obvious
Date Wed, 27 Jul 2016 17:05:32 GMT
make permissions editing more obvious


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

Branch: refs/heads/develop
Commit: e6a733637e40b47a168074c8dde998d21b2f2c4e
Parents: c5a2779
Author: Jeff Kinnison <jeffdkinnison@gmail.com>
Authored: Wed Jul 13 12:28:39 2016 -0400
Committer: Jeff Kinnison <jeffdkinnison@gmail.com>
Committed: Wed Jul 13 12:28:39 2016 -0400

----------------------------------------------------------------------
 public/js/sharing/share.js         | 111 +++++++-------------------------
 public/js/sharing/sharing_utils.js |  39 ++++++-----
 2 files changed, 48 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e6a73363/public/js/sharing/share.js
----------------------------------------------------------------------
diff --git a/public/js/sharing/share.js b/public/js/sharing/share.js
index ac37181..8b3c9bc 100755
--- a/public/js/sharing/share.js
+++ b/public/js/sharing/share.js
@@ -4,88 +4,6 @@
  * @author Jeff Kinnison <jkinniso@nd.edu>
  */
 
-var access_enum = {
-    NONE: '0',
-    READ: '1',
-    WRITE: '2'
-};
-
-var dummy_user_data = [
-    {
-        username: 'testuser1',
-        firstname: 'Jane',
-        lastname: 'Doe',
-        email: 'jadoe@institution.edu',
-        access: access_enum.NONE
-    },
-    {
-        username: 'testuser2',
-        firstname: 'Ego',
-        lastname: 'Id',
-        email: 'freud@institution.gov',
-        access: access_enum.NONE
-    },
-    {
-        username: 'testuser3',
-        firstname: 'Ivan',
-        lastname: 'Ivanov',
-        email: 'notkgb@totallynotkgb.ru',
-        access: access_enum.NONE
-    },
-    {
-        username: 'testuser4',
-        firstname: 'Grok',
-        lastname: 'Smytheson',
-        email: 'popsicle@prehistoric.com',
-        access: access_enum.ADMIN
-    },
-    {
-        username: 'testuser5',
-        firstname: 'Identifier',
-        lastname: 'Appellation',
-        email: 'idapp@institution.edu',
-        access: access_enum.EDIT
-    }
-];
-
-var dummy_group_data = [
-    {
-        username: 'Venusian Climate Studies',
-        firstname: 'Gazorpazorp',
-        lastname: 'Field',
-        email: 'gfield@venus.plt',
-        access: access_enum.NONE
-    },
-    {
-        username: 'Molecular Dynamics Rawks',
-        firstname: 'Jorgen',
-        lastname: 'Jorgenson',
-        email: 'jjorg@deshaw.org',
-        access: access_enum.NONE
-    },
-    {
-        username: 'Socialist Distributed Algorithms',
-        firstname: 'Richard',
-        lastname: 'Stallman',
-        email: 'allmayhaz@cloud.org',
-        access: access_enum.NONE
-    },
-    {
-        username: 'Stonferd Center for New Age Math',
-        firstname: 'Gugliermo',
-        lastname: 'Marconi',
-        email: 'gmarconi@stonferd.edu',
-        access: access_enum.VIEW
-    },
-    {
-        username: 'CIT Center for Autonomous Studies',
-        firstname: 'Madison',
-        lastname: 'Li',
-        email: 'madili@cit.edu',
-        access: access_enum.EDIT
-    },
-];
-
 $(function() {
     var comparator_map, comparator, $original_shared_list, $revoke_list;
     comparator_map = {
@@ -117,7 +35,9 @@ $(function() {
                         access = access_enum.READ;
                     }
                 }
+
                 $user = createThumbnail(user, data.firstname, data.lastname, data.email,
access);
+                $user.find('.sharing-thumbnail-access').hide();
 
                 $user.addClass('user-thumbnail');
                 if (access === access_enum.NONE) {
@@ -149,7 +69,7 @@ $(function() {
         //         }
         //     }
         // }
-        if ($share.children.length === 0) {
+        if ($share.children().length === 0) {
             $share.append($('<p>This project has not been shared</p>')).addClass('text-align-center');
         }
         $('.user-thumbnail').show();
@@ -179,7 +99,8 @@ $(function() {
             $share_list.each(function(index, element) {
                 var $e;
                 $e = $(element);
-                $e.find('.sharing-thumbnail-access').prop('disabled', false);
+                $e.find('.sharing-thumbnail-access-text').hide();
+                $e.find('.sharing-thumbnail-access').prop('disabled', false).show();
                 $e.find('.sharing-thumbnail-unshare').show();
                 $e.detach().appendTo($('#share-box-share'));
             })
@@ -243,7 +164,6 @@ $(function() {
     $('body').on('change', '.order-results-selector', function(e) {
         var $target, $sibling, $sorted;
         $target = $(e.target);
-        console.log($target);
         comparator = comparator_map[$target.val()];
         $('.order-results-selector').val($target.val());
         $sibling = $target.siblings('#shared-users, #share-box-users');
@@ -328,16 +248,33 @@ $(function() {
         e.preventDefault();
         $target = $(e.target).closest('.sharing-thumbnail');
         changeShareState($target);
+        // if ($target.closest('ul, div').hasClass('share-box-share')) {
+        //     $target.find('.sharing-thumbnail-access-text').hide();
+        //     $target.find('.sharing-thumbnail-access').show();
+        // }
+        // else {
+        //     $target.find('.sharing-thumbnail-access').hide();
+        //     $target.find('.sharing-thumbnail-access-text').show();
+        // }
+        $('.share-box-filter').trigger('keydown');
+        $('.order-results-selector').trigger('change');
         return false;
     });
 
     // Handle changing access level
     $('body').on('change', '.sharing-thumbnail-access', function(e) {
-        var $target, $parent, data;
+        var $target, $parent, data, access;
         $target = $(e.target);
         $parent = $target.closest('.sharing-thumbnail');
         data = $parent.data();
-        data.currentaccess = $target.val();
+        access = parseInt($target.val());
+        if (access > 0) {
+            data.currentaccess.read = true;
+        }
+        if (access > 1) {
+            data.currentaccess.write = true;
+        }
+        $parent.find('.sharing-thumbnail-access-text').val(access_text[access]);
         $parent.data(data);
     });
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e6a73363/public/js/sharing/sharing_utils.js
----------------------------------------------------------------------
diff --git a/public/js/sharing/sharing_utils.js b/public/js/sharing/sharing_utils.js
index 3d5ddb9..464d332 100644
--- a/public/js/sharing/sharing_utils.js
+++ b/public/js/sharing/sharing_utils.js
@@ -1,5 +1,17 @@
+var access_enum = {
+    NONE: 0,
+    READ: 1,
+    WRITE: 2
+};
+
+var access_text = [
+  'Cannot access',
+  'Can read',
+  'can write'
+];
+
 var createThumbnail = function(username, firstname, lastname, email, access = access_enum.NONE,
share = true) {
-  var $thumbnail, data, select, options;
+  var $thumbnail, data, select, options, access_text_current;
 
   data = {
       username: username,
@@ -16,14 +28,15 @@ var createThumbnail = function(username, firstname, lastname, email, access
= ac
       }
   };
 
-  if (access === access_enum.READ) {
+  access_text_current = access_text[access];
+
+  if (access !== access_enum.NONE) {
       data.access.read = true;
       data.currentaccess.read = true;
   }
-  else if (access === access_enum.WRITE) {
-      data.access.read = true;
+
+  if (access === access_enum.WRITE) {
       data.access.write = true;
-      data.currentaccess.read = true;
       data.currentaccess.write = true;
   }
 
@@ -54,6 +67,7 @@ var createThumbnail = function(username, firstname, lastname, email, access
= ac
                               <h5 class="sharing-thumbnail-name">' + firstname + '
' + lastname + '</h5> \
                               <p class="sharing-thumbnail-email">' + email + '</p>
\
                               ' + select + ' \
+                              <label class="sharing-thumbnail-access-text">' + access_text_current
+ '</label> \
                           </div> \
                       </div>');
 
@@ -66,21 +80,19 @@ 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();
+        $target.find('.sharing-thumbnail-access-text').val(access_text[access_enum.READ]).hide();
         data.currentaccess.read = true;
         $target.data(data);
         $target.find('.sharing-thumbnail-unshare').show();
         $target.detach().prependTo('#share-box-share').show();
     }
-    // Otherwise move to the shared list
     else if ($target.hasClass('share-box-share-item')) {
-        console.log("Revoking share");
-        $target.find('select').val('0').prop("disabled", true).hide();
-        data.currentaccess.read = true;
-        data.currentaccess.write = true;
+        $target.find('.sharing-thumbnail-access').val('0').prop("disabled", true).hide();
+        $target.find('.sharing-thumbnail-access-text').val(access_text[access_enum.NONE]).show();
+        data.currentaccess.read = false;
+        data.currentaccess.write = false;
         $target.data(data);
         $target.find('.sharing-thumbnail-unshare').hide();
         $target.detach().appendTo('#share-box-users');
@@ -92,7 +104,6 @@ var changeShareState = function($target) {
 
 var usernameComparator = function(a, b) {
    var $a, $b;
-   console.log("Sorting by username");
    $a = $(a).data();
    $b = $(b).data();
 
@@ -169,10 +180,8 @@ var userFilter = function(users, pattern) {
            re.test(data.lastname.toLowerCase()) ||
            re.test(data.email.toLowerCase())
        ) {
-           console.log("Showing the user");
            $(element).show();
        } else {
-           console.log("Hiding the user");
            $(element).hide();
        }
    });


Mime
View raw message