Merged galaxy/galaxy-central into default

This commit is contained in:
Carl Eberhard
2014-09-16 09:05:46 -04:00
85 changed files with 1186 additions and 1932 deletions
+20
View File
@@ -593,6 +593,26 @@ function init_refresh_on_change () {
});
};
// jQuery plugin to prevent double submission of forms
// Ref: http://stackoverflow.com/questions/2830542/prevent-double-submission-of-forms-in-jquery
jQuery.fn.preventDoubleSubmission = function() {
$(this).on('submit',function(e){
var $form = $(this);
if ($form.data('submitted') === true) {
// Previously submitted - don't submit again
e.preventDefault();
} else {
// Mark it so that the next submit can be ignored
$form.data('submitted', true);
}
});
// Keep chainability
return this;
};
$(document).ready( function() {
// Refresh events for form fields.
+14 -9
View File
@@ -25,21 +25,26 @@ define([ 'mvc/history/history-contents' ], function( HISTORY_CONTENTS ){
},
// filter datasets by data type
filterType: function(filter_type) {
// return matched datasets
return this.currHistoryContents.filter( function( content ){
// link details
var history_content_type = content.get( 'history_content_type' );
var data_type = content.get( 'file_ext');
filterType: function(options) {
options = options || {};
return this.currHistoryContents.filter(function(content){
// match datatypes
var found = false;
for (var i in options.data_types) {
if (content.get('data_type').indexOf(options.data_types[i]) != -1) {
found = true;
break;
}
}
// apply filter
return history_content_type === 'dataset';// && (data_type === filter_type || filter_type === '');
// final match result
return (content.get('history_content_type') === options.content_type || !options.content_type) &&
(found || !options.data_types) && !content.get('deleted');
});
},
// filter datasets by id
filter: function(filter_id) {
// return matched datasets
return _.first( this.currHistoryContents.filter( function( content ){ return content.get( 'id' ) === filter_id; }) );
}
});
+21 -18
View File
@@ -56,6 +56,12 @@ define(['mvc/ui/ui-portlet', 'mvc/ui/ui-misc',
});
},
// message
message: function(options) {
$(this.main_el).empty();
$(this.main_el).append(ToolTemplate.message(options));
},
// reset form
reset: function() {
for (var i in this.element_list) {
@@ -63,6 +69,20 @@ define(['mvc/ui/ui-portlet', 'mvc/ui/ui-misc',
}
},
// refresh
refresh: function() {
// recreate tree structure
this.tree.refresh();
// trigger change
for (var id in this.field_list) {
this.field_list[id].trigger('change');
}
// log
console.debug('tools-form::refresh() - Recreated tree structure. Refresh.');
},
// initialize tool form
_initializeToolForm: function() {
// link this
@@ -135,10 +155,6 @@ define(['mvc/ui/ui-portlet', 'mvc/ui/ui-misc',
button_search.$el.hide();
}
// create message
self.message = new Ui.Message();
self.portlet.append(self.message.$el);
// append form
$(self.main_el).append(self.portlet.$el);
@@ -174,22 +190,9 @@ define(['mvc/ui/ui-portlet', 'mvc/ui/ui-misc',
// trigger refresh
self.refresh();
//self.job_handler.submit();
self.tree.finalize();
}
});
},
// refresh
refresh: function() {
// recreate tree structure
this.tree.refresh();
// trigger change
for (var id in this.field_list) {
this.field_list[id].trigger('change');
}
// log
console.debug('tools-form::refresh() - Recreated tree structure. Refresh.');
}
});
+5 -1
View File
@@ -31,12 +31,16 @@ return Backbone.Model.extend({
// success handler
function(response) {
if (!response.outputs || response.outputs.length == 0) {
console.log(response);
console.debug(response);
}
self.app.message({
text : 'A job has been successfully added to the queue. You can check the status of queued jobs and view the resulting data by refreshing the History pane. When the job has been run the status will change from \'running\' to \'finished\' if completed successfully or \'error\' if problems were encountered.'
});
self._refreshHdas();
},
// error handler
function(response) {
console.debug(response);
if (response && response.message && response.message.data) {
var error_messages = self.app.tree.match(response.message.data);
for (var id in error_messages) {
+2 -4
View File
@@ -16,13 +16,11 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'm
// set text
this.$el.find('.ui-table-form-error-text').html(text);
this.$el.find('.ui-table-form-error').fadeIn();
this.$el.addClass('ui-table-row-error');
},
// reset
reset: function() {
this.$el.find('.ui-table-form-error').hide();
this.$el.removeClass('ui-table-form-error');
},
// template
@@ -35,7 +33,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'm
}
// add error
$input.append('<div class="ui-table-form-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');
$input.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');
// add label
if (options.label) {
@@ -274,7 +272,7 @@ define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'm
// dataset column
case 'data_column':
field = this._field_data_colum(input_def);
field = this._field_select(input_def);
break;
// conditional select field
@@ -6,54 +6,6 @@ var View = Backbone.View.extend({
initialize : function(app, options) {
// link this
var self = this;
// get datasets
var datasets = app.datasets.filterType();
// configure options fields
var select_data = [];
for (var i in datasets) {
select_data.push({
label: datasets[i].get('name'),
value: datasets[i].get('id')
});
}
// create select field
this.select = new Ui.Select.View({
data : select_data,
value : select_data[0].value,
onchange : function() {
self.trigger('change');
}
});
// create select field for multiple files
this.select_multiple = new Ui.Select.View({
multiple : true,
data : select_data,
value : select_data[0].value,
onchange : function() {
self.trigger('change');
}
});
// create select field for multiple files
this.select_collection = new Ui.Select.View({
data : select_data,
value : select_data[0].value,
onchange : function() {
self.trigger('change');
}
});
// add change event. fires on trigger
this.on('change', function() {
if (options.onchange) {
options.onchange(self.value());
}
});
// tabs
this.tabs = new Tabs.View({
@@ -62,20 +14,66 @@ var View = Backbone.View.extend({
}
});
// add tab
this.tabs.add({
id : 'single',
title : 'Select a dataset',
$el : this.select.$el
//
// datasets
//
var datasets = app.datasets.filterType({
content_type : 'dataset',
data_types : options.extensions
});
// configure options fields
var dataset_options = [];
for (var i in datasets) {
dataset_options.push({
label: datasets[i].get('name'),
value: datasets[i].get('id')
});
}
// select field
this.select_datasets = new Ui.Select.View({
multiple : true,
data : dataset_options,
value : dataset_options[0] && dataset_options[0].value,
onchange : function() {
self.trigger('change');
}
});
// add tab
this.tabs.add({
id : 'multiple',
title : 'Select multiple datasets',
$el : this.select_multiple.$el
id : 'datasets',
title : 'Select datasets',
$el : this.select_datasets.$el
});
//
// collections
//
var collections = app.datasets.filterType({
content_type : 'collection',
data_types : options.extensions
});
// configure options fields
var collection_options = [];
for (var i in collections) {
collection_options.push({
label: collections[i].get('name'),
value: collections[i].get('id')
});
}
// create select field for collections
this.select_collection = new Ui.Select.View({
data : collection_options,
value : collection_options[0] && collection_options[0].value,
onchange : function() {
self.trigger('change');
}
});
// add tab
this.tabs.add({
id : 'collection',
@@ -85,18 +83,23 @@ var View = Backbone.View.extend({
// add element
this.setElement(this.tabs.$el);
// add change event. fires on trigger
this.on('change', function() {
if (options.onchange) {
options.onchange(self.value());
}
});
},
// value
value : function (new_value) {
var current_tab = this.tabs.current();
switch(current_tab) {
case 'multiple' :
return this.select_multiple.value();
case 'collection' :
case 'datasets':
return this.select_datasets.value();
case 'collection':
return this.select_collection.value();
default :
return this.select.value();
}
},
@@ -13,6 +13,12 @@ return {
citations: function() {
return '<div id="citations"></div>';
},
message: function(options) {
return '<div class="donemessagelarge">' +
'<p>' + options.text + '</p>' +
'</div>';
}
};
+31 -13
View File
@@ -50,8 +50,8 @@ return Backbone.Model.extend({
// converter between raw dictionary and job dictionary
function convert(identifier, head) {
for (var i in head) {
var node = head[i];
for (var index in head) {
var node = head[index];
if (node.input) {
// get node
var input = node.input;
@@ -68,9 +68,9 @@ return Backbone.Model.extend({
// handle repeats
case 'repeat':
var index = 0;
for (var j in node) {
if (j.indexOf('section') != -1) {
convert(job_input_id + '_' + index++, node[j]);
for (var i in node) {
if (i.indexOf('section') != -1) {
convert(job_input_id + '_' + index++, node[i]);
}
}
break;
@@ -83,20 +83,38 @@ return Backbone.Model.extend({
add (job_input_id + '|' + input.test_param.name, input.id, value);
// find selected case
for (var j in input.cases) {
if (input.cases[j].value == value) {
convert(job_input_id, head[input.id + '-section-' + j]);
for (var i in input.cases) {
if (input.cases[i].value == value) {
convert(job_input_id, head[input.id + '-section-' + i]);
break;
}
}
break;
// handle data inputs
case 'data':
var value = {
id : self.app.field_list[input.id].value(),
src : 'hda'
// create array for dataset ids
var dataset_selection = null;
// collect dataset ids from input field
var value = self.app.field_list[input.id].value();
if (typeof value === 'string') {
dataset_selection = {
id : value,
src : 'hda'
};
} else {
// create array of dataset dictionaries for api submission
dataset_selection = [];
for (var i in value) {
dataset_selection.push({
id : value[i],
src : 'hda'
});
}
}
add(job_input_id, input.id, value);
// add final array to job definition
add(job_input_id, input.id, dataset_selection);
break;
// handle boolean input
case 'boolean':
@@ -118,7 +136,7 @@ return Backbone.Model.extend({
// start conversion
convert('', this.dict);
console.log(this.job_def);
// return result
return this.job_def;
},
+4 -4
View File
@@ -1,6 +1,6 @@
// dependencies
define(['utils/utils', 'mvc/ui/ui-select-default', 'mvc/ui/ui-slider', 'mvc/ui/ui-checkbox', 'mvc/ui/ui-radiobutton', 'mvc/ui/ui-button-menu', 'mvc/ui/ui-modal'],
function(Utils, Select, Slider, Checkbox, RadioButton, ButtonMenu, Modal) {
define(['utils/utils', 'mvc/ui/ui-select-default', 'mvc/ui/ui-slider', 'mvc/ui/ui-options', 'mvc/ui/ui-button-menu', 'mvc/ui/ui-modal'],
function(Utils, Select, Slider, Options, ButtonMenu, Modal) {
/**
* This class contains backbone wrappers for basic ui elements such as Images, Labels, Buttons, Input fields etc.
@@ -403,8 +403,8 @@ return {
Label : Label,
Message : Message,
Modal : Modal,
RadioButton : RadioButton,
Checkbox : Checkbox,
RadioButton : Options.RadioButton,
Checkbox : Options.Checkbox,
Searchbox : Searchbox,
Select : Select,
Hidden : Hidden,
+1 -1
View File
@@ -172,7 +172,7 @@ var View = Backbone.View.extend({
// check if selected value exists
exists: function(value) {
return this.$select.find('option[value=' + value + ']').length > 0;
return this.$select.find('option[value="' + value + '"]').length > 0;
},
// change
+7 -11
View File
@@ -31,10 +31,9 @@ return Backbone.View.extend({
// fill table
_fill: function(ftp_files) {
if (ftp_files.length > 0) {
// add table
this.$el.find('#upload-ftp-content').html($(this._template_table()));
this.$el.find('#upload-ftp-content').html($(this._templateTable()));
// add files to table
var size = 0;
@@ -48,7 +47,7 @@ return Backbone.View.extend({
this.$el.find('#upload-ftp-disk').html(Utils.bytesToString (size, true));
} else {
// add info
this.$el.find('#upload-ftp-content').html($(this._template_info()));
this.$el.find('#upload-ftp-content').html($(this._templateInfo()));
}
// hide spinner
@@ -58,7 +57,7 @@ return Backbone.View.extend({
// add
add: function(ftp_file) {
// create new item
var $it = $(this._template_row(ftp_file));
var $it = $(this._templateRow(ftp_file));
// append to table
$(this.el).find('tbody').append($it);
@@ -118,7 +117,7 @@ return Backbone.View.extend({
},
// template row
_template_row: function(options) {
_templateRow: function(options) {
return '<tr>' +
'<td><div id="upload-ftp-add"/></td>' +
'<td style="width: 200px"><p style="width: inherit; word-wrap: break-word;">' + options.path + '</p></td>' +
@@ -128,8 +127,7 @@ return Backbone.View.extend({
},
// load table template
_template_table: function()
{
_templateTable: 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"/>' +
@@ -151,16 +149,14 @@ return Backbone.View.extend({
},
// load table template
_template_info: function()
{
_templateInfo: function() {
return '<div class="upload-ftp-warning warningmessage">' +
'Your FTP directory does not contain any files.' +
'</div>';
},
// load html template
_template: function()
{
_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>' +
+7 -14
View File
@@ -214,16 +214,14 @@ return Backbone.View.extend({
//
// genome
_refreshGenome: function()
{
_refreshGenome: function() {
// update genome info on screen
var genome = this.model.get('genome');
this.select_genome.value(genome);
},
// progress
_refreshInfo: function()
{
_refreshInfo: function() {
// write error message
var info = this.model.get('info');
if (info) {
@@ -234,8 +232,7 @@ return Backbone.View.extend({
},
// progress
_refreshPercentage : function()
{
_refreshPercentage : function() {
var percentage = parseInt(this.model.get('percentage'));
this.$el.find('.progress-bar').css({ width : percentage + '%' });
if (percentage != 100)
@@ -245,8 +242,7 @@ return Backbone.View.extend({
},
// status
_refreshStatus : function()
{
_refreshStatus : function() {
// get element
var it = this.$el;
@@ -315,8 +311,7 @@ return Backbone.View.extend({
},
// attach file info popup
_showExtensionInfo : function()
{
_showExtensionInfo : function() {
// initialize
var $el = $(this.el).find('#extension-info');
var extension = this.model.get('extension');
@@ -343,8 +338,7 @@ return Backbone.View.extend({
},
// attach file info popup
_showSettings : function()
{
_showSettings : function() {
// check if popover is visible
if (!this.settings.visible) {
// show popover
@@ -371,8 +365,7 @@ return Backbone.View.extend({
},
// template
_template: function(options)
{
_template: function(options) {
return '<tr id="upload-item-' + options.id + '" class="upload-item">' +
'<td>' +
'<div style="position: relative;">' +
+8 -9
View File
@@ -25,12 +25,12 @@ return Backbone.View.extend({
// 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');
self._switchState('#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');
self._switchState('#upload-to-posix-lines', 'to_posix_lines');
});
// render
@@ -45,8 +45,8 @@ return Backbone.View.extend({
// 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'));
this._renderState('#upload-space-to-tabs', this.model.get('space_to_tabs'));
this._renderState('#upload-to-posix-lines', this.model.get('to_posix_lines'));
// disable options
var $cover = this.$el.find('#upload-settings-cover');
@@ -58,16 +58,16 @@ return Backbone.View.extend({
},
// switch state
_switch_state: function (element_id, parameter_id) {
_switchState: 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);
this._renderState(element_id, checked);
}
},
// render state
_render_state: function (element_id, checked) {
_renderState: function (element_id, checked) {
// swith icon class
var $it = this.$el.find(element_id);
$it.removeClass();
@@ -79,8 +79,7 @@ return Backbone.View.extend({
},
// load template
_template: function()
{
_template: function() {
return '<div class="upload-settings" style="position: relative;">' +
'<div id="upload-settings-cover" class="upload-settings-cover"/>' +
'<table class="table table-striped">' +
+1 -2
View File
@@ -19,8 +19,7 @@ define(["utils/utils",
) {
// galaxy upload
return Backbone.View.extend(
{
return Backbone.View.extend({
// options
options : {
nginx_upload_path : ''