From aa26d68f183b32658463821892d35601a5e085ee Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 18 Oct 2013 17:48:14 -0700 Subject: [PATCH] Updating manually now uses a command so it shows progress --- src/NzbDrone.Api/Update/UpdateModule.cs | 11 ----------- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + .../Update/Commands/InstallUpdateCommand.cs | 13 +++++++++++++ src/NzbDrone.Core/Update/InstallUpdateService.cs | 7 ++++++- src/UI/System/Update/UpdateItemView.js | 7 ++++--- 5 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 src/NzbDrone.Core/Update/Commands/InstallUpdateCommand.cs diff --git a/src/NzbDrone.Api/Update/UpdateModule.cs b/src/NzbDrone.Api/Update/UpdateModule.cs index 2ade0b76d..c35f3f50f 100644 --- a/src/NzbDrone.Api/Update/UpdateModule.cs +++ b/src/NzbDrone.Api/Update/UpdateModule.cs @@ -22,7 +22,6 @@ namespace NzbDrone.Api.Update _recentUpdateProvider = recentUpdateProvider; _installUpdateService = installUpdateService; GetResourceAll = GetRecentUpdates; - Post["/"] = x=> InstallUpdate(); } private List GetRecentUpdates() @@ -46,16 +45,6 @@ namespace NzbDrone.Api.Update return resources; } - - private Response InstallUpdate() - { - var updateResource = Request.Body.FromJson(); - - var updatePackage = updateResource.InjectTo(); - _installUpdateService.InstallUpdate(updatePackage); - - return updateResource.AsResponse(); - } } public class UpdateResource : RestResource diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 5c25f088e..3906a937b 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -570,6 +570,7 @@ + diff --git a/src/NzbDrone.Core/Update/Commands/InstallUpdateCommand.cs b/src/NzbDrone.Core/Update/Commands/InstallUpdateCommand.cs new file mode 100644 index 000000000..8dfe88f1c --- /dev/null +++ b/src/NzbDrone.Core/Update/Commands/InstallUpdateCommand.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NzbDrone.Core.Messaging.Commands; + +namespace NzbDrone.Core.Update.Commands +{ + public class InstallUpdateCommand : Command + { + public UpdatePackage UpdatePackage { get; set; } + } +} diff --git a/src/NzbDrone.Core/Update/InstallUpdateService.cs b/src/NzbDrone.Core/Update/InstallUpdateService.cs index 6b4b10ab3..15b1e8bad 100644 --- a/src/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/src/NzbDrone.Core/Update/InstallUpdateService.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Core.Update void InstallUpdate(UpdatePackage updatePackage); } - public class InstallUpdateService : IInstallUpdates, IExecute + public class InstallUpdateService : IInstallUpdates, IExecute, IExecute { private readonly ICheckUpdateService _checkUpdateService; private readonly Logger _logger; @@ -89,5 +89,10 @@ namespace NzbDrone.Core.Update InstallUpdate(latestAvailable); } } + + public void Execute(InstallUpdateCommand message) + { + InstallUpdate(message.UpdatePackage); + } } } diff --git a/src/UI/System/Update/UpdateItemView.js b/src/UI/System/Update/UpdateItemView.js index 79186cd65..362b76690 100644 --- a/src/UI/System/Update/UpdateItemView.js +++ b/src/UI/System/Update/UpdateItemView.js @@ -2,8 +2,9 @@ define( [ - 'marionette' - ], function (Marionette) { + 'marionette', + 'Commands/CommandController' + ], function (Marionette, CommandController) { return Marionette.ItemView.extend({ template: 'System/Update/UpdateItemViewTemplate', @@ -12,7 +13,7 @@ define( }, _installUpdate: function () { - this.model.save(); + CommandController.Execute('installUpdate', { updatePackage: this.model.toJSON() }); } }); });