mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
Auto reload when server has been updated
New: Updating will reload UI on navigation
This commit is contained in:
parent
99f2b07a11
commit
eff7c4b7b7
@ -1,18 +1,11 @@
|
||||
using Nancy;
|
||||
using Nancy.Bootstrapper;
|
||||
using NzbDrone.Api.Frontend;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Api.Extensions.Pipelines
|
||||
{
|
||||
public class CacheHeaderPipeline : IRegisterNancyPipeline
|
||||
public class NzbDroneVersionPipeline : IRegisterNancyPipeline
|
||||
{
|
||||
private readonly ICacheableSpecification _cacheableSpecification;
|
||||
|
||||
public CacheHeaderPipeline(ICacheableSpecification cacheableSpecification)
|
||||
{
|
||||
_cacheableSpecification = cacheableSpecification;
|
||||
}
|
||||
|
||||
public void Register(IPipelines pipelines)
|
||||
{
|
||||
pipelines.AfterRequest.AddItemToStartOfPipeline(Handle);
|
||||
@ -20,14 +13,7 @@ public void Register(IPipelines pipelines)
|
||||
|
||||
private void Handle(NancyContext context)
|
||||
{
|
||||
if (_cacheableSpecification.IsCacheable(context))
|
||||
{
|
||||
context.Response.Headers.EnableCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Headers.DisableCache();
|
||||
}
|
||||
context.Response.Headers.Add("X-ApplicationVersion", BuildInfo.Version.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using Nancy;
|
||||
using Nancy.Bootstrapper;
|
||||
using NzbDrone.Api.Frontend;
|
||||
|
||||
namespace NzbDrone.Api.Extensions.Pipelines
|
||||
{
|
||||
public class CacheHeaderPipeline : IRegisterNancyPipeline
|
||||
{
|
||||
private readonly ICacheableSpecification _cacheableSpecification;
|
||||
|
||||
public CacheHeaderPipeline(ICacheableSpecification cacheableSpecification)
|
||||
{
|
||||
_cacheableSpecification = cacheableSpecification;
|
||||
}
|
||||
|
||||
public void Register(IPipelines pipelines)
|
||||
{
|
||||
pipelines.AfterRequest.AddItemToStartOfPipeline(Handle);
|
||||
}
|
||||
|
||||
private void Handle(NancyContext context)
|
||||
{
|
||||
if (_cacheableSpecification.IsCacheable(context))
|
||||
{
|
||||
context.Response.Headers.EnableCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Headers.DisableCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -122,6 +122,7 @@
|
||||
<Compile Include="Episodes\RenameEpisodeModule.cs" />
|
||||
<Compile Include="Episodes\RenameEpisodeResource.cs" />
|
||||
<Compile Include="Extensions\Pipelines\CacheHeaderPipeline.cs" />
|
||||
<Compile Include="Extensions\Pipelines\NzbDroneVersionPipeline.cs" />
|
||||
<Compile Include="Extensions\Pipelines\GZipPipeline.cs" />
|
||||
<Compile Include="Extensions\Pipelines\IfModifiedPipeline.cs" />
|
||||
<Compile Include="Extensions\Pipelines\IRegisterNancyPipeline.cs" />
|
||||
|
@ -101,6 +101,7 @@
|
||||
<Compile Include="AccessControl\FirewallAdapter.cs" />
|
||||
<Compile Include="AccessControl\UrlAclAdapter.cs" />
|
||||
<Compile Include="BrowserService.cs" />
|
||||
<Compile Include="Owin\MiddleWare\NzbDroneVersionMiddleWare.cs" />
|
||||
<Compile Include="SpinService.cs" />
|
||||
<Compile Include="SingleInstancePolicy.cs" />
|
||||
<Compile Include="IUserAlert.cs" />
|
||||
|
@ -13,7 +13,7 @@ public NancyMiddleWare(INancyBootstrapper nancyBootstrapper)
|
||||
_nancyBootstrapper = nancyBootstrapper;
|
||||
}
|
||||
|
||||
public int Order { get { return 1; } }
|
||||
public int Order { get { return 2; } }
|
||||
|
||||
public void Attach(IAppBuilder appBuilder)
|
||||
{
|
||||
|
@ -0,0 +1,32 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Owin;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using Owin;
|
||||
|
||||
namespace NzbDrone.Host.Owin.MiddleWare
|
||||
{
|
||||
public class NzbDroneVersionMiddleWare : IOwinMiddleWare
|
||||
{
|
||||
public int Order { get { return 0; } }
|
||||
|
||||
public void Attach(IAppBuilder appBuilder)
|
||||
{
|
||||
appBuilder.Use(typeof (AddApplicationVersionHeader));
|
||||
}
|
||||
}
|
||||
|
||||
public class AddApplicationVersionHeader : OwinMiddleware
|
||||
{
|
||||
public AddApplicationVersionHeader(OwinMiddleware next)
|
||||
: base(next)
|
||||
{
|
||||
}
|
||||
|
||||
public override Task Invoke(OwinRequest request, OwinResponse response)
|
||||
{
|
||||
response.AddHeader("X-ApplicationVersion", BuildInfo.Version.ToString());
|
||||
|
||||
return Next.Invoke(request, response);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ namespace NzbDrone.Host.Owin.MiddleWare
|
||||
{
|
||||
public class SignalRMiddleWare : IOwinMiddleWare
|
||||
{
|
||||
public int Order { get { return 0; } }
|
||||
public int Order { get { return 1; } }
|
||||
|
||||
public SignalRMiddleWare(IContainer container)
|
||||
{
|
||||
|
@ -28,6 +28,29 @@ define(
|
||||
xhr.headers['X-Api-Key'] = window.NzbDrone.ApiKey;
|
||||
}
|
||||
|
||||
return original.apply(this, arguments);
|
||||
return original.apply(this, arguments).done(function (response, status, xhr){
|
||||
var version = xhr.getResponseHeader('X-ApplicationVersion');
|
||||
|
||||
if (!window.NzbDrone || !window.NzbDrone.Version) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (version !== window.NzbDrone.Version) {
|
||||
var vent = require('vent');
|
||||
var messenger = require('Shared/Messenger');
|
||||
|
||||
if (!vent || !messenger) {
|
||||
return;
|
||||
}
|
||||
|
||||
messenger.show({
|
||||
message : 'NzbDrone has been updated',
|
||||
hideAfter : 0,
|
||||
id : 'droneUpdated'
|
||||
});
|
||||
|
||||
vent.trigger(vent.Events.ServerUpdated);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ define(
|
||||
|
||||
series: function () {
|
||||
this.setTitle('NzbDrone');
|
||||
AppLayout.mainRegion.show(new SeriesIndexLayout());
|
||||
this.showMainRegion(new SeriesIndexLayout());
|
||||
},
|
||||
|
||||
seriesDetails: function (query) {
|
||||
@ -28,7 +28,7 @@ define(
|
||||
if (series.length !== 0) {
|
||||
var targetSeries = series[0];
|
||||
this.setTitle(targetSeries.get('title'));
|
||||
AppLayout.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries }));
|
||||
this.showMainRegion(new SeriesDetailsLayout({ model: targetSeries }));
|
||||
}
|
||||
else {
|
||||
this.showNotFound();
|
||||
|
@ -50,15 +50,6 @@ define(
|
||||
|
||||
this.signalRconnection.reconnected(function() {
|
||||
tryingToReconnect = false;
|
||||
|
||||
var currentVersion = StatusModel.get('version');
|
||||
|
||||
var promise = StatusModel.fetch();
|
||||
promise.done(function () {
|
||||
if (StatusModel.get('version') !== currentVersion) {
|
||||
vent.trigger(vent.Events.ServerUpdated);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.signalRconnection.disconnected(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user