DS-1639 AJAX progress bar for file upload in JSPUI

This commit is contained in:
Andrea Bollini
2013-08-29 10:26:08 +02:00
parent b98b0f522a
commit 0a45c3038b
33 changed files with 1812 additions and 13 deletions

View File

@@ -316,7 +316,8 @@ public class UploadStep extends AbstractProcessingStep
// files have been uploaded.
// ---------------------------------------------------
//check if a file is required to be uploaded
if (fileRequired && !item.hasUploadedFiles())
if (fileRequired && !item.hasUploadedFiles()
&& !buttonPressed.equals(SUBMIT_MORE_BUTTON))
{
return STATUS_NO_FILES_ERROR;
}

View File

@@ -914,6 +914,14 @@ jsp.submit.choose-file.info7 = Information ab
jsp.submit.choose-file.info9 = Please give a brief description of the contents of this file, for example "Main article", or "Experiment data readings".
jsp.submit.choose-file.title = Upload a File
jsp.submit.choose-file.skip = Skip file upload >
jsp.submit.choose-file.upload-ajax.button.cancel = Cancel
jsp.submit.choose-file.upload-ajax.button.select-file = Select a file...
jsp.submit.choose-file.upload-ajax.dialog.close = Ok
jsp.submit.choose-file.upload-ajax.fileRequired.title = File required
jsp.submit.choose-file.upload-ajax.fileRequired.info = You must upload at least one file for this item
jsp.submit.choose-file.upload-ajax.uploadInit = Upload is starting...
jsp.submit.choose-file.upload-ajax.uploadInProgress = Upload in progress... <b>{0}%</b> [{1} bytes of {2}]
jsp.submit.choose-file.upload-ajax.uploadCompleted = Upload completed.
jsp.submit.complete.heading = Submit: Submission Complete!
jsp.submit.complete.info = Your submission will now go through the workflow process designated for the collection to which you are submitting. You will receive e-mail notification as soon as your submission has become a part of the collection, or if for some reason there is a problem with your submission. You can also check on the status of your submission by going to the My DSpace page.
jsp.submit.complete.again = Submit another item to the same collection
@@ -1619,4 +1627,4 @@ org.dspace.app.webui.jsptag.policies-list.label_name = Name
org.dspace.app.webui.jsptag.policies-list.label_action = Action
org.dspace.app.webui.jsptag.policies-list.label_group = Group
org.dspace.app.webui.jsptag.policies-list.label_sdate = Start Date
org.dspace.app.webui.jsptag.policies-list.label_edate = End Date
org.dspace.app.webui.jsptag.policies-list.label_edate = End Date

View File

@@ -0,0 +1,62 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.webui.json;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.dspace.app.webui.util.FileUploadListener;
import org.dspace.app.webui.util.FileUploadRequest;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import com.google.gson.Gson;
public class UploadProgressJSON extends JSONRequest
{
@Override
public void doJSONRequest(Context context, HttpServletRequest req,
HttpServletResponse resp) throws AuthorizeException, IOException
{
HttpSession session = req.getSession(false);
if (session == null)
{
return;
}
FileUploadListener listner = (FileUploadListener) session
.getAttribute(FileUploadRequest.FILE_UPLOAD_LISTNER);
if (listner == null || listner.getContentLength() == 0)
{
return;
}
else
{
long contentLength = listner.getContentLength();
UploadProgressDTO dto = new UploadProgressDTO();
long bytesRead = listner.getBytesRead();
dto.readBytes = bytesRead;
dto.totalBytes = contentLength;
Gson gson = new Gson();
resp.getWriter().write(gson.toJson(dto));
if (listner.isCompleted())
{
session.removeAttribute(FileUploadRequest.FILE_UPLOAD_LISTNER);
}
}
}
}
class UploadProgressDTO {
long totalBytes;
long readBytes;
}

View File

@@ -21,22 +21,25 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
import org.apache.log4j.Logger;
import org.dspace.app.util.SubmissionInfo;
import org.dspace.app.util.SubmissionStepConfig;
import org.dspace.app.webui.submit.JSPStepManager;
import org.dspace.app.webui.util.FileUploadRequest;
import org.dspace.app.webui.util.JSONUploadResponse;
import org.dspace.app.webui.util.JSPManager;
import org.dspace.app.webui.util.UIUtil;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.WorkspaceItem;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.workflow.WorkflowItem;
import org.dspace.submit.AbstractProcessingStep;
import com.google.gson.Gson;
/**
* Submission Manager servlet for DSpace. Handles the initial submission of
* items, as well as the editing of items further down the line.
@@ -226,7 +229,22 @@ public class SubmissionController extends DSpaceServlet
} catch (FileSizeLimitExceededException e)
{
log.warn("Upload exceeded upload.max");
JSPManager.showFileSizeLimitExceededError(request, response, e.getMessage(), e.getActualSize(), e.getPermittedSize());
if (ConfigurationManager.getBooleanProperty("webui.submit.upload.ajax", true))
{
Gson gson = new Gson();
// old browser need to see this response as html to work
response.setContentType("text/html");
JSONUploadResponse jsonResponse = new JSONUploadResponse();
jsonResponse.addUploadFileSizeLimitExceeded(
e.getActualSize(), e.getPermittedSize());
response.getWriter().print(gson.toJson(jsonResponse));
response.flushBuffer();
}
else
{
JSPManager.showFileSizeLimitExceededError(request, response, e.getMessage(), e.getActualSize(), e.getPermittedSize());
}
return;
}
//also, upload any files and save their contents to Request (for later processing by UploadStep)

View File

@@ -9,6 +9,8 @@ package org.dspace.app.webui.submit.step;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -21,6 +23,7 @@ import org.dspace.app.util.SubmissionInfo;
import org.dspace.app.webui.servlet.SubmissionController;
import org.dspace.app.webui.submit.JSPStep;
import org.dspace.app.webui.submit.JSPStepManager;
import org.dspace.app.webui.util.JSONUploadResponse;
import org.dspace.app.webui.util.JSPManager;
import org.dspace.app.webui.util.UIUtil;
import org.dspace.authorize.AuthorizeException;
@@ -34,6 +37,10 @@ import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.submit.step.UploadStep;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
/**
* Upload step for DSpace JSP-UI. Handles the pages that revolve around uploading files
* (and verifying a successful upload) for an item being submitted into DSpace.
@@ -182,6 +189,34 @@ public class JSPUploadStep extends JSPStep
// Do we need to skip the upload entirely?
boolean fileRequired = ConfigurationManager.getBooleanProperty("webui.submit.upload.required", true);
if (UIUtil.getBoolParameter(request, "ajaxUpload"))
{
Gson gson = new Gson();
// old browser need to see this response as html to work
response.setContentType("text/html");
JSONUploadResponse jsonResponse = new JSONUploadResponse();
String bitstreamName = null;
int bitstreamID = -1;
long size = 0;
String url = null;
if (subInfo.getBitstream() != null)
{
Bitstream bitstream = subInfo.getBitstream();
bitstreamName = bitstream.getName();
bitstreamID = bitstream.getID();
size = bitstream.getSize();
url = request.getContextPath() + "/retrieve/" + bitstreamID
+ "/" + UIUtil.encodeBitstreamName(bitstreamName);
}
jsonResponse.addUploadFileStatus(bitstreamName, bitstreamID, size,
url, status);
response.getWriter().print(gson.toJson(jsonResponse));
response.flushBuffer();
return;
}
if (buttonPressed.equalsIgnoreCase(UploadStep.SUBMIT_SKIP_BUTTON) ||
(buttonPressed.equalsIgnoreCase(UploadStep.SUBMIT_UPLOAD_BUTTON) && !fileRequired))
{

View File

@@ -0,0 +1,47 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.webui.util;
import org.apache.commons.fileupload.ProgressListener;
public class FileUploadListener implements ProgressListener
{
private volatile long bytesRead = 0L, contentLength = 0L, item = 0L;
public FileUploadListener()
{
super();
}
public void update(long aBytesRead, long aContentLength, int anItem)
{
bytesRead = aBytesRead;
contentLength = aContentLength;
item = anItem;
}
public long getBytesRead()
{
return bytesRead;
}
public long getContentLength()
{
return contentLength;
}
public long getItem()
{
return item;
}
public boolean isCompleted()
{
return bytesRead == contentLength;
}
}

View File

@@ -13,6 +13,7 @@ import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpSession;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException;
@@ -31,6 +32,8 @@ import org.dspace.core.ConfigurationManager;
*/
public class FileUploadRequest extends HttpServletRequestWrapper
{
public static final String FILE_UPLOAD_LISTNER = "file-upload-listner";
private Map<String, String> parameters = new HashMap<String, String>();
private Map<String, FileItem> fileitems = new HashMap<String, FileItem>();
@@ -64,6 +67,19 @@ public class FileUploadRequest extends HttpServletRequestWrapper
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
HttpSession session = req.getSession();
if (ConfigurationManager.getBooleanProperty("webui.submit.upload.ajax", true))
{
// set file upload progress listener
FileUploadListener listener = new FileUploadListener();
session.setAttribute(FILE_UPLOAD_LISTNER, listener);
// upload servlet allows to set upload listener
upload.setProgressListener(listener);
}
try
{
@@ -104,6 +120,13 @@ public class FileUploadRequest extends HttpServletRequestWrapper
}
throw new IOException(e.getMessage(), e);
}
finally
{
if (ConfigurationManager.getBooleanProperty("webui.submit.upload.ajax", true))
{
session.removeAttribute(FILE_UPLOAD_LISTNER);
}
}
}
// Methods to replace HSR methods

View File

@@ -0,0 +1,57 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.webui.util;
import java.util.ArrayList;
import java.util.List;
public class JSONUploadResponse
{
List<JSONUploadFileStatus> files = new ArrayList<JSONUploadFileStatus>();
JSONFileSizeLimitExceeded fileSizeLimitExceeded;
public void addUploadFileStatus(String name, int bitstreamID,
long size, String url, int status)
{
JSONUploadFileStatus uploadFileStatus = new JSONUploadFileStatus();
uploadFileStatus.name = name;
uploadFileStatus.bitstreamID = bitstreamID;
uploadFileStatus.size = size;
uploadFileStatus.url = url;
uploadFileStatus.status = status;
files.add(uploadFileStatus);
}
public void addUploadFileSizeLimitExceeded(long actualSize,
long permittedSize)
{
this.fileSizeLimitExceeded = new JSONFileSizeLimitExceeded();
fileSizeLimitExceeded.actualSize = actualSize;
fileSizeLimitExceeded.permittedSize = permittedSize;
}
}
class JSONUploadFileStatus
{
String name;
int bitstreamID;
long size;
String url;
int status;
}
class JSONFileSizeLimitExceeded
{
long actualSize;
long permittedSize;
}

View File

@@ -52,7 +52,7 @@
<link rel="stylesheet" href="<%= request.getContextPath() %>/print.css" media="print" type="text/css" />
<link rel="shortcut icon" href="<%= request.getContextPath() %>/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="<%= request.getContextPath() %>/css/discovery.css" type="text/css" />
<link rel="stylesheet" href="<%= request.getContextPath() %>/static/css/jquery-ui-1.8.22.custom/redmond/jquery-ui-1.8.22.custom.css" type="text/css" />
<link rel="stylesheet" href="<%= request.getContextPath() %>/static/css/jquery-ui-1.10.3.custom/redmond/jquery-ui-1.10.3.custom.min.css" type="text/css" />
<%
if (!"NONE".equals(feedRef))
{
@@ -78,8 +78,8 @@
}
%>
<script type='text/javascript' src='<%= request.getContextPath() %>/static/js/jquery/jquery-1.7.2.min.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/static/js/jquery/jquery-ui-1.8.22.custom.min.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/static/js/jquery/jquery-1.10.2.min.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/static/js/jquery/jquery-ui-1.10.3.custom.min.js'></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/utils.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/static/js/scriptaculous/prototype.js"> </script>
<script type="text/javascript" src="<%= request.getContextPath() %>/static/js/scriptaculous/effects.js"> </script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,27 @@
@charset "UTF-8";
/*
* jQuery File Upload UI Plugin NoScript CSS 1.0
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
.fileinput-button input {
position: static;
opacity: 1;
filter: none;
transform: none;
font-size: inherit;
direction: inherit;
}
.fileinput-button span,
.fileinput-button i,
.fileupload-buttonbar .delete,
.fileupload-buttonbar .toggle {
display: none;
}

View File

@@ -0,0 +1,68 @@
@charset "UTF-8";
/*
* jQuery File Upload UI Plugin CSS 8.8.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
.fileinput-button {
position: relative;
overflow: hidden;
}
.fileinput-button input {
position: absolute;
top: 0;
right: 0;
margin: 0;
opacity: 0;
filter: alpha(opacity=0);
transform: translate(-300px, 0) scale(4);
font-size: 23px;
direction: ltr;
cursor: pointer;
}
.fileupload-buttonbar .btn,
.fileupload-buttonbar .toggle {
margin-bottom: 5px;
}
.progress-animated .progress-bar,
.progress-animated .bar {
background: url(../img/progressbar.gif) !important;
filter: none;
}
.fileupload-loading {
float: right;
width: 32px;
height: 32px;
background: url(../img/loading.gif) center no-repeat;
background-size: contain;
display: none;
}
.fileupload-processing .fileupload-loading {
display: block;
}
.files audio,
.files video {
max-width: 300px;
}
@media (max-width: 767px) {
.fileupload-buttonbar .toggle,
.files .toggle,
.files .btn span {
display: none;
}
.files .name {
width: 80px;
word-wrap: break-word;
}
.files audio,
.files video {
max-width: 80px;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -9,6 +9,8 @@
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
prefix="fmt" %>
@@ -42,15 +44,249 @@
// Determine whether a file is REQUIRED to be uploaded (default to true)
boolean fileRequired = ConfigurationManager.getBooleanProperty("webui.submit.upload.required", true);
%>
boolean ajaxProgress = ConfigurationManager.getBooleanProperty("webui.submit.upload.ajax", true);
if (ajaxProgress)
{
%>
<c:set var="dspace.layout.head.last" scope="request">
<link rel="stylesheet" href="<%= request.getContextPath() %>/static/css/jquery.fileupload-ui.css">
<!-- CSS adjustments for browsers with JavaScript disabled -->
<noscript><link rel="stylesheet" href="<%= request.getContextPath() %>/static/css/jquery.fileupload-ui-noscript.css"></noscript>
<script type="text/javascript">
function initProgressBar($){
var progressbarArea = $("#progressBarArea");
progressbarArea.show();
}
function updateProgressBar($, data){
$('#uploadForm').find('input').attr('disabled','disabled');
$('#spanFile').button("disable")
$('#spanFileCancel').button("disable")
var percent = parseInt(data.loaded / data.total * 100, 10);
var progressbarArea = $("#progressBarArea");
var progressbar = $("#progressBar");
progressbar.progressbar({ value: data.loaded, max: data.total});
progressbarArea.find('p.progressBarInitMsg').hide();
progressbarArea.find('p.progressBarProgressMsg').show();
progressbarArea.find('p.progressBarCompleteMsg').hide();
progressbarArea.find('span.bytesRead').html(data.loaded);
progressbarArea.find('span.bytesTotal').html(data.total);
progressbarArea.find('span.percent').html(percent);
}
function completeProgressBar($, total){
var progressbarArea = $("#progressBarArea");
var progressbar = $("#progressBar");
progressbar.progressbar({ value: total, max: total});
progressbarArea.find('p.progressBarInitMsg').hide();
progressbarArea.find('p.progressBarProgressMsg').hide();
progressbarArea.find('p.progressBarCompleteMsg').show();
progressbarArea.find('span.bytesTotal').html(total);
}
function monitorProgressJSON($){
$.ajax({
cache: false,
url: '<%= request.getContextPath() %>/json/uploadProgress'})
.done(function(progress) {
var data = {loaded: progress.readBytes, total: progress.totalBytes};
updateProgressBar($, data);
setTimeout(function() {
monitorProgressJSON($);
}, 250);
});
}
function decorateFileInputChangeEvent($) {
if ($('#selectedFile').length > 0) {
$('#selectedFile').html($('#tfile').val().replace(/.*(\/|\\)/, '')).append('&nbsp;');
}
else {
$('<p id="selectedFile">'+$('#tfile').val().replace(/.*(\/|\\)/, '')+'</p>').insertAfter($('#spanFile')).append('&nbsp;');
var span = $('<span id="spanFileCancel"><fmt:message key="jsp.submit.choose-file.upload-ajax.button.cancel"/></span>');
span.appendTo($('#selectedFile'));
span.button({icons: {primary: "ui-icon ui-icon-cancel"}})
.click(function(e){
var parent = $('#spanFile').parent();
$('#spanFile').remove();
$('#selectedFile').remove();
$('<input type="file" name="file" id="tfile">').appendTo(parent);
$('#tfile').wrap('<span id="spanFile" class="fileinput-button"><fmt:message key="jsp.submit.choose-file.upload-ajax.button.select-file"/></span>');
$('#spanFile').button({icons: {primary: "ui-icon ui-icon-folder-open"}});
$('#tfile').on('change', function(){
decorateFileInputChangeEvent($);
});
});
}
}
function setupAjaxUpload($, data){
var progressbarArea = $("#progressBarArea");
var progressbar = $("#progressBar");
progressbar.progressbar({ value: false});
progressbarArea.find('p.progressBarInitMsg').show();
progressbarArea.find('p.progressBarProgressMsg').hide();
progressbarArea.find('p.progressBarCompleteMsg').hide();
progressbarArea.hide();
$('#tfile').wrap('<span id="spanFile" class="fileinput-button"><fmt:message key="jsp.submit.choose-file.upload-ajax.button.select-file"/></span>');
$('#spanFile').button({icons: {primary: "ui-icon ui-icon-folder-open"}});
$('#tfile').on('change', function(){
decorateFileInputChangeEvent($);
});
// the skip button should not send any files
$('input[name="<%=UploadStep.SUBMIT_SKIP_BUTTON%>"]').on('click', function(){
$('#tfile').val('');
});
$('#uploadForm').append('<input type="hidden" id="ajaxUpload" name="ajaxUpload" value="true" />');
// track the upload progress for all the submit buttons other than the skip
$('input[type="submit"]').not(":disabled")
.on('click', function(e){
$('#uploadForm').attr('target','uploadFormIFrame');
if ($('#tfile').val() != null && $('#tfile').val() != '') {
initProgressBar($);
setTimeout(function() {
monitorProgressJSON($);
}, 100);
}
$('#uploadFormIFrame').on('load',function(){
var resultFile = null;
try {
var jsonResult = $.parseJSON($('#uploadFormIFrame').contents().find('body').text());
if (jsonResult.fileSizeLimitExceeded) {
$('#actualSize').html(jsonResult.fileSizeLimitExceeded.actualSize);
$('#limitSize').html(jsonResult.fileSizeLimitExceeded.permittedSize);
$('#fileSizeLimitExceeded').dialog("open");
return true;
}
resultFile = jsonResult.files[0];
} catch (err) {
resultFile = new Object();
resultFile.status = null;
}
if (resultFile.status == <%= UploadStep.STATUS_COMPLETE %> ||
resultFile.status == <%= UploadStep.STATUS_UNKNOWN_FORMAT %>)
{
completeProgressBar($, resultFile.size);
if (resultFile.status == <%= UploadStep.STATUS_COMPLETE %>)
{
$('#uploadFormPostAjax').removeAttr('enctype')
.append('<input type="hidden" name="<%= UploadStep.SUBMIT_UPLOAD_BUTTON %>" value="1">');
}
else
{
$('#uploadFormPostAjax')
.append('<input type="hidden" name="submit_format_'+resultFile.bitstreamID+'" value="1">')
.append('<input type="hidden" name="bitstream_id" value="'+resultFile.bitstreamID+'">');
}
$('#uploadFormPostAjax').submit();
}
else {
if (resultFile.status == <%= UploadStep.STATUS_NO_FILES_ERROR %>) {
$('#fileRequired').dialog("open");
}
else if (resultFile.status == <%= UploadStep.STATUS_VIRUS_CHECKER_UNAVAILABLE %>) {
completeProgressBar($, resultFile.size);
$('#virusCheckNA').dialog("open");
}
else if (resultFile.status == <%= UploadStep.STATUS_CONTAINS_VIRUS %>) {
completeProgressBar($, resultFile.size);
$('#virusFound').dialog("open");
}
else {
$('#uploadError').dialog("open");
}
}
});
});
}
jQuery(document).ready(function($){
setupAjaxUpload($);
$('#uploadError').dialog({modal: true, autoOpen: false, width: 600, buttons: {
'<fmt:message key="jsp.submit.choose-file.upload-ajax.dialog.close"/>': function() {
$(this).dialog("close");
$('#uploadFormPostAjax')
.append('<input type="hidden" name="<%= UploadStep.SUBMIT_MORE_BUTTON %>" value="1">');
$('#uploadFormPostAjax').submit();
}
}});
$('#fileRequired').dialog({modal: true, autoOpen: false, width: 600, buttons: {
'<fmt:message key="jsp.submit.choose-file.upload-ajax.dialog.close"/>': function() {
$(this).dialog("close");
$('#uploadFormPostAjax')
.append('<input type="hidden" name="<%= UploadStep.SUBMIT_MORE_BUTTON %>" value="1">');
$('#uploadFormPostAjax').submit();
}
}});
$('#fileSizeLimitExceeded').dialog({modal: true, autoOpen: false, width: 600, buttons: {
'<fmt:message key="jsp.submit.choose-file.upload-ajax.dialog.close"/>': function() {
$(this).dialog("close");
$('#uploadFormPostAjax')
.append('<input type="hidden" name="<%= UploadStep.SUBMIT_MORE_BUTTON %>" value="1">');
$('#uploadFormPostAjax').submit();
}
}});
$('#virusFound').dialog({modal: true, autoOpen: false, width: 600, buttons: {
'<fmt:message key="jsp.submit.choose-file.upload-ajax.dialog.close"/>': function() {
$('#uploadFormPostAjax')
.append('<input type="hidden" name="<%= UploadStep.SUBMIT_MORE_BUTTON %>" value="1">');
$('#uploadFormPostAjax').submit();
$(this).dialog("close");
}
}});
$('#virusCheckNA').dialog({modal: true, autoOpen:false, width: 600, buttons: {
'<fmt:message key="jsp.submit.choose-file.upload-ajax.dialog.close"/>': function() {
$('#uploadFormPostAjax')
.append('<input type="hidden" name="<%= UploadStep.SUBMIT_MORE_BUTTON %>" value="1">');
$('#uploadFormPostAjax').submit();
$(this).dialog("close");
}
}});
});
</script>
</c:set>
<% } %>
<dspace:layout locbar="off"
navbar="off"
titlekey="jsp.submit.choose-file.title"
nocache="true">
<form method="post" action="<%= request.getContextPath() %>/submit" enctype="multipart/form-data" onkeydown="return disableEnterKey(event);">
<% if (ajaxProgress) { %>
<div style="display:none;" id="uploadError" title="<fmt:message key="jsp.submit.upload-error.title" />">
<p><fmt:message key="jsp.submit.upload-error.info" /></p>
</div>
<div style="display:none;" id="fileRequired" title="<fmt:message key="jsp.submit.choose-file.upload-ajax.fileRequired.title" />">
<p><fmt:message key="jsp.submit.choose-file.upload-ajax.fileRequired.info" /></p>
</div>
<div style="display:none;" id="fileSizeLimitExceeded" title="<fmt:message key="jsp.error.exceeded-size.title" />">
<p><fmt:message key="jsp.error.exceeded-size.text1">
<fmt:param><span id="actualSize">&nbsp;</span></fmt:param>
<fmt:param><span id="limitSize">&nbsp;</span></fmt:param>
</fmt:message></p>
</div>
<div style="display:none;" id="virusFound" title="<fmt:message key="jsp.submit.upload-error.title" />">
<p><fmt:message key="jsp.submit.virus-error.info" /></p>
</div>
<div style="display:none;" id="virusCheckNA" title="<fmt:message key="jsp.submit.upload-error.title" />">
<p><fmt:message key="jsp.submit.virus-checker-error.info" /></p>
</div>
<form style="display:none;" id="uploadFormPostAjax" method="post" action="<%= request.getContextPath() %>/submit"
enctype="multipart/form-data" onkeydown="return disableEnterKey(event);">
<%= SubmissionController.getSubmissionParameters(context, request) %>
</form>
<iframe id="uploadFormIFrame" name="uploadFormIFrame" style="display: none"> </iframe>
<% } %>
<form id="uploadForm" method="post" action="<%= request.getContextPath() %>/submit" enctype="multipart/form-data" onkeydown="return disableEnterKey(event);">
<jsp:include page="/submit/progressbar.jsp"/>
<%-- Hidden fields needed for SubmissionController servlet to know which step is next--%>
@@ -78,6 +314,27 @@
<div class="submitFormHelp"><fmt:message key="jsp.submit.choose-file.info6"/>
<dspace:popup page="<%= LocaleSupport.getLocalizedMessage(pageContext, \"help.formats\")%>"><fmt:message key="jsp.submit.choose-file.info7"/></dspace:popup>
</div>
<% if (ajaxProgress)
{
%>
<div id="progressBarArea" style="display: none; width: 50%; float: right;">
<div id="progressBar"></div>
<p class="progressBarInitMsg">
<fmt:message key="jsp.submit.choose-file.upload-ajax.uploadInit"/>
</p>
<p class="progressBarProgressMsg" style="display: none;">
<fmt:message key="jsp.submit.choose-file.upload-ajax.uploadInProgress">
<fmt:param><span class="percent">&nbsp;</span></fmt:param>
<fmt:param><span class="bytesRead">&nbsp;</span></fmt:param>
<fmt:param><span class="bytesTotal">&nbsp;</span></fmt:param>
</fmt:message></p>
<p class="progressBarCompleteMsg" style="display: none;">
<fmt:message key="jsp.submit.choose-file.upload-ajax.uploadCompleted">
<fmt:param><span class="bytesTotal">&nbsp;</span></fmt:param>
</fmt:message></p>
</div>
<% } %>
<table border="0" align="center">
<tr>
@@ -145,7 +402,7 @@
</td>
<%
//if upload is set to optional, or user returned to this page after pressing "Add Another File" button
if (!fileRequired || UIUtil.getSubmitButton(request, "").equals(UploadStep.SUBMIT_MORE_BUTTON))
if (!fileRequired || subInfo.getSubmissionItem().getItem().hasUploadedFiles())
{
%>
<td>

View File

@@ -1204,7 +1204,8 @@ plugin.sequence.org.dspace.plugin.SiteHomeProcessor = \
#
# comment out this line if you disable Discovery
plugin.named.org.dspace.app.webui.json.JSONRequest = \
org.dspace.app.webui.discovery.DiscoveryJSONRequest = discovery
org.dspace.app.webui.discovery.DiscoveryJSONRequest = discovery,\
org.dspace.app.webui.json.UploadProgressJSON = uploadProgress
#### Submission License substitution variables ####
@@ -1850,4 +1851,4 @@ webui.suggest.enable = false
# from. If your DSpace is in a load balanced enviornment or otherwise behind a
# context-switch then you will need to set the paramater to the HTTP parameter that
# records the original IP address.
#xmlui.controlpanel.activity.ipheader = X-Forward-For
#xmlui.controlpanel.activity.ipheader = X-Forward-For