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) .OrderByDescending(u => u.Version)
.InjectTo<List<UpdateResource>>(); .InjectTo<List<UpdateResource>>();
foreach (var updateResource in resources) var first = resources.First();
{ first.Latest = true;
if (updateResource.Version > BuildInfo.Version)
{
updateResource.IsUpgrade = true;
}
else if (updateResource.Version == BuildInfo.Version) if (first.Version > BuildInfo.Version)
{ {
updateResource.Installed = true; first.Installable = true;
} }
var installed = resources.SingleOrDefault(r => r.Version == BuildInfo.Version);
if (installed != null)
{
installed.Installed = true;
} }
return resources; return resources;

View File

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

View File

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