summaryrefslogtreecommitdiffstats
path: root/idrop-web
diff options
context:
space:
mode:
authorMike Conway <mikeconway@dhcp152-54-6-70.wireless.europa.renci.org>2011-04-06 13:12:16 (GMT)
committer Mike Conway <mikeconway@dhcp152-54-6-70.wireless.europa.renci.org>2011-04-06 13:12:16 (GMT)
commit6ebe8300c5f9f1ac361881706dd105a096b765a0 (patch)
treee2a2d946d5fdabe87920e30c10b3d51e0c898f59 /idrop-web
parentc23df89beb1a69b8a28cf980a74f462c3d48028a (diff)
downloadQCG-Data-6ebe8300c5f9f1ac361881706dd105a096b765a0.zip
QCG-Data-6ebe8300c5f9f1ac361881706dd105a096b765a0.tar.gz
QCG-Data-6ebe8300c5f9f1ac361881706dd105a096b765a0.tar.bz2
upload dialog web app
Diffstat (limited to 'idrop-web')
-rw-r--r--idrop-web/.gitignore2
-rw-r--r--idrop-web/designnotes.txt2
-rw-r--r--idrop-web/grails-app/conf/Config.groovy94
-rw-r--r--idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy14
-rw-r--r--idrop-web/grails-app/views/file/uploadDialog.gsp25
-rw-r--r--idrop-web/grails-app/views/file/uploadDialogDone.gsp8
-rw-r--r--idrop-web/grails-app/views/layouts/main.gsp4
-rwxr-xr-xidrop-web/web-app/css/jquery.fileupload-ui.css81
-rw-r--r--idrop-web/web-app/images/ajax-loader-bar.gifbin0 -> 10819 bytes
-rwxr-xr-xidrop-web/web-app/images/pbar-ani.gifbin0 -> 3323 bytes
-rwxr-xr-xidrop-web/web-app/js/jquery.fileupload-ui.js322
-rwxr-xr-xidrop-web/web-app/js/jquery.fileupload.js642
-rw-r--r--idrop-web/web-app/js/mydrop/home.js112
-rw-r--r--idrop-web/web-app/js/mydrop/lingo_common.js11
14 files changed, 1216 insertions, 101 deletions
diff --git a/idrop-web/.gitignore b/idrop-web/.gitignore
index beef00d..60a844d 100644
--- a/idrop-web/.gitignore
+++ b/idrop-web/.gitignore
@@ -2,3 +2,5 @@
.project
.settings
target
+.DS_Store
+plugins
diff --git a/idrop-web/designnotes.txt b/idrop-web/designnotes.txt
index 478fb37..82ff509 100644
--- a/idrop-web/designnotes.txt
+++ b/idrop-web/designnotes.txt
@@ -36,7 +36,7 @@ palette: http://colorschemedesigner.com/#4W42Jw09Rw0w0
##### Generated by Color Scheme Designer (c) Petr Stanicek 2002-2010
-
+6f7f86
LOW SAT
diff --git a/idrop-web/grails-app/conf/Config.groovy b/idrop-web/grails-app/conf/Config.groovy
index 601ced2..48aa191 100644
--- a/idrop-web/grails-app/conf/Config.groovy
+++ b/idrop-web/grails-app/conf/Config.groovy
@@ -13,19 +13,28 @@
grails.project.groupId = appName // change this to alter the default package name and Maven publishing destination
grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
grails.mime.use.accept.header = false
-grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
- xml: ['text/xml', 'application/xml'],
- text: 'text/plain',
- js: 'text/javascript',
- rss: 'application/rss+xml',
- atom: 'application/atom+xml',
- css: 'text/css',
- csv: 'text/csv',
- all: '*/*',
- json: ['application/json','text/json'],
- form: 'application/x-www-form-urlencoded',
- multipartForm: 'multipart/form-data'
- ]
+grails.mime.types = [ html: [
+ 'text/html',
+ 'application/xhtml+xml'
+ ],
+ xml: [
+ 'text/xml',
+ 'application/xml'
+ ],
+ text: 'text/plain',
+ js: 'text/javascript',
+ rss: 'application/rss+xml',
+ atom: 'application/atom+xml',
+ css: 'text/css',
+ csv: 'text/csv',
+ all: '*/*',
+ json: [
+ 'application/json',
+ 'text/json'
+ ],
+ form: 'application/x-www-form-urlencoded',
+ multipartForm: 'multipart/form-data'
+]
// URL Mapping Cache Max Size, defaults to 5000
//grails.urlmapping.cache.maxsize = 1000
@@ -51,48 +60,41 @@ grails.validateable.packages = ['org.irods']
// set per-environment serverURL stem for creating absolute links
environments {
- production {
- grails.serverURL = "http://irendb.renci.org:8080/${appName}"
- }
- development {
- grails.serverURL = "http://localhost:8080/${appName}"
- }
- test {
- grails.serverURL = "http://localhost:8080/${appName}"
- }
-
+ production { grails.serverURL = "http://irendb.renci.org:8080/${appName}" }
+ development { grails.serverURL = "http://localhost:8080/${appName}" }
+ test { grails.serverURL = "http://localhost:8080/${appName}" }
}
// log4j configuration
log4j = {
-
+
root {
info()
additivity = true
}
-
- // Example of changing the log pattern for the default console
- // appender:
- //
- // appenders {
- // console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
- // }
- error 'org.codehaus.groovy.grails.web.servlet', // controllers
- 'org.codehaus.groovy.grails.web.pages', // GSP
- 'org.codehaus.groovy.grails.web.sitemesh', // layouts
- 'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
- 'org.codehaus.groovy.grails.web.mapping', // URL mapping
- 'org.codehaus.groovy.grails.commons', // core / classloading
- 'org.codehaus.groovy.grails.plugins', // plugins
- 'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
- 'org.springframework',
- 'org.hibernate',
- 'net.sf.ehcache.hibernate'
+ // Example of changing the log pattern for the default console
+ // appender:
+ //
+ // appenders {
+ // console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
+ // }
+
+ error 'org.codehaus.groovy.grails.web.servlet', // controllers
+ 'org.codehaus.groovy.grails.web.pages', // GSP
+ 'org.codehaus.groovy.grails.web.sitemesh', // layouts
+ 'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
+ 'org.codehaus.groovy.grails.web.mapping', // URL mapping
+ 'org.codehaus.groovy.grails.commons', // core / classloading
+ 'org.codehaus.groovy.grails.plugins', // plugins
+ 'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
+ 'org.springframework',
+ 'org.hibernate',
+ 'net.sf.ehcache.hibernate'
- warn 'org.mortbay.log'
- debug 'org.irods.idrop'
- warn 'org.irods.jargon'
- info 'grails.app.controller'
+ warn 'org.mortbay.log'
+ debug 'org.irods.mydrop'
+ info 'org.irods.jargon'
+ warn 'grails.app.controller'
warn 'org.springframework.security'
}
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy
index c0d90ff..19923bf 100644
--- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy
@@ -15,6 +15,8 @@ import org.irods.jargon.core.pub.io.IRODSFile
import org.irods.jargon.core.pub.io.IRODSFileOutputStream
import org.springframework.security.core.context.SecurityContextHolder
import org.irods.jargon.core.pub.io.IRODSFileImpl
+import grails.converters.*
+
class FileController {
@@ -77,7 +79,6 @@ class FileController {
response.outputStream << irodsFileInputStream // Performing a binary stream copy
-
}
/**
@@ -122,6 +123,8 @@ class FileController {
def f = request.getFile('file')
def name = f.getOriginalFilename()
+ log.info("f is ${f}");
+
log.info("name is : ${name}")
def irodsCollectionPath = params.collectionParentName
@@ -146,5 +149,14 @@ class FileController {
irodsFileOutputStream.flush()
irodsFileOutputStream.close()
+ def jsonBuff = []
+
+ jsonBuff.add(
+ ["name": name, "type":"blah", "size":100]
+ )
+
+ //render jsonBuff as JSON
+ render "{\"name\":\"${name}\",\"type\":\"image/jpeg\",\"size\":\"1000\"}"
+
}
}
diff --git a/idrop-web/grails-app/views/file/uploadDialog.gsp b/idrop-web/grails-app/views/file/uploadDialog.gsp
index 27b2733..ab68d8b 100644
--- a/idrop-web/grails-app/views/file/uploadDialog.gsp
+++ b/idrop-web/grails-app/views/file/uploadDialog.gsp
@@ -1,28 +1,27 @@
<div id="uploadDialogDiv">
-<script>
-
-
-</script>
-
+
<div class="box">
<g:form controller="file" action="upload" method="post"
- name="uploadForm" enctype="multipart/form-data">
+ name="uploadForm" enctype="multipart/form-data"
+ target="upload_target">
<fieldset id="verticalForm">
<label for="">Parent Collection:</label>
<g:textField name="collectionParentName"
value="${irodsTargetCollection}" readonly="true" />
- <br /> <input type="file" name="file" /> <br /> <label
- for="tags">Tags:</label>
+ <br />
+ <div id="file_upload_container">
+ <input type="file" name="file" multiple>
+ <button>Upload</button>
+ <div>Upload files</div>
+ </div>
<g:textField id="infoTags" name="tags"
value="tags.spaceDelimitedTagsForDomain" />
- <button type="button" id="upload" value="upload"
- onclick="doUploadFromDialog()">Upload File</button>
- <div id="uploadInfoUpdateAra">
- <!-- div for any updates -->
- </div>
+ <br />
+ <table id="files"></table>
</fieldset>
</g:form>
+
</div>
</div>
diff --git a/idrop-web/grails-app/views/file/uploadDialogDone.gsp b/idrop-web/grails-app/views/file/uploadDialogDone.gsp
new file mode 100644
index 0000000..14a859c
--- /dev/null
+++ b/idrop-web/grails-app/views/file/uploadDialogDone.gsp
@@ -0,0 +1,8 @@
+<div id="uploadDialogDoneDiv">
+<script>
+uploadCompleted();
+</script>
+DONE
+</div>
+
+
diff --git a/idrop-web/grails-app/views/layouts/main.gsp b/idrop-web/grails-app/views/layouts/main.gsp
index b9c5b0d..f8bfd4d 100644
--- a/idrop-web/grails-app/views/layouts/main.gsp
+++ b/idrop-web/grails-app/views/layouts/main.gsp
@@ -5,6 +5,7 @@
<link rel="stylesheet" href="${resource(dir:'css',file:'base.css')}" />
<link rel="stylesheet" href="${resource(dir:'css',file:'style.css')}" />
<link rel="stylesheet" href="${resource(dir:'css',file:'jqcloud.css')}" />
+<link rel="stylesheet" href="${resource(dir:'css',file:'jquery.fileupload-ui.css')}" />
<link rel="stylesheet"
href="${resource(dir:'css',file:'reset-fonts-grids.css')}" />
<link rel="stylesheet" href="${resource(dir:'css',file:'overcast/jquery-ui-1.8.7.custom.css')}" />
@@ -17,11 +18,12 @@
<g:javascript library="jquery.jstree.min" />
<g:javascript library="jquery.dataTables.min" />
<g:javascript library="jqcloud-0.1.6" />
+<g:javascript library="jquery.fileupload-ui" />
+<g:javascript library="jquery.fileupload" />
<g:javascript library="mydrop/lingo_common" />
<g:javascript library="mydrop/main" />
<g:javascript library="jquery-ui-13" />
-
<!-- preserve the application context as a js variable for use in AJAX callbacks -->
<script type="text/javascript">
context = "${request.contextPath}";
diff --git a/idrop-web/web-app/css/jquery.fileupload-ui.css b/idrop-web/web-app/css/jquery.fileupload-ui.css
new file mode 100755
index 0000000..829d3bb
--- /dev/null
+++ b/idrop-web/web-app/css/jquery.fileupload-ui.css
@@ -0,0 +1,81 @@
+@charset 'UTF-8';
+
+div.file_upload {
+ position: relative;
+ overflow: hidden;
+ direction: ltr;
+ cursor: pointer;
+ text-align: center;
+ color: #333;
+ font-weight: bold;
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ border-radius: 10px;
+ width: 200px;
+ height: 30px;
+ line-height: 30px;
+ background: #6f7f86;
+ border: 1px solid #6f7f86;
+}
+
+div.file_upload_small {
+ width: 200px;
+ height: 30px;
+ line-height: 30px;
+ font-size: 100%;
+ background: #6f7f86;
+ border: 1px solid #6f7f86;
+}
+
+div.file_upload_large {
+ width: 100%;
+ height: 150px;
+ line-height: 150px;
+ font-size: 20px;
+ background: #6f7f86;
+ border: 1px solid #6f7f86;
+}
+
+div.file_upload_highlight {
+ background: #6f7f86;
+}
+
+div.file_upload input {
+ position: absolute;
+ top: 0;
+ right: 0;
+ margin: 0;
+ border: 300px solid transparent;
+ opacity: 0;
+ -ms-filter: 'alpha(opacity=0)';
+ filter: alpha(opacity=0);
+ -o-transform: translate(-300px, -300px) scale(10);
+ -moz-transform: translate(-800px, 0) scale(10);
+ cursor: pointer;
+ height: 100%;
+}
+
+:root .file_upload input {
+ height: auto;
+}
+
+.file_upload iframe, .file_upload button {
+ display: none;
+}
+
+.file_upload_preview img {
+ width: 80px;
+}
+
+.file_upload_progress .ui-progressbar-value {
+ background: url(../images/pbar-ani.gif);
+}
+
+.file_upload_progress div {
+ width: 150px;
+ height: 15px;
+}
+
+.file_upload_cancel button {
+ cursor: pointer;
+} \ No newline at end of file
diff --git a/idrop-web/web-app/images/ajax-loader-bar.gif b/idrop-web/web-app/images/ajax-loader-bar.gif
new file mode 100644
index 0000000..d84f653
--- /dev/null
+++ b/idrop-web/web-app/images/ajax-loader-bar.gif
Binary files differ
diff --git a/idrop-web/web-app/images/pbar-ani.gif b/idrop-web/web-app/images/pbar-ani.gif
new file mode 100755
index 0000000..fbcce6b
--- /dev/null
+++ b/idrop-web/web-app/images/pbar-ani.gif
Binary files differ
diff --git a/idrop-web/web-app/js/jquery.fileupload-ui.js b/idrop-web/web-app/js/jquery.fileupload-ui.js
new file mode 100755
index 0000000..49e2596
--- /dev/null
+++ b/idrop-web/web-app/js/jquery.fileupload-ui.js
@@ -0,0 +1,322 @@
+/*
+ * jQuery File Upload User Interface Plugin 3.7.1
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://creativecommons.org/licenses/MIT/
+ */
+
+/*jslint browser: true */
+/*global jQuery, FileReader, URL */
+
+(function ($) {
+
+ var undef = 'undefined',
+ func = 'function',
+ UploadHandler,
+ methods,
+
+ LocalImage = function (file, imageTypes) {
+ var img,
+ fileReader;
+ if (!imageTypes.test(file.type)) {
+ return null;
+ }
+ img = document.createElement('img');
+ if (typeof URL !== undef && typeof URL.createObjectURL === func) {
+ img.src = URL.createObjectURL(file);
+ img.onload = function () {
+ URL.revokeObjectURL(this.src);
+ };
+ return img;
+ }
+ if (typeof FileReader !== undef) {
+ fileReader = new FileReader();
+ if (typeof fileReader.readAsDataURL === func) {
+ fileReader.onload = function (e) {
+ img.src = e.target.result;
+ };
+ fileReader.readAsDataURL(file);
+ return img;
+ }
+ }
+ return null;
+ };
+
+ UploadHandler = function (container, options) {
+ var uploadHandler = this,
+ dragOverTimeout,
+ isDropZoneEnlarged;
+
+ this.requestHeaders = {'Accept': 'application/json, text/javascript, */*; q=0.01'};
+ this.dropZone = container;
+ this.imageTypes = /^image\/(gif|jpeg|png)$/;
+ this.previewSelector = '.file_upload_preview';
+ this.progressSelector = '.file_upload_progress div';
+ this.cancelSelector = '.file_upload_cancel button';
+ this.cssClassSmall = 'file_upload_small';
+ this.cssClassLarge = 'file_upload_large';
+ this.cssClassHighlight = 'file_upload_highlight';
+ this.dropEffect = 'highlight';
+ this.uploadTable = this.downloadTable = null;
+
+ this.buildUploadRow = this.buildDownloadRow = function () {
+ return null;
+ };
+
+ this.addNode = function (parentNode, node, callBack) {
+ if (node) {
+ node.css('display', 'none').appendTo(parentNode).fadeIn(function () {
+ if (typeof callBack === func) {
+ try {
+ callBack();
+ } catch (e) {
+ // Fix endless exception loop:
+ $(this).stop();
+ throw e;
+ }
+ }
+ });
+ } else if (typeof callBack === func) {
+ callBack();
+ }
+ };
+
+ this.removeNode = function (node, callBack) {
+ if (node) {
+ node.fadeOut(function () {
+ $(this).remove();
+ if (typeof callBack === func) {
+ try {
+ callBack();
+ } catch (e) {
+ // Fix endless exception loop:
+ $(this).stop();
+ throw e;
+ }
+ }
+ });
+ } else if (typeof callBack === func) {
+ callBack();
+ }
+ };
+
+ this.onAbort = function (event, files, index, xhr, handler) {
+ handler.removeNode(handler.uploadRow);
+ };
+
+ this.cancelUpload = function (event, files, index, xhr, handler) {
+ var readyState = xhr.readyState;
+ xhr.abort();
+ // If readyState is below 2, abort() has no effect:
+ if (isNaN(readyState) || readyState < 2) {
+ handler.onAbort(event, files, index, xhr, handler);
+ }
+ };
+
+ this.initProgressBar = function (node, value) {
+ if (typeof node.progressbar === func) {
+ return node.progressbar({
+ value: value
+ });
+ } else {
+ var progressbar = $('<progress value="' + value + '" max="100"/>').appendTo(node);
+ progressbar.progressbar = function (key, value) {
+ progressbar.attr('value', value);
+ };
+ return progressbar;
+ }
+ };
+
+ this.initUploadRow = function (event, files, index, xhr, handler, callBack) {
+ var uploadRow = handler.uploadRow = handler.buildUploadRow(files, index, handler);
+ if (uploadRow) {
+ handler.progressbar = handler.initProgressBar(
+ uploadRow.find(handler.progressSelector),
+ 0
+ );
+ uploadRow.find(handler.cancelSelector).click(function (e) {
+ handler.cancelUpload(e, files, index, xhr, handler);
+ });
+ uploadRow.find(handler.previewSelector).each(function () {
+ $(this).append(new LocalImage(files[index], handler.imageTypes));
+ });
+ }
+ handler.addNode(
+ (typeof handler.uploadTable === func ? handler.uploadTable(handler) : handler.uploadTable),
+ uploadRow,
+ callBack
+ );
+ };
+
+ this.initUploadProgress = function (xhr, handler) {
+ if (!xhr.upload) {
+ handler.progressbar.progressbar(
+ 'value',
+ 100 // indeterminate progress displayed by a full animated progress bar
+ );
+ }
+ };
+
+ this.initUpload = function (event, files, index, xhr, handler, callBack) {
+ handler.initUploadRow(event, files, index, xhr, handler, function () {
+ if (typeof handler.beforeSend === func) {
+ handler.beforeSend(event, files, index, xhr, handler, function () {
+ handler.initUploadProgress(xhr, handler);
+ callBack();
+ });
+ } else {
+ handler.initUploadProgress(xhr, handler);
+ callBack();
+ }
+ });
+ };
+
+ this.onProgress = function (event, files, index, xhr, handler) {
+ if (handler.progressbar) {
+ handler.progressbar.progressbar(
+ 'value',
+ parseInt(event.loaded / event.total * 100, 10)
+ );
+ }
+ };
+
+ this.parseResponse = function (xhr) {
+ if (typeof xhr.responseText !== undef) {
+ return $.parseJSON(xhr.responseText);
+ } else {
+ // Instead of an XHR object, an iframe is used for legacy browsers:
+ return $.parseJSON(xhr.contents().text());
+ }
+ };
+
+ this.initDownloadRow = function (event, files, index, xhr, handler, callBack) {
+ var json, downloadRow;
+ try {
+ json = handler.response = handler.parseResponse(xhr);
+ downloadRow = handler.downloadRow = handler.buildDownloadRow(json, handler);
+ handler.addNode(
+ (typeof handler.downloadTable === func ? handler.downloadTable(handler) : handler.downloadTable),
+ downloadRow,
+ callBack
+ );
+ } catch (e) {
+ if (typeof handler.onError === func) {
+ handler.originalEvent = event;
+ handler.onError(e, files, index, xhr, handler);
+ } else {
+ throw e;
+ }
+ }
+ };
+
+ this.onLoad = function (event, files, index, xhr, handler) {
+ handler.removeNode(handler.uploadRow, function () {
+ handler.initDownloadRow(event, files, index, xhr, handler, function () {
+ if (typeof handler.onComplete === func) {
+ handler.onComplete(event, files, index, xhr, handler);
+ }
+ });
+ });
+ };
+
+ this.dropZoneEnlarge = function () {
+ if (!isDropZoneEnlarged) {
+ if (typeof uploadHandler.dropZone.switchClass === func) {
+ uploadHandler.dropZone.switchClass(
+ uploadHandler.cssClassSmall,
+ uploadHandler.cssClassLarge
+ );
+ } else {
+ uploadHandler.dropZone.addClass(uploadHandler.cssClassLarge);
+ uploadHandler.dropZone.removeClass(uploadHandler.cssClassSmall);
+ }
+ isDropZoneEnlarged = true;
+ }
+ };
+
+ this.dropZoneReduce = function () {
+ if (typeof uploadHandler.dropZone.switchClass === func) {
+ uploadHandler.dropZone.switchClass(
+ uploadHandler.cssClassLarge,
+ uploadHandler.cssClassSmall
+ );
+ } else {
+ uploadHandler.dropZone.addClass(uploadHandler.cssClassSmall);
+ uploadHandler.dropZone.removeClass(uploadHandler.cssClassLarge);
+ }
+ isDropZoneEnlarged = false;
+ };
+
+ this.onDocumentDragEnter = function (event) {
+ uploadHandler.dropZoneEnlarge();
+ };
+
+ this.onDocumentDragOver = function (event) {
+ if (dragOverTimeout) {
+ clearTimeout(dragOverTimeout);
+ }
+ dragOverTimeout = setTimeout(function () {
+ uploadHandler.dropZoneReduce();
+ }, 200);
+ };
+
+ this.onDragEnter = this.onDragLeave = function (event) {
+ uploadHandler.dropZone.toggleClass(uploadHandler.cssClassHighlight);
+ };
+
+ this.onDrop = function (event) {
+ if (dragOverTimeout) {
+ clearTimeout(dragOverTimeout);
+ }
+ if (uploadHandler.dropEffect && typeof uploadHandler.dropZone.effect === func) {
+ uploadHandler.dropZone.effect(uploadHandler.dropEffect, function () {
+ uploadHandler.dropZone.removeClass(uploadHandler.cssClassHighlight);
+ uploadHandler.dropZoneReduce();
+ });
+ } else {
+ uploadHandler.dropZone.removeClass(uploadHandler.cssClassHighlight);
+ uploadHandler.dropZoneReduce();
+ }
+ };
+
+ $.extend(this, options);
+ };
+
+ methods = {
+ init : function (options) {
+ return this.each(function () {
+ $(this).fileUpload(new UploadHandler($(this), options));
+ });
+ },
+
+ option: function (option, value, namespace) {
+ if (typeof option === undef || (typeof option === 'string' && typeof value === undef)) {
+ return $(this).fileUpload('option', option, value, namespace);
+ }
+ return this.each(function () {
+ $(this).fileUpload('option', option, value, namespace);
+ });
+ },
+
+ destroy : function (namespace) {
+ return this.each(function () {
+ $(this).fileUpload('destroy', namespace);
+ });
+ }
+ };
+
+ $.fn.fileUploadUI = function (method) {
+ if (methods[method]) {
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
+ } else if (typeof method === 'object' || !method) {
+ return methods.init.apply(this, arguments);
+ } else {
+ $.error('Method ' + method + ' does not exist on jQuery.fileUploadUI');
+ }
+ };
+
+}(jQuery)); \ No newline at end of file
diff --git a/idrop-web/web-app/js/jquery.fileupload.js b/idrop-web/web-app/js/jquery.fileupload.js
new file mode 100755
index 0000000..836521a
--- /dev/null
+++ b/idrop-web/web-app/js/jquery.fileupload.js
@@ -0,0 +1,642 @@
+/*
+ * jQuery File Upload Plugin 3.8.2
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://creativecommons.org/licenses/MIT/
+ */
+
+/*jslint browser: true */
+/*global File, FileReader, FormData, unescape, jQuery */
+
+(function ($) {
+
+ var defaultNamespace = 'file_upload',
+ undef = 'undefined',
+ func = 'function',
+ num = 'number',
+ FileUpload,
+ methods,
+
+ MultiLoader = function (callBack, numberComplete) {
+ var loaded = 0;
+ this.complete = function () {
+ loaded += 1;
+ if (loaded === numberComplete) {
+ callBack();
+ }
+ };
+ };
+
+ FileUpload = function (container) {
+ var fileUpload = this,
+ uploadForm,
+ fileInput,
+ settings = {
+ namespace: defaultNamespace,
+ uploadFormFilter: function (index) {
+ return true;
+ },
+ fileInputFilter: function (index) {
+ return true;
+ },
+ cssClass: defaultNamespace,
+ dragDropSupport: true,
+ dropZone: container,
+ url: function (form) {
+ return form.attr('action');
+ },
+ method: function (form) {
+ return form.attr('method');
+ },
+ fieldName: function (input) {
+ return input.attr('name');
+ },
+ formData: function (form) {
+ return form.serializeArray();
+ },
+ multipart: true,
+ multiFileRequest: false,
+ withCredentials: false,
+ forceIframeUpload: false
+ },
+ documentListeners = {},
+ dropZoneListeners = {},
+ protocolRegExp = /^http(s)?:\/\//,
+ optionsReference,
+
+ isXHRUploadCapable = function () {
+ return typeof XMLHttpRequest !== undef && typeof File !== undef && (
+ !settings.multipart || typeof FormData !== undef || typeof FileReader !== undef
+ );
+ },
+
+ initEventHandlers = function () {
+ if (settings.dragDropSupport) {
+ if (typeof settings.onDocumentDragEnter === func) {
+ documentListeners['dragenter.' + settings.namespace] = function (e) {
+ settings.onDocumentDragEnter(e);
+ };
+ }
+ if (typeof settings.onDocumentDragLeave === func) {
+ documentListeners['dragleave.' + settings.namespace] = function (e) {
+ settings.onDocumentDragLeave(e);
+ };
+ }
+ documentListeners['dragover.' + settings.namespace] = fileUpload.onDocumentDragOver;
+ documentListeners['drop.' + settings.namespace] = fileUpload.onDocumentDrop;
+ $(document).bind(documentListeners);
+ if (typeof settings.onDragEnter === func) {
+ dropZoneListeners['dragenter.' + settings.namespace] = function (e) {
+ settings.onDragEnter(e);
+ };
+ }
+ if (typeof settings.onDragLeave === func) {
+ dropZoneListeners['dragleave.' + settings.namespace] = function (e) {
+ settings.onDragLeave(e);
+ };
+ }
+ dropZoneListeners['dragover.' + settings.namespace] = fileUpload.onDragOver;
+ dropZoneListeners['drop.' + settings.namespace] = fileUpload.onDrop;
+ settings.dropZone.bind(dropZoneListeners);
+ }
+ fileInput.bind('change.' + settings.namespace, fileUpload.onChange);
+ },
+
+ removeEventHandlers = function () {
+ $.each(documentListeners, function (key, value) {
+ $(document).unbind(key, value);
+ });
+ $.each(dropZoneListeners, function (key, value) {
+ settings.dropZone.unbind(key, value);
+ });
+ fileInput.unbind('change.' + settings.namespace);
+ },
+
+ initUploadEventHandlers = function (files, index, xhr, settings) {
+ if (typeof settings.onProgress === func) {
+ xhr.upload.onprogress = function (e) {
+ settings.onProgress(e, files, index, xhr, settings);
+ };
+ }
+ if (typeof settings.onLoad === func) {
+ xhr.onload = function (e) {
+ settings.onLoad(e, files, index, xhr, settings);
+ };
+ }
+ if (typeof settings.onAbort === func) {
+ xhr.onabort = function (e) {
+ settings.onAbort(e, files, index, xhr, settings);
+ };
+ }
+ if (typeof settings.onError === func) {
+ xhr.onerror = function (e) {
+ settings.onError(e, files, index, xhr, settings);
+ };
+ }
+ },
+
+ getUrl = function (settings) {
+ if (typeof settings.url === func) {
+ return settings.url(settings.uploadForm || uploadForm);
+ }
+ return settings.url;
+ },
+
+ getMethod = function (settings) {
+ if (typeof settings.method === func) {
+ return settings.method(settings.uploadForm || uploadForm);
+ }
+ return settings.method;
+ },
+
+ getFieldName = function (settings) {
+ if (typeof settings.fieldName === func) {
+ return settings.fieldName(settings.fileInput || fileInput);
+ }
+ return settings.fieldName;
+ },
+
+ getFormData = function (settings) {
+ var formData;
+ if (typeof settings.formData === func) {
+ return settings.formData(settings.uploadForm || uploadForm);
+ } else if ($.isArray(settings.formData)) {
+ return settings.formData;
+ } else if (settings.formData) {
+ formData = [];
+ $.each(settings.formData, function (name, value) {
+ formData.push({name: name, value: value});
+ });
+ return formData;
+ }
+ return [];
+ },
+
+ isSameDomain = function (url) {
+ if (protocolRegExp.test(url)) {
+ var host = location.host,
+ indexStart = location.protocol.length + 2,
+ index = url.indexOf(host, indexStart),
+ pathIndex = index + host.length;
+ if ((index === indexStart || index === url.indexOf('@', indexStart) + 1) &&
+ (url.length === pathIndex || $.inArray(url.charAt(pathIndex), ['/', '?', '#']) !== -1)) {
+ return true;
+ }
+ return false;
+ }
+ return true;
+ },
+
+ setRequestHeaders = function (xhr, settings, sameDomain) {
+ if (sameDomain) {
+ xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ } else if (settings.withCredentials) {
+ xhr.withCredentials = true;
+ }
+ if ($.isArray(settings.requestHeaders)) {
+ $.each(settings.requestHeaders, function (index, header) {
+ xhr.setRequestHeader(header[0], header[1]);
+ });
+ } else if (settings.requestHeaders) {
+ $.each(settings.requestHeaders, function (name, value) {
+ xhr.setRequestHeader(name, value);
+ });
+ }
+ },
+
+ nonMultipartUpload = function (file, xhr, sameDomain) {
+ if (sameDomain) {
+ xhr.setRequestHeader('X-File-Name', unescape(encodeURIComponent(file.name)));
+ }
+ xhr.setRequestHeader('Content-Type', file.type);
+ xhr.send(file);
+ },
+
+ formDataUpload = function (files, xhr, settings) {
+ var formData = new FormData(),
+ i;
+ $.each(getFormData(settings), function (index, field) {
+ formData.append(field.name, field.value);
+ });
+ for (i = 0; i < files.length; i += 1) {
+ formData.append(getFieldName(settings), files[i]);
+ }
+ xhr.send(formData);
+ },
+
+ loadFileContent = function (file, callBack) {
+ var fileReader = new FileReader();
+ fileReader.onload = function (e) {
+ file.content = e.target.result;
+ callBack();
+ };
+ fileReader.readAsBinaryString(file);
+ },
+
+ buildMultiPartFormData = function (boundary, files, filesFieldName, fields) {
+ var doubleDash = '--',
+ crlf = '\r\n',
+ formData = '';
+ $.each(fields, function (index, field) {
+ formData += doubleDash + boundary + crlf +
+ 'Content-Disposition: form-data; name="' +
+ unescape(encodeURIComponent(field.name)) +
+ '"' + crlf + crlf +
+ unescape(encodeURIComponent(field.value)) + crlf;
+ });
+ $.each(files, function (index, file) {
+ formData += doubleDash + boundary + crlf +
+ 'Content-Disposition: form-data; name="' +
+ unescape(encodeURIComponent(filesFieldName)) +
+ '"; filename="' + unescape(encodeURIComponent(file.name)) + '"' + crlf +
+ 'Content-Type: ' + file.type + crlf + crlf +
+ file.content + crlf;
+ });
+ formData += doubleDash + boundary + doubleDash + crlf;
+ return formData;
+ },
+
+ fileReaderUpload = function (files, xhr, settings) {
+ var boundary = '----MultiPartFormBoundary' + (new Date()).getTime(),
+ loader,
+ i;
+ xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + boundary);
+ loader = new MultiLoader(function () {
+ xhr.sendAsBinary(buildMultiPartFormData(
+ boundary,
+ files,
+ getFieldName(settings),
+ getFormData(settings)
+ ));
+ }, files.length);
+ for (i = 0; i < files.length; i += 1) {
+ loadFileContent(files[i], loader.complete);
+ }
+ },
+
+ upload = function (files, index, xhr, settings) {
+ var url = getUrl(settings),
+ sameDomain = isSameDomain(url),
+ filesToUpload;
+ initUploadEventHandlers(files, index, xhr, settings);
+ xhr.open(getMethod(settings), url, true);
+ setRequestHeaders(xhr, settings, sameDomain);
+ if (!settings.multipart) {
+ nonMultipartUpload(files[index], xhr, sameDomain);
+ } else {
+ if (typeof index === num) {
+ filesToUpload = [files[index]];
+ } else {
+ filesToUpload = files;
+ }
+ if (typeof FormData !== undef) {
+ formDataUpload(filesToUpload, xhr, settings);
+ } else if (typeof FileReader !== undef) {
+ fileReaderUpload(filesToUpload, xhr, settings);
+ } else {
+ $.error('Browser does neither support FormData nor FileReader interface');
+ }
+ }
+ },
+
+ handleUpload = function (event, files, input, form, index) {
+ var xhr = new XMLHttpRequest(),
+ uploadSettings = $.extend({}, settings);
+ uploadSettings.fileInput = input;
+ uploadSettings.uploadForm = form;
+ if (typeof uploadSettings.initUpload === func) {
+ uploadSettings.initUpload(
+ event,
+ files,
+ index,
+ xhr,
+ uploadSettings,
+ function () {
+ upload(files, index, xhr, uploadSettings);
+ }
+ );
+ } else {
+ upload(files, index, xhr, uploadSettings);
+ }
+ },
+
+ handleFiles = function (event, files, input, form) {
+ var i;
+ if (settings.multiFileRequest) {
+ handleUpload(event, files, input, form);
+ } else {
+ for (i = 0; i < files.length; i += 1) {
+ handleUpload(event, files, input, form, i);
+ }
+ }
+ },
+
+ legacyUploadFormDataInit = function (input, form, settings) {
+ var formData = getFormData(settings);
+ form.find(':input').not(':disabled')
+ .attr('disabled', true)
+ .addClass(settings.namespace + '_disabled');
+ $.each(formData, function (index, field) {
+ $('<input type="hidden"/>')
+ .attr('name', field.name)
+ .val(field.value)
+ .addClass(settings.namespace + '_form_data')
+ .appendTo(form);
+ });
+ input
+ .attr('name', getFieldName(settings))
+ .appendTo(form);
+ },
+
+ legacyUploadFormDataReset = function (input, form, settings) {
+ input.detach();
+ form.find('.' + settings.namespace + '_disabled')
+ .removeAttr('disabled')
+ .removeClass(settings.namespace + '_disabled');
+ form.find('.' + settings.namespace + '_form_data').remove();
+ },
+
+ legacyUpload = function (input, form, iframe, settings) {
+ var originalAction = form.attr('action'),
+ originalMethod = form.attr('method'),
+ originalTarget = form.attr('target');
+ iframe
+ .unbind('abort')
+ .bind('abort', function (e) {
+ iframe.readyState = 0;
+ // javascript:false as iframe src prevents warning popups on HTTPS in IE6
+ // concat is used here to prevent the "Script URL" JSLint error:
+ iframe.unbind('load').attr('src', 'javascript'.concat(':false;'));
+ if (typeof settings.onAbort === func) {
+ settings.onAbort(e, [{name: input.val(), type: null, size: null}], 0, iframe, settings);
+ }
+ })
+ .unbind('load')
+ .bind('load', function (e) {
+ iframe.readyState = 4;
+ if (typeof settings.onLoad === func) {
+ settings.onLoad(e, [{name: input.val(), type: null, size: null}], 0, iframe, settings);
+ }
+ // Fix for IE endless progress bar activity bug (happens on form submits to iframe targets):
+ $('<iframe src="javascript:false;" style="display:none"></iframe>').appendTo(form).remove();
+ });
+ form
+ .attr('action', getUrl(settings))
+ .attr('method', getMethod(settings))
+ .attr('target', iframe.attr('name'));
+ legacyUploadFormDataInit(input, form, settings);
+ iframe.readyState = 2;
+ form.get(0).submit();
+ legacyUploadFormDataReset(input, form, settings);
+ form
+ .attr('action', originalAction)
+ .attr('method', originalMethod)
+ .attr('target', originalTarget);
+ },
+
+ handleLegacyUpload = function (event, input, form) {
+ // javascript:false as iframe src prevents warning popups on HTTPS in IE6:
+ var iframe = $('<iframe src="javascript:false;" style="display:none" name="iframe_' +
+ settings.namespace + '_' + (new Date()).getTime() + '"></iframe>'),
+ uploadSettings = $.extend({}, settings);
+ uploadSettings.fileInput = input;
+ uploadSettings.uploadForm = form;
+ iframe.readyState = 0;
+ iframe.abort = function () {
+ iframe.trigger('abort');
+ };
+ iframe.bind('load', function () {
+ iframe.unbind('load');
+ if (typeof uploadSettings.initUpload === func) {
+ uploadSettings.initUpload(
+ event,
+ [{name: input.val(), type: null, size: null}],
+ 0,
+ iframe,
+ uploadSettings,
+ function () {
+ legacyUpload(input, form, iframe, uploadSettings);
+ }
+ );
+ } else {
+ legacyUpload(input, form, iframe, uploadSettings);
+ }
+ }).appendTo(form);
+ },
+
+ initUploadForm = function () {
+ uploadForm = (container.is('form') ? container : container.find('form'))
+ .filter(settings.uploadFormFilter);
+ },
+
+ initFileInput = function () {
+ fileInput = (uploadForm.length ? uploadForm : container).find('input:file')
+ .filter(settings.fileInputFilter);
+ },
+
+ replaceFileInput = function (input) {
+ var inputClone = input.clone(true);
+ $('<form/>').append(inputClone).get(0).reset();
+ input.after(inputClone).detach();
+ initFileInput();
+ };
+
+ this.onDocumentDragOver = function (e) {
+ if (typeof settings.onDocumentDragOver === func &&
+ settings.onDocumentDragOver(e) === false) {
+ return false;
+ }
+ e.preventDefault();
+ };
+
+ this.onDocumentDrop = function (e) {
+ if (typeof settings.onDocumentDrop === func &&
+ settings.onDocumentDrop(e) === false) {
+ return false;
+ }
+ e.preventDefault();
+ };
+
+ this.onDragOver = function (e) {
+ if (typeof settings.onDragOver === func &&
+ settings.onDragOver(e) === false) {
+ return false;
+ }
+ var dataTransfer = e.originalEvent.dataTransfer;
+ if (dataTransfer && dataTransfer.files) {
+ dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy';
+ e.preventDefault();
+ }
+ };
+
+ this.onDrop = function (e) {
+ if (typeof settings.onDrop === func &&
+ settings.onDrop(e) === false) {
+ return false;
+ }
+ var dataTransfer = e.originalEvent.dataTransfer;
+ if (dataTransfer && dataTransfer.files && isXHRUploadCapable()) {
+ handleFiles(e, dataTransfer.files);
+ }
+ e.preventDefault();
+ };
+
+ this.onChange = function (e) {
+ if (typeof settings.onChange === func &&
+ settings.onChange(e) === false) {
+ return false;
+ }
+ var input = $(e.target),
+ form = $(e.target.form);
+ if (form.length === 1) {
+ input.data(defaultNamespace + '_form', form);
+ replaceFileInput(input);
+ } else {
+ form = input.data(defaultNamespace + '_form');
+ }
+ if (!settings.forceIframeUpload && e.target.files && isXHRUploadCapable()) {
+ handleFiles(e, e.target.files, input, form);
+ } else {
+ handleLegacyUpload(e, input, form);
+ }
+ };
+
+ this.init = function (options) {
+ if (options) {
+ $.extend(settings, options);
+ optionsReference = options;
+ }
+ initUploadForm();
+ initFileInput();
+ if (container.data(settings.namespace)) {
+ $.error('FileUpload with namespace "' + settings.namespace + '" already assigned to this element');
+ return;
+ }
+ container
+ .data(settings.namespace, fileUpload)
+ .addClass(settings.cssClass);
+ settings.dropZone.not(container).addClass(settings.cssClass);
+ initEventHandlers();
+ };
+
+ this.options = function (options) {
+ var oldCssClass,
+ oldDropZone,
+ uploadFormFilterUpdate,
+ fileInputFilterUpdate;
+ if (typeof options === undef) {
+ return $.extend({}, settings);
+ }
+ if (optionsReference) {
+ $.extend(optionsReference, options);
+ }
+ removeEventHandlers();
+ $.each(options, function (name, value) {
+ switch (name) {
+ case 'namespace':
+ $.error('The FileUpload namespace cannot be updated.');
+ return;
+ case 'uploadFormFilter':
+ uploadFormFilterUpdate = true;
+ fileInputFilterUpdate = true;
+ break;
+ case 'fileInputFilter':
+ fileInputFilterUpdate = true;
+ break;
+ case 'cssClass':
+ oldCssClass = settings.cssClass;
+ break;
+ case 'dropZone':
+ oldDropZone = settings.dropZone;
+ break;
+ }
+ settings[name] = value;
+ });
+ if (uploadFormFilterUpdate) {
+ initUploadForm();
+ }
+ if (fileInputFilterUpdate) {
+ initFileInput();
+ }
+ if (typeof oldCssClass !== undef) {
+ container
+ .removeClass(oldCssClass)
+ .addClass(settings.cssClass);
+ (oldDropZone ? oldDropZone : settings.dropZone).not(container)
+ .removeClass(oldCssClass);
+ settings.dropZone.not(container).addClass(settings.cssClass);
+ } else if (oldDropZone) {
+ oldDropZone.not(container).removeClass(settings.cssClass);
+ settings.dropZone.not(container).addClass(settings.cssClass);
+ }
+ initEventHandlers();
+ };
+
+ this.option = function (name, value) {
+ var options;
+ if (typeof value === undef) {
+ return settings[name];
+ }
+ options = {};
+ options[name] = value;
+ fileUpload.options(options);
+ };
+
+ this.destroy = function () {
+ removeEventHandlers();
+ container
+ .removeData(settings.namespace)
+ .removeClass(settings.cssClass);
+ settings.dropZone.not(container).removeClass(settings.cssClass);
+ };
+ };
+
+ methods = {
+ init : function (options) {
+ return this.each(function () {
+ (new FileUpload($(this))).init(options);
+ });
+ },
+
+ option: function (option, value, namespace) {
+ namespace = namespace ? namespace : defaultNamespace;
+ var fileUpload = $(this).data(namespace);
+ if (fileUpload) {
+ if (typeof option === 'string') {
+ return fileUpload.option(option, value);
+ }
+ return fileUpload.options(option);
+ } else {
+ $.error('No FileUpload with namespace "' + namespace + '" assigned to this element');
+ }
+ },
+
+ destroy : function (namespace) {
+ namespace = namespace ? namespace : defaultNamespace;
+ return this.each(function () {
+ var fileUpload = $(this).data(namespace);
+ if (fileUpload) {
+ fileUpload.destroy();
+ } else {
+ $.error('No FileUpload with namespace "' + namespace + '" assigned to this element');
+ }
+ });
+
+ }
+ };
+
+ $.fn.fileUpload = function (method) {
+ if (methods[method]) {
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
+ } else if (typeof method === 'object' || !method) {
+ return methods.init.apply(this, arguments);
+ } else {
+ $.error('Method ' + method + ' does not exist on jQuery.fileUpload');
+ }
+ };
+
+}(jQuery)); \ No newline at end of file
diff --git a/idrop-web/web-app/js/mydrop/home.js b/idrop-web/web-app/js/mydrop/home.js
index 8a24890..69b8723 100644
--- a/idrop-web/web-app/js/mydrop/home.js
+++ b/idrop-web/web-app/js/mydrop/home.js
@@ -10,6 +10,7 @@
var dataTree;
var browseOptionVal = "details";
var selectedPath = null;
+var fileUploadUI = null;
/**
* Initialize the tree control for the first view by issuing an ajax directory
@@ -116,10 +117,10 @@ function nodeSelected(event, data) {
}
-
/**
- * On selection of a browser mode (from the top bar of the browse view), set the option such that selected directories in the
- * tree result in the given view in the right hand pane
+ * On selection of a browser mode (from the top bar of the browse view), set the
+ * option such that selected directories in the tree result in the given view in
+ * the right hand pane
*/
function setBrowseMode() {
browseOptionVal = $("#browseDisplayOption").val();
@@ -127,32 +128,32 @@ function setBrowseMode() {
}
/**
- * Upon selection of a collection or data object from the tree, display the content on the right-hand side. The type of
- * detail shown is contingent on the 'browseOption' that is set in the drop-down above the browse area.
+ * Upon selection of a collection or data object from the tree, display the
+ * content on the right-hand side. The type of detail shown is contingent on the
+ * 'browseOption' that is set in the drop-down above the browse area.
*/
function updateBrowseDetailsForPathBasedOnCurrentModel(absPath) {
-
+
if (absPath == null) {
return;
}
-
- if (browseOptionVal === null) {
+
+ if (browseOptionVal === null) {
browseOptionVal = "info";
}
-
+
if (browseOptionVal == "details") {
-
- lcSendValueAndCallbackHtmlAfterErrorCheck(
- "/browse/displayBrowseGridDetails?absPath=" + absPath, "#infoDiv",
- "#infoDiv", null);
- } else if (browseOptionVal == "info") {
+
lcSendValueAndCallbackHtmlAfterErrorCheck(
- "/browse/fileInfo?absPath=" + absPath, "#infoDiv",
- "#infoDiv", null);
- } else if (browseOptionVal == "metadata") {
+ "/browse/displayBrowseGridDetails?absPath=" + absPath,
+ "#infoDiv", "#infoDiv", null);
+ } else if (browseOptionVal == "info") {
+ lcSendValueAndCallbackHtmlAfterErrorCheck("/browse/fileInfo?absPath="
+ + absPath, "#infoDiv", "#infoDiv", null);
+ } else if (browseOptionVal == "metadata") {
lcSendValueAndCallbackHtmlAfterErrorCheck(
"/metadata/listMetadata?absPath=" + absPath, "#infoDiv",
- "#infoDiv", null);
+ "#infoDiv", null);
}
}
@@ -160,42 +161,75 @@ function updateBrowseDetailsForPathBasedOnCurrentModel(absPath) {
* Show the dialog to allow upload of data
*/
function showUploadDialog() {
-
+
if (selectedPath == null) {
alert("No path was selected, use the tree to select an iRODS collection to upload the file to");
return;
}
-
+
var url = "/file/prepareUploadDialog";
var params = {
- irodsTargetCollection:selectedPath
- }
-
- lcSendValueWithParamsAndPlugHtmlInDiv(url, params, "",
- function(data) { fillInUploadDialog(data);});
-
+ irodsTargetCollection : selectedPath
+ }
+
+ lcSendValueWithParamsAndPlugHtmlInDiv(url, params, "", function(data) {
+ fillInUploadDialog(data);
+ });
+
}
+/**
+ * On load of upload dialog, this will be called when the pre-set data is
+ * available
+ *
+ * @param data
+ */
function fillInUploadDialog(data) {
-
+
if (data == null) {
return;
}
+
+ $('#uploadDialog').remove();
- var $dialog = $('<div id="uploadDialog"></div>')
- .html(data)
- .dialog({
- autoOpen: true,
- modal: true,
- width: 400,
- title: 'Upload to iRODS'
+ var $dialog = $('<div id="uploadDialog"></div>').html(data).dialog({
+ autoOpen : false,
+ modal : true,
+ width : 400,
+ title : 'Upload to iRODS',
+ create : function(event, ui) {
+ initializeUploadDialogAjaxLoader();
+ }
});
+
+ $dialog.dialog('open');
}
-function doUploadFromDialog() {
- alert("I'm doing the upload now");
- $("#uploadForm").submit();
+function initializeUploadDialogAjaxLoader() {
+ if (fileUploadUI != null) {
+ $("#fileUploadForm").remove;
+ }
+ //} else {
+ fileUploadUI = $('#uploadForm')
+ .fileUploadUI(
+ {
+ uploadTable : $('#files'),
+ downloadTable : $('#files'),
+ buildUploadRow : function(files, index) {
+ return $('<tr><td>'
+ + files[index].name
+ + '<\/td>'
+ + '<td class="file_upload_progress"><div><\/div><\/td>'
+ + '<td class="file_upload_cancel">'
+ + '<button class="ui-state-default ui-corner-all" title="Cancel">'
+ + '<span class="ui-icon ui-icon-cancel">Cancel<\/span>'
+ + '<\/button><\/td><\/tr>');
+ },
+ buildDownloadRow : function(file) {
+ return $('<tr><td>' + file.name
+ + '<\/td><\/tr>');
+ }
+ });
+ //}
}
-
-
diff --git a/idrop-web/web-app/js/mydrop/lingo_common.js b/idrop-web/web-app/js/mydrop/lingo_common.js
index ae6c613..b977b7f 100644
--- a/idrop-web/web-app/js/mydrop/lingo_common.js
+++ b/idrop-web/web-app/js/mydrop/lingo_common.js
@@ -477,3 +477,14 @@ function lcShowBusyIconInDiv(divSelector) {
$(divSelector).html(img);
}
+
+/**
+ * Handy method to show a loading icon in the div specified by the given JQuery selector
+ * @param divSelector
+ */
+function lcShowLoaderBarIconInDiv(divSelector) {
+ var img = document.createElement('IMG');
+ img.setAttribute("src", context + "/images/ajax-loader-bar.gif");
+
+ $(divSelector).html(img);
+}