1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

replaced bootstrap notifications for errors with messenger.js

This commit is contained in:
Keivan Beigi 2013-05-03 16:50:22 -07:00
parent 6ecfbe0c23
commit 381af184ce
4 changed files with 80 additions and 72 deletions

View File

@ -81,7 +81,8 @@ ul.messenger.messenger-fixed.messenger-on-top.messenger-on-left, ul.messenger.me
}
/* line 66, ../../src/sass/messenger.sass */
ul.messenger.messenger-fixed.messenger-on-right, ul.messenger.messenger-fixed.messenger-on-left {
width: 350px;
width: auto;
min-width: 350px;
}
/* line 69, ../../src/sass/messenger.sass */
ul.messenger.messenger-fixed.messenger-on-right .messenger-actions, ul.messenger.messenger-fixed.messenger-on-left .messenger-actions {

View File

@ -0,0 +1,74 @@
"use strict";
define(function () {
/* var model = new NzbDrone.Shared.NotificationModel();
model.set('title','test notification');
model.set('message','test message');
model.set('level', 'error');
this.push(model);
*/
window.alert = function (message) {
window.Messenger().post(message);
};
var self = this;
window.onerror = function (msg, url, line) {
try {
var a = document.createElement('a');
a.href = url;
var messageText = a.pathname.split('/').pop() + ' : ' + line + "</br>" + msg;
var message = {
message : messageText,
type : 'error',
hideAfter: 1000,
showCloseButton: true
};
window.Messenger().post(message);
} catch (error) {
console.log("An error occurred while reporting error. " + error);
console.log(msg);
window.alert('Couldn\'t report JS error. ' + msg);
}
return false; //don't suppress default alerts and logs.
};
$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
//don't report 200 error codes
if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) {
return undefined;
}
//don't report aborted requests
if (xmlHttpRequest.statusText === 'abort') {
return undefined;
}
var message = {
type : 'error',
hideAfter: 1000,
showCloseButton: true
};
if (xmlHttpRequest.status === 0 && xmlHttpRequest.readyState === 0) {
message.message = 'NzbDrone Server Not Reachable. make sure NzbDrone is running.';
} else {
message.message = ajaxOptions.type + " " + ajaxOptions.url + " : " + xmlHttpRequest.statusText;
}
window.Messenger().post(message);
alert('test');
return false;
});
});

View File

@ -2,74 +2,7 @@
define(['app', 'Shared/NotificationModel'], function () {
var notificationCollection = Backbone.Collection.extend({
model: NzbDrone.Shared.NotificationModel,
initialize: function () {
/* var model = new NzbDrone.Shared.NotificationModel();
model.set('title','test notification');
model.set('message','test message');
model.set('level', 'error');
this.push(model);
*/
window.alert = function (message) {
window.Messenger().post(message);
};
var self = this;
window.onerror = function (msg, url, line) {
try {
var model = new NzbDrone.Shared.NotificationModel();
var a = document.createElement('a');
a.href = url;
model.set('title', a.pathname.split('/').pop() + ' : ' + line);
model.set('message', msg);
model.set('level', 'error');
self.push(model);
} catch (error) {
console.log("An error occurred while reporting error. " + error);
console.log(msg);
window.alert('Couldn\'t report JS error. ' + msg);
}
return false; //don't suppress default alerts and logs.
};
$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
//don't report 200 error codes
if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) {
return undefined;
}
//don't report aborted requests
if (xmlHttpRequest.statusText === 'abort') {
return undefined;
}
var model = new NzbDrone.Shared.NotificationModel();
model.set('level', 'error');
if (xmlHttpRequest.status === 0 && xmlHttpRequest.readyState === 0) {
model.set('title', "Connection Failed");
model.set('message', "NzbDrone Server Not Reachable. make sure NzbDrone is running.");
} else {
model.set('title', ajaxOptions.type + " " + ajaxOptions.url + " : " + xmlHttpRequest.statusText);
model.set('message', xmlHttpRequest.responseText);
}
self.push(model);
return false;
});
}
model: NzbDrone.Shared.NotificationModel
});
return new notificationCollection();

View File

@ -26,7 +26,7 @@ require.config({
}
});
define('app', function () {
define('app', ['Instrumentation/ErrorHandler'], function () {
window.NzbDrone = new Backbone.Marionette.Application();
window.NzbDrone.Config = {};
@ -63,11 +63,11 @@ define('app', function () {
//TODO: Move to commands
OpenModalDialog : 'openModal',
CloseModalDialog: 'closeModal',
SeriesAdded: 'seriesAdded'
SeriesAdded : 'seriesAdded'
};
window.NzbDrone.Commands = {
SaveSettings : 'saveSettings'
SaveSettings: 'saveSettings'
};
window.NzbDrone.Constants = {