mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Removed check for update button, latest version will have install link
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
private UpdateResource GetAvailableUpdate()
|
||||
{
|
||||
var update = _checkUpdateService.AvailableUpdate();
|
||||
var response = new UpdateResource();
|
||||
|
||||
if (update != null)
|
||||
{
|
||||
return update.InjectTo<UpdateResource>();
|
||||
}
|
||||
|
||||
return response;
|
||||
Post["/"] = x=> InstallUpdate();
|
||||
}
|
||||
|
||||
private List<UpdateResource> GetRecentUpdates()
|
||||
{
|
||||
return ToListResource(_recentUpdateProvider.GetRecentUpdatePackages);
|
||||
var resources = _recentUpdateProvider.GetRecentUpdatePackages()
|
||||
.OrderByDescending(u => u.Version)
|
||||
.InjectTo<List<UpdateResource>>();
|
||||
|
||||
if (resources.Any())
|
||||
{
|
||||
resources.First().Latest = true;
|
||||
}
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
private Response InstallUpdate()
|
||||
{
|
||||
var updateResource = Request.Body.FromJson<UpdateResource>();
|
||||
|
||||
var updatePackage = updateResource.InjectTo<UpdatePackage>();
|
||||
_installUpdateService.InstallUpdate(updatePackage);
|
||||
|
||||
return updateResource.AsResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +60,7 @@ public class UpdateResource : RestResource
|
||||
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 @@
|
||||
|
||||
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 @@ public InstallUpdateService(ICheckUpdateService checkUpdateService, IAppFolderIn
|
||||
_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 @@ private void InstallUpdate(UpdatePackage updatePackage)
|
||||
_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…
Reference in New Issue
Block a user