Manual episode search added to episode details

pull/4/head
Mark McDowall 11 years ago
parent ffda032751
commit 6f949dd129

@ -0,0 +1,9 @@
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.IndexerSearch
{
public class EpisodeSearchCommand : ICommand
{
public int EpisodeId { get; set; }
}
}

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Download;
namespace NzbDrone.Core.IndexerSearch
{
public class EpisodeSearchService : IExecute<EpisodeSearchCommand>
{
private readonly ISearchForNzb _nzbSearchService;
private readonly IDownloadApprovedReports _downloadApprovedReports;
public EpisodeSearchService(ISearchForNzb nzbSearchService, IDownloadApprovedReports downloadApprovedReports)
{
_nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports;
}
public void Execute(EpisodeSearchCommand message)
{
var decisions = _nzbSearchService.EpisodeSearch(message.EpisodeId);
_downloadApprovedReports.DownloadApproved(decisions);
}
}
}

@ -250,6 +250,8 @@
<Compile Include="Download\DownloadClientProvider.cs" />
<Compile Include="Download\DownloadClientType.cs" />
<Compile Include="Download\SabQueueItem.cs" />
<Compile Include="IndexerSearch\EpisodeSearchService.cs" />
<Compile Include="IndexerSearch\EpisodeSearchCommand.cs" />
<Compile Include="IndexerSearch\SeasonSearchCommand.cs" />
<Compile Include="IndexerSearch\SeasonSearchService.cs" />
<Compile Include="Indexers\FetchAndParseRssService.cs" />

@ -3,15 +3,12 @@ define(
[
'marionette',
'Episode/Summary/View',
'Episode/Search/Layout',
'Release/Collection',
'Shared/SpinnerView'
], function (Marionette, SummaryView, SearchLayout, ReleaseCollection, SpinnerView) {
'Episode/Search/Layout'
], function (Marionette, SummaryView, SearchLayout) {
return Marionette.Layout.extend({
template: 'Episode/LayoutTemplate',
regions: {
summary : '#episode-summary',
activity: '#episode-activity',
@ -31,7 +28,6 @@ define(
'click .x-episode-search' : '_showSearch'
},
onShow: function () {
this._showSummary();
this._releaseSearchActivated = false;
@ -61,23 +57,8 @@ define(
e.preventDefault();
}
if (this._releaseSearchActivated) {
return;
}
var self = this;
this.ui.search.tab('show');
this.search.show(new SpinnerView());
var releases = new ReleaseCollection();
var promise = releases.fetchEpisodeReleases(this.model.id);
promise.done(function () {
if (!self.isClosed) {
self.search.show(new SearchLayout({collection: releases}));
}
});
this.search.show(new SearchLayout({ model: this.model }));
}
});

@ -1,69 +1,71 @@
'use strict';
define(
[
'app',
'marionette',
'backgrid',
'Cells/FileSizeCell',
'Cells/QualityCell',
'Release/ApprovalStatusCell',
'Release/DownloadReportCell'
], function (Marionette, Backgrid, FileSizeCell, QualityCell, ApprovalStatusCell, DownloadReportCell) {
'Episode/Search/ManualLayout',
'Release/Collection',
'Shared/SpinnerView',
'Shared/Messenger',
'Commands/CommandController'
], function (App, Marionette, ManualSearchLayout, ReleaseCollection, SpinnerView, Messenger, CommandController) {
return Marionette.Layout.extend({
template: 'Episode/Search/LayoutTemplate',
regions: {
grid: '#episode-release-grid'
main: '#episode-search-region'
},
columns:
[
{
name : 'age',
label : 'Age',
sortable: true,
cell : Backgrid.IntegerCell
},
{
name : 'title',
label : 'Title',
sortable: true,
cell : Backgrid.StringCell
},
{
name : 'size',
label : 'Size',
sortable: true,
cell : FileSizeCell
},
{
name : 'quality',
label : 'Quality',
sortable: true,
cell : QualityCell
},
{
name : 'rejections',
label: 'decision',
cell : ApprovalStatusCell
},
{
name : 'download',
label: '',
cell : DownloadReportCell
}
],
events: {
'click .x-search-auto': '_searchAuto',
'click .x-search-manual': '_searchManual'
},
onShow: function () {
if (!this.isClosed) {
this.grid.show(new Backgrid.Grid({
row : Backgrid.Row,
columns : this.columns,
collection: this.collection,
className : 'table table-hover'
}));
this._releaseSearchActivated = false;
},
_searchAuto: function (e) {
if (e) {
e.preventDefault();
}
CommandController.Execute('episodeSearch', { episodeId: this.model.get('id') });
var seriesTitle = this.model.get('series').get('title');
var season = this.model.get('seasonNumber');
var episode = this.model.get('episodeNumber');
var message = seriesTitle + ' - S' + season.pad(2) + 'E' + episode.pad(2);
Messenger.show({
message: 'Search started for: ' + message
});
App.modalRegion.closeModal();
},
_searchManual: function (e) {
if (e) {
e.preventDefault();
}
if (this._releaseSearchActivated) {
return;
}
var self = this;
this.main.show(new SpinnerView());
var releases = new ReleaseCollection();
var promise = releases.fetchEpisodeReleases(this.model.id);
promise.done(function () {
if (!self.isClosed) {
self.main.show(new ManualSearchLayout({collection: releases}));
}
});
}
});

@ -1 +1,7 @@
<div id="episode-release-grid"/>

<div id="episode-search-region">
<div class="search-buttons">
<button class="btn btn-large btn-block x-search-auto"><i class="icon-rocket"/> Automatic Search</button>
<button class="btn btn-large btn-block btn-primary x-search-manual"><i class="icon-user"/> Manual Search</button>
</div>
</div>

@ -0,0 +1,71 @@
'use strict';
define(
[
'marionette',
'backgrid',
'Cells/FileSizeCell',
'Cells/QualityCell',
'Release/ApprovalStatusCell',
'Release/DownloadReportCell'
], function (Marionette, Backgrid, FileSizeCell, QualityCell, ApprovalStatusCell, DownloadReportCell) {
return Marionette.Layout.extend({
template: 'Episode/Search/ManualLayoutTemplate',
regions: {
grid: '#episode-release-grid'
},
columns:
[
{
name : 'age',
label : 'Age',
sortable: true,
cell : Backgrid.IntegerCell
},
{
name : 'title',
label : 'Title',
sortable: true,
cell : Backgrid.StringCell
},
{
name : 'size',
label : 'Size',
sortable: true,
cell : FileSizeCell
},
{
name : 'quality',
label : 'Quality',
sortable: true,
cell : QualityCell
},
{
name : 'rejections',
label: 'decision',
cell : ApprovalStatusCell
},
{
name : 'download',
label: '',
cell : DownloadReportCell
}
],
onShow: function () {
if (!this.isClosed) {
this.grid.show(new Backgrid.Grid({
row : Backgrid.Row,
columns : this.columns,
collection: this.collection,
className : 'table table-hover'
}));
}
}
});
});

@ -0,0 +1 @@
<div id="episode-release-grid"/>

@ -15,7 +15,7 @@
<tbody>
<tr>
<td>{{path}}</td>
<td>{{Byte size}}</td>
<td>{{Bytes size}}</td>
<td>{{quality.quality.name}}</td>
</tr>
</tbody>

@ -15,12 +15,13 @@ define(
}
this.episodeCollection = options.episodeCollection;
this.series = options.series;
},
itemViewOptions: function () {
return {
episodeCollection: this.episodeCollection
episodeCollection: this.episodeCollection,
series : this.series
};
}

@ -67,7 +67,7 @@ define(
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
_.each(this.episodeCollection.models, function (episode) {
episode.set({ hideSeriesLink: true });
episode.set({ hideSeriesLink: true, series: options.series });
});
},

@ -43,7 +43,8 @@ define(
$.when(this.episodeCollection.fetch({data: { seriesId: this.model.id }}), this.seasonCollection.fetch({data: { seriesId: this.model.id }})).done(function () {
self.seasons.show(new SeasonCollectionView({
collection : self.seasonCollection,
episodeCollection: self.episodeCollection
episodeCollection: self.episodeCollection,
series : self.model
}));
});
},

@ -89,8 +89,7 @@ define(
defaults: {
seasonNumber: 0,
status : 0,
title : 'TBA'
status : 0
}
});
});

@ -162,6 +162,12 @@
margin-top : 30px;
font-size : 12px;
}
.search-buttons {
width: 400px;
margin-left: auto;
margin-right: auto;
}
}
.season-grid {

@ -6,10 +6,11 @@ define([
'Settings/Notifications/Model',
'Settings/Notifications/DeleteView',
'Shared/Messenger',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Form/FormBuilder'
], function (App, Marionette, NotificationModel, DeleteView, Messenger, AsModelBoundView) {
], function (App, Marionette, NotificationModel, DeleteView, Messenger, CommandController, AsModelBoundView) {
var model = Marionette.ItemView.extend({
template: 'Settings/Notifications/EditTemplate',
@ -79,7 +80,7 @@ define([
});
var self = this;
var commandPromise = App.Commands.Execute(testCommand, properties);
var commandPromise = CommandController.Execute(testCommand, properties);
commandPromise.done(function () {
Messenger.show({
message: 'Notification settings tested successfully'

Loading…
Cancel
Save