Manual Import works

Automatically importing still broken
pull/2/head
Tim Turner 8 years ago
parent 3cb42f06c2
commit 0fa1509ca6

@ -10,5 +10,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
public List<int> EpisodeIds { get; set; } public List<int> EpisodeIds { get; set; }
public QualityModel Quality { get; set; } public QualityModel Quality { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
public int MovieId { get; set; }
} }
} }

@ -17,5 +17,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
public QualityModel Quality { get; set; } public QualityModel Quality { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
public IEnumerable<Rejection> Rejections { get; set; } public IEnumerable<Rejection> Rejections { get; set; }
public Movie Movie { get; set; }
} }
} }

@ -0,0 +1,43 @@
var vent = require('../../vent');
var NzbDroneCell = require('../../Cells/NzbDroneCell');
var SelectMovieLayout = require('../Movie/SelectMovieLayout');
module.exports = NzbDroneCell.extend({
className : 'series-title-cell editable',
events : {
'click' : '_onClick'
},
render : function() {
this.$el.empty();
var movie = this.model.get('movie');
if (movie)
{
this.$el.html(movie.title + " (" + movie.year + ")" );
}
this.delegateEvents();
return this;
},
_onClick : function () {
var view = new SelectMovieLayout();
this.listenTo(view, 'manualimport:selected:movie', this._setMovie);
vent.trigger(vent.Commands.OpenModal2Command, view);
},
_setMovie : function (e) {
if (this.model.has('movie') && e.model.id === this.model.get('movie').id) {
return;
}
this.model.set({
movie : e.model.toJSON()
});
}
});

@ -16,6 +16,7 @@ var QualityCell = require('./Cells/QualityCell');
var FileSizeCell = require('../Cells/FileSizeCell'); var FileSizeCell = require('../Cells/FileSizeCell');
var ApprovalStatusCell = require('../Cells/ApprovalStatusCell'); var ApprovalStatusCell = require('../Cells/ApprovalStatusCell');
var ManualImportCollection = require('./ManualImportCollection'); var ManualImportCollection = require('./ManualImportCollection');
var MovieCell = require('./Cells/MovieCell');
var Messenger = require('../Shared/Messenger'); var Messenger = require('../Shared/Messenger');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
@ -49,23 +50,29 @@ module.exports = Marionette.Layout.extend({
sortable : true sortable : true
}, },
{ {
name : 'series', name : 'movie',
label : 'Series', label : 'Movie',
cell : SeriesCell, cell : MovieCell,
sortable : true sortable : true
}, },
{ // {
name : 'seasonNumber', // name : 'series',
label : 'Season', // label : 'Series',
cell : SeasonCell, // cell : SeriesCell,
sortable : true // sortable : true
}, // },
{ // {
name : 'episodes', // name : 'seasonNumber',
label : 'Episode(s)', // label : 'Season',
cell : EpisodesCell, // cell : SeasonCell,
sortable : false // sortable : true
}, // },
// {
// name : 'episodes',
// label : 'Episode(s)',
// cell : EpisodesCell,
// sortable : false
// },
{ {
name : 'quality', name : 'quality',
label : 'Quality', label : 'Quality',
@ -176,29 +183,36 @@ module.exports = Marionette.Layout.extend({
return; return;
} }
if (_.any(selected, function (model) { if(_.any(selected, function(model) {
return !model.has('series'); return !model.has('movie');
})) { })) {
this._showErrorMessage('Movie must be chosen for each selected file');
this._showErrorMessage('Series must be chosen for each selected file');
return; return;
} }
if (_.any(selected, function (model) { // if (_.any(selected, function (model) {
return !model.has('seasonNumber'); // return !model.has('series');
})) { // })) {
this._showErrorMessage('Season must be chosen for each selected file'); // this._showErrorMessage('Series must be chosen for each selected file');
return; // return;
} // }
if (_.any(selected, function (model) { // if (_.any(selected, function (model) {
return !model.has('episodes') || model.get('episodes').length === 0; // return !model.has('seasonNumber');
})) { // })) {
this._showErrorMessage('One or more episodes must be chosen for each selected file'); // this._showErrorMessage('Season must be chosen for each selected file');
return; // return;
} // }
// if (_.any(selected, function (model) {
// return !model.has('episodes') || model.get('episodes').length === 0;
// })) {
// this._showErrorMessage('One or more episodes must be chosen for each selected file');
// return;
// }
var importMode = this.ui.importMode.val(); var importMode = this.ui.importMode.val();
@ -207,8 +221,9 @@ module.exports = Marionette.Layout.extend({
files : _.map(selected, function (file) { files : _.map(selected, function (file) {
return { return {
path : file.get('path'), path : file.get('path'),
seriesId : file.get('series').id, movieId : file.get('movie').id,
episodeIds : _.map(file.get('episodes'), 'id'), // seriesId : file.get('series').id,
// episodeIds : _.map(file.get('episodes'), 'id'),
quality : file.get('quality'), quality : file.get('quality'),
downloadId : file.get('downloadId') downloadId : file.get('downloadId')
}; };

@ -0,0 +1,101 @@
var _ = require('underscore');
var vent = require('vent');
var Marionette = require('marionette');
var Backgrid = require('backgrid');
var MoviesCollection = require('../../Movies/MoviesCollection');
var SelectRow = require('./SelectMovieRow');
module.exports = Marionette.Layout.extend({
template : 'ManualImport/Movie/SelectMovieLayoutTemplate',
regions : {
movie : '.x-movie'
},
ui : {
filter : '.x-filter'
},
columns : [
{
name : 'title',
label : 'Title',
cell : 'String',
sortValue : 'sortTitle'
}
],
initialize : function() {
this.movieCollection = MoviesCollection.clone();
this._setModelCollection();
this.listenTo(this.movieCollection, 'row:selected', this._onSelected);
this.listenTo(this, 'modal:afterShow', this._setFocus);
},
onRender : function() {
this.movieView = new Backgrid.Grid({
columns : this.columns,
collection : this.movieCollection,
className : 'table table-hover season-grid',
row : SelectRow
});
this.movie.show(this.movieView);
this._setupFilter();
},
_setupFilter : function () {
var self = this;
//TODO: This should be a mixin (same as Add Series searching)
this.ui.filter.keyup(function(e) {
if (_.contains([
9,
16,
17,
18,
19,
20,
33,
34,
35,
36,
37,
38,
39,
40,
91,
92,
93
], e.keyCode)) {
return;
}
self._filter(self.ui.filter.val());
});
},
_filter : function (term) {
this.movieCollection.setFilter(['title', term, 'contains']);
this._setModelCollection();
},
_onSelected : function (e) {
this.trigger('manualimport:selected:movie', { model: e.model });
vent.trigger(vent.Commands.CloseModal2Command);
},
_setFocus : function () {
this.ui.filter.focus();
},
_setModelCollection: function () {
var self = this;
_.each(this.movieCollection.models, function (model) {
model.collection = self.movieCollection;
});
}
});

@ -0,0 +1,30 @@
<div class="modal-content">
<div class="manual-import-modal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>
Manual Import - Select Movie
</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" class="form-control x-filter" placeholder="Filter movies" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 x-movie"></div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>

@ -0,0 +1,13 @@
var Backgrid = require('backgrid');
module.exports = Backgrid.Row.extend({
className : 'select-row select-series-row',
events : {
'click' : '_onClick'
},
_onClick : function() {
this.model.collection.trigger('row:selected', { model: this.model });
}
});

@ -4,16 +4,25 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'ManualImport/Summary/ManualImportSummaryViewTemplate', template : 'ManualImport/Summary/ManualImportSummaryViewTemplate',
// initialize : function (options) {
// var episodes = _.map(options.episodes, function (episode) {
// return episode.toJSON();
// });
// this.templateHelpers = {
// file : options.file,
// series : options.series,
// season : options.season,
// episodes : episodes,
// quality : options.quality
// };
// }
initialize : function (options) { initialize : function (options) {
var episodes = _.map(options.episodes, function (episode) {
return episode.toJSON();
});
this.templateHelpers = { this.templateHelpers = {
file : options.file, file : options.file,
series : options.series, movie : options.movie,
season : options.season,
episodes : episodes,
quality : options.quality quality : options.quality
}; };
} }

@ -3,16 +3,8 @@
<dt>Path:</dt> <dt>Path:</dt>
<dd>{{file}}</dd> <dd>{{file}}</dd>
<dt>Series:</dt> <dt>Movie:</dt>
<dd>{{series.title}}</dd> <dd>{{movie.title}} ({{movie.year}})</dd>
<dt>Season:</dt>
<dd>{{season.seasonNumber}}</dd>
{{#each episodes}}
<dt>Episode:</dt>
<dd>{{episodeNumber}} - {{title}}</dd>
{{/each}}
<dt>Quality:</dt> <dt>Quality:</dt>
<dd>{{quality.name}}</dd> <dd>{{quality.name}}</dd>

@ -10,6 +10,7 @@ var LogDetailsView = require('../../System/Logs/Table/Details/LogDetailsView');
var RenamePreviewLayout = require('../../Rename/RenamePreviewLayout'); var RenamePreviewLayout = require('../../Rename/RenamePreviewLayout');
var ManualImportLayout = require('../../ManualImport/ManualImportLayout'); var ManualImportLayout = require('../../ManualImport/ManualImportLayout');
var FileBrowserLayout = require('../FileBrowser/FileBrowserLayout'); var FileBrowserLayout = require('../FileBrowser/FileBrowserLayout');
var MoviesDetailsLayout = require('../../Movies/Details/MoviesDetailsLayout');
module.exports = Marionette.AppRouter.extend({ module.exports = Marionette.AppRouter.extend({
initialize : function() { initialize : function() {

Loading…
Cancel
Save