1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 12:32:31 +01:00

Manual episode search added to episode details

This commit is contained in:
Mark McDowall 2013-06-28 17:35:21 -07:00
parent ffda032751
commit 6f949dd129
15 changed files with 191 additions and 84 deletions

View File

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

View File

@ -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);
}
}
}

View File

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

View File

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

View File

@ -1,69 +1,71 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'marionette', 'marionette',
'backgrid', 'Episode/Search/ManualLayout',
'Cells/FileSizeCell', 'Release/Collection',
'Cells/QualityCell', 'Shared/SpinnerView',
'Release/ApprovalStatusCell', 'Shared/Messenger',
'Release/DownloadReportCell' 'Commands/CommandController'
], function (Marionette, Backgrid, FileSizeCell, QualityCell, ApprovalStatusCell, DownloadReportCell) { ], function (App, Marionette, ManualSearchLayout, ReleaseCollection, SpinnerView, Messenger, CommandController) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Episode/Search/LayoutTemplate', template: 'Episode/Search/LayoutTemplate',
regions: { regions: {
grid: '#episode-release-grid' main: '#episode-search-region'
}, },
columns: events: {
[ 'click .x-search-auto': '_searchAuto',
{ 'click .x-search-manual': '_searchManual'
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 () { onShow: function () {
if (!this.isClosed) { this._releaseSearchActivated = false;
this.grid.show(new Backgrid.Grid({ },
row : Backgrid.Row,
columns : this.columns, _searchAuto: function (e) {
collection: this.collection, if (e) {
className : 'table table-hover' 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}));
}
});
} }
}); });

View File

@ -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>

View File

@ -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'
}));
}
}
});
});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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