diff --git a/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs b/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs new file mode 100644 index 000000000..4e309fde8 --- /dev/null +++ b/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs @@ -0,0 +1,9 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.IndexerSearch +{ + public class SeriesSearchCommand : ICommand + { + public int SeriesId { get; set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs b/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs new file mode 100644 index 000000000..89dd7c6c2 --- /dev/null +++ b/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs @@ -0,0 +1,37 @@ +using System.Linq; +using NzbDrone.Common.Messaging; +using NzbDrone.Core.Download; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.IndexerSearch +{ + public class SeriesSearchService : IExecute + { + private readonly ISeasonService _seasonService; + private readonly ISearchForNzb _nzbSearchService; + private readonly IDownloadApprovedReports _downloadApprovedReports; + + public SeriesSearchService(ISeasonService seasonService, + ISearchForNzb nzbSearchService, + IDownloadApprovedReports downloadApprovedReports) + { + _seasonService = seasonService; + _nzbSearchService = nzbSearchService; + _downloadApprovedReports = downloadApprovedReports; + } + + public void Execute(SeriesSearchCommand message) + { + var seasons = _seasonService.GetSeasonsBySeries(message.SeriesId) + .Where(s => s.SeasonNumber > 0) + .OrderBy(s => s.SeasonNumber) + .ToList(); + + foreach (var season in seasons) + { + var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber); + _downloadApprovedReports.DownloadApproved(decisions); + } + } + } +} diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index d220524f7..820e86709 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -255,6 +255,8 @@ + + diff --git a/UI/Series/Details/SeasonLayout.js b/UI/Series/Details/SeasonLayout.js index 4bd3fa017..9d9cc276b 100644 --- a/UI/Series/Details/SeasonLayout.js +++ b/UI/Series/Details/SeasonLayout.js @@ -95,13 +95,14 @@ define( _seasonSearch: function () { Actioneer.ExecuteCommand({ - command : 'seasonSearch', - properties : { + command : 'seasonSearch', + properties : { seriesId : this.model.get('seriesId'), seasonNumber: this.model.get('seasonNumber') }, - element : this.ui.seasonSearch, - failMessage: 'Season search failed' + element : this.ui.seasonSearch, + failMessage : 'Search for season {0} failed'.format(this.model.get('seasonNumber')), + startMessage: 'Search for season {0} started'.format(this.model.get('seasonNumber')) }); }, diff --git a/UI/Series/Details/SeriesDetailsLayout.js b/UI/Series/Details/SeriesDetailsLayout.js index 845317e7f..5d237caa2 100644 --- a/UI/Series/Details/SeriesDetailsLayout.js +++ b/UI/Series/Details/SeriesDetailsLayout.js @@ -25,14 +25,16 @@ define( monitored: '.x-monitored', edit : '.x-edit', refresh : '.x-refresh', - rename : '.x-rename' + rename : '.x-rename', + search : '.x-search' }, events: { 'click .x-monitored': '_toggleMonitored', 'click .x-edit' : '_editSeries', 'click .x-refresh' : '_refreshSeries', - 'click .x-rename' : '_renameSeries' + 'click .x-rename' : '_renameSeries', + 'click .x-search' : '_seriesSearch' }, initialize: function () { @@ -146,6 +148,18 @@ define( element : this.ui.rename, failMessage: 'Series search failed' }); + }, + + _seriesSearch: function () { + Actioneer.ExecuteCommand({ + command : 'seriesSearch', + properties : { + seriesId : this.model.get('id') + }, + element : this.ui.search, + failMessage : 'Series search failed', + startMessage: 'Search for {0} started'.format(this.model.get('title')) + }); } }); }); diff --git a/UI/Series/Details/SeriesDetailsTemplate.html b/UI/Series/Details/SeriesDetailsTemplate.html index 4ebc6cef3..c665cfad1 100644 --- a/UI/Series/Details/SeriesDetailsTemplate.html +++ b/UI/Series/Details/SeriesDetailsTemplate.html @@ -5,8 +5,9 @@ {{title}} - - + + + diff --git a/UI/Shared/Actioneer.js b/UI/Shared/Actioneer.js index be88033aa..2c54fb37c 100644 --- a/UI/Shared/Actioneer.js +++ b/UI/Shared/Actioneer.js @@ -5,6 +5,7 @@ define(['Commands/CommandController', 'Shared/Messenger'], ExecuteCommand: function (options) { options.iconClass = this._getIconClass(options.element); + this._showStartMessage(options); this._setSpinnerOnElement(options); var promise = CommandController.Execute(options.command, options.properties); @@ -14,9 +15,10 @@ define(['Commands/CommandController', 'Shared/Messenger'], SaveModel: function (options) { options.iconClass = this._getIconClass(options.element); + this._showStartMessage(options); this._setSpinnerOnElement(options); - var promise = options.context.model.save(); + var promise = options.context.model.save(); this._handlePromise(promise, options); }, @@ -80,6 +82,14 @@ define(['Commands/CommandController', 'Shared/Messenger'], options.element.removeClass(options.iconClass); options.element.addClass('icon-nd-spinner'); } + }, + + _showStartMessage: function (options) { + if (options.startMessage) { + Messenger.show({ + message: options.startMessage + }); + } } } });