2012-01-19 06:01:47 +01:00
|
|
|
|
using System.Linq;
|
2011-03-23 06:19:23 +01:00
|
|
|
|
using System.Web.Mvc;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Jobs;
|
2011-03-23 06:19:23 +01:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Web.Models;
|
|
|
|
|
using Telerik.Web.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HistoryController : Controller
|
|
|
|
|
{
|
2011-04-10 04:44:01 +02:00
|
|
|
|
private readonly HistoryProvider _historyProvider;
|
2011-08-27 02:59:51 +02:00
|
|
|
|
private readonly JobProvider _jobProvider;
|
2011-03-23 06:19:23 +01:00
|
|
|
|
|
2011-08-27 02:59:51 +02:00
|
|
|
|
public HistoryController(HistoryProvider historyProvider, JobProvider jobProvider)
|
2011-03-23 06:19:23 +01:00
|
|
|
|
{
|
|
|
|
|
_historyProvider = historyProvider;
|
2011-08-27 02:59:51 +02:00
|
|
|
|
_jobProvider = jobProvider;
|
2011-03-23 06:19:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-06 04:04:35 +02:00
|
|
|
|
public JsonResult Trim()
|
2011-03-23 06:19:23 +01:00
|
|
|
|
{
|
|
|
|
|
_historyProvider.Trim();
|
2012-01-19 06:01:47 +01:00
|
|
|
|
return JsonNotificationResult.Info("Trimmed History");
|
2011-03-23 06:19:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-06 04:04:35 +02:00
|
|
|
|
public JsonResult Purge()
|
2011-03-23 06:19:23 +01:00
|
|
|
|
{
|
|
|
|
|
_historyProvider.Purge();
|
2012-01-19 06:01:47 +01:00
|
|
|
|
return JsonNotificationResult.Info("History Cleared");
|
2011-03-23 06:19:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-27 02:59:51 +02:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public JsonResult Delete(int historyId)
|
|
|
|
|
{
|
|
|
|
|
//Delete the existing item from history
|
|
|
|
|
_historyProvider.Delete(historyId);
|
|
|
|
|
|
2012-01-19 06:01:47 +01:00
|
|
|
|
return JsonNotificationResult.Info("History Item Deleted");
|
2011-08-27 02:59:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public JsonResult Redownload(int historyId, int episodeId)
|
|
|
|
|
{
|
|
|
|
|
//Delete the existing item from history
|
|
|
|
|
_historyProvider.Delete(historyId);
|
|
|
|
|
|
|
|
|
|
//Queue a job to download the replacement episode
|
|
|
|
|
_jobProvider.QueueJob(typeof(EpisodeSearchJob), episodeId);
|
|
|
|
|
|
2012-01-19 06:01:47 +01:00
|
|
|
|
return JsonNotificationResult.Info("Episode Redownload Started");
|
2011-08-27 02:59:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-23 06:19:23 +01:00
|
|
|
|
[GridAction]
|
|
|
|
|
public ActionResult _AjaxBinding()
|
|
|
|
|
{
|
2011-06-20 01:44:45 +02:00
|
|
|
|
var history = _historyProvider.AllItemsWithRelationships().Select(h => new HistoryModel
|
2011-06-14 17:07:48 +02:00
|
|
|
|
{
|
2011-06-20 01:44:45 +02:00
|
|
|
|
HistoryId = h.HistoryId,
|
2011-08-31 02:15:22 +02:00
|
|
|
|
SeriesId = h.SeriesId,
|
2011-06-20 01:44:45 +02:00
|
|
|
|
SeasonNumber = h.Episode.SeasonNumber,
|
|
|
|
|
EpisodeNumber = h.Episode.EpisodeNumber,
|
|
|
|
|
EpisodeTitle = h.Episode.Title,
|
|
|
|
|
EpisodeOverview = h.Episode.Overview,
|
|
|
|
|
SeriesTitle = h.SeriesTitle,
|
|
|
|
|
NzbTitle = h.NzbTitle,
|
|
|
|
|
Quality = h.Quality.ToString(),
|
|
|
|
|
IsProper = h.IsProper,
|
|
|
|
|
Date = h.Date,
|
2011-08-27 02:59:51 +02:00
|
|
|
|
Indexer = h.Indexer,
|
|
|
|
|
EpisodeId = h.EpisodeId
|
2011-06-14 17:07:48 +02:00
|
|
|
|
});
|
2011-03-23 06:19:23 +01:00
|
|
|
|
|
|
|
|
|
return View(new GridModel(history));
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-10 04:44:01 +02:00
|
|
|
|
}
|