summaryrefslogtreecommitdiffstats
path: root/idrop-web
diff options
context:
space:
mode:
authorMike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-05-05 22:28:50 (GMT)
committer Mike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-05-05 22:28:50 (GMT)
commit5471b16aa79f00b8c2d5c5d330af0802e3b40d51 (patch)
tree86e3a353cf3f990df94291fd42db53c05914472a /idrop-web
parent980197f395e2e33ff0b141abaf8f948b1df7447d (diff)
downloadQCG-Data-5471b16aa79f00b8c2d5c5d330af0802e3b40d51.zip
QCG-Data-5471b16aa79f00b8c2d5c5d330af0802e3b40d51.tar.gz
QCG-Data-5471b16aa79f00b8c2d5c5d330af0802e3b40d51.tar.bz2
acl add web
Diffstat (limited to 'idrop-web')
-rw-r--r--idrop-web/grails-app/conf/UrlMappings.groovy10
-rw-r--r--idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy32
-rw-r--r--idrop-web/grails-app/views/home/index.gsp51
-rw-r--r--idrop-web/grails-app/views/sharing/aclDetails.gsp42
-rw-r--r--idrop-web/grails-app/views/sharing/aclDialog.gsp20
-rw-r--r--idrop-web/test/unit/org/irods/mydrop/controller/SharingControllerTests.groovy74
-rw-r--r--idrop-web/web-app/css/main.css3
-rw-r--r--idrop-web/web-app/js/mydrop/home.js113
-rw-r--r--idrop-web/web-app/js/mydrop/lingo_common.js2
9 files changed, 262 insertions, 85 deletions
diff --git a/idrop-web/grails-app/conf/UrlMappings.groovy b/idrop-web/grails-app/conf/UrlMappings.groovy
index 2e60148..9f45d89 100644
--- a/idrop-web/grails-app/conf/UrlMappings.groovy
+++ b/idrop-web/grails-app/conf/UrlMappings.groovy
@@ -7,17 +7,19 @@ class UrlMappings {
}
}
- //"/file/**" (controller:"file", action:"index")
"/file/**" (controller:"file", action:"index"){
name = {request.requestURI}
}
-
- "/"(controller:"home", action:"index")
- "500"(view:'/error')
+
"/$controller/$action?"{
constraints {
// apply constraints here
}
}
+
+ "/"(controller:"home", action:"index")
+ "500"(view:'/error')
+
}
}
+ \ No newline at end of file
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy
index 3eac7d5..a5c2ecd 100644
--- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy
@@ -4,12 +4,12 @@ package org.irods.mydrop.controller
import org.irods.jargon.core.connection.IRODSAccount
import org.irods.jargon.core.exception.JargonException
import org.irods.jargon.core.exception.JargonRuntimeException
+import org.irods.jargon.core.protovalues.FilePermissionEnum
import org.irods.jargon.core.pub.CollectionAO
import org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO
import org.irods.jargon.core.pub.DataObjectAO
import org.irods.jargon.core.pub.IRODSAccessObjectFactory
import org.irods.jargon.core.pub.domain.DataObject
-import org.irods.jargon.core.query.UserFilePermission
import org.springframework.security.core.context.SecurityContextHolder
@@ -73,7 +73,27 @@ class SharingController {
render(view:"aclDetails", model:[acls:acls])
}
-
+
+ /**
+ * Display an Acl dialog for an add or edit
+ */
+ def prepareAclDialog = {
+ log.info "prepareAclDialog"
+ log.info "params: ${params}"
+
+ // if a user is provided, this will be an edit, otherwise, it's a create
+ def userName = params['userName'];
+ def absPath = params['absPath']
+
+ if (!absPath) {
+ log.error "no absPath in request for prepareAclDialog()"
+ throw new JargonException("a path was not supplied")
+ }
+
+ render(view:"aclDialog", model:[absPath:absPath, userName:userName, userPermissionEnum:FilePermissionEnum.listAllValues()])
+
+ }
+
/**
* Update the ACL by responding to an AJAX editable update on a node. This uses the editable feature of the
* ACL JQuery table
@@ -86,20 +106,18 @@ class SharingController {
def absPath = params['absPath']
- if (userName == false) {
+ if (!userName) {
throw new JargonException("userName not supplied")
}
- if (acl == false) {
+ if (!acl) {
throw new JargonException("acl not supplied")
}
- if (absPath == false) {
+ if (!absPath) {
throw new JargonException("absPath not supplied")
}
-
-
log.info("updateACL userName: ${userName} acl: ${acl} absPath: ${absPath}")
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)
diff --git a/idrop-web/grails-app/views/home/index.gsp b/idrop-web/grails-app/views/home/index.gsp
index 8b32070..bef9191 100644
--- a/idrop-web/grails-app/views/home/index.gsp
+++ b/idrop-web/grails-app/views/home/index.gsp
@@ -7,12 +7,9 @@
<div id="tabs">
<ul>
- <li><a href="#quickView">Quick View</a>
- </li>
- <li><a href="#search">Search</a>
- </li>
- <li><a href="#browse">Browse</a>
- </li>
+ <li><a href="#quickView">Quick View</a></li>
+ <li><a href="#search">Search</a></li>
+ <li><a href="#browse">Browse</a></li>
</ul>
<div id="quickView">
<div class="objectContainer">
@@ -74,31 +71,33 @@
<div id="browse">
<div id="browser" class="wrapper" style="width: 100%">
+ <div id="browseToolbar" class="xui-layout-north"
+ style="height: 30px; position: relative; display: block;">
+ <div id="headerSearchBox" class="ui-widget-header fg-toolbar">
+
+ <div id="browseMenu" class="fg-buttonset fg-buttonset-multi"
+ style="float: left">
+ Display Option:
+ <g:select name="browseDisplayOption" id="browseDisplayOption"
+ from="${['info', 'sharing', 'metadata']}"
+ noSelection="${['details':'details']}" onChange="setBrowseMode()" />
+ </div>
+
+ <button type="button" id="upload"
+ class="ui-state-default ui-corner-all" value="upload"
+ onclick="showUploadDialog()")>Upload</button>
+ </div>
+
+
+ </div>
+ <g:render template="/common/panelmessages" />
+
<div id="dataTreeView" class="">
+
<!-- no empty divs -->
<div id="dataTreeDiv" class="ui-layout-west">
<!-- no empty divs -->
</div>
- <div id="browseToolbar" class="ui-layout-north">
- <div id="headerSearchBox" class="ui-widget-header fg-toolbar">
-
- <div id="browseMenu" class="fg-buttonset fg-buttonset-multi"
- style="float: left">
- Display Option:
- <g:select name="browseDisplayOption" id="browseDisplayOption"
- from="${['info', 'sharing', 'metadata']}"
- noSelection="${['details':'details']}"
- onChange="setBrowseMode()" />
- </div>
-
- <button type="button" id="upload"
- class="ui-state-default ui-corner-all" value="upload"
- onclick="showUploadDialog()")>Upload</button>
- </div>
-
-
- </div>
- <g:render template="/common/panelmessages" />
<div id="infoDiv" class="ui-layout-center">
<h2>Select a directory or file to see info and tags based on
diff --git a/idrop-web/grails-app/views/sharing/aclDetails.gsp b/idrop-web/grails-app/views/sharing/aclDetails.gsp
index af62205..83e6c1a 100644
--- a/idrop-web/grails-app/views/sharing/aclDetails.gsp
+++ b/idrop-web/grails-app/views/sharing/aclDetails.gsp
@@ -1,10 +1,10 @@
<g:render template="/common/panelmessages" />
<div id="detailsToolbar" class="fg-toolbar ui-widget-header">
<div id="detailsMenu" class="fg-buttonset fg-buttonset-multi"
- style="float: left">
+ style="float: left, clear: both;">
<button type="button" id="addAclButton"
class="ui-state-default ui-corner-all" value="addAcl"
- onclick="addAcl()")>Add Share</button>
+ onclick="prepareAclDialog()")>Add Share</button>
<button type="button" id="updateAclButton"
class="ui-state-default ui-corner-all" value="updateAcl"
onclick="updateAcl()")>Update Share</button>
@@ -17,6 +17,9 @@
<!-- -->
</div>
+<div id="aclDialogArea">
+<!-- area for generating dialogs --></div>
+
<div>
<table cellspacing="0" cellpadding="0" border="0" id="aclDetailsTable"
style="width: 100%;">
@@ -80,39 +83,4 @@
});
-
-// FIXME: diff div for loading gif
-
- /**
- * Called by data table upon submit of an acl change
- */
- function aclUpdate(value, settings, userName) {
- //lcShowBusyIconInDiv("#aclMessageArea");
- var url = '/sharing/updateAcl';
- //var aPos = dataTable.fnGetPosition( this );
- //alert("apos =" + aPos);
- if (selectedPath == null) {
- throw "no collection or data object selected";
- }
-
- lcShowBusyIconInDiv(messageAreaSelector);
-
- var params = {
- absPath : selectedPath,
- acl : value,
- userName: userName
- }
-
- var jqxhr = $.post(context + url, params, function(data, status, xhr) {
- lcClearDivAndDivClass(messageAreaSelector);
-
- }, "html").error(function() {
- setMessageInArea(messageAreaSelector, "Error sharing file");
- //alert("in error, this is :" + this.html());
- });
-
- return value;
-
- }
-
</script> \ No newline at end of file
diff --git a/idrop-web/grails-app/views/sharing/aclDialog.gsp b/idrop-web/grails-app/views/sharing/aclDialog.gsp
new file mode 100644
index 0000000..54f3094
--- /dev/null
+++ b/idrop-web/grails-app/views/sharing/aclDialog.gsp
@@ -0,0 +1,20 @@
+<div id="aclDialogDiv">
+<div id="aclDialogMessageArea">
+ <!-- message area for acl dialogs -->
+</div>
+ <div style="clear: both;">
+ <g:form controller="sharing" action="updateAcl" method="post"
+ name="aclUpdateForm">
+ <fieldset id="verticalForm">
+ <label for="absPath">Path:</label>
+ <g:textField name="absPath" value="${absPath}" readonly="true" />
+ <br /> <label for="userName">User Name:</label>
+ <g:textField id="userName" name="userName" value="${userName}" />
+ <br /> <label for="acl">Share Type:</label>
+ <g:select name="acl" from="${userPermissionEnum}" />
+ <br />
+
+ </fieldset>
+ </g:form>
+ </div>
+</div>
diff --git a/idrop-web/test/unit/org/irods/mydrop/controller/SharingControllerTests.groovy b/idrop-web/test/unit/org/irods/mydrop/controller/SharingControllerTests.groovy
index 4cc2180..d84a35d 100644
--- a/idrop-web/test/unit/org/irods/mydrop/controller/SharingControllerTests.groovy
+++ b/idrop-web/test/unit/org/irods/mydrop/controller/SharingControllerTests.groovy
@@ -5,6 +5,7 @@ import grails.test.ControllerUnitTestCase
import java.util.Properties
import org.irods.jargon.core.connection.IRODSAccount
+import org.irods.jargon.core.exception.JargonException
import org.irods.jargon.core.pub.CollectionAO
import org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO
import org.irods.jargon.core.pub.DataObjectAO
@@ -12,7 +13,7 @@ import org.irods.jargon.core.pub.IRODSAccessObjectFactory
import org.irods.jargon.core.pub.IRODSFileSystem
import org.irods.jargon.core.pub.domain.Collection
import org.irods.jargon.core.pub.domain.DataObject
-import org.irods.jargon.core.query.UserFilePermission
+import org.irods.jargon.core.pub.domain.UserFilePermission
import org.irods.jargon.spring.security.IRODSAuthenticationToken
import org.irods.jargon.testutils.TestingPropertiesHelper
import org.mockito.Mockito
@@ -50,13 +51,13 @@ class SharingControllerTests extends ControllerUnitTestCase {
retObject.setCollectionName(testPath)
Mockito.when(collectionListAndSearchAO.getFullObjectForType(testPath)).thenReturn(retObject)
Mockito.when(irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)).thenReturn(collectionListAndSearchAO)
-
+
CollectionAO collectionAO = Mockito.mock(CollectionAO.class)
List<UserFilePermission> mockMetadata = new ArrayList<UserFilePermission>();
Mockito.when(collectionAO.listPermissionsForCollection(testPath)).thenReturn(mockMetadata);
Mockito.when(irodsAccessObjectFactory.getCollectionAO(irodsAccount)).thenReturn(collectionAO)
-
- controller.irodsAccessObjectFactory = irodsAccessObjectFactory
+
+ controller.irodsAccessObjectFactory = irodsAccessObjectFactory
controller.irodsAccount = irodsAccount
controller.params.absPath = testPath
controller.listAcl()
@@ -68,8 +69,8 @@ class SharingControllerTests extends ControllerUnitTestCase {
def metadata = mav.model.acls
assertNotNull("null acls object", metadata)
}
-
-
+
+
void testListAclDataObject() {
def testPath = "/testpath"
def testFileName = "filename.txt"
@@ -80,12 +81,12 @@ class SharingControllerTests extends ControllerUnitTestCase {
retObject.setDataName(testFileName)
Mockito.when(collectionListAndSearchAO.getFullObjectForType(testPath)).thenReturn(retObject)
Mockito.when(irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)).thenReturn(collectionListAndSearchAO)
-
+
DataObjectAO dataObjectAO = Mockito.mock(DataObjectAO.class)
List<UserFilePermission> mockMetadata = new ArrayList<UserFilePermission>();
Mockito.when(dataObjectAO.listPermissionsForDataObject(testPath + "/" + testFileName)).thenReturn(mockMetadata);
Mockito.when(irodsAccessObjectFactory.getDataObjectAO(irodsAccount)).thenReturn(dataObjectAO)
-
+
controller.irodsAccessObjectFactory = irodsAccessObjectFactory
controller.irodsAccount = irodsAccount
controller.params.absPath = testPath
@@ -98,5 +99,60 @@ class SharingControllerTests extends ControllerUnitTestCase {
def metadata = mav.model.acls
assertNotNull("null acls object", metadata)
}
-
+
+ void testPrepareAclDialogWhenCreate() {
+ def testPath = "/testpath"
+ def testFileName = "filename.txt"
+ def irodsAccessObjectFactory = Mockito.mock(IRODSAccessObjectFactory.class)
+
+ controller.irodsAccessObjectFactory = irodsAccessObjectFactory
+ controller.irodsAccount = irodsAccount
+ controller.params.absPath = testPath
+ controller.prepareAclDialog()
+ def mav = controller.modelAndView
+ def name = mav.viewName
+
+ assertNotNull("null mav", mav)
+ assertEquals("view name incorrect", "aclDialog", name)
+ def absPath = mav.model.absPath
+ assertNotNull("null absPath object", absPath)
+ assertEquals("wrong abspath", testPath, absPath)
+ assertNotNull("no acl options enum", mav.model.userPermissionEnum)
+ assertNull("should not be a user name", mav.model.userName)
+ }
+
+ void testPrepareAclDialogWhenEdit() {
+ def testPath = "/testpath"
+ def testFileName = "filename.txt"
+ def irodsAccessObjectFactory = Mockito.mock(IRODSAccessObjectFactory.class)
+
+ controller.irodsAccessObjectFactory = irodsAccessObjectFactory
+ controller.irodsAccount = irodsAccount
+ controller.params.absPath = testPath
+ controller.params.userName = "userName"
+ controller.prepareAclDialog()
+ def mav = controller.modelAndView
+ def name = mav.viewName
+
+ assertNotNull("null mav", mav)
+ assertEquals("view name incorrect", "aclDialog", name)
+ def absPath = mav.model.absPath
+ assertNotNull("null absPath object", absPath)
+ assertEquals("wrong abspath", testPath, absPath)
+ assertNotNull("no acl options enum", mav.model.userPermissionEnum)
+ assertNotNull("should be a user name", mav.model.userName)
+ }
+
+ void testPrepareAclDialogWhenNullAbsPath() {
+ def testPath = null
+ def testFileName = "filename.txt"
+ def irodsAccessObjectFactory = Mockito.mock(IRODSAccessObjectFactory.class)
+
+ controller.irodsAccessObjectFactory = irodsAccessObjectFactory
+ controller.irodsAccount = irodsAccount
+ controller.params.absPath = testPath
+ controller.params.userName = "userName"
+
+ shouldFail(JargonException) { controller.prepareAclDialog() }
+ }
}
diff --git a/idrop-web/web-app/css/main.css b/idrop-web/web-app/css/main.css
index 0c77e5c..68c0037 100644
--- a/idrop-web/web-app/css/main.css
+++ b/idrop-web/web-app/css/main.css
@@ -148,6 +148,9 @@ div#tabs {
.fg-toolbar {
padding: .5em;
margin: 0;
+ display: block;
+ clear: both;
+
}
.fg-toolbar .fg-buttonset {
diff --git a/idrop-web/web-app/js/mydrop/home.js b/idrop-web/web-app/js/mydrop/home.js
index 2820e76..afbc66b 100644
--- a/idrop-web/web-app/js/mydrop/home.js
+++ b/idrop-web/web-app/js/mydrop/home.js
@@ -11,6 +11,14 @@ var dataTree;
var browseOptionVal = "details";
var selectedPath = null;
var fileUploadUI = null;
+var aclDialogMessageSelector = "#aclDialogMessageArea";
+
+
+/**
+ * presets for url's
+ */
+
+var aclUpdateUrl = '/sharing/updateAcl';
/**
* Initialize the tree control for the first view by issuing an ajax directory
@@ -240,9 +248,112 @@ function initializeUploadDialogAjaxLoader() {
return $('<tr><td>' + file.name + '<\/td><\/tr>');
},
onError : function(event, files, index, xhr, handler) {
- $("#upload_message_area").html("an error occurred in the upload");
+ $("#upload_message_area").html("an error occurred:" + xhr);
$("#upload_message_area").addClass("message");
}
});
}
+
+/**
+ * Called by data table upon submit of an acl change
+ */
+function aclUpdate(value, settings, userName) {
+ // lcShowBusyIconInDiv("#aclMessageArea");
+
+ // var aPos = dataTable.fnGetPosition( this );
+ // alert("apos =" + aPos);
+ if (selectedPath == null) {
+ throw "no collection or data object selected";
+ }
+
+ lcShowBusyIconInDiv(messageAreaSelector);
+
+ var params = {
+ absPath : selectedPath,
+ acl : value,
+ userName: userName
+ }
+
+ var jqxhr = $.post(context + aclUpdateUrl, params, function(data, status, xhr) {
+ lcClearDivAndDivClass(messageAreaSelector);
+
+ }, "html").error(function() {
+ setMessageInArea(messageAreaSelector, "Error sharing file");
+ });
+
+ return value;
+
+}
+
+/**
+ * Prepare the dialog to allow create of ACL data
+ */
+function prepareAclDialog() {
+
+ if (selectedPath == null) {
+ alert("No path is selected, Share cannot be set");
+ return;
+ }
+
+ var url = "/sharing/prepareAclDialog";
+ var params = {
+ absPath : selectedPath
+ }
+
+ lcSendValueWithParamsAndPlugHtmlInDiv(url, params, "", function(data) {
+ showAclDialog(data);
+ });
+
+}
+
+/**
+ * The ACL dialog is prepared and ready to display as a JQuery dialog box, show
+ * it
+ *
+ * @param data
+ */
+function showAclDialog(data) {
+ $("#aclDialogArea").html(data);
+ $("#aclDialogArea").dialog({
+ "width" : 400,
+ "modal" : true,
+ "buttons" : { "Ok": function() { submitAclDialog(); }, "Cancel": function() { $(this).dialog("close"); } },
+ "title" : "Edit Share Permission"
+ });
+
+}
+
+function submitAclDialog() {
+
+ var userName = $('[name=userName]').val();
+ if (userName == null || userName == "") {
+ setMessageInArea(aclDialogMessageSelector, "Please select a user to share data with");
+ return false;
+ }
+ var permissionVal = $('[name=acl]').val();
+ if (permissionVal == null || permissionVal == "" || permissionVal== "NONE") {
+ setMessageInArea(aclDialogMessageSelector, "Please select a permission value in the drop-down");
+ return false;
+ }
+
+ if (selectedPath == null) {
+ throw "no collection or data object selected";
+ }
+
+ lcShowBusyIconInDiv(aclDialogMessageSelector);
+
+ var params = {
+ absPath : selectedPath,
+ acl : permissionVal,
+ userName: userName
+ }
+
+ var jqxhr = $.post(context + aclUpdateUrl, params, function(data, status, xhr) {
+ lcClearDivAndDivClass(aclDialogMessageSelector);
+
+ }, "html").error(function() {
+ setMessageInArea(aclDialogMessageSelector, "Error saving sharing permissions");
+ }).success(function() {$("#aclDialogArea").dialog("close"); setMessage("Sharing permission saved successfully") });
+
+}
diff --git a/idrop-web/web-app/js/mydrop/lingo_common.js b/idrop-web/web-app/js/mydrop/lingo_common.js
index bfa1057..41f7547 100644
--- a/idrop-web/web-app/js/mydrop/lingo_common.js
+++ b/idrop-web/web-app/js/mydrop/lingo_common.js
@@ -369,7 +369,7 @@ function lcSendValueWithParamsAndPlugHtmlInDiv(getUrl, params, resultDiv,
lcFillInDivWithHtml(data, resultDiv, postLoadFunction);
}
}, "html").error(function() {
- setMessage("Error creating upload dialog");
+ setMessage("Error in request");
});
} catch (err) {