2011-04-28 09:04:57 +03:00
|
|
|
using System;
|
2011-06-14 18:07:48 +03:00
|
|
|
using System.Collections.Generic;
|
2011-04-28 09:04:57 +03:00
|
|
|
using System.Linq;
|
2011-03-23 07:19:23 +02:00
|
|
|
using System.Web.Mvc;
|
2011-04-28 07:27:02 +03:00
|
|
|
using NzbDrone.Core.Model;
|
2011-03-23 07:19:23 +02:00
|
|
|
using NzbDrone.Core.Providers;
|
2011-08-27 03:59:51 +03:00
|
|
|
using NzbDrone.Core.Providers.Jobs;
|
2011-03-23 07:19:23 +02:00
|
|
|
using NzbDrone.Web.Models;
|
|
|
|
using Telerik.Web.Mvc;
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
{
|
|
|
|
public class HistoryController : Controller
|
|
|
|
{
|
2011-04-10 05:44:01 +03:00
|
|
|
private readonly HistoryProvider _historyProvider;
|
2011-08-27 03:59:51 +03:00
|
|
|
private readonly JobProvider _jobProvider;
|
2011-03-23 07:19:23 +02:00
|
|
|
|
2011-08-27 03:59:51 +03:00
|
|
|
public HistoryController(HistoryProvider historyProvider, JobProvider jobProvider)
|
2011-03-23 07:19:23 +02:00
|
|
|
{
|
|
|
|
_historyProvider = historyProvider;
|
2011-08-27 03:59:51 +03:00
|
|
|
_jobProvider = jobProvider;
|
2011-03-23 07:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// GET: /History/
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
{
|
|
|
|
return View();
|
|
|
|
}
|
|
|
|
|
2011-08-06 05:04:35 +03:00
|
|
|
public JsonResult Trim()
|
2011-03-23 07:19:23 +02:00
|
|
|
{
|
|
|
|
_historyProvider.Trim();
|
2011-08-22 04:00:12 +03:00
|
|
|
return Json(new NotificationResult() { Title = "Trimmed History items"});
|
2011-03-23 07:19:23 +02:00
|
|
|
}
|
|
|
|
|
2011-08-06 05:04:35 +03:00
|
|
|
public JsonResult Purge()
|
2011-03-23 07:19:23 +02:00
|
|
|
{
|
|
|
|
_historyProvider.Purge();
|
2011-08-22 04:00:12 +03:00
|
|
|
return Json(new NotificationResult() { Title = "History Cleared" });
|
2011-03-23 07:19:23 +02:00
|
|
|
}
|
|
|
|
|
2011-08-27 03:59:51 +03:00
|
|
|
[HttpPost]
|
|
|
|
public JsonResult Delete(int historyId)
|
|
|
|
{
|
|
|
|
//Delete the existing item from history
|
|
|
|
_historyProvider.Delete(historyId);
|
|
|
|
|
|
|
|
return Json(new NotificationResult() { Title = "History Item Deleted" });
|
|
|
|
}
|
|
|
|
|
|
|
|
[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);
|
|
|
|
|
|
|
|
return Json(new NotificationResult() { Title = "Episode Redownload Started" });
|
|
|
|
}
|
|
|
|
|
2011-03-23 07:19:23 +02:00
|
|
|
[GridAction]
|
|
|
|
public ActionResult _AjaxBinding()
|
|
|
|
{
|
2011-06-20 02:44:45 +03:00
|
|
|
var history = _historyProvider.AllItemsWithRelationships().Select(h => new HistoryModel
|
2011-06-14 18:07:48 +03:00
|
|
|
{
|
2011-06-20 02:44:45 +03:00
|
|
|
HistoryId = h.HistoryId,
|
|
|
|
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 03:59:51 +03:00
|
|
|
Indexer = h.Indexer,
|
|
|
|
EpisodeId = h.EpisodeId
|
2011-06-14 18:07:48 +03:00
|
|
|
});
|
2011-03-23 07:19:23 +02:00
|
|
|
|
|
|
|
return View(new GridModel(history));
|
|
|
|
}
|
|
|
|
}
|
2011-04-10 05:44:01 +03:00
|
|
|
}
|