mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
QA, history panel: better error details: full url, ajax data, Raven/Sentry id if available; galaxy-app-base: add global listeners
This commit is contained in:
@@ -59,6 +59,8 @@ GalaxyApp.prototype._init = function init( options ){
|
||||
// options.onload();
|
||||
//}
|
||||
|
||||
self._setUpListeners();
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
@@ -122,6 +124,28 @@ GalaxyApp.prototype._initUser = function _initUser( userJSON ){
|
||||
return self;
|
||||
};
|
||||
|
||||
/** Set up DOM/jQuery/Backbone event listeners enabled for all pages */
|
||||
GalaxyApp.prototype._setUpListeners = function _setUpListeners(){
|
||||
var self = this;
|
||||
|
||||
// hook to jq beforeSend to record the most recent ajax call and cache some data about it
|
||||
/** cached info about the last ajax call made through jQuery */
|
||||
self.lastAjax = {};
|
||||
$( document ).bind( 'ajaxSend', function( ev, xhr, options ){
|
||||
var data = options.data;
|
||||
try {
|
||||
data = JSON.parse( data );
|
||||
} catch( err ){}
|
||||
|
||||
self.lastAjax = {
|
||||
url : location.href.slice( 0, -1 ) + options.url,
|
||||
data : data
|
||||
};
|
||||
//TODO:?? we might somehow manage to *retry* ajax using either this hook or Backbone.sync
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/** string rep */
|
||||
GalaxyApp.prototype.toString = function toString(){
|
||||
var userEmail = this.user.get( 'email' ) || '(anonymous)';
|
||||
|
||||
@@ -190,6 +190,7 @@ var ReadOnlyHistoryPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend
|
||||
// this.hdaViews = null;
|
||||
//},
|
||||
|
||||
//TODO: break this out
|
||||
// ........................................................................ error handling
|
||||
/** Event handler for errors (from the panel, the history, or the history's HDAs)
|
||||
* @param {Model or View} model the (Backbone) source of the error
|
||||
@@ -202,6 +203,8 @@ var ReadOnlyHistoryPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend
|
||||
this.error( model, xhr, options, msg, details );
|
||||
//TODO: getting JSON parse errors from jq migrate
|
||||
|
||||
window.xhr = xhr;
|
||||
|
||||
// interrupted ajax
|
||||
if( xhr && xhr.status === 0 && xhr.readyState === 0 ){
|
||||
|
||||
@@ -211,6 +214,7 @@ var ReadOnlyHistoryPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend
|
||||
|
||||
// otherwise, show an error message inside the panel
|
||||
} else {
|
||||
// if sentry is available, attempt to get the event id
|
||||
var parsed = this._parseErrorMessage( model, xhr, options, msg, details );
|
||||
// it's possible to have a triggered error before the message container is rendered - wait for it to show
|
||||
if( !this.$messages().is( ':visible' ) ){
|
||||
@@ -226,18 +230,25 @@ var ReadOnlyHistoryPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend
|
||||
/** Parse an error event into an Object usable by displayMessage based on the parameters
|
||||
* note: see errorHandler for more info on params
|
||||
*/
|
||||
_parseErrorMessage : function( model, xhr, options, msg, details ){
|
||||
_parseErrorMessage : function( model, xhr, options, msg, details, sentryId ){
|
||||
var user = Galaxy.currUser,
|
||||
// add the args (w/ some extra info) into an obj
|
||||
parsed = {
|
||||
message : this._bePolite( msg ),
|
||||
details : {
|
||||
user : ( user instanceof USER.User )?( user.toJSON() ):( user + '' ),
|
||||
source : ( model instanceof Backbone.Model )?( model.toJSON() ):( model + '' ),
|
||||
message : msg,
|
||||
raven : ( window.Raven )?( Raven.lastEventId() ):( undefined ),
|
||||
agent : navigator.userAgent,
|
||||
// add ajax data from Galaxy object cache
|
||||
url : ( window.Galaxy )?( Galaxy.lastAjax.url ):( undefined ),
|
||||
data : ( window.Galaxy )?( Galaxy.lastAjax.data ):( undefined ),
|
||||
options : ( xhr )?( _.omit( options, 'xhr' ) ):( options ),
|
||||
xhr : xhr,
|
||||
options : ( xhr )?( _.omit( options, 'xhr' ) ):( options )
|
||||
source : ( _.isFunction( model.toJSON ) )?( model.toJSON() ):( model + '' ),
|
||||
user : ( user instanceof USER.User )?( user.toJSON() ):( user + '' )
|
||||
}
|
||||
};
|
||||
|
||||
// add any extra details passed in
|
||||
_.extend( parsed.details, details || {} );
|
||||
// fancy xhr.header parsing (--> obj)
|
||||
|
||||
@@ -1 +1 @@
|
||||
define(["mvc/user/user-model","utils/metrics-logger","utils/add-logging","utils/localization","bootstrapped-data"],function(b,d,g,e,a){function h(n){var m=this;return m._init(n||{})}g(h,"GalaxyApp");h.prototype.defaultOptions={patchExisting:true,root:"/"};h.prototype._init=function k(n){var m=this;_.extend(m,Backbone.Events);m._processOptions(n);m.debug("GalaxyApp.options: ",m.options);m._patchGalaxy(window.Galaxy);m._initLogger(n.loggerOptions||{});m.debug("GalaxyApp.logger: ",m.logger);m._initLocale();m.debug("GalaxyApp.localize: ",m.localize);m.config=n.config||a.config||{};m.debug("GalaxyApp.config: ",m.config);m._initUser(n.user||a.user||{});m.debug("GalaxyApp.user: ",m.user);m.trigger("ready",m);return m};h.prototype._processOptions=function f(o){var n=this,p=n.defaultOptions;n.debug("_processOptions: ",o);n.options={};for(var m in p){if(p.hasOwnProperty(m)){n.options[m]=(o.hasOwnProperty(m))?(o[m]):(p[m])}}return n};h.prototype._patchGalaxy=function f(m){var o=this;if(o.options.patchExisting&&m){o.debug("found existing Galaxy object:",m);for(var n in m){if(m.hasOwnProperty(n)){o.debug("\t patching in "+n+" to Galaxy");o[n]=m[n]}}}};h.prototype._initLogger=function l(n){var m=this;m.debug("_initLogger:",n);m.logger=new d.MetricsLogger(n);return m};h.prototype._initLocale=function j(n){var m=this;m.debug("_initLocale:",n);m.localize=e;window._l=m.localize;return m};h.prototype._initUser=function i(n){var m=this;m.debug("_initUser:",n);m.user=new b.User(n);m.currUser=m.user;return m};h.prototype.toString=function c(){var m=this.user.get("email")||"(anonymous)";return"GalaxyApp("+m+")"};return{GalaxyApp:h}});
|
||||
define(["mvc/user/user-model","utils/metrics-logger","utils/add-logging","utils/localization","bootstrapped-data"],function(b,d,h,e,a){function i(o){var n=this;return n._init(o||{})}h(i,"GalaxyApp");i.prototype.defaultOptions={patchExisting:true,root:"/"};i.prototype._init=function l(o){var n=this;_.extend(n,Backbone.Events);n._processOptions(o);n.debug("GalaxyApp.options: ",n.options);n._patchGalaxy(window.Galaxy);n._initLogger(o.loggerOptions||{});n.debug("GalaxyApp.logger: ",n.logger);n._initLocale();n.debug("GalaxyApp.localize: ",n.localize);n.config=o.config||a.config||{};n.debug("GalaxyApp.config: ",n.config);n._initUser(o.user||a.user||{});n.debug("GalaxyApp.user: ",n.user);n.trigger("ready",n);n._setUpListeners();return n};i.prototype._processOptions=function g(p){var o=this,q=o.defaultOptions;o.debug("_processOptions: ",p);o.options={};for(var n in q){if(q.hasOwnProperty(n)){o.options[n]=(p.hasOwnProperty(n))?(p[n]):(q[n])}}return o};i.prototype._patchGalaxy=function g(n){var p=this;if(p.options.patchExisting&&n){p.debug("found existing Galaxy object:",n);for(var o in n){if(n.hasOwnProperty(o)){p.debug("\t patching in "+o+" to Galaxy");p[o]=n[o]}}}};i.prototype._initLogger=function m(o){var n=this;n.debug("_initLogger:",o);n.logger=new d.MetricsLogger(o);return n};i.prototype._initLocale=function k(o){var n=this;n.debug("_initLocale:",o);n.localize=e;window._l=n.localize;return n};i.prototype._initUser=function j(o){var n=this;n.debug("_initUser:",o);n.user=new b.User(o);n.currUser=n.user;return n};i.prototype._setUpListeners=function f(){var n=this;n.lastAjax={};$(document).bind("ajaxSend",function(q,s,o){var r=o.data;try{r=JSON.parse(r)}catch(p){}n.lastAjax={url:location.href.slice(0,-1)+o.url,data:r}})};i.prototype.toString=function c(){var n=this.user.get("email")||"(anonymous)";return"GalaxyApp("+n+")"};return{GalaxyApp:i}});
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user