mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Manually mark a release as failed to start failed download process (history details)
This commit is contained in:
parent
70127125c2
commit
da0f04d4c8
@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using Nancy;
|
||||
using Nancy.ModelBinding;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.History;
|
||||
|
||||
namespace NzbDrone.Api.History
|
||||
@ -9,11 +12,15 @@ namespace NzbDrone.Api.History
|
||||
public class HistoryModule : NzbDroneRestModule<HistoryResource>
|
||||
{
|
||||
private readonly IHistoryService _historyService;
|
||||
private readonly IFailedDownloadService _failedDownloadService;
|
||||
|
||||
public HistoryModule(IHistoryService historyService)
|
||||
public HistoryModule(IHistoryService historyService, IFailedDownloadService failedDownloadService)
|
||||
{
|
||||
_historyService = historyService;
|
||||
_failedDownloadService = failedDownloadService;
|
||||
GetResourcePaged = GetHistory;
|
||||
|
||||
Post["/failed"] = x => MarkAsFailed();
|
||||
}
|
||||
|
||||
private PagingResource<HistoryResource> GetHistory(PagingResource<HistoryResource> pagingResource)
|
||||
@ -36,5 +43,12 @@ private PagingResource<HistoryResource> GetHistory(PagingResource<HistoryResourc
|
||||
|
||||
return ApplyToPage(_historyService.Paged, pagingSpec);
|
||||
}
|
||||
|
||||
private Response MarkAsFailed()
|
||||
{
|
||||
var id = (int)Request.Form.Id;
|
||||
_failedDownloadService.MarkAsFailed(id);
|
||||
return new Object().AsResponse();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,12 @@
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public class FailedDownloadService : IExecute<FailedDownloadCommand>
|
||||
public interface IFailedDownloadService
|
||||
{
|
||||
void MarkAsFailed(int historyId);
|
||||
}
|
||||
|
||||
public class FailedDownloadService : IFailedDownloadService, IExecute<FailedDownloadCommand>
|
||||
{
|
||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||
private readonly IHistoryService _historyService;
|
||||
@ -37,6 +42,12 @@ public FailedDownloadService(IProvideDownloadClient downloadClientProvider,
|
||||
_downloadClient = _downloadClientProvider.GetDownloadClient();
|
||||
}
|
||||
|
||||
public void MarkAsFailed(int historyId)
|
||||
{
|
||||
var item = _historyService.Get(historyId);
|
||||
PublishDownloadFailedEvent(new List<History.History> {item}, "Manually marked as failed");
|
||||
}
|
||||
|
||||
private void CheckForFailedDownloads()
|
||||
{
|
||||
if (!_configService.EnableFailedDownloadHandling)
|
||||
|
@ -22,6 +22,7 @@ public interface IHistoryService
|
||||
List<History> Failed();
|
||||
List<History> Grabbed();
|
||||
History MostRecentForEpisode(int episodeId);
|
||||
History Get(int id);
|
||||
}
|
||||
|
||||
public class HistoryService : IHistoryService, IHandle<EpisodeGrabbedEvent>, IHandle<EpisodeImportedEvent>, IHandle<DownloadFailedEvent>
|
||||
@ -65,6 +66,11 @@ public History MostRecentForEpisode(int episodeId)
|
||||
return _historyRepository.MostRecentForEpisode(episodeId);
|
||||
}
|
||||
|
||||
public History Get(int id)
|
||||
{
|
||||
return _historyRepository.Get(id);
|
||||
}
|
||||
|
||||
public void Purge()
|
||||
{
|
||||
_historyRepository.Purge();
|
||||
|
@ -1,10 +1,30 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
'vent',
|
||||
'marionette',
|
||||
'jquery'
|
||||
], function (vent, Marionette, $) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'History/Details/HistoryDetailsViewTemplate'
|
||||
template: 'History/Details/HistoryDetailsViewTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-mark-as-failed': '_markAsFailed'
|
||||
},
|
||||
|
||||
_markAsFailed: function () {
|
||||
var url = window.NzbDrone.ApiRoot + '/history/failed';
|
||||
var data = {
|
||||
id: this.model.get('id')
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data
|
||||
});
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -63,6 +63,7 @@
|
||||
{{/if_eq}}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{#if_eq eventType compare="grabbed"}}<button class="btn btn-danger x-mark-as-failed">mark as failed</button>{{/if_eq}}
|
||||
<button class="btn" data-dismiss="modal">close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user