Updates cleanup

This commit is contained in:
Mark McDowall 2013-10-06 15:22:43 -07:00
parent 27511769ae
commit 308f76d0fe
5 changed files with 50 additions and 27 deletions

View File

@ -5,6 +5,7 @@ using Nancy;
using Newtonsoft.Json;
using NzbDrone.Api.Extensions;
using NzbDrone.Api.REST;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Update;
using NzbDrone.Api.Mapping;
@ -30,9 +31,17 @@ namespace NzbDrone.Api.Update
.OrderByDescending(u => u.Version)
.InjectTo<List<UpdateResource>>();
if (resources.Any())
foreach (var updateResource in resources)
{
resources.First().Latest = true;
if (updateResource.Version > BuildInfo.Version)
{
updateResource.IsUpgrade = true;
}
else if (updateResource.Version == BuildInfo.Version)
{
updateResource.Installed = true;
}
}
return resources;
@ -58,7 +67,8 @@ namespace NzbDrone.Api.Update
public DateTime ReleaseDate { get; set; }
public String FileName { get; set; }
public String Url { get; set; }
public Boolean Latest { get; set; }
public Boolean IsUpgrade { get; set; }
public Boolean Installed { get; set; }
public UpdateChanges Changes { get; set; }
}
}

View File

@ -0,0 +1,26 @@
'use strict';
define(
[
'handlebars',
'System/StatusModel'
], function (Handlebars, StatusModel) {
Handlebars.registerHelper('if_windows', function(options) {
if (StatusModel.get('isWindows'))
{
return options.fn(this);
}
return options.inverse(this);
});
Handlebars.registerHelper('if_linux', function(options) {
if (StatusModel.get('isLinux'))
{
return options.fn(this);
}
return options.inverse(this);
});
});

View File

@ -1,22 +0,0 @@
'use strict';
define(
[
'handlebars'
], function (Handlebars) {
Handlebars.registerHelper('currentVersion', function (version, latest) {
var currentVersion = window.NzbDrone.ServerStatus.version;
if (currentVersion === version)
{
return new Handlebars.SafeString('<i class="icon-ok" title="Installed"></i>');
}
if (latest) {
return new Handlebars.SafeString('<span class="label label-inverse install-update x-install-update">Install</span>');
}
return '';
});
});

View File

@ -9,7 +9,7 @@ define(
'Handlebars/Helpers/Episode',
'Handlebars/Helpers/Series',
'Handlebars/Helpers/Quality',
'Handlebars/Helpers/Version',
'Handlebars/Helpers/System',
'Handlebars/Handlebars.Debug'
], function (Templates) {
return function () {

View File

@ -1,6 +1,15 @@
<div class="update">
<fieldset>
<legend>{{version}} <span class="date">- {{ShortDate releaseDate}} {{currentVersion version latest}}</span></legend>
<legend>{{version}}
<span class="date">
- {{ShortDate releaseDate}}
{{#if installed}}<i class="icon-ok" title="Installed"></i>{{/if}}
{{#if_windows}}
{{#if isUpgrade}}<span class="label label-inverse install-update x-install-update">Install</span>{{/if}}
{{/if_windows}}
</span>
</legend>
{{#with changes}}
{{#each new}}