UI will reload on navigation if the backend has been update
This commit is contained in:
parent
541cd0ce19
commit
c286f1b18a
|
@ -29,49 +29,49 @@ define(
|
||||||
|
|
||||||
addSeries: function (action) {
|
addSeries: function (action) {
|
||||||
this.setTitle('Add Series');
|
this.setTitle('Add Series');
|
||||||
AppLayout.mainRegion.show(new AddSeriesLayout({action: action}));
|
this.showMainRegion(new AddSeriesLayout({action: action}));
|
||||||
},
|
},
|
||||||
|
|
||||||
calendar: function () {
|
calendar: function () {
|
||||||
this.setTitle('Calendar');
|
this.setTitle('Calendar');
|
||||||
AppLayout.mainRegion.show(new CalendarLayout());
|
this.showMainRegion(new CalendarLayout());
|
||||||
},
|
},
|
||||||
|
|
||||||
settings: function (action) {
|
settings: function (action) {
|
||||||
this.setTitle('Settings');
|
this.setTitle('Settings');
|
||||||
AppLayout.mainRegion.show(new SettingsLayout({ action: action }));
|
this.showMainRegion(new SettingsLayout({ action: action }));
|
||||||
},
|
},
|
||||||
|
|
||||||
missing: function () {
|
missing: function () {
|
||||||
this.setTitle('Missing');
|
this.setTitle('Missing');
|
||||||
|
|
||||||
AppLayout.mainRegion.show(new MissingLayout());
|
this.showMainRegion(new MissingLayout());
|
||||||
},
|
},
|
||||||
|
|
||||||
history: function (action) {
|
history: function (action) {
|
||||||
this.setTitle('History');
|
this.setTitle('History');
|
||||||
|
|
||||||
AppLayout.mainRegion.show(new HistoryLayout({ action: action }));
|
this.showMainRegion(new HistoryLayout({ action: action }));
|
||||||
},
|
},
|
||||||
|
|
||||||
rss: function () {
|
rss: function () {
|
||||||
this.setTitle('RSS');
|
this.setTitle('RSS');
|
||||||
AppLayout.mainRegion.show(new ReleaseLayout());
|
this.showMainRegion(new ReleaseLayout());
|
||||||
},
|
},
|
||||||
|
|
||||||
system: function (action) {
|
system: function (action) {
|
||||||
this.setTitle('System');
|
this.setTitle('System');
|
||||||
AppLayout.mainRegion.show(new SystemLayout({ action: action }));
|
this.showMainRegion(new SystemLayout({ action: action }));
|
||||||
},
|
},
|
||||||
|
|
||||||
seasonPass: function () {
|
seasonPass: function () {
|
||||||
this.setTitle('Season Pass');
|
this.setTitle('Season Pass');
|
||||||
AppLayout.mainRegion.show(new SeasonPassLayout());
|
this.showMainRegion(new SeasonPassLayout());
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function () {
|
update: function () {
|
||||||
this.setTitle('Updates');
|
this.setTitle('Updates');
|
||||||
AppLayout.mainRegion.show(new UpdateLayout());
|
this.showMainRegion(new UpdateLayout());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
'use strict';
|
||||||
|
define(function () {
|
||||||
|
window.onbeforeunload = function () {
|
||||||
|
window.NzbDrone.unloading = true;
|
||||||
|
};
|
||||||
|
});
|
|
@ -1,15 +1,20 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
|
'vent',
|
||||||
'AppLayout',
|
'AppLayout',
|
||||||
'marionette',
|
'marionette',
|
||||||
'Shared/NotFoundView'
|
'Shared/NotFoundView'
|
||||||
], function (AppLayout, Marionette, NotFoundView) {
|
], function (vent, AppLayout, Marionette, NotFoundView) {
|
||||||
return Marionette.AppRouter.extend({
|
return Marionette.AppRouter.extend({
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
this.listenTo(vent, vent.Events.ServerUpdated, this._onServerUpdated);
|
||||||
|
},
|
||||||
|
|
||||||
showNotFound: function () {
|
showNotFound: function () {
|
||||||
this.setTitle('Not Found');
|
this.setTitle('Not Found');
|
||||||
AppLayout.mainRegion.show(new NotFoundView(this));
|
this.showMainRegion(new NotFoundView(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
setTitle: function (title) {
|
setTitle: function (title) {
|
||||||
|
@ -19,6 +24,21 @@ define(
|
||||||
else {
|
else {
|
||||||
document.title = title + ' - NzbDrone';
|
document.title = title + ' - NzbDrone';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_onServerUpdated: function () {
|
||||||
|
this.pendingUpdate = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
showMainRegion: function (view) {
|
||||||
|
if (this.pendingUpdate) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
//AppLayout
|
||||||
|
AppLayout.mainRegion.show(view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,8 +4,9 @@ define(
|
||||||
'vent',
|
'vent',
|
||||||
'jquery',
|
'jquery',
|
||||||
'Shared/Messenger',
|
'Shared/Messenger',
|
||||||
|
'System/StatusModel',
|
||||||
'signalR'
|
'signalR'
|
||||||
], function (vent, $, Messenger) {
|
], function (vent, $, Messenger, StatusModel) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
appInitializer: function () {
|
appInitializer: function () {
|
||||||
|
@ -39,48 +40,61 @@ define(
|
||||||
vent.trigger('server:' + message.name, message.body);
|
vent.trigger('server:' + message.name, message.body);
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.signalRconnection.reconnecting(function() {
|
this.signalRconnection.reconnecting(function() {
|
||||||
// tryingToReconnect = true;
|
if (window.NzbDrone.unloading) {
|
||||||
//
|
return;
|
||||||
// Messenger.show({
|
}
|
||||||
// id : messengerId,
|
|
||||||
// type : 'info',
|
tryingToReconnect = true;
|
||||||
// hideAfter : 0,
|
|
||||||
// message : 'Connection to backend lost, attempting to reconnect'
|
Messenger.show({
|
||||||
// });
|
id : messengerId,
|
||||||
// });
|
type : 'info',
|
||||||
//
|
hideAfter : 0,
|
||||||
// this.signalRconnection.reconnected(function() {
|
message : 'Connection to backend lost, attempting to reconnect'
|
||||||
// tryingToReconnect = false;
|
});
|
||||||
//
|
});
|
||||||
// Messenger.show({
|
|
||||||
// id : messengerId,
|
this.signalRconnection.reconnected(function() {
|
||||||
// type : 'success',
|
tryingToReconnect = false;
|
||||||
// hideAfter : 5,
|
|
||||||
// message : 'Connection to backend restored'
|
var currentVersion = StatusModel.get('version');
|
||||||
// });
|
|
||||||
// });
|
var promise = StatusModel.fetch();
|
||||||
//
|
promise.done(function () {
|
||||||
// this.signalRconnection.disconnected(function () {
|
if (StatusModel.get('version') !== currentVersion) {
|
||||||
// if (tryingToReconnect) {
|
vent.trigger(vent.Events.ServerUpdated);
|
||||||
// $('<div class="modal-backdrop"></div>').appendTo(document.body);
|
}
|
||||||
//
|
});
|
||||||
// Messenger.show({
|
|
||||||
// id : messengerId,
|
Messenger.show({
|
||||||
// type : 'error',
|
id : messengerId,
|
||||||
// hideAfter : 0,
|
type : 'success',
|
||||||
// message : 'Connection to backend lost',
|
hideAfter : 5,
|
||||||
// actions : {
|
message : 'Connection to backend restored'
|
||||||
// cancel: {
|
});
|
||||||
// label: 'Reload',
|
});
|
||||||
// action: function() {
|
|
||||||
// window.location.reload();
|
this.signalRconnection.disconnected(function () {
|
||||||
// }
|
if (tryingToReconnect) {
|
||||||
// }
|
$('<div class="modal-backdrop"></div>').appendTo(document.body);
|
||||||
// }
|
|
||||||
// });
|
Messenger.show({
|
||||||
// }
|
id : messengerId,
|
||||||
// });
|
type : 'error',
|
||||||
|
hideAfter : 0,
|
||||||
|
message : 'Connection to backend lost',
|
||||||
|
actions : {
|
||||||
|
cancel: {
|
||||||
|
label: 'Reload',
|
||||||
|
action: function() {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.signalRconnection.start({ transport:
|
this.signalRconnection.start({ transport:
|
||||||
[
|
[
|
||||||
|
|
|
@ -8,7 +8,6 @@ define(
|
||||||
url: window.NzbDrone.ApiRoot + '/system/status'
|
url: window.NzbDrone.ApiRoot + '/system/status'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var instance = new StatusModel();
|
var instance = new StatusModel();
|
||||||
instance.fetch();
|
instance.fetch();
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
@ -191,7 +191,8 @@ define(
|
||||||
'Series/SeriesController',
|
'Series/SeriesController',
|
||||||
'Router',
|
'Router',
|
||||||
'Shared/Modal/Controller',
|
'Shared/Modal/Controller',
|
||||||
'Instrumentation/StringFormat'
|
'Instrumentation/StringFormat',
|
||||||
|
'LifeCycle'
|
||||||
], function ($, Backbone, Marionette, RouteBinder, SignalRBroadcaster, NavbarView, AppLayout, SeriesController, Router, ModalController) {
|
], function ($, Backbone, Marionette, RouteBinder, SignalRBroadcaster, NavbarView, AppLayout, SeriesController, Router, ModalController) {
|
||||||
|
|
||||||
new SeriesController();
|
new SeriesController();
|
||||||
|
|
|
@ -11,7 +11,8 @@ define(
|
||||||
SeriesAdded : 'series:added',
|
SeriesAdded : 'series:added',
|
||||||
SeriesDeleted : 'series:deleted',
|
SeriesDeleted : 'series:deleted',
|
||||||
SeasonRenamed : 'season:renamed',
|
SeasonRenamed : 'season:renamed',
|
||||||
CommandComplete: 'command:complete'
|
CommandComplete: 'command:complete',
|
||||||
|
ServerUpdated : 'server:updated'
|
||||||
};
|
};
|
||||||
|
|
||||||
vent.Commands = {
|
vent.Commands = {
|
||||||
|
|
Loading…
Reference in New Issue