properly detect connection issues and show appropriate message.

pull/3113/head
kay.one 12 years ago
parent bdad866ac6
commit 8a52b8da02

@ -1,7 +1,7 @@
"use strict";
define(['app', 'Shared/NotificationModel'], function () {
var collection = Backbone.Collection.extend({
var notificationCollection = Backbone.Collection.extend({
model: NzbDrone.Shared.NotificationModel,
@ -40,36 +40,34 @@ define(['app', 'Shared/NotificationModel'], function () {
$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
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.");
self.push(model);
return false;
}
//don't report 200 error codes
if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) {
return undefined;
}
//doesn't report aborted requests
//don't report aborted requests
if (xmlHttpRequest.statusText === 'abort') {
return undefined;
}
model.set('title', ajaxOptions.type + " " + ajaxOptions.url + " : " + xmlHttpRequest.statusText);
model.set('message', xmlHttpRequest.responseText);
self.push(model);
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;
});
}
});
return new collection();
return new notificationCollection();
});

Loading…
Cancel
Save