diff --git a/NzbDrone.Core/Jobs/DeleteSeriesJob.cs b/NzbDrone.Core/Jobs/DeleteSeriesJob.cs index b02108ab0..f3555fbc3 100644 --- a/NzbDrone.Core/Jobs/DeleteSeriesJob.cs +++ b/NzbDrone.Core/Jobs/DeleteSeriesJob.cs @@ -2,6 +2,7 @@ using System; using Ninject; using NLog; +using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -10,13 +11,15 @@ namespace NzbDrone.Core.Jobs public class DeleteSeriesJob : IJob { private readonly SeriesProvider _seriesProvider; + private readonly DiskProvider _diskProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); [Inject] - public DeleteSeriesJob(SeriesProvider seriesProvider) + public DeleteSeriesJob(SeriesProvider seriesProvider, DiskProvider diskProvider) { _seriesProvider = seriesProvider; + _diskProvider = diskProvider; } public string Name @@ -31,20 +34,30 @@ namespace NzbDrone.Core.Jobs public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) { - DeleteSeries(notification, targetId); + DeleteSeries(notification, targetId, Convert.ToBoolean(secondaryTargetId)); } - private void DeleteSeries(ProgressNotification notification, int seriesId) + private void DeleteSeries(ProgressNotification notification, int seriesId, bool deleteFiles) { Logger.Trace("Deleting Series [{0}]", seriesId); - var title = _seriesProvider.GetSeries(seriesId).Title; + var series = _seriesProvider.GetSeries(seriesId); + var title = series.Title; notification.CurrentMessage = String.Format("Deleting '{0}' from database", title); _seriesProvider.DeleteSeries(seriesId); notification.CurrentMessage = String.Format("Successfully deleted '{0}' from database", title); + + if (deleteFiles) + { + notification.CurrentMessage = String.Format("Deleting files from disk for series '{0}'", title); + + _diskProvider.DeleteFolder(series.Path, true); + + notification.CurrentMessage = String.Format("Successfully deleted files from disk for series '{0}'", title); + } } } } \ No newline at end of file diff --git a/NzbDrone.Web/Content/NzbDrone.css b/NzbDrone.Web/Content/NzbDrone.css index ddc7a878b..1e80b38d8 100644 --- a/NzbDrone.Web/Content/NzbDrone.css +++ b/NzbDrone.Web/Content/NzbDrone.css @@ -243,3 +243,7 @@ button span, input[type="button"] span, input[type="submit"] span, input[type="r { text-decoration: underline; } + +.series-delete-files { + padding-top: 15px; +} \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index ac7098962..e18e7ef4d 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -19,7 +19,6 @@ namespace NzbDrone.Web.Controllers [HandleError] public class SeriesController : Controller { - private readonly EpisodeProvider _episodeProvider; private readonly QualityProvider _qualityProvider; private readonly SeriesProvider _seriesProvider; private readonly JobProvider _jobProvider; @@ -27,12 +26,11 @@ namespace NzbDrone.Web.Controllers // // GET: /Series/ - public SeriesController(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, + public SeriesController(SeriesProvider seriesProvider, QualityProvider qualityProvider, JobProvider jobProvider, SeasonProvider seasonProvider) { _seriesProvider = seriesProvider; - _episodeProvider = episodeProvider; _qualityProvider = qualityProvider; _jobProvider = jobProvider; _seasonProvider = seasonProvider; @@ -80,9 +78,9 @@ namespace NzbDrone.Web.Controllers } [HttpPost] - public EmptyResult DeleteSeries(int seriesId) + public EmptyResult DeleteSeries(int seriesId, bool deleteFiles) { - _jobProvider.QueueJob(typeof(DeleteSeriesJob), seriesId); + _jobProvider.QueueJob(typeof(DeleteSeriesJob), seriesId, Convert.ToInt32(deleteFiles)); return new EmptyResult(); } diff --git a/NzbDrone.Web/Scripts/NzbDrone/series.js b/NzbDrone.Web/Scripts/NzbDrone/series.js index b5558e4a5..b1b06fd6d 100644 --- a/NzbDrone.Web/Scripts/NzbDrone/series.js +++ b/NzbDrone.Web/Scripts/NzbDrone/series.js @@ -13,21 +13,17 @@ $("#seriesEditor").dialog({ text: "Delete", class: "ui-delete-button", click: function () { - var answer = confirm("Are you sure you want to delete this series?"); - if (answer) { - var seriesId = $('#SeriesId').val(); + $(this).dialog("close"); + + //Get the SeriesId and Title + var seriesId = $('#SeriesId').val(); + var title = $('[aria-labelledby="ui-dialog-title-seriesEditor"]').find('#ui-dialog-title-seriesEditor').text(); - $.ajax({ - type: "POST", - url: seriesDeleteUrl, - data: { seriesId: seriesId }, - success: function (data) { - //Remove the row from the grid... along with the details row - afterDelete(); - } - }); - $(this).dialog("close"); - } + //Fill in the view + $('#seriesDelete').children('.seriesId').val(seriesId); + $('#seriesDelete').children('.seriesTitle').html(title); + + $("#seriesDelete").dialog("open"); } }, "Save": function () { @@ -52,12 +48,12 @@ $("#seriesDelete").dialog({ buttons: { "Delete": function () { var seriesId = $('.seriesId').val(); + var deleteFiles = $('#DeleteFilesFromDisk').is(':checked'); $.ajax({ type: "POST", url: seriesDeleteUrl, - data: { seriesId: seriesId }, + data: { seriesId: seriesId, deleteFiles: deleteFiles }, success: function (data) { - //Remove the row from the grid... along with the details row afterDelete(seriesId); } }); diff --git a/NzbDrone.Web/Views/Series/Details.cshtml b/NzbDrone.Web/Views/Series/Details.cshtml index 60e692cc9..34c7a3153 100644 --- a/NzbDrone.Web/Views/Series/Details.cshtml +++ b/NzbDrone.Web/Views/Series/Details.cshtml @@ -109,9 +109,16 @@
-