mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-12 16:13:58 -07:00
New: After an update the update page will redirect to a success or failure page, depending on the result.
Fix: Notifications will attempt to reconnect to NzbDrone after it is shutdown.
This commit is contained in:
parent
14387b0b28
commit
6e86db66c8
6 changed files with 96 additions and 11 deletions
|
@ -46,5 +46,19 @@ namespace NzbDrone.Web.Controllers
|
||||||
ViewBag.Log = _diskProvider.ReadAllText(filepath).Replace(Environment.NewLine, "<br/>");
|
ViewBag.Log = _diskProvider.ReadAllText(filepath).Replace(Environment.NewLine, "<br/>");
|
||||||
return View();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
15
NzbDrone.Web/Models/PostUpgradeModel.cs
Normal file
15
NzbDrone.Web/Models/PostUpgradeModel.cs
Normal file
|
@ -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<DateTime, string> LogFile { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -228,6 +228,7 @@
|
||||||
<Compile Include="Models\DataTablesParams.cs" />
|
<Compile Include="Models\DataTablesParams.cs" />
|
||||||
<Compile Include="Models\JobModel.cs" />
|
<Compile Include="Models\JobModel.cs" />
|
||||||
<Compile Include="Models\LogModel.cs" />
|
<Compile Include="Models\LogModel.cs" />
|
||||||
|
<Compile Include="Models\PostUpgradeModel.cs" />
|
||||||
<Compile Include="Models\UpcomingEpisodesModel.cs" />
|
<Compile Include="Models\UpcomingEpisodesModel.cs" />
|
||||||
<Compile Include="Models\SeasonModel.cs" />
|
<Compile Include="Models\SeasonModel.cs" />
|
||||||
<Compile Include="Models\SeriesDetailsModel.cs" />
|
<Compile Include="Models\SeriesDetailsModel.cs" />
|
||||||
|
@ -509,6 +510,7 @@
|
||||||
<None Include="Content\DataTables-1.9.0\media\images\Sorting icons.psd" />
|
<None Include="Content\DataTables-1.9.0\media\images\Sorting icons.psd" />
|
||||||
<Content Include="Views\Settings\Plex.cshtml" />
|
<Content Include="Views\Settings\Plex.cshtml" />
|
||||||
<Content Include="Views\Shared\NoSeriesBanner.cshtml" />
|
<Content Include="Views\Shared\NoSeriesBanner.cshtml" />
|
||||||
|
<Content Include="Views\Update\Post.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||||
|
|
|
@ -34,16 +34,17 @@
|
||||||
|
|
||||||
jqXHR.error(function (xhr, textStatus, thrownError) {
|
jqXHR.error(function (xhr, textStatus, thrownError) {
|
||||||
//ignore notification errors.
|
//ignore notification errors.
|
||||||
if (this.url.indexOf("/notification/Comet") !== 0) {
|
if (this.url.indexOf("/notification/Comet") === 0 || this.url.indexOf("/Health/Index") === 0)
|
||||||
alert("Status: " + textStatus + ", Error: " + thrownError);
|
return;
|
||||||
$.gritter.add({
|
|
||||||
title: 'Request failed',
|
alert("Status: " + textStatus + ", Error: " + thrownError);
|
||||||
text: this.url,
|
$.gritter.add({
|
||||||
image: '../../content/images/error.png',
|
title: 'Request failed',
|
||||||
class_name: 'gritter-fail',
|
text: this.url,
|
||||||
time: 10000
|
image: '../../content/images/error.png',
|
||||||
});
|
class_name: 'gritter-fail',
|
||||||
}
|
time: 10000
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -71,6 +72,9 @@ $(window).load(function () {
|
||||||
data: { message: currentMessage },
|
data: { message: currentMessage },
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
notificationCallback(data);
|
notificationCallback(data);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
$.doTimeout(5000, refreshNotifications);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
@model NzbDrone.Web.Models.UpdateModel
|
@model NzbDrone.Web.Models.UpdateModel
|
||||||
@{ViewBag.Title = "Update";}
|
@{ViewBag.Title = "Update";}
|
||||||
|
|
||||||
@if (Model.UpdatePackage == null)
|
@if (Model.UpdatePackage == null)
|
||||||
{
|
{
|
||||||
<h2>
|
<h2>
|
||||||
|
@ -9,7 +10,7 @@ else
|
||||||
{
|
{
|
||||||
<h2>
|
<h2>
|
||||||
Available Update: @Model.UpdatePackage.Version
|
Available Update: @Model.UpdatePackage.Version
|
||||||
@Ajax.ActionLink("Update", "StartUpdate", "Update", null)
|
@Ajax.ActionLink("Update", "StartUpdate", "Update", new AjaxOptions{ OnSuccess = "updateStarted" })
|
||||||
</h2>
|
</h2>
|
||||||
}
|
}
|
||||||
@if (Model.LogFiles.Count != 0)
|
@if (Model.LogFiles.Count != 0)
|
||||||
|
@ -26,3 +27,33 @@ else
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@section Scripts
|
||||||
|
{
|
||||||
|
<script type="text/javascript">
|
||||||
|
function updateStarted() {
|
||||||
|
var errors = 0;
|
||||||
|
|
||||||
|
//Pool the server every 5 seconds for a change in state
|
||||||
|
$.doTimeout('updateStarted', 5000, function () {
|
||||||
|
$.ajax({
|
||||||
|
url: '/Health/Index',
|
||||||
|
type: "GET",
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
//Handle the first error that occured
|
||||||
|
errors++;
|
||||||
|
},
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (errors > 0) {
|
||||||
|
//Kill the timer, redirect
|
||||||
|
$.doTimeout('updateStarted');
|
||||||
|
window.location = '/Update/Post?expectedVersion=@Model.UpdatePackage.Version';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
}
|
19
NzbDrone.Web/Views/Update/Post.cshtml
Normal file
19
NzbDrone.Web/Views/Update/Post.cshtml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
@model NzbDrone.Web.Models.PostUpgradeModel
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Post Upgrade";
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (Model.Success)
|
||||||
|
{
|
||||||
|
<h1><strong>Successfully upgraded to @(Model.CurrentVersion)</strong></h1>
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
<h1><strong>Failed to upgrade to @(Model.ExpectedVersion)</strong></h1>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>Please review the log file:
|
||||||
|
<a href="@Url.Action("ViewLog", "Update", new { filePath = Model.LogFile.Value })">
|
||||||
|
@Model.LogFile.Key.ToString("MMM dd, hh:mm tt")</a></h3>
|
||||||
|
</div>
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue