commit/galaxy-central: guerler: Ui: Add portlet to ui library and use it in charts app
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/86f8a8311fec/ Changeset: 86f8a8311fec User: guerler Date: 2014-02-21 02:09:44 Summary: Ui: Add portlet to ui library and use it in charts app Affected #: 29 files diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/app.js --- a/config/plugins/visualizations/charts/static/app.js +++ b/config/plugins/visualizations/charts/static/app.js @@ -1,7 +1,7 @@ // dependencies -define(['library/portlet', 'library/ui', 'library/utils', - 'views/charts', 'views/viewport', 'views/chart', 'views/group', - 'models/config', 'models/datasets', 'models/chart', 'models/charts', 'models/group', 'models/types'], +define(['mvc/ui/ui-portlet', 'plugin/library/ui', 'utils/utils', + 'plugin/views/charts', 'plugin/views/viewport', 'plugin/views/chart', 'plugin/views/group', + 'plugin/models/config', 'plugin/models/datasets', 'plugin/models/chart', 'plugin/models/charts', 'plugin/models/group', 'plugin/models/types'], function( Portlet, Ui, Utils, ChartsView, ViewportView, ChartView, GroupView, Config, Datasets, Chart, Charts, Group, Types @@ -42,7 +42,7 @@ // create portlet if (!this.options.config.widget) { - this.portlet = new Portlet({icon : 'fa-bar-chart-o', label : 'Charts'}); + this.portlet = new Portlet.View({icon : 'fa-bar-chart-o', label : 'Charts'}); } else { this.portlet = $('<div></div>'); } diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/charts/horizontal.js --- a/config/plugins/visualizations/charts/static/charts/horizontal.js +++ b/config/plugins/visualizations/charts/static/charts/horizontal.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // widget return Backbone.View.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/charts/line.js --- a/config/plugins/visualizations/charts/static/charts/line.js +++ b/config/plugins/visualizations/charts/static/charts/line.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // widget return Backbone.View.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/charts/linewithfocus.js --- a/config/plugins/visualizations/charts/static/charts/linewithfocus.js +++ b/config/plugins/visualizations/charts/static/charts/linewithfocus.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // widget return Backbone.View.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/charts/piechart.js --- a/config/plugins/visualizations/charts/static/charts/piechart.js +++ b/config/plugins/visualizations/charts/static/charts/piechart.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // widget return Backbone.View.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/charts/scatterplot.js --- a/config/plugins/visualizations/charts/static/charts/scatterplot.js +++ b/config/plugins/visualizations/charts/static/charts/scatterplot.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // widget return Backbone.View.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/charts/stackedarea.js --- a/config/plugins/visualizations/charts/static/charts/stackedarea.js +++ b/config/plugins/visualizations/charts/static/charts/stackedarea.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // widget return Backbone.View.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/library/portlet.js --- a/config/plugins/visualizations/charts/static/library/portlet.js +++ /dev/null @@ -1,171 +0,0 @@ -// dependencies -define(['library/utils'], function(Utils) { - -// return -return Backbone.View.extend( -{ - // visibility - visible: false, - - // defaults options - optionsDefault: { - label : '', - icon : 'fa-tasks', - buttons : null, - body : null, - height : null, - operations : null, - placement : 'bottom', - overflow : 'auto' - }, - - // content - $content : null, - - // initialize - initialize : function(options) { - // configure options - this.options = Utils.merge(options, this.optionsDefault); - - // create new element - this.setElement(this.template(this.options)); - - // link content - this.$content = this.$el.find('#content'); - - // set content height - if (this.options.height) { - this.$el.find('#body').css('height', this.options.height); - this.$el.find('#content').css('overflow', this.options.overflow); - } - - // append buttons - this.$buttons = $(this.el).find('#buttons'); - if (this.options.buttons) { - // link functions - var self = this; - $.each(this.options.buttons, function(name, item) { - item.$el.prop('id', name); - self.$buttons.append(item.$el); - }); - } else { - this.$buttons.remove(); - } - - // append operations - this.$operations = $(this.el).find('#operations'); - if (this.options.operations) { - // link functions - var self = this; - $.each(this.options.operations, function(name, item) { - item.$el.prop('id', name); - self.$operations.append(item.$el); - }); - } - - // add body - if(this.options.body) { - this.append(this.options.body); - } - }, - - // append - append: function($el) { - this.$content.append(Utils.wrap($el)); - }, - - // content - content: function() { - return this.$content; - }, - - // hide modal - show: function(){ - // fade in - this.$el.fadeIn('fast'); - - // set flag - this.visible = true; - }, - - // hide modal - hide: function(){ - // fade out - this.$el.fadeOut('fast'); - - // set flag - this.visible = false; - }, - - // enable buttons - enableButton: function(id) { - this.$buttons.find('#' + id).prop('disabled', false); - }, - - // disable buttons - disableButton: function(id) { - this.$buttons.find('#' + id).prop('disabled', true); - }, - - // enable operation - hideOperation: function(id) { - this.$operations.find('#' + id).hide(); - }, - - // disable operation - showOperation: function(id) { - this.$operations.find('#' + id).show(); - }, - - // set operation - setOperation: function(id, callback) { - var $el = this.$operations.find('#' + id); - $el.off('click'); - $el.on('click', callback); - }, - - // label - label: function(new_label) { - var $el = this.$el.find('#label'); - if (new_label) { - $el.html(new_label); - } - return $el.html(); - }, - - // fill regular modal template - template: function(options) { - var tmpl = '<div class="toolForm">'; - - if (options.label || options.icon) { - tmpl += '<div id="title" class="toolFormTitle" style="overflow:hidden;">' + - '<div id="operations" style="float: right;"></div>' + - '<div style="overflow: hidden">'; - - if (options.icon) - tmpl += '<i style="padding-top: 3px; float: left; font-size: 1.2em" class="icon fa ' + options.icon + '"> </i>'; - - tmpl += '<div id="label" style="padding-top: 2px; float: left;">' + options.label + '</div>'; - - tmpl += '</div>' + - '</div>'; - } - tmpl += '<div id="body" class="toolFormBody">'; - - if (options.placement == 'top') { - tmpl += '<div id="buttons" class="buttons" style="height: 50px; padding: 10px;"></div>'; - } - - tmpl += '<div id="content" class="content" style="height: inherit; padding: 10px;"></div>'; - - if (options.placement == 'bottom') { - tmpl += '<div id="buttons" class="buttons" style="height: 50px; padding: 10px;"></div>'; - } - - tmpl += '</div>' + - '</div>'; - return tmpl; - } -}); - -}); diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/library/table.js --- a/config/plugins/visualizations/charts/static/library/table.js +++ b/config/plugins/visualizations/charts/static/library/table.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // return return Backbone.View.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/library/ui.js --- a/config/plugins/visualizations/charts/static/library/ui.js +++ b/config/plugins/visualizations/charts/static/library/ui.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils', 'library/ui.select'], function(Utils, Select) { +define(['utils/utils', 'plugin/library/ui.select'], function(Utils, Select) { // plugin var Label = Backbone.View.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/library/ui.select.js --- a/config/plugins/visualizations/charts/static/library/ui.select.js +++ b/config/plugins/visualizations/charts/static/library/ui.select.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // plugin return Backbone.View.extend( @@ -55,7 +55,7 @@ }, // label - label : function () { + text : function () { return this.$el.find('option:selected').text(); }, @@ -84,7 +84,7 @@ }, // remove - remove: function(value) { + del: function(value) { // remove option $(this.el).find('option[value=' + value + ']').remove(); $(this.el).trigger('change'); diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/library/utils.js --- a/config/plugins/visualizations/charts/static/library/utils.js +++ /dev/null @@ -1,130 +0,0 @@ -// dependencies -define([], function() { - -// get -function get (url, success, error) { - request('GET', url, {}, success, error); -}; - -// generic function to send json to url -function request (method, url, data, success, error) { - - // encode data into url - if (method == 'GET' || method == 'DELETE') { - url = url + "?" + $.param(data); - } - - // prepare request - var xhr = new XMLHttpRequest(); - xhr.open(method, url, true); - xhr.setRequestHeader('Accept', 'application/json'); - xhr.setRequestHeader('Cache-Control', 'no-cache'); - xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - xhr.setRequestHeader('Content-Type', 'application/json'); - xhr.onloadend = function() { - var status = xhr.status; - if (status == 200) { - try { - response = jQuery.parseJSON(xhr.responseText); - } catch (e) { - response = xhr.responseText; - } - success && success(response); - } else { - error && error(status); - } - }; - - // make request - if (method == 'GET' || method == 'DELETE') { - xhr.send(); - } else { - xhr.send(JSON.stringify(data)); - } -}; - -// merge -function merge (options, optionsDefault) { - if (options) - return _.defaults(options, optionsDefault); - else - return optionsDefault; -}; - -// get css value -function cssGetAttribute (classnames, name) { - if (classnames.length == 0) { - console.log('cssGetAttribute() : Requires a list of classnames'); - } - - // place dummy element - var el = $('<div class="' + classnames[0] + '"></div>'); - var traverse_el = el; - for (var i in classnames) { - traverse_el.append('<div class="' + classnames[i] + '"></div>'); - traverse_el = traverse_el.find('.' + classnames[i]); - } - - // required append - el.appendTo(':eq(0)'); - - // get value - var value = el.css(name); - - // remove element - el.remove(); - - // return css value - return value; -}; - -// load css -function cssLoadFile (url) { - // check if css is already available - if (!$('link[href^="' + url + '"]').length) - $('<link href="' + galaxy_config.root + url + '" rel="stylesheet">').appendTo('head'); -}; - -// unique ide -function uuid(){ - return (new Date().getTime()).toString(36); -}; - -// wrap -function wrap($el) { - var wrapper = $('<p></p>'); - wrapper.append($el); - return wrapper; -}; - -// time -function time() { - // get date object - var d = new Date(); - - // format items - var hours = (d.getHours() < 10 ? "0" : "") + d.getHours(); - var minutes = (d.getMinutes() < 10 ? "0" : "") + d.getMinutes() - - // format final stamp - var datetime = d.getDate() + "/" - + (d.getMonth() + 1) + "/" - + d.getFullYear() + ", " - + hours + ":" - + minutes; - return datetime; -}; - -// return -return { - cssLoadFile : cssLoadFile, - cssGetAttribute : cssGetAttribute, - get : get, - merge : merge, - request: request, - uuid: uuid, - wrap : wrap, - time : time -}; - -}); diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/models/chart.js --- a/config/plugins/visualizations/charts/static/models/chart.js +++ b/config/plugins/visualizations/charts/static/models/chart.js @@ -1,5 +1,5 @@ // dependencies -define(['models/groups'], function(Groups) { +define(['plugin/models/groups'], function(Groups) { // model diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/models/charts.js --- a/config/plugins/visualizations/charts/static/models/charts.js +++ b/config/plugins/visualizations/charts/static/models/charts.js @@ -1,5 +1,5 @@ // dependencies -define(['models/chart'], function(Chart) { +define(['plugin/models/chart'], function(Chart) { // collection return Backbone.Collection.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/models/datasets.js --- a/config/plugins/visualizations/charts/static/models/datasets.js +++ b/config/plugins/visualizations/charts/static/models/datasets.js @@ -1,5 +1,5 @@ // dependencies -define(['library/utils'], function(Utils) { +define(['utils/utils'], function(Utils) { // widget return Backbone.Model.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/models/groups.js --- a/config/plugins/visualizations/charts/static/models/groups.js +++ b/config/plugins/visualizations/charts/static/models/groups.js @@ -1,5 +1,5 @@ // dependencies -define(['models/group'], function(Group) { +define(['plugin/models/group'], function(Group) { // collection return Backbone.Collection.extend( diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/views/chart.js --- a/config/plugins/visualizations/charts/static/views/chart.js +++ b/config/plugins/visualizations/charts/static/views/chart.js @@ -1,5 +1,5 @@ // dependencies -define(['library/portlet', 'library/table', 'library/ui', 'library/utils', 'models/chart', 'views/groups'], +define(['mvc/ui/ui-portlet', 'plugin/library/table', 'plugin/library/ui', 'utils/utils', 'plugin/models/chart', 'plugin/views/groups'], function(Portlet, Table, Ui, Utils, Chart, GroupsView) { // widget @@ -82,7 +82,7 @@ // add table to portlet var self = this; - this.portlet = new Portlet({ + this.portlet = new Portlet.View({ icon : 'fa-edit', label : 'Create a new chart:', operations : { diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/views/charts.js --- a/config/plugins/visualizations/charts/static/views/charts.js +++ b/config/plugins/visualizations/charts/static/views/charts.js @@ -1,5 +1,5 @@ // dependencies -define(['library/portlet', 'library/table', 'library/ui', 'library/utils'], function(Portlet, Table, Ui, Utils) { +define(['mvc/ui/ui-portlet', 'plugin/library/table', 'plugin/library/ui', 'utils/utils'], function(Portlet, Table, Ui, Utils) { // widget return Backbone.View.extend( @@ -31,7 +31,7 @@ // add table to portlet var self = this; - this.portlet = new Portlet({ + this.portlet = new Portlet.View({ icon : 'fa-list', label : 'List of created charts:', height : 100, diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/views/group.js --- a/config/plugins/visualizations/charts/static/views/group.js +++ b/config/plugins/visualizations/charts/static/views/group.js @@ -1,5 +1,5 @@ // dependencies -define(['library/portlet', 'library/table', 'library/ui', 'library/utils'], +define(['mvc/ui/ui-portlet', 'plugin/library/table', 'plugin/library/ui', 'utils/utils'], function(Portlet, Table, Ui, Utils) { // chart config @@ -24,7 +24,7 @@ // add table to portlet var self = this; - this.portlet = new Portlet({ + this.portlet = new Portlet.View({ icon : 'fa-edit', label : 'Define group properties:', operations : { diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/views/groups.js --- a/config/plugins/visualizations/charts/static/views/groups.js +++ b/config/plugins/visualizations/charts/static/views/groups.js @@ -1,5 +1,5 @@ // dependencies -define(['library/portlet', 'library/table', 'library/ui', 'library/utils'], function(Portlet, Table, Ui, Utils) { +define(['mvc/ui/ui-portlet', 'plugin/library/table', 'plugin/library/ui', 'utils/utils'], function(Portlet, Table, Ui, Utils) { // chart config return Backbone.View.extend( @@ -28,7 +28,7 @@ // add table to portlet var self = this; - this.portlet = new Portlet({ + this.portlet = new Portlet.View({ icon : '', label : 'Select data columns:', height : 100, diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/static/views/viewport.js --- a/config/plugins/visualizations/charts/static/views/viewport.js +++ b/config/plugins/visualizations/charts/static/views/viewport.js @@ -1,5 +1,5 @@ // dependencies -define(['library/portlet', 'library/ui', 'library/utils'], +define(['mvc/ui/ui-portlet', 'plugin/library/ui', 'utils/utils'], function(Portlet, Ui, Utils) { // widget @@ -24,7 +24,7 @@ this.options = Utils.merge(options, this.optionsDefault); // add table to portlet - this.portlet = new Portlet({ + this.portlet = new Portlet.View({ label : '', icon : 'fa-signal', height : this.options.height, @@ -121,7 +121,7 @@ // create chart view var self = this; - require(['charts/' + chart_type], function(ChartView) { + require(['plugin/charts/' + chart_type], function(ChartView) { // create chart var view = new ChartView(self.app, {svg_id : svg_id, chart : chart}); diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 config/plugins/visualizations/charts/templates/charts.mako --- a/config/plugins/visualizations/charts/templates/charts.mako +++ b/config/plugins/visualizations/charts/templates/charts.mako @@ -47,7 +47,10 @@ // configure require require.config({ - baseUrl: config.root + "plugins/visualizations/charts/static/", + baseUrl: config.root + "static/scripts/", + paths: { + "plugin": config.root + "plugins/visualizations/charts/static/" + }, shim: { "libs/underscore": { exports: "_" }, "libs/backbone/backbone": { exports: "Backbone" } @@ -58,7 +61,7 @@ var app = null; $(function() { // request application script - require(['app'], function(App) { + require(['plugin/app'], function(App) { // load options var options = { config : ${h.to_json_string( config )}, diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 static/scripts/mvc/ui/ui-portlet.js --- /dev/null +++ b/static/scripts/mvc/ui/ui-portlet.js @@ -0,0 +1,175 @@ +// dependencies +define(['utils/utils'], function(Utils) { + +// return +var View = Backbone.View.extend( +{ + // visibility + visible: false, + + // defaults options + optionsDefault: { + label : '', + icon : 'fa-tasks', + buttons : null, + body : null, + height : null, + operations : null, + placement : 'bottom', + overflow : 'auto' + }, + + // content + $content : null, + + // initialize + initialize : function(options) { + // configure options + this.options = Utils.merge(options, this.optionsDefault); + + // create new element + this.setElement(this.template(this.options)); + + // link content + this.$content = this.$el.find('#content'); + + // set content height + if (this.options.height) { + this.$el.find('#body').css('height', this.options.height); + this.$el.find('#content').css('overflow', this.options.overflow); + } + + // append buttons + this.$buttons = $(this.el).find('#buttons'); + if (this.options.buttons) { + // link functions + var self = this; + $.each(this.options.buttons, function(name, item) { + item.$el.prop('id', name); + self.$buttons.append(item.$el); + }); + } else { + this.$buttons.remove(); + } + + // append operations + this.$operations = $(this.el).find('#operations'); + if (this.options.operations) { + // link functions + var self = this; + $.each(this.options.operations, function(name, item) { + item.$el.prop('id', name); + self.$operations.append(item.$el); + }); + } + + // add body + if(this.options.body) { + this.append(this.options.body); + } + }, + + // append + append: function($el) { + this.$content.append(Utils.wrap($el)); + }, + + // content + content: function() { + return this.$content; + }, + + // hide modal + show: function(){ + // fade in + this.$el.fadeIn('fast'); + + // set flag + this.visible = true; + }, + + // hide modal + hide: function(){ + // fade out + this.$el.fadeOut('fast'); + + // set flag + this.visible = false; + }, + + // enable buttons + enableButton: function(id) { + this.$buttons.find('#' + id).prop('disabled', false); + }, + + // disable buttons + disableButton: function(id) { + this.$buttons.find('#' + id).prop('disabled', true); + }, + + // enable operation + hideOperation: function(id) { + this.$operations.find('#' + id).hide(); + }, + + // disable operation + showOperation: function(id) { + this.$operations.find('#' + id).show(); + }, + + // set operation + setOperation: function(id, callback) { + var $el = this.$operations.find('#' + id); + $el.off('click'); + $el.on('click', callback); + }, + + // label + label: function(new_label) { + var $el = this.$el.find('#label'); + if (new_label) { + $el.html(new_label); + } + return $el.html(); + }, + + // fill regular modal template + template: function(options) { + var tmpl = '<div class="toolForm">'; + + if (options.label || options.icon) { + tmpl += '<div id="title" class="toolFormTitle" style="overflow:hidden;">' + + '<div id="operations" style="float: right;"></div>' + + '<div style="overflow: hidden">'; + + if (options.icon) + tmpl += '<i style="padding-top: 3px; float: left; font-size: 1.2em" class="icon fa ' + options.icon + '"> </i>'; + + tmpl += '<div id="label" style="padding-top: 2px; float: left;">' + options.label + '</div>'; + + tmpl += '</div>' + + '</div>'; + } + tmpl += '<div id="body" class="toolFormBody">'; + + if (options.placement == 'top') { + tmpl += '<div id="buttons" class="buttons" style="height: 50px; padding: 10px;"></div>'; + } + + tmpl += '<div id="content" class="content" style="height: inherit; padding: 10px;"></div>'; + + if (options.placement == 'bottom') { + tmpl += '<div id="buttons" class="buttons" style="height: 50px; padding: 10px;"></div>'; + } + + tmpl += '</div>' + + '</div>'; + return tmpl; + } +}); + +return { + View : View +} + +}); diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 static/scripts/mvc/upload/upload-ftp.js --- a/static/scripts/mvc/upload/upload-ftp.js +++ b/static/scripts/mvc/upload/upload-ftp.js @@ -21,7 +21,7 @@ this.setElement(this._template()); // load extension - Utils.jsonFromUrl(galaxy_config.root + 'api/ftp_files', function(ftp_files) { self._fill(ftp_files); }); + Utils.get(galaxy_config.root + 'api/ftp_files', function(ftp_files) { self._fill(ftp_files); }); }, // events diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 static/scripts/mvc/upload/upload-view.js --- a/static/scripts/mvc/upload/upload-view.js +++ b/static/scripts/mvc/upload/upload-view.js @@ -112,7 +112,7 @@ // load extension var self = this; - Utils.jsonFromUrl(galaxy_config.root + "api/datatypes?extension_only=False", + Utils.get(galaxy_config.root + "api/datatypes?extension_only=False", function(datatypes) { for (key in datatypes) { self.list_extensions.push({ @@ -135,7 +135,7 @@ }); // load genomes - Utils.jsonFromUrl(galaxy_config.root + "api/genomes", + Utils.get(galaxy_config.root + "api/genomes", function(genomes) { for (key in genomes) { self.list_genomes.push({ diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 static/scripts/packed/mvc/upload/upload-ftp.js --- a/static/scripts/packed/mvc/upload/upload-ftp.js +++ b/static/scripts/packed/mvc/upload/upload-ftp.js @@ -1,1 +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" style="float: left;"><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 +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.get(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" style="float: left;"><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 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 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-button","mvc/upload/upload-model","mvc/upload/upload-row","mvc/upload/upload-ftp","mvc/ui/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,list_extensions:[],list_genomes:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},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(i){this.options=_.defaults(i,this.options)}if(!Galaxy.currHistoryPanel||!Galaxy.currHistoryPanel.model){window.setTimeout(function(){h.initialize()},500);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?extension_only=False",function(j){for(key in j){h.list_extensions.push({id:j[key].extension,text:j[key].extension,description:j[key].description,description_url:j[key].description_url})}h.list_extensions.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0});if(!h.options.datatypes_disable_auto){h.list_extensions.unshift(h.auto)}});f.jsonFromUrl(galaxy_config.root+"api/genomes",function(j){for(key in j){h.list_genomes.push({id:j[key][1],text:j[key][0]})}h.list_genomes.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0})});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()},"Paste/Fetch data":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()}});var i=this.modal.getButton("Choose FTP file");this.ftp=new d.View({title:"FTP files",container:i})}this.modal.show();this._updateUser();this._updateScreen()},_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=="local"){this.uploadbox.configure({paramname:"files_0|file_data"})}else{this.uploadbox.configure({paramname:null})}tool_input={};if(h=="new"){tool_input["files_0|url_paste"]=q}if(h=="ftp"){tool_input["files_0|ftp_files"]=n}tool_input.dbkey=r;tool_input.file_type=p;tool_input["files_0|type"]="upload_dataset";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("percentage",100);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("percentage",100);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.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)}},_updateUser:function(){this.current_user=Galaxy.currUser.get("id");this.current_history=null;if(this.current_user){this.current_history=Galaxy.currHistoryPanel.model.get("id")}},_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("Paste/Fetch data")}else{this.modal.disableButton("Choose local file");this.modal.disableButton("Choose FTP file");this.modal.disableButton("Paste/Fetch data")}if(this.current_user&&this.options.ftp_upload_dir&&this.options.ftp_upload_site){this.modal.showButton("Choose FTP file")}else{this.modal.hideButton("Choose FTP 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 +define(["galaxy.modal","utils/utils","mvc/upload/upload-button","mvc/upload/upload-model","mvc/upload/upload-row","mvc/upload/upload-ftp","mvc/ui/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,list_extensions:[],list_genomes:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},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(i){this.options=_.defaults(i,this.options)}if(!Galaxy.currHistoryPanel||!Galaxy.currHistoryPanel.model){window.setTimeout(function(){h.initialize()},500);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.get(galaxy_config.root+"api/datatypes?extension_only=False",function(j){for(key in j){h.list_extensions.push({id:j[key].extension,text:j[key].extension,description:j[key].description,description_url:j[key].description_url})}h.list_extensions.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0});if(!h.options.datatypes_disable_auto){h.list_extensions.unshift(h.auto)}});f.get(galaxy_config.root+"api/genomes",function(j){for(key in j){h.list_genomes.push({id:j[key][1],text:j[key][0]})}h.list_genomes.sort(function(l,k){return l.id>k.id?1:l.id<k.id?-1:0})});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()},"Paste/Fetch data":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()}});var i=this.modal.getButton("Choose FTP file");this.ftp=new d.View({title:"FTP files",container:i})}this.modal.show();this._updateUser();this._updateScreen()},_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=="local"){this.uploadbox.configure({paramname:"files_0|file_data"})}else{this.uploadbox.configure({paramname:null})}tool_input={};if(h=="new"){tool_input["files_0|url_paste"]=q}if(h=="ftp"){tool_input["files_0|ftp_files"]=n}tool_input.dbkey=r;tool_input.file_type=p;tool_input["files_0|type"]="upload_dataset";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("percentage",100);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("percentage",100);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.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)}},_updateUser:function(){this.current_user=Galaxy.currUser.get("id");this.current_history=null;if(this.current_user){this.current_history=Galaxy.currHistoryPanel.model.get("id")}},_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("Paste/Fetch data")}else{this.modal.disableButton("Choose local file");this.modal.disableButton("Choose FTP file");this.modal.disableButton("Paste/Fetch data")}if(this.current_user&&this.options.ftp_upload_dir&&this.options.ftp_upload_site){this.modal.showButton("Choose FTP file")}else{this.modal.hideButton("Choose FTP 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 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 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 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 +define(["libs/underscore"],function(j){function d(l,m,k){g("GET",l,{},m,k)}function g(p,l,m,o,k){if(p=="GET"||p=="DELETE"){if(l.indexOf("?")==-1){l+="?"}else{l+="&"}l+=$.param(m)}var n=new XMLHttpRequest();n.open(p,l,true);n.setRequestHeader("Accept","application/json");n.setRequestHeader("Cache-Control","no-cache");n.setRequestHeader("X-Requested-With","XMLHttpRequest");n.setRequestHeader("Content-Type","application/json");n.onloadend=function(){var q=n.status;if(q==200){try{response=jQuery.parseJSON(n.responseText)}catch(r){response=n.responseText}o&&o(response)}else{k&&k(q)}};if(p=="GET"||p=="DELETE"){n.send()}else{n.send(JSON.stringify(m))}}function h(n,k){var l=$('<div class="'+n+'"></div>');l.appendTo(":eq(0)");var m=l.css(k);l.remove();return m}function f(k){if(!$('link[href^="'+k+'"]').length){$('<link href="'+galaxy_config.root+k+'" rel="stylesheet">').appendTo("head")}}function i(k,l){if(k){return j.defaults(k,l)}else{return l}}function b(l,n){var m="";if(l>=100000000000){l=l/100000000000;m="TB"}else{if(l>=100000000){l=l/100000000;m="GB"}else{if(l>=100000){l=l/100000;m="MB"}else{if(l>=100){l=l/100;m="KB"}else{if(l>0){l=l*10;m="b"}else{return"<strong>-</strong>"}}}}}var k=(Math.round(l)/10);if(n){return k+" "+m}else{return"<strong>"+k+"</strong> "+m}}function a(){return(new Date().getTime()).toString(36)}function c(k){var l=$("<p></p>");l.append(k);return l}function e(){var m=new Date();var k=(m.getHours()<10?"0":"")+m.getHours();var l=(m.getMinutes()<10?"0":"")+m.getMinutes();var n=m.getDate()+"/"+(m.getMonth()+1)+"/"+m.getFullYear()+", "+k+":"+l;return n}return{cssLoadFile:f,cssGetAttribute:h,get:d,merge:i,bytesToString:b,uuid:a,time:e,wrap:c,request:g}}); \ No newline at end of file diff -r 0f65411e40224e7a9b32f3273896113654a742ce -r 86f8a8311fec37d0cfcae2e919e37e96a31ca297 static/scripts/utils/utils.js --- a/static/scripts/utils/utils.js +++ b/static/scripts/utils/utils.js @@ -7,35 +7,50 @@ define(["libs/underscore"], function(_) { // generic function to recieve json from url -function jsonFromUrl (url, successHandler, errorHandler) { +function get (url, success, error) { + request('GET', url, {}, success, error); +}; + +// generic function to send json to url +function request (method, url, data, success, error) { + + // encode data into url + if (method == 'GET' || method == 'DELETE') { + if (url.indexOf('?') == -1) { + url += '?'; + } else { + url += '&'; + } + url += $.param(data) + } - // open url + // prepare request var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - - // configure request + xhr.open(method, url, true); xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Cache-Control', 'no-cache'); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - - // on completion + xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onloadend = function() { var status = xhr.status; if (status == 200) { - try - { + try { response = jQuery.parseJSON(xhr.responseText); } catch (e) { response = xhr.responseText; } - successHandler && successHandler(response); + success && success(response); } else { - errorHandler && errorHandler(status); + error && error(status); } }; - - // submit request - xhr.send(); + + // make request + if (method == 'GET' || method == 'DELETE') { + xhr.send(); + } else { + xhr.send(JSON.stringify(data)); + } }; // get css value @@ -96,14 +111,42 @@ return (new Date().getTime()).toString(36); }; +// wrap +function wrap($el) { + var wrapper = $('<p></p>'); + wrapper.append($el); + return wrapper; +}; + +// time +function time() { + // get date object + var d = new Date(); + + // format items + var hours = (d.getHours() < 10 ? "0" : "") + d.getHours(); + var minutes = (d.getMinutes() < 10 ? "0" : "") + d.getMinutes() + + // format final stamp + var datetime = d.getDate() + "/" + + (d.getMonth() + 1) + "/" + + d.getFullYear() + ", " + + hours + ":" + + minutes; + return datetime; +}; + // return return { cssLoadFile : cssLoadFile, cssGetAttribute : cssGetAttribute, - jsonFromUrl : jsonFromUrl, + get : get, merge : merge, bytesToString: bytesToString, - uuid: uuid + uuid: uuid, + time: time, + wrap: wrap, + request: request }; }); Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org