UI for automatic update.

This commit is contained in:
kay.one 2011-11-13 22:01:51 -08:00
parent 571998e70e
commit 8779a37f7f
5 changed files with 77 additions and 5 deletions

View File

@ -14,7 +14,7 @@ namespace NzbDrone.Common
if (logEvent == null || logEvent.Exception == null) return;
if (Debugger.IsAttached || Process.GetCurrentProcess().ProcessName.Contains("JetBrains")) return;
Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName);
Logger.Trace("Sending Exception to Exceptioneer. Process Name: {0}", Process.GetCurrentProcess().ProcessName);
logEvent.Exception.Data.Add("Message", logEvent.Message);

View File

@ -2,6 +2,8 @@
using System.IO;
using System.Linq;
using NLog;
using NLog.Config;
using NLog.Targets;
using NzbDrone.Common;
using NzbDrone.Update.Providers;
@ -26,10 +28,7 @@ namespace NzbDrone.Update
{
Console.WriteLine("Starting NzbDrone Update Client");
LogConfiguration.RegisterConsoleLogger(LogLevel.Trace);
LogConfiguration.RegisterUdpLogger();
LogConfiguration.RegisterExceptioneer();
LogConfiguration.Reload();
InitLoggers();
logger.Info("Initializing update application");
@ -48,6 +47,26 @@ namespace NzbDrone.Update
}
}
private static void InitLoggers()
{
LogConfiguration.RegisterConsoleLogger(LogLevel.Trace);
LogConfiguration.RegisterUdpLogger();
LogConfiguration.RegisterExceptioneer();
var fileTarget = new FileTarget();
fileTarget.AutoFlush = true;
fileTarget.ConcurrentWrites = false;
fileTarget.DeleteOldFileOnStartup = true;
fileTarget.FileName = "upgrade.log";
fileTarget.KeepFileOpen =false;
fileTarget.Layout = "${logger}: ${message} ${exception}";
LogManager.Configuration.AddTarget(fileTarget.GetType().Name, fileTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, fileTarget));
LogConfiguration.Reload();
}
public void Start(string[] args)
{
VerfityArguments(args);

View File

@ -0,0 +1,32 @@
using System.Linq;
using System.Web.Mvc;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers
{
public class UpdateController : Controller
{
private readonly UpdateProvider _updateProvider;
private readonly JobProvider _jobProvider;
public UpdateController(UpdateProvider updateProvider, JobProvider jobProvider)
{
_updateProvider = updateProvider;
_jobProvider = jobProvider;
}
public ActionResult Index()
{
return View(_updateProvider.GetAvilableUpdate());
}
public ActionResult StartUpdate()
{
_jobProvider.QueueJob(typeof(AppUpdateJob), 0, 0);
return Json(new NotificationResult() { Title = "Update will begin shortly", NotificationType = NotificationType.Info, Text = "NzbDrone will restart automatically."});
}
}
}

View File

@ -45,6 +45,7 @@
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="MvcMiniProfiler, Version=1.9.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MiniProfiler.1.9\lib\net40\MvcMiniProfiler.dll</HintPath>
@ -448,6 +449,7 @@
<Compile Include="Controllers\StreamController.cs" />
<Compile Include="Controllers\SystemController.cs" />
<Compile Include="Controllers\UpcomingController.cs" />
<Compile Include="Controllers\UpdateController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
@ -922,6 +924,9 @@
<ItemGroup>
<Content Include="Views\Settings\Prowl.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Update\Index.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -0,0 +1,16 @@
@model NzbDrone.Core.Model.UpdatePackage
@section TitleContent{
Update
}
@if (Model == null)
{
<h2>
There are no updates available.</h2>
}
else
{
<h2>
Available Update: @Model.Version
@Ajax.ActionLink("Update", "StartUpdate", "Update", null)
</h2>
}