1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f170cf78702b/ Changeset: f170cf78702b User: guerler Date: 2013-10-16 09:36:17 Summary: Add url, text input field to upload form Affected #: 4 files diff -r ecd1fe4c471d2cf9ede923c43f27d4e380f961d1 -r f170cf78702b3913a5e09ada1c75db2800ebc982 static/scripts/galaxy.upload.js --- a/static/scripts/galaxy.upload.js +++ b/static/scripts/galaxy.upload.js @@ -71,7 +71,7 @@ on_click : function(e) { self.event_show(e) }, on_unload : function() { if (self.counter.running > 0) - return "Currently uploads are running."; + return "Several uploads are still processing."; }, with_number : true }); @@ -129,9 +129,6 @@ // add upload item $(this.el).find('tbody:last').append(this.template_row(id)); - // scroll to bottom - //$(this.el).scrollTop($(this.el).prop('scrollHeight')); - // access upload item var it = this.get_upload_item(index); @@ -156,6 +153,26 @@ // update screen this.update_screen(); + + // activate text field if file content is zero + if (file.size == -1) + { + // get text component + var text = it.find('#text'); + + // get dimensions + var padding = parseInt($(text.parent()).css('padding')); + var width = it.width() - 2 * padding; + var height = it.height(); + + // set dimensions + text.width(width); + text.css('top', height + 'px'); + it.height(height + text.height() + padding); + + // show text field + text.show(); + } }, // start @@ -175,8 +192,13 @@ var current_history = Galaxy.currHistoryPanel.model.get('id'); var file_type = it.find('#extension').val(); var genome = it.find('#genome').val(); + var url_paste = it.find('#text-content').val(); var space_to_tabs = it.find('#space_to_tabs').is(':checked'); + // validate + if (!url_paste && !(file.size > 0)) + return null; + // configure uploadbox this.uploadbox.configure({url : galaxy_config.root + "api/tools/", paramname : "files_0|file_data"}); @@ -186,6 +208,7 @@ tool_input['file_type'] = file_type; tool_input['files_0|NAME'] = file.name; tool_input['files_0|type'] = 'upload_dataset'; + tool_input['files_0|url_paste'] = url_paste; tool_input['space_to_tabs'] = space_to_tabs; // setup data @@ -193,7 +216,7 @@ data['history_id'] = current_history; data['tool_id'] = 'upload1'; data['inputs'] = JSON.stringify(tool_input); - + // return additional data to be send with file return data; }, @@ -288,7 +311,7 @@ }, // start upload process - event_upload : function() + event_start : function() { // check if (this.counter.announce == 0 || this.counter.running > 0) @@ -307,6 +330,7 @@ symbol.addClass(self.state.queued); // disable options + $(this).find('#text-content').attr('disabled', true); $(this).find('#genome').attr('disabled', true); $(this).find('#extension').attr('disabled', true); $(this).find('#space_to_tabs').attr('disabled', true); @@ -318,21 +342,21 @@ this.update_screen(); // initiate upload procedure in plugin - this.uploadbox.upload(); + this.uploadbox.start(); }, // pause upload process - event_pause : function() + event_stop : function() { // check if (this.counter.running == 0) return; // request pause - this.uploadbox.pause(); + this.uploadbox.stop(); // set html content - $('#upload-info').html('Queueing will pause after completing the current file...'); + $('#upload-info').html('Queue will pause after completing the current file...'); }, // queue is done @@ -355,6 +379,7 @@ symbol.addClass(self.state.init); // disable options + $(this).find('#text-content').attr('disabled', false); $(this).find('#genome').attr('disabled', false); $(this).find('#extension').attr('disabled', false); $(this).find('#space_to_tabs').attr('disabled', false); @@ -412,6 +437,12 @@ } }, + // add (pseudo) file + event_add : function () + { + this.uploadbox.add([{ name : 'New File', size : -1 }]); + }, + // show/hide upload frame event_show : function (e) { @@ -428,13 +459,14 @@ title : 'Upload files from your local drive', body : this.template('upload-box', 'upload-info'), buttons : { - 'Select' : function() {self.uploadbox.select()}, - 'Upload' : function() {self.event_upload()}, - 'Pause' : function() {self.event_pause()}, - 'Reset' : function() {self.event_reset()}, - 'Close' : function() {self.modal.hide()} + 'Select' : function() {self.uploadbox.select()}, + 'Create' : function() {self.event_add()}, + 'Upload' : function() {self.event_start()}, + 'Pause' : function() {self.event_stop()}, + 'Reset' : function() {self.event_reset()}, + 'Close' : function() {self.modal.hide()}, }, - height : '350', + height : '400', width : '850' }); @@ -475,13 +507,14 @@ { // identify unit var unit = ""; - if (size >= 100000000000) { size = size / 100000000000; unit = "TB"; } else - if (size >= 100000000) { size = size / 100000000; unit = "GB"; } else - if (size >= 100000) { size = size / 100000; unit = "MB"; } else - if (size >= 100) { size = size / 100; unit = "KB"; } else - { size = size * 10; unit = "b"; } + if (size >= 100000000000) { size = size / 100000000000; unit = 'TB'; } else + if (size >= 100000000) { size = size / 100000000; unit = 'GB'; } else + if (size >= 100000) { size = size / 100000; unit = 'MB'; } else + if (size >= 100) { size = size / 100; unit = 'KB'; } else + if (size > 0) { size = size * 10; unit = 'b'; } else return '?'; + // return formatted string - return "<strong>" + (Math.round(size) / 10) + "</strong> " + unit; + return '<strong>' + (Math.round(size) / 10) + '</strong> ' + unit; }, // set screen @@ -494,7 +527,7 @@ // check default message if(this.counter.announce == 0) { - if (this.uploadbox.compatible) + if (this.uploadbox.compatible()) message = 'Drag&drop files into this box or click \'Select\' to select files!'; else message = 'Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Please upgrade to i.e. Firefox 4+, Chrome 7+, IE 10+, Opera 12+ or Safari 6+.' @@ -532,10 +565,14 @@ // select upload button if (this.counter.running == 0) + { this.modal.enableButton('Select'); - else + this.modal.enableButton('Create'); + } else { this.modal.disableButton('Select'); - + this.modal.disableButton('Create'); + } + // table visibility if (this.counter.announce + this.counter.success + this.counter.error > 0) $(this.el).find('table').show(); @@ -569,7 +606,13 @@ { // construct template var tmpl = '<tr id="' + id.substr(1) + '" class="upload-item">' + - '<td><div id="title" class="title"></div></td>' + + '<td style="position: relative;">' + + '<div id="title" class="title"></div>' + + '<div id="text" class="text">' + + '<div class="text-info">You may specify a list of URLs (one per line) or paste the contents of a file.</div>' + + '<textarea id="text-content" class="text-content form-control"></textarea>' + + '</div>' + + '</td>' + '<td><div id="size" class="size"></div></td>'; // add file type selectore diff -r ecd1fe4c471d2cf9ede923c43f27d4e380f961d1 -r f170cf78702b3913a5e09ada1c75db2800ebc982 static/scripts/utils/galaxy.uploadbox.js --- a/static/scripts/utils/galaxy.uploadbox.js +++ b/static/scripts/utils/galaxy.uploadbox.js @@ -25,7 +25,8 @@ error_default : "Please make sure the file is available.", error_server : "Upload request failed.", error_toomany : "You can only queue <20 files per upload session.", - error_login : "Uploads require you to log in." + error_login : "Uploads require you to log in.", + error_missing : "No upload content available." } // options @@ -42,7 +43,7 @@ // indicates if queue is currently running var queue_running = false; - var queue_pause = false; + var queue_stop = false; // element var el = null; @@ -159,21 +160,15 @@ // process an upload, recursive function process() { - // log - //console.log("Processing queue..." + queue_length + " (" + queue_running + " / " + queue_pause + ")"); - // validate - if (queue_length == 0 || queue_pause) + if (queue_length == 0 || queue_stop) { - queue_pause = false; + queue_stop = false; queue_running = false; opts.complete(); return; } else queue_running = true; - - // log - //console.log("Looking for file..."); // get an identifier from the queue var index = -1; @@ -188,9 +183,6 @@ // remove from queue remove(index) - - // log - //console.log("Initializing ('" + file.name + "')."); // identify maximum file size var filesize = file.size; @@ -199,8 +191,14 @@ // check file size if (filesize < maxfilesize) { - // send data - send(index, file, opts.initialize(index, file)) + // get parameters + var data = opts.initialize(index, file); + + // validate + if (data) + send(index, file, data); + else + error(index, file, opts.error_missing); } else { // skip file error(index, file, opts.error_filesize); @@ -214,7 +212,10 @@ var formData = new FormData(); for (var key in data) formData.append(key, data[key]); - formData.append(opts.paramname, file, file.name); + + // check file size + if (file.size > 0) + formData.append(opts.paramname, file, file.name); // prepare request xhr = new XMLHttpRequest(); @@ -226,9 +227,6 @@ // captures state changes xhr.onreadystatechange = function() { - // status change - //console.log("Status changed: " + xhr.readyState + "."); - // check for request completed, server connection closed if (xhr.readyState != xhr.DONE) return; @@ -271,9 +269,6 @@ // send request xhr.send(formData); - - // sending file - //console.log("Sending file ('" + file.name + "')."); } // success @@ -314,7 +309,7 @@ } // initiate upload process - function upload() + function start() { if (!queue_running) { @@ -323,11 +318,11 @@ } } - // pause upload process - function pause() + // stop upload process + function stop() { - // request pause - queue_pause = true; + // request stop + queue_stop = true; } // set options @@ -349,9 +344,10 @@ // export functions return { 'select' : select, + 'add' : add, 'remove' : remove, - 'upload' : upload, - 'pause' : pause, + 'start' : start, + 'stop' : stop, 'reset' : reset, 'configure' : configure, 'compatible' : compatible diff -r ecd1fe4c471d2cf9ede923c43f27d4e380f961d1 -r f170cf78702b3913a5e09ada1c75db2800ebc982 static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1129,6 +1129,8 @@ .upload-box .table th{text-align:center;white-space:nowrap} .upload-box .table td{margin:0px;paddign:0px} .upload-box .title{width:130px;word-wrap:break-word;font-size:11px} +.upload-box .text{position:absolute;display:none}.upload-box .text .text-content{font-size:11px;width:100%;height:50px;resize:none} +.upload-box .text .text-info{font-size:11px;color:#999} .upload-box .extension{width:100px;font-size:11px} .upload-box .genome{width:150px;font-size:11px} .upload-box .size{width:60px;white-space:nowrap} diff -r ecd1fe4c471d2cf9ede923c43f27d4e380f961d1 -r f170cf78702b3913a5e09ada1c75db2800ebc982 static/style/src/less/upload.less --- a/static/style/src/less/upload.less +++ b/static/style/src/less/upload.less @@ -39,6 +39,23 @@ font-size : @font-size-small; } + .text { + position: absolute; + display: none; + + .text-content { + font-size : @font-size-small; + width : 100%; + height : 50px; + resize : none; + } + + .text-info { + font-size : @font-size-small; + color : @gray-light; + } + } + .extension { width: 100px; font-size : @font-size-small; Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.