1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/3e2779423079/ Changeset: 3e2779423079 User: guerler Date: 2013-10-11 00:23:20 Summary: Add pause option to new upload front end Affected #: 2 files diff -r 657b263294836bbc1847ff66de72ddc7eb94ba11 -r 3e277942307951d816dfc345f619200d186ca954 static/scripts/galaxy.upload.js --- a/static/scripts/galaxy.upload.js +++ b/static/scripts/galaxy.upload.js @@ -24,9 +24,11 @@ // states state : { - init : 'fa-icon-trash', + init : 'fa-icon-trash', + queued : 'fa-icon-spinner fa-icon-spin', + running : '__running__', success : 'fa-icon-ok', - error : 'fa-icon-warning-sign' + error : 'fa-icon-warning-sign' }, // counter @@ -133,6 +135,10 @@ // get element var it = this.get_upload_item(index); + // update status + var sy = it.find('#symbol'); + sy.addClass(this.state.running); + // get configuration var current_history = Galaxy.currHistoryPanel.model.get('id'); var file_type = it.find('#extension').val(); @@ -208,10 +214,8 @@ // update icon var sy = it.find('#symbol'); - sy.removeClass('fa-icon-spin'); - sy.removeClass('fa-icon-spinner'); - - // set status + sy.removeClass(this.state.running); + sy.removeClass(this.state.queued); sy.addClass(this.state.success); }, @@ -245,10 +249,8 @@ // update icon var sy = it.find('#symbol'); - sy.removeClass('fa-icon-spin'); - sy.removeClass('fa-icon-spinner'); - - // set status + sy.removeClass(this.state.running); + sy.removeClass(this.state.queued); sy.addClass(this.state.error); }, @@ -267,14 +269,14 @@ var symbol = $(this).find('#symbol'); if(symbol.hasClass(self.state.init)) { + // set status symbol.removeClass(self.state.init); - symbol.addClass('fa-icon-spinner'); - symbol.addClass('fa-icon-spin'); + symbol.addClass(self.state.queued); + + // disable options + $(this).find('#extension').attr('disabled', true); + $(this).find('#space_to_tabs').attr('disabled', true); } - - // disable options - $(this).find('#extension').attr('disabled', true); - $(this).find('#space_to_tabs').attr('disabled', true); }); // update running @@ -285,6 +287,35 @@ this.uploadbox.upload(); }, + // pause upload process + event_pause : function() + { + // check + if (this.counter.running == 0) + return; + + // initiate upload procedure in plugin + this.uploadbox.pause(); + + // switch icons for new uploads + var items = $(this.el).find('.upload-item'); + var self = this; + items.each(function() + { + var symbol = $(this).find('#symbol'); + if(symbol.hasClass(self.state.queued) && !symbol.hasClass(self.state.running)) + { + // update status + symbol.removeClass(self.state.queued); + symbol.addClass(self.state.init); + + // disable options + $(this).find('#extension').attr('disabled', false); + $(this).find('#space_to_tabs').attr('disabled', false); + } + }); + }, + // queue is done event_complete: function() { @@ -361,6 +392,7 @@ 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()} }, @@ -452,6 +484,12 @@ this.modal.enableButton('Upload'); else this.modal.disableButton('Upload'); + + // pause upload button + if (this.counter.running > 0) + this.modal.enableButton('Pause'); + else + this.modal.disableButton('Pause'); // select upload button if (this.counter.running == 0) diff -r 657b263294836bbc1847ff66de72ddc7eb94ba11 -r 3e277942307951d816dfc345f619200d186ca954 static/scripts/utils/galaxy.uploadbox.js --- a/static/scripts/utils/galaxy.uploadbox.js +++ b/static/scripts/utils/galaxy.uploadbox.js @@ -154,7 +154,7 @@ function process() { // validate - if (queue_length == 0) + if (queue_length == 0 || !queue_status) { queue_status = false; opts.complete(); @@ -229,11 +229,6 @@ // prepare request var xhr = new XMLHttpRequest(); - - // prepare upload progress - xhr.upload.index = index; - xhr.upload.file = file; - xhr.upload.addEventListener('progress', progress, false); // onloadend xhr.onloadend = function() @@ -265,6 +260,11 @@ success(index, file, response); } + // prepare upload progress + xhr.upload.index = index; + xhr.upload.file = file; + xhr.upload.addEventListener('progress', progress, false); + // open request xhr.open('POST', opts.url, true); xhr.setRequestHeader('Accept', 'application/json'); @@ -314,7 +314,17 @@ function upload() { if (!queue_status) + { + queue_status = true; process(); + } + } + + // pause upload process + function pause() + { + // set global status variable to false + queue_status = false; } // set options @@ -338,6 +348,7 @@ 'select' : select, 'remove' : remove, 'upload' : upload, + 'pause' : pause, 'reset' : reset, 'configure' : configure, 'compatible' : compatible 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.