Issue #160: Provide Async Error Handling
Added Toast notification for unexpected errors On 401 and 403 Errors, user is redirected to login
This commit is contained in:
@ -0,0 +1,35 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone'],
|
||||
function($,
|
||||
_,
|
||||
Backbone) {
|
||||
return Backbone.View.extend({
|
||||
el:'#error-notification-container',
|
||||
initialize: function() {
|
||||
Backbone.on("error:unhandled", this.showNotification.bind(this));
|
||||
this.hideNotification();
|
||||
this.currentTimeout = null;
|
||||
},
|
||||
|
||||
showNotification: function() {
|
||||
var self = this;
|
||||
if (!this.$el.is(':visible')) {
|
||||
this.$el.show(350);
|
||||
}
|
||||
if (this.currentTimeout != null) {
|
||||
window.clearTimeout(this.currentTimeout);
|
||||
}
|
||||
this.currentTimeout = window.setTimeout(function() {
|
||||
self.hideNotification();
|
||||
self.currentTimeout = null;
|
||||
}, 3000);
|
||||
},
|
||||
|
||||
hideNotification: function() {
|
||||
if (this.$el.is(':visible')) {
|
||||
this.$el.hide(350);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
@ -2,17 +2,20 @@
|
||||
define(['jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'libs/jquery.form'],
|
||||
'libs/jquery.form',
|
||||
'goatApp/view/ErrorNotificationView'],
|
||||
function(
|
||||
$,
|
||||
_,
|
||||
Backbone,
|
||||
JQueryForm) {
|
||||
JQueryForm,
|
||||
ErrorNotificationView) {
|
||||
return Backbone.View.extend({
|
||||
el:'#lesson-content-wrapper', //TODO << get this fixed up in DOM
|
||||
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
new ErrorNotificationView();
|
||||
},
|
||||
|
||||
/* initial renering */
|
||||
|
Reference in New Issue
Block a user