From 032bc2d5c4474710c21d2ab0cbe332bcebb0a539 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Mon, 23 Jan 2017 20:51:33 +0100 Subject: [PATCH] Add basic ui of manual import. --- src/NzbDrone.Api/NzbDrone.Api.csproj | 3 +- .../Series/FetchMovieListModule.cs | 45 ++++++++++++ .../List/AddFromListCollectionView.js | 72 +++++++++---------- .../AddFromListCollectionViewTemplate.hbs | 5 +- src/UI/AddMovies/List/AddFromListView.js | 53 +++++++++++--- src/UI/AddMovies/List/ListItemView.js | 22 ++++++ .../AddMovies/List/ListItemViewTemplate.hbs | 3 + 7 files changed, 151 insertions(+), 52 deletions(-) create mode 100644 src/NzbDrone.Api/Series/FetchMovieListModule.cs create mode 100644 src/UI/AddMovies/List/ListItemView.js create mode 100644 src/UI/AddMovies/List/ListItemViewTemplate.hbs diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index de7b4faab..097933cdc 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -238,6 +238,7 @@ + @@ -299,4 +300,4 @@ --> - + \ No newline at end of file diff --git a/src/NzbDrone.Api/Series/FetchMovieListModule.cs b/src/NzbDrone.Api/Series/FetchMovieListModule.cs new file mode 100644 index 000000000..a6ec92f76 --- /dev/null +++ b/src/NzbDrone.Api/Series/FetchMovieListModule.cs @@ -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 + { + 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 MapToResource(IEnumerable 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; + } + } + } +} \ No newline at end of file diff --git a/src/UI/AddMovies/List/AddFromListCollectionView.js b/src/UI/AddMovies/List/AddFromListCollectionView.js index 4177bd995..91a963601 100644 --- a/src/UI/AddMovies/List/AddFromListCollectionView.js +++ b/src/UI/AddMovies/List/AddFromListCollectionView.js @@ -1,51 +1,47 @@ var Marionette = require('marionette'); -var AddMoviesView = require('../AddMoviesView'); +var ListItemView = require('./ListItemView'); var vent = require('vent'); -module.exports = Marionette.CompositeView.extend({ - itemView : AddMoviesView, - itemViewContainer : '.x-loading-folders', - template : 'AddMovies/List/AddFromListCollectionViewTemplate', +module.exports = Marionette.CollectionView.extend({ + itemView : ListItemView, ui : { - loadingFolders : '.x-loading-list' + loadingList : '.x-loading-list' }, initialize : function() { - this.collection = new UnmappedFolderCollection(); - this.collection.importItems(this.model); - }, - showCollection : function() { - this._showAndSearch(0); }, - appendHtml : function(collectionView, itemView, index) { - collectionView.ui.loadingFolders.before(itemView.el); - }, - - _showAndSearch : function(index) { - var self = this; - var model = this.collection.at(index); - - if (model) { - var currentIndex = index; - var folderName = model.get('folder').name; - this.addItemView(model, this.getItemView(), index); - this.children.findByModel(model).search({ term : folderName }).always(function() { - if (!self.isClosed) { - self._showAndSearch(currentIndex + 1); - } - }); - } - - else { - this.ui.loadingFolders.hide(); - } - }, - - itemViewOptions : { - isExisting : true - } + showCollection : function() { + }, + // + // appendHtml : function(collectionView, itemView, index) { + // collectionView.ui.loadingFolders.before(itemView.el); + // }, + // + // _showAndSearch : function(index) { + // var self = this; + // var model = this.collection.at(index); + // + // if (model) { + // var currentIndex = index; + // var folderName = model.get('folder').name; + // this.addItemView(model, this.getItemView(), index); + // this.children.findByModel(model).search({ term : folderName }).always(function() { + // if (!self.isClosed) { + // self._showAndSearch(currentIndex + 1); + // } + // }); + // } + // + // else { + // this.ui.loadingFolders.hide(); + // } + // }, + // + // itemViewOptions : { + // isExisting : true + // } }); diff --git a/src/UI/AddMovies/List/AddFromListCollectionViewTemplate.hbs b/src/UI/AddMovies/List/AddFromListCollectionViewTemplate.hbs index dc812c87f..34a766b7a 100644 --- a/src/UI/AddMovies/List/AddFromListCollectionViewTemplate.hbs +++ b/src/UI/AddMovies/List/AddFromListCollectionViewTemplate.hbs @@ -1,5 +1,4 @@
-
- Loading search results from TheTVDB for your movies, this may take a few minutes. -
+
+
diff --git a/src/UI/AddMovies/List/AddFromListView.js b/src/UI/AddMovies/List/AddFromListView.js index 199240007..292d02665 100644 --- a/src/UI/AddMovies/List/AddFromListView.js +++ b/src/UI/AddMovies/List/AddFromListView.js @@ -1,8 +1,9 @@ var _ = require('underscore'); var vent = require('vent'); var Marionette = require('marionette'); +var Backgrid = require('backgrid'); var AddFromListCollection = require('./AddFromListCollection'); -//var SearchResultCollectionView = require('./SearchResultCollectionView'); +var AddFromListCollectionView = require('./AddFromListCollectionView'); var AddListView = require("../../Settings/NetImport/Add/NetImportAddItemView"); var EmptyView = require('../EmptyView'); var NotFoundView = require('../NotFoundView'); @@ -10,6 +11,16 @@ var ListCollection = require("../../Settings/NetImport/NetImportCollection"); var ErrorView = require('../ErrorView'); var LoadingView = require('../../Shared/LoadingView'); 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'); 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 : { 'click .x-load-more' : '_onLoadMore', "change .x-list-selection" : "_listSelected", @@ -46,6 +78,8 @@ module.exports = Marionette.Layout.extend({ this.collection = new AddFromListCollection(); + this.listenTo(this.collection, 'sync', this._showResults); + /*this.listenTo(this.collection, 'sync', this._showResults); this.resultCollectionView = new SearchResultCollectionView({ @@ -126,7 +160,7 @@ module.exports = Marionette.Layout.extend({ this.fetchResult.show(new LoadingView()); this.currentFetchPromise = this.collection.fetch( - { data : { profileId : listId} } + { data : { listId : listId} } ) this.currentFetchPromise.fail(function() { self._showError(); @@ -149,17 +183,16 @@ module.exports = Marionette.Layout.extend({ }, _showResults : function() { - if (!this.isClosed) { if (this.collection.length === 0) { - this.ui.searchBar.show(); - this.searchResult.show(new NotFoundView({ term : this.collection.term })); + this.fetchResult.show(new NotFoundView({ term : "" })); } else { - this.searchResult.show(this.resultCollectionView); - if (!this.showingAll) { - this.ui.loadMore.show(); - } + this.fetchResult.show(new Backgrid.Grid({ + collection : this.collection, + columns : this.columns, + className : 'table table-hover' + })); } - } + }, _abortExistingSearch : function() { diff --git a/src/UI/AddMovies/List/ListItemView.js b/src/UI/AddMovies/List/ListItemView.js new file mode 100644 index 000000000..f93b2778e --- /dev/null +++ b/src/UI/AddMovies/List/ListItemView.js @@ -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; diff --git a/src/UI/AddMovies/List/ListItemViewTemplate.hbs b/src/UI/AddMovies/List/ListItemViewTemplate.hbs new file mode 100644 index 000000000..70d974ae7 --- /dev/null +++ b/src/UI/AddMovies/List/ListItemViewTemplate.hbs @@ -0,0 +1,3 @@ +
+ ASDF +