Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for remaining webhooks PR issues. #3102

Merged
merged 3 commits into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
758 changes: 380 additions & 378 deletions client/galaxy/scripts/layout/menu.js

Large diffs are not rendered by default.

64 changes: 29 additions & 35 deletions client/galaxy/scripts/mvc/tool/tool-form.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/**
This is the regular tool form.
*/
/* This is the regular tool form */
define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form-base', 'mvc/webhooks' ],
function( Utils, Ui, Modal, ToolFormBase, Webhooks ) {

var View = ToolFormBase.extend({
var View = Backbone.View.extend({
initialize: function( options ) {
var self = this;
options.listen_to_history = true;
options.always_refresh = false;
this.modal = parent.Galaxy.modal || new Modal.View();
ToolFormBase.prototype.initialize.call( this, Utils.merge({
customize: function( options ) {
this.form = new ToolFormBase( Utils.merge({
listen_to_history : true,
always_refresh : false,
customize : function( options ) {
// build execute button
options.buttons = {
execute: execute_btn = new Ui.Button({
Expand All @@ -22,10 +19,10 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form
floating : 'clear',
onclick : function() {
execute_btn.wait();
self.portlet.disable();
self.form.portlet.disable();
self.submit( options, function() {
execute_btn.unwait();
self.portlet.enable();
self.form.portlet.enable();
} );
}
})
Expand All @@ -45,6 +42,9 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form
}
}
}, options ) );
this.deferred = this.form.deferred;
this.setElement( '<div/>' );
this.$el.append( this.form.$el );
},

/** Submit a regular job.
Expand All @@ -56,9 +56,9 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form
var job_def = {
tool_id : options.id,
tool_version : options.version,
inputs : this.data.create()
inputs : this.form.data.create()
}
this.trigger( 'reset' );
this.form.trigger( 'reset' );
if ( !self.validate( job_def ) ) {
Galaxy.emit.debug( 'tool-form::submit()', 'Submission canceled. Validation failed.' );
callback && callback();
Expand All @@ -80,38 +80,32 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form
callback && callback();
self.$el.children().hide();
self.$el.append( self._templateSuccess( response ) );

// Show Webhook if job is running
if ( response.jobs && response.jobs.length > 0 ) {
self.$el.append( $( '<div/>', { id: 'webhook-view' } ) );
var WebhookApp = new Webhooks.WebhookView({
urlRoot: Galaxy.root + 'api/webhooks/tool'
});
}

parent.Galaxy && parent.Galaxy.currHistoryPanel && parent.Galaxy.currHistoryPanel.refreshContents();
},
error : function( response ) {
callback && callback();
Galaxy.emit.debug( 'tool-form::submit', 'Submission failed.', response );
var input_found = false;
if ( response && response.err_data ) {
var error_messages = self.data.matchResponse( response.err_data );
for (var input_id in error_messages) {
self.highlight( input_id, error_messages[ input_id ]);
var error_messages = self.form.data.matchResponse( response.err_data );
for ( var input_id in error_messages ) {
self.form.highlight( input_id, error_messages[ input_id ]);
input_found = true;
break;
}
}
if ( !input_found ) {
self.modal.show({
title : 'Job submission failed',
body : ( response && response.err_msg ) || self._templateError( job_def ),
buttons : {
'Close' : function() {
self.modal.hide();
}
}
body : self._templateError( job_def, response && response.err_msg ),
buttons : { 'Close' : function() { self.modal.hide() } }
});
}
}
Expand All @@ -127,15 +121,15 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form
var batch_src = null;
for ( var job_input_id in job_inputs ) {
var input_value = job_inputs[ job_input_id ];
var input_id = this.data.match( job_input_id );
var input_field = this.field_list[ input_id ];
var input_def = this.input_list[ input_id ];
var input_id = this.form.data.match( job_input_id );
var input_field = this.form.field_list[ input_id ];
var input_def = this.form.input_list[ input_id ];
if ( !input_id || !input_def || !input_field ) {
Galaxy.emit.debug('tool-form::validate()', 'Retrieving input objects failed.');
continue;
}
if ( !input_def.optional && input_value == null ) {
this.highlight( input_id );
this.form.highlight( input_id );
return false;
}
if ( input_value && input_value.batch ) {
Expand All @@ -145,14 +139,14 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form
if ( batch_src === null ) {
batch_src = src;
} else if ( batch_src !== src ) {
this.highlight( input_id, 'Please select either dataset or dataset list fields for all batch mode fields.' );
this.form.highlight( input_id, 'Please select either dataset or dataset list fields for all batch mode fields.' );
return false;
}
}
if ( batch_n === -1 ) {
batch_n = n;
} else if ( batch_n !== n ) {
this.highlight( input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + batch_n + '</b>.' );
this.form.highlight( input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + batch_n + '</b>.' );
return false;
}
}
Expand All @@ -165,21 +159,21 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form
var njobs = response.jobs.length;
var njobs_text = njobs == 1 ? '1 job has' : njobs + ' jobs have';
var $message = $( '<div/>' ).addClass( 'donemessagelarge' )
.append( $( '<p/>' ).text( njobs_text + ' been successfully added to the queue - resulting in the following datasets:' ) );
.append( $( '<p/>' ).text( njobs_text + ' been successfully added to the queue - resulting in the following datasets:' ) );
_.each( response.outputs, function( output ) {
$message.append( $( '<p/>' ).addClass( 'messagerow' ).append( $( '<b/>' ).text( output.hid + ': ' + output.name ) ) );
});
$message.append( $( '<p/>' ).append( '<b/>' ).text( '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.' ) );
return $message;
} else {
return this._templateError( response );
return this._templateError( response, 'Invalid success response. No jobs found.' );
}
},

_templateError: function( response ) {
_templateError: function( response, err_msg ) {
return $( '<div/>' ).addClass( 'errormessagelarge' )
.append( $( '<p/>' ).text( 'The server could not complete the request. Please contact the Galaxy Team if this error persists.' ) )
.append( $( '<pre/>' ).text( JSON.stringify( response, null, 4 ) ) );
.append( $( '<p/>' ).text( 'The server could not complete the request. Please contact the Galaxy Team if this error persists. ' + ( err_msg || '' ) ) )
.append( $( '<pre/>' ).text( JSON.stringify( response, null, 4 ) ) );
}
});

Expand Down