commit/galaxy-central: guerler: Separate upload javascript into files and place into mvc directory
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/be283631c612/ Changeset: be283631c612 User: guerler Date: 2014-01-17 23:55:15 Summary: Separate upload javascript into files and place into mvc directory Affected #: 22 files diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a config/plugins/visualizations/charts/static/app.js --- a/config/plugins/visualizations/charts/static/app.js +++ b/config/plugins/visualizations/charts/static/app.js @@ -46,12 +46,23 @@ // append main this.charts_view.append(this.viewport_view.$el); - // create + // set elements + this.setElement(this.portlet.$el); + + // hide views this.group_view.$el.hide(); this.charts_view.$el.hide(); - // set elements - this.setElement(this.portlet.$el); + // events + var self = this; + this.config.on('change:current_view', function() { + self._showCurrent(); + }); + }, + + // current view + _showCurrent: function() { + }, // execute command diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/galaxy.library.js --- a/static/scripts/galaxy.library.js +++ b/static/scripts/galaxy.library.js @@ -11,7 +11,7 @@ define([ "galaxy.modal", "galaxy.masthead", - "utils/galaxy.utils", + "utils/utils", "libs/toastr"], function(mod_modal, mod_masthead, mod_utils, mod_toastr) { // MMMMMMMMMMMMMMM diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/galaxy.masthead.js --- a/static/scripts/galaxy.masthead.js +++ b/static/scripts/galaxy.masthead.js @@ -1,9 +1,5 @@ -/* - galaxy masthead -*/ - // dependencies -define(["utils/galaxy.utils"], function(mod_utils) { +define([], function() { // masthead var GalaxyMasthead = Backbone.View.extend( diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/galaxy.upload.js --- a/static/scripts/galaxy.upload.js +++ /dev/null @@ -1,703 +0,0 @@ -/* - galaxy upload -*/ - -// dependencies -define(["galaxy.modal", "galaxy.masthead", "utils/galaxy.utils", "utils/galaxy.uploadbox"], function(mod_modal, mod_masthead, mod_utils) { - -// galaxy upload -var GalaxyUpload = Backbone.View.extend( -{ - // own modal - modal : null, - - // button - button_show : null, - - // upload mod - uploadbox: null, - - // current history - current_history: null, - - // extension types - select_extension :[['Auto-detect', 'auto']], - - // genomes - select_genome : [['Unspecified (?)', '?']], - - // states - state : { - init : 'fa fa-trash-o', - queued : 'fa fa-spinner fa-spin', - running : '__running__', - success : 'fa fa-check', - error : 'fa fa-exclamation-triangle' - }, - - // counter - counter : { - // stats - announce : 0, - success : 0, - error : 0, - running : 0, - - // reset stats - reset : function() - { - this.announce = this.success = this.error = this.running = 0; - } - }, - - // options - options : { - nginx_upload_path : '' - }, - - // initialize - initialize : function(options) - { - // wait for galaxy history panel (workaround due to the use of iframes) - if (!Galaxy.currHistoryPanel) - { - var self = this; - window.setTimeout(function() { self.initialize() }, 500) - return; - } - - // check if logged in - if (!Galaxy.currUser.get('id')) - return; - - // add activate icon - var self = this; - this.button_show = new mod_masthead.GalaxyMastheadIcon ( - { - icon : 'fa-arrow-circle-o-up', - tooltip : 'Upload Files', - on_click : function(e) { self.event_show(e) }, - on_unload : function() { - if (self.counter.running > 0) - return "Several uploads are still processing."; - }, - with_number : true - }); - - // add to masthead - Galaxy.masthead.prepend(this.button_show); - - // load extension - var self = this; - mod_utils.jsonFromUrl(galaxy_config.root + "api/datatypes", - function(datatypes) { - for (key in datatypes) - self.select_extension.push([datatypes[key], datatypes[key]]); - }); - - // load genomes - mod_utils.jsonFromUrl(galaxy_config.root + "api/genomes", - function(genomes) { - // backup default - var def = self.select_genome[0]; - - // fill array - self.select_genome = []; - for (key in genomes) - if (genomes[key].length > 1) - if (genomes[key][1] !== def[1]) - self.select_genome.push(genomes[key]); - - // sort - self.select_genome.sort(function(a, b) { - return a[0] > b[0] ? 1 : a[0] < b[0] ? -1 : 0; - }); - - // insert default back to array - self.select_genome.unshift(def); - }); - - // read in options - if (options) { - this.options = _.defaults(options, this.options); - } - }, - - // mouse over - event_dragover : function (e) - { - }, - - // mouse left - event_dragleave : function (e) - { - }, - - // start - event_announce : function(index, file, message) - { - // make id - var id = '#upload-' + index; - - // add upload item - $(this.el).find('tbody:last').append(this.template_row(id)); - - // access upload item - var it = this.get_upload_item(index); - - // fade in - it.fadeIn(); - - // update title - it.find('#title').html(file.name); - - // update info - it.find('#size').html(this.size_to_string (file.size)); - - // add functionality to new row elements - var self = this; - - // handle click event - it.find('#symbol').on('click', function() { self.event_remove (index) }); - - // handle text editing event - it.find('#text-content').on('keyup', function() { - var count = it.find('#text-content').val().length; - it.find('#size').html(self.size_to_string (count)); - }); - - // handle genome selection event - var self = this; - it.find('#genome').on('change', function(e) { - // identify selected genome - var selected_genome = $(e.target).val(); - - // update genome - var items = $(self.el).find('.upload-item'); - items.each(function() - { - var symbol = $(this).find('#symbol'); - var genome = $(this).find('#genome'); - if(symbol.hasClass(self.state.init) && genome.val() == '?') { - genome.val(selected_genome); - } - }); - }); - - // initialize progress - this.event_progress(index, file, 0); - - // update counter - this.counter.announce++; - - // 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 padding - var padding = 8; - - // get dimensions - var width = it.width() - 2 * padding; - var height = it.height() - padding; - - // set dimensions - text.css('width', width + 'px'); - text.css('top', height + 'px'); - it.height(height + text.height() + 2 * padding); - - // show text field - text.show(); - } - }, - - // start - event_initialize : function(index, file, message) - { - // update on screen counter - this.button_show.number(this.counter.announce); - - // get element - var it = this.get_upload_item(index); - - // update status - var sy = it.find('#symbol'); - sy.addClass(this.state.running); - - // get configuration - 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 : this.options.nginx_upload_path, paramname : "files_0|file_data"}); - - // configure tool - tool_input = {}; - tool_input['dbkey'] = genome; - 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 - data = {}; - data['history_id'] = this.current_history; - data['tool_id'] = 'upload1'; - data['inputs'] = JSON.stringify(tool_input); - - // return additional data to be send with file - return data; - }, - - // progress - event_progress : function(index, file, message) - { - // get element - var it = this.get_upload_item(index); - - // get value - var percentage = parseInt(message); - - // update progress - it.find('.progress-bar').css({ width : percentage + '%' }); - - // update value - if (percentage != 100) - it.find('#percentage').html(percentage + '%'); - else - it.find('#percentage').html('Adding to history...'); - }, - - // success - event_success : function(index, file, message) - { - // make sure progress is shown correctly - this.event_progress(index, file, 100); - - // update on screen counter - this.button_show.number(''); - - // update counter - this.counter.announce--; - this.counter.success++; - - // update on screen info - this.update_screen(); - - // get element - var it = this.get_upload_item(index); - - // update progress frame - it.addClass('success'); - - // update text - it.find('#percentage').html('100%'); - - // update icon - var sy = it.find('#symbol'); - sy.removeClass(this.state.running); - sy.removeClass(this.state.queued); - sy.addClass(this.state.success); - - // update galaxy history - Galaxy.currHistoryPanel.refreshHdas(); - }, - - // error - event_error : function(index, file, message) - { - // make sure progress is shown correctly - this.event_progress(index, file, 0); - - // update on screen counter - this.button_show.number(''); - - // update counter - this.counter.announce--; - this.counter.error++; - - // update on screen info - this.update_screen(); - - // get element - var it = this.get_upload_item(index); - - // update progress frame - it.addClass('danger'); - - // remove progress bar - it.find('.progress').remove(); - - // write error message - it.find('#info').html('<strong>Failed: </strong>' + message).show(); - - // update icon - var sy = it.find('#symbol'); - sy.removeClass(this.state.running); - sy.removeClass(this.state.queued); - sy.addClass(this.state.error); - }, - - // start upload process - event_start : function() - { - // check - if (this.counter.announce == 0 || this.counter.running > 0) - return; - - // 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.init)) - { - // set status - symbol.removeClass(self.state.init); - 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); - } - }); - - // backup current history - this.current_history = Galaxy.currHistoryPanel.model.get('id'); - - // update running - this.counter.running = this.counter.announce; - this.update_screen(); - - // initiate upload procedure in plugin - this.uploadbox.start(); - }, - - // pause upload process - event_stop : function() - { - // check - if (this.counter.running == 0) - return; - - // request pause - this.uploadbox.stop(); - - // set html content - $('#upload-info').html('Queue will pause after completing the current file...'); - }, - - // queue is done - event_complete: function() - { - // update running - this.counter.running = 0; - this.update_screen(); - - // 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('#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); - } - }); - }, - - // remove all - event_reset : function() - { - // make sure queue is not running - if (this.counter.running == 0) - { - // remove from screen - var items = $(this.el).find('.upload-item'); - $(this.el).find('table').fadeOut({ complete : function() { items.remove(); }}); - - // reset counter - this.counter.reset(); - - // show on screen info - this.update_screen(); - - // remove from queue - this.uploadbox.reset(); - } - }, - - // remove item from upload list - event_remove : function(index) - { - // get item - var it = this.get_upload_item(index); - var sy = it.find('#symbol'); - - // only remove from queue if not in processing line - if (sy.hasClass(this.state.init) || sy.hasClass(this.state.success) || sy.hasClass(this.state.error)) - { - // reduce counter - if (it.hasClass('success')) - this.counter.success--; - else if (it.hasClass('danger')) - this.counter.error--; - else - this.counter.announce--; - - // show on screen info - this.update_screen(); - - // remove from queue - this.uploadbox.remove(index); - - // remove element - it.remove(); - } - }, - - // create (pseudo) file - event_create : function () - { - this.uploadbox.add([{ name : 'New File', size : -1 }]); - }, - - // show/hide upload frame - event_show : function (e) - { - // prevent default - e.preventDefault(); - - // create modal - if (!this.modal) - { - // make modal - var self = this; - this.modal = new mod_modal.GalaxyModal( - { - title : 'Upload files from your local drive', - body : this.template('upload-box', 'upload-info'), - buttons : { - 'Select' : function() {self.uploadbox.select()}, - 'Create' : function() {self.event_create()}, - 'Upload' : function() {self.event_start()}, - 'Pause' : function() {self.event_stop()}, - 'Reset' : function() {self.event_reset()}, - 'Close' : function() {self.modal.hide()}, - }, - height : '400', - width : '900' - }); - - // set element - this.setElement('#upload-box'); - - // file upload - var self = this; - this.uploadbox = this.$el.uploadbox( - { - dragover : function() { self.event_dragover() }, - dragleave : function() { self.event_dragleave() }, - announce : function(index, file, message) { self.event_announce(index, file, message) }, - initialize : function(index, file, message) { return self.event_initialize(index, file, message) }, - success : function(index, file, message) { self.event_success(index, file, message) }, - progress : function(index, file, message) { self.event_progress(index, file, message) }, - error : function(index, file, message) { self.event_error(index, file, message) }, - complete : function() { self.event_complete() }, - }); - - // setup info - this.update_screen(); - } - - // show modal - this.modal.show(); - }, - - // get upload item - get_upload_item: function(index) - { - // get element - return $(this.el).find('#upload-' + index); - }, - - // to string - size_to_string : function (size) - { - // 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 - if (size > 0) { size = size * 10; unit = 'b'; } else - return '<strong>-</strong>'; - - // return formatted string - return '<strong>' + (Math.round(size) / 10) + '</strong> ' + unit; - }, - - // set screen - update_screen: function () - { - /* - update on screen info - */ - - // check default message - if(this.counter.announce == 0) - { - 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+.' - } else { - if (this.counter.running == 0) - message = 'You added ' + this.counter.announce + ' file(s) to the queue. Add more files or click \'Upload\' to proceed.'; - else - message = 'Please wait...' + this.counter.announce + ' out of ' + this.counter.running + ' remaining.'; - } - - // set html content - $('#upload-info').html(message); - - /* - update button status - */ - - // update reset button - if (this.counter.running == 0 && this.counter.announce + this.counter.success + this.counter.error > 0) - this.modal.enableButton('Reset'); - else - this.modal.disableButton('Reset'); - - // update upload button - if (this.counter.running == 0 && this.counter.announce > 0) - 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) - { - this.modal.enableButton('Select'); - 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(); - else - $(this.el).find('table').hide(); - }, - - // load html template - template: function(id, idInfo) - { - return '<div id="' + id + '" class="upload-box">' + - '<table class="table table-striped" style="display: none;">' + - '<thead>' + - '<tr>' + - '<th>Name</th>' + - '<th>Size</th>' + - '<th>Type</th>' + - '<th>Genome</th>' + - '<th>Space→Tab</th>' + - '<th>Status</th>' + - '<th></th>' + - '</tr>' + - '</thead>' + - '<tbody></tbody>' + - '</table>' + - '</div>' + - '<h6 id="' + idInfo + '" class="upload-info"></h6>'; - }, - - template_row: function(id) - { - // construct template - var tmpl = '<tr id="' + id.substr(1) + '" class="upload-item">' + - '<td>' + - '<div 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>' + - '</div>' + - '</td>' + - '<td><div id="size" class="size"></div></td>'; - - // add file type selectore - tmpl += '<td>' + - '<select id="extension" class="extension">'; - for (key in this.select_extension) - tmpl += '<option value="' + this.select_extension[key][1] + '">' + this.select_extension[key][0] + '</option>'; - tmpl += '</select>' + - '</td>'; - - // add genome selector - tmpl += '<td>' + - '<select id="genome" class="genome">'; - for (key in this.select_genome) - tmpl += '<option value="' + this.select_genome[key][1] + '">' + this.select_genome[key][0] + '</option>'; - tmpl += '</select>' + - '</td>'; - - // add next row - tmpl += '<td><input id="space_to_tabs" type="checkbox"></input></td>' + - '<td>' + - '<div id="info" class="info">' + - '<div class="progress">' + - '<div class="progress-bar progress-bar-success"></div>' + - '<div id="percentage" class="percentage">0%</div>' + - '</div>' + - '</div>' + - '</td>' + - '<td><div id="symbol" class="symbol ' + this.state.init + '"></div></td>' + - '</tr>'; - - // return html string - return tmpl; - } -}); - -// return -return { - GalaxyUpload: GalaxyUpload -}; - -}); diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/mvc/upload/upload-model.js --- /dev/null +++ b/static/scripts/mvc/upload/upload-model.js @@ -0,0 +1,27 @@ +// dependencies +define([], function() { + +// model +var Model = Backbone.Model.extend({ + defaults: { + extension : 'auto', + genome : '?', + url_paste : '', + space_to_tabs : false, + status : 'init', + info : null + } +}); + +// collection +var Collection = Backbone.Collection.extend({ + model: Model +}); + +// return +return { + Model: Model, + Collection : Collection +}; + +}); diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/mvc/upload/upload-row.js --- /dev/null +++ b/static/scripts/mvc/upload/upload-row.js @@ -0,0 +1,270 @@ +// dependencies +define(['mvc/upload/upload-model'], function(UploadModel) { + +// item view +return Backbone.View.extend({ + // options + options: { + padding : 8 + }, + + // states + status_classes : { + init : 'symbol fa fa-trash-o', + queued : 'symbol fa fa-spinner fa-spin', + success : 'symbol fa fa-check', + error : 'symbol fa fa-exclamation-triangle' + }, + + // render + initialize: function(app, options) { + // link app + this.app = app; + + // link this + var self = this; + + // create model + this.model = new UploadModel.Model(options); + + // add upload item + this.setElement(this._template(options)); + + // link item + var it = this.$el; + + // handle click event + it.find('#symbol').on('click', function() { + // get current status + var status = self.model.get('status'); + + // only remove from queue if not in processing line + if (status == 'init' || status == 'success' || status == 'error') + { + // remove from collection + self.app.collection.remove(self.model); + } + }); + + // handle text editing event + it.find('#text-content').on('keyup', function() { + // get properties + var $el = it.find('#text-content'); + var value = $el.val(); + var count = value.length; + + // update size string + it.find('#size').html(self._formatSize (count)); + + // update url paste content + self.model.set('url_paste', value); + }); + + // handle genome selection + it.find('#genome').on('change', function(e) { + self.model.set('genome', $(e.target).val()); + }); + + // handle extension selection + it.find('#extension').on('change', function(e) { + self.model.set('extension', $(e.target).val()); + }); + + // handle space to tabs button + it.find('#space_to_tabs').on('change', function(e) { + self.model.set('space_to_tabs', $(e.target).prop('checked')); + }); + + // events + this.model.on('change:percentage', function() { + self._refreshPercentage(); + }); + this.model.on('change:status', function() { + self._refreshStatus(); + }); + this.model.on('change:info', function() { + self._refreshInfo(); + }); + this.model.on('remove', function() { + self.remove(); + }); + this.app.collection.on('reset', function() { + self.remove(); + }); + }, + + // render + render: function() { + // read model + var file_name = this.model.get('file_name'); + var file_size = this.model.get('file_size'); + + // link item + var it = this.$el; + + // update title + it.find('#title').html(file_name); + + // update info + it.find('#size').html(this._formatSize (file_size)); + + // activate text field if file content is zero + if (file_size == -1) + { + // get text component + var text = it.find('#text'); + + // get padding + var padding = this.options.padding; + + // get dimensions + var width = it.width() - 2 * padding; + var height = it.height() - padding; + + // set dimensions + text.css('width', width + 'px'); + text.css('top', height + 'px'); + it.height(height + text.height() + 2 * padding); + + // show text field + text.show(); + } + }, + + // progress + _refreshInfo: function() + { + // write error message + var info = this.model.get('info'); + if (info) { + this.$el.find('#info').html('<strong>Failed: </strong>' + info).show(); + } else { + this.$el.find('#info').hide(); + } + }, + + // progress + _refreshPercentage : function() + { + var percentage = parseInt(this.model.get('percentage')); + this.$el.find('.progress-bar').css({ width : percentage + '%' }); + if (percentage != 100) + this.$el.find('#percentage').html(percentage + '%'); + else + this.$el.find('#percentage').html('Adding to history...'); + }, + + // status + _refreshStatus : function() + { + // get element + var it = this.$el; + + // identify new status + var status = this.model.get('status'); + var status_class = this.status_classes[status]; + + // identify symbol and reset classes + var sy = this.$el.find('#symbol'); + sy.removeClass(); + + // set new status class + sy.addClass(status_class); + + // enable form fields + if (status == 'init') { + it.find('#text-content').attr('disabled', false); + it.find('#genome').attr('disabled', false); + it.find('#extension').attr('disabled', false); + it.find('#space_to_tabs').attr('disabled', false); + } else { + it.find('#text-content').attr('disabled', true); + it.find('#genome').attr('disabled', true); + it.find('#extension').attr('disabled', true); + it.find('#space_to_tabs').attr('disabled', true); + } + + // success + if (status == 'success') { + it.addClass('success'); + it.find('#percentage').html('100%'); + } + + // error + if (status == 'error') { + it.addClass('danger'); + it.find('.progress').remove(); + } + }, + + // to string + _formatSize : function (size) + { + // 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 + if (size > 0) { size = size * 10; unit = 'b'; } else + return '<strong>-</strong>'; + + // return formatted string + return '<strong>' + (Math.round(size) / 10) + '</strong> ' + unit; + }, + + // template + _template: function(options) + { + // link this + var self = this; + + // construct template + var tmpl = '<tr id="upload-item-' + options.id + '" class="upload-item">' + + '<td>' + + '<div 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>' + + '</div>' + + '</td>' + + '<td><div id="size" class="size"></div></td>'; + + // add file type selectore + tmpl += '<td>' + + '<select id="extension" class="extension">'; + for (key in self.app.select_extension) + tmpl += '<option value="' + self.app.select_extension[key][1] + '">' + self.app.select_extension[key][0] + '</option>'; + tmpl += '</select>' + + '</td>'; + + // add genome selector + tmpl += '<td>' + + '<select id="genome" class="genome">'; + for (key in self.app.select_genome) + tmpl += '<option value="' + self.app.select_genome[key][1] + '">' + self.app.select_genome[key][0] + '</option>'; + tmpl += '</select>' + + '</td>'; + + // add next row + tmpl += '<td><input id="space_to_tabs" type="checkbox"></input></td>' + + '<td>' + + '<div id="info" class="info">' + + '<div class="progress">' + + '<div class="progress-bar progress-bar-success"></div>' + + '<div id="percentage" class="percentage">0%</div>' + + '</div>' + + '</div>' + + '</td>' + + '<td><div id="symbol" class="' + this.status_classes.init + '"></div></td>' + + '</tr>'; + + // return html string + return tmpl; + } + +}); + +}); diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/mvc/upload/upload-view.js --- /dev/null +++ b/static/scripts/mvc/upload/upload-view.js @@ -0,0 +1,509 @@ +// dependencies +define(["galaxy.modal", + "galaxy.masthead", + "utils/utils", + "mvc/upload/upload-model", + "mvc/upload/upload-row", + "utils/uploadbox"], + + function( mod_modal, + mod_masthead, + mod_utils, + UploadModel, + UploadItem + ) { + +// galaxy upload +return Backbone.View.extend( +{ + // own modal + modal : null, + + // button + button_show : null, + + // jquery uploadbox plugin + uploadbox: null, + + // current history + current_history: null, + + // extension types + select_extension :[['Auto-detect', 'auto']], + + // genomes + select_genome : [['Unspecified (?)', '?']], + + // collection + collection : new UploadModel.Collection(), + + // counter + counter : { + // stats + announce : 0, + success : 0, + error : 0, + running : 0, + + // reset stats + reset : function() + { + this.announce = this.success = this.error = this.running = 0; + } + }, + + // options + options : { + nginx_upload_path : '' + }, + + // initialize + initialize : function(options) + { + // link this + var self = this; + + // wait for galaxy history panel (workaround due to the use of iframes) + if (!Galaxy.currHistoryPanel) + { + window.setTimeout(function() { self.initialize() }, 500) + return; + } + + // check if logged in + if (!Galaxy.currUser.get('id')) + return; + + // add activate icon + this.button_show = new mod_masthead.GalaxyMastheadIcon ( + { + icon : 'fa-arrow-circle-o-up', + tooltip : 'Upload Files', + on_click : function(e) { self._eventShow(e) }, + on_unload : function() { + if (self.counter.running > 0) + return "Several uploads are still processing."; + }, + with_number : true + }); + + // add to masthead + Galaxy.masthead.prepend(this.button_show); + + // load extension + var self = this; + mod_utils.jsonFromUrl(galaxy_config.root + "api/datatypes", + function(datatypes) { + for (key in datatypes) + self.select_extension.push([datatypes[key], datatypes[key]]); + }); + + // load genomes + mod_utils.jsonFromUrl(galaxy_config.root + "api/genomes", + function(genomes) { + // backup default + var def = self.select_genome[0]; + + // fill array + self.select_genome = []; + for (key in genomes) + if (genomes[key].length > 1) + if (genomes[key][1] !== def[1]) + self.select_genome.push(genomes[key]); + + // sort + self.select_genome.sort(function(a, b) { + return a[0] > b[0] ? 1 : a[0] < b[0] ? -1 : 0; + }); + + // insert default back to array + self.select_genome.unshift(def); + }); + + // read in options + if (options) { + this.options = _.defaults(options, this.options); + } + + // events + this.collection.on('remove', function(item) { + self._eventRemove(item); + }); + this.collection.on('change', function(item) { + console.log('here'); + }); + }, + + // + // event triggered by upload button + // + + // show/hide upload frame + _eventShow : function (e) + { + // prevent default + e.preventDefault(); + + // create modal + if (!this.modal) + { + // make modal + var self = this; + this.modal = new mod_modal.GalaxyModal( + { + title : 'Upload files from your local drive', + body : this._template('upload-box', 'upload-info'), + buttons : { + 'Select' : function() {self.uploadbox.select()}, + 'Create' : function() {self._eventCreate()}, + 'Upload' : function() {self._eventStart()}, + 'Pause' : function() {self._eventStop()}, + 'Reset' : function() {self._eventReset()}, + 'Close' : function() {self.modal.hide()}, + }, + height : '400', + width : '900' + }); + + // set element + this.setElement('#upload-box'); + + // file upload + var self = this; + this.uploadbox = this.$el.uploadbox( + { + announce : function(index, file, message) { self._eventAnnounce(index, file, message) }, + initialize : function(index, file, message) { return self._eventInitialize(index, file, message) }, + progress : function(index, file, message) { self._eventProgress(index, file, message) }, + success : function(index, file, message) { self._eventSuccess(index, file, message) }, + error : function(index, file, message) { self._eventError(index, file, message) }, + complete : function() { self._eventComplete() } + }); + + // setup info + this._updateScreen(); + } + + // show modal + this.modal.show(); + }, + + // + // events triggered by collection + // + + // remove item from upload list + _eventRemove : function(item) + { + // update status + var status = item.get('status'); + + // reduce counter + if (status == 'success') { + this.counter.success--; + } else if (status == 'error') { + this.counter.error--; + } else { + this.counter.announce--; + } + + // show on screen info + this._updateScreen(); + + // remove from queue + this.uploadbox.remove(item.id); + }, + + // + // events triggered by the upload box plugin + // + + // a new file has been dropped/selected through the uploadbox plugin + _eventAnnounce : function(index, file, message) + { + // update counter + this.counter.announce++; + + // update screen + this._updateScreen(); + + // create view/model + var upload_item = new UploadItem(this, { + id : index, + file_name : file.name, + file_size : file.size + }); + + // add to collection + this.collection.add(upload_item.model); + + // add upload item element to table + $(this.el).find('tbody:last').append(upload_item.$el); + + // render + upload_item.render(); + }, + + // the uploadbox plugin is initializing the upload for this file + _eventInitialize : function(index, file, message) + { + // get element + var it = this.collection.get(index); + + // update status + it.set('state', 'running'); + + // update on screen counter + this.button_show.number(this.counter.announce); + + // get configuration + var file_type = it.get('extension'); + var file_name = it.get('file_name'); + var genome = it.get('genome'); + var url_paste = it.get('url_paste'); + var space_to_tabs = it.get('space_to_tabs'); + + // validate + if (!url_paste && !(file.size > 0)) + return null; + + // configure uploadbox + this.uploadbox.configure({url : this.options.nginx_upload_path, paramname : "files_0|file_data"}); + + // configure tool + tool_input = {}; + tool_input['dbkey'] = genome; + 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 + data = {}; + data['history_id'] = this.current_history; + data['tool_id'] = 'upload1'; + data['inputs'] = JSON.stringify(tool_input); + + // return additional data to be send with file + return data; + }, + + // progress + _eventProgress : function(index, file, percentage) + { + var it = this.collection.get(index); + it.set('percentage', percentage); + }, + + // success + _eventSuccess : function(index, file, message) + { + // update status + var it = this.collection.get(index); + it.set('status', 'success'); + + // update on screen counter + this.button_show.number(''); + + // update counter + this.counter.announce--; + this.counter.success++; + + // update on screen info + this._updateScreen(); + + // update galaxy history + Galaxy.currHistoryPanel.refreshHdas(); + }, + + // error + _eventError : function(index, file, message) + { + // get element + var it = this.collection.get(index); + + // update status + it.set('status', 'error'); + it.set('info', message); + + // update on screen counter + this.button_show.number(''); + + // update counter + this.counter.announce--; + this.counter.error++; + + // update on screen info + this._updateScreen(); + }, + + // queue is done + _eventComplete: function() { + // reset queued upload to initial status + this.collection.each(function(item) { + if(item.get('status') == 'queued') { + item.set('status', 'init'); + } + }); + + // update running + this.counter.running = 0; + this._updateScreen(); + }, + + // + // events triggered by this view + // + + // create (pseudo) file + _eventCreate : function () + { + this.uploadbox.add([{ name : 'New File', size : -1 }]); + }, + + // start upload process + _eventStart : function() { + // check + if (this.counter.announce == 0 || this.counter.running > 0) { + return; + } + + // switch icons for new uploads + this.collection.each(function(item) { + if(item.get('status') == 'init') { + item.set('status', 'queued'); + } + }); + + // backup current history + this.current_history = Galaxy.currHistoryPanel.model.get('id'); + + // update running + this.counter.running = this.counter.announce; + this._updateScreen(); + + // initiate upload procedure in plugin + this.uploadbox.start(); + }, + + // pause upload process + _eventStop : function() { + // check + if (this.counter.running == 0) { + return; + } + + // request pause + this.uploadbox.stop(); + + // set html content + $('#upload-info').html('Queue will pause after completing the current file...'); + }, + + // remove all + _eventReset : function() { + // make sure queue is not running + if (this.counter.running == 0) + { + // reset collection + this.collection.reset(); + + // reset counter + this.counter.reset(); + + // show on screen info + this._updateScreen(); + + // remove from queue + this.uploadbox.reset(); + } + }, + + // set screen + _updateScreen: function () + { + /* + update on screen info + */ + + // check default message + if(this.counter.announce == 0) + { + 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+.' + } else { + if (this.counter.running == 0) + message = 'You added ' + this.counter.announce + ' file(s) to the queue. Add more files or click \'Upload\' to proceed.'; + else + message = 'Please wait...' + this.counter.announce + ' out of ' + this.counter.running + ' remaining.'; + } + + // set html content + $('#upload-info').html(message); + + /* + update button status + */ + + // update reset button + if (this.counter.running == 0 && this.counter.announce + this.counter.success + this.counter.error > 0) + this.modal.enableButton('Reset'); + else + this.modal.disableButton('Reset'); + + // update upload button + if (this.counter.running == 0 && this.counter.announce > 0) + 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) + { + this.modal.enableButton('Select'); + 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(); + else + $(this.el).find('table').hide(); + }, + + // load html template + _template: function(id, idInfo) + { + return '<div id="' + id + '" class="upload-box">' + + '<table class="table table-striped" style="display: none;">' + + '<thead>' + + '<tr>' + + '<th>Name</th>' + + '<th>Size</th>' + + '<th>Type</th>' + + '<th>Genome</th>' + + '<th>Space→Tab</th>' + + '<th>Status</th>' + + '<th></th>' + + '</tr>' + + '</thead>' + + '<tbody></tbody>' + + '</table>' + + '</div>' + + '<h6 id="' + idInfo + '" class="upload-info"></h6>'; + } +}); + +}); diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/galaxy.library.js --- a/static/scripts/packed/galaxy.library.js +++ b/static/scripts/packed/galaxy.library.js @@ -1,1 +1,1 @@ -var view=null;var library_router=null;var responses=[];define(["galaxy.modal","galaxy.masthead","utils/galaxy.utils","libs/toastr"],function(k,l,h,n){var f=Backbone.Model.extend({urlRoot:"/api/libraries"});var c=Backbone.Model.extend({urlRoot:"/api/folders"});var o=Backbone.Collection.extend({url:"/api/libraries",model:f});var i=Backbone.Model.extend({urlRoot:"/api/libraries/datasets"});var d=Backbone.Collection.extend({model:i});var e=Backbone.Model.extend({defaults:{folder:new d(),full_path:"unknown",urlRoot:"/api/folders/",id:"unknown"},parse:function(r){this.full_path=r[0].full_path;this.get("folder").reset(r[1].folder_contents);return r}});var b=Backbone.Model.extend({urlRoot:"/api/histories/"});var j=Backbone.Model.extend({url:"/api/histories/"});var p=Backbone.Collection.extend({url:"/api/histories",model:j});var q=Backbone.Router.extend({routes:{"":"libraries","folders/:id":"folder_content","folders/:folder_id/download/:format":"download"}});var m=Backbone.View.extend({el:"#center",progress:0,progressStep:1,lastSelectedHistory:"",modal:null,folders:null,initialize:function(){this.folders=[];this.queue=jQuery.Deferred();this.queue.resolve()},templateFolder:function(){var r=[];r.push('<div id="library_container" style="width: 90%; margin: auto; margin-top: 2em; ">');r.push('<h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>');r.push('<div id="library_folder_toolbar" >');r.push(' <button title="Create New Folder" id="toolbtn_create_folder" class="btn btn-primary" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder-close"></span> folder</button>');r.push(' <button id="toolbtn_bulk_import" class="btn btn-primary" style="display: none; margin-left: 0.5em;" type="button"><span class="fa fa-external-link"></span> to history</button>');r.push(' <div id="toolbtn_dl" class="btn-group" style="margin-left: 0.5em; display: none; ">');r.push(' <button id="drop_toggle" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">');r.push(' <span class="fa fa-download"></span> download <span class="caret"></span>');r.push(" </button>");r.push(' <ul class="dropdown-menu" role="menu">');r.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');r.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');r.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');r.push(" </ul>");r.push(" </div>");r.push("</div>");r.push('<div class="library_breadcrumb">');r.push('<a title="Return to the list of libraries" href="#">Libraries</a><b>|</b> ');r.push("<% _.each(path, function(path_item) { %>");r.push("<% if (path_item[0] != id) { %>");r.push('<a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a><b>|</b> ');r.push("<% } else { %>");r.push('<span title="You are in this folder"><%- path_item[1] %></span>');r.push("<% } %>");r.push("<% }); %>");r.push("</div>");r.push('<table id="folder_table" class="table table-condensed">');r.push(" <thead>");r.push(' <th style="text-align: center; width: 20px; "><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>');r.push(' <th class="button_heading">view</th>');r.push(" <th>name</th>");r.push(" <th>data type</th>");r.push(" <th>size</th>");r.push(" <th>date (UTC)</th>");r.push(" </thead>");r.push(" <tbody>");r.push(" <td></td>");r.push(' <td><button title="Go to parent folder" type="button" data-id="<%- upper_folder_id %>" class="btn_open_folder btn btn-default btn-xs">');r.push(' <span class="fa fa-arrow-up"></span> .. go up</td>');r.push(" <td></td>");r.push(" <td></td>");r.push(" <td></td>");r.push(" <td></td>");r.push(" </tr>");r.push(" <% _.each(items, function(content_item) { %>");r.push(' <tr class="folder_row light" id="<%- content_item.id %>">');r.push(' <% if (content_item.get("type") === "folder") { %>');r.push(" <td></td>");r.push(' <td><button title="Open this folder" type="button" data-id="<%- content_item.id %>" class="btn_open_folder btn btn-default btn-xs">');r.push(' <span class="fa fa-folder-open"></span> browse</td>');r.push(' <td><%- content_item.get("name") %>');r.push(' <% if (content_item.get("item_count") === 0) { %>');r.push(' <span class="muted">(empty folder)</span>');r.push(" <% } %>");r.push(" </td>");r.push(" <td>folder</td>");r.push(' <td><%= _.escape(content_item.get("item_count")) %> item(s)</td>');r.push(" <% } else { %>");r.push(' <td style="text-align: center; "><input style="margin: 0;" type="checkbox"></td>');r.push(" <td>");r.push(' <button title="See details of this dataset" type="button" class="library-dataset btn btn-default btn-xs">');r.push(' <span class="fa fa-eye"></span> details');r.push(" </button>");r.push(" </td>");r.push(' <td><%- content_item.get("name") %></td>');r.push(' <td><%= _.escape(content_item.get("data_type")) %></td>');r.push(' <td><%= _.escape(content_item.get("readable_size")) %></td>');r.push(" <% } %> ");r.push(' <td><%= _.escape(content_item.get("time_updated")) %></td>');r.push(" </tr>");r.push(" <% }); %>");r.push(" ");r.push(" </tbody>");r.push("</table>");r.push("</div>");return r.join("")},templateDatasetModal:function(){var r=[];r.push('<div id="dataset_info_modal">');r.push(' <table class="table table-striped table-condensed">');r.push(" <tr>");r.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');r.push(' <td><%= _.escape(item.get("name")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Data type</th>');r.push(' <td><%= _.escape(item.get("data_type")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Genome build</th>');r.push(' <td><%= _.escape(item.get("genome_build")) %></td>');r.push(" </tr>");r.push(' <th scope="row">Size</th>');r.push(" <td><%= _.escape(size) %></td>");r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Date uploaded (UTC)</th>');r.push(' <td><%= _.escape(item.get("date_uploaded")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Uploaded by</th>');r.push(' <td><%= _.escape(item.get("uploaded_by")) %></td>');r.push(" </tr>");r.push(' <tr scope="row">');r.push(' <th scope="row">Data Lines</th>');r.push(' <td scope="row"><%= _.escape(item.get("metadata_data_lines")) %></td>');r.push(" </tr>");r.push(' <th scope="row">Comment Lines</th>');r.push(' <% if (item.get("metadata_comment_lines") === "") { %>');r.push(' <td scope="row"><%= _.escape(item.get("metadata_comment_lines")) %></td>');r.push(" <% } else { %>");r.push(' <td scope="row">unknown</td>');r.push(" <% } %>");r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Number of Columns</th>');r.push(' <td scope="row"><%= _.escape(item.get("metadata_columns")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Column Types</th>');r.push(' <td scope="row"><%= _.escape(item.get("metadata_column_types")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Miscellaneous information</th>');r.push(' <td scope="row"><%= _.escape(item.get("misc_blurb")) %></td>');r.push(" </tr>");r.push(" </table>");r.push(' <pre class="peek">');r.push(" </pre>");r.push("</div>");return r.join("")},templateHistorySelectInModal:function(){var r=[];r.push('<span id="history_modal_combo" style="width:90%; margin-left: 1em; margin-right: 1em; ">');r.push("Select history: ");r.push('<select id="dataset_import_single" name="dataset_import_single" style="width:50%; margin-bottom: 1em; "> ');r.push(" <% _.each(histories, function(history) { %>");r.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');r.push(" <% }); %>");r.push("</select>");r.push("</span>");return r.join("")},templateBulkImportInModal:function(){var r=[];r.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');r.push("Select history: ");r.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');r.push(" <% _.each(histories, function(history) { %>");r.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');r.push(" <% }); %>");r.push("</select>");r.push("</span>");return r.join("")},templateProgressBar:function(){var r=[];r.push('<div class="import_text">');r.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");r.push("</div>");r.push('<div class="progress">');r.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');r.push(' <span class="completion_span">0% Complete</span>');r.push(" </div>");r.push("</div>");r.push("");return r.join("")},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return tmpl_array.join("")},events:{"click #select-all-checkboxes":"selectAll","click .folder_row":"selectClickedRow","click #toolbtn_bulk_import":"modalBulkImport","click #toolbtn_dl":"bulkDownload","click .library-dataset":"showDatasetDetails","click #toolbtn_create_folder":"createFolderFromModal","click .btn_open_folder":"navigateToFolder"},render:function(r){$("#center").css("overflow","auto");view=this;var t=this;var s=new e({id:r.id});s.url=s.attributes.urlRoot+r.id+"/contents";s.fetch({success:function(u){for(var w=0;w<s.attributes.folder.models.length;w++){var v=s.attributes.folder.models[w];if(v.get("type")==="file"){v.set("readable_size",t.size_to_string(v.get("file_size")))}}var y=s.full_path;var z;if(y.length===1){z=0}else{z=y[y.length-2][0]}var x=_.template(t.templateFolder(),{path:s.full_path,items:s.attributes.folder.models,id:r.id,upper_folder_id:z});t.$el.html(x)},error:function(){n.error("An error occured :(")}})},size_to_string:function(r){var s="";if(r>=100000000000){r=r/100000000000;s="TB"}else{if(r>=100000000){r=r/100000000;s="GB"}else{if(r>=100000){r=r/100000;s="MB"}else{if(r>=100){r=r/100;s="KB"}else{r=r*10;s="b"}}}}return(Math.round(r)/10)+s},navigateToFolder:function(s){var r=$(s.target).attr("data-id");if(typeof r==="undefined"){return false}else{if(r==="0"){library_router.navigate("/",{trigger:true,replace:false})}else{library_router.navigate("folders/"+r,{trigger:true,replace:false})}}},showDatasetDetails:function(u){u.preventDefault();var v=$(u.target).parent().parent().attr("id");var t=new i();var s=new p();t.id=v;var r=this;t.fetch({success:function(w){s.fetch({success:function(x){r.renderModalAfterFetch(w,x)},error:function(){n.error("An error occured during fetching histories:(");r.renderModalAfterFetch(w)}})},error:function(){n.error("An error occured during loading dataset details :(")}})},renderModalAfterFetch:function(w,t){var u=this.size_to_string(w.get("file_size"));var v=_.template(this.templateDatasetModal(),{item:w,size:u});var s=this;this.modal=new k.GalaxyModal({destructible:true,bindClosingEvents:true,title:"Dataset Details",body:v,buttons:{Import:function(){s.importCurrentIntoHistory()},Download:function(){s.downloadCurrent()},Close:function(){s.modal.hideOrDestroy()}}});$(".peek").html(w.get("peek"));if(typeof history.models!==undefined){var r=_.template(this.templateHistorySelectInModal(),{histories:t.models});$(this.modal.elMain).find(".buttons").prepend(r);if(s.lastSelectedHistory.length>0){$(this.modal.elMain).find("#dataset_import_single").val(s.lastSelectedHistory)}}this.modal.show()},downloadCurrent:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var r=[];r.push($("#id_row").attr("data-id"));var s="/api/libraries/datasets/download/uncompressed";var t={ldda_ids:r};folderContentView.processDownload(s,t);this.modal.enableButton("Import");this.modal.enableButton("Download")},importCurrentIntoHistory:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var t=$(this.modal.elMain).find("select[name=dataset_import_single] option:selected").val();this.lastSelectedHistory=t;var r=$("#id_row").attr("data-id");var u=new b();var s=this;u.url=u.urlRoot+t+"/contents";u.save({content:r,source:"library"},{success:function(){n.success("Dataset imported");s.modal.enableButton("Import");s.modal.enableButton("Download")},error:function(){n.error("An error occured! Dataset not imported. Please try again.");s.modal.enableButton("Import");s.modal.enableButton("Download")}})},selectAll:function(s){var r=s.target.checked;that=this;$(":checkbox").each(function(){this.checked=r;$row=$(this.parentElement.parentElement);(r)?that.makeDarkRow($row):that.makeWhiteRow($row)});this.checkTools()},selectClickedRow:function(s){var u="";var r;var t;if(s.target.localName==="input"){u=s.target;r=$(s.target.parentElement.parentElement);t="input"}else{if(s.target.localName==="td"){u=$("#"+s.target.parentElement.id).find(":checkbox")[0];r=$(s.target.parentElement);t="td"}}if(u===""){s.stopPropagation();return}if(u===undefined){s.stopPropagation();return}if(u.checked){if(t==="td"){u.checked="";this.makeWhiteRow(r)}else{if(t==="input"){this.makeDarkRow(r)}}}else{if(t==="td"){u.checked="selected";this.makeDarkRow(r)}else{if(t==="input"){this.makeWhiteRow(r)}}}this.checkTools()},makeDarkRow:function(r){r.removeClass("light");r.find("a").removeClass("light");r.addClass("dark");r.find("a").addClass("dark")},makeWhiteRow:function(r){r.removeClass("dark");r.find("a").removeClass("dark");r.addClass("light");r.find("a").addClass("light")},checkTools:function(){var r=$("#folder_table").find(":checked");if(r.length>0){$("#toolbtn_bulk_import").show();$("#toolbtn_dl").show()}else{$("#toolbtn_bulk_import").hide();$("#toolbtn_dl").hide()}},modalBulkImport:function(){var s=this;var r=new p();r.fetch({success:function(t){var u=_.template(s.templateBulkImportInModal(),{histories:t.models});s.modal=new k.GalaxyModal({destructible:true,bindClosingEvents:true,title:"Import into History",body:u,buttons:{Import:function(){s.importAllIntoHistory()},Close:function(){s.modal.hideOrDestroy()}}});s.modal.show()},error:function(){n.error("An error occured :(")}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var t=$("select[name=dataset_import_bulk] option:selected").val();var x=$("select[name=dataset_import_bulk] option:selected").text();var z=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){z.push(this.parentElement.parentElement.id)}});var y=_.template(this.templateProgressBar(),{history_name:x});$(this.modal.elMain).find(".modal-body").html(y);var u=100/z.length;this.initProgress(u);var r=[];for(var s=z.length-1;s>=0;s--){library_dataset_id=z[s];var v=new b();var w=this;v.url=v.urlRoot+t+"/contents";v.content=library_dataset_id;v.source="library";r.push(v)}this.chainCall(r)},chainCall:function(s){var r=this;var t=s.pop();if(typeof t==="undefined"){n.success("All datasets imported");this.modal.hideOrDestroy();return}var u=$.when(t.save({content:t.content,source:t.source})).done(function(v){r.updateProgress();responses.push(v);r.chainCall(s)})},initProgress:function(r){this.progress=0;this.progressStep=r},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(r,v){var t=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){t.push(this.parentElement.parentElement.id)}});var s="/api/libraries/datasets/download/"+v;var u={ldda_ids:t};this.processDownload(s,u,"get")},processDownload:function(s,t,u){if(s&&t){t=typeof t=="string"?t:$.param(t);var r="";$.each(t.split("&"),function(){var v=this.split("=");r+='<input type="hidden" name="'+v[0]+'" value="'+v[1]+'" />'});$('<form action="'+s+'" method="'+(u||"post")+'">'+r+"</form>").appendTo("body").submit().remove();n.info("Your download will begin soon")}},createFolderFromModal:function(){event.preventDefault();event.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,bindClosingEvents:true,title:"Create New Folder",body:this.templateNewFolderInModal(),buttons:{Create:function(){r.create_new_folder_event()},Close:function(){r.modal.hideOrDestroy();r.modal=null}}});this.modal.show()},create_new_folder_event:function(){var r=this.serialize_new_folder();if(this.validate_new_folder(r)){var t=new c();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];t.url=t.urlRoot+"/"+current_folder_id;var s=this;t.save(r,{success:function(u){s.modal.hideOrDestroy();n.success("Folder created");s.render({id:current_folder_id})},error:function(){n.error("An error occured :(")}})}else{n.error("Folder's name is missing")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(r){return r.name!==""}});var a=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"show_library_modal"},initialize:function(){},templateLibraryList:function(){tmpl_array=[];tmpl_array.push('<div id="library_container" style="width: 90%; margin: auto; margin-top: 2em; overflow: auto !important; ">');tmpl_array.push("");tmpl_array.push('<h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>');tmpl_array.push('<a href="" id="create_new_library_btn" class="btn btn-primary file ">New Library</a>');tmpl_array.push('<table class="table table-condensed">');tmpl_array.push(" <thead>");tmpl_array.push(' <th class="button_heading"></th>');tmpl_array.push(" <th>name</th>");tmpl_array.push(" <th>description</th>");tmpl_array.push(" <th>synopsis</th> ");tmpl_array.push(" <th>model type</th> ");tmpl_array.push(" </thead>");tmpl_array.push(" <tbody>");tmpl_array.push(" <% _.each(libraries, function(library) { %>");tmpl_array.push(" <tr>");tmpl_array.push(' <td><button title="Open this library" type="button" data-id="<%- library.get("root_folder_id") %>" class="btn_open_folder btn btn-default btn-xs">');tmpl_array.push(' <span class="fa fa-folder-open"></span> browse</td>');tmpl_array.push(' <td><%- library.get("name") %></td>');tmpl_array.push(' <td><%= _.escape(library.get("description")) %></td>');tmpl_array.push(' <td><%= _.escape(library.get("synopsis")) %></td>');tmpl_array.push(' <td><%= _.escape(library.get("model_class")) %></td>');tmpl_array.push(" </tr>");tmpl_array.push(" <% }); %>");tmpl_array.push(" </tbody>");tmpl_array.push("</table>");tmpl_array.push("</div>");return tmpl_array.join("")},templateNewLibraryInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_library_modal">');tmpl_array.push(" <form>");tmpl_array.push(' <input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push(' <input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push(' <input type="text" name="Synopsis" value="" placeholder="Synopsis">');tmpl_array.push(" </form>");tmpl_array.push("</div>");return tmpl_array.join("")},render:function(){$("#center").css("overflow","auto");var r=this;libraries=new o();libraries.fetch({success:function(s){var t=_.template(r.templateLibraryList(),{libraries:s.models});r.$el.html(t)},error:function(t,s){if(s.statusCode().status===403){n.info("Please log in first. Redirecting to login page in 3s.");setTimeout(r.redirectToLogin,3000)}else{n.error("An error occured. Please try again.")}}})},redirectToHome:function(){window.location="../"},redirectToLogin:function(){window.location="/user/login"},modal:null,show_library_modal:function(s){s.preventDefault();s.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,bindClosingEvents:true,title:"Create New Library",body:this.templateNewLibraryInModal(),buttons:{Create:function(){r.create_new_library_event()},Close:function(){r.modal.hideOrDestroy()}}});this.modal.show()},create_new_library_event:function(){var t=this.serialize_new_library();if(this.validate_new_library(t)){var s=new f();var r=this;s.save(t,{success:function(u){r.modal.hideOrDestroy();r.clear_library_modal();r.render();n.success("Library created")},error:function(){n.error("An error occured :(")}})}else{n.error("Library's name is missing")}return false},clear_library_modal:function(){$("input[name='Name']").val("");$("input[name='Description']").val("");$("input[name='Synopsis']").val("")},serialize_new_library:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val(),synopsis:$("input[name='Synopsis']").val()}},validate_new_library:function(r){return r.name!==""}});var g=Backbone.View.extend({folderContentView:null,galaxyLibraryview:null,initialize:function(){folderContentView=new m();galaxyLibraryview=new a();library_router=new q();library_router.on("route:libraries",function(){galaxyLibraryview.render()});library_router.on("route:folder_content",function(r){folderContentView.render({id:r})});library_router.on("route:download",function(r,s){if($("#center").find(":checked").length===0){library_router.navigate("folders/"+r,{trigger:true,replace:true})}else{folderContentView.download(r,s);library_router.navigate("folders/"+r,{trigger:false,replace:true})}});Backbone.history.start({pushState:false})}});return{GalaxyApp:g}}); \ No newline at end of file +var view=null;var library_router=null;var responses=[];define(["galaxy.modal","galaxy.masthead","utils/utils","libs/toastr"],function(k,l,h,n){var f=Backbone.Model.extend({urlRoot:"/api/libraries"});var c=Backbone.Model.extend({urlRoot:"/api/folders"});var o=Backbone.Collection.extend({url:"/api/libraries",model:f});var i=Backbone.Model.extend({urlRoot:"/api/libraries/datasets"});var d=Backbone.Collection.extend({model:i});var e=Backbone.Model.extend({defaults:{folder:new d(),full_path:"unknown",urlRoot:"/api/folders/",id:"unknown"},parse:function(r){this.full_path=r[0].full_path;this.get("folder").reset(r[1].folder_contents);return r}});var b=Backbone.Model.extend({urlRoot:"/api/histories/"});var j=Backbone.Model.extend({url:"/api/histories/"});var p=Backbone.Collection.extend({url:"/api/histories",model:j});var q=Backbone.Router.extend({routes:{"":"libraries","folders/:id":"folder_content","folders/:folder_id/download/:format":"download"}});var m=Backbone.View.extend({el:"#center",progress:0,progressStep:1,lastSelectedHistory:"",modal:null,folders:null,initialize:function(){this.folders=[];this.queue=jQuery.Deferred();this.queue.resolve()},templateFolder:function(){var r=[];r.push('<div id="library_container" style="width: 90%; margin: auto; margin-top: 2em; ">');r.push('<h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>');r.push('<div id="library_folder_toolbar" >');r.push(' <button title="Create New Folder" id="toolbtn_create_folder" class="btn btn-primary" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder-close"></span> folder</button>');r.push(' <button id="toolbtn_bulk_import" class="btn btn-primary" style="display: none; margin-left: 0.5em;" type="button"><span class="fa fa-external-link"></span> to history</button>');r.push(' <div id="toolbtn_dl" class="btn-group" style="margin-left: 0.5em; display: none; ">');r.push(' <button id="drop_toggle" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">');r.push(' <span class="fa fa-download"></span> download <span class="caret"></span>');r.push(" </button>");r.push(' <ul class="dropdown-menu" role="menu">');r.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');r.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');r.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');r.push(" </ul>");r.push(" </div>");r.push("</div>");r.push('<div class="library_breadcrumb">');r.push('<a title="Return to the list of libraries" href="#">Libraries</a><b>|</b> ');r.push("<% _.each(path, function(path_item) { %>");r.push("<% if (path_item[0] != id) { %>");r.push('<a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a><b>|</b> ');r.push("<% } else { %>");r.push('<span title="You are in this folder"><%- path_item[1] %></span>');r.push("<% } %>");r.push("<% }); %>");r.push("</div>");r.push('<table id="folder_table" class="table table-condensed">');r.push(" <thead>");r.push(' <th style="text-align: center; width: 20px; "><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>');r.push(' <th class="button_heading">view</th>');r.push(" <th>name</th>");r.push(" <th>data type</th>");r.push(" <th>size</th>");r.push(" <th>date (UTC)</th>");r.push(" </thead>");r.push(" <tbody>");r.push(" <td></td>");r.push(' <td><button title="Go to parent folder" type="button" data-id="<%- upper_folder_id %>" class="btn_open_folder btn btn-default btn-xs">');r.push(' <span class="fa fa-arrow-up"></span> .. go up</td>');r.push(" <td></td>");r.push(" <td></td>");r.push(" <td></td>");r.push(" <td></td>");r.push(" </tr>");r.push(" <% _.each(items, function(content_item) { %>");r.push(' <tr class="folder_row light" id="<%- content_item.id %>">');r.push(' <% if (content_item.get("type") === "folder") { %>');r.push(" <td></td>");r.push(' <td><button title="Open this folder" type="button" data-id="<%- content_item.id %>" class="btn_open_folder btn btn-default btn-xs">');r.push(' <span class="fa fa-folder-open"></span> browse</td>');r.push(' <td><%- content_item.get("name") %>');r.push(' <% if (content_item.get("item_count") === 0) { %>');r.push(' <span class="muted">(empty folder)</span>');r.push(" <% } %>");r.push(" </td>");r.push(" <td>folder</td>");r.push(' <td><%= _.escape(content_item.get("item_count")) %> item(s)</td>');r.push(" <% } else { %>");r.push(' <td style="text-align: center; "><input style="margin: 0;" type="checkbox"></td>');r.push(" <td>");r.push(' <button title="See details of this dataset" type="button" class="library-dataset btn btn-default btn-xs">');r.push(' <span class="fa fa-eye"></span> details');r.push(" </button>");r.push(" </td>");r.push(' <td><%- content_item.get("name") %></td>');r.push(' <td><%= _.escape(content_item.get("data_type")) %></td>');r.push(' <td><%= _.escape(content_item.get("readable_size")) %></td>');r.push(" <% } %> ");r.push(' <td><%= _.escape(content_item.get("time_updated")) %></td>');r.push(" </tr>");r.push(" <% }); %>");r.push(" ");r.push(" </tbody>");r.push("</table>");r.push("</div>");return r.join("")},templateDatasetModal:function(){var r=[];r.push('<div id="dataset_info_modal">');r.push(' <table class="table table-striped table-condensed">');r.push(" <tr>");r.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');r.push(' <td><%= _.escape(item.get("name")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Data type</th>');r.push(' <td><%= _.escape(item.get("data_type")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Genome build</th>');r.push(' <td><%= _.escape(item.get("genome_build")) %></td>');r.push(" </tr>");r.push(' <th scope="row">Size</th>');r.push(" <td><%= _.escape(size) %></td>");r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Date uploaded (UTC)</th>');r.push(' <td><%= _.escape(item.get("date_uploaded")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Uploaded by</th>');r.push(' <td><%= _.escape(item.get("uploaded_by")) %></td>');r.push(" </tr>");r.push(' <tr scope="row">');r.push(' <th scope="row">Data Lines</th>');r.push(' <td scope="row"><%= _.escape(item.get("metadata_data_lines")) %></td>');r.push(" </tr>");r.push(' <th scope="row">Comment Lines</th>');r.push(' <% if (item.get("metadata_comment_lines") === "") { %>');r.push(' <td scope="row"><%= _.escape(item.get("metadata_comment_lines")) %></td>');r.push(" <% } else { %>");r.push(' <td scope="row">unknown</td>');r.push(" <% } %>");r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Number of Columns</th>');r.push(' <td scope="row"><%= _.escape(item.get("metadata_columns")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Column Types</th>');r.push(' <td scope="row"><%= _.escape(item.get("metadata_column_types")) %></td>');r.push(" </tr>");r.push(" <tr>");r.push(' <th scope="row">Miscellaneous information</th>');r.push(' <td scope="row"><%= _.escape(item.get("misc_blurb")) %></td>');r.push(" </tr>");r.push(" </table>");r.push(' <pre class="peek">');r.push(" </pre>");r.push("</div>");return r.join("")},templateHistorySelectInModal:function(){var r=[];r.push('<span id="history_modal_combo" style="width:90%; margin-left: 1em; margin-right: 1em; ">');r.push("Select history: ");r.push('<select id="dataset_import_single" name="dataset_import_single" style="width:50%; margin-bottom: 1em; "> ');r.push(" <% _.each(histories, function(history) { %>");r.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');r.push(" <% }); %>");r.push("</select>");r.push("</span>");return r.join("")},templateBulkImportInModal:function(){var r=[];r.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');r.push("Select history: ");r.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');r.push(" <% _.each(histories, function(history) { %>");r.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');r.push(" <% }); %>");r.push("</select>");r.push("</span>");return r.join("")},templateProgressBar:function(){var r=[];r.push('<div class="import_text">');r.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");r.push("</div>");r.push('<div class="progress">');r.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');r.push(' <span class="completion_span">0% Complete</span>');r.push(" </div>");r.push("</div>");r.push("");return r.join("")},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return tmpl_array.join("")},events:{"click #select-all-checkboxes":"selectAll","click .folder_row":"selectClickedRow","click #toolbtn_bulk_import":"modalBulkImport","click #toolbtn_dl":"bulkDownload","click .library-dataset":"showDatasetDetails","click #toolbtn_create_folder":"createFolderFromModal","click .btn_open_folder":"navigateToFolder"},render:function(r){$("#center").css("overflow","auto");view=this;var t=this;var s=new e({id:r.id});s.url=s.attributes.urlRoot+r.id+"/contents";s.fetch({success:function(u){for(var w=0;w<s.attributes.folder.models.length;w++){var v=s.attributes.folder.models[w];if(v.get("type")==="file"){v.set("readable_size",t.size_to_string(v.get("file_size")))}}var y=s.full_path;var z;if(y.length===1){z=0}else{z=y[y.length-2][0]}var x=_.template(t.templateFolder(),{path:s.full_path,items:s.attributes.folder.models,id:r.id,upper_folder_id:z});t.$el.html(x)},error:function(){n.error("An error occured :(")}})},size_to_string:function(r){var s="";if(r>=100000000000){r=r/100000000000;s="TB"}else{if(r>=100000000){r=r/100000000;s="GB"}else{if(r>=100000){r=r/100000;s="MB"}else{if(r>=100){r=r/100;s="KB"}else{r=r*10;s="b"}}}}return(Math.round(r)/10)+s},navigateToFolder:function(s){var r=$(s.target).attr("data-id");if(typeof r==="undefined"){return false}else{if(r==="0"){library_router.navigate("/",{trigger:true,replace:false})}else{library_router.navigate("folders/"+r,{trigger:true,replace:false})}}},showDatasetDetails:function(u){u.preventDefault();var v=$(u.target).parent().parent().attr("id");var t=new i();var s=new p();t.id=v;var r=this;t.fetch({success:function(w){s.fetch({success:function(x){r.renderModalAfterFetch(w,x)},error:function(){n.error("An error occured during fetching histories:(");r.renderModalAfterFetch(w)}})},error:function(){n.error("An error occured during loading dataset details :(")}})},renderModalAfterFetch:function(w,t){var u=this.size_to_string(w.get("file_size"));var v=_.template(this.templateDatasetModal(),{item:w,size:u});var s=this;this.modal=new k.GalaxyModal({destructible:true,bindClosingEvents:true,title:"Dataset Details",body:v,buttons:{Import:function(){s.importCurrentIntoHistory()},Download:function(){s.downloadCurrent()},Close:function(){s.modal.hideOrDestroy()}}});$(".peek").html(w.get("peek"));if(typeof history.models!==undefined){var r=_.template(this.templateHistorySelectInModal(),{histories:t.models});$(this.modal.elMain).find(".buttons").prepend(r);if(s.lastSelectedHistory.length>0){$(this.modal.elMain).find("#dataset_import_single").val(s.lastSelectedHistory)}}this.modal.show()},downloadCurrent:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var r=[];r.push($("#id_row").attr("data-id"));var s="/api/libraries/datasets/download/uncompressed";var t={ldda_ids:r};folderContentView.processDownload(s,t);this.modal.enableButton("Import");this.modal.enableButton("Download")},importCurrentIntoHistory:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var t=$(this.modal.elMain).find("select[name=dataset_import_single] option:selected").val();this.lastSelectedHistory=t;var r=$("#id_row").attr("data-id");var u=new b();var s=this;u.url=u.urlRoot+t+"/contents";u.save({content:r,source:"library"},{success:function(){n.success("Dataset imported");s.modal.enableButton("Import");s.modal.enableButton("Download")},error:function(){n.error("An error occured! Dataset not imported. Please try again.");s.modal.enableButton("Import");s.modal.enableButton("Download")}})},selectAll:function(s){var r=s.target.checked;that=this;$(":checkbox").each(function(){this.checked=r;$row=$(this.parentElement.parentElement);(r)?that.makeDarkRow($row):that.makeWhiteRow($row)});this.checkTools()},selectClickedRow:function(s){var u="";var r;var t;if(s.target.localName==="input"){u=s.target;r=$(s.target.parentElement.parentElement);t="input"}else{if(s.target.localName==="td"){u=$("#"+s.target.parentElement.id).find(":checkbox")[0];r=$(s.target.parentElement);t="td"}}if(u===""){s.stopPropagation();return}if(u===undefined){s.stopPropagation();return}if(u.checked){if(t==="td"){u.checked="";this.makeWhiteRow(r)}else{if(t==="input"){this.makeDarkRow(r)}}}else{if(t==="td"){u.checked="selected";this.makeDarkRow(r)}else{if(t==="input"){this.makeWhiteRow(r)}}}this.checkTools()},makeDarkRow:function(r){r.removeClass("light");r.find("a").removeClass("light");r.addClass("dark");r.find("a").addClass("dark")},makeWhiteRow:function(r){r.removeClass("dark");r.find("a").removeClass("dark");r.addClass("light");r.find("a").addClass("light")},checkTools:function(){var r=$("#folder_table").find(":checked");if(r.length>0){$("#toolbtn_bulk_import").show();$("#toolbtn_dl").show()}else{$("#toolbtn_bulk_import").hide();$("#toolbtn_dl").hide()}},modalBulkImport:function(){var s=this;var r=new p();r.fetch({success:function(t){var u=_.template(s.templateBulkImportInModal(),{histories:t.models});s.modal=new k.GalaxyModal({destructible:true,bindClosingEvents:true,title:"Import into History",body:u,buttons:{Import:function(){s.importAllIntoHistory()},Close:function(){s.modal.hideOrDestroy()}}});s.modal.show()},error:function(){n.error("An error occured :(")}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var t=$("select[name=dataset_import_bulk] option:selected").val();var x=$("select[name=dataset_import_bulk] option:selected").text();var z=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){z.push(this.parentElement.parentElement.id)}});var y=_.template(this.templateProgressBar(),{history_name:x});$(this.modal.elMain).find(".modal-body").html(y);var u=100/z.length;this.initProgress(u);var r=[];for(var s=z.length-1;s>=0;s--){library_dataset_id=z[s];var v=new b();var w=this;v.url=v.urlRoot+t+"/contents";v.content=library_dataset_id;v.source="library";r.push(v)}this.chainCall(r)},chainCall:function(s){var r=this;var t=s.pop();if(typeof t==="undefined"){n.success("All datasets imported");this.modal.hideOrDestroy();return}var u=$.when(t.save({content:t.content,source:t.source})).done(function(v){r.updateProgress();responses.push(v);r.chainCall(s)})},initProgress:function(r){this.progress=0;this.progressStep=r},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(r,v){var t=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){t.push(this.parentElement.parentElement.id)}});var s="/api/libraries/datasets/download/"+v;var u={ldda_ids:t};this.processDownload(s,u,"get")},processDownload:function(s,t,u){if(s&&t){t=typeof t=="string"?t:$.param(t);var r="";$.each(t.split("&"),function(){var v=this.split("=");r+='<input type="hidden" name="'+v[0]+'" value="'+v[1]+'" />'});$('<form action="'+s+'" method="'+(u||"post")+'">'+r+"</form>").appendTo("body").submit().remove();n.info("Your download will begin soon")}},createFolderFromModal:function(){event.preventDefault();event.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,bindClosingEvents:true,title:"Create New Folder",body:this.templateNewFolderInModal(),buttons:{Create:function(){r.create_new_folder_event()},Close:function(){r.modal.hideOrDestroy();r.modal=null}}});this.modal.show()},create_new_folder_event:function(){var r=this.serialize_new_folder();if(this.validate_new_folder(r)){var t=new c();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];t.url=t.urlRoot+"/"+current_folder_id;var s=this;t.save(r,{success:function(u){s.modal.hideOrDestroy();n.success("Folder created");s.render({id:current_folder_id})},error:function(){n.error("An error occured :(")}})}else{n.error("Folder's name is missing")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(r){return r.name!==""}});var a=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"show_library_modal"},initialize:function(){},templateLibraryList:function(){tmpl_array=[];tmpl_array.push('<div id="library_container" style="width: 90%; margin: auto; margin-top: 2em; overflow: auto !important; ">');tmpl_array.push("");tmpl_array.push('<h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>');tmpl_array.push('<a href="" id="create_new_library_btn" class="btn btn-primary file ">New Library</a>');tmpl_array.push('<table class="table table-condensed">');tmpl_array.push(" <thead>");tmpl_array.push(' <th class="button_heading"></th>');tmpl_array.push(" <th>name</th>");tmpl_array.push(" <th>description</th>");tmpl_array.push(" <th>synopsis</th> ");tmpl_array.push(" <th>model type</th> ");tmpl_array.push(" </thead>");tmpl_array.push(" <tbody>");tmpl_array.push(" <% _.each(libraries, function(library) { %>");tmpl_array.push(" <tr>");tmpl_array.push(' <td><button title="Open this library" type="button" data-id="<%- library.get("root_folder_id") %>" class="btn_open_folder btn btn-default btn-xs">');tmpl_array.push(' <span class="fa fa-folder-open"></span> browse</td>');tmpl_array.push(' <td><%- library.get("name") %></td>');tmpl_array.push(' <td><%= _.escape(library.get("description")) %></td>');tmpl_array.push(' <td><%= _.escape(library.get("synopsis")) %></td>');tmpl_array.push(' <td><%= _.escape(library.get("model_class")) %></td>');tmpl_array.push(" </tr>");tmpl_array.push(" <% }); %>");tmpl_array.push(" </tbody>");tmpl_array.push("</table>");tmpl_array.push("</div>");return tmpl_array.join("")},templateNewLibraryInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_library_modal">');tmpl_array.push(" <form>");tmpl_array.push(' <input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push(' <input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push(' <input type="text" name="Synopsis" value="" placeholder="Synopsis">');tmpl_array.push(" </form>");tmpl_array.push("</div>");return tmpl_array.join("")},render:function(){$("#center").css("overflow","auto");var r=this;libraries=new o();libraries.fetch({success:function(s){var t=_.template(r.templateLibraryList(),{libraries:s.models});r.$el.html(t)},error:function(t,s){if(s.statusCode().status===403){n.info("Please log in first. Redirecting to login page in 3s.");setTimeout(r.redirectToLogin,3000)}else{n.error("An error occured. Please try again.")}}})},redirectToHome:function(){window.location="../"},redirectToLogin:function(){window.location="/user/login"},modal:null,show_library_modal:function(s){s.preventDefault();s.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,bindClosingEvents:true,title:"Create New Library",body:this.templateNewLibraryInModal(),buttons:{Create:function(){r.create_new_library_event()},Close:function(){r.modal.hideOrDestroy()}}});this.modal.show()},create_new_library_event:function(){var t=this.serialize_new_library();if(this.validate_new_library(t)){var s=new f();var r=this;s.save(t,{success:function(u){r.modal.hideOrDestroy();r.clear_library_modal();r.render();n.success("Library created")},error:function(){n.error("An error occured :(")}})}else{n.error("Library's name is missing")}return false},clear_library_modal:function(){$("input[name='Name']").val("");$("input[name='Description']").val("");$("input[name='Synopsis']").val("")},serialize_new_library:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val(),synopsis:$("input[name='Synopsis']").val()}},validate_new_library:function(r){return r.name!==""}});var g=Backbone.View.extend({folderContentView:null,galaxyLibraryview:null,initialize:function(){folderContentView=new m();galaxyLibraryview=new a();library_router=new q();library_router.on("route:libraries",function(){galaxyLibraryview.render()});library_router.on("route:folder_content",function(r){folderContentView.render({id:r})});library_router.on("route:download",function(r,s){if($("#center").find(":checked").length===0){library_router.navigate("folders/"+r,{trigger:true,replace:true})}else{folderContentView.download(r,s);library_router.navigate("folders/"+r,{trigger:false,replace:true})}});Backbone.history.start({pushState:false})}});return{GalaxyApp:g}}); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/galaxy.masthead.js --- a/static/scripts/packed/galaxy.masthead.js +++ b/static/scripts/packed/galaxy.masthead.js @@ -1,1 +1,1 @@ -define(["utils/galaxy.utils"],function(c){var a=Backbone.View.extend({el_masthead:"#everything",options:null,$background:null,list:[],initialize:function(f){this.options=f;$("body").off();this.setElement($(this._template(f)));$(this.el_masthead).append($(this.el));this.$background=$(this.el).find("#masthead-background");var e=this;window.onbeforeunload=function(){var h="";for(key in e.list){if(e.list[key].options.on_unload){var g=e.list[key].options.on_unload();if(g){h+=g+" "}}}if(h!=""){return h}}},events:{click:"_click",mousedown:function(f){f.preventDefault()}},append:function(e){return this._add(e,true)},prepend:function(e){return this._add(e,false)},highlight:function(f){var e=$(this.el).find("#"+f+"> li");if(e){e.addClass("active")}},_add:function(h,f){var e=$(this.el).find("#"+h.location);if(e){var g=$(h.el);g.addClass("masthead-item");if(f){e.append(g)}else{e.prepend(g)}this.list.push(h)}return null},_click:function(h){var g=$(this.el).find(".popup");if(g){g.hide()}var f=$(h.target).closest(".masthead-item").find(".popup");if($(h.target).hasClass("head")){f.show();this.$background.show()}else{this.$background.hide()}},_template:function(e){return'<div><div id="masthead" class="navbar navbar-fixed-top navbar-inverse"><div style="position: relative; right: -50%; float: left;"><div id="navbar" style="display: block; position: relative; right: 50%;"></div></div><div class="navbar-brand"><a href="'+e.logo_url+'"><img border="0" src="'+galaxy_config.root+'static/images/galaxyIcon_noText.png"><span id="brand"> Galaxy '+e.brand+'</span></a></div><div class="quota-meter-container"></div><div id="iconbar" class="iconbar"></div></div><div id="masthead-background" style="display: none; position: absolute; top: 33px; width: 100%; height: 100%; z-index: 1010"></div></div>'}});var b=Backbone.View.extend({options:{id:"",icon:"fa-cog",tooltip:"",with_number:false,on_click:function(){alert("clicked")},on_unload:null,visible:true},location:"iconbar",initialize:function(f){if(f){this.options=_.defaults(f,this.options)}this.setElement($(this._template(this.options)));var e=this;$(this.el).find(".icon").tooltip({title:this.options.tooltip,placement:"bottom"}).on("mouseup",e.options.on_click);if(!this.options.visible){this.hide()}},show:function(){$(this.el).css({visibility:"visible"})},hide:function(){$(this.el).css({visibility:"hidden"})},icon:function(e){$(this.el).find(".icon").removeClass(this.options.icon).addClass(e);this.options.icon=e},toggle:function(){$(this.el).addClass("toggle")},untoggle:function(){$(this.el).removeClass("toggle")},number:function(e){$(this.el).find(".number").text(e)},_template:function(f){var e='<div id="'+f.id+'" class="symbol"><div class="icon fa fa-2x '+f.icon+'"></div>';if(f.with_number){e+='<div class="number"></div>'}e+="</div>";return e}});var d=Backbone.View.extend({options:{id:"",title:"",target:"_parent",content:"",type:"url",scratchbook:false,on_unload:null,visible:true,disabled:false,title_attribute:""},location:"navbar",$menu:null,events:{"click .head":"_head"},initialize:function(e){if(e){this.options=_.defaults(e,this.options)}if(this.options.content&&this.options.content.indexOf("//")===-1){this.options.content=galaxy_config.root+this.options.content}this.setElement($(this._template(this.options)));if(this.options.disabled){$(this.el).find(".root").addClass("disabled");this._attachPopover()}if(!this.options.visible){this.hide()}},show:function(){$(this.el).css({visibility:"visible"})},hide:function(){$(this.el).css({visibility:"hidden"})},add:function(g){var h={title:"Title",content:"",type:"url",target:"_parent",scratchbook:false,divider:false};if(g){h=_.defaults(g,h)}if(h.content&&h.content.indexOf("//")===-1){h.content=galaxy_config.root+h.content}if(!this.$menu){$(this.el).find(".root").append(this._templateMenu());$(this.el).find(".symbol").addClass("caret");this.$menu=$(this.el).find(".popup")}var f=$(this._templateMenuItem(h));this.$menu.append(f);var e=this;f.on("click",function(i){i.preventDefault();if(e.options.target==="_blank"){return true}Galaxy.frame.add(g)});if(h.divider){this.$menu.append($(this._templateDivider()))}},_head:function(f){f.preventDefault();if(this.options.disabled){return}if(!this.$menu){Galaxy.frame.add(this.options)}},_attachPopover:function(){var e=$(this.el).find(".head");e.popover({html:true,content:'Please <a href="/user/login">log in</a> or <a href="/user/create">register</a> to use this feature.',placement:"bottom"}).on("shown.bs.popover",function(){setTimeout(function(){e.popover("hide")},5000)})},_templateMenuItem:function(e){return'<li><a href="'+e.content+'" target="'+e.target+'">'+e.title+"</a></li>"},_templateMenu:function(){return'<ul class="popup dropdown-menu"></ul>'},_templateDivider:function(){return'<li class="divider"></li>'},_template:function(f){var e='<ul id="'+f.id+'" class="nav navbar-nav" border="0" cellspacing="0"><li class="root dropdown" style=""><a class="head dropdown-toggle" data-toggle="dropdown" target="'+f.target+'" href="'+f.content+'" title="'+f.title_attribute+'">'+f.title+'<b class="symbol"></b></a></li></ul>';return e}});return{GalaxyMasthead:a,GalaxyMastheadTab:d,GalaxyMastheadIcon:b}}); \ No newline at end of file +define([],function(){var a=Backbone.View.extend({el_masthead:"#everything",options:null,$background:null,list:[],initialize:function(e){this.options=e;$("body").off();this.setElement($(this._template(e)));$(this.el_masthead).append($(this.el));this.$background=$(this.el).find("#masthead-background");var d=this;window.onbeforeunload=function(){var g="";for(key in d.list){if(d.list[key].options.on_unload){var f=d.list[key].options.on_unload();if(f){g+=f+" "}}}if(g!=""){return g}}},events:{click:"_click",mousedown:function(d){d.preventDefault()}},append:function(d){return this._add(d,true)},prepend:function(d){return this._add(d,false)},highlight:function(e){var d=$(this.el).find("#"+e+"> li");if(d){d.addClass("active")}},_add:function(g,e){var d=$(this.el).find("#"+g.location);if(d){var f=$(g.el);f.addClass("masthead-item");if(e){d.append(f)}else{d.prepend(f)}this.list.push(g)}return null},_click:function(g){var f=$(this.el).find(".popup");if(f){f.hide()}var d=$(g.target).closest(".masthead-item").find(".popup");if($(g.target).hasClass("head")){d.show();this.$background.show()}else{this.$background.hide()}},_template:function(d){return'<div><div id="masthead" class="navbar navbar-fixed-top navbar-inverse"><div style="position: relative; right: -50%; float: left;"><div id="navbar" style="display: block; position: relative; right: 50%;"></div></div><div class="navbar-brand"><a href="'+d.logo_url+'"><img border="0" src="'+galaxy_config.root+'static/images/galaxyIcon_noText.png"><span id="brand"> Galaxy '+d.brand+'</span></a></div><div class="quota-meter-container"></div><div id="iconbar" class="iconbar"></div></div><div id="masthead-background" style="display: none; position: absolute; top: 33px; width: 100%; height: 100%; z-index: 1010"></div></div>'}});var b=Backbone.View.extend({options:{id:"",icon:"fa-cog",tooltip:"",with_number:false,on_click:function(){alert("clicked")},on_unload:null,visible:true},location:"iconbar",initialize:function(e){if(e){this.options=_.defaults(e,this.options)}this.setElement($(this._template(this.options)));var d=this;$(this.el).find(".icon").tooltip({title:this.options.tooltip,placement:"bottom"}).on("mouseup",d.options.on_click);if(!this.options.visible){this.hide()}},show:function(){$(this.el).css({visibility:"visible"})},hide:function(){$(this.el).css({visibility:"hidden"})},icon:function(d){$(this.el).find(".icon").removeClass(this.options.icon).addClass(d);this.options.icon=d},toggle:function(){$(this.el).addClass("toggle")},untoggle:function(){$(this.el).removeClass("toggle")},number:function(d){$(this.el).find(".number").text(d)},_template:function(e){var d='<div id="'+e.id+'" class="symbol"><div class="icon fa fa-2x '+e.icon+'"></div>';if(e.with_number){d+='<div class="number"></div>'}d+="</div>";return d}});var c=Backbone.View.extend({options:{id:"",title:"",target:"_parent",content:"",type:"url",scratchbook:false,on_unload:null,visible:true,disabled:false,title_attribute:""},location:"navbar",$menu:null,events:{"click .head":"_head"},initialize:function(d){if(d){this.options=_.defaults(d,this.options)}if(this.options.content&&this.options.content.indexOf("//")===-1){this.options.content=galaxy_config.root+this.options.content}this.setElement($(this._template(this.options)));if(this.options.disabled){$(this.el).find(".root").addClass("disabled");this._attachPopover()}if(!this.options.visible){this.hide()}},show:function(){$(this.el).css({visibility:"visible"})},hide:function(){$(this.el).css({visibility:"hidden"})},add:function(f){var g={title:"Title",content:"",type:"url",target:"_parent",scratchbook:false,divider:false};if(f){g=_.defaults(f,g)}if(g.content&&g.content.indexOf("//")===-1){g.content=galaxy_config.root+g.content}if(!this.$menu){$(this.el).find(".root").append(this._templateMenu());$(this.el).find(".symbol").addClass("caret");this.$menu=$(this.el).find(".popup")}var e=$(this._templateMenuItem(g));this.$menu.append(e);var d=this;e.on("click",function(h){h.preventDefault();if(d.options.target==="_blank"){return true}Galaxy.frame.add(f)});if(g.divider){this.$menu.append($(this._templateDivider()))}},_head:function(d){d.preventDefault();if(this.options.disabled){return}if(!this.$menu){Galaxy.frame.add(this.options)}},_attachPopover:function(){var d=$(this.el).find(".head");d.popover({html:true,content:'Please <a href="/user/login">log in</a> or <a href="/user/create">register</a> to use this feature.',placement:"bottom"}).on("shown.bs.popover",function(){setTimeout(function(){d.popover("hide")},5000)})},_templateMenuItem:function(d){return'<li><a href="'+d.content+'" target="'+d.target+'">'+d.title+"</a></li>"},_templateMenu:function(){return'<ul class="popup dropdown-menu"></ul>'},_templateDivider:function(){return'<li class="divider"></li>'},_template:function(e){var d='<ul id="'+e.id+'" class="nav navbar-nav" border="0" cellspacing="0"><li class="root dropdown" style=""><a class="head dropdown-toggle" data-toggle="dropdown" target="'+e.target+'" href="'+e.content+'" title="'+e.title_attribute+'">'+e.title+'<b class="symbol"></b></a></li></ul>';return d}});return{GalaxyMasthead:a,GalaxyMastheadTab:c,GalaxyMastheadIcon:b}}); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/galaxy.upload.js --- a/static/scripts/packed/galaxy.upload.js +++ /dev/null @@ -1,1 +0,0 @@ -define(["galaxy.modal","galaxy.masthead","utils/galaxy.utils","utils/galaxy.uploadbox"],function(b,c,d){var a=Backbone.View.extend({modal:null,button_show:null,uploadbox:null,current_history:null,select_extension:[["Auto-detect","auto"]],select_genome:[["Unspecified (?)","?"]],state:{init:"fa fa-trash-o",queued:"fa fa-spinner fa-spin",running:"__running__",success:"fa fa-check",error:"fa fa-exclamation-triangle"},counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},options:{nginx_upload_path:""},initialize:function(f){if(!Galaxy.currHistoryPanel){var e=this;window.setTimeout(function(){e.initialize()},500);return}if(!Galaxy.currUser.get("id")){return}var e=this;this.button_show=new c.GalaxyMastheadIcon({icon:"fa-arrow-circle-o-up",tooltip:"Upload Files",on_click:function(g){e.event_show(g)},on_unload:function(){if(e.counter.running>0){return"Several uploads are still processing."}},with_number:true});Galaxy.masthead.prepend(this.button_show);var e=this;d.jsonFromUrl(galaxy_config.root+"api/datatypes",function(g){for(key in g){e.select_extension.push([g[key],g[key]])}});d.jsonFromUrl(galaxy_config.root+"api/genomes",function(g){var h=e.select_genome[0];e.select_genome=[];for(key in g){if(g[key].length>1){if(g[key][1]!==h[1]){e.select_genome.push(g[key])}}}e.select_genome.sort(function(j,i){return j[0]>i[0]?1:j[0]<i[0]?-1:0});e.select_genome.unshift(h)});if(f){this.options=_.defaults(f,this.options)}},event_dragover:function(f){},event_dragleave:function(f){},event_announce:function(i,g,n){var f="#upload-"+i;$(this.el).find("tbody:last").append(this.template_row(f));var h=this.get_upload_item(i);h.fadeIn();h.find("#title").html(g.name);h.find("#size").html(this.size_to_string(g.size));var m=this;h.find("#symbol").on("click",function(){m.event_remove(i)});h.find("#text-content").on("keyup",function(){var o=h.find("#text-content").val().length;h.find("#size").html(m.size_to_string(o))});var m=this;h.find("#genome").on("change",function(q){var p=$(q.target).val();var o=$(m.el).find(".upload-item");o.each(function(){var s=$(this).find("#symbol");var r=$(this).find("#genome");if(s.hasClass(m.state.init)&&r.val()=="?"){r.val(p)}})});this.event_progress(i,g,0);this.counter.announce++;this.update_screen();if(g.size==-1){var l=h.find("#text");var j=8;var e=h.width()-2*j;var k=h.height()-j;l.css("width",e+"px");l.css("top",k+"px");h.height(k+l.height()+2*j);l.show()}},event_initialize:function(i,e,m){this.button_show.number(this.counter.announce);var g=this.get_upload_item(i);var j=g.find("#symbol");j.addClass(this.state.running);var f=g.find("#extension").val();var l=g.find("#genome").val();var k=g.find("#text-content").val();var h=g.find("#space_to_tabs").is(":checked");if(!k&&!(e.size>0)){return null}this.uploadbox.configure({url:this.options.nginx_upload_path,paramname:"files_0|file_data"});tool_input={};tool_input.dbkey=l;tool_input.file_type=f;tool_input["files_0|NAME"]=e.name;tool_input["files_0|type"]="upload_dataset";tool_input["files_0|url_paste"]=k;tool_input.space_to_tabs=h;data={};data.history_id=this.current_history;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},event_progress:function(f,g,i){var h=this.get_upload_item(f);var e=parseInt(i);h.find(".progress-bar").css({width:e+"%"});if(e!=100){h.find("#percentage").html(e+"%")}else{h.find("#percentage").html("Adding to history...")}},event_success:function(e,f,h){this.event_progress(e,f,100);this.button_show.number("");this.counter.announce--;this.counter.success++;this.update_screen();var g=this.get_upload_item(e);g.addClass("success");g.find("#percentage").html("100%");var i=g.find("#symbol");i.removeClass(this.state.running);i.removeClass(this.state.queued);i.addClass(this.state.success);Galaxy.currHistoryPanel.refreshHdas()},event_error:function(e,f,h){this.event_progress(e,f,0);this.button_show.number("");this.counter.announce--;this.counter.error++;this.update_screen();var g=this.get_upload_item(e);g.addClass("danger");g.find(".progress").remove();g.find("#info").html("<strong>Failed: </strong>"+h).show();var i=g.find("#symbol");i.removeClass(this.state.running);i.removeClass(this.state.queued);i.addClass(this.state.error)},event_start:function(){if(this.counter.announce==0||this.counter.running>0){return}var f=$(this.el).find(".upload-item");var e=this;f.each(function(){var g=$(this).find("#symbol");if(g.hasClass(e.state.init)){g.removeClass(e.state.init);g.addClass(e.state.queued);$(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)}});this.current_history=Galaxy.currHistoryPanel.model.get("id");this.counter.running=this.counter.announce;this.update_screen();this.uploadbox.start()},event_stop:function(){if(this.counter.running==0){return}this.uploadbox.stop();$("#upload-info").html("Queue will pause after completing the current file...")},event_complete:function(){this.counter.running=0;this.update_screen();var f=$(this.el).find(".upload-item");var e=this;f.each(function(){var g=$(this).find("#symbol");if(g.hasClass(e.state.queued)&&!g.hasClass(e.state.running)){g.removeClass(e.state.queued);g.addClass(e.state.init);$(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)}})},event_reset:function(){if(this.counter.running==0){var e=$(this.el).find(".upload-item");$(this.el).find("table").fadeOut({complete:function(){e.remove()}});this.counter.reset();this.update_screen();this.uploadbox.reset()}},event_remove:function(e){var f=this.get_upload_item(e);var g=f.find("#symbol");if(g.hasClass(this.state.init)||g.hasClass(this.state.success)||g.hasClass(this.state.error)){if(f.hasClass("success")){this.counter.success--}else{if(f.hasClass("danger")){this.counter.error--}else{this.counter.announce--}}this.update_screen();this.uploadbox.remove(e);f.remove()}},event_create:function(){this.uploadbox.add([{name:"New File",size:-1}])},event_show:function(g){g.preventDefault();if(!this.modal){var f=this;this.modal=new b.GalaxyModal({title:"Upload files from your local drive",body:this.template("upload-box","upload-info"),buttons:{Select:function(){f.uploadbox.select()},Create:function(){f.event_create()},Upload:function(){f.event_start()},Pause:function(){f.event_stop()},Reset:function(){f.event_reset()},Close:function(){f.modal.hide()},},height:"400",width:"900"});this.setElement("#upload-box");var f=this;this.uploadbox=this.$el.uploadbox({dragover:function(){f.event_dragover()},dragleave:function(){f.event_dragleave()},announce:function(e,h,i){f.event_announce(e,h,i)},initialize:function(e,h,i){return f.event_initialize(e,h,i)},success:function(e,h,i){f.event_success(e,h,i)},progress:function(e,h,i){f.event_progress(e,h,i)},error:function(e,h,i){f.event_error(e,h,i)},complete:function(){f.event_complete()},});this.update_screen()}this.modal.show()},get_upload_item:function(e){return $(this.el).find("#upload-"+e)},size_to_string:function(e){var f="";if(e>=100000000000){e=e/100000000000;f="TB"}else{if(e>=100000000){e=e/100000000;f="GB"}else{if(e>=100000){e=e/100000;f="MB"}else{if(e>=100){e=e/100;f="KB"}else{if(e>0){e=e*10;f="b"}else{return"<strong>-</strong>"}}}}}return"<strong>"+(Math.round(e)/10)+"</strong> "+f},update_screen:function(){if(this.counter.announce==0){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+."}}else{if(this.counter.running==0){message="You added "+this.counter.announce+" file(s) to the queue. Add more files or click 'Upload' to proceed."}else{message="Please wait..."+this.counter.announce+" out of "+this.counter.running+" remaining."}}$("#upload-info").html(message);if(this.counter.running==0&&this.counter.announce+this.counter.success+this.counter.error>0){this.modal.enableButton("Reset")}else{this.modal.disableButton("Reset")}if(this.counter.running==0&&this.counter.announce>0){this.modal.enableButton("Upload")}else{this.modal.disableButton("Upload")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Select");this.modal.enableButton("Create")}else{this.modal.disableButton("Select");this.modal.disableButton("Create")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("table").show()}else{$(this.el).find("table").hide()}},template:function(f,e){return'<div id="'+f+'" class="upload-box"><table class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Genome</th><th>Space→Tab</th><th>Status</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+e+'" class="upload-info"></h6>'},template_row:function(f){var e='<tr id="'+f.substr(1)+'" class="upload-item"><td><div 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></div></td><td><div id="size" class="size"></div></td>';e+='<td><select id="extension" class="extension">';for(key in this.select_extension){e+='<option value="'+this.select_extension[key][1]+'">'+this.select_extension[key][0]+"</option>"}e+="</select></td>";e+='<td><select id="genome" class="genome">';for(key in this.select_genome){e+='<option value="'+this.select_genome[key][1]+'">'+this.select_genome[key][0]+"</option>"}e+="</select></td>";e+='<td><input id="space_to_tabs" type="checkbox"></input></td><td><div id="info" class="info"><div class="progress"><div class="progress-bar progress-bar-success"></div><div id="percentage" class="percentage">0%</div></div></div></td><td><div id="symbol" class="symbol '+this.state.init+'"></div></td></tr>';return e}});return{GalaxyUpload:a}}); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/mvc/upload/upload-model.js --- /dev/null +++ b/static/scripts/packed/mvc/upload/upload-model.js @@ -0,0 +1,1 @@ +define([],function(){var b=Backbone.Model.extend({defaults:{extension:"auto",genome:"?",url_paste:"",space_to_tabs:false,status:"init",info:null}});var a=Backbone.Collection.extend({model:b});return{Model:b,Collection:a}}); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/mvc/upload/upload-row.js --- /dev/null +++ b/static/scripts/packed/mvc/upload/upload-row.js @@ -0,0 +1,1 @@ +define(["mvc/upload/upload-model"],function(a){return Backbone.View.extend({options:{padding:8},status_classes:{init:"symbol fa fa-trash-o",queued:"symbol fa fa-spinner fa-spin",success:"symbol fa fa-check",error:"symbol fa fa-exclamation-triangle"},initialize:function(e,c){this.app=e;var b=this;this.model=new a.Model(c);this.setElement(this._template(c));var d=this.$el;d.find("#symbol").on("click",function(){var f=b.model.get("status");if(f=="init"||f=="success"||f=="error"){b.app.collection.remove(b.model)}});d.find("#text-content").on("keyup",function(){var f=d.find("#text-content");var h=f.val();var g=h.length;d.find("#size").html(b._formatSize(g));b.model.set("url_paste",h)});d.find("#genome").on("change",function(f){b.model.set("genome",$(f.target).val())});d.find("#extension").on("change",function(f){b.model.set("extension",$(f.target).val())});d.find("#space_to_tabs").on("change",function(f){b.model.set("space_to_tabs",$(f.target).prop("checked"))});this.model.on("change:percentage",function(){b._refreshPercentage()});this.model.on("change:status",function(){b._refreshStatus()});this.model.on("change:info",function(){b._refreshInfo()});this.model.on("remove",function(){b.remove()});this.app.collection.on("reset",function(){b.remove()})},render:function(){var h=this.model.get("file_name");var c=this.model.get("file_size");var e=this.$el;e.find("#title").html(h);e.find("#size").html(this._formatSize(c));if(c==-1){var g=e.find("#text");var f=this.options.padding;var d=e.width()-2*f;var b=e.height()-f;g.css("width",d+"px");g.css("top",b+"px");e.height(b+g.height()+2*f);g.show()}},_refreshInfo:function(){var b=this.model.get("info");if(b){this.$el.find("#info").html("<strong>Failed: </strong>"+b).show()}else{this.$el.find("#info").hide()}},_refreshPercentage:function(){var b=parseInt(this.model.get("percentage"));this.$el.find(".progress-bar").css({width:b+"%"});if(b!=100){this.$el.find("#percentage").html(b+"%")}else{this.$el.find("#percentage").html("Adding to history...")}},_refreshStatus:function(){var c=this.$el;var b=this.model.get("status");var e=this.status_classes[b];var d=this.$el.find("#symbol");d.removeClass();d.addClass(e);if(b=="init"){c.find("#text-content").attr("disabled",false);c.find("#genome").attr("disabled",false);c.find("#extension").attr("disabled",false);c.find("#space_to_tabs").attr("disabled",false)}else{c.find("#text-content").attr("disabled",true);c.find("#genome").attr("disabled",true);c.find("#extension").attr("disabled",true);c.find("#space_to_tabs").attr("disabled",true)}if(b=="success"){c.addClass("success");c.find("#percentage").html("100%")}if(b=="error"){c.addClass("danger");c.find(".progress").remove()}},_formatSize:function(b){var c="";if(b>=100000000000){b=b/100000000000;c="TB"}else{if(b>=100000000){b=b/100000000;c="GB"}else{if(b>=100000){b=b/100000;c="MB"}else{if(b>=100){b=b/100;c="KB"}else{if(b>0){b=b*10;c="b"}else{return"<strong>-</strong>"}}}}}return"<strong>"+(Math.round(b)/10)+"</strong> "+c},_template:function(d){var c=this;var b='<tr id="upload-item-'+d.id+'" class="upload-item"><td><div 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></div></td><td><div id="size" class="size"></div></td>';b+='<td><select id="extension" class="extension">';for(key in c.app.select_extension){b+='<option value="'+c.app.select_extension[key][1]+'">'+c.app.select_extension[key][0]+"</option>"}b+="</select></td>";b+='<td><select id="genome" class="genome">';for(key in c.app.select_genome){b+='<option value="'+c.app.select_genome[key][1]+'">'+c.app.select_genome[key][0]+"</option>"}b+="</select></td>";b+='<td><input id="space_to_tabs" type="checkbox"></input></td><td><div id="info" class="info"><div class="progress"><div class="progress-bar progress-bar-success"></div><div id="percentage" class="percentage">0%</div></div></div></td><td><div id="symbol" class="'+this.status_classes.init+'"></div></td></tr>';return b}})}); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/mvc/upload/upload-view.js --- /dev/null +++ b/static/scripts/packed/mvc/upload/upload-view.js @@ -0,0 +1,1 @@ +define(["galaxy.modal","galaxy.masthead","utils/utils","mvc/upload/upload-model","mvc/upload/upload-row","utils/uploadbox"],function(a,d,e,c,b){return Backbone.View.extend({modal:null,button_show:null,uploadbox:null,current_history:null,select_extension:[["Auto-detect","auto"]],select_genome:[["Unspecified (?)","?"]],collection:new c.Collection(),counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},options:{nginx_upload_path:""},initialize:function(g){var f=this;if(!Galaxy.currHistoryPanel){window.setTimeout(function(){f.initialize()},500);return}if(!Galaxy.currUser.get("id")){return}this.button_show=new d.GalaxyMastheadIcon({icon:"fa-arrow-circle-o-up",tooltip:"Upload Files",on_click:function(h){f._eventShow(h)},on_unload:function(){if(f.counter.running>0){return"Several uploads are still processing."}},with_number:true});Galaxy.masthead.prepend(this.button_show);var f=this;e.jsonFromUrl(galaxy_config.root+"api/datatypes",function(h){for(key in h){f.select_extension.push([h[key],h[key]])}});e.jsonFromUrl(galaxy_config.root+"api/genomes",function(h){var i=f.select_genome[0];f.select_genome=[];for(key in h){if(h[key].length>1){if(h[key][1]!==i[1]){f.select_genome.push(h[key])}}}f.select_genome.sort(function(k,j){return k[0]>j[0]?1:k[0]<j[0]?-1:0});f.select_genome.unshift(i)});if(g){this.options=_.defaults(g,this.options)}this.collection.on("remove",function(h){f._eventRemove(h)});this.collection.on("change",function(h){console.log("here")})},_eventShow:function(g){g.preventDefault();if(!this.modal){var f=this;this.modal=new a.GalaxyModal({title:"Upload files from your local drive",body:this._template("upload-box","upload-info"),buttons:{Select:function(){f.uploadbox.select()},Create:function(){f._eventCreate()},Upload:function(){f._eventStart()},Pause:function(){f._eventStop()},Reset:function(){f._eventReset()},Close:function(){f.modal.hide()},},height:"400",width:"900"});this.setElement("#upload-box");var f=this;this.uploadbox=this.$el.uploadbox({announce:function(h,i,j){f._eventAnnounce(h,i,j)},initialize:function(h,i,j){return f._eventInitialize(h,i,j)},progress:function(h,i,j){f._eventProgress(h,i,j)},success:function(h,i,j){f._eventSuccess(h,i,j)},error:function(h,i,j){f._eventError(h,i,j)},complete:function(){f._eventComplete()}});this._updateScreen()}this.modal.show()},_eventRemove:function(g){var f=g.get("status");if(f=="success"){this.counter.success--}else{if(f=="error"){this.counter.error--}else{this.counter.announce--}}this._updateScreen();this.uploadbox.remove(g.id)},_eventAnnounce:function(f,g,i){this.counter.announce++;this._updateScreen();var h=new b(this,{id:f,file_name:g.name,file_size:g.size});this.collection.add(h.model);$(this.el).find("tbody:last").append(h.$el);h.render()},_eventInitialize:function(j,f,n){var h=this.collection.get(j);h.set("state","running");this.button_show.number(this.counter.announce);var g=h.get("extension");var k=h.get("file_name");var m=h.get("genome");var l=h.get("url_paste");var i=h.get("space_to_tabs");if(!l&&!(f.size>0)){return null}this.uploadbox.configure({url:this.options.nginx_upload_path,paramname:"files_0|file_data"});tool_input={};tool_input.dbkey=m;tool_input.file_type=g;tool_input["files_0|NAME"]=k;tool_input["files_0|type"]="upload_dataset";tool_input["files_0|url_paste"]=l;tool_input.space_to_tabs=i;data={};data.history_id=this.current_history;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},_eventProgress:function(g,h,f){var i=this.collection.get(g);i.set("percentage",f)},_eventSuccess:function(f,g,i){var h=this.collection.get(f);h.set("status","success");this.button_show.number("");this.counter.announce--;this.counter.success++;this._updateScreen();Galaxy.currHistoryPanel.refreshHdas()},_eventError:function(f,g,i){var h=this.collection.get(f);h.set("status","error");h.set("info",i);this.button_show.number("");this.counter.announce--;this.counter.error++;this._updateScreen()},_eventComplete:function(){this.collection.each(function(f){if(f.get("status")=="queued"){f.set("status","init")}});this.counter.running=0;this._updateScreen()},_eventCreate:function(){this.uploadbox.add([{name:"New File",size:-1}])},_eventStart:function(){if(this.counter.announce==0||this.counter.running>0){return}this.collection.each(function(f){if(f.get("status")=="init"){f.set("status","queued")}});this.current_history=Galaxy.currHistoryPanel.model.get("id");this.counter.running=this.counter.announce;this._updateScreen();this.uploadbox.start()},_eventStop:function(){if(this.counter.running==0){return}this.uploadbox.stop();$("#upload-info").html("Queue will pause after completing the current file...")},_eventReset:function(){if(this.counter.running==0){this.collection.reset();this.counter.reset();this._updateScreen();this.uploadbox.reset()}},_updateScreen:function(){if(this.counter.announce==0){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+."}}else{if(this.counter.running==0){message="You added "+this.counter.announce+" file(s) to the queue. Add more files or click 'Upload' to proceed."}else{message="Please wait..."+this.counter.announce+" out of "+this.counter.running+" remaining."}}$("#upload-info").html(message);if(this.counter.running==0&&this.counter.announce+this.counter.success+this.counter.error>0){this.modal.enableButton("Reset")}else{this.modal.disableButton("Reset")}if(this.counter.running==0&&this.counter.announce>0){this.modal.enableButton("Upload")}else{this.modal.disableButton("Upload")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Select");this.modal.enableButton("Create")}else{this.modal.disableButton("Select");this.modal.disableButton("Create")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("table").show()}else{$(this.el).find("table").hide()}},_template:function(g,f){return'<div id="'+g+'" class="upload-box"><table class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Genome</th><th>Space→Tab</th><th>Status</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+f+'" class="upload-info"></h6>'}})}); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/utils/galaxy.uploadbox.js --- a/static/scripts/packed/utils/galaxy.uploadbox.js +++ /dev/null @@ -1,1 +0,0 @@ -(function(c){jQuery.event.props.push("dataTransfer");var h={url:"",paramname:"content",maxfilesize:2048,maxfilenumber:20,dragover:function(){},dragleave:function(){},announce:function(){},initialize:function(){},progress:function(){},success:function(){},error:function(k,l,m){alert(m)},complete:function(){},error_filesize:"File exceeds 2GB. Please use an FTP client.",error_default:"Please make sure the file is available.",error_server:"Upload request failed.",error_login:"Uploads require you to log in.",error_missing:"No upload content available."};var a={};var e={};var f=0;var j=0;var d=false;var g=false;var b=null;var i=null;c.fn.uploadbox=function(A){a=c.extend({},h,A);b=this;b.append('<input id="uploadbox_input" type="file" style="display: none" multiple>');b.on("drop",o);b.on("dragover",p);b.on("dragleave",x);c("#uploadbox_input").change(function(B){z(B.target.files);c(this).val("")});function o(B){if(!B.dataTransfer){return}z(B.dataTransfer.files);B.preventDefault();return false}function p(B){B.preventDefault();a.dragover.call(B)}function x(B){B.stopPropagation();a.dragleave.call(B)}function k(B){if(B.lengthComputable){a.progress(this.index,this.file,Math.round((B.loaded*100)/B.total))}}function z(D){if(d){return}for(var C=0;C<D.length;C++){if(j>=a.maxfilenumber){break}var B=String(f++);e[B]=D[C];a.announce(B,e[B],"");j++}}function r(B){if(e[B]){delete e[B];j--}}function m(){if(j==0||g){g=false;d=false;a.complete();return}else{d=true}var D=-1;for(var F in e){D=F;break}var E=e[D];r(D);var C=E.size;var B=1048576*a.maxfilesize;if(C<B){var G=a.initialize(D,E);if(G){q(D,E,G)}else{u(D,E,a.error_missing)}}else{u(D,E,a.error_filesize)}}function q(B,D,E){var F=new FormData();for(var C in E){F.append(C,E[C])}if(D.size>0){F.append(a.paramname,D,D.name)}i=new XMLHttpRequest();i.open("POST",a.url,true);i.setRequestHeader("Accept","application/json");i.setRequestHeader("Cache-Control","no-cache");i.setRequestHeader("X-Requested-With","XMLHttpRequest");i.onreadystatechange=function(){if(i.readyState!=i.DONE){return}var G=null;if(i.responseText){try{G=jQuery.parseJSON(i.responseText)}catch(H){G=i.responseText}}if(i.status<200||i.status>299){var I=i.statusText;if(i.status==403){I=a.error_login}else{if(i.status==0){I=a.error_server}else{if(!I){I=a.error_default}}}u(B,D,I+" ("+i.status+")")}else{y(B,D,G)}};i.upload.index=B;i.upload.file=D;i.upload.addEventListener("progress",k,false);i.send(F)}function y(B,C,D){a.success(B,C,D);m()}function u(B,C,D){a.error(B,C,D);m()}function w(){c("#uploadbox_input").trigger("click")}function t(B){for(B in e){r(B)}}function l(){if(!d){d=true;m()}}function v(){g=true}function n(B){a=c.extend({},a,B);return a}function s(){return window.File&&window.FormData&&window.XMLHttpRequest&&window.FileList}return{select:w,add:z,remove:r,start:l,stop:v,reset:t,configure:n,compatible:s}}})(jQuery); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/utils/galaxy.utils.js --- a/static/scripts/packed/utils/galaxy.utils.js +++ /dev/null @@ -1,1 +0,0 @@ -define(["libs/underscore"],function(c){function d(g,f,e){var h=new XMLHttpRequest();h.open("GET",g,true);h.setRequestHeader("Accept","application/json");h.setRequestHeader("Cache-Control","no-cache");h.setRequestHeader("X-Requested-With","XMLHttpRequest");h.onloadend=function(){var i=h.status;if(i==200){try{response=jQuery.parseJSON(h.responseText)}catch(j){response=h.responseText}f&&f(response)}else{e&&e(i)}};h.send()}function b(h,e){var f=$('<div class="'+h+'"></div>');f.appendTo(":eq(0)");var g=f.css(e);f.remove();return g}function a(e){if(!$('link[href^="'+e+'"]').length){$('<link href="'+galaxy_config.root+e+'" rel="stylesheet">').appendTo("head")}}return{cssLoadFile:a,cssGetAttribute:b,jsonFromUrl:d}}); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/utils/uploadbox.js --- /dev/null +++ b/static/scripts/packed/utils/uploadbox.js @@ -0,0 +1,1 @@ +(function(c){jQuery.event.props.push("dataTransfer");var h={url:"",paramname:"content",maxfilesize:2048,maxfilenumber:20,dragover:function(){},dragleave:function(){},announce:function(){},initialize:function(){},progress:function(){},success:function(){},error:function(k,l,m){alert(m)},complete:function(){},error_filesize:"File exceeds 2GB. Please use an FTP client.",error_default:"Please make sure the file is available.",error_server:"Upload request failed.",error_login:"Uploads require you to log in.",error_missing:"No upload content available."};var a={};var e={};var f=0;var j=0;var d=false;var g=false;var b=null;var i=null;c.fn.uploadbox=function(A){a=c.extend({},h,A);b=this;b.append('<input id="uploadbox_input" type="file" style="display: none" multiple>');b.on("drop",o);b.on("dragover",p);b.on("dragleave",x);c("#uploadbox_input").change(function(B){z(B.target.files);c(this).val("")});function o(B){if(!B.dataTransfer){return}z(B.dataTransfer.files);B.preventDefault();return false}function p(B){B.preventDefault();a.dragover.call(B)}function x(B){B.stopPropagation();a.dragleave.call(B)}function k(B){if(B.lengthComputable){a.progress(this.index,this.file,Math.round((B.loaded*100)/B.total))}}function z(D){if(d){return}for(var C=0;C<D.length;C++){if(j>=a.maxfilenumber){break}var B=String(f++);e[B]=D[C];a.announce(B,e[B],"");j++}}function r(B){if(e[B]){delete e[B];j--}}function m(){if(j==0||g){g=false;d=false;a.complete();return}else{d=true}var D=-1;for(var F in e){D=F;break}var E=e[D];r(D);var C=E.size;var B=1048576*a.maxfilesize;if(C<B){var G=a.initialize(D,E);if(G){q(D,E,G)}else{u(D,E,a.error_missing)}}else{u(D,E,a.error_filesize)}}function q(B,D,E){var F=new FormData();for(var C in E){F.append(C,E[C])}if(D.size>0){F.append(a.paramname,D,D.name)}i=new XMLHttpRequest();i.open("POST",a.url,true);i.setRequestHeader("Accept","application/json");i.setRequestHeader("Cache-Control","no-cache");i.setRequestHeader("X-Requested-With","XMLHttpRequest");i.onreadystatechange=function(){if(i.readyState!=i.DONE){return}var G=null;if(i.responseText){try{G=jQuery.parseJSON(i.responseText)}catch(H){G=i.responseText}}if(i.status<200||i.status>299){var I=i.statusText;if(i.status==403){I=a.error_login}else{if(i.status==0){I=a.error_server}else{if(!I){I=a.error_default}}}u(B,D,I+" ("+i.status+")")}else{y(B,D,G)}};i.upload.index=B;i.upload.file=D;i.upload.addEventListener("progress",k,false);i.send(F)}function y(B,C,D){a.success(B,C,D);m()}function u(B,C,D){a.error(B,C,D);m()}function w(){c("#uploadbox_input").trigger("click")}function t(B){for(B in e){r(B)}}function l(){if(!d){d=true;m()}}function v(){g=true}function n(B){a=c.extend({},a,B);return a}function s(){return window.File&&window.FormData&&window.XMLHttpRequest&&window.FileList}return{select:w,add:z,remove:r,start:l,stop:v,reset:t,configure:n,compatible:s}}})(jQuery); \ No newline at end of file diff -r 315dc0e1cb4889e477fd820b6455d4146ad1958d -r be283631c6120086adfe98ba6e46513e119a443a static/scripts/packed/utils/utils.js --- /dev/null +++ b/static/scripts/packed/utils/utils.js @@ -0,0 +1,1 @@ +define(["libs/underscore"],function(c){function d(g,f,e){var h=new XMLHttpRequest();h.open("GET",g,true);h.setRequestHeader("Accept","application/json");h.setRequestHeader("Cache-Control","no-cache");h.setRequestHeader("X-Requested-With","XMLHttpRequest");h.onloadend=function(){var i=h.status;if(i==200){try{response=jQuery.parseJSON(h.responseText)}catch(j){response=h.responseText}f&&f(response)}else{e&&e(i)}};h.send()}function b(h,e){var f=$('<div class="'+h+'"></div>');f.appendTo(":eq(0)");var g=f.css(e);f.remove();return g}function a(e){if(!$('link[href^="'+e+'"]').length){$('<link href="'+galaxy_config.root+e+'" rel="stylesheet">').appendTo("head")}}return{cssLoadFile:a,cssGetAttribute:b,jsonFromUrl:d}}); \ No newline at end of file This diff is so big that we needed to truncate the remainder. 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.
participants (1)
-
commits-noreply@bitbucket.org