1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d8fcf33cbe4a/ Changeset: d8fcf33cbe4a User: guerler Date: 2014-02-08 00:47:25 Summary: Upload: Add ftp support, separate modules, Ui: Add popovers, Grids: Fix search icon Affected #: 31 files
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 lib/galaxy/webapps/galaxy/api/ftp_files.py --- /dev/null +++ b/lib/galaxy/webapps/galaxy/api/ftp_files.py @@ -0,0 +1,52 @@ +""" +API operations on ftp files. +""" +import logging +from galaxy.web.base.controller import BaseAPIController, url_for +from galaxy import web +import os.path +import os +import time +from operator import itemgetter + +log = logging.getLogger( __name__ ) + +class FTPFilesAPIController( BaseAPIController ): + @web.expose_api + def index( self, trans, **kwd ): + """ + GET /api/ftp_files/ + Displays local files. + """ + # initialize response + response = [] + + # identify ftp directory + user_ftp_base_dir = trans.app.config.ftp_upload_dir + if user_ftp_base_dir is None: + return [] + + # identify user sub directory + user_ftp_dir = None + if user_ftp_base_dir is not None and trans is not None and trans.user is not None: + identifier = trans.app.config.ftp_upload_dir_identifier + user_ftp_dir = os.path.join( user_ftp_base_dir, getattr(trans.user, identifier) ) + if user_ftp_dir is None: + return [] + + # read directory + if os.path.exists( user_ftp_dir ): + for ( dirpath, dirnames, filenames ) in os.walk( user_ftp_dir ): + for filename in filenames: + path = os.path.relpath( os.path.join( dirpath, filename ), user_ftp_dir ) + statinfo = os.lstat( os.path.join( dirpath, filename ) ) + response.append( dict( path = path, + size = statinfo.st_size, + ctime = time.strftime( "%m/%d/%Y %I:%M:%S %p", time.localtime( statinfo.st_ctime ) ) ) ) + + # sort by path + response = sorted(response, key=itemgetter("path")) + + # return + return response +
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -127,6 +127,7 @@ webapp.mapper.resource( 'form', 'forms', path_prefix='/api' ) webapp.mapper.resource( 'request_type', 'request_types', path_prefix='/api' ) webapp.mapper.resource( 'role', 'roles', path_prefix='/api' ) + webapp.mapper.resource( 'ftp_file', 'ftp_files', path_prefix='/api' ) webapp.mapper.resource( 'group', 'groups', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'quota', 'quotas', path_prefix='/api' ) webapp.mapper.connect( '/api/tools/{id:.+?}', action='show', controller="tools" )
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/galaxy.modal.js --- a/static/scripts/galaxy.modal.js +++ b/static/scripts/galaxy.modal.js @@ -86,6 +86,12 @@ this.$buttons.find('#' + button_id).hide(); },
+ // get button + getButton: function(name) { + var button_id = this.buttonList[name]; + return this.$buttons.find('#' + button_id); + }, + // returns scroll top for body element scrollTop: function() { return this.$body.scrollTop(); @@ -175,7 +181,7 @@ '<button type="button" class="close" style="display: none;">×</button>' + '<h4 class="title">' + title + '</h4>' + '</div>' + - '<div class="modal-body"></div>' + + '<div class="modal-body" style="position: static;"></div>' + '<div class="modal-footer">' + '<div class="buttons" style="float: right;"></div>' + '</div>' +
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/mvc/grid/grid-template.js --- a/static/scripts/mvc/grid/grid-template.js +++ b/static/scripts/mvc/grid/grid-template.js @@ -556,7 +556,7 @@ tmpl += '<span class="search-box">' + '<input class="search-box-input" id="input-' + column_key + '-filter" name="f-' + column_key + '" type="text" placeholder="' + value + '" size="' + size + '"/>' + '<button type="submit" style="background: transparent; border: none; padding: 4px; margin: 0px;">' + - '<i class="fa fa-plus-circle"></i>' + + '<i class="fa fa-search"></i>' + '</button>' + '</span>' + '</form>';
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/mvc/ui.popover.js --- /dev/null +++ b/static/scripts/mvc/ui.popover.js @@ -0,0 +1,169 @@ +// dependencies +define(['utils/utils'], function(Utils) { + +var View = Backbone.View.extend({ + + // default options + optionsDefault: { + with_close : true, + container : 'body', + title : null, + placement : 'top' + }, + + // visibility flag + visible: false, + + // initialize + initialize: function (options) { + + // link this + var self = this; + + // update options + this.options = _.defaults(options, this.optionsDefault); + + // set element + this.setElement(this._template(this.options)); + + // attach popover to parent + this.options.container.parent().append(this.$el); + + // attach close + if (this.options.with_close) { + this.$el.find('#close').on('click', function() { self.hide(); }); + } + + // generate unique id + this.uuid = Utils.uuid(); + + // add event to hide if click is outside of popup + var self = this; + $('body').on('mousedown.' + this.uuid, function(e) { self._hide(e) }); + }, + + // title + title: function(val) { + if (val !== undefined) { + this.$el.find('.popover-title-label').html(val); + } + }, + + // show + show: function () { + // show popover + this.$el.show(); + this.visible = true; + + // calculate position + var position = this._get_placement(this.options.placement); + + // set position + this.$el.css(position); + }, + + // calculate position and error + _get_placement: function(placement) { + // get popover dimensions + var width = this._get_width(this.$el); + var height = this.$el.height(); + + // get container details + var $container = this.options.container; + var container_width = this._get_width($container); + var container_height = this._get_height($container); + var container_position = $container.position(); + + // initialize position + var top = 0; + var left = 0; + + // calculate position + if (placement == 'top' || placement == 'bottom') { + left = container_position.left - width + (container_width + width) / 2; + if (placement == 'top') { + top = container_position.top - height - 5; + } else { + top = container_position.top + container_height + 5; + } + } + + // return + return {top: top, left: left}; + }, + + // width + _get_width: function($el) { + return $el.width() + parseInt($el.css('padding-left')) + parseInt($el.css('padding-right')) + }, + + // heigth + _get_height: function($el) { + return $el.height() + parseInt($el.css('padding-top')) + parseInt($el.css('padding-bottom')) + }, + + // hide + hide: function () { + this.$el.hide(); + this.visible = false; + }, + + // append + append: function($el) { + this.$el.find('.popover-content').append($el); + }, + + // empty + empty: function($el) { + this.$el.find('.popover-content').empty(); + }, + + // remove + remove: function() { + // remove event handler + $('body').off('mousedown.' + this.uuid); + + // remove element from dom + this.$el.remove(); + }, + + // remove + _hide : function(e) { + //the 'is' for buttons that trigger popups + //the 'has' for icons within a button that triggers a popup + if (!$(this.options.container).is(e.target) && + !$(this.el).is(e.target) && + $(this.el).has(e.target).length === 0) { + this.hide(); + } + }, + + // template + _template: function(options) { + var tmpl = '<div class="popover-view popover fade ' + options.placement + ' in">' + + '<div class="arrow"></div>' + + '<div class="popover-title">' + + '<div class="popover-title-label">' + + options.title + + '</div>'; + + // add close icon + if (options.with_close) { + tmpl += '<div id="close" class="popover-close fa fa-times-circle"></div>'; + } + + // finalize + tmpl += '</div>' + + '<div class="popover-content"></div>' + + '</div>'; + + // return + return tmpl; + } +}); + +return { + View: View +} + +}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/mvc/upload/upload-button.js --- /dev/null +++ b/static/scripts/mvc/upload/upload-button.js @@ -0,0 +1,102 @@ +// dependencies +define([], function() { + +// create model +var Model = Backbone.Model.extend({ + defaults: { + percentage : 0, + icon : 'fa-circle', + label : '', + status : '' + } +}); + +// progress bar button on ui +var View = Backbone.View.extend({ + // model + model : null, + + // initialize + initialize : function(model) { + // link this + var self = this; + + // create model + this.model = model; + + // get options + this.options = this.model.attributes; + + // create new element + this.setElement(this._template(this.options)); + + // add event + $(this.el).on('click', this.options.onclick); + + // add tooltip + if (this.options.tooltip) { + $(this.el).tooltip({title: this.options.tooltip, placement: 'bottom'}); + } + + // events + this.model.on('change:percentage', function() { + self._percentage(self.model.get('percentage')); + }); + this.model.on('change:status', function() { + self._status(self.model.get('status')); + }); + + // unload event + var self = this; + $(window).on('beforeunload', function() { + var text = ""; + if (self.options.onunload) { + text = self.options.onunload(); + } + if (text != "") { + return text; + } + }); + }, + + // set status + _status: function(value) { + var $el = this.$el.find('.progress-bar'); + $el.removeClass(); + $el.addClass('progress-bar'); + $el.addClass('progress-bar-notransition'); + if (value != '') { + $el.addClass('progress-bar-' + value); + console.log($el); + } + }, + + // set percentage + _percentage: function(value) { + var $el = this.$el.find('.progress-bar'); + $el.css({ width : value + '%' }); + }, + + // template + _template: function(options) { + return '<div style="float: right">' + + '<div class="upload-button">' + + '<div class="progress">' + + '<div class="progress-bar"></div>' + + '</div>' + + '<div id="label" class="label">' + + '<a class="panel-header-button" href="javascript:void(0)">' + + '<span class="fa fa-upload"></span>' + + '</a>' + + '</div>' + + '</div>' + + '</div>'; + } +}); + +return { + Model: Model, + View: View +}; + +});
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/mvc/upload/upload-ftp.js --- /dev/null +++ b/static/scripts/mvc/upload/upload-ftp.js @@ -0,0 +1,173 @@ +// dependencies +define(['utils/utils'], function(Utils) { + +// item view +return Backbone.View.extend({ + // options + options: { + class_add : 'upload-icon-button fa fa-square-o', + class_remove : 'upload-icon-button fa fa-check-square-o' + }, + + // render + initialize: function(app) { + // link app + this.app = app; + + // link this + var self = this; + + // set template + this.setElement(this._template()); + + // load extension + Utils.jsonFromUrl(galaxy_config.root + 'api/ftp_files', function(ftp_files) { self._fill(ftp_files); }); + }, + + // events + events: { + 'mousedown' : function(e) { e.preventDefault(); } + }, + + // fill table + _fill: function(ftp_files) { + + if (ftp_files.length > 0) { + // add table + this.$el.find('#upload-ftp-content').html($(this._template_table())); + + // add files to table + var size = 0; + for (key in ftp_files) { + this.add(ftp_files[key]); + size += ftp_files[key].size; + } + + // update stats + this.$el.find('#upload-ftp-number').html(ftp_files.length + ' files'); + this.$el.find('#upload-ftp-disk').html(Utils.bytesToString (size, true)); + } else { + // add info + this.$el.find('#upload-ftp-content').html($(this._template_info())); + } + + // hide spinner + this.$el.find('#upload-ftp-wait').hide(); + }, + + // add + add: function(ftp_file) { + // create new item + var $it = $(this._template_row(ftp_file)); + + // append to table + $(this.el).find('tbody').append($it); + + // find model and set initial 'add' icon class + var icon_class = ''; + if (this._find(ftp_file)) { + icon_class = this.options.class_remove; + } else { + icon_class = this.options.class_add; + } + $it.find('#upload-ftp-add').addClass(icon_class); + + // click to add ftp files + var self = this; + $it.find('#upload-ftp-add').on('click', function() { + // find model + var model_index = self._find(ftp_file); + + // update icon + $(this).removeClass(); + + // add model + if (!model_index) { + // add to uploadbox + self.app.uploadbox.add([{ + mode : 'ftp', + name : ftp_file.path, + size : ftp_file.size, + path : ftp_file.path + }]); + + // add new icon class + $(this).addClass(self.options.class_remove); + } else { + // remove + self.app.collection.remove(model_index); + + // add new icon class + $(this).addClass(self.options.class_add); + } + }); + }, + + // get model index + _find: function(ftp_file) { + // check if exists already + var filtered = this.app.collection.where({file_path : ftp_file.path}); + var model_index = null; + for (var key in filtered) { + var item = filtered[key]; + if (item.get('status') == 'init' && item.get('file_mode') == 'ftp') { + model_index = item.get('id'); + } + } + return model_index; + }, + + // template row + _template_row: function(options) { + return '<tr>' + + '<td><div id="upload-ftp-add"/></td>' + + '<td>' + options.path + '</td>' + + '<td style="white-space: nowrap;">' + Utils.bytesToString(options.size) + '</td>' + + '<td style="white-space: nowrap;">' + options.ctime + '</td>' + + '</tr>'; + }, + + // load table template + _template_table: function() + { + return '<span style="whitespace: nowrap; float: left;">Available files: </span>' + + '<span style="whitespace: nowrap; float: right;">' + + '<span class="upload-icon fa fa-file-text-o"/>' + + '<span id="upload-ftp-number"/> ' + + '<span class="upload-icon fa fa-hdd-o"/>' + + '<span id="upload-ftp-disk"/>' + + '</span>' + + '<table class="grid">' + + '<thead>' + + '<tr>' + + '<th></th>' + + '<th>Name</th>' + + '<th>Size</th>' + + '<th>Created</th>' + + '</tr>' + + '</thead>' + + '<tbody></tbody>' + + '</table>'; + }, + + // load table template + _template_info: function() + { + return '<div class="upload-ftp-warning warningmessage">' + + 'Your FTP directory does not contain any files.' + + '</div>'; + }, + + // load html template + _template: function() + { + return '<div class="upload-ftp">' + + '<div id="upload-ftp-wait" class="upload-ftp-wait fa fa-spinner fa-spin"/>' + + '<div class="upload-ftp-help">This Galaxy server allows you to upload files via FTP. To upload some files, log in to the FTP server at <strong>' + this.app.options.ftp_upload_site + '</strong> using your Galaxy credentials (email address and password).</div>' + + '<div id="upload-ftp-content"></div>' + + '<div>'; + } + +}); + +});
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/mvc/upload/upload-model.js --- a/static/scripts/mvc/upload/upload-model.js +++ b/static/scripts/mvc/upload/upload-model.js @@ -7,9 +7,16 @@ extension : 'auto', genome : '?', url_paste : '', + status : 'init', + info : null, + file_mode : 'local', + file_size : 0, + file_type : null, + file_path : '', + + // settings space_to_tabs : false, - status : 'init', - info : null + to_posix_lines : true } });
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/mvc/upload/upload-row.js --- a/static/scripts/mvc/upload/upload-row.js +++ b/static/scripts/mvc/upload/upload-row.js @@ -1,5 +1,16 @@ // dependencies -define(['mvc/upload/upload-model', 'mvc/upload/upload-extensions'], function(UploadModel, UploadExtensions) { +define(['utils/utils', + 'mvc/upload/upload-model', + 'mvc/upload/upload-extensions', + 'mvc/upload/upload-settings', + 'mvc/ui.popover'], + + function( Utils, + UploadModel, + UploadExtensions, + UploadSettings, + Popover + ) {
// item view return Backbone.View.extend({ @@ -11,13 +22,16 @@
// states status_classes : { - init : 'symbol fa fa-trash-o', - queued : 'symbol fa fa-spinner fa-spin', - running : 'symbol fa fa-spinner fa-spin', - success : 'symbol fa fa-check', - error : 'symbol fa fa-exclamation-triangle' + init : 'upload-icon-button fa fa-trash-o', + queued : 'upload-icon fa fa-spinner fa-spin', + running : 'upload-icon fa fa-spinner fa-spin', + success : 'upload-icon-button fa fa-check', + error : 'upload-icon-button fa fa-exclamation-triangle' },
+ // handle for settings popover + settings: null, + // render initialize: function(app, options) { // link app @@ -35,36 +49,32 @@ // link item var it = this.$el;
+ // append popup to settings icon + this.settings = new Popover.View({ + title : 'Upload configuration', + container : it.find('#settings'), + placement : 'bottom' + }); + + // + // ui events + // + // 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); - } - }); + it.find('#symbol').on('click', function() { self._removeRow(); });
- // handle mouse over - it.find('#extension_info').on('mouseover' , function() { self._showExtensionInfo(); }) - .on('mouseleave', function() { self._hideExtensionInfo(); }); + // handle extension info popover + it.find('#extension-info').on('click' , function(e) { self._showExtensionInfo(); }) + .on('mousedown', function(e) { e.preventDefault(); }); + + // handle settings popover + it.find('#settings').on('click' , function(e) { self._showSettings(); }) + .on('mousedown', function(e) { e.preventDefault(); });
// 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); - self.model.set('file_size', count); + it.find('#text-content').on('keyup', function(e) { + self.model.set('url_paste', $(e.target).val()); + self.model.set('file_size', $(e.target).val().length); });
// handle genome selection @@ -75,7 +85,6 @@ // handle extension selection it.find('#extension').on('change', function(e) { self.model.set('extension', $(e.target).val()); - self.$el.find('#extension_info').popover('destroy'); });
// handle space to tabs button @@ -83,19 +92,27 @@ self.model.set('space_to_tabs', $(e.target).prop('checked')); });
- // events + // + // model events + // this.model.on('change:percentage', function() { self._refreshPercentage(); }); this.model.on('change:status', function() { self._refreshStatus(); }); + this.model.on('change:extension', function() { + self._destroyExtensionInfo(); + }); this.model.on('change:info', function() { self._refreshInfo(); }); this.model.on('change:genome', function() { self._refreshGenome(); }); + this.model.on('change:file_size', function() { + self._refreshFileSize(); + }); this.model.on('remove', function() { self._destroyExtensionInfo(); self.remove(); @@ -109,8 +126,9 @@ // render render: function() { // read model - var file_name = this.model.get('file_name'); - var file_size = this.model.get('file_size'); + var file_name = this.model.get('file_name'); + var file_size = this.model.get('file_size'); + var file_mode = this.model.get('file_mode');
// link item var it = this.$el; @@ -119,10 +137,14 @@ it.find('#title').html(file_name);
// update info - it.find('#size').html(this._formatSize (file_size)); + it.find('#size').html(Utils.bytesToString (file_size));
- // activate text field if file content is zero - if (file_size == -1) + // remove mode class + it.find('#mode').removeClass() + .addClass('mode'); + + // activate text field if file is new + if (file_mode == 'new') { // get text component var text = it.find('#text'); @@ -141,9 +163,28 @@
// show text field text.show(); + + // update icon + it.find('#mode').addClass('fa fa-pencil'); + } + + // file from local disk + if (file_mode == 'local') { + // update icon + it.find('#mode').addClass('fa fa-laptop'); + } + + // file from ftp + if (file_mode == 'ftp') { + // update icon + it.find('#mode').addClass('fa fa-code-fork'); } },
+ // + // handle model events + // + // genome _refreshGenome: function() { @@ -218,45 +259,69 @@ } },
- // 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; + // refresh size + _refreshFileSize: function() { + var count = this.model.get('file_size'); + this.$el.find('#size').html(Utils.bytesToString (count)); + }, + + // + // handle ui events + // + + // remove row + _removeRow: function() { + // get current status + var status = this.model.get('status'); + + // only remove from queue if not in processing line + if (status == 'init' || status == 'success' || status == 'error') { + // remove from collection + this.app.collection.remove(this.model); + } },
// attach file info popup _showExtensionInfo : function() { // initialize - var self = this; - var $el = $(this.el).find('#extension_info'); + var $el = $(this.el).find('#extension-info'); var extension = this.model.get('extension'); var title = $(this.el).find('#extension').find('option:selected').text();
// create popup - $el.popover({ - html: true, - title: title, - content: UploadExtensions(extension), - placement: 'bottom', - container: self.$el.parent() - }); + if (!this.extension_popup) { + this.extension_popup = new Popover.View({ + content: UploadExtensions(extension), + placement: 'bottom', + container: $el + }); + }
- // show popup - $el.popover('show'); - - // clear previous timers - clearTimeout(this.popover_timeout); + // show / hide popup + if (!this.extension_popup.visible) { + this.extension_popup.title(title); + this.extension_popup.empty(); + this.extension_popup.append(UploadExtensions(extension)); + this.extension_popup.show(); + } else { + this.extension_popup.hide(); + } + }, + + // attach file info popup + _showSettings : function() + { + // check if popover is visible + if (!this.settings.visible) { + // show popover + this.settings.empty(); + this.settings.append((new UploadSettings(this)).$el); + this.settings.show(); + } else { + // hide popover + this.settings.hide(); + } },
// attach file info popup @@ -272,9 +337,9 @@ // attach file info popup _destroyExtensionInfo : function() { - this.$el.find('#extension_info').popover('destroy'); + this.$el.find('#extension-info').popover('destroy'); }, - + // template _template: function(options) { @@ -285,6 +350,7 @@ var tmpl = '<tr id="upload-item-' + options.id + '" class="upload-item">' + '<td>' + '<div style="position: relative;">' + + '<div id="mode"></div>' + '<div id="title" class="title"></div>' + '<div id="text" class="text">' + '<div class="text-info">You can tell Galaxy to download data from web by entering URL in this box (one per line). You can also directly paste the contents of a file.</div>' + @@ -292,7 +358,9 @@ '</div>' + '</div>' + '</td>' + - '<td><div id="size" class="size"></div></td>'; + '<td>' + + '<div id="size" class="size"></div>' + + '</td>';
// add file type selectore tmpl += '<td>' + @@ -300,7 +368,7 @@ 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>' + - ' <i id="extension_info" class="fa fa-search" style="cursor: pointer;"/>' + + ' <i id="extension-info" class="upload-icon-button fa fa-search"/>' + '</td>';
// add genome selector @@ -312,7 +380,7 @@ '</td>';
// add next row - tmpl += '<td><input id="space_to_tabs" type="checkbox"></input></td>' + + tmpl += '<td><div id="settings" class="upload-icon-button fa fa-gear"></div>' + '<td>' + '<div id="info" class="info">' + '<div class="progress">' +
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/mvc/upload/upload-settings.js --- /dev/null +++ b/static/scripts/mvc/upload/upload-settings.js @@ -0,0 +1,102 @@ +// dependencies +define(['utils/utils'], function(Utils) { + +// item view +return Backbone.View.extend({ + // options + options: { + class_check : 'upload-icon-button fa fa-check-square-o', + class_uncheck : 'upload-icon-button fa fa-square-o' + }, + + // render + initialize: function(app) { + // link app + this.app = app; + + // link this + var self = this; + + // set template + this.setElement(this._template()); + + // link model + this.model = this.app.model; + + // ui event: space to tabs + this.$el.find('#upload-space-to-tabs').on('click', function() { + self._switch_state('#upload-space-to-tabs', 'space_to_tabs'); + }); + + // ui event: to posix + this.$el.find('#upload-to-posix-lines').on('click', function() { + self._switch_state('#upload-to-posix-lines', 'to_posix_lines'); + }); + + // render + this.render(); + }, + + // events + events: { + 'mousedown' : function(e) { e.preventDefault(); } + }, + + // render + render: function() { + // render states + this._render_state('#upload-space-to-tabs', this.model.get('space_to_tabs')); + this._render_state('#upload-to-posix-lines', this.model.get('to_posix_lines')); + + // disable options + var $cover = this.$el.find('#upload-settings-cover'); + if (this.model.get('status') != 'init') { + $cover.show(); + } else { + $cover.hide(); + } + }, + + // switch state + _switch_state: function (element_id, parameter_id) { + if (this.model.get('status') == 'init') { + var checked = !this.model.get(parameter_id); + this.model.set(parameter_id, checked); + this._render_state(element_id, checked); + } + }, + + // render state + _render_state: function (element_id, checked) { + // swith icon class + var $it = this.$el.find(element_id); + $it.removeClass(); + if (checked) { + $it.addClass(this.options.class_check); + } else { + $it.addClass(this.options.class_uncheck); + } + }, + + // load template + _template: function() + { + return '<div class="upload-settings" style="position: relative;">' + + '<div id="upload-settings-cover" class="upload-settings-cover"/>' + + '<table class="table table-striped">' + + '<tbody>' + + '<tr>' + + '<td><div id="upload-space-to-tabs"/></td>' + + '<td>Convert spaces to tabs</td>' + + '</tr>' + + '<tr>' + + '<td><div id="upload-to-posix-lines"/></td>' + + '<td>Use POSIX standard</td>' + + '</tr>' + + '</tbody>' + + '</table>' + + '</div>'; + } +}); + +});
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/mvc/upload/upload-view.js --- a/static/scripts/mvc/upload/upload-view.js +++ b/static/scripts/mvc/upload/upload-view.js @@ -1,117 +1,36 @@ // dependencies define(["galaxy.modal", "utils/utils", + "mvc/upload/upload-button", "mvc/upload/upload-model", "mvc/upload/upload-row", + "mvc/upload/upload-ftp", + "mvc/ui.popover", "mvc/ui", "utils/uploadbox"],
function( Modal, Utils, + UploadButton, UploadModel, - UploadItem + UploadItem, + UploadFtp, + Popover ) {
-// create model -var ProgressButtonModel = Backbone.Model.extend({ - defaults: { - percentage : 0, - icon : 'fa-circle', - label : '', - status : '' - } -}); - -// progress bar button on ui -var ProgressButton = Backbone.View.extend({ - // model - model : null, - - // initialize - initialize : function(model) { - // link this - var self = this; - - // create model - this.model = model; - - // get options - this.options = this.model.attributes; - - // create new element - this.setElement(this._template(this.options)); - - // add event - $(this.el).on('click', this.options.onclick); - - // add tooltip - if (this.options.tooltip) { - $(this.el).tooltip({title: this.options.tooltip, placement: 'bottom'}); - } - - // events - this.model.on('change:percentage', function() { - self._percentage(self.model.get('percentage')); - }); - this.model.on('change:status', function() { - self._status(self.model.get('status')); - }); - - // unload event - var self = this; - $(window).on('beforeunload', function() { - var text = ""; - if (self.options.onunload) { - text = self.options.onunload(); - } - if (text != "") { - return text; - } - }); - }, - - // set status - _status: function(value) { - var $el = this.$el.find('.progress-bar'); - $el.removeClass(); - $el.addClass('progress-bar'); - $el.addClass('progress-bar-notransition'); - if (value != '') { - $el.addClass('progress-bar-' + value); - } - }, - - // set percentage - _percentage: function(value) { - var $el = this.$el.find('.progress-bar'); - $el.css({ width : value + '%' }); - }, - - // template - _template: function(options) { - return '<div style="float: right">' + - '<div class="progress-button">' + - '<div class="progress">' + - '<div class="progress-bar"></div>' + - '</div>' + - '<div id="label" class="label">' + - '<a class="panel-header-button" href="javascript:void(0)">' + - '<span class="fa fa-upload"></span>' + - '</a>' + - '</div>' + - '</div>' + - '</div>'; - } -}); - // galaxy upload return Backbone.View.extend( { + // options + options : { + nginx_upload_path : '' + }, + // own modal modal : null,
// button - button_show : null, + ui_button : null,
// jquery uploadbox plugin uploadbox: null, @@ -131,6 +50,9 @@ // collection collection : new UploadModel.Collection(),
+ // ftp file viewer + ftp : null, + // counter counter : { // stats @@ -140,36 +62,29 @@ running : 0,
// reset stats - reset : function() - { + reset : function() { this.announce = this.success = this.error = this.running = 0; } }, - - // options - options : { - nginx_upload_path : '' - }, - + // initialize - initialize : function(options) - { + initialize : function(options) { // link this var self = this;
// wait for galaxy history panel (workaround due to the use of iframes) - if (!Galaxy.currHistoryPanel || !Galaxy.currHistoryPanel.model) - { + if (!Galaxy.currHistoryPanel || !Galaxy.currHistoryPanel.model) { window.setTimeout(function() { self.initialize() }, 500) return; }
// check if logged in - if (!Galaxy.currUser.get('id')) + if (!Galaxy.currUser.get('id')) { return; + }
// create model - this.button_show = new ProgressButtonModel({ + this.ui_button = new UploadButton.Model({ icon : 'fa-upload', tooltip : 'Download from URL or upload files from disk', label : 'Load Data', @@ -186,7 +101,7 @@ });
// define location - $('#left .unified-panel-header-inner').append((new ProgressButton(this.button_show)).$el); + $('#left .unified-panel-header-inner').append((new UploadButton.View(this.ui_button)).$el);
// load extension var self = this; @@ -242,33 +157,29 @@ //
// show/hide upload frame - _eventShow : function (e) - { + _eventShow : function (e) { // prevent default e.preventDefault(); - // stop propagation of event (for click-outside-of-modal-to-close functionality) - e.stopPropagation();
// create modal - if (!this.modal) - { + if (!this.modal) { // make modal var self = this; - this.modal = new Modal.GalaxyModal( - { + this.modal = new Modal.GalaxyModal({ title : 'Download data directly from web or upload files from your disk', body : this._template('upload-box', 'upload-info'), buttons : { - 'Choose files' : function() {self.uploadbox.select()}, - 'Create file' : function() {self._eventCreate()}, - 'Start' : function() {self._eventStart()}, - 'Pause' : function() {self._eventStop()}, - 'Reset' : function() {self._eventReset()}, - 'Close' : function() {self.modal.hide()}, + 'Choose local file' : function() {self.uploadbox.select()}, + 'Choose FTP file' : function() {self._eventFtp()}, + 'Create new file' : function() {self._eventCreate()}, + 'Start' : function() {self._eventStart()}, + 'Pause' : function() {self._eventStop()}, + 'Reset' : function() {self._eventReset()}, + 'Close' : function() {self.modal.hide()}, }, height : '400', width : '900', - closing_events : true + closing_events : true });
// set element @@ -276,8 +187,7 @@
// file upload var self = this; - this.uploadbox = this.$el.uploadbox( - { + 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) }, @@ -288,6 +198,17 @@
// setup info this._updateScreen(); + + // add ftp file viewer + if (this.options.ftp_upload_dir && this.options.ftp_upload_site) { + var button = this.modal.getButton('Choose FTP file'); + this.ftp = new Popover.View({ + title : 'FTP files', + container : button + }); + } else { + this.modal.hideButton('Choose FTP file'); + } }
// show modal @@ -299,8 +220,7 @@ //
// remove item from upload list - _eventRemove : function(item) - { + _eventRemove : function(item) { // update status var status = item.get('status');
@@ -325,8 +245,7 @@ //
// a new file has been dropped/selected through the uploadbox plugin - _eventAnnounce : function(index, file, message) - { + _eventAnnounce : function(index, file, message) { // update counter this.counter.announce++;
@@ -337,22 +256,23 @@ var upload_item = new UploadItem(this, { id : index, file_name : file.name, - file_size : file.size + file_size : file.size, + file_mode : file.mode, + file_path : file.path });
// add to collection this.collection.add(upload_item.model);
// add upload item element to table - $(this.el).find('tbody:last').append(upload_item.$el); + $(this.el).find('tbody:first').append(upload_item.$el);
// render upload_item.render(); },
// the uploadbox plugin is initializing the upload for this file - _eventInitialize : function(index, file, message) - { + _eventInitialize : function(index, file, message) { // get element var it = this.collection.get(index);
@@ -360,26 +280,38 @@ it.set('status', 'running');
// get configuration - var file_type = it.get('extension'); var file_name = it.get('file_name'); + var file_path = it.get('file_path'); + var file_mode = it.get('file_mode'); + var extension = it.get('extension'); var genome = it.get('genome'); var url_paste = it.get('url_paste'); var space_to_tabs = it.get('space_to_tabs'); + var to_posix_lines = it.get('to_posix_lines');
// 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"}); + this.uploadbox.configure({url : this.options.nginx_upload_path}); + + // configure file mode + if (file_mode == 'ftp') { + this.uploadbox.configure({paramname : ''}); + } else { + this.uploadbox.configure({paramname : 'files_0|file_data'}); + }
// configure tool tool_input = {}; tool_input['dbkey'] = genome; - tool_input['file_type'] = file_type; + tool_input['file_type'] = extension; tool_input['files_0|type'] = 'upload_dataset'; tool_input['files_0|url_paste'] = url_paste; + tool_input['files_0|ftp_files'] = file_path; tool_input['space_to_tabs'] = space_to_tabs; + tool_input['to_posix_lines'] = to_posix_lines;
// setup data data = {}; @@ -392,19 +324,17 @@ },
// progress - _eventProgress : function(index, file, percentage) - { + _eventProgress : function(index, file, percentage) { // set progress for row var it = this.collection.get(index); it.set('percentage', percentage);
// update ui button - this.button_show.set('percentage', this._upload_percentage(percentage, file.size)); + this.ui_button.set('percentage', this._upload_percentage(percentage, file.size)); },
// success - _eventSuccess : function(index, file, message) - { + _eventSuccess : function(index, file, message) { // update status var it = this.collection.get(index); it.set('status', 'success'); @@ -413,7 +343,7 @@ var file_size = it.get('file_size');
// update ui button - this.button_show.set('percentage', this._upload_percentage(100, file_size)); + this.ui_button.set('percentage', this._upload_percentage(100, file_size));
// update completed this.upload_completed += file_size * 100; @@ -430,8 +360,7 @@ },
// error - _eventError : function(index, file, message) - { + _eventError : function(index, file, message) { // get element var it = this.collection.get(index);
@@ -440,8 +369,8 @@ it.set('info', message);
// update ui button - this.button_show.set('percentage', this._upload_percentage(100, file.size)); - this.button_show.set('status', 'danger'); + this.ui_button.set('percentage', this._upload_percentage(100, file.size)); + this.ui_button.set('status', 'danger');
// update completed this.upload_completed += file.size * 100; @@ -472,10 +401,27 @@ // events triggered by this view //
- // create (pseudo) file + _eventFtp: function() { + // check if popover is visible + if (!this.ftp.visible) { + // show popover + this.ftp.empty(); + this.ftp.append((new UploadFtp(this)).$el); + this.ftp.show(); + } else { + // hide popover + this.ftp.hide(); + } + }, + + // create a new file _eventCreate : function () { - this.uploadbox.add([{ name : 'New File', size : -1 }]); + this.uploadbox.add([{ + name : 'New File', + size : 0, + mode : 'new' + }]); },
// start upload process @@ -498,8 +444,8 @@ });
// reset progress - this.button_show.set('percentage', 0); - this.button_show.set('status', 'success'); + this.ui_button.set('percentage', 0); + this.ui_button.set('status', 'success');
// backup current history this.current_history = Galaxy.currHistoryPanel.model.get('id'); @@ -520,7 +466,7 @@ }
// show upload has paused - this.button_show.set('status', 'info'); + this.ui_button.set('status', 'info');
// request pause this.uploadbox.stop(); @@ -547,13 +493,12 @@ this.uploadbox.reset();
// reset button - this.button_show.set('percentage', 0); + this.ui_button.set('percentage', 0); } },
// set screen - _updateScreen: function () - { + _updateScreen: function () { /* update on screen info */ @@ -600,18 +545,20 @@ // select upload button if (this.counter.running == 0) { - this.modal.enableButton('Choose files'); - this.modal.enableButton('Create file'); + this.modal.enableButton('Choose local file'); + this.modal.enableButton('Choose FTP file'); + this.modal.enableButton('Create new file'); } else { - this.modal.disableButton('Choose files'); - this.modal.disableButton('Create file'); + this.modal.disableButton('Choose local file'); + this.modal.disableButton('Choose FTP file'); + this.modal.disableButton('Create new file'); }
// table visibility if (this.counter.announce + this.counter.success + this.counter.error > 0) - $(this.el).find('table').show(); + $(this.el).find('#upload-table').show(); else - $(this.el).find('table').hide(); + $(this.el).find('#upload-table').hide(); },
// calculate percentage of all queued uploads @@ -620,17 +567,16 @@ },
// load html template - _template: function(id, idInfo) - { + _template: function(id, idInfo) { return '<div id="' + id + '" class="upload-box">' + - '<table class="table table-striped" style="display: none;">' + + '<table id="upload-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>Settings</th>' + '<th>Status</th>' + '<th></th>' + '</tr>' +
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/galaxy.modal.js --- a/static/scripts/packed/galaxy.modal.js +++ b/static/scripts/packed/galaxy.modal.js @@ -1,1 +1,1 @@ -define([],function(){var a=Backbone.View.extend({elMain:"#everything",optionsDefault:{title:"galaxy-modal",body:"",backdrop:true,height:null,width:null,closing_events:false},buttonList:{},initialize:function(b){if(b){this._create(b)}},show:function(b){this.initialize(b);if(this.options.height){this.$body.css("height",this.options.height);this.$body.css("overflow","hidden")}else{this.$body.css("max-height",$(window).height()/2)}if(this.options.width){this.$dialog.css("width",this.options.width)}if(this.visible){this.$el.show()}else{this.$el.fadeIn("fast")}this.visible=true},hide:function(){this.visible=false;this.$el.fadeOut("fast")},enableButton:function(b){var c=this.buttonList[b];this.$buttons.find("#"+c).prop("disabled",false)},disableButton:function(b){var c=this.buttonList[b];this.$buttons.find("#"+c).prop("disabled",true)},showButton:function(b){var c=this.buttonList[b];this.$buttons.find("#"+c).show()},hideButton:function(b){var c=this.buttonList[b];this.$buttons.find("#"+c).hide()},scrollTop:function(){return this.$body.scrollTop()},_create:function(d){var c=this;this.options=_.defaults(d,this.optionsDefault);if(this.options.body=="progress"){this.options.body=$('<div class="progress progress-striped active"><div class="progress-bar progress-bar-info" style="width:100%"></div></div>')}if(this.$el){this.$el.remove();$(document).off("keyup")}this.setElement(this._template(this.options.title));this.$dialog=(this.$el).find(".modal-dialog");this.$body=(this.$el).find(".modal-body");this.$footer=(this.$el).find(".modal-footer");this.$buttons=(this.$el).find(".buttons");this.$backdrop=(this.$el).find(".modal-backdrop");this.$body.html(this.options.body);if(!this.options.backdrop){this.$backdrop.removeClass("in")}if(this.options.buttons){this.buttonList={};var b=0;$.each(this.options.buttons,function(e,g){var f="button-"+b++;c.$buttons.append($('<button id="'+f+'"></button>').text(e).click(g)).append(" ");c.buttonList[e]=f})}else{this.$footer.hide()}$(this.elMain).append($(this.el));if(this.options.closing_events){if(!this.options.buttons.Pause){$(document).on("keyup",function(f){if(f.keyCode==27){c.hide()}})}this.$el.find(".modal-backdrop").on("click",function(){c.hide()})}},_template:function(b){return'<div class="modal"><div class="modal-backdrop fade in" style="z-index: -1;"></div><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" style="display: none;">×</button><h4 class="title">'+b+'</h4></div><div class="modal-body"></div><div class="modal-footer"><div class="buttons" style="float: right;"></div></div></div</div></div>'}});return{GalaxyModal:a}}); \ No newline at end of file +define([],function(){var a=Backbone.View.extend({elMain:"#everything",optionsDefault:{title:"galaxy-modal",body:"",backdrop:true,height:null,width:null,closing_events:false},buttonList:{},initialize:function(b){if(b){this._create(b)}},show:function(b){this.initialize(b);if(this.options.height){this.$body.css("height",this.options.height);this.$body.css("overflow","hidden")}else{this.$body.css("max-height",$(window).height()/2)}if(this.options.width){this.$dialog.css("width",this.options.width)}if(this.visible){this.$el.show()}else{this.$el.fadeIn("fast")}this.visible=true},hide:function(){this.visible=false;this.$el.fadeOut("fast")},enableButton:function(b){var c=this.buttonList[b];this.$buttons.find("#"+c).prop("disabled",false)},disableButton:function(b){var c=this.buttonList[b];this.$buttons.find("#"+c).prop("disabled",true)},showButton:function(b){var c=this.buttonList[b];this.$buttons.find("#"+c).show()},hideButton:function(b){var c=this.buttonList[b];this.$buttons.find("#"+c).hide()},getButton:function(b){var c=this.buttonList[b];return this.$buttons.find("#"+c)},scrollTop:function(){return this.$body.scrollTop()},_create:function(d){var c=this;this.options=_.defaults(d,this.optionsDefault);if(this.options.body=="progress"){this.options.body=$('<div class="progress progress-striped active"><div class="progress-bar progress-bar-info" style="width:100%"></div></div>')}if(this.$el){this.$el.remove();$(document).off("keyup")}this.setElement(this._template(this.options.title));this.$dialog=(this.$el).find(".modal-dialog");this.$body=(this.$el).find(".modal-body");this.$footer=(this.$el).find(".modal-footer");this.$buttons=(this.$el).find(".buttons");this.$backdrop=(this.$el).find(".modal-backdrop");this.$body.html(this.options.body);if(!this.options.backdrop){this.$backdrop.removeClass("in")}if(this.options.buttons){this.buttonList={};var b=0;$.each(this.options.buttons,function(e,g){var f="button-"+b++;c.$buttons.append($('<button id="'+f+'"></button>').text(e).click(g)).append(" ");c.buttonList[e]=f})}else{this.$footer.hide()}$(this.elMain).append($(this.el));if(this.options.closing_events){if(!this.options.buttons.Pause){$(document).on("keyup",function(f){if(f.keyCode==27){c.hide()}})}this.$el.find(".modal-backdrop").on("click",function(){c.hide()})}},_template:function(b){return'<div class="modal"><div class="modal-backdrop fade in" style="z-index: -1;"></div><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" style="display: none;">×</button><h4 class="title">'+b+'</h4></div><div class="modal-body" style="position: static;"></div><div class="modal-footer"><div class="buttons" style="float: right;"></div></div></div</div></div>'}});return{GalaxyModal:a}}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/mvc/grid/grid-template.js --- a/static/scripts/packed/mvc/grid/grid-template.js +++ b/static/scripts/packed/mvc/grid/grid-template.js @@ -1,1 +1,1 @@ -define([],function(){return{grid:function(b){var a="";if(b.embedded){a=this.grid_header(b)+this.grid_table(b)}else{a='<div class="loading-elt-overlay"></div><table><tr><td width="75%">'+this.grid_header(b)+'</td><td></td><td></td></tr><tr><td width="100%" id="grid-message" valign="top"></td><td></td><td></td></tr></table>'+this.grid_table(b)}if(b.info_text){a+='<br><div class="toolParamHelp" style="clear: both;">'+b.info_text+"</div>"}return a},grid_table:function(a){return'<form method="post" onsubmit="return false;"><table id="grid-table" class="grid"><thead id="grid-table-header"></thead><tbody id="grid-table-body"></tbody><tfoot id="grid-table-footer"></tfoot></table></form>'},grid_header:function(c){var b='<div class="grid-header">';if(!c.embedded){b+="<h2>"+c.title+"</h2>"}if(c.global_actions){b+='<ul class="manage-table-actions">';var d=(c.global_actions.length>=3);if(d){b+='<li><a class="action-button" id="popup-global-actions" class="menubutton">Actions</a></li><div popupmenu="popup-global-actions">'}for(i in c.global_actions){var e=c.global_actions[i];var a="";if(e.inbound){a="use-inbound"}else{a="use-outbound"}b+='<li><a class="action-button '+a+'" href="'+e.url_args+'" onclick="return false;">'+e.label+"</a></li>"}if(d){b+="</div>"}b+="</ul>"}if(c.insert){b+=c.insert}b+=this.grid_filters(c);b+="</div>";return b},header:function(b){var a="<tr>";if(b.show_item_checkboxes){a+="<th>";if(b.items.length>0){a+='<input type="checkbox" id="check_all" name=select_all_checkbox value="true"><input type="hidden" name=select_all_checkbox value="true">'}a+="</th>"}for(var c in b.columns){var d=b.columns[c];if(d.visible){a+='<th id="'+d.key+'-header">';if(d.href){a+='<a href="'+d.href+'" class="sort-link" sort_key="'+d.key+'">'+d.label+"</a>"}else{a+=d.label}a+='<span class="sort-arrow">'+d.extra+"</span></th>"}}a+="</tr>";return a},body:function(r){var k="";var s=0;var e=r.items.length;if(e==0){k+='<tr><td colspan="100"><em>No Items</em></td></tr>';s=1}for(var f in r.items){var p=r.items[f];var a=p.encode_id;var g="grid-"+f+"-popup";k+="<tr ";if(r.current_item_id==p.id){k+='class="current"'}k+=">";if(r.show_item_checkboxes){k+='<td style="width: 1.5em;"><input type="checkbox" name="id" value="'+a+'" id="'+a+'" class="grid-row-select-checkbox" /></td>'}for(j in r.columns){var d=r.columns[j];if(d.visible){var c="";if(d.nowrap){c='style="white-space:nowrap;"'}var q=p.column_config[d.label];var h=q.link;var l=q.value;var o=q.inbound;if(jQuery.type(l)==="string"){l=l.replace(////g,"/")}var b="";var n="";if(d.attach_popup){b="grid-"+f+"-popup";n="menubutton";if(h!=""){n+=" split"}n+=" popup"}k+="<td "+c+">";if(h){if(r.operations.length!=0){k+='<div id="'+b+'" class="'+n+'" style="float: left;">'}var m="";if(o){m="use-inbound"}else{m="use-outbound"}k+='<a class="label '+m+'" href="'+h+'" onclick="return false;">'+l+"</a>";if(r.operations.length!=0){k+="</div>"}}else{k+='<div id="'+b+'" class="'+n+'"><label id="'+d.label_id_prefix+a+'" for="'+a+'">'+l+"</label></div>"}k+="</td>"}}k+="</tr>";s++}return k},footer:function(o){var k="";if(o.use_paging&&o.num_pages>1){var m=o.num_page_links;var a=o.cur_page_num;var n=o.num_pages;var h=m/2;var g=a-h;var e=0;if(g==0){g=1;e=h-(a-g)}var d=h+e;var c=a+d;if(c<=n){max_offset=0}else{c=n;max_offset=d-(c+1-a)}if(max_offset!=0){g-=max_offset;if(g<1){g=1}}k+='<tr id="page-links-row">';if(o.show_item_checkboxes){k+="<td></td>"}k+='<td colspan="100"><span id="page-link-container">Page:';if(g>1){k+='<span class="page-link" id="page-link-1"><a href="javascript:void(0);" page_num="1" onclick="return false;">1</a></span> ...'}for(var l=g;l<c+1;l++){if(l==o.cur_page_num){k+='<span class="page-link inactive-link" id="page-link-'+l+'">'+l+"</span>"}else{k+='<span class="page-link" id="page-link-'+l+'"><a href="javascript:void(0);" onclick="return false;" page_num="'+l+'">'+l+"</a></span>"}}if(c<n){k+='...<span class="page-link" id="page-link-'+n+'"><a href="javascript:void(0);" onclick="return false;" page_num="'+n+'">'+n+"</a></span>"}k+="</span>";k+='<span class="page-link" id="show-all-link-span"> | <a href="javascript:void(0);" onclick="return false;" page_num="all">Show All</a></span></td></tr>'}if(o.show_item_checkboxes){k+='<tr><input type="hidden" id="operation" name="operation" value=""><td></td><td colspan="100">For <span class="grid-selected-count"></span> selected '+o.get_class_plural+": ";for(i in o.operations){var b=o.operations[i];if(b.allow_multiple){k+='<input type="button" value="'+b.label+'" class="operation-button action-button"> '}}k+="</td></tr>"}var f=false;for(i in o.operations){if(o.operations[i].global_operation){f=true;break}}if(f){k+='<tr><td colspan="100">';for(i in o.operations){var b=o.operations[i];if(b.global_operation){k+='<a class="action-button" href="'+b.global_operation+'">'+b.label+"</a>"}}k+="</td></tr>"}if(o.legend){k+='<tr><td colspan="100">'+o.legend+"</td></tr>"}return k},message:function(a){return'<p><div class="'+a.status+'message transient-message">'+a.message+'</div><div style="clear: both"></div></p>'},grid_filters:function(n){var a=n.default_filter_dict;var b=n.filters;var e="none";if(n.advanced_search){e="block"}var m=false;for(var g in n.columns){var d=n.columns[g];if(d.filterable=="advanced"){var l=d.key;var c=b[l];var f=a[l];if(c&&f&&c!=f){e="block"}m=true}}var k="block";if(e=="block"){k="none"}var h='<div id="standard-search" style="display: '+k+';"><table><tr><td style="padding: 0;"><table>';for(var g in n.columns){var d=n.columns[g];if(d.filterable=="standard"){h+=this.grid_column_filter(n,d)}}h+="</table></td></tr><tr><td>";if(m){h+='<a href="" class="advanced-search-toggle">Advanced Search</a>'}h+="</td></tr></table></div>";h+='<div id="advanced-search" style="display: '+e+'; margin-top: 5px; border: 1px solid #ccc;"><table><tr><td style="text-align: left" colspan="100"><a href="" class="advanced-search-toggle">Close Advanced Search</a></td></tr>';for(var g in n.columns){var d=n.columns[g];if(d.filterable=="advanced"){h+=this.grid_column_filter(n,d)}}h+="</table></div>";return h},grid_column_filter:function(e,c){var t=e.default_filter_dict;var l=e.filters;var a=c.label;var b=c.key;if(c.filterable=="advanced"){a=a.toLowerCase()}var k="<tr>";if(c.filterable=="advanced"){k+='<td align="left" style="padding-left: 10px">'+a+":</td>"}k+='<td style="padding-bottom: 1px;">';if(c.is_text){k+='<form class="text-filter-form" column_key="'+b+'" action="'+e.url+'" method="get" >';for(u in e.columns){var g=e.columns[u];var p=l[g.key];if(p){if(p!="All"){if(g.is_text){p=JSON.stringify(p)}k+='<input type="hidden" id="'+g.key+'" name="f-'+g.key+'" value="'+p+'"/>'}}}k+='<span id="'+b+'-filtering-criteria">';var h=l[b];if(h){var f=jQuery.type(h);if(f=="string"){if(h!="All"){k+=this.filter_element(b,h)}}if(f=="array"){for(var u in h){var n=h[u];var v=h;v=v.slice(u);k+=this.filter_element(b,n)}}}k+="</span>";var r="";if(c.filterable=="standard"){r=c.label.toLowerCase();var q=r.length;if(q<20){q=20}q=q+4}k+='<span class="search-box"><input class="search-box-input" id="input-'+b+'-filter" name="f-'+b+'" type="text" placeholder="'+r+'" size="'+q+'"/><button type="submit" style="background: transparent; border: none; padding: 4px; margin: 0px;"><i class="fa fa-plus-circle"></i></button></span></form>'}else{k+='<span id="'+b+'-filtering-criteria">';var s=false;for(cf_label in e.categorical_filters[b]){var o=e.categorical_filters[b][cf_label];var d="";var m="";for(key in o){d=key;m=o[key]}if(s){k+=" | "}s=true;var n=l[b];if(n&&o[b]&&n==m){k+='<span class="categorical-filter '+b+'-filter current-filter">'+cf_label+"</span>"}else{k+='<span class="categorical-filter '+b+'-filter"><a href="javascript:void(0);" filter_key="'+d+'" filter_val="'+m+'">'+cf_label+"</a></span>"}}k+="</span>"}k+="</td></tr>";return k},filter_element:function(b,a){return'<span class="text-filter-val">'+a+'<a href="javascript:void(0);" filter_key="'+b+'" filter_val="'+a+'"><i class="fa fa-times" style="padding-left: 5px; padding-bottom: 6px;"/></a></span>'}}}); \ No newline at end of file +define([],function(){return{grid:function(b){var a="";if(b.embedded){a=this.grid_header(b)+this.grid_table(b)}else{a='<div class="loading-elt-overlay"></div><table><tr><td width="75%">'+this.grid_header(b)+'</td><td></td><td></td></tr><tr><td width="100%" id="grid-message" valign="top"></td><td></td><td></td></tr></table>'+this.grid_table(b)}if(b.info_text){a+='<br><div class="toolParamHelp" style="clear: both;">'+b.info_text+"</div>"}return a},grid_table:function(a){return'<form method="post" onsubmit="return false;"><table id="grid-table" class="grid"><thead id="grid-table-header"></thead><tbody id="grid-table-body"></tbody><tfoot id="grid-table-footer"></tfoot></table></form>'},grid_header:function(c){var b='<div class="grid-header">';if(!c.embedded){b+="<h2>"+c.title+"</h2>"}if(c.global_actions){b+='<ul class="manage-table-actions">';var d=(c.global_actions.length>=3);if(d){b+='<li><a class="action-button" id="popup-global-actions" class="menubutton">Actions</a></li><div popupmenu="popup-global-actions">'}for(i in c.global_actions){var e=c.global_actions[i];var a="";if(e.inbound){a="use-inbound"}else{a="use-outbound"}b+='<li><a class="action-button '+a+'" href="'+e.url_args+'" onclick="return false;">'+e.label+"</a></li>"}if(d){b+="</div>"}b+="</ul>"}if(c.insert){b+=c.insert}b+=this.grid_filters(c);b+="</div>";return b},header:function(b){var a="<tr>";if(b.show_item_checkboxes){a+="<th>";if(b.items.length>0){a+='<input type="checkbox" id="check_all" name=select_all_checkbox value="true"><input type="hidden" name=select_all_checkbox value="true">'}a+="</th>"}for(var c in b.columns){var d=b.columns[c];if(d.visible){a+='<th id="'+d.key+'-header">';if(d.href){a+='<a href="'+d.href+'" class="sort-link" sort_key="'+d.key+'">'+d.label+"</a>"}else{a+=d.label}a+='<span class="sort-arrow">'+d.extra+"</span></th>"}}a+="</tr>";return a},body:function(r){var k="";var s=0;var e=r.items.length;if(e==0){k+='<tr><td colspan="100"><em>No Items</em></td></tr>';s=1}for(var f in r.items){var p=r.items[f];var a=p.encode_id;var g="grid-"+f+"-popup";k+="<tr ";if(r.current_item_id==p.id){k+='class="current"'}k+=">";if(r.show_item_checkboxes){k+='<td style="width: 1.5em;"><input type="checkbox" name="id" value="'+a+'" id="'+a+'" class="grid-row-select-checkbox" /></td>'}for(j in r.columns){var d=r.columns[j];if(d.visible){var c="";if(d.nowrap){c='style="white-space:nowrap;"'}var q=p.column_config[d.label];var h=q.link;var l=q.value;var o=q.inbound;if(jQuery.type(l)==="string"){l=l.replace(////g,"/")}var b="";var n="";if(d.attach_popup){b="grid-"+f+"-popup";n="menubutton";if(h!=""){n+=" split"}n+=" popup"}k+="<td "+c+">";if(h){if(r.operations.length!=0){k+='<div id="'+b+'" class="'+n+'" style="float: left;">'}var m="";if(o){m="use-inbound"}else{m="use-outbound"}k+='<a class="label '+m+'" href="'+h+'" onclick="return false;">'+l+"</a>";if(r.operations.length!=0){k+="</div>"}}else{k+='<div id="'+b+'" class="'+n+'"><label id="'+d.label_id_prefix+a+'" for="'+a+'">'+l+"</label></div>"}k+="</td>"}}k+="</tr>";s++}return k},footer:function(o){var k="";if(o.use_paging&&o.num_pages>1){var m=o.num_page_links;var a=o.cur_page_num;var n=o.num_pages;var h=m/2;var g=a-h;var e=0;if(g==0){g=1;e=h-(a-g)}var d=h+e;var c=a+d;if(c<=n){max_offset=0}else{c=n;max_offset=d-(c+1-a)}if(max_offset!=0){g-=max_offset;if(g<1){g=1}}k+='<tr id="page-links-row">';if(o.show_item_checkboxes){k+="<td></td>"}k+='<td colspan="100"><span id="page-link-container">Page:';if(g>1){k+='<span class="page-link" id="page-link-1"><a href="javascript:void(0);" page_num="1" onclick="return false;">1</a></span> ...'}for(var l=g;l<c+1;l++){if(l==o.cur_page_num){k+='<span class="page-link inactive-link" id="page-link-'+l+'">'+l+"</span>"}else{k+='<span class="page-link" id="page-link-'+l+'"><a href="javascript:void(0);" onclick="return false;" page_num="'+l+'">'+l+"</a></span>"}}if(c<n){k+='...<span class="page-link" id="page-link-'+n+'"><a href="javascript:void(0);" onclick="return false;" page_num="'+n+'">'+n+"</a></span>"}k+="</span>";k+='<span class="page-link" id="show-all-link-span"> | <a href="javascript:void(0);" onclick="return false;" page_num="all">Show All</a></span></td></tr>'}if(o.show_item_checkboxes){k+='<tr><input type="hidden" id="operation" name="operation" value=""><td></td><td colspan="100">For <span class="grid-selected-count"></span> selected '+o.get_class_plural+": ";for(i in o.operations){var b=o.operations[i];if(b.allow_multiple){k+='<input type="button" value="'+b.label+'" class="operation-button action-button"> '}}k+="</td></tr>"}var f=false;for(i in o.operations){if(o.operations[i].global_operation){f=true;break}}if(f){k+='<tr><td colspan="100">';for(i in o.operations){var b=o.operations[i];if(b.global_operation){k+='<a class="action-button" href="'+b.global_operation+'">'+b.label+"</a>"}}k+="</td></tr>"}if(o.legend){k+='<tr><td colspan="100">'+o.legend+"</td></tr>"}return k},message:function(a){return'<p><div class="'+a.status+'message transient-message">'+a.message+'</div><div style="clear: both"></div></p>'},grid_filters:function(n){var a=n.default_filter_dict;var b=n.filters;var e="none";if(n.advanced_search){e="block"}var m=false;for(var g in n.columns){var d=n.columns[g];if(d.filterable=="advanced"){var l=d.key;var c=b[l];var f=a[l];if(c&&f&&c!=f){e="block"}m=true}}var k="block";if(e=="block"){k="none"}var h='<div id="standard-search" style="display: '+k+';"><table><tr><td style="padding: 0;"><table>';for(var g in n.columns){var d=n.columns[g];if(d.filterable=="standard"){h+=this.grid_column_filter(n,d)}}h+="</table></td></tr><tr><td>";if(m){h+='<a href="" class="advanced-search-toggle">Advanced Search</a>'}h+="</td></tr></table></div>";h+='<div id="advanced-search" style="display: '+e+'; margin-top: 5px; border: 1px solid #ccc;"><table><tr><td style="text-align: left" colspan="100"><a href="" class="advanced-search-toggle">Close Advanced Search</a></td></tr>';for(var g in n.columns){var d=n.columns[g];if(d.filterable=="advanced"){h+=this.grid_column_filter(n,d)}}h+="</table></div>";return h},grid_column_filter:function(e,c){var t=e.default_filter_dict;var l=e.filters;var a=c.label;var b=c.key;if(c.filterable=="advanced"){a=a.toLowerCase()}var k="<tr>";if(c.filterable=="advanced"){k+='<td align="left" style="padding-left: 10px">'+a+":</td>"}k+='<td style="padding-bottom: 1px;">';if(c.is_text){k+='<form class="text-filter-form" column_key="'+b+'" action="'+e.url+'" method="get" >';for(u in e.columns){var g=e.columns[u];var p=l[g.key];if(p){if(p!="All"){if(g.is_text){p=JSON.stringify(p)}k+='<input type="hidden" id="'+g.key+'" name="f-'+g.key+'" value="'+p+'"/>'}}}k+='<span id="'+b+'-filtering-criteria">';var h=l[b];if(h){var f=jQuery.type(h);if(f=="string"){if(h!="All"){k+=this.filter_element(b,h)}}if(f=="array"){for(var u in h){var n=h[u];var v=h;v=v.slice(u);k+=this.filter_element(b,n)}}}k+="</span>";var r="";if(c.filterable=="standard"){r=c.label.toLowerCase();var q=r.length;if(q<20){q=20}q=q+4}k+='<span class="search-box"><input class="search-box-input" id="input-'+b+'-filter" name="f-'+b+'" type="text" placeholder="'+r+'" size="'+q+'"/><button type="submit" style="background: transparent; border: none; padding: 4px; margin: 0px;"><i class="fa fa-search"></i></button></span></form>'}else{k+='<span id="'+b+'-filtering-criteria">';var s=false;for(cf_label in e.categorical_filters[b]){var o=e.categorical_filters[b][cf_label];var d="";var m="";for(key in o){d=key;m=o[key]}if(s){k+=" | "}s=true;var n=l[b];if(n&&o[b]&&n==m){k+='<span class="categorical-filter '+b+'-filter current-filter">'+cf_label+"</span>"}else{k+='<span class="categorical-filter '+b+'-filter"><a href="javascript:void(0);" filter_key="'+d+'" filter_val="'+m+'">'+cf_label+"</a></span>"}}k+="</span>"}k+="</td></tr>";return k},filter_element:function(b,a){return'<span class="text-filter-val">'+a+'<a href="javascript:void(0);" filter_key="'+b+'" filter_val="'+a+'"><i class="fa fa-times" style="padding-left: 5px; padding-bottom: 6px;"/></a></span>'}}}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/mvc/ui.popover.js --- /dev/null +++ b/static/scripts/packed/mvc/ui.popover.js @@ -0,0 +1,1 @@ +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{with_close:true,container:"body",title:null,placement:"top"},visible:false,initialize:function(d){var c=this;this.options=_.defaults(d,this.optionsDefault);this.setElement(this._template(this.options));this.options.container.parent().append(this.$el);if(this.options.with_close){this.$el.find("#close").on("click",function(){c.hide()})}this.uuid=a.uuid();var c=this;$("body").on("mousedown."+this.uuid,function(f){c._hide(f)})},title:function(c){if(c!==undefined){this.$el.find(".popover-title-label").html(c)}},show:function(){this.$el.show();this.visible=true;var c=this._get_placement(this.options.placement);this.$el.css(c)},_get_placement:function(h){var d=this._get_width(this.$el);var j=this.$el.height();var k=this.options.container;var c=this._get_width(k);var f=this._get_height(k);var g=k.position();var i=0;var e=0;if(h=="top"||h=="bottom"){e=g.left-d+(c+d)/2;if(h=="top"){i=g.top-j-5}else{i=g.top+f+5}}return{top:i,left:e}},_get_width:function(c){return c.width()+parseInt(c.css("padding-left"))+parseInt(c.css("padding-right"))},_get_height:function(c){return c.height()+parseInt(c.css("padding-top"))+parseInt(c.css("padding-bottom"))},hide:function(){this.$el.hide();this.visible=false},append:function(c){this.$el.find(".popover-content").append(c)},empty:function(c){this.$el.find(".popover-content").empty()},remove:function(){$("body").off("mousedown."+this.uuid);this.$el.remove()},_hide:function(c){if(!$(this.options.container).is(c.target)&&!$(this.el).is(c.target)&&$(this.el).has(c.target).length===0){this.hide()}},_template:function(d){var c='<div class="popover-view popover fade '+d.placement+' in"><div class="arrow"></div><div class="popover-title"><div class="popover-title-label">'+d.title+"</div>";if(d.with_close){c+='<div id="close" class="popover-close fa fa-times-circle"></div>'}c+='</div><div class="popover-content"></div></div>';return c}});return{View:b}}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/mvc/upload/upload-button.js --- /dev/null +++ b/static/scripts/packed/mvc/upload/upload-button.js @@ -0,0 +1,1 @@ +define([],function(){var b=Backbone.Model.extend({defaults:{percentage:0,icon:"fa-circle",label:"",status:""}});var a=Backbone.View.extend({model:null,initialize:function(d){var c=this;this.model=d;this.options=this.model.attributes;this.setElement(this._template(this.options));$(this.el).on("click",this.options.onclick);if(this.options.tooltip){$(this.el).tooltip({title:this.options.tooltip,placement:"bottom"})}this.model.on("change:percentage",function(){c._percentage(c.model.get("percentage"))});this.model.on("change:status",function(){c._status(c.model.get("status"))});var c=this;$(window).on("beforeunload",function(){var e="";if(c.options.onunload){e=c.options.onunload()}if(e!=""){return e}})},_status:function(d){var c=this.$el.find(".progress-bar");c.removeClass();c.addClass("progress-bar");c.addClass("progress-bar-notransition");if(d!=""){c.addClass("progress-bar-"+d);console.log(c)}},_percentage:function(d){var c=this.$el.find(".progress-bar");c.css({width:d+"%"})},_template:function(c){return'<div style="float: right"><div class="upload-button"><div class="progress"><div class="progress-bar"></div></div><div id="label" class="label"><a class="panel-header-button" href="javascript:void(0)"><span class="fa fa-upload"></span></a></div></div></div>'}});return{Model:b,View:a}}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/mvc/upload/upload-ftp.js --- /dev/null +++ b/static/scripts/packed/mvc/upload/upload-ftp.js @@ -0,0 +1,1 @@ +define(["utils/utils"],function(a){return Backbone.View.extend({options:{class_add:"upload-icon-button fa fa-square-o",class_remove:"upload-icon-button fa fa-check-square-o"},initialize:function(c){this.app=c;var b=this;this.setElement(this._template());a.jsonFromUrl(galaxy_config.root+"api/ftp_files",function(d){b._fill(d)})},events:{mousedown:function(b){b.preventDefault()}},_fill:function(c){if(c.length>0){this.$el.find("#upload-ftp-content").html($(this._template_table()));var b=0;for(key in c){this.add(c[key]);b+=c[key].size}this.$el.find("#upload-ftp-number").html(c.length+" files");this.$el.find("#upload-ftp-disk").html(a.bytesToString(b,true))}else{this.$el.find("#upload-ftp-content").html($(this._template_info()))}this.$el.find("#upload-ftp-wait").hide()},add:function(e){var d=$(this._template_row(e));$(this.el).find("tbody").append(d);var c="";if(this._find(e)){c=this.options.class_remove}else{c=this.options.class_add}d.find("#upload-ftp-add").addClass(c);var b=this;d.find("#upload-ftp-add").on("click",function(){var f=b._find(e);$(this).removeClass();if(!f){b.app.uploadbox.add([{mode:"ftp",name:e.path,size:e.size,path:e.path}]);$(this).addClass(b.options.class_remove)}else{b.app.collection.remove(f);$(this).addClass(b.options.class_add)}})},_find:function(f){var c=this.app.collection.where({file_path:f.path});var b=null;for(var d in c){var e=c[d];if(e.get("status")=="init"&&e.get("file_mode")=="ftp"){b=e.get("id")}}return b},_template_row:function(b){return'<tr><td><div id="upload-ftp-add"/></td><td>'+b.path+'</td><td style="white-space: nowrap;">'+a.bytesToString(b.size)+'</td><td style="white-space: nowrap;">'+b.ctime+"</td></tr>"},_template_table:function(){return'<span style="whitespace: nowrap; float: left;">Available files: </span><span style="whitespace: nowrap; float: right;"><span class="upload-icon fa fa-file-text-o"/><span id="upload-ftp-number"/> <span class="upload-icon fa fa-hdd-o"/><span id="upload-ftp-disk"/></span><table class="grid"><thead><tr><th></th><th>Name</th><th>Size</th><th>Created</th></tr></thead><tbody></tbody></table>'},_template_info:function(){return'<div class="upload-ftp-warning warningmessage">Your FTP directory does not contain any files.</div>'},_template:function(){return'<div class="upload-ftp"><div id="upload-ftp-wait" class="upload-ftp-wait fa fa-spinner fa-spin"/><div class="upload-ftp-help">This Galaxy server allows you to upload files via FTP. To upload some files, log in to the FTP server at <strong>'+this.app.options.ftp_upload_site+'</strong> using your Galaxy credentials (email address and password).</div><div id="upload-ftp-content"></div><div>'}})}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/mvc/upload/upload-model.js --- a/static/scripts/packed/mvc/upload/upload-model.js +++ b/static/scripts/packed/mvc/upload/upload-model.js @@ -1,1 +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 +define([],function(){var b=Backbone.Model.extend({defaults:{extension:"auto",genome:"?",url_paste:"",status:"init",info:null,file_mode:"local",file_size:0,file_type:null,file_path:"",space_to_tabs:false,to_posix_lines:true}});var a=Backbone.Collection.extend({model:b});return{Model:b,Collection:a}}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/mvc/upload/upload-row.js --- a/static/scripts/packed/mvc/upload/upload-row.js +++ b/static/scripts/packed/mvc/upload/upload-row.js @@ -1,1 +1,1 @@ -define(["mvc/upload/upload-model","mvc/upload/upload-extensions"],function(a,b){return Backbone.View.extend({options:{padding:8,timeout:2000},status_classes:{init:"symbol fa fa-trash-o",queued:"symbol fa fa-spinner fa-spin",running:"symbol fa fa-spinner fa-spin",success:"symbol fa fa-check",error:"symbol fa fa-exclamation-triangle"},initialize:function(f,d){this.app=f;var c=this;this.model=new a.Model(d);this.setElement(this._template(d));var e=this.$el;e.find("#symbol").on("click",function(){var g=c.model.get("status");if(g=="init"||g=="success"||g=="error"){c.app.collection.remove(c.model)}});e.find("#extension_info").on("mouseover",function(){c._showExtensionInfo()}).on("mouseleave",function(){c._hideExtensionInfo()});e.find("#text-content").on("keyup",function(){var g=e.find("#text-content");var i=g.val();var h=i.length;e.find("#size").html(c._formatSize(h));c.model.set("url_paste",i);c.model.set("file_size",h)});e.find("#genome").on("change",function(g){c.model.set("genome",$(g.target).val())});e.find("#extension").on("change",function(g){c.model.set("extension",$(g.target).val());c.$el.find("#extension_info").popover("destroy")});e.find("#space_to_tabs").on("change",function(g){c.model.set("space_to_tabs",$(g.target).prop("checked"))});this.model.on("change:percentage",function(){c._refreshPercentage()});this.model.on("change:status",function(){c._refreshStatus()});this.model.on("change:info",function(){c._refreshInfo()});this.model.on("change:genome",function(){c._refreshGenome()});this.model.on("remove",function(){c._destroyExtensionInfo();c.remove()});this.app.collection.on("reset",function(){c._destroyExtensionInfo();c.remove()})},render:function(){var i=this.model.get("file_name");var d=this.model.get("file_size");var f=this.$el;f.find("#title").html(i);f.find("#size").html(this._formatSize(d));if(d==-1){var h=f.find("#text");var g=this.options.padding;var e=f.width()-2*g;var c=f.height()-g;h.css("width",e+"px");h.css("top",c+"px");f.height(c+h.height()+2*g);h.show()}},_refreshGenome:function(){var c=this.model.get("genome");this.$el.find("#genome").val(c)},_refreshInfo:function(){var c=this.model.get("info");if(c){this.$el.find("#info").html("<strong>Failed: </strong>"+c).show()}else{this.$el.find("#info").hide()}},_refreshPercentage:function(){var c=parseInt(this.model.get("percentage"));this.$el.find(".progress-bar").css({width:c+"%"});if(c!=100){this.$el.find("#percentage").html(c+"%")}else{this.$el.find("#percentage").html("Adding to history...")}},_refreshStatus:function(){var d=this.$el;var c=this.model.get("status");var f=this.status_classes[c];var e=this.$el.find("#symbol");e.removeClass();e.addClass(f);if(c=="init"){d.find("#text-content").attr("disabled",false);d.find("#genome").attr("disabled",false);d.find("#extension").attr("disabled",false);d.find("#space_to_tabs").attr("disabled",false)}else{d.find("#text-content").attr("disabled",true);d.find("#genome").attr("disabled",true);d.find("#extension").attr("disabled",true);d.find("#space_to_tabs").attr("disabled",true)}if(c=="success"){d.addClass("success");d.find("#percentage").html("100%")}if(c=="error"){d.addClass("danger");d.find(".progress").remove()}},_formatSize:function(c){var d="";if(c>=100000000000){c=c/100000000000;d="TB"}else{if(c>=100000000){c=c/100000000;d="GB"}else{if(c>=100000){c=c/100000;d="MB"}else{if(c>=100){c=c/100;d="KB"}else{if(c>0){c=c*10;d="b"}else{return"<strong>-</strong>"}}}}}return"<strong>"+(Math.round(c)/10)+"</strong> "+d},_showExtensionInfo:function(){var c=this;var d=$(this.el).find("#extension_info");var f=this.model.get("extension");var e=$(this.el).find("#extension").find("option:selected").text();d.popover({html:true,title:e,content:b(f),placement:"bottom",container:c.$el.parent()});d.popover("show");clearTimeout(this.popover_timeout)},_hideExtensionInfo:function(){var c=this;this.popover_timeout=setTimeout(function(){c._destroyExtensionInfo()},this.options.timeout)},_destroyExtensionInfo:function(){this.$el.find("#extension_info").popover("destroy")},_template:function(e){var d=this;var c='<tr id="upload-item-'+e.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 can tell Galaxy to download data from web by entering URL in this box (one per line). You can also directly 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>';c+='<td><select id="extension" class="extension">';for(key in d.app.select_extension){c+='<option value="'+d.app.select_extension[key][1]+'">'+d.app.select_extension[key][0]+"</option>"}c+='</select> <i id="extension_info" class="fa fa-search" style="cursor: pointer;"/></td>';c+='<td><select id="genome" class="genome">';for(key in d.app.select_genome){c+='<option value="'+d.app.select_genome[key][1]+'">'+d.app.select_genome[key][0]+"</option>"}c+="</select></td>";c+='<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 c}})}); \ No newline at end of file +define(["utils/utils","mvc/upload/upload-model","mvc/upload/upload-extensions","mvc/upload/upload-settings","mvc/ui.popover"],function(d,b,e,a,c){return Backbone.View.extend({options:{padding:8,timeout:2000},status_classes:{init:"upload-icon-button fa fa-trash-o",queued:"upload-icon fa fa-spinner fa-spin",running:"upload-icon fa fa-spinner fa-spin",success:"upload-icon-button fa fa-check",error:"upload-icon-button fa fa-exclamation-triangle"},settings:null,initialize:function(i,g){this.app=i;var f=this;this.model=new b.Model(g);this.setElement(this._template(g));var h=this.$el;this.settings=new c.View({title:"Upload configuration",container:h.find("#settings"),placement:"bottom"});h.find("#symbol").on("click",function(){f._removeRow()});h.find("#extension-info").on("click",function(j){f._showExtensionInfo()}).on("mousedown",function(j){j.preventDefault()});h.find("#settings").on("click",function(j){f._showSettings()}).on("mousedown",function(j){j.preventDefault()});h.find("#text-content").on("keyup",function(j){f.model.set("url_paste",$(j.target).val());f.model.set("file_size",$(j.target).val().length)});h.find("#genome").on("change",function(j){f.model.set("genome",$(j.target).val())});h.find("#extension").on("change",function(j){f.model.set("extension",$(j.target).val())});h.find("#space_to_tabs").on("change",function(j){f.model.set("space_to_tabs",$(j.target).prop("checked"))});this.model.on("change:percentage",function(){f._refreshPercentage()});this.model.on("change:status",function(){f._refreshStatus()});this.model.on("change:extension",function(){f._destroyExtensionInfo()});this.model.on("change:info",function(){f._refreshInfo()});this.model.on("change:genome",function(){f._refreshGenome()});this.model.on("change:file_size",function(){f._refreshFileSize()});this.model.on("remove",function(){f._destroyExtensionInfo();f.remove()});this.app.collection.on("reset",function(){f._destroyExtensionInfo();f.remove()})},render:function(){var m=this.model.get("file_name");var g=this.model.get("file_size");var j=this.model.get("file_mode");var i=this.$el;i.find("#title").html(m);i.find("#size").html(d.bytesToString(g));i.find("#mode").removeClass().addClass("mode");if(j=="new"){var l=i.find("#text");var k=this.options.padding;var h=i.width()-2*k;var f=i.height()-k;l.css("width",h+"px");l.css("top",f+"px");i.height(f+l.height()+2*k);l.show();i.find("#mode").addClass("fa fa-pencil")}if(j=="local"){i.find("#mode").addClass("fa fa-laptop")}if(j=="ftp"){i.find("#mode").addClass("fa fa-code-fork")}},_refreshGenome:function(){var f=this.model.get("genome");this.$el.find("#genome").val(f)},_refreshInfo:function(){var f=this.model.get("info");if(f){this.$el.find("#info").html("<strong>Failed: </strong>"+f).show()}else{this.$el.find("#info").hide()}},_refreshPercentage:function(){var f=parseInt(this.model.get("percentage"));this.$el.find(".progress-bar").css({width:f+"%"});if(f!=100){this.$el.find("#percentage").html(f+"%")}else{this.$el.find("#percentage").html("Adding to history...")}},_refreshStatus:function(){var g=this.$el;var f=this.model.get("status");var i=this.status_classes[f];var h=this.$el.find("#symbol");h.removeClass();h.addClass(i);if(f=="init"){g.find("#text-content").attr("disabled",false);g.find("#genome").attr("disabled",false);g.find("#extension").attr("disabled",false);g.find("#space_to_tabs").attr("disabled",false)}else{g.find("#text-content").attr("disabled",true);g.find("#genome").attr("disabled",true);g.find("#extension").attr("disabled",true);g.find("#space_to_tabs").attr("disabled",true)}if(f=="success"){g.addClass("success");g.find("#percentage").html("100%")}if(f=="error"){g.addClass("danger");g.find(".progress").remove()}},_refreshFileSize:function(){var f=this.model.get("file_size");this.$el.find("#size").html(d.bytesToString(f))},_removeRow:function(){var f=this.model.get("status");if(f=="init"||f=="success"||f=="error"){this.app.collection.remove(this.model)}},_showExtensionInfo:function(){var f=$(this.el).find("#extension-info");var h=this.model.get("extension");var g=$(this.el).find("#extension").find("option:selected").text();if(!this.extension_popup){this.extension_popup=new c.View({content:e(h),placement:"bottom",container:f})}if(!this.extension_popup.visible){this.extension_popup.title(g);this.extension_popup.empty();this.extension_popup.append(e(h));this.extension_popup.show()}else{this.extension_popup.hide()}},_showSettings:function(){if(!this.settings.visible){this.settings.empty();this.settings.append((new a(this)).$el);this.settings.show()}else{this.settings.hide()}},_hideExtensionInfo:function(){var f=this;this.popover_timeout=setTimeout(function(){f._destroyExtensionInfo()},this.options.timeout)},_destroyExtensionInfo:function(){this.$el.find("#extension-info").popover("destroy")},_template:function(h){var g=this;var f='<tr id="upload-item-'+h.id+'" class="upload-item"><td><div style="position: relative;"><div id="mode"></div><div id="title" class="title"></div><div id="text" class="text"><div class="text-info">You can tell Galaxy to download data from web by entering URL in this box (one per line). You can also directly 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>';f+='<td><select id="extension" class="extension">';for(key in g.app.select_extension){f+='<option value="'+g.app.select_extension[key][1]+'">'+g.app.select_extension[key][0]+"</option>"}f+='</select> <i id="extension-info" class="upload-icon-button fa fa-search"/></td>';f+='<td><select id="genome" class="genome">';for(key in g.app.select_genome){f+='<option value="'+g.app.select_genome[key][1]+'">'+g.app.select_genome[key][0]+"</option>"}f+="</select></td>";f+='<td><div id="settings" class="upload-icon-button fa fa-gear"></div><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 f}})}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/mvc/upload/upload-settings.js --- /dev/null +++ b/static/scripts/packed/mvc/upload/upload-settings.js @@ -0,0 +1,1 @@ +define(["utils/utils"],function(a){return Backbone.View.extend({options:{class_check:"upload-icon-button fa fa-check-square-o",class_uncheck:"upload-icon-button fa fa-square-o"},initialize:function(c){this.app=c;var b=this;this.setElement(this._template());this.model=this.app.model;this.$el.find("#upload-space-to-tabs").on("click",function(){b._switch_state("#upload-space-to-tabs","space_to_tabs")});this.$el.find("#upload-to-posix-lines").on("click",function(){b._switch_state("#upload-to-posix-lines","to_posix_lines")});this.render()},events:{mousedown:function(b){b.preventDefault()}},render:function(){this._render_state("#upload-space-to-tabs",this.model.get("space_to_tabs"));this._render_state("#upload-to-posix-lines",this.model.get("to_posix_lines"));var b=this.$el.find("#upload-settings-cover");if(this.model.get("status")!="init"){b.show()}else{b.hide()}},_switch_state:function(c,b){if(this.model.get("status")=="init"){var d=!this.model.get(b);this.model.set(b,d);this._render_state(c,d)}},_render_state:function(b,d){var c=this.$el.find(b);c.removeClass();if(d){c.addClass(this.options.class_check)}else{c.addClass(this.options.class_uncheck)}},_template:function(){return'<div class="upload-settings" style="position: relative;"><div id="upload-settings-cover" class="upload-settings-cover"/><table class="table table-striped"><tbody><tr><td><div id="upload-space-to-tabs"/></td><td>Convert spaces to tabs</td></tr><tr><td><div id="upload-to-posix-lines"/></td><td>Use POSIX standard</td></tr></tbody></table></div>'}})}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/mvc/upload/upload-view.js --- a/static/scripts/packed/mvc/upload/upload-view.js +++ b/static/scripts/packed/mvc/upload/upload-view.js @@ -1,1 +1,1 @@ -define(["galaxy.modal","utils/utils","mvc/upload/upload-model","mvc/upload/upload-row","mvc/ui","utils/uploadbox"],function(c,f,e,d){var b=Backbone.Model.extend({defaults:{percentage:0,icon:"fa-circle",label:"",status:""}});var a=Backbone.View.extend({model:null,initialize:function(h){var g=this;this.model=h;this.options=this.model.attributes;this.setElement(this._template(this.options));$(this.el).on("click",this.options.onclick);if(this.options.tooltip){$(this.el).tooltip({title:this.options.tooltip,placement:"bottom"})}this.model.on("change:percentage",function(){g._percentage(g.model.get("percentage"))});this.model.on("change:status",function(){g._status(g.model.get("status"))});var g=this;$(window).on("beforeunload",function(){var i="";if(g.options.onunload){i=g.options.onunload()}if(i!=""){return i}})},_status:function(h){var g=this.$el.find(".progress-bar");g.removeClass();g.addClass("progress-bar");g.addClass("progress-bar-notransition");if(h!=""){g.addClass("progress-bar-"+h)}},_percentage:function(h){var g=this.$el.find(".progress-bar");g.css({width:h+"%"})},_template:function(g){return'<div style="float: right"><div class="progress-button"><div class="progress"><div class="progress-bar"></div></div><div id="label" class="label"><a class="panel-header-button" href="javascript:void(0)"><span class="fa fa-upload"></span></a></div></div></div>'}});return Backbone.View.extend({modal:null,button_show:null,uploadbox:null,current_history:null,upload_size:0,select_extension:[["Auto-detect","auto"]],select_genome:[["Unspecified (?)","?"]],collection:new e.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(h){var g=this;if(!Galaxy.currHistoryPanel||!Galaxy.currHistoryPanel.model){window.setTimeout(function(){g.initialize()},500);return}if(!Galaxy.currUser.get("id")){return}this.button_show=new b({icon:"fa-upload",tooltip:"Download from URL or upload files from disk",label:"Load Data",onclick:function(i){if(i){g._eventShow(i)}},onunload:function(){if(g.counter.running>0){return"Several uploads are still processing."}}});$("#left .unified-panel-header-inner").append((new a(this.button_show)).$el);var g=this;f.jsonFromUrl(galaxy_config.root+"api/datatypes",function(i){for(key in i){g.select_extension.push([i[key],i[key]])}});f.jsonFromUrl(galaxy_config.root+"api/genomes",function(i){var j=g.select_genome[0];g.select_genome=[];for(key in i){if(i[key].length>1){if(i[key][1]!==j[1]){g.select_genome.push(i[key])}}}g.select_genome.sort(function(l,k){return l[0]>k[0]?1:l[0]<k[0]?-1:0});g.select_genome.unshift(j)});if(h){this.options=_.defaults(h,this.options)}this.collection.on("remove",function(i){g._eventRemove(i)});this.collection.on("change:genome",function(j){var i=j.get("genome");g.collection.each(function(k){if(k.get("status")=="init"&&k.get("genome")=="?"){k.set("genome",i)}})})},_eventShow:function(h){h.preventDefault();h.stopPropagation();if(!this.modal){var g=this;this.modal=new c.GalaxyModal({title:"Download data directly from web or upload files from your disk",body:this._template("upload-box","upload-info"),buttons:{"Choose files":function(){g.uploadbox.select()},"Create file":function(){g._eventCreate()},Start:function(){g._eventStart()},Pause:function(){g._eventStop()},Reset:function(){g._eventReset()},Close:function(){g.modal.hide()},},height:"400",width:"900",closing_events:true});this.setElement("#upload-box");var g=this;this.uploadbox=this.$el.uploadbox({announce:function(i,j,k){g._eventAnnounce(i,j,k)},initialize:function(i,j,k){return g._eventInitialize(i,j,k)},progress:function(i,j,k){g._eventProgress(i,j,k)},success:function(i,j,k){g._eventSuccess(i,j,k)},error:function(i,j,k){g._eventError(i,j,k)},complete:function(){g._eventComplete()}});this._updateScreen()}this.modal.show()},_eventRemove:function(h){var g=h.get("status");if(g=="success"){this.counter.success--}else{if(g=="error"){this.counter.error--}else{this.counter.announce--}}this._updateScreen();this.uploadbox.remove(h.id)},_eventAnnounce:function(g,h,j){this.counter.announce++;this._updateScreen();var i=new d(this,{id:g,file_name:h.name,file_size:h.size});this.collection.add(i.model);$(this.el).find("tbody:last").append(i.$el);i.render()},_eventInitialize:function(k,g,o){var i=this.collection.get(k);i.set("status","running");var h=i.get("extension");var l=i.get("file_name");var n=i.get("genome");var m=i.get("url_paste");var j=i.get("space_to_tabs");if(!m&&!(g.size>0)){return null}this.uploadbox.configure({url:this.options.nginx_upload_path,paramname:"files_0|file_data"});tool_input={};tool_input.dbkey=n;tool_input.file_type=h;tool_input["files_0|type"]="upload_dataset";tool_input["files_0|url_paste"]=m;tool_input.space_to_tabs=j;data={};data.history_id=this.current_history;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},_eventProgress:function(h,i,g){var j=this.collection.get(h);j.set("percentage",g);this.button_show.set("percentage",this._upload_percentage(g,i.size))},_eventSuccess:function(h,i,k){var j=this.collection.get(h);j.set("status","success");var g=j.get("file_size");this.button_show.set("percentage",this._upload_percentage(100,g));this.upload_completed+=g*100;this.counter.announce--;this.counter.success++;this._updateScreen();Galaxy.currHistoryPanel.refreshHdas()},_eventError:function(g,h,j){var i=this.collection.get(g);i.set("status","error");i.set("info",j);this.button_show.set("percentage",this._upload_percentage(100,h.size));this.button_show.set("status","danger");this.upload_completed+=h.size*100;this.counter.announce--;this.counter.error++;this._updateScreen()},_eventComplete:function(){this.collection.each(function(g){if(g.get("status")=="queued"){g.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}var g=this;this.upload_size=0;this.upload_completed=0;this.collection.each(function(h){if(h.get("status")=="init"){h.set("status","queued");g.upload_size+=h.get("file_size")}});this.button_show.set("percentage",0);this.button_show.set("status","success");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.button_show.set("status","info");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();this.button_show.set("percentage",0)}},_updateScreen:function(){if(this.counter.announce==0){if(this.uploadbox.compatible()){message="You can Drag & Drop files into this box."}else{message="Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Some supported browsers are: 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 'Start' 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("Start")}else{this.modal.disableButton("Start")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Choose files");this.modal.enableButton("Create file")}else{this.modal.disableButton("Choose files");this.modal.disableButton("Create file")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("table").show()}else{$(this.el).find("table").hide()}},_upload_percentage:function(g,h){return(this.upload_completed+(g*h))/this.upload_size},_template:function(h,g){return'<div id="'+h+'" 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="'+g+'" class="upload-info"></h6>'}})}); \ No newline at end of file +define(["galaxy.modal","utils/utils","mvc/upload/upload-button","mvc/upload/upload-model","mvc/upload/upload-row","mvc/upload/upload-ftp","mvc/ui.popover","mvc/ui","utils/uploadbox"],function(a,f,e,c,b,g,d){return Backbone.View.extend({options:{nginx_upload_path:""},modal:null,ui_button:null,uploadbox:null,current_history:null,upload_size:0,select_extension:[["Auto-detect","auto"]],select_genome:[["Unspecified (?)","?"]],collection:new c.Collection(),ftp:null,counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},initialize:function(i){var h=this;if(!Galaxy.currHistoryPanel||!Galaxy.currHistoryPanel.model){window.setTimeout(function(){h.initialize()},500);return}if(!Galaxy.currUser.get("id")){return}this.ui_button=new e.Model({icon:"fa-upload",tooltip:"Download from URL or upload files from disk",label:"Load Data",onclick:function(j){if(j){h._eventShow(j)}},onunload:function(){if(h.counter.running>0){return"Several uploads are still processing."}}});$("#left .unified-panel-header-inner").append((new e.View(this.ui_button)).$el);var h=this;f.jsonFromUrl(galaxy_config.root+"api/datatypes",function(j){for(key in j){h.select_extension.push([j[key],j[key]])}});f.jsonFromUrl(galaxy_config.root+"api/genomes",function(j){var k=h.select_genome[0];h.select_genome=[];for(key in j){if(j[key].length>1){if(j[key][1]!==k[1]){h.select_genome.push(j[key])}}}h.select_genome.sort(function(m,l){return m[0]>l[0]?1:m[0]<l[0]?-1:0});h.select_genome.unshift(k)});if(i){this.options=_.defaults(i,this.options)}this.collection.on("remove",function(j){h._eventRemove(j)});this.collection.on("change:genome",function(k){var j=k.get("genome");h.collection.each(function(l){if(l.get("status")=="init"&&l.get("genome")=="?"){l.set("genome",j)}})})},_eventShow:function(j){j.preventDefault();if(!this.modal){var h=this;this.modal=new a.GalaxyModal({title:"Download data directly from web or upload files from your disk",body:this._template("upload-box","upload-info"),buttons:{"Choose local file":function(){h.uploadbox.select()},"Choose FTP file":function(){h._eventFtp()},"Create new file":function(){h._eventCreate()},Start:function(){h._eventStart()},Pause:function(){h._eventStop()},Reset:function(){h._eventReset()},Close:function(){h.modal.hide()},},height:"400",width:"900",closing_events:true});this.setElement("#upload-box");var h=this;this.uploadbox=this.$el.uploadbox({announce:function(k,l,m){h._eventAnnounce(k,l,m)},initialize:function(k,l,m){return h._eventInitialize(k,l,m)},progress:function(k,l,m){h._eventProgress(k,l,m)},success:function(k,l,m){h._eventSuccess(k,l,m)},error:function(k,l,m){h._eventError(k,l,m)},complete:function(){h._eventComplete()}});this._updateScreen();if(this.options.ftp_upload_dir&&this.options.ftp_upload_site){var i=this.modal.getButton("Choose FTP file");this.ftp=new d.View({title:"FTP files",container:i})}else{this.modal.hideButton("Choose FTP file")}}this.modal.show()},_eventRemove:function(i){var h=i.get("status");if(h=="success"){this.counter.success--}else{if(h=="error"){this.counter.error--}else{this.counter.announce--}}this._updateScreen();this.uploadbox.remove(i.id)},_eventAnnounce:function(h,i,k){this.counter.announce++;this._updateScreen();var j=new b(this,{id:h,file_name:i.name,file_size:i.size,file_mode:i.mode,file_path:i.path});this.collection.add(j.model);$(this.el).find("tbody:first").append(j.$el);j.render()},_eventInitialize:function(m,j,s){var k=this.collection.get(m);k.set("status","running");var o=k.get("file_name");var n=k.get("file_path");var h=k.get("file_mode");var p=k.get("extension");var r=k.get("genome");var q=k.get("url_paste");var l=k.get("space_to_tabs");var i=k.get("to_posix_lines");if(!q&&!(j.size>0)){return null}this.uploadbox.configure({url:this.options.nginx_upload_path});if(h=="ftp"){this.uploadbox.configure({paramname:""})}else{this.uploadbox.configure({paramname:"files_0|file_data"})}tool_input={};tool_input.dbkey=r;tool_input.file_type=p;tool_input["files_0|type"]="upload_dataset";tool_input["files_0|url_paste"]=q;tool_input["files_0|ftp_files"]=n;tool_input.space_to_tabs=l;tool_input.to_posix_lines=i;data={};data.history_id=this.current_history;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},_eventProgress:function(i,j,h){var k=this.collection.get(i);k.set("percentage",h);this.ui_button.set("percentage",this._upload_percentage(h,j.size))},_eventSuccess:function(i,j,l){var k=this.collection.get(i);k.set("status","success");var h=k.get("file_size");this.ui_button.set("percentage",this._upload_percentage(100,h));this.upload_completed+=h*100;this.counter.announce--;this.counter.success++;this._updateScreen();Galaxy.currHistoryPanel.refreshHdas()},_eventError:function(h,i,k){var j=this.collection.get(h);j.set("status","error");j.set("info",k);this.ui_button.set("percentage",this._upload_percentage(100,i.size));this.ui_button.set("status","danger");this.upload_completed+=i.size*100;this.counter.announce--;this.counter.error++;this._updateScreen()},_eventComplete:function(){this.collection.each(function(h){if(h.get("status")=="queued"){h.set("status","init")}});this.counter.running=0;this._updateScreen()},_eventFtp:function(){if(!this.ftp.visible){this.ftp.empty();this.ftp.append((new g(this)).$el);this.ftp.show()}else{this.ftp.hide()}},_eventCreate:function(){this.uploadbox.add([{name:"New File",size:0,mode:"new"}])},_eventStart:function(){if(this.counter.announce==0||this.counter.running>0){return}var h=this;this.upload_size=0;this.upload_completed=0;this.collection.each(function(i){if(i.get("status")=="init"){i.set("status","queued");h.upload_size+=i.get("file_size")}});this.ui_button.set("percentage",0);this.ui_button.set("status","success");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.ui_button.set("status","info");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();this.ui_button.set("percentage",0)}},_updateScreen:function(){if(this.counter.announce==0){if(this.uploadbox.compatible()){message="You can Drag & Drop files into this box."}else{message="Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Some supported browsers are: 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 'Start' 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("Start")}else{this.modal.disableButton("Start")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Choose local file");this.modal.enableButton("Choose FTP file");this.modal.enableButton("Create new file")}else{this.modal.disableButton("Choose local file");this.modal.disableButton("Choose FTP file");this.modal.disableButton("Create new file")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("#upload-table").show()}else{$(this.el).find("#upload-table").hide()}},_upload_percentage:function(h,i){return(this.upload_completed+(h*i))/this.upload_size},_template:function(i,h){return'<div id="'+i+'" class="upload-box"><table id="upload-table" class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Genome</th><th>Settings</th><th>Status</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+h+'" class="upload-info"></h6>'}})}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/utils/config.js --- a/static/scripts/packed/utils/config.js +++ b/static/scripts/packed/utils/config.js @@ -1,1 +1,1 @@ -define(["libs/underscore","viz/trackster/util","utils/config"],function(c,f,b){var d=Backbone.Model.extend({initialize:function(g){var h=this.get("key");this.set("id",h);var i=c.find(d.known_settings_defaults,function(j){return j.key===h});if(i){this.set(c.extend({},i,g))}if(this.get("type")==="color"&&!this.get("value")){this.set("value",f.get_random_color())}},set_value:function(h){var g=this.get("type");if(g==="float"){h=parseFloat(h)}else{if(g==="int"){h=parseInt(h,10)}}this.set("value",h)}},{known_settings_defaults:[{key:"name",label:"Name",type:"text",default_value:""},{key:"color",label:"Color",type:"color",default_value:null},{key:"min_value",label:"Min Value",type:"float",default_value:null},{key:"max_value",label:"Max Value",type:"float",default_value:null},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:32,hidden:true},{key:"pos_color",label:"Positive Color",type:"color",default_value:"#FF8C00"},{key:"neg_color",label:"Negative Color",type:"color",default_value:"#4169E1"},{key:"block_color",label:"Block color",type:"color",default_value:null},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:null},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true}]});var e=Backbone.Collection.extend({model:d,to_key_value_dict:function(){var g={};this.each(function(h){g[h.get("key")]=h.get("value")});return g},get_value:function(g){var h=this.get(g);if(h){return h.get("value")}return undefined}},{from_config_dict:function(h){var g=c.map(c.keys(h),function(i){return{key:i,value:h[i]}});return new e(g)}});var a=Backbone.View.extend({className:"config-settings-view",render:function(){var g=this.$el;this.collection.each(function(k,p){if(k.get("hidden")){return}var j="param_"+p,q=k.get("type"),u=k.get("value");var w=$("<div class='form-row' />").appendTo(g);w.append($("<label />").attr("for",j).text(k.get("label")+":"));if(q==="bool"){w.append($('<input type="checkbox" />').attr("id",j).attr("name",j).attr("checked",u))}else{if(q==="text"){w.append($('<input type="text"/>').attr("id",j).val(u).click(function(){$(this).select()}))}else{if(q==="select"){var s=$("<select />").attr("id",j);for(var n=0;n<k.options.length;n++){$("<option/>").text(k.options[n].label).attr("value",k.options[n].value).appendTo(s)}s.val(u);w.append(s)}else{if(q==="color"){var v=$("<div/>").appendTo(w),r=$("<input />").attr("id",j).attr("name",j).val(u).css("float","left").appendTo(v).click(function(x){$(".tooltip").removeClass("in");var i=$(this).siblings(".tooltip").addClass("in");i.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top-($(i).height()/2)+($(this).height()/2)}).show();i.click(function(y){y.stopPropagation()});$(document).bind("click.color-picker",function(){i.hide();$(document).unbind("click.color-picker")});x.stopPropagation()}),o=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(v).attr("title","Set new random color").tooltip(),t=$("<div class='tooltip right' style='position: absolute;' />").appendTo(v).hide(),l=$("<div class='tooltip-inner' style='text-align: inherit'></div>").appendTo(t),h=$("<div class='tooltip-arrow'></div>").appendTo(t),m=$.farbtastic(l,{width:100,height:100,callback:r,color:u});v.append($("<div/>").css("clear","both"));(function(i){o.click(function(){i.setColor(f.get_random_color())})})(m)}else{w.append($("<input />").attr("id",j).attr("name",j).val(u))}}}}if(k.help){w.append($("<div class='help'/>").text(k.help))}});return this},render_in_modal:function(k){var g=this,j=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},h=function(){g.update_from_form();Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},i=function(l){if((l.keyCode||l.which)===27){j()}else{if((l.keyCode||l.which)===13){h()}}};$(window).bind("keypress.check_enter_esc",i);if(this.$el.children().length===0){this.render()}Galaxy.modal.show({title:k||"Configure",body:this.$el,buttons:{Cancel:j,OK:h}})},update_from_form:function(){var g=this;this.collection.each(function(i,h){if(!i.get("hidden")){var k="param_"+h;var j=g.$el.find("#"+k).val();if(i.get("type")==="bool"){j=container.find("#"+k).is(":checked")}i.set_value(j)}})}});return{ConfigSettingCollection:e,ConfigSettingCollectionView:a}}); \ No newline at end of file +define(["libs/underscore","viz/trackster/util","utils/config"],function(c,f,b){var d=Backbone.Model.extend({initialize:function(g){var h=this.get("key");this.set("id",h);var i=c.find(d.known_settings_defaults,function(j){return j.key===h});if(i){this.set(c.extend({},i,g))}if(this.get("type")==="color"&&!this.get("value")){this.set("value",f.get_random_color())}},set_value:function(h){var g=this.get("type");if(g==="float"){h=parseFloat(h)}else{if(g==="int"){h=parseInt(h,10)}}this.set("value",h)}},{known_settings_defaults:[{key:"name",label:"Name",type:"text",default_value:""},{key:"color",label:"Color",type:"color",default_value:null},{key:"min_value",label:"Min Value",type:"float",default_value:null},{key:"max_value",label:"Max Value",type:"float",default_value:null},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:32,hidden:true},{key:"pos_color",label:"Positive Color",type:"color",default_value:"#FF8C00"},{key:"neg_color",label:"Negative Color",type:"color",default_value:"#4169E1"},{key:"block_color",label:"Block color",type:"color",default_value:null},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:null},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true}]});var e=Backbone.Collection.extend({model:d,to_key_value_dict:function(){var g={};this.each(function(h){g[h.get("key")]=h.get("value")});return g},get_value:function(g){var h=this.get(g);if(h){return h.get("value")}return undefined}},{from_config_dict:function(h){var g=c.map(c.keys(h),function(i){return{key:i,value:h[i]}});return new e(g)}});var a=Backbone.View.extend({className:"config-settings-view",render:function(){var g=this.$el;this.collection.each(function(k,p){if(k.get("hidden")){return}var j="param_"+p,q=k.get("type"),u=k.get("value");var w=$("<div class='form-row' />").appendTo(g);w.append($("<label />").attr("for",j).text(k.get("label")+":"));if(q==="bool"){w.append($('<input type="checkbox" />').attr("id",j).attr("name",j).attr("checked",u))}else{if(q==="text"){w.append($('<input type="text"/>').attr("id",j).val(u).click(function(){$(this).select()}))}else{if(q==="select"){var s=$("<select />").attr("id",j);for(var n=0;n<k.options.length;n++){$("<option/>").text(k.options[n].label).attr("value",k.options[n].value).appendTo(s)}s.val(u);w.append(s)}else{if(q==="color"){var v=$("<div/>").appendTo(w),r=$("<input />").attr("id",j).attr("name",j).val(u).css("float","left").appendTo(v).click(function(x){$(".tooltip").removeClass("in");var i=$(this).siblings(".tooltip").addClass("in");i.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top-($(i).height()/2)+($(this).height()/2)}).show();i.click(function(y){y.stopPropagation()});$(document).bind("click.color-picker",function(){i.hide();$(document).unbind("click.color-picker")});x.stopPropagation()}),o=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(v).attr("title","Set new random color").tooltip(),t=$("<div class='tooltip right' style='position: absolute;' />").appendTo(v).hide(),l=$("<div class='tooltip-inner' style='text-align: inherit'></div>").appendTo(t),h=$("<div class='tooltip-arrow'></div>").appendTo(t),m=$.farbtastic(l,{width:100,height:100,callback:r,color:u});v.append($("<div/>").css("clear","both"));(function(i){o.click(function(){i.setColor(f.get_random_color())})})(m)}else{w.append($("<input />").attr("id",j).attr("name",j).val(u))}}}}if(k.help){w.append($("<div class='help'/>").text(k.help))}});return this},render_in_modal:function(k){var g=this,j=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},h=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc");g.update_from_form()},i=function(l){if((l.keyCode||l.which)===27){j()}else{if((l.keyCode||l.which)===13){h()}}};$(window).bind("keypress.check_enter_esc",i);if(this.$el.children().length===0){this.render()}Galaxy.modal.show({title:k||"Configure",body:this.$el,buttons:{Cancel:j,OK:h}})},update_from_form:function(){var g=this;this.collection.each(function(i,h){if(!i.get("hidden")){var k="param_"+h;var j=g.$el.find("#"+k).val();if(i.get("type")==="bool"){j=container.find("#"+k).is(":checked")}i.set_value(j)}})}});return{ConfigSettingCollection:e,ConfigSettingCollectionView:a}}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/utils/uploadbox.js --- a/static/scripts/packed/utils/uploadbox.js +++ b/static/scripts/packed/utils/uploadbox.js @@ -1,1 +1,1 @@ -(function(c){jQuery.event.props.push("dataTransfer");var h={url:"",paramname:"content",maxfilesize:2048,maxfilenumber:50,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 +(function(c){jQuery.event.props.push("dataTransfer");var h={url:"",paramname:"content",maxfilesize:2048,maxfilenumber:50,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}var E=f;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++}return E}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 H=E.mode;var B=1048576*a.maxfilesize;if(C<B||E.mode=="ftp"){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 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/utils/utils.js --- a/static/scripts/packed/utils/utils.js +++ b/static/scripts/packed/utils/utils.js @@ -1,1 +1,1 @@ -define(["libs/underscore"],function(c){function d(h,g,f){var i=new XMLHttpRequest();i.open("GET",h,true);i.setRequestHeader("Accept","application/json");i.setRequestHeader("Cache-Control","no-cache");i.setRequestHeader("X-Requested-With","XMLHttpRequest");i.onloadend=function(){var j=i.status;if(j==200){try{response=jQuery.parseJSON(i.responseText)}catch(k){response=i.responseText}g&&g(response)}else{f&&f(j)}};i.send()}function b(i,f){var g=$('<div class="'+i+'"></div>');g.appendTo(":eq(0)");var h=g.css(f);g.remove();return h}function a(f){if(!$('link[href^="'+f+'"]').length){$('<link href="'+galaxy_config.root+f+'" rel="stylesheet">').appendTo("head")}}function e(f,g){if(f){return c.defaults(f,g)}else{return g}}return{cssLoadFile:a,cssGetAttribute:b,jsonFromUrl:d,merge:e}}); \ No newline at end of file +define(["libs/underscore"],function(c){function f(j,i,h){var k=new XMLHttpRequest();k.open("GET",j,true);k.setRequestHeader("Accept","application/json");k.setRequestHeader("Cache-Control","no-cache");k.setRequestHeader("X-Requested-With","XMLHttpRequest");k.onloadend=function(){var l=k.status;if(l==200){try{response=jQuery.parseJSON(k.responseText)}catch(m){response=k.responseText}i&&i(response)}else{h&&h(l)}};k.send()}function b(k,h){var i=$('<div class="'+k+'"></div>');i.appendTo(":eq(0)");var j=i.css(h);i.remove();return j}function a(h){if(!$('link[href^="'+h+'"]').length){$('<link href="'+galaxy_config.root+h+'" rel="stylesheet">').appendTo("head")}}function g(h,i){if(h){return c.defaults(h,i)}else{return i}}function d(i,k){var j="";if(i>=100000000000){i=i/100000000000;j="TB"}else{if(i>=100000000){i=i/100000000;j="GB"}else{if(i>=100000){i=i/100000;j="MB"}else{if(i>=100){i=i/100;j="KB"}else{if(i>0){i=i*10;j="b"}else{return"<strong>-</strong>"}}}}}var h=(Math.round(i)/10);if(k){return h+" "+j}else{return"<strong>"+h+"</strong> "+j}}function e(){return(new Date().getTime()).toString(36)}return{cssLoadFile:a,cssGetAttribute:b,jsonFromUrl:f,merge:g,bytesToString:d,uuid:e}}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/packed/viz/circster.js --- a/static/scripts/packed/viz/circster.js +++ b/static/scripts/packed/viz/circster.js @@ -1,1 +1,1 @@ -define(["utils/utils","libs/underscore","libs/d3","viz/visualization","utils/config"],function(h,i,n,k,c){h.cssLoadFile("static/style/circster.css");var o=Backbone.Model.extend({is_visible:function(s,p){var q=s.getBoundingClientRect(),r=$("svg")[0].getBoundingClientRect();if(q.right<0||q.left>r.right||q.bottom<0||q.top>r.bottom){return false}return true}});var j={drawTicks:function(t,s,x,r,p){var w=t.append("g").selectAll("g").data(s).enter().append("g").selectAll("g").data(x).enter().append("g").attr("class","tick").attr("transform",function(y){return"rotate("+(y.angle*180/Math.PI-90)+")translate("+y.radius+",0)"});var v=[],u=[],q=function(y){return y.angle>Math.PI?"end":null};if(p){v=[0,0,0,-4];u=[4,0,"",".35em"];q=null}else{v=[1,0,4,0];u=[0,4,".35em",""]}w.append("line").attr("x1",v[0]).attr("y1",v[1]).attr("x2",v[2]).attr("y1",v[3]).style("stroke","#000");w.append("text").attr("x",u[0]).attr("y",u[1]).attr("dx",u[2]).attr("dy",u[3]).attr("text-anchor",q).attr("transform",r).text(function(y){return y.label})},formatNum:function(q,p){if(p===undefined){p=2}if(q===null){return null}var s=null;if(q<1){s=q.toPrecision(p)}else{var r=Math.round(q.toPrecision(p));if(q<1000){s=r}else{if(q<1000000){s=Math.round((r/1000).toPrecision(3)).toFixed(0)+"K"}else{if(q<1000000000){s=Math.round((r/1000000).toPrecision(3)).toFixed(0)+"M"}}}}return s}};var d=Backbone.Model.extend({});var a=Backbone.View.extend({className:"circster",initialize:function(p){this.genome=p.genome;this.track_gap=10;this.label_arc_height=50;this.scale=1;this.circular_views=null;this.chords_views=null;this.model.get("drawables").on("add",this.add_track,this);this.model.get("drawables").on("remove",this.remove_track,this);var q=this.model.get("config");q.get("arc_dataset_height").on("change:value",this.update_track_bounds,this)},get_circular_tracks:function(){return this.model.get("drawables").filter(function(p){return p.get("track_type")!=="DiagonalHeatmapTrack"})},get_chord_tracks:function(){return this.model.get("drawables").filter(function(p){return p.get("track_type")==="DiagonalHeatmapTrack"})},get_tracks_bounds:function(){var r=this.get_circular_tracks(),s=this.model.get("config").get_value("arc_dataset_height"),p=Math.min(this.$el.width(),this.$el.height()),u=p/2-r.length*(s+this.track_gap)-(this.label_arc_height+this.track_gap),t=n.range(u,p/2,s+this.track_gap);var q=this;return i.map(t,function(v){return[v,v+s]})},render:function(){var y=this,p=y.$el.width(),x=y.$el.height(),u=this.get_circular_tracks(),s=this.get_chord_tracks(),r=y.model.get("config").get_value("total_gap"),t=this.get_tracks_bounds(),q=n.select(y.$el[0]).append("svg").attr("width",p).attr("height",x).attr("pointer-events","all").append("svg:g").call(n.behavior.zoom().on("zoom",function(){var z=n.event.scale;q.attr("transform","translate("+n.event.translate+") scale("+z+")");if(y.scale!==z){if(y.zoom_drag_timeout){clearTimeout(y.zoom_drag_timeout)}y.zoom_drag_timeout=setTimeout(function(){},400)}})).attr("transform","translate("+p/2+","+x/2+")").append("svg:g").attr("class","tracks");this.circular_views=u.map(function(A,B){var z=new e({el:q.append("g")[0],track:A,radius_bounds:t[B],genome:y.genome,total_gap:r});z.render();return z});this.chords_views=s.map(function(A){var z=new l({el:q.append("g")[0],track:A,radius_bounds:t[0],genome:y.genome,total_gap:r});z.render();return z});var w=this.circular_views[this.circular_views.length-1].radius_bounds[1],v=[w,w+this.label_arc_height];this.label_track_view=new b({el:q.append("g")[0],track:new d(),radius_bounds:v,genome:y.genome,total_gap:r});this.label_track_view.render()},add_track:function(w){var q=this.model.get("config").get_value("total_gap");if(w.get("track_type")==="DiagonalHeatmapTrack"){var s=this.circular_views[0].radius_bounds,v=new l({el:n.select("g.tracks").append("g")[0],track:w,radius_bounds:s,genome:this.genome,total_gap:q});v.render();this.chords_views.push(v)}else{var u=this.get_tracks_bounds();i.each(this.circular_views,function(x,y){x.update_radius_bounds(u[y])});i.each(this.chords_views,function(x){x.update_radius_bounds(u[0])});var t=this.circular_views.length,p=new e({el:n.select("g.tracks").append("g")[0],track:w,radius_bounds:u[t],genome:this.genome,total_gap:q});p.render();this.circular_views.push(p);var r=u[u.length-1];r[1]=r[0];this.label_track_view.update_radius_bounds(r)}},remove_track:function(q,s,r){var p=this.circular_views[r.index];this.circular_views.splice(r.index,1);p.$el.remove();var t=this.get_tracks_bounds();i.each(this.circular_views,function(u,v){u.update_radius_bounds(t[v])})},update_track_bounds:function(){var p=this.get_tracks_bounds();i.each(this.circular_views,function(q,r){q.update_radius_bounds(p[r])})}});var m=Backbone.View.extend({tagName:"g",initialize:function(p){this.bg_stroke="ccc";this.loading_bg_fill="000";this.bg_fill="ccc";this.total_gap=p.total_gap;this.track=p.track;this.radius_bounds=p.radius_bounds;this.genome=p.genome;this.chroms_layout=this._chroms_layout();this.data_bounds=[];this.scale=1;this.parent_elt=n.select(this.$el[0])},get_fill_color:function(){var p=this.track.get("config").get_value("block_color");if(!p){p=this.track.get("config").get_value("color")}return p},render:function(){var t=this.parent_elt;if(!t){console.log("no parent elt")}var s=this.chroms_layout,v=n.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]),p=t.selectAll("g").data(s).enter().append("svg:g"),r=p.append("path").attr("d",v).attr("class","chrom-background").style("stroke",this.bg_stroke).style("fill",this.loading_bg_fill);r.append("title").text(function(x){return x.data.chrom});var q=this,u=q.track.get("data_manager"),w=(u?u.data_is_ready():true);$.when(w).then(function(){$.when(q._render_data(t)).then(function(){r.style("fill",q.bg_fill);q.render_labels()})})},render_labels:function(){},update_radius_bounds:function(q){this.radius_bounds=q;var p=n.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]);this.parent_elt.selectAll("g>path.chrom-background").transition().duration(1000).attr("d",p);this._transition_chrom_data();this._transition_labels()},update_scale:function(s){var r=this.scale;this.scale=s;if(s<=r){return}var q=this,p=new o();this.parent_elt.selectAll("path.chrom-data").filter(function(u,t){return p.is_visible(this)}).each(function(z,v){var y=n.select(this),u=y.attr("chrom"),x=q.genome.get_chrom_region(u),w=q.track.get("data_manager"),t;if(!w.can_get_more_detailed_data(x)){return}t=q.track.get("data_manager").get_more_detailed_data(x,"Coverage",0,s);$.when(t).then(function(C){y.remove();q._update_data_bounds();var B=i.find(q.chroms_layout,function(D){return D.data.chrom===u});var A=q.get_fill_color();q._render_chrom_data(q.parent_elt,B,C).style("stroke",A).style("fill",A)})});return q},_transition_chrom_data:function(){var q=this.track,s=this.chroms_layout,p=this.parent_elt.selectAll("g>path.chrom-data"),t=p[0].length;if(t>0){var r=this;$.when(q.get("data_manager").get_genome_wide_data(this.genome)).then(function(v){var u=i.reject(i.map(v,function(w,x){var y=null,z=r._get_path_function(s[x],w);if(z){y=z(w.data)}return y}),function(w){return w===null});p.each(function(x,w){n.select(this).transition().duration(1000).attr("d",u[w])})})}},_transition_labels:function(){},_update_data_bounds:function(){var p=this.data_bounds;this.data_bounds=this.get_data_bounds(this.track.get("data_manager").get_genome_wide_data(this.genome));if(this.data_bounds[0]<p[0]||this.data_bounds[1]>p[1]){this._transition_chrom_data()}},_render_data:function(s){var r=this,q=this.chroms_layout,p=this.track,t=$.Deferred();$.when(p.get("data_manager").get_genome_wide_data(this.genome)).then(function(v){r.data_bounds=r.get_data_bounds(v);layout_and_data=i.zip(q,v),chroms_data_layout=i.map(layout_and_data,function(w){var x=w[0],y=w[1];return r._render_chrom_data(s,x,y)});var u=r.get_fill_color();r.parent_elt.selectAll("path.chrom-data").style("stroke",u).style("fill",u);t.resolve(s)});return t},_render_chrom_data:function(p,q,r){},_get_path_function:function(q,p){},_chroms_layout:function(){var q=this.genome.get_chroms_info(),s=n.layout.pie().value(function(u){return u.len}).sort(null),t=s(q),p=2*Math.PI*this.total_gap/q.length,r=i.map(t,function(w,v){var u=w.endAngle-p;w.endAngle=(u>w.startAngle?u:w.startAngle);return w});return r}});var b=m.extend({initialize:function(p){m.prototype.initialize.call(this,p);this.innerRadius=this.radius_bounds[0];this.radius_bounds[0]=this.radius_bounds[1];this.bg_stroke="fff";this.bg_fill="fff";this.min_arc_len=0.05},_render_data:function(r){var q=this,p=r.selectAll("g");p.selectAll("path").attr("id",function(v){return"label-"+v.data.chrom});p.append("svg:text").filter(function(v){return v.endAngle-v.startAngle>q.min_arc_len}).attr("text-anchor","middle").append("svg:textPath").attr("class","chrom-label").attr("xlink:href",function(v){return"#label-"+v.data.chrom}).attr("startOffset","25%").text(function(v){return v.data.chrom});var s=function(x){var v=(x.endAngle-x.startAngle)/x.value,w=n.range(0,x.value,25000000).map(function(y,z){return{radius:q.innerRadius,angle:y*v+x.startAngle,label:z===0?0:(z%3?null:q.formatNum(y))}});if(w.length<4){w[w.length-1].label=q.formatNum(Math.round((w[w.length-1].angle-x.startAngle)/v))}return w};var u=function(v){return v.angle>Math.PI?"rotate(180)translate(-16)":null};var t=i.filter(this.chroms_layout,function(v){return v.endAngle-v.startAngle>q.min_arc_len});this.drawTicks(this.parent_elt,t,s,u)}});i.extend(b.prototype,j);var g=m.extend({_quantile:function(q,p){q.sort(n.ascending);return n.quantile(q,p)},_render_chrom_data:function(p,s,q){var t=this._get_path_function(s,q);if(!t){return null}var r=p.datum(q.data),u=r.append("path").attr("class","chrom-data").attr("chrom",s.data.chrom).attr("d",t);return u},_get_path_function:function(s,r){if(typeof r==="string"||!r.data||r.data.length===0){return null}var p=n.scale.linear().domain(this.data_bounds).range(this.radius_bounds).clamp(true);var t=n.scale.linear().domain([0,r.data.length]).range([s.startAngle,s.endAngle]);var q=n.svg.line.radial().interpolate("linear").radius(function(u){return p(u[1])}).angle(function(v,u){return t(u)});return n.svg.area.radial().interpolate(q.interpolate()).innerRadius(p(0)).outerRadius(q.radius()).angle(q.angle())},render_labels:function(){var p=this,q=function(){return"rotate(90)"};this.drawTicks(this.parent_elt,[this.chroms_layout[0]],this._data_bounds_ticks_fn(),q,true)},_transition_labels:function(){if(this.data_bounds.length===0){return}var q=this,s=i.filter(this.chroms_layout,function(t){return t.endAngle-t.startAngle>0.08}),r=i.filter(s,function(u,t){return t%3===0}),p=i.flatten(i.map(r,function(t){return q._data_bounds_ticks_fn()(t)}));this.parent_elt.selectAll("g.tick").data(p).transition().attr("transform",function(t){return"rotate("+(t.angle*180/Math.PI-90)+")translate("+t.radius+",0)"})},_data_bounds_ticks_fn:function(){var p=this;visibleChroms=0;return function(q){return[{radius:p.radius_bounds[0],angle:q.startAngle,label:p.formatNum(p.data_bounds[0])},{radius:p.radius_bounds[1],angle:q.startAngle,label:p.formatNum(p.data_bounds[1])}]}},get_data_bounds:function(p){}});i.extend(g.prototype,j);var e=g.extend({get_data_bounds:function(q){var p=i.flatten(i.map(q,function(r){if(r){return i.map(r.data,function(s){return parseInt(s[1],10)||0})}else{return 0}}));return[i.min(p),this._quantile(p,0.98)||i.max(p)]}});var l=m.extend({render:function(){var p=this;$.when(p.track.get("data_manager").data_is_ready()).then(function(){$.when(p.track.get("data_manager").get_genome_wide_data(p.genome)).then(function(s){var r=[],q=p.genome.get_chroms_info();i.each(s,function(w,v){var t=q[v].chrom;var u=i.map(w.data,function(y){var x=p._get_region_angle(t,y[1]),z=p._get_region_angle(y[3],y[4]);return{source:{startAngle:x,endAngle:x+0.01},target:{startAngle:z,endAngle:z+0.01}}});r=r.concat(u)});p.parent_elt.append("g").attr("class","chord").selectAll("path").data(r).enter().append("path").style("fill",p.get_fill_color()).attr("d",n.svg.chord().radius(p.radius_bounds[0])).style("opacity",1)})})},update_radius_bounds:function(p){this.radius_bounds=p;this.parent_elt.selectAll("path").transition().attr("d",n.svg.chord().radius(this.radius_bounds[0]))},_get_region_angle:function(r,p){var q=i.find(this.chroms_layout,function(s){return s.data.chrom===r});return q.endAngle-((q.endAngle-q.startAngle)*(q.data.len-p)/q.data.len)}});var f=Backbone.View.extend({initialize:function(){var p=new k.Genome(galaxy_config.app.genome),q=new k.GenomeVisualization(galaxy_config.app.viz_config);q.get("config").add([{key:"arc_dataset_height",label:"Arc Dataset Height",type:"int",value:25,view:"circster"},{key:"total_gap",label:"Gap [0-1]",type:"float",value:0.4,view:"circster",hidden:true}]);var s=new a({el:$("#center .unified-panel-body"),genome:p,model:q});s.render();$("#center .unified-panel-header-inner").append(galaxy_config.app.viz_config.title+" "+galaxy_config.app.viz_config.dbkey);var r=create_icon_buttons_menu([{icon_class:"plus-button",title:"Add tracks",on_click:function(){k.select_datasets(galaxy_config.root+"visualization/list_current_history_datasets",galaxy_config.root+"api/datasets",q.get("dbkey"),function(t){q.add_tracks(t)})}},{icon_class:"gear",title:"Settings",on_click:function(){var t=new c.ConfigSettingCollectionView({collection:q.get("config")});t.render_in_modal("Configure Visualization")}},{icon_class:"disk--arrow",title:"Save",on_click:function(){Galaxy.modal.show({title:"Saving...",body:"progress"});$.ajax({url:galaxy_config.root+"visualization/save",type:"POST",dataType:"json",data:{id:q.get("vis_id"),title:q.get("title"),dbkey:q.get("dbkey"),type:"trackster",vis_json:JSON.stringify(q)}}).success(function(t){Galaxy.modal.hide();q.set("vis_id",t.vis_id)}).error(function(){Galaxy.modal.show({title:"Could Not Save",body:"Could not save visualization. Please try again later.",buttons:{Cancel:function(){Galaxy.modal.hide()}}})})}},{icon_class:"cross-circle",title:"Close",on_click:function(){window.location=galaxy_config.root+"visualization/list"}}],{tooltip_config:{placement:"bottom"}});r.$el.attr("style","float: right");$("#center .unified-panel-header-inner").append(r.$el);$(".menu-button").tooltip({placement:"bottom"})}});return{GalaxyApp:f}}); \ No newline at end of file +define(["utils/utils","libs/underscore","libs/d3","viz/visualization","utils/config"],function(h,i,n,k,c){h.cssLoadFile("static/style/circster.css");var o=Backbone.Model.extend({is_visible:function(s,p){var q=s.getBoundingClientRect(),r=$("svg")[0].getBoundingClientRect();if(q.right<0||q.left>r.right||q.bottom<0||q.top>r.bottom){return false}return true}});var j={drawTicks:function(t,s,x,r,p){var w=t.append("g").selectAll("g").data(s).enter().append("g").selectAll("g").data(x).enter().append("g").attr("class","tick").attr("transform",function(y){return"rotate("+(y.angle*180/Math.PI-90)+")translate("+y.radius+",0)"});var v=[],u=[],q=function(y){return y.angle>Math.PI?"end":null};if(p){v=[0,0,0,-4];u=[4,0,"",".35em"];q=null}else{v=[1,0,4,0];u=[0,4,".35em",""]}w.append("line").attr("x1",v[0]).attr("y1",v[1]).attr("x2",v[2]).attr("y1",v[3]).style("stroke","#000");w.append("text").attr("x",u[0]).attr("y",u[1]).attr("dx",u[2]).attr("dy",u[3]).attr("text-anchor",q).attr("transform",r).text(function(y){return y.label})},formatNum:function(q,p){if(p===undefined){p=2}if(q===null){return null}var s=null;if(q<1){s=q.toPrecision(p)}else{var r=Math.round(q.toPrecision(p));if(q<1000){s=r}else{if(q<1000000){s=Math.round((r/1000).toPrecision(3)).toFixed(0)+"K"}else{if(q<1000000000){s=Math.round((r/1000000).toPrecision(3)).toFixed(0)+"M"}}}}return s}};var d=Backbone.Model.extend({});var a=Backbone.View.extend({className:"circster",initialize:function(p){this.genome=p.genome;this.label_arc_height=50;this.scale=1;this.circular_views=null;this.chords_views=null;this.model.get("drawables").on("add",this.add_track,this);this.model.get("drawables").on("remove",this.remove_track,this);var q=this.model.get("config");q.get("arc_dataset_height").on("change:value",this.update_track_bounds,this);q.get("track_gap").on("change:value",this.update_track_bounds,this)},get_circular_tracks:function(){return this.model.get("drawables").filter(function(p){return p.get("track_type")!=="DiagonalHeatmapTrack"})},get_chord_tracks:function(){return this.model.get("drawables").filter(function(p){return p.get("track_type")==="DiagonalHeatmapTrack"})},get_tracks_bounds:function(){var r=this.get_circular_tracks(),t=this.model.get("config").get_value("arc_dataset_height"),s=this.model.get("config").get_value("track_gap"),p=Math.min(this.$el.width(),this.$el.height())-20,v=p/2-r.length*(t+s)+s-this.label_arc_height,u=n.range(v,p/2,t+s);var q=this;return i.map(u,function(w){return[w,w+t]})},render:function(){var y=this,p=y.$el.width(),x=y.$el.height(),u=this.get_circular_tracks(),s=this.get_chord_tracks(),r=y.model.get("config").get_value("total_gap"),t=this.get_tracks_bounds(),q=n.select(y.$el[0]).append("svg").attr("width",p).attr("height",x).attr("pointer-events","all").append("svg:g").call(n.behavior.zoom().on("zoom",function(){var z=n.event.scale;q.attr("transform","translate("+n.event.translate+") scale("+z+")");if(y.scale!==z){if(y.zoom_drag_timeout){clearTimeout(y.zoom_drag_timeout)}y.zoom_drag_timeout=setTimeout(function(){},400)}})).attr("transform","translate("+p/2+","+x/2+")").append("svg:g").attr("class","tracks");this.circular_views=u.map(function(A,B){var z=new e({el:q.append("g")[0],track:A,radius_bounds:t[B],genome:y.genome,total_gap:r});z.render();return z});this.chords_views=s.map(function(A){var z=new l({el:q.append("g")[0],track:A,radius_bounds:t[0],genome:y.genome,total_gap:r});z.render();return z});var w=this.circular_views[this.circular_views.length-1].radius_bounds[1],v=[w,w+this.label_arc_height];this.label_track_view=new b({el:q.append("g")[0],track:new d(),radius_bounds:v,genome:y.genome,total_gap:r});this.label_track_view.render()},add_track:function(v){var q=this.model.get("config").get_value("total_gap");if(v.get("track_type")==="DiagonalHeatmapTrack"){var r=this.circular_views[0].radius_bounds,u=new l({el:n.select("g.tracks").append("g")[0],track:v,radius_bounds:r,genome:this.genome,total_gap:q});u.render();this.chords_views.push(u)}else{var t=this.get_tracks_bounds();i.each(this.circular_views,function(w,x){w.update_radius_bounds(t[x])});i.each(this.chords_views,function(w){w.update_radius_bounds(t[0])});var s=this.circular_views.length,p=new e({el:n.select("g.tracks").append("g")[0],track:v,radius_bounds:t[s],genome:this.genome,total_gap:q});p.render();this.circular_views.push(p)}},remove_track:function(q,s,r){var p=this.circular_views[r.index];this.circular_views.splice(r.index,1);p.$el.remove();var t=this.get_tracks_bounds();i.each(this.circular_views,function(u,v){u.update_radius_bounds(t[v])})},update_track_bounds:function(){var p=this.get_tracks_bounds();i.each(this.circular_views,function(q,r){q.update_radius_bounds(p[r])});i.each(this.chords_views,function(q){q.update_radius_bounds(p[0])})}});var m=Backbone.View.extend({tagName:"g",initialize:function(p){this.bg_stroke="ddd";this.loading_bg_fill="ffc";this.bg_fill="ddd";this.total_gap=p.total_gap;this.track=p.track;this.radius_bounds=p.radius_bounds;this.genome=p.genome;this.chroms_layout=this._chroms_layout();this.data_bounds=[];this.scale=1;this.parent_elt=n.select(this.$el[0])},get_fill_color:function(){var p=this.track.get("config").get_value("block_color");if(!p){p=this.track.get("config").get_value("color")}return p},render:function(){var t=this.parent_elt;if(!t){console.log("no parent elt")}var s=this.chroms_layout,v=n.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]),p=t.selectAll("g").data(s).enter().append("svg:g"),r=p.append("path").attr("d",v).attr("class","chrom-background").style("stroke",this.bg_stroke).style("fill",this.loading_bg_fill);r.append("title").text(function(x){return x.data.chrom});var q=this,u=q.track.get("data_manager"),w=(u?u.data_is_ready():true);$.when(w).then(function(){$.when(q._render_data(t)).then(function(){r.style("fill",q.bg_fill);q.render_labels()})})},render_labels:function(){},update_radius_bounds:function(q){this.radius_bounds=q;var p=n.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]);this.parent_elt.selectAll("g>path.chrom-background").transition().duration(1000).attr("d",p);this._transition_chrom_data();this._transition_labels()},update_scale:function(s){var r=this.scale;this.scale=s;if(s<=r){return}var q=this,p=new o();this.parent_elt.selectAll("path.chrom-data").filter(function(u,t){return p.is_visible(this)}).each(function(z,v){var y=n.select(this),u=y.attr("chrom"),x=q.genome.get_chrom_region(u),w=q.track.get("data_manager"),t;if(!w.can_get_more_detailed_data(x)){return}t=q.track.get("data_manager").get_more_detailed_data(x,"Coverage",0,s);$.when(t).then(function(C){y.remove();q._update_data_bounds();var B=i.find(q.chroms_layout,function(D){return D.data.chrom===u});var A=q.get_fill_color();q._render_chrom_data(q.parent_elt,B,C).style("stroke",A).style("fill",A)})});return q},_transition_chrom_data:function(){var q=this.track,s=this.chroms_layout,p=this.parent_elt.selectAll("g>path.chrom-data"),t=p[0].length;if(t>0){var r=this;$.when(q.get("data_manager").get_genome_wide_data(this.genome)).then(function(v){var u=i.reject(i.map(v,function(w,x){var y=null,z=r._get_path_function(s[x],w);if(z){y=z(w.data)}return y}),function(w){return w===null});p.each(function(x,w){n.select(this).transition().duration(1000).attr("d",u[w])})})}},_transition_labels:function(){},_update_data_bounds:function(){var p=this.data_bounds;this.data_bounds=this.get_data_bounds(this.track.get("data_manager").get_genome_wide_data(this.genome));if(this.data_bounds[0]<p[0]||this.data_bounds[1]>p[1]){this._transition_chrom_data()}},_render_data:function(s){var r=this,q=this.chroms_layout,p=this.track,t=$.Deferred();$.when(p.get("data_manager").get_genome_wide_data(this.genome)).then(function(v){r.data_bounds=r.get_data_bounds(v);layout_and_data=i.zip(q,v),chroms_data_layout=i.map(layout_and_data,function(w){var x=w[0],y=w[1];return r._render_chrom_data(s,x,y)});var u=r.get_fill_color();r.parent_elt.selectAll("path.chrom-data").style("stroke",u).style("fill",u);t.resolve(s)});return t},_render_chrom_data:function(p,q,r){},_get_path_function:function(q,p){},_chroms_layout:function(){var q=this.genome.get_chroms_info(),s=n.layout.pie().value(function(u){return u.len}).sort(null),t=s(q),p=2*Math.PI*this.total_gap/q.length,r=i.map(t,function(w,v){var u=w.endAngle-p;w.endAngle=(u>w.startAngle?u:w.startAngle);return w});return r}});var b=m.extend({initialize:function(p){m.prototype.initialize.call(this,p);this.innerRadius=this.radius_bounds[0];this.radius_bounds[0]=this.radius_bounds[1];this.bg_stroke="fff";this.bg_fill="fff";this.min_arc_len=0.05},_render_data:function(r){var q=this,p=r.selectAll("g");p.selectAll("path").attr("id",function(v){return"label-"+v.data.chrom});p.append("svg:text").filter(function(v){return v.endAngle-v.startAngle>q.min_arc_len}).attr("text-anchor","middle").append("svg:textPath").attr("class","chrom-label").attr("xlink:href",function(v){return"#label-"+v.data.chrom}).attr("startOffset","25%").text(function(v){return v.data.chrom});var s=function(x){var v=(x.endAngle-x.startAngle)/x.value,w=n.range(0,x.value,25000000).map(function(y,z){return{radius:q.innerRadius,angle:y*v+x.startAngle,label:z===0?0:(z%3?null:q.formatNum(y))}});if(w.length<4){w[w.length-1].label=q.formatNum(Math.round((w[w.length-1].angle-x.startAngle)/v))}return w};var u=function(v){return v.angle>Math.PI?"rotate(180)translate(-16)":null};var t=i.filter(this.chroms_layout,function(v){return v.endAngle-v.startAngle>q.min_arc_len});this.drawTicks(this.parent_elt,t,s,u)}});i.extend(b.prototype,j);var g=m.extend({_quantile:function(q,p){q.sort(n.ascending);return n.quantile(q,p)},_render_chrom_data:function(p,s,q){var t=this._get_path_function(s,q);if(!t){return null}var r=p.datum(q.data),u=r.append("path").attr("class","chrom-data").attr("chrom",s.data.chrom).attr("d",t);return u},_get_path_function:function(s,r){if(typeof r==="string"||!r.data||r.data.length===0){return null}var p=n.scale.linear().domain(this.data_bounds).range(this.radius_bounds).clamp(true);var t=n.scale.linear().domain([0,r.data.length]).range([s.startAngle,s.endAngle]);var q=n.svg.line.radial().interpolate("linear").radius(function(u){return p(u[1])}).angle(function(v,u){return t(u)});return n.svg.area.radial().interpolate(q.interpolate()).innerRadius(p(0)).outerRadius(q.radius()).angle(q.angle())},render_labels:function(){var p=this,q=function(){return"rotate(90)"};this.drawTicks(this.parent_elt,[this.chroms_layout[0]],this._data_bounds_ticks_fn(),q,true)},_transition_labels:function(){if(this.data_bounds.length===0){return}var q=this,s=i.filter(this.chroms_layout,function(t){return t.endAngle-t.startAngle>0.08}),r=i.filter(s,function(u,t){return t%3===0}),p=i.flatten(i.map(r,function(t){return q._data_bounds_ticks_fn()(t)}));this.parent_elt.selectAll("g.tick").data(p).transition().attr("transform",function(t){return"rotate("+(t.angle*180/Math.PI-90)+")translate("+t.radius+",0)"})},_data_bounds_ticks_fn:function(){var p=this;visibleChroms=0;return function(q){return[{radius:p.radius_bounds[0],angle:q.startAngle,label:p.formatNum(p.data_bounds[0])},{radius:p.radius_bounds[1],angle:q.startAngle,label:p.formatNum(p.data_bounds[1])}]}},get_data_bounds:function(p){}});i.extend(g.prototype,j);var e=g.extend({get_data_bounds:function(q){var p=i.flatten(i.map(q,function(r){if(r){return i.map(r.data,function(s){return parseInt(s[1],10)||0})}else{return 0}}));return[i.min(p),this._quantile(p,0.5)||i.max(p)]}});var l=m.extend({render:function(){var p=this;$.when(p.track.get("data_manager").data_is_ready()).then(function(){$.when(p.track.get("data_manager").get_genome_wide_data(p.genome)).then(function(s){var r=[],q=p.genome.get_chroms_info();i.each(s,function(w,v){var t=q[v].chrom;var u=i.map(w.data,function(y){var x=p._get_region_angle(t,y[1]),z=p._get_region_angle(y[3],y[4]);return{source:{startAngle:x,endAngle:x+0.01},target:{startAngle:z,endAngle:z+0.01}}});r=r.concat(u)});p.parent_elt.append("g").attr("class","chord").selectAll("path").data(r).enter().append("path").style("fill",p.get_fill_color()).attr("d",n.svg.chord().radius(p.radius_bounds[0])).style("opacity",1)})})},update_radius_bounds:function(p){this.radius_bounds=p;this.parent_elt.selectAll("path").transition().attr("d",n.svg.chord().radius(this.radius_bounds[0]))},_get_region_angle:function(r,p){var q=i.find(this.chroms_layout,function(s){return s.data.chrom===r});return q.endAngle-((q.endAngle-q.startAngle)*(q.data.len-p)/q.data.len)}});var f=Backbone.View.extend({initialize:function(){var p=new k.Genome(galaxy_config.app.genome),q=new k.GenomeVisualization(galaxy_config.app.viz_config);q.get("config").add([{key:"arc_dataset_height",label:"Arc Dataset Height",type:"int",value:25,view:"circster"},{key:"track_gap",label:"Gap Between Tracks",type:"int",value:5,view:"circster"},{key:"total_gap",label:"Gap [0-1]",type:"float",value:0.4,view:"circster",hidden:true}]);var s=new a({el:$("#center .unified-panel-body"),genome:p,model:q});s.render();$("#center .unified-panel-header-inner").append(galaxy_config.app.viz_config.title+" "+galaxy_config.app.viz_config.dbkey);var r=create_icon_buttons_menu([{icon_class:"plus-button",title:"Add tracks",on_click:function(){k.select_datasets(galaxy_config.root+"visualization/list_current_history_datasets",galaxy_config.root+"api/datasets",q.get("dbkey"),function(t){q.add_tracks(t)})}},{icon_class:"gear",title:"Settings",on_click:function(){var t=new c.ConfigSettingCollectionView({collection:q.get("config")});t.render_in_modal("Configure Visualization")}},{icon_class:"disk--arrow",title:"Save",on_click:function(){Galaxy.modal.show({title:"Saving...",body:"progress"});$.ajax({url:galaxy_config.root+"visualization/save",type:"POST",dataType:"json",data:{id:q.get("vis_id"),title:q.get("title"),dbkey:q.get("dbkey"),type:"trackster",vis_json:JSON.stringify(q)}}).success(function(t){Galaxy.modal.hide();q.set("vis_id",t.vis_id)}).error(function(){Galaxy.modal.show({title:"Could Not Save",body:"Could not save visualization. Please try again later.",buttons:{Cancel:function(){Galaxy.modal.hide()}}})})}},{icon_class:"cross-circle",title:"Close",on_click:function(){window.location=galaxy_config.root+"visualization/list"}}],{tooltip_config:{placement:"bottom"}});r.$el.attr("style","float: right");$("#center .unified-panel-header-inner").append(r.$el);$(".menu-button").tooltip({placement:"bottom"})}});return{GalaxyApp:f}}); \ No newline at end of file
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/utils/uploadbox.js --- a/static/scripts/utils/uploadbox.js +++ b/static/scripts/utils/uploadbox.js @@ -123,6 +123,10 @@ if (queue_running) return;
+ // backup queue index + var current_index = queue_index; + + // add files to queue for (var i = 0; i < files.length; i++) { // check @@ -136,11 +140,14 @@ queue[index] = files[i];
// announce - opts.announce(index, queue[index], ""); + opts.announce(index, queue[index], '');
// increase counter queue_length++; } + + // return + return current_index; }
// remove entry from queue @@ -183,12 +190,15 @@ // remove from queue remove(index)
+ // collect file details + var filesize = file.size; + var filemode = file.mode; + // identify maximum file size - var filesize = file.size; var maxfilesize = 1048576 * opts.maxfilesize;
- // check file size - if (filesize < maxfilesize) + // check file size, unless its an ftp file + if (filesize < maxfilesize || file.mode == 'ftp') { // get parameters var data = opts.initialize(index, file);
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/scripts/utils/utils.js --- a/static/scripts/utils/utils.js +++ b/static/scripts/utils/utils.js @@ -71,12 +71,39 @@ return optionsDefault; };
+// to string +function bytesToString (size, normal_font) { + // 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 + var rounded = (Math.round(size) / 10); + if (normal_font) { + return rounded + ' ' + unit; + } else { + return '<strong>' + rounded + '</strong> ' + unit; + } +}; + +// unique ide +function uuid(){ + return (new Date().getTime()).toString(36); +}; + // return return { cssLoadFile : cssLoadFile, cssGetAttribute : cssGetAttribute, jsonFromUrl : jsonFromUrl, - merge : merge + merge : merge, + bytesToString: bytesToString, + uuid: uuid };
});
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1250,26 +1250,34 @@ .galaxy-frame .frame .f-close{right:5px;top:3px} .galaxy-frame .frame .f-pin{left:6px;top:3px} .galaxy-frame .frame .f-resize{background:#fff;width:16px;height:16px;color:#2c3143;right:0px;bottom:0px;text-align:center;line-height:16px;border:0px} -.progress-button{position:relative;width:31px;height:21px;top:-4px;cursor:pointer;-moz-border-radius:3px;border-radius:3px}.progress-button .progress{height:21px} -.progress-button .progress-bar-danger{background:#f9c7c5} -.progress-button .progress-bar-success{background:#aff1af} -.progress-button .progress-bar-info{background:#ffc} -.progress-button .progress-bar-notransition{-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none} -.progress-button .label{position:absolute;top:2px;width:inherit;text-align:center;line-height:19px;font-size:1.2em} +.upload-button{position:relative;width:31px;height:21px;top:-4px;cursor:pointer;-moz-border-radius:3px;border-radius:3px}.upload-button .progress{height:21px} +.upload-button .progress-bar-danger{background:#f9c7c5} +.upload-button .progress-bar-success{background:#aff1af} +.upload-button .progress-bar-info{background:#ffc} +.upload-button .progress-bar-notransition{-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none} +.upload-button .label{position:absolute;top:2px;width:inherit;text-align:center;line-height:19px;font-size:1.2em} +.upload-icon{font-size:1.2em;width:1.2em} +.upload-icon-button{font-size:1.2em;width:1.2em;cursor:pointer} .upload-info{font-weight:normal;text-align:center} .upload-box{width:100%;height:95%;text-align:center;overflow:scroll;font-size:12px;line-height:1.33;-moz-border-radius:5px;border-radius:5px;border:1px dashed #bfbfbf;padding:10px;overflow-x:hidden;-ms-overflow-style:none}.upload-box .popover{max-width:500px;width:auto} .upload-box .table{width:100%} .upload-box .table th{text-align:center;white-space:nowrap} .upload-box .table td{margin:0px;paddign:0px} -.upload-box .title{width:130px;word-wrap:break-word;font-size:11px} +.upload-box .mode{float:left;font-size:1.2em;width:1.2em;color:#555} +.upload-box .title{width:130px;word-wrap:break-word;font-size:11px;float:left} .upload-box .text{position:absolute;display:none}.upload-box .text .text-content{font-size:11px;width:100%;height:50px;resize:none;background:inherit;color:#000} .upload-box .text .text-info{font-size:11px} .upload-box .extension{width:100px;font-size:11px} .upload-box .genome{width:150px;font-size:11px} .upload-box .size{width:60px;white-space:nowrap} -.upload-box .info{width:130px;font-size:11px}.upload-box .info .progress{top:1px;position:relative;width:100%;padding:0px;margin:0px}.upload-box .info .progress .progress-bar{border-radius:inherit;-moz-border-radius:inherit} +.upload-box .info{width:130px;font-size:11px;line-height:1.2em}.upload-box .info .progress{top:1px;position:relative;width:100%;padding:0px;margin:0px;line-height:1.55em}.upload-box .info .progress .progress-bar{border-radius:inherit;-moz-border-radius:inherit} .upload-box .info .progress .percentage{position:absolute;text-align:center;width:100%;color:#fff} -.upload-box .symbol{font-size:1.2em;cursor:pointer} +.upload-ftp{height:250px;width:500px;overflow:auto}.upload-ftp .upload-ftp-wait{font-size:1.2em;position:absolute;bottom:10px;right:10px} +.upload-ftp .upload-ftp-help{margin-bottom:10px} +.upload-ftp .upload-ftp-warning{text-align:center;margin-top:20px} +.upload-settings .upload-settings-cover{position:absolute;width:100%;height:100%;top:0px;left:0px;background:#fff;opacity:0.4;cursor:no-drop} +.popover-view{max-width:700px;display:none}.popover-view .popover-close{position:absolute;right:10px;top:7px;font-size:1.2em;cursor:pointer} +.popover-view .popover-title{padding:4px 10px} .libraryRow{background-color:#ebd9b2} .datasetHighlighted{background-color:#f9f9f9} .libraryItemDeleted-True{font-style:italic}
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/style/src/less/base.less --- a/static/style/src/less/base.less +++ b/static/style/src/less/base.less @@ -23,6 +23,7 @@ // galaxy sub-components @import "frame.less"; @import "upload.less"; +@import "ui.less"; @import "library.less"; @import "toastr.less";
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/style/src/less/ui.less --- /dev/null +++ b/static/style/src/less/ui.less @@ -0,0 +1,16 @@ +.popover-view { + max-width: 700px; + display: none; + + .popover-close { + position: absolute; + right: 10px; + top: 7px; + font-size: 1.2em; + cursor: pointer; + } + + .popover-title { + padding: 4px 10px; + } +}
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 static/style/src/less/upload.less --- a/static/style/src/less/upload.less +++ b/static/style/src/less/upload.less @@ -1,4 +1,4 @@ -.progress-button { +.upload-button { position: relative; width: 31px; height: 21px; @@ -41,6 +41,17 @@ } }
+.upload-icon { + font-size: 1.2em; + width: 1.2em; +} + +.upload-icon-button { + font-size: 1.2em; + width: 1.2em; + cursor: pointer; +} + .upload-info { font-weight: normal; text-align: center; @@ -79,10 +90,18 @@ paddign: 0px; }
+ .mode { + float: left; + font-size: 1.2em; + width: 1.2em; + color: @gray; + } + .title { width: 130px; word-wrap: break-word; font-size : @font-size-small; + float: left; }
.text { @@ -122,6 +141,7 @@ .info { width: 130px; font-size : @font-size-small; + line-height: 1.2em;
.progress { top:1px; @@ -129,7 +149,8 @@ width: 100%; padding: 0px; margin: 0px; - + line-height: 1.55em; + .progress-bar { border-radius: inherit; -moz-border-radius: inherit; @@ -143,9 +164,40 @@ } } } +} + +.upload-ftp { + height: 250px; + width: 500px; + overflow: auto;
- .symbol { + .upload-ftp-wait { font-size: 1.2em; - cursor: pointer; + position: absolute; + bottom: 10px; + right: 10px; + } + + .upload-ftp-help { + margin-bottom: 10px; + } + + .upload-ftp-warning { + text-align: center; + margin-top: 20px; } } + + +.upload-settings { + .upload-settings-cover { + position: absolute; + width: 100%; + height: 100%; + top: 0px; + left: 0px; + background: @white; + opacity: 0.4; + cursor: no-drop; + } +}
diff -r 21c6fe1aec03c44a4fd9abbc2267bec5b29611d5 -r d8fcf33cbe4ac5e1129c674b1807675b2c02ccc6 templates/webapps/galaxy/galaxy.masthead.mako --- a/templates/webapps/galaxy/galaxy.masthead.mako +++ b/templates/webapps/galaxy/galaxy.masthead.mako @@ -52,6 +52,8 @@ 'logo_url' : h.url_for(app.config.get( 'logo_url', '/')), 'is_admin_user' : trans.user and app.config.is_admin_user(trans.user), 'active_view' : active_view, + 'ftp_upload_dir' : app.config.get("ftp_upload_dir", None), + 'ftp_upload_site' : app.config.get("ftp_upload_site", None),
## user details 'user' : {
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.
galaxy-commits@lists.galaxyproject.org