Merge pull request #974 from geogolem/MovieEditorFixes

revert some changes -- use FullCollection (maybe just for now)
pull/980/head
geogolem 8 years ago committed by GitHub
commit e742371d15

@ -2,8 +2,7 @@ var $ = require('jquery');
var _ = require('underscore'); var _ = require('underscore');
var SelectAllCell = require('../../Cells/SelectAllCell'); var SelectAllCell = require('../../Cells/SelectAllCell');
var Backgrid = require('backgrid'); var Backgrid = require('backgrid');
//var FullMovieCollection = require('../../Movies/FullMovieCollection'); var FullMovieCollection = require('../../Movies/FullMovieCollection');
var MoviesCollectionClient = require('../../Movies/MoviesCollectionClient');
module.exports = SelectAllCell.extend({ module.exports = SelectAllCell.extend({
@ -15,7 +14,7 @@ module.exports = SelectAllCell.extend({
this._originalInit.apply(this, arguments); this._originalInit.apply(this, arguments);
var tmdbId = this.model.get('tmdbId'); var tmdbId = this.model.get('tmdbId');
var existingMovie = MoviesCollectionClient.fullCollection.where({ tmdbId: tmdbId }); var existingMovie = FullMovieCollection.where({ tmdbId: tmdbId });
this.isDuplicate = existingMovie.length > 0 ? true : false; this.isDuplicate = existingMovie.length > 0 ? true : false;
this.listenTo(this.model, 'change', this._refresh); this.listenTo(this.model, 'change', this._refresh);

@ -1,7 +1,6 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
var SearchResultView = require('./SearchResultView'); var SearchResultView = require('./SearchResultView');
//var FullMovieCollection = require('../Movies/FullMovieCollection'); var FullMovieCollection = require('../Movies/FullMovieCollection');
var MoviesCollectionClient = require('../Movies/MoviesCollectionClient');
var vent = require('vent'); var vent = require('vent');
module.exports = Marionette.CollectionView.extend({ module.exports = Marionette.CollectionView.extend({
@ -49,7 +48,7 @@ module.exports = Marionette.CollectionView.extend({
appendHtml : function(collectionView, itemView, index) { appendHtml : function(collectionView, itemView, index) {
var tmdbId = itemView.model.get('tmdbId'); var tmdbId = itemView.model.get('tmdbId');
var existingMovies = MoviesCollectionClient.fullCollection.where({ tmdbId: tmdbId }); var existingMovies = FullMovieCollection.where({ tmdbId: tmdbId });
if(existingMovies.length > 0) { if(existingMovies.length > 0) {
if(this.showExisting) { if(this.showExisting) {
if (index < this.showing || index === 0) { if (index < this.showing || index === 0) {

@ -6,8 +6,7 @@ var Marionette = require('marionette');
var Profiles = require('../Profile/ProfileCollection'); var Profiles = require('../Profile/ProfileCollection');
var RootFolders = require('./RootFolders/RootFolderCollection'); var RootFolders = require('./RootFolders/RootFolderCollection');
var RootFolderLayout = require('./RootFolders/RootFolderLayout'); var RootFolderLayout = require('./RootFolders/RootFolderLayout');
//var FullMovieCollection = require('../Movies/FullMovieCollection'); var FullMovieCollection = require('../Movies/FullMovieCollection');
var MoviesCollectionClient = require('../Movies/MoviesCollectionClient');
var Config = require('../Config'); var Config = require('../Config');
var Messenger = require('../Shared/Messenger'); var Messenger = require('../Shared/Messenger');
var AsValidatedView = require('../Mixins/AsValidatedView'); var AsValidatedView = require('../Mixins/AsValidatedView');
@ -107,7 +106,7 @@ var view = Marionette.ItemView.extend({
}, },
_configureTemplateHelpers : function() { _configureTemplateHelpers : function() {
var existingMovies = MoviesCollectionClient.fullCollection.where({ tmdbId : this.model.get('tmdbId') }); var existingMovies = FullMovieCollection.where({ tmdbId : this.model.get('tmdbId') });
if (existingMovies.length > 0) { if (existingMovies.length > 0) {
this.templateHelpers.existing = existingMovies[0].toJSON(); this.templateHelpers.existing = existingMovies[0].toJSON();
} }
@ -218,7 +217,7 @@ var view = Marionette.ItemView.extend({
}); });
promise.done(function() { promise.done(function() {
MoviesCollectionClient.fullCollection.add(self.model); FullMovieCollection.add(self.model);
self.close(); self.close();

@ -6,6 +6,7 @@ var RootFolders = require('../../AddMovies/RootFolders/RootFolderCollection');
var RootFolderLayout = require('../../AddMovies/RootFolders/RootFolderLayout'); var RootFolderLayout = require('../../AddMovies/RootFolders/RootFolderLayout');
var UpdateFilesMoviesView = require('./Organize/OrganizeFilesView'); var UpdateFilesMoviesView = require('./Organize/OrganizeFilesView');
var Config = require('../../Config'); var Config = require('../../Config');
var FullMovieCollection = require('../FullMovieCollection');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Movies/Editor/MovieEditorFooterViewTemplate', template : 'Movies/Editor/MovieEditorFooterViewTemplate',
@ -44,11 +45,16 @@ module.exports = Marionette.ItemView.extend({
this.listenTo(this.moviesCollection, 'backgrid:selected', function(model, selected) { this.listenTo(this.moviesCollection, 'backgrid:selected', function(model, selected) {
var m = this.moviesCollection.fullCollection.findWhere({ tmdbId : model.get('tmdbId') }); var m = FullMovieCollection.findWhere({ tmdbId : model.get('tmdbId') });
m.set('selected', selected); m.set('selected', selected);
this._updateInfo(); this._updateInfo();
}); });
this.listenTo(FullMovieCollection, 'save', function() {
window.alert(' Done Saving');
var selected = FullMovieCollection.where({ selected : true });
});
this.listenTo(RootFolders, 'all', this.render); this.listenTo(RootFolders, 'all', this.render);
@ -61,14 +67,19 @@ module.exports = Marionette.ItemView.extend({
_updateAndSave : function() { _updateAndSave : function() {
//var selected = this.editorGrid.getSelectedModels(); //var selected = this.editorGrid.getSelectedModels();
var selected = this.moviesCollection.fullCollection.where({ selected : true }); var selected = FullMovieCollection.where({ selected : true });
var monitored = this.ui.monitored.val(); var monitored = this.ui.monitored.val();
var minAvail = this.ui.minimumAvailability.val(); var minAvail = this.ui.minimumAvailability.val();
var profile = this.ui.profile.val(); var profile = this.ui.profile.val();
var seasonFolder = this.ui.seasonFolder.val(); var seasonFolder = this.ui.seasonFolder.val();
var rootFolder = this.ui.rootFolder.val(); var rootFolder = this.ui.rootFolder.val();
var i = 0;
var b = [];
_.each(selected, function(model) { _.each(selected, function(model) {
b[i] = model.get('tmdbId');
i++;
if (monitored === 'true') { if (monitored === 'true') {
model.set('monitored', true); model.set('monitored', true);
} else if (monitored === 'false') { } else if (monitored === 'false') {
@ -96,7 +107,38 @@ module.exports = Marionette.ItemView.extend({
} }
model.edited = true; model.edited = true;
}); });
this.moviesCollection.save(); for (var j=0; j<i; j++) {
var m = this.moviesCollection.fullCollection.findWhere({ tmdbId : b[j] });
if (m!== undefined) {
if (monitored === 'true') {
m.set('monitored', true);
} else if (monitored === 'false') {
m.set('monitored', false);
}
if (minAvail !=='noChange') {
m.set('minimumAvailability', minAvail);
}
if (profile !== 'noChange') {
m.set('profileId', parseInt(profile, 10));
}
if (seasonFolder === 'true') {
m.set('seasonFolder', true);
} else if (seasonFolder === 'false') {
m.set('seasonFolder', false);
}
if (rootFolder !== 'noChange') {
var rootFolderPath = RootFolders.get(parseInt(rootFolder, 10));
m.set('rootFolderPath', rootFolderPath.get('path'));
}
}
}
FullMovieCollection.save();
}, },
_updateInfo : function() { _updateInfo : function() {

@ -2,6 +2,7 @@ var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var Backgrid = require('backgrid'); var Backgrid = require('backgrid');
var EmptyView = require('../Index/EmptyView'); var EmptyView = require('../Index/EmptyView');
var FullMovieCollection = require ('../FullMovieCollection');
var MoviesCollection = require('../MoviesCollectionClient'); var MoviesCollection = require('../MoviesCollectionClient');
var MovieTitleCell = require('../../Cells/MovieTitleCell'); var MovieTitleCell = require('../../Cells/MovieTitleCell');
var DownloadedQualityCell = require('../../Cells/DownloadedQualityCell'); var DownloadedQualityCell = require('../../Cells/DownloadedQualityCell');
@ -12,7 +13,6 @@ var FooterView = require('./MovieEditorFooterView');
var GridPager = require('../../Shared/Grid/Pager'); var GridPager = require('../../Shared/Grid/Pager');
require('../../Mixins/backbone.signalr.mixin'); require('../../Mixins/backbone.signalr.mixin');
//require('../Globals');
window.shownOnce = false; window.shownOnce = false;
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Movies/Editor/MovieEditorLayoutTemplate', template : 'Movies/Editor/MovieEditorLayoutTemplate',
@ -81,31 +81,27 @@ module.exports = Marionette.Layout.extend({
}, },
initialize : function() { initialize : function() {
this.tableShown = window.shownOnce; //false;
this.movieCollection = MoviesCollection; this.movieCollection = MoviesCollection;
this.movieCollection.bindSignalR(); this.movieCollection.bindSignalR();
//this.movieCollection.switchMode('client');
this.movieCollection.fullCollection.bindSignalR(); this.movieCollection.fullCollection.bindSignalR();
var selected = this.movieCollection.fullCollection.where( { selected : true });
var selected = FullMovieCollection.where( { selected : true });
_.each(selected, function(model) { _.each(selected, function(model) {
model.set('selected', false); model.set('selected', false);
}); });
this.listenTo(this.movieCollection, 'sync', function() { this.listenTo(this.movieCollection, 'sync', function() {
this._showToolbar(); this._showToolbar();
if (!this.tableShown) { this._showTable();
this._showTable(); this._showPager();
this._showPager();
}
}); });
this.listenTo(this.movieCollection.fullCollection, 'sync', function() { this.listenTo(this.movieCollection.fullCollection, 'sync', function() {
}); });
this.listenTo(this.movieCollection, 'save', function() { //this.listenTo(FullMovieCollection, 'save', function() {
window.alert('Done Saving'); // window.alert('Done Saving');
}); //});
this.filteringOptions = { this.filteringOptions = {
type : 'radio', type : 'radio',
@ -157,15 +153,16 @@ module.exports = Marionette.Layout.extend({
} }
] ]
}; };
window.shownOnce = true;
}, },
onRender : function() { onRender : function() {
if (this.tableShown) { this._showToolbar();
this._showToolbar(); this._showTable();
this._showTable(); this._showPager();
this._showPager(); if (window.shownOnce){
} this.movieCollection.fetch();
}
window.shownOnce = true;
}, },
onClose : function() { onClose : function() {
@ -191,7 +188,6 @@ module.exports = Marionette.Layout.extend({
this.toolbar.close(); this.toolbar.close();
return; return;
} }
this.tableShown = true;
this.columns[0].sortedCollection = this.movieCollection; this.columns[0].sortedCollection = this.movieCollection;
this.editorGrid = new Backgrid.Grid({ this.editorGrid = new Backgrid.Grid({
@ -226,6 +222,6 @@ module.exports = Marionette.Layout.extend({
_setFilter : function(buttonContext) { _setFilter : function(buttonContext) {
var mode = buttonContext.model.get('key'); var mode = buttonContext.model.get('key');
this.movieCollection.setFilterMode(mode, { reset : false }); this.movieCollection.setFilterMode(mode);
} }
}); });

@ -1,12 +1,12 @@
/*var movieCollection = require('./MoviesCollection'); var movieCollection = require('./MoviesCollection');
var fullCollection = movieCollection.clone(); var fullCollection = movieCollection.clone();
fullCollection.bindSignalR(); fullCollection.bindSignalR();
fullCollection.state.pageSize = 100000; fullCollection.state.pageSize = 100000;
fullCollection.fetch({reset : true}); fullCollection.fetch({reset : true});
module.exports = fullCollection;*/ module.exports = fullCollection;
var movieCollection = require('./MoviesCollectionClient'); /*var movieCollection = require('./MoviesCollectionClient');
movieCollection.bindSignalR(); movieCollection.bindSignalR();
module.exports = movieCollection.fullCollection; module.exports = movieCollection.fullCollection;*/

@ -1,487 +1,476 @@
var _ = require('underscore'); var _ = require('underscore');
var Marionette = require('marionette'); var Marionette = require('marionette');
var Backgrid = require('backgrid'); var Backgrid = require('backgrid');
var PosterCollectionView = require('./Posters/SeriesPostersCollectionView'); var PosterCollectionView = require('./Posters/SeriesPostersCollectionView');
var ListCollectionView = require('./Overview/SeriesOverviewCollectionView'); var ListCollectionView = require('./Overview/SeriesOverviewCollectionView');
var EmptyView = require('./EmptyView'); var EmptyView = require('./EmptyView');
var MoviesCollection = require('../MoviesCollection'); var MoviesCollection = require('../MoviesCollection');
//var FullMovieCollection = require('../FullMovieCollection');
//var InCinemasCell = require('../../Cells/InCinemasCell'); var FullMovieCollection = require('../FullMovieCollection');
var RelativeDateCell = require('../../Cells/RelativeDateCell'); var InCinemasCell = require('../../Cells/InCinemasCell');
var MovieTitleCell = require('../../Cells/MovieTitleCell');
var TemplatedCell = require('../../Cells/TemplatedCell'); var RelativeDateCell = require('../../Cells/RelativeDateCell');
var ProfileCell = require('../../Cells/ProfileCell');
var MovieLinksCell = require('../../Cells/MovieLinksCell'); var MovieTitleCell = require('../../Cells/MovieTitleCell');
var MovieActionCell = require('../../Cells/MovieActionCell'); var TemplatedCell = require('../../Cells/TemplatedCell');
var MovieStatusCell = require('../../Cells/MovieStatusCell'); var ProfileCell = require('../../Cells/ProfileCell');
var MovieDownloadStatusCell = require('../../Cells/MovieDownloadStatusCell'); var MovieLinksCell = require('../../Cells/MovieLinksCell');
var DownloadedQualityCell = require('../../Cells/DownloadedQualityCell'); var MovieActionCell = require('../../Cells/MovieActionCell');
var FooterView = require('./FooterView'); var MovieStatusCell = require('../../Cells/MovieStatusCell');
var GridPager = require('../../Shared/Grid/Pager'); var MovieDownloadStatusCell = require('../../Cells/MovieDownloadStatusCell');
var FooterModel = require('./FooterModel'); var DownloadedQualityCell = require('../../Cells/DownloadedQualityCell');
var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout'); var FooterView = require('./FooterView');
require('../../Mixins/backbone.signalr.mixin'); var GridPager = require('../../Shared/Grid/Pager');
var FooterModel = require('./FooterModel');
var MoviesCollectionClient = require('../MoviesCollectionClient'); var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
require('../../Mixins/backbone.signalr.mixin');
//this variable prevents double fetching the FullMovieCollection on first load //var MoviesCollectionClient = require('../MoviesCollectionClient');
//var shownOnce = false;
//require('../Globals');
window.shownOnce = false; //this variable prevents double fetching the FullMovieCollection on first load
module.exports = Marionette.Layout.extend({ //var shownOnce = false;
template : 'Movies/Index/MoviesIndexLayoutTemplate', //require('../Globals');
window.shownOnce = false;
regions : { module.exports = Marionette.Layout.extend({
seriesRegion : '#x-series', template : 'Movies/Index/MoviesIndexLayoutTemplate',
toolbar : '#x-toolbar',
toolbar2 : '#x-toolbar2', regions : {
footer : '#x-series-footer', seriesRegion : '#x-series',
pager : "#x-movie-pager", toolbar : '#x-toolbar',
pagerTop : "#x-movie-pager-top" toolbar2 : '#x-toolbar2',
}, footer : '#x-series-footer',
pager : "#x-movie-pager",
columns : [ pagerTop : "#x-movie-pager-top"
{ },
name : 'status',
label : '', columns : [
cell : MovieStatusCell {
}, name : 'status',
{ label : '',
name : 'title', cell : MovieStatusCell
label : 'Title', },
cell : MovieTitleCell, {
cellValue : 'this', name : 'title',
}, label : 'Title',
{ cell : MovieTitleCell,
name : 'added', cellValue : 'this',
label : 'Date Added', },
cell : RelativeDateCell {
}, name : 'added',
{ label : 'Date Added',
name : "downloadedQuality", cell : RelativeDateCell
label : "Downloaded", },
cell : DownloadedQualityCell, {
sortable : true name : "downloadedQuality",
}, label : "Downloaded",
{ cell : DownloadedQualityCell,
name : 'profileId', sortable : true
label : 'Profile', },
cell : ProfileCell {
}, name : 'profileId',
{ label : 'Profile',
name : 'inCinemas', cell : ProfileCell
label : 'In Cinemas', },
cell : RelativeDateCell {
}, name : 'inCinemas',
{ label : 'In Cinemas',
name : 'this', cell : RelativeDateCell
label : 'Links', },
cell : MovieLinksCell, {
className : "movie-links-cell", name : 'this',
sortable : false, label : 'Links',
}, cell : MovieLinksCell,
{ className : "movie-links-cell",
name : "this", sortable : false,
label : "Status", },
cell : MovieDownloadStatusCell, {
sortable : false, name : "this",
sortValue : function(m, k) { label : "Status",
if (m.get("downloaded")) { cell : MovieDownloadStatusCell,
return -1; sortable : false,
} sortValue : function(m, k) {
return 0; if (m.get("downloaded")) {
} return -1;
}, }
{ return 0;
name : 'this', }
label : '', },
sortable : false, {
cell : MovieActionCell name : 'this',
} label : '',
], sortable : false,
cell : MovieActionCell
leftSideButtons : { }
type : 'default', ],
storeState : false,
collapse : true, leftSideButtons : {
items : [ type : 'default',
{ storeState : false,
title : 'Add Movie', collapse : true,
icon : 'icon-sonarr-add', items : [
route : 'addmovies' {
}, title : 'Add Movie',
{ icon : 'icon-sonarr-add',
title : 'Movie Editor', route : 'addmovies'
icon : 'icon-sonarr-edit', },
route : 'movieeditor' {
}, title : 'Movie Editor',
{ icon : 'icon-sonarr-edit',
title : 'RSS Sync', route : 'movieeditor'
icon : 'icon-sonarr-rss', },
command : 'rsssync', {
errorMessage : 'RSS Sync Failed!' title : 'RSS Sync',
}, icon : 'icon-sonarr-rss',
{ command : 'rsssync',
title : 'Update Library', errorMessage : 'RSS Sync Failed!'
icon : 'icon-sonarr-refresh', },
command : 'refreshmovie', {
successMessage : 'Library was updated!', title : 'Update Library',
errorMessage : 'Library update failed!' icon : 'icon-sonarr-refresh',
} command : 'refreshmovie',
] successMessage : 'Library was updated!',
}, errorMessage : 'Library update failed!'
}
initialize : function() { ]
//this variable prevents us from showing the list before seriesCollection has been fetched the first time },
this.renderedOnce = false;
this.seriesCollection = MoviesCollection;//.clone(); initialize : function() {
this.seriesCollection.bindSignalR(); //this variable prevents us from showing the list before seriesCollection has been fetched the first time
this.seriesCollection = MoviesCollection;//.clone();
this.seriesCollection.bindSignalR();
/*var selected = MoviesCollectionClient.fullCollection.where( { saved : true }); this.listenTo(FullMovieCollection, 'sync', function() {
this._showFooter();
_.each(selected, function(model) { });
model.set('saved', false);
});*/ this.listenTo(this.seriesCollection, 'sync', function(model, collection, options) {
this._renderView();
//MoviesCollectionClient.fetch();
});
//if (window.shownOnce) { this.listenTo(this.seriesCollection, "change", function(model) {
// FullMovieCollection.fetch({reset : true}); if (model.get('saved')) {
//} model.set('saved', false);
this.seriesCollection.fetch();
this.listenTo(MoviesCollectionClient, 'sync', function(eventName) { //FullMovieCollection.fetch({reset : true });
this._showFooter(); //this._showFooter();
window.shownOnce = true; var m = FullMovieCollection.findWhere( { tmdbId : model.get('tmdbId') });
}); m.set('monitored', model.get('monitored'));
m.set('minimumAvailability', model.get('minimumAvailability'));
this.listenTo(this.seriesCollection, 'sync', function(model, collection, options) { m.set( {profileId : model.get('profileId') } );
this._renderView();
//MoviesCollectionClient.fetch(); this._showFooter();
this.renderedOnce = true; }
}); });
this.listenTo(this.seriesCollection, "change", function(model) {
if (model.get('saved')) { this.listenTo(this.seriesCollection, 'remove', function(model, collection, options) {
model.set('saved', false); if (model.get('deleted')) {
this.seriesCollection.fetch(); this.seriesCollection.fetch(); //need to do this so that the page shows a full page and the 'total records' number is updated
//FullMovieCollection.fetch({reset : true }); //FullMovieCollection.fetch({reset : true}); //need to do this to update the footer
//this._showFooter(); FullMovieCollection.remove(model);
var m = MoviesCollectionClient.fullCollection.findWhere( { tmdbId : model.get('tmdbId') }); this._showFooter();
m.set('monitored', model.get('monitored')); }
m.set('minimumAvailability', model.get('minimumAvailability'));
m.set( {profileId : model.get('profileId') } ); });
this.sortingOptions = {
this._showFooter(); type : 'sorting',
} storeState : false,
}); viewCollection : this.seriesCollection,
callback : this._sort,
items : [
this.listenTo(this.seriesCollection, 'remove', function(model, collection, options) { {
if (model.get('deleted')) { title : 'Title',
this.seriesCollection.fetch(); //need to do this so that the page shows a full page and the 'total records' number is updated name : 'title'
//FullMovieCollection.fetch({reset : true}); //need to do this to update the footer },
MoviesCollectionClient.fullCollection.remove(model); {
this._showFooter(); title: 'Downloaded',
} name: 'downloadedQuality'
},
}); {
title : 'Profile',
this.sortingOptions = { name : 'profileId'
type : 'sorting', },
storeState : false, {
viewCollection : this.seriesCollection, title : 'In Cinemas',
callback : this._sort, name : 'inCinemas'
items : [ },
{ /*{
title : 'Title', title : "Status",
name : 'title' name : "status",
}, }*/
{ ]
title: 'Downloaded', };
name: 'downloadedQuality'
}, this.filteringOptions = {
{ type : 'radio',
title : 'Profile', storeState : true,
name : 'profileId' menuKey : 'series.filterMode',
}, defaultAction : 'all',
{ items : [
title : 'In Cinemas', {
name : 'inCinemas' key : 'all',
}, title : '',
/*{ tooltip : 'All',
title : "Status", icon : 'icon-sonarr-all',
name : "status", callback : this._setFilter
}*/ },
] {
}; key : 'monitored',
title : '',
this.filteringOptions = { tooltip : 'Monitored Only',
type : 'radio', icon : 'icon-sonarr-monitored',
storeState : true, callback : this._setFilter
menuKey : 'series.filterMode', },
defaultAction : 'all', {
items : [ key : 'missing',
{ title : '',
key : 'all', tooltip : 'Missing Only',
title : '', icon : 'icon-sonarr-missing',
tooltip : 'All', callback : this._setFilter
icon : 'icon-sonarr-all', },
callback : this._setFilter {
}, key : 'released',
{ title : '',
key : 'monitored', tooltip : 'Released',
title : '', icon : 'icon-sonarr-movie-released',
tooltip : 'Monitored Only', callback : this._setFilter
icon : 'icon-sonarr-monitored', },
callback : this._setFilter {
}, key : 'announced',
{ title : '',
key : 'missing', tooltip : 'Announced',
title : '', icon : 'icon-sonarr-movie-announced',
tooltip : 'Missing Only', callback : this._setFilter
icon : 'icon-sonarr-missing', },
callback : this._setFilter {
}, key : 'cinemas',
{ title : '',
key : 'released', tooltip : 'In Cinemas',
title : '', icon : 'icon-sonarr-movie-cinemas',
tooltip : 'Released', callback : this._setFilter
icon : 'icon-sonarr-movie-released', }
callback : this._setFilter ]
}, };
{
key : 'announced', this.viewButtons = {
title : '', type : 'radio',
tooltip : 'Announced', storeState : true,
icon : 'icon-sonarr-movie-announced', menuKey : 'seriesViewMode',
callback : this._setFilter defaultAction : 'listView',
}, items : [
{ {
key : 'cinemas', key : 'posterView',
title : '', title : '',
tooltip : 'In Cinemas', tooltip : 'Posters',
icon : 'icon-sonarr-movie-cinemas', icon : 'icon-sonarr-view-poster',
callback : this._setFilter callback : this._showPosters
} },
] {
}; key : 'listView',
title : '',
this.viewButtons = { tooltip : 'Overview List',
type : 'radio', icon : 'icon-sonarr-view-list',
storeState : true, callback : this._showList
menuKey : 'seriesViewMode', },
defaultAction : 'listView', {
items : [ key : 'tableView',
{ title : '',
key : 'posterView', tooltip : 'Table',
title : '', icon : 'icon-sonarr-view-table',
tooltip : 'Posters', callback : this._showTable
icon : 'icon-sonarr-view-poster', }
callback : this._showPosters ]
}, };
{ },
key : 'listView',
title : '', onShow : function() {
tooltip : 'Overview List', this._showToolbar();
icon : 'icon-sonarr-view-list', this._fetchCollection();
callback : this._showList if (window.shownOnce) {
}, this._showFooter();
{ }
key : 'tableView', window.shownOnce = true;
title : '', },
tooltip : 'Table',
icon : 'icon-sonarr-view-table', _showTable : function() {
callback : this._showTable this.currentView = new Backgrid.Grid({
} collection : this.seriesCollection,
] columns : this.columns,
}; className : 'table table-hover'
}, });
onShow : function() { this._showPager();
this._showToolbar(); this._renderView();
//if (window.shownOnce) { },
this._showFooter();
//} _showList : function() {
//this._fetchCollection(); //this.current = "list";
}, this.currentView = new ListCollectionView({
collection : this.seriesCollection
_showTable : function() { });
this.currentView = new Backgrid.Grid({
collection : this.seriesCollection, this._renderView();
columns : this.columns, },
className : 'table table-hover'
}); _showPosters : function() {
this.currentView = new PosterCollectionView({
//this._showPager(); collection : this.seriesCollection
if (this.renderedOnce) { });
this._renderView();
} this._renderView();
}, },
_showList : function() { _sort : function() {
//this.current = "list"; console.warn("Sorting");
this.currentView = new ListCollectionView({ },
collection : this.seriesCollection
}); _renderView : function() {
if (MoviesCollection.length === 0) {
this._renderView(); this.seriesRegion.show(new EmptyView());
},
this.toolbar.close();
_showPosters : function() { this.toolbar2.close();
this.currentView = new PosterCollectionView({ } else {
collection : this.seriesCollection this.renderedOnce = true;
}); this.seriesRegion.show(this.currentView);
this.listenTo(this.currentView.collection, 'sync', function(eventName){
this._renderView(); this._showPager();
}, });
this._showToolbar();
_sort : function() { }
console.warn("Sorting"); },
},
_fetchCollection : function() {
_renderView : function() { this.seriesCollection.fetch();
if (MoviesCollection.length === 0) { },
this.seriesRegion.show(new EmptyView());
_setFilter : function(buttonContext) {
this.toolbar.close(); var mode = buttonContext.model.get('key');
this.toolbar2.close(); this.seriesCollection.setFilterMode(mode);
} else { },
this.seriesRegion.show(this.currentView); _showToolbar : function() {
this._showToolbar(); if (this.toolbar.currentView) {
this._showPager(); return;
} }
},
this.toolbar2.show(new ToolbarLayout({
_setFilter : function(buttonContext) { right : [
var mode = buttonContext.model.get('key'); this.filteringOptions
this.seriesCollection.setFilterMode(mode); ],
}, context : this
}));
_showToolbar : function() {
if (this.toolbar.currentView) { this.toolbar.show(new ToolbarLayout({
return; right : [
} this.sortingOptions,
this.viewButtons
this.toolbar2.show(new ToolbarLayout({ ],
right : [ left : [
this.filteringOptions this.leftSideButtons
], ],
context : this context : this
})); }));
},
this.toolbar.show(new ToolbarLayout({
right : [ _showPager : function() {
this.sortingOptions, var pager = new GridPager({
this.viewButtons columns : this.columns,
], collection : this.seriesCollection,
left : [ });
this.leftSideButtons var pagerTop = new GridPager({
], columns : this.columns,
context : this collection : this.seriesCollection,
})); });
}, this.pager.show(pager);
this.pagerTop.show(pagerTop);
_showPager : function() { },
var pager = new GridPager({
columns : this.columns, _showFooter : function() {
collection : this.seriesCollection, var footerModel = new FooterModel();
}); var movies = FullMovieCollection.models.length;
var pagerTop = new GridPager({ //instead of all the counters could do something like this with different query in the where...
columns : this.columns, //var releasedMovies = FullMovieCollection.where({ 'released' : this.model.get('released') });
collection : this.seriesCollection, // releasedMovies.length
});
this.pager.show(pager); var announced = 0;
this.pagerTop.show(pagerTop); var incinemas = 0;
}, var released = 0;
_showFooter : function() { var monitored = 0;
var footerModel = new FooterModel();
var movies = MoviesCollectionClient.fullCollection.models.length; var downloaded =0;
//instead of all the counters could do something like this with different query in the where... var missingMonitored=0;
//var releasedMovies = FullMovieCollection.where({ 'released' : this.model.get('released') }); var missingNotMonitored=0;
// releasedMovies.length var missingMonitoredNotAvailable=0;
var missingMonitoredAvailable=0;
var announced = 0;
var incinemas = 0; var downloadedMonitored=0;
var released = 0; var downloadedNotMonitored=0;
var monitored = 0; _.each(FullMovieCollection.models, function(model) {
var downloaded =0; if (model.get('status').toLowerCase() === 'released') {
var missingMonitored=0; released++;
var missingNotMonitored=0; }
var missingMonitoredNotAvailable=0; else if (model.get('status').toLowerCase() === 'incinemas') {
var missingMonitoredAvailable=0; incinemas++;
}
var downloadedMonitored=0; else if (model.get('status').toLowerCase() === 'announced') {
var downloadedNotMonitored=0; announced++;
}
_.each(MoviesCollectionClient.fullCollection.models, function(model) {
if (model.get('monitored')) {
if (model.get('status').toLowerCase() === 'released') { monitored++;
released++; if (model.get('downloaded')) {
} downloadedMonitored++;
else if (model.get('status').toLowerCase() === 'incinemas') { }
incinemas++; }
} else { //not monitored
else if (model.get('status').toLowerCase() === 'announced') { if (model.get('downloaded')) {
announced++; downloadedNotMonitored++;
} }
else { //missing
if (model.get('monitored')) { missingNotMonitored++;
monitored++; }
if (model.get('downloaded')) { }
downloadedMonitored++;
} if (model.get('downloaded')) {
} downloaded++;
else { //not monitored }
if (model.get('downloaded')) { else { //missing
downloadedNotMonitored++; if (!model.get('isAvailable')) {
} if (model.get('monitored')) {
else { //missing missingMonitoredNotAvailable++;
missingNotMonitored++; }
} }
}
if (model.get('monitored')) {
if (model.get('downloaded')) { missingMonitored++;
downloaded++; if (model.get('isAvailable')) {
} missingMonitoredAvailable++;
else { //missing }
if (!model.get('isAvailable')) { }
if (model.get('monitored')) { }
missingMonitoredNotAvailable++; });
}
} footerModel.set({
movies : movies,
if (model.get('monitored')) { announced : announced,
missingMonitored++; incinemas : incinemas,
if (model.get('isAvailable')) { released : released,
missingMonitoredAvailable++; monitored : monitored,
} downloaded : downloaded,
} downloadedMonitored : downloadedMonitored,
} downloadedNotMonitored : downloadedNotMonitored,
}); missingMonitored : missingMonitored,
missingMonitoredAvailable : missingMonitoredAvailable,
footerModel.set({ missingMonitoredNotAvailable : missingMonitoredNotAvailable,
movies : movies, missingNotMonitored : missingNotMonitored
announced : announced, });
incinemas : incinemas,
released : released, this.footer.show(new FooterView({ model : footerModel }));
monitored : monitored, }
downloaded : downloaded, });
downloadedMonitored : downloadedMonitored,
downloadedNotMonitored : downloadedNotMonitored,
missingMonitored : missingMonitored,
missingMonitoredAvailable : missingMonitoredAvailable,
missingMonitoredNotAvailable : missingMonitoredNotAvailable,
missingNotMonitored : missingNotMonitored
});
this.footer.show(new FooterView({ model : footerModel }));
}
});

@ -1,7 +1,6 @@
var movieCollection = require('./MoviesCollection'); var movieCollection = require('./MoviesCollection');
var GCCollection = movieCollection.clone(); var ClientCollection = movieCollection.clone();
GCCollection.bindSignalR(); ClientCollection.bindSignalR();
GCCollection.switchMode('client'); //state.pageSize = 100000; ClientCollection.switchMode('client'); //state.pageSize = 100000;
//CCollection.fetch(); module.exports = ClientCollection;
module.exports = GCCollection;

@ -1,8 +1,7 @@
var NzbDroneController = require('../Shared/NzbDroneController'); var NzbDroneController = require('../Shared/NzbDroneController');
var AppLayout = require('../AppLayout'); var AppLayout = require('../AppLayout');
var MoviesCollection = require('./MoviesCollection'); var MoviesCollection = require('./MoviesCollection');
//var FullMovieCollection = require("./FullMovieCollection"); var FullMovieCollection = require("./FullMovieCollection");
var MoviesCollectionClient = require('./MoviesCollectionClient');
var MoviesIndexLayout = require('./Index/MoviesIndexLayout'); var MoviesIndexLayout = require('./Index/MoviesIndexLayout');
var MoviesDetailsLayout = require('./Details/MoviesDetailsLayout'); var MoviesDetailsLayout = require('./Details/MoviesDetailsLayout');
@ -23,10 +22,11 @@ module.exports = NzbDroneController.extend({
}, },
seriesDetails : function(query) { seriesDetails : function(query) {
if(MoviesCollectionClient.fullCollection.length > 0) {
if(FullMovieCollection.length > 0) {
this._renderMovieDetails(query); this._renderMovieDetails(query);
} else { } else {
this.listenTo(MoviesCollectionClient, 'sync', function(model, options) { this.listenTo(FullMovieCollection, 'sync', function(model, options) {
this._renderMovieDetails(query); this._renderMovieDetails(query);
}); });
} }
@ -34,7 +34,7 @@ module.exports = NzbDroneController.extend({
_renderMovieDetails: function(query) { _renderMovieDetails: function(query) {
var movies = MoviesCollectionClient.fullCollection.where({ titleSlug : query }); var movies = FullMovieCollection.where({ titleSlug : query });
if (movies.length !== 0) { if (movies.length !== 0) {
var targetMovie = movies[0]; var targetMovie = movies[0];

@ -2,8 +2,7 @@ var _ = require('underscore');
var $ = require('jquery'); var $ = require('jquery');
var vent = require('vent'); var vent = require('vent');
var Backbone = require('backbone'); var Backbone = require('backbone');
//var FullMovieCollection = require('../Movies/FullMovieCollection'); var FullMovieCollection = require('../Movies/FullMovieCollection');
var MoviesCollectionClient = require('../Movies/MoviesCollectionClient');
require('typeahead'); require('typeahead');
vent.on(vent.Hotkeys.NavbarSearch, function() { vent.on(vent.Hotkeys.NavbarSearch, function() {
@ -12,7 +11,7 @@ vent.on(vent.Hotkeys.NavbarSearch, function() {
var substringMatcher = function() { var substringMatcher = function() {
return function findMatches (q, cb) { return function findMatches (q, cb) {
var matches = _.select(MoviesCollectionClient.fullCollection.toJSON(), function(series) { var matches = _.select(FullMovieCollection.toJSON(), function(series) {
return series.title.toLowerCase().indexOf(q.toLowerCase()) > -1; return series.title.toLowerCase().indexOf(q.toLowerCase()) > -1;
}); });
cb(matches); cb(matches);

Loading…
Cancel
Save