Add basic ui of manual import.

This commit is contained in:
Leonardo Galli 2017-01-23 20:51:33 +01:00
parent fbe9ad6582
commit 032bc2d5c4
7 changed files with 151 additions and 52 deletions

View File

@ -238,6 +238,7 @@
<Compile Include="SeasonPass\SeasonPassResource.cs" /> <Compile Include="SeasonPass\SeasonPassResource.cs" />
<Compile Include="Series\AlternateTitleResource.cs" /> <Compile Include="Series\AlternateTitleResource.cs" />
<Compile Include="Series\MovieFileResource.cs" /> <Compile Include="Series\MovieFileResource.cs" />
<Compile Include="Series\FetchMovieListModule.cs" />
<Compile Include="Series\SeasonResource.cs" /> <Compile Include="Series\SeasonResource.cs" />
<Compile Include="SeasonPass\SeasonPassModule.cs" /> <Compile Include="SeasonPass\SeasonPassModule.cs" />
<Compile Include="Series\SeriesEditorModule.cs" /> <Compile Include="Series\SeriesEditorModule.cs" />
@ -299,4 +300,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

View File

@ -0,0 +1,45 @@
using System.Collections.Generic;
using Nancy;
using NzbDrone.Api.Extensions;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource;
using System.Linq;
using NzbDrone.Core.NetImport;
namespace NzbDrone.Api.Movie
{
public class FetchMovieListModule : NzbDroneRestModule<MovieResource>
{
private readonly IFetchNetImport _fetchNetImport;
public FetchMovieListModule(IFetchNetImport netImport)
: base("/netimport/movies")
{
_fetchNetImport = netImport;
Get["/"] = x => Search();
}
private Response Search()
{
var results = _fetchNetImport.FetchAndFilter((int) Request.Query.listId, false);
return MapToResource(results).AsResponse();
}
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Core.Tv.Movie> movies)
{
foreach (var currentSeries in movies)
{
var resource = currentSeries.ToResource();
var poster = currentSeries.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
if (poster != null)
{
resource.RemotePoster = poster.Url;
}
yield return resource;
}
}
}
}

View File

@ -1,51 +1,47 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
var AddMoviesView = require('../AddMoviesView'); var ListItemView = require('./ListItemView');
var vent = require('vent'); var vent = require('vent');
module.exports = Marionette.CompositeView.extend({ module.exports = Marionette.CollectionView.extend({
itemView : AddMoviesView, itemView : ListItemView,
itemViewContainer : '.x-loading-folders',
template : 'AddMovies/List/AddFromListCollectionViewTemplate',
ui : { ui : {
loadingFolders : '.x-loading-list' loadingList : '.x-loading-list'
}, },
initialize : function() { initialize : function() {
this.collection = new UnmappedFolderCollection();
this.collection.importItems(this.model);
}, },
showCollection : function() { showCollection : function() {
this._showAndSearch(0); },
}, //
// appendHtml : function(collectionView, itemView, index) {
appendHtml : function(collectionView, itemView, index) { // collectionView.ui.loadingFolders.before(itemView.el);
collectionView.ui.loadingFolders.before(itemView.el); // },
}, //
// _showAndSearch : function(index) {
_showAndSearch : function(index) { // var self = this;
var self = this; // var model = this.collection.at(index);
var model = this.collection.at(index); //
// if (model) {
if (model) { // var currentIndex = index;
var currentIndex = index; // var folderName = model.get('folder').name;
var folderName = model.get('folder').name; // this.addItemView(model, this.getItemView(), index);
this.addItemView(model, this.getItemView(), index); // this.children.findByModel(model).search({ term : folderName }).always(function() {
this.children.findByModel(model).search({ term : folderName }).always(function() { // if (!self.isClosed) {
if (!self.isClosed) { // self._showAndSearch(currentIndex + 1);
self._showAndSearch(currentIndex + 1); // }
} // });
}); // }
} //
// else {
else { // this.ui.loadingFolders.hide();
this.ui.loadingFolders.hide(); // }
} // },
}, //
// itemViewOptions : {
itemViewOptions : { // isExisting : true
isExisting : true // }
}
}); });

View File

@ -1,5 +1,4 @@
<div class="x-list"> <div class="x-list">
<div class="loading-list x-loading-list"> <div class="x-loading-list">
Loading search results from TheTVDB for your movies, this may take a few minutes. </div>
</div>
</div> </div>

View File

@ -1,8 +1,9 @@
var _ = require('underscore'); var _ = require('underscore');
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var Backgrid = require('backgrid');
var AddFromListCollection = require('./AddFromListCollection'); var AddFromListCollection = require('./AddFromListCollection');
//var SearchResultCollectionView = require('./SearchResultCollectionView'); var AddFromListCollectionView = require('./AddFromListCollectionView');
var AddListView = require("../../Settings/NetImport/Add/NetImportAddItemView"); var AddListView = require("../../Settings/NetImport/Add/NetImportAddItemView");
var EmptyView = require('../EmptyView'); var EmptyView = require('../EmptyView');
var NotFoundView = require('../NotFoundView'); var NotFoundView = require('../NotFoundView');
@ -10,6 +11,16 @@ var ListCollection = require("../../Settings/NetImport/NetImportCollection");
var ErrorView = require('../ErrorView'); var ErrorView = require('../ErrorView');
var LoadingView = require('../../Shared/LoadingView'); var LoadingView = require('../../Shared/LoadingView');
var AppLayout = require('../../AppLayout'); var AppLayout = require('../../AppLayout');
var InCinemasCell = require('../../Cells/InCinemasCell');
var MovieTitleCell = require('../../Cells/MovieTitleCell');
var TemplatedCell = require('../../Cells/TemplatedCell');
var ProfileCell = require('../../Cells/ProfileCell');
var MovieLinksCell = require('../../Cells/MovieLinksCell');
var MovieActionCell = require('../../Cells/MovieActionCell');
var MovieStatusCell = require('../../Cells/MovieStatusCell');
var MovieDownloadStatusCell = require('../../Cells/MovieDownloadStatusCell');
var DownloadedQualityCell = require('../../Cells/DownloadedQualityCell');
var SchemaModal = require('../../Settings/NetImport/Add/NetImportSchemaModal'); var SchemaModal = require('../../Settings/NetImport/Add/NetImportSchemaModal');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
@ -25,6 +36,27 @@ module.exports = Marionette.Layout.extend({
}, },
columns : [
{
name : 'title',
label : 'Title',
cell : MovieTitleCell,
cellValue : 'this',
},
{
name : 'profileId',
label : 'Profile',
cell : ProfileCell
},
{
name : 'this',
label : 'Links',
cell : MovieLinksCell,
className : "movie-links-cell",
sortable : false,
}
],
events : { events : {
'click .x-load-more' : '_onLoadMore', 'click .x-load-more' : '_onLoadMore',
"change .x-list-selection" : "_listSelected", "change .x-list-selection" : "_listSelected",
@ -46,6 +78,8 @@ module.exports = Marionette.Layout.extend({
this.collection = new AddFromListCollection(); this.collection = new AddFromListCollection();
this.listenTo(this.collection, 'sync', this._showResults);
/*this.listenTo(this.collection, 'sync', this._showResults); /*this.listenTo(this.collection, 'sync', this._showResults);
this.resultCollectionView = new SearchResultCollectionView({ this.resultCollectionView = new SearchResultCollectionView({
@ -126,7 +160,7 @@ module.exports = Marionette.Layout.extend({
this.fetchResult.show(new LoadingView()); this.fetchResult.show(new LoadingView());
this.currentFetchPromise = this.collection.fetch( this.currentFetchPromise = this.collection.fetch(
{ data : { profileId : listId} } { data : { listId : listId} }
) )
this.currentFetchPromise.fail(function() { this.currentFetchPromise.fail(function() {
self._showError(); self._showError();
@ -149,17 +183,16 @@ module.exports = Marionette.Layout.extend({
}, },
_showResults : function() { _showResults : function() {
if (!this.isClosed) {
if (this.collection.length === 0) { if (this.collection.length === 0) {
this.ui.searchBar.show(); this.fetchResult.show(new NotFoundView({ term : "" }));
this.searchResult.show(new NotFoundView({ term : this.collection.term }));
} else { } else {
this.searchResult.show(this.resultCollectionView); this.fetchResult.show(new Backgrid.Grid({
if (!this.showingAll) { collection : this.collection,
this.ui.loadMore.show(); columns : this.columns,
} className : 'table table-hover'
}));
} }
}
}, },
_abortExistingSearch : function() { _abortExistingSearch : function() {

View File

@ -0,0 +1,22 @@
var _ = require('underscore');
var vent = require('vent');
var AppLayout = require('../../AppLayout');
var Backbone = require('backbone');
var Marionette = require('marionette');
var Config = require('../../Config');
var Messenger = require('../../Shared/Messenger');
var AsValidatedView = require('../../Mixins/AsValidatedView');
require('jquery.dotdotdot');
var view = Marionette.ItemView.extend({
template : 'AddMovies/SearchResultViewTemplate',
})
AsValidatedView.apply(view);
module.exports = view;

View File

@ -0,0 +1,3 @@
<div class="fetch-item">
ASDF
</div>