diff --git a/NzbDrone.Web/Controllers/UpdateController.cs b/NzbDrone.Web/Controllers/UpdateController.cs index 8a2982bd3..fc2033657 100644 --- a/NzbDrone.Web/Controllers/UpdateController.cs +++ b/NzbDrone.Web/Controllers/UpdateController.cs @@ -46,5 +46,19 @@ namespace NzbDrone.Web.Controllers ViewBag.Log = _diskProvider.ReadAllText(filepath).Replace(Environment.NewLine, "
"); return View(); } + + [HttpGet] + public ActionResult Post(string expectedVersion) + { + var model = new PostUpgradeModel(); + model.CurrentVersion = _enviromentProvider.Version; + model.ExpectedVersion = Version.Parse(expectedVersion); + model.Success = model.CurrentVersion >= model.ExpectedVersion; + + if (!model.Success) + model.LogFile = _updateProvider.UpdateLogFile().FirstOrDefault(); + + return View(model); + } } } diff --git a/NzbDrone.Web/Models/PostUpgradeModel.cs b/NzbDrone.Web/Models/PostUpgradeModel.cs new file mode 100644 index 000000000..3d17fb2a1 --- /dev/null +++ b/NzbDrone.Web/Models/PostUpgradeModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace NzbDrone.Web.Models +{ + public class PostUpgradeModel + { + public Version CurrentVersion { get; set; } + public Version ExpectedVersion { get; set; } + public bool Success { get; set; } + public KeyValuePair LogFile { get; set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 4abc1bb7f..46bd02761 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -228,6 +228,7 @@ + @@ -509,6 +510,7 @@ + diff --git a/NzbDrone.Web/Scripts/NzbDrone/Notification.js b/NzbDrone.Web/Scripts/NzbDrone/Notification.js index 1a6d7acee..0eaa53086 100644 --- a/NzbDrone.Web/Scripts/NzbDrone/Notification.js +++ b/NzbDrone.Web/Scripts/NzbDrone/Notification.js @@ -34,16 +34,17 @@ jqXHR.error(function (xhr, textStatus, thrownError) { //ignore notification errors. - if (this.url.indexOf("/notification/Comet") !== 0) { - alert("Status: " + textStatus + ", Error: " + thrownError); - $.gritter.add({ - title: 'Request failed', - text: this.url, - image: '../../content/images/error.png', - class_name: 'gritter-fail', - time: 10000 - }); - } + if (this.url.indexOf("/notification/Comet") === 0 || this.url.indexOf("/Health/Index") === 0) + return; + + alert("Status: " + textStatus + ", Error: " + thrownError); + $.gritter.add({ + title: 'Request failed', + text: this.url, + image: '../../content/images/error.png', + class_name: 'gritter-fail', + time: 10000 + }); }); }); @@ -71,6 +72,9 @@ $(window).load(function () { data: { message: currentMessage }, success: function (data) { notificationCallback(data); + }, + error: function () { + $.doTimeout(5000, refreshNotifications); } }); } diff --git a/NzbDrone.Web/Views/Update/Index.cshtml b/NzbDrone.Web/Views/Update/Index.cshtml index 20e6cea24..6c06fe61a 100644 --- a/NzbDrone.Web/Views/Update/Index.cshtml +++ b/NzbDrone.Web/Views/Update/Index.cshtml @@ -1,5 +1,6 @@ @model NzbDrone.Web.Models.UpdateModel @{ViewBag.Title = "Update";} + @if (Model.UpdatePackage == null) {

@@ -9,7 +10,7 @@ else {

Available Update: @Model.UpdatePackage.Version - @Ajax.ActionLink("Update", "StartUpdate", "Update", null) + @Ajax.ActionLink("Update", "StartUpdate", "Update", new AjaxOptions{ OnSuccess = "updateStarted" })

} @if (Model.LogFiles.Count != 0) @@ -26,3 +27,33 @@ else } } + +@section Scripts +{ + +} \ No newline at end of file diff --git a/NzbDrone.Web/Views/Update/Post.cshtml b/NzbDrone.Web/Views/Update/Post.cshtml new file mode 100644 index 000000000..196569f40 --- /dev/null +++ b/NzbDrone.Web/Views/Update/Post.cshtml @@ -0,0 +1,19 @@ +@model NzbDrone.Web.Models.PostUpgradeModel +@{ + ViewBag.Title = "Post Upgrade"; +} + + @if (Model.Success) + { +

Successfully upgraded to @(Model.CurrentVersion)

+ } + + else{ +

Failed to upgrade to @(Model.ExpectedVersion)

+ +
+

Please review the log file: + + @Model.LogFile.Key.ToString("MMM dd, hh:mm tt")

+
+ }