Fixed: Only show install/cannot install on the latest version

This commit is contained in:
Mark McDowall 2014-10-31 08:42:09 -07:00
parent 86aba08289
commit 877a851fe9
3 changed files with 20 additions and 15 deletions

View File

@ -22,17 +22,19 @@ namespace NzbDrone.Api.Update
.OrderByDescending(u => u.Version)
.InjectTo<List<UpdateResource>>();
foreach (var updateResource in resources)
{
if (updateResource.Version > BuildInfo.Version)
{
updateResource.IsUpgrade = true;
}
var first = resources.First();
first.Latest = true;
else if (updateResource.Version == BuildInfo.Version)
{
updateResource.Installed = true;
}
if (first.Version > BuildInfo.Version)
{
first.Installable = true;
}
var installed = resources.SingleOrDefault(r => r.Version == BuildInfo.Version);
if (installed != null)
{
installed.Installed = true;
}
return resources;

View File

@ -14,8 +14,9 @@ namespace NzbDrone.Api.Update
public DateTime ReleaseDate { get; set; }
public String FileName { get; set; }
public String Url { get; set; }
public Boolean IsUpgrade { get; set; }
public Boolean Installed { get; set; }
public Boolean Installable { get; set; }
public Boolean Latest { get; set; }
public UpdateChanges Changes { get; set; }
public String Hash { get; set; }
}

View File

@ -8,10 +8,12 @@
{{#if installed}}
<span class="label label-success">Installed</span>
{{else}}
{{#if isUpgrade}}
<span class="label label-default install-update x-install-update">Install</span>
{{else}}
<span class="label label-default label-disabled" title="Cannot install an older version">Install</span>
{{#if latest}}
{{#if installable}}
<span class="label label-default install-update x-install-update">Install</span>
{{else}}
<span class="label label-default label-disabled" title="Cannot install an older version">Install</span>
{{/if}}
{{/if}}
{{/if}}
</span>