mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 14:55:20 -07:00
First pass at ui for manually importing from lists.
This commit is contained in:
parent
87da542758
commit
fbe9ad6582
9 changed files with 277 additions and 21 deletions
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.NetImport.CouchPotato
|
||||||
[FieldDefinition(3, Label = "CouchPotato API Key", HelpText = "CoouchPootato API Key.")]
|
[FieldDefinition(3, Label = "CouchPotato API Key", HelpText = "CoouchPootato API Key.")]
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(4, Label = "Only Active", HelpText = "Should only active (not yet downloaded) movies be fetched")]
|
[FieldDefinition(4, Label = "Only Active", HelpText = "Should only active (not yet downloaded) movies be fetched", Type = FieldType.Checkbox)]
|
||||||
public bool OnlyActive { get; set; }
|
public bool OnlyActive { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ var RootFolderLayout = require('./RootFolders/RootFolderLayout');
|
||||||
var ExistingMoviesCollectionView = require('./Existing/AddExistingMovieCollectionView');
|
var ExistingMoviesCollectionView = require('./Existing/AddExistingMovieCollectionView');
|
||||||
var AddMoviesView = require('./AddMoviesView');
|
var AddMoviesView = require('./AddMoviesView');
|
||||||
var ProfileCollection = require('../Profile/ProfileCollection');
|
var ProfileCollection = require('../Profile/ProfileCollection');
|
||||||
var ListCollection = require("../Settings/NetImport/NetImportCollection");
|
var AddFromListView = require("./List/AddFromListView");
|
||||||
var RootFolderCollection = require('./RootFolders/RootFolderCollection');
|
var RootFolderCollection = require('./RootFolders/RootFolderCollection');
|
||||||
require('../Movies/MoviesCollection');
|
require('../Movies/MoviesCollection');
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ module.exports = Marionette.Layout.extend({
|
||||||
events : {
|
events : {
|
||||||
'click .x-import' : '_importMovies',
|
'click .x-import' : '_importMovies',
|
||||||
'click .x-add-new' : '_addMovies',
|
'click .x-add-new' : '_addMovies',
|
||||||
|
"click .x-add-lists" : "_addFromList",
|
||||||
'click .x-show-existing' : '_toggleExisting'
|
'click .x-show-existing' : '_toggleExisting'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -31,12 +32,7 @@ module.exports = Marionette.Layout.extend({
|
||||||
RootFolderCollection.fetch().done(function() {
|
RootFolderCollection.fetch().done(function() {
|
||||||
RootFolderCollection.synced = true;
|
RootFolderCollection.synced = true;
|
||||||
});
|
});
|
||||||
this.templateHelpers = {}
|
|
||||||
this.listCollection = new ListCollection();
|
|
||||||
this.templateHelpers.lists = this.listCollection.toJSON();
|
|
||||||
|
|
||||||
this.listenTo(this.listCollection, 'all', this._listsUpdated);
|
|
||||||
this.listCollection.fetch();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -52,10 +48,6 @@ module.exports = Marionette.Layout.extend({
|
||||||
this.workspace.show(new AddMoviesView());
|
this.workspace.show(new AddMoviesView());
|
||||||
},
|
},
|
||||||
|
|
||||||
_listsUpdated : function() {
|
|
||||||
this.templateHelpers.lists = this.listCollection.toJSON();
|
|
||||||
this.render();
|
|
||||||
},
|
|
||||||
|
|
||||||
_folderSelected : function(options) {
|
_folderSelected : function(options) {
|
||||||
vent.trigger(vent.Commands.CloseModalCommand);
|
vent.trigger(vent.Commands.CloseModalCommand);
|
||||||
|
@ -70,5 +62,9 @@ module.exports = Marionette.Layout.extend({
|
||||||
|
|
||||||
_addMovies : function() {
|
_addMovies : function() {
|
||||||
this.workspace.show(new AddMoviesView());
|
this.workspace.show(new AddMoviesView());
|
||||||
|
},
|
||||||
|
|
||||||
|
_addFromList : function() {
|
||||||
|
this.workspace.show(new AddFromListView());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="btn-group add-movies-btn-group btn-group-lg btn-block">
|
<div class="btn-group add-movies-btn-group btn-group-lg btn-block">
|
||||||
<button type="button" class="btn btn-default col-md-10 col-xs-8 add-movies-import-btn x-import">
|
<button type="button" class="btn btn-default col-md-7 col-xs-4 add-movies-import-btn x-import">
|
||||||
<i class="icon-sonarr-hdd"/>
|
<i class="icon-sonarr-hdd"/>
|
||||||
Import existing movies on disk
|
Import existing movies on disk
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-default col-md-2 col-xs-4 x-add-new"><i class="icon-sonarr-active hidden-xs"></i> Add New Movie</button>
|
<button class="btn btn-default col-md-2 col-xs-4 x-add-new"><i class="icon-sonarr-active hidden-xs"></i> Add New Movie</button>
|
||||||
|
<button class="btn btn-default col-md-3 col-xs-4 x-add-lists"><i class="icon-sonarr-active hidden-xs"></i> Add Movies from Lists</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,14 +34,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" style="margin-bottom: 0px;">
|
|
||||||
<label class="col-sm-3 control-label">Lists</label>
|
|
||||||
|
|
||||||
<div class="col-sm-8">
|
|
||||||
{{> ListSelectionPartial lists}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
18
src/UI/AddMovies/List/AddFromListCollection.js
Normal file
18
src/UI/AddMovies/List/AddFromListCollection.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
var MovieModel = require('../../Movies/MovieModel');
|
||||||
|
var _ = require('underscore');
|
||||||
|
|
||||||
|
module.exports = Backbone.Collection.extend({
|
||||||
|
url : window.NzbDrone.ApiRoot + '/netimport/movies',
|
||||||
|
model : MovieModel,
|
||||||
|
|
||||||
|
parse : function(response) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
_.each(response, function(model) {
|
||||||
|
model.id = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
});
|
51
src/UI/AddMovies/List/AddFromListCollectionView.js
Normal file
51
src/UI/AddMovies/List/AddFromListCollectionView.js
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
var Marionette = require('marionette');
|
||||||
|
var AddMoviesView = require('../AddMoviesView');
|
||||||
|
var vent = require('vent');
|
||||||
|
|
||||||
|
module.exports = Marionette.CompositeView.extend({
|
||||||
|
itemView : AddMoviesView,
|
||||||
|
itemViewContainer : '.x-loading-folders',
|
||||||
|
template : 'AddMovies/List/AddFromListCollectionViewTemplate',
|
||||||
|
|
||||||
|
ui : {
|
||||||
|
loadingFolders : '.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
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,5 @@
|
||||||
|
<div class="x-list">
|
||||||
|
<div class="loading-list x-loading-list">
|
||||||
|
Loading search results from TheTVDB for your movies, this may take a few minutes.
|
||||||
|
</div>
|
||||||
|
</div>
|
177
src/UI/AddMovies/List/AddFromListView.js
Normal file
177
src/UI/AddMovies/List/AddFromListView.js
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
var _ = require('underscore');
|
||||||
|
var vent = require('vent');
|
||||||
|
var Marionette = require('marionette');
|
||||||
|
var AddFromListCollection = require('./AddFromListCollection');
|
||||||
|
//var SearchResultCollectionView = require('./SearchResultCollectionView');
|
||||||
|
var AddListView = require("../../Settings/NetImport/Add/NetImportAddItemView");
|
||||||
|
var EmptyView = require('../EmptyView');
|
||||||
|
var NotFoundView = require('../NotFoundView');
|
||||||
|
var ListCollection = require("../../Settings/NetImport/NetImportCollection");
|
||||||
|
var ErrorView = require('../ErrorView');
|
||||||
|
var LoadingView = require('../../Shared/LoadingView');
|
||||||
|
var AppLayout = require('../../AppLayout');
|
||||||
|
var SchemaModal = require('../../Settings/NetImport/Add/NetImportSchemaModal');
|
||||||
|
|
||||||
|
module.exports = Marionette.Layout.extend({
|
||||||
|
template : 'AddMovies/List/AddFromListViewTemplate',
|
||||||
|
|
||||||
|
regions : {
|
||||||
|
fetchResult : '#fetch-result'
|
||||||
|
},
|
||||||
|
|
||||||
|
ui : {
|
||||||
|
moviesSearch : '.x-movies-search',
|
||||||
|
listSelection : ".x-list-selection",
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
events : {
|
||||||
|
'click .x-load-more' : '_onLoadMore',
|
||||||
|
"change .x-list-selection" : "_listSelected",
|
||||||
|
"click .x-fetch-list" : "_fetchList"
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize : function(options) {
|
||||||
|
console.log(options);
|
||||||
|
|
||||||
|
this.isExisting = options.isExisting;
|
||||||
|
//this.collection = new AddFromListCollection();
|
||||||
|
|
||||||
|
this.templateHelpers = {}
|
||||||
|
this.listCollection = new ListCollection();
|
||||||
|
this.templateHelpers.lists = this.listCollection.toJSON();
|
||||||
|
|
||||||
|
this.listenTo(this.listCollection, 'all', this._listsUpdated);
|
||||||
|
this.listCollection.fetch();
|
||||||
|
|
||||||
|
this.collection = new AddFromListCollection();
|
||||||
|
|
||||||
|
/*this.listenTo(this.collection, 'sync', this._showResults);
|
||||||
|
|
||||||
|
this.resultCollectionView = new SearchResultCollectionView({
|
||||||
|
collection : this.collection,
|
||||||
|
isExisting : this.isExisting
|
||||||
|
});*/
|
||||||
|
|
||||||
|
//this.throttledSearch = _.debounce(this.search, 1000, { trailing : true }).bind(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
onRender : function() {
|
||||||
|
var self = this;
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow : function() {
|
||||||
|
this.ui.moviesSearch.focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
search : function(options) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.collection.reset();
|
||||||
|
|
||||||
|
if (!options.term || options.term === this.collection.term) {
|
||||||
|
return Marionette.$.Deferred().resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.searchResult.show(new LoadingView());
|
||||||
|
this.collection.term = options.term;
|
||||||
|
this.currentSearchPromise = this.collection.fetch({
|
||||||
|
data : { term : options.term }
|
||||||
|
});
|
||||||
|
|
||||||
|
this.currentSearchPromise.fail(function() {
|
||||||
|
self._showError();
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.currentSearchPromise;
|
||||||
|
},
|
||||||
|
|
||||||
|
_onMoviesAdded : function(options) {
|
||||||
|
if (this.isExisting && options.movie.get('path') === this.model.get('folder').path) {
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!this.isExisting) {
|
||||||
|
this.resultCollectionView.setExisting(options.movie.get('tmdbId'));
|
||||||
|
/*this.collection.term = '';
|
||||||
|
this.collection.reset();
|
||||||
|
this._clearResults();
|
||||||
|
this.ui.moviesSearch.val('');
|
||||||
|
this.ui.moviesSearch.focus();*/ //TODO: Maybe add option wheter to clear search result.
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_onLoadMore : function() {
|
||||||
|
var showingAll = this.resultCollectionView.showMore();
|
||||||
|
this.ui.searchBar.show();
|
||||||
|
|
||||||
|
if (showingAll) {
|
||||||
|
this.ui.loadMore.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_listSelected : function() {
|
||||||
|
var rootFolderValue = this.ui.listSelection.val();
|
||||||
|
if (rootFolderValue === 'addNew') {
|
||||||
|
//var rootFolderLayout = new SchemaModal(this.listCollection);
|
||||||
|
//AppLayout.modalRegion.show(rootFolderLayout);
|
||||||
|
SchemaModal.open(this.listCollection)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_fetchList : function() {
|
||||||
|
var self = this;
|
||||||
|
var listId = this.ui.listSelection.val();
|
||||||
|
|
||||||
|
this.fetchResult.show(new LoadingView());
|
||||||
|
|
||||||
|
this.currentFetchPromise = this.collection.fetch(
|
||||||
|
{ data : { profileId : listId} }
|
||||||
|
)
|
||||||
|
this.currentFetchPromise.fail(function() {
|
||||||
|
self._showError();
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
_listsUpdated : function() {
|
||||||
|
this.templateHelpers.lists = this.listCollection.toJSON();
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
|
|
||||||
|
_clearResults : function() {
|
||||||
|
|
||||||
|
if (!this.isExisting) {
|
||||||
|
this.searchResult.show(new EmptyView());
|
||||||
|
} else {
|
||||||
|
this.searchResult.close();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_showResults : function() {
|
||||||
|
if (!this.isClosed) {
|
||||||
|
if (this.collection.length === 0) {
|
||||||
|
this.ui.searchBar.show();
|
||||||
|
this.searchResult.show(new NotFoundView({ term : this.collection.term }));
|
||||||
|
} else {
|
||||||
|
this.searchResult.show(this.resultCollectionView);
|
||||||
|
if (!this.showingAll) {
|
||||||
|
this.ui.loadMore.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_abortExistingSearch : function() {
|
||||||
|
if (this.currentSearchPromise && this.currentSearchPromise.readyState > 0 && this.currentSearchPromise.readyState < 4) {
|
||||||
|
console.log('aborting previous pending search request.');
|
||||||
|
this.currentSearchPromise.abort();
|
||||||
|
} else {
|
||||||
|
this._clearResults();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_showError : function() {
|
||||||
|
this.fetchResult.show(new ErrorView({ term : "" }));
|
||||||
|
}
|
||||||
|
});
|
15
src/UI/AddMovies/List/AddFromListViewTemplate.hbs
Normal file
15
src/UI/AddMovies/List/AddFromListViewTemplate.hbs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<div class="x-search-bar">
|
||||||
|
<div class="form-group" style="margin-bottom: 0px;">
|
||||||
|
<label class="col-sm-1 control-label">List</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{{> ListSelectionPartial lists}}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<button class="btn x-fetch-list">Fetch List</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div id="fetch-result" class="result-list col-md-12"/>
|
||||||
|
</div>
|
|
@ -1,4 +1,5 @@
|
||||||
<select class="col-md-4 form-control x-root-folder" validation-name="RootFolderPath">
|
<select class="col-md-4 form-control x-list-selection" validation-name="ListSelection">
|
||||||
|
<option value="0">All</option>
|
||||||
{{#if this}}
|
{{#if this}}
|
||||||
{{#each this}}
|
{{#each this}}
|
||||||
<option value="{{id}}">{{name}}</option>
|
<option value="{{id}}">{{name}}</option>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue