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 477928456e81c128cacac6e0e9ca255c04f877c1..88e95b38ad2f474cd883bccd67f8165370309916 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 @@ -63,11 +63,14 @@ function eraseCookie(name) { * * @class */ -function openbis(url, dssUrl) { - this.generalInfoServiceUrl = url + "/rmi-general-information-v1.json"; - this.queryServiceUrl = url + "/rmi-query-v1.json"; - this.dssUrl = dssUrl + "/rmi-dss-api-v1.json"; - this.webInfoServiceUrl = url + "/openbis/openbis/rmi-web-information-v1.json" +function openbis(openbisUrl, dssUrl) { + this.openbisUrl = openbisUrl; + this.dssUrl = dssUrl; + + this.generalInfoServiceUrl = openbisUrl + "/rmi-general-information-v1.json"; + this.queryServiceUrl = openbisUrl + "/rmi-query-v1.json"; + this.dssApiUrl = dssUrl + "/rmi-dss-api-v1.json"; + this.webInfoServiceUrl = openbisUrl + "/openbis/openbis/rmi-web-information-v1.json" } @@ -263,7 +266,7 @@ openbis.prototype.listDataSetsForSample = function(sample, restrictToDirectlyCon */ openbis.prototype.listFilesForDataSet = function(dataSetCode, path, recursive, action) { ajaxRequest({ - url: this.dssUrl, + url: this.dssApiUrl, data: { "method" : "listFilesForDataSet", "params" : [ this.sessionToken, dataSetCode, path, recursive ] }, @@ -278,7 +281,7 @@ openbis.prototype.listFilesForDataSet = function(dataSetCode, path, recursive, a */ openbis.prototype.getDownloadUrlForFileForDataSet = function(dataSetCode, filePath, action) { ajaxRequest({ - url: this.dssUrl, + url: this.dssApiUrl, data: { "method" : "getDownloadUrlForFileForDataSet", "params" : [ this.sessionToken, dataSetCode, filePath ] }, @@ -314,6 +317,31 @@ openbis.prototype.executeQuery = function(queryId, parameterBindings, action) { }); } +openbis.prototype.createSessionWorkspaceUploader = function(uploaderContainer){ + var $this = this; + + $('head').append('<link rel="stylesheet" media="screen" type="text/css" href="../uploader/css/src/upload.css" />'); + $('head').append('<script charset="utf-8" type="text/javascript" src="../uploader/js/src/upload.js" />'); + + $(uploaderContainer).load("../uploader/index.html", function(){ + Uploader.init({ + smart_mode: true, + 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", + sessionID: $this.sessionToken + }); + }); +} + +openbis.prototype.createSessionWorkspaceDownloadUrl = function(filePath){ + return this.dssUrl + "/datastore_server/session_workspace_file_download?sessionID=" + this.sessionToken + "&filePath=" + filePath; +} + +openbis.prototype.createSessionWorkspaceDownloadLink = function(filePath, linkText){ + return $("<a href='" + this.createSessionWorkspaceDownloadUrl(filePath) + "'>" + (linkText ? linkText : filePath) + "</a>"); +} + /** * A utility class for deferring an action until all of some kind of action has completed * @@ -345,6 +373,9 @@ actionDeferrer.prototype.dependencyCompleted = function(key) { } } +/** + * Provides a context information for webapps that are embedded inside the OpenBIS UI. + */ function openbisWebAppContext(){ this.sessionId = this.getParameter("session-id"); this.entityKind = this.getParameter("entity-kind"); 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 e32cb4ea4cbf5d49852ef61d4b2bdfea1b193dec..3612c626e7da295ecbacdd5c5ff07afb6ed2359d 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 @@ -1,32 +1,3 @@ -<!DOCTYPE html> -<html lang="de" dir="ltr"> -<head> -<title>Uploader 2.0</title> -<meta http-equiv="content-type" content="text/html; charset=utf-8" /> -<meta http-equiv="content-language" content="de" /> -<script charset="utf-8" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> -<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes" /> -<link rel="stylesheet" media="screen" type="text/css" href="css/src/upload.css" /> -<link rel="icon" type="image/png" href="img/favicon.gif"> -<script charset="utf-8" type="text/javascript" src="js/src/upload.js"></script> -<script charset="utf-8" type="text/javascript" src="../js/openbis.js"></script> -<script type="text/javascript"> -$(document).ready(function() { - - var o = new openbis("http://127.0.0.1:8888/openbis/openbis", "http://127.0.0.1:8889/datastore_server"); - - o.login("admin","password", function(response){ - Uploader.init({ - smart_mode: true, - chunk_size: 1000*1024, - file_upload_url: "http://127.0.0.1:8889/datastore_server/session_workspace_file_upload", - form_upload_url: "http://127.0.0.1:8889/datastore_server/session_workspace_form_upload", - sessionID: response.result - }); - }); - -}); -</script> <!-- Copyright 2012 Oliver Lau, Heise Zeitschriften Verlag @@ -42,8 +13,7 @@ Copyright 2012 Oliver Lau, Heise Zeitschriften Verlag See the License for the specific language governing permissions and limitations under the License. --> -</head> -<body> + <h1>Dateien hochladen</h1> <div id="filedrop"> <div id="filedrop-inner-box"> @@ -65,14 +35,11 @@ Copyright 2012 Oliver Lau, Heise Zeitschriften Verlag </form> </div><!-- filedrop-inner-box --> </div><!-- filedrop --> -<h2><a href="#">Uploads ^^</a></h2> +<h2><a href="#">Uploads</a></h2> <div id="filelist-container"> <ul id="filelist"></ul> <button id="filelist-clear-button" style="display: none">Liste leeren</button> </div><!-- filelist-container --> -<div id="footer"> - Copyright © 2012 <a href="mailto:ola@ct.de">Oliver Lau</a>, <a href="http://www.heise.de/" target="_blank">Heise Zeitschriften Verlag</a>. Lizenziert unter der <a href="www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache License 2.0</a>. -</div> <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"> <rect x="0" y="0" width="12" height="12" fill="#fff" /> @@ -88,6 +55,4 @@ Copyright 2012 Oliver Lau, Heise Zeitschriften Verlag <path d="M 1 1 L 11 5.5 L 1 11 Z" fill="#0c0" /> </svg> </div> -<div id="iframe-container"></div> -</body> -</html> +<div id="iframe-container"></div> \ No newline at end of file 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 727c4918870ac1f5da706482e160983b46e5a21f..574fc6d5f4d11645607e848d06d996f936f31a70 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 @@ -160,6 +160,7 @@ var Uploader = (function() { return; var xhr = new XMLHttpRequest; progress[id].xhr = xhr; + // pkupczyk: added sessionID xhr.open("POST", settings.file_upload_url + "?filename=" + file.name + "&id=" + id + @@ -301,6 +302,7 @@ var Uploader = (function() { function generateUploadForm() { var id = ++current_form_id; $("#iframe-container") + // pkupczyk: added sessionID .append("<iframe id=\"iframe-" + id + "\"" + " name=\"iframe-" + id + "\"" + "></iframe>" + @@ -359,13 +361,18 @@ var Uploader = (function() { $("#pause-button").replaceWith("<img id=\"pause-button\" src=\"img/pause-button.png\" width=\"12\" height=\"12\" class=\"mini-button\">"); } // Site-spezifische Einstellungen aus Konfigurationsdatei lesen - $.ajax("config.json", { async: false, dataType: "json" }) + + /* pkupczyk: we don't need this + + $.ajax("config.json", { async: false }) .done(function(data) { settings = $.extend({}, settings, data); }) .error(function(jqXHR, textStatus, errorThrown) { console.log([jqXHR, textStatus, errorThrown]); }); + */ + // Einstellungen ggf. mit init()-Parametern ueberschreiben settings = $.extend({}, settings, opts); settings.smart_mode = settings.smart_mode && defaults.smart_mode;