Removed check for update button, latest version will have install link

pull/4/head
Mark McDowall 11 years ago
parent e4b2c30616
commit 03fac8bfe5

@ -1,6 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.SignalR.Hosting;
using Nancy;
using Nancy.ModelBinding;
using Newtonsoft.Json;
using NzbDrone.Api.Extensions;
using NzbDrone.Api.REST;
using NzbDrone.Core.Update;
using NzbDrone.Api.Mapping;
@ -9,33 +14,40 @@ namespace NzbDrone.Api.Update
{
public class UpdateModule : NzbDroneRestModule<UpdateResource>
{
private readonly ICheckUpdateService _checkUpdateService;
private readonly IRecentUpdateProvider _recentUpdateProvider;
private readonly IInstallUpdates _installUpdateService;
public UpdateModule(ICheckUpdateService checkUpdateService,
IRecentUpdateProvider recentUpdateProvider)
public UpdateModule(IRecentUpdateProvider recentUpdateProvider,
IInstallUpdates installUpdateService)
{
_checkUpdateService = checkUpdateService;
_recentUpdateProvider = recentUpdateProvider;
_installUpdateService = installUpdateService;
GetResourceAll = GetRecentUpdates;
Post["/"] = x=> InstallUpdate();
}
private UpdateResource GetAvailableUpdate()
private List<UpdateResource> GetRecentUpdates()
{
var update = _checkUpdateService.AvailableUpdate();
var response = new UpdateResource();
var resources = _recentUpdateProvider.GetRecentUpdatePackages()
.OrderByDescending(u => u.Version)
.InjectTo<List<UpdateResource>>();
if (update != null)
if (resources.Any())
{
return update.InjectTo<UpdateResource>();
resources.First().Latest = true;
}
return response;
return resources;
}
private List<UpdateResource> GetRecentUpdates()
private Response InstallUpdate()
{
return ToListResource(_recentUpdateProvider.GetRecentUpdatePackages);
var updateResource = Request.Body.FromJson<UpdateResource>();
var updatePackage = updateResource.InjectTo<UpdatePackage>();
_installUpdateService.InstallUpdate(updatePackage);
return updateResource.AsResponse();
}
}
@ -48,7 +60,7 @@ 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 UpdateChanges Changes { get; set; }
}
}

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
@ -10,7 +11,12 @@ using NzbDrone.Core.Instrumentation;
namespace NzbDrone.Core.Update
{
public class InstallUpdateService : IExecute<ApplicationUpdateCommand>
public interface IInstallUpdates
{
void InstallUpdate(UpdatePackage updatePackage);
}
public class InstallUpdateService : IInstallUpdates, IExecute<ApplicationUpdateCommand>
{
private readonly ICheckUpdateService _checkUpdateService;
private readonly Logger _logger;
@ -35,19 +41,7 @@ namespace NzbDrone.Core.Update
_logger = logger;
}
public void Execute(ApplicationUpdateCommand message)
{
_logger.ProgressDebug("Checking for updates");
var latestAvailable = _checkUpdateService.AvailableUpdate();
if (latestAvailable != null)
{
InstallUpdate(latestAvailable);
}
}
private void InstallUpdate(UpdatePackage updatePackage)
public void InstallUpdate(UpdatePackage updatePackage)
{
try
{
@ -84,5 +78,16 @@ namespace NzbDrone.Core.Update
_logger.ErrorException("Update process failed", ex);
}
}
public void Execute(ApplicationUpdateCommand message)
{
_logger.ProgressDebug("Checking for updates");
var latestAvailable = _checkUpdateService.AvailableUpdate();
if (latestAvailable != null)
{
InstallUpdate(latestAvailable);
}
}
}
}

@ -5,15 +5,11 @@ namespace NzbDrone.Core.Update
{
public class UpdatePackage
{
public string Id { get; set; }
public Version Version { get; set; }
public String Branch { get; set; }
public DateTime ReleaseDate { get; set; }
public String FileName { get; set; }
public String Url { get; set; }
public UpdateChanges Changes { get; set; }
}
}

@ -5,7 +5,7 @@ define(
'handlebars'
], function (Handlebars) {
Handlebars.registerHelper('currentVersion', function (version) {
Handlebars.registerHelper('currentVersion', function (version, latest) {
var currentVersion = window.NzbDrone.ServerStatus.version;
if (currentVersion === version)
@ -13,6 +13,10 @@ define(
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 '';
});
});

@ -6,6 +6,14 @@ define(
'marionette'
], function (App, Marionette) {
return Marionette.ItemView.extend({
template: 'System/Update/UpdateItemViewTemplate'
template: 'System/Update/UpdateItemViewTemplate',
events: {
'click .x-install-update': '_installUpdate'
},
_installUpdate: function () {
this.model.save();
}
});
});

@ -1,6 +1,6 @@
<div class="update">
<fieldset>
<legend>{{version}} <span class="date">- {{ShortDate releaseDate}} {{currentVersion version}}</span></legend>
<legend>{{version}} <span class="date">- {{ShortDate releaseDate}} {{currentVersion version latest}}</span></legend>
{{#with changes}}
{{#each new}}

@ -5,28 +5,13 @@ define(
'backgrid',
'System/Update/UpdateCollection',
'System/Update/UpdateCollectionView',
'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView'
], function (Marionette, Backgrid, UpdateCollection, UpdateCollectionView, ToolbarLayout, LoadingView) {
], function (Marionette, Backgrid, UpdateCollection, UpdateCollectionView, LoadingView) {
return Marionette.Layout.extend({
template: 'System/Update/UpdateLayoutTemplate',
regions: {
updates: '#x-updates',
toolbar: '#x-toolbar'
},
leftSideButtons: {
type : 'default',
storeState: false,
items :
[
{
title : 'Check for Update',
icon : 'icon-nd-update',
command: 'applicationUpdate'
}
]
updates: '#x-updates'
},
initialize: function () {
@ -35,7 +20,6 @@ define(
onRender: function () {
this.updates.show(new LoadingView());
this._showToolbar();
var self = this;
var promise = this.updateCollection.fetch();
@ -43,16 +27,6 @@ define(
promise.done(function (){
self.updates.show(new UpdateCollectionView({ collection: self.updateCollection }));
});
},
_showToolbar: function () {
this.toolbar.show(new ToolbarLayout({
left :
[
this.leftSideButtons
],
context: this
}));
}
});
});

@ -1,5 +1,4 @@
<div id="x-toolbar"/>
<div class="row">
<div class="row">
<div class="span12">
<div id="x-updates"/>
</div>

@ -1,3 +1,5 @@
@import '../../Shared/Styles/clickable';
.update {
margin-bottom: 30px;
@ -22,4 +24,9 @@
margin-bottom: 2px;
font-size: 13px;
}
.install-update {
.clickable();
margin-left: 10px;
}
}
Loading…
Cancel
Save