From b0e3e5504c3f6ff8744db388c35d45e73235ac53 Mon Sep 17 00:00:00 2001 From: pkupczyk <pkupczyk> Date: Fri, 10 Aug 2012 15:17:24 +0000 Subject: [PATCH] SP-224 / BIS-143: Expose session workspace to Custom Web UI: - make the download servlet return proper file names - adjust Uploader2 UI SVN: 26334 --- .../SessionWorkspaceFileDownloadServlet.java | 5 +---- .../cisd/openbis/public/resources/js/openbis.js | 1 + .../public/resources/uploader/css/src/upload.css | 2 -- .../openbis/public/resources/uploader/index.html | 14 +++++++------- .../public/resources/uploader/js/src/upload.js | 15 +++++++++------ 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/SessionWorkspaceFileDownloadServlet.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/SessionWorkspaceFileDownloadServlet.java index 830741b050c..994a516bca6 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/SessionWorkspaceFileDownloadServlet.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/SessionWorkspaceFileDownloadServlet.java @@ -135,14 +135,11 @@ public class SessionWorkspaceFileDownloadServlet extends HttpServlet try { String fileName = FilenameUtils.getName(filePath); + response.setHeader("Content-Disposition", "inline; filename=" + fileName); response.setContentType(URLConnection.guessContentTypeFromName(fileName)); response.setStatus(HttpServletResponse.SC_OK); outputStream = response.getOutputStream(); - - long startTime = System.currentTimeMillis(); IOUtils.copyLarge(fileStream, outputStream); - System.err.println("Download took: " + (System.currentTimeMillis() - startTime) - + " ms"); } finally { IOUtils.closeQuietly(fileStream); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js/openbis.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js/openbis.js index 88e95b38ad2..ae79d223dd0 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js/openbis.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js/openbis.js @@ -329,6 +329,7 @@ openbis.prototype.createSessionWorkspaceUploader = function(uploaderContainer){ chunk_size: 1000*1024, file_upload_url: $this.dssUrl + "/datastore_server/session_workspace_file_upload", form_upload_url: $this.dssUrl + "/datastore_server/session_workspace_form_upload", + file_download_url: $this.dssUrl + "/datastore_server/session_workspace_file_download", sessionID: $this.sessionToken }); }); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/css/src/upload.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/css/src/upload.css index b9baecdeb64..f48d76f4eec 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/css/src/upload.css +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/css/src/upload.css @@ -64,7 +64,6 @@ a:hover { } #filedrop { color: #000; - background-color: Beige; transition: background-color 0.25s linear; -moz-transition: background-color 0.25s linear; -o-transition: background-color 0.25s linear; @@ -124,7 +123,6 @@ button:hover { background-image: -webkit-linear-gradient(bottom, rgb(220,220,220) 8%, rgb(255,255,255) 89%); } #filelist-container { - background-color: Beige; padding: 2ex 1em 3ex 1em; } #filelist { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/index.html b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/index.html index 3612c626e7d..8363481403f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/index.html +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/index.html @@ -14,7 +14,7 @@ Copyright 2012 Oliver Lau, Heise Zeitschriften Verlag limitations under the License. --> -<h1>Dateien hochladen</h1> +<h1>Session workspace upload</h1> <div id="filedrop"> <div id="filedrop-inner-box"> <div id="filedrop-chooser"> @@ -27,7 +27,7 @@ Copyright 2012 Oliver Lau, Heise Zeitschriften Verlag <path transform="translate(10, 10) scale(1.5)" fill="url(#grd)" d="M 0 10 Q 0 0 10 0 L 110 0 Q 120 0 120 10 L 120 60 Q 120 70 110 70 L 85 70 L 85 45 L 110 45 L 60 10 L 10 45 L 35 45 L 35 70 L 10 70 Q 0 70 0 60 L 0 10 Z" /> </svg> <br /> - <button class="huge" id="fileinput-button">Dateien auswählen</button> + <button class="huge" id="fileinput-button">Select files to upload</button> </div><!-- filedrop-chooser --> <div id="filedrop-hint"></div><!-- filedrop-hint --> <form id="upload-form"> @@ -35,22 +35,22 @@ Copyright 2012 Oliver Lau, Heise Zeitschriften Verlag </form> </div><!-- filedrop-inner-box --> </div><!-- filedrop --> -<h2><a href="#">Uploads</a></h2> +<h2>Uploads</h2> <div id="filelist-container"> <ul id="filelist"></ul> - <button id="filelist-clear-button" style="display: none">Liste leeren</button> + <button id="filelist-clear-button" style="display: none">Clear all</button> </div><!-- filelist-container --> <div style="display: none" id="secret-elements"> - <svg class="mini-button" title="Abbrechen" id="stop-button" xmlns="http://www.w3.org/2000/svg" version="1.1" width="12" height="12"> + <svg class="mini-button" title="Abort" id="stop-button" xmlns="http://www.w3.org/2000/svg" version="1.1" width="12" height="12"> <rect x="0" y="0" width="12" height="12" fill="#fff" /> <rect x="1" y="1" width="10" height="10" fill="#c00" /> </svg> - <svg class="mini-button" title="Pausieren" id="pause-button" xmlns="http://www.w3.org/2000/svg" version="1.1" width="12" height="12"> + <svg class="mini-button" title="Paus" id="pause-button" xmlns="http://www.w3.org/2000/svg" version="1.1" width="12" height="12"> <rect x="0" y="0" width="12" height="12" fill="#fff" /> <rect x="2" y="1" width="3" height="10" fill="#00c" /> <rect x="7" y="1" width="3" height="10" fill="#00c" /> </svg> - <svg class="mini-button" title="Fortsetzen" id="play-button" xmlns="http://www.w3.org/2000/svg" version="1.1" width="12" height="12"> + <svg class="mini-button" title="Continue" id="play-button" xmlns="http://www.w3.org/2000/svg" version="1.1" width="12" height="12"> <rect x="0" y="0" width="12" height="12" fill="#fff" /> <path d="M 1 1 L 11 5.5 L 1 11 Z" fill="#0c0" /> </svg> diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/js/src/upload.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/js/src/upload.js index 574fc6d5f4d..c10240d3a14 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/js/src/upload.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/uploader/js/src/upload.js @@ -191,8 +191,9 @@ var Uploader = (function() { $("#progressbar-" + d.id).css("width", "100%"); $("#upload-" + d.id).addClass("ready"); $("#speed-" + d.id).html(styleSize(file.size / secs) + "/s"); + // pkupczyk: changed download url $("#filename-" + d.id).replaceWith("<a target=\"_blank\" " + - "href=\"" + settings.upload_dir + "/" + + "href=\"" + settings.file_download_url + "?sessionID=" + settings.sessionID + "&filePath=" + d.filename + "\">" + d.filename + "</a>"); $("#action-bar-" + d.id).remove(); delete progress[d.id]; @@ -376,10 +377,12 @@ var Uploader = (function() { // Einstellungen ggf. mit init()-Parametern ueberschreiben settings = $.extend({}, settings, opts); settings.smart_mode = settings.smart_mode && defaults.smart_mode; - $("h2 > a").attr("href", settings.upload_dir); + + // pkupczyk: we do not provide listing of uploaded files yet + //$("h2 > a").attr("href", settings.upload_dir); + if (settings.smart_mode) { - $("#filedrop-hint").html("Hochzuladende Dateien hier ablegen " + - "oder durch Klicken auswählen"); + $("#filedrop-hint").html("Drag and drop the files to upload here or click 'Select files to upload' button."); $(settings.file_input) .bind("change", function(event) { uploadFiles(event.target.files); @@ -416,11 +419,11 @@ var Uploader = (function() { ); } else { // fallback mode - $("#filedrop-hint").html("Hochzuladende Dateien durch Klicken auswählen"); + $("#filedrop-hint").html("Click 'Select files to upload' button."); generateUploadForm(); } $(settings.file_list_clear_button).click(clearFileList); - $("#filedrop-hint").append(".<br/>Upload startet sofort nach der Auswahl."); + $("#filedrop-hint").append("<br/>Upload starts immediately after the file selection."); } }; })(); -- GitLab