Skip to content

Commit

Permalink
Handle error report submission
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Aug 10, 2017
1 parent 6f8f381 commit 838b233
Showing 1 changed file with 88 additions and 92 deletions.
180 changes: 88 additions & 92 deletions client/galaxy/scripts/mvc/dataset/dataset-error.js
Expand Up @@ -15,13 +15,13 @@ define( [ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/form/form-view' ], function( Uti

Utils.get({
url : data_url,
success : function( data_response ) {
var job_url = Galaxy.root + 'api/jobs/' + data_response.creating_job + '?full=True';
success : function( dataset ) {
var job_url = Galaxy.root + 'api/jobs/' + dataset.creating_job + '?full=True';
Utils.get({
url : job_url,
success : function( job_response ) {
var job_url = Galaxy.root + 'api/jobs/' + data_response.creating_job + '?full=True';
self.render_error_page( self, data_response, job_response );
success : function( job ) {
var job_url = Galaxy.root + 'api/jobs/' + dataset.creating_job + '?full=True';
self.render_error_page( self, dataset, job );
},
error : function( response ) {
var error_response = {
Expand All @@ -47,45 +47,28 @@ define( [ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/form/form-view' ], function( Uti
},

/** Render the view */
render_error_page: function( self, data_response, job_response ) {
render_error_page: function( self, dataset, job ) {
self.$el.empty().append( self._templateHeader() );
console.log(data_response, job_response);
console.log(dataset, job);
//self.display_message( message, self.$( '.response-message' ) );
// Create all tabs
//self.create_tabs( response, self.$( '.edit-attr' ) );
self.$el.append('<p>An error occured while creating <b>' + data_response.name + '</b></p>');
self.$el.append('<p>An error occured while running the tool <b>' + job.tool_id + '</b>.</p>');
self.$el.append('<p>Tool execution generated the following messages:</p>');
self.$el.append('<pre>' + job_response.stderr + '</pre>');
self.$el.append('<pre class="code">' + job.stderr + '</pre>');
self.$el.append('<h2>Report This Error</pre>');
self.$el.append('<p>Usually the local Galaxy administrators regularly review errors that occur on the server. However, if you would like to provide additional information (such as what you were trying to do when the error occurred) and a contact e-mail address, we will be better able to investigate your problem and get back to you.</p>');
self.$el.append(self._getBugFormTemplate());
},

/** Perform AJAX post call */
call_ajax: function( self, data, tab_name ) {
var post_url = Galaxy.root + 'dataset/edit';
$.ajax({
type: "PUT",
url: post_url,
data: data,
success: function( response ) {
self.render_attribute_page( self, response );
},
error : function( response ) {
var error_response = {
'status': 'error',
'message': 'Error occured while saving. Please fill all the required fields and try again.',
'persistent': true,
'cls': 'errormessage'
};
self.display_message( error_response, self.$( '.response-message' ) );
}
});
self.$el.append(self._getBugFormTemplate(dataset, job));
},

/** Display actions messages */
display_message: function( response, $el ) {
$el.empty().html( new Ui.Message( response ).$el );
display_message: function( response, $el, safe ) {
if(!safe){
$el.empty().html( new Ui.Message( response ).$el );
} else {
$el.empty().html( new Ui.UnescapedMessage( response ).$el );
}

},

/** Main template */
Expand All @@ -97,71 +80,84 @@ define( [ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/form/form-view' ], function( Uti
},

/** Convert tab template */
_getBugFormTemplate: function( response ) {
_getBugFormTemplate: function(dataset, job) {
var self = this;
var inputs = [
{
"help": "Your email address",
"options": [],
"type": "text",
"name": "email",
"label": "Your email",
"value": Galaxy.user.get('email')
},
{
"help": "Any additional comments you can provide regarding what you were doing at the time of the bug.",
"options": [],
"type": "text",
"area": true,
"name": "message",
"label": "Message"
}
];

// TODO
if(false && response.any_public){
inputs.push({
"name": "public_consent",
"label": "Public Disclosure Consent",
"help": "This Galaxy is configured to report to one or more error reporting backends that public to the world. By selecting 'yes', you acknowledge that this bug report will be made public.",
"value": String( Boolean( false ) ),
"options": [],
"type": "boolean",
})
}

var form = new Form({
title : 'Error Report',
inputs : [
{
"help": "Your email address",
"options": [],
"type": "text",
"name": "email",
"label": "Your email"
},
{
"help": "Any additional comments you can provide regarding what you were doing at the time of the bug.",
"options": [],
"type": "text",
"name": "email",
"label": "Message"
}
],

operations: {
'submit' : new Ui.ButtonIcon({
tooltip : 'Submit the bug report.',
title : 'Submit',
inputs : inputs,
buttons : {
save : new Ui.Button({
icon : 'fa-bug',
title : 'Report',
cls : 'ui-button btn btn-primary',
floating : 'clear',
onclick : function() {
var form_data = form.data.create();
var post_url = Galaxy.root + 'api/jobs/' + job.id + '/error'
// Some required metadata
form_data.dataset_id = dataset.id;
$.ajax({
type: "POST",
url: post_url,
data: form_data,
success: function( response ) {
// Clear out the div
self.$el.empty().append( self._templateHeader() );
// And display the messages.
response.messages.forEach(function(message){
self.display_message( {
'status': message[1],
'message': message[0],
'persistent': true,
}, self.$( '.response-message' ), true );
});
},
error : function( response ) {
var error_response = {
'status': 'error',
'message': 'Error occured while saving. Please fill all the required fields and try again.',
'persistent': true,
'cls': 'errormessage'
};
self.display_message( error_response, self.$( '.response-message' ) );
}
});
}
})
}
},
});
return form.$el;
},

/** Submit action */
_submit: function( self, form, response, type ) {
var form_data = form.data.create();
form_data.dataset_id = response.dataset_id;
switch( type ) {
case "edit_attributes":
form_data.save = 'Save';
break;

case "auto-detect":
form_data.detect = 'Auto-detect';
break;

case "convert":
if ( form_data.target_type !== null && form_data.target_type ) {
form_data.dataset_id = response.dataset_id;
form_data.convert_data = 'Convert';
}
break;

case "change":
form_data.change = 'Save';
break;

case "permissions":
var post_data = {};
post_data.permissions = JSON.stringify( form_data );
post_data.update_roles_button = "Save";
post_data.dataset_id = response.dataset_id;
form_data = post_data;
break;
}
self.call_ajax( self, form_data );
}
});

Expand Down

0 comments on commit 838b233

Please sign in to comment.