Merge pull request #974 from geogolem/MovieEditorFixes

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

@ -2,8 +2,7 @@ var $ = require('jquery');
var _ = require('underscore');
var SelectAllCell = require('../../Cells/SelectAllCell');
var Backgrid = require('backgrid');
//var FullMovieCollection = require('../../Movies/FullMovieCollection');
var MoviesCollectionClient = require('../../Movies/MoviesCollectionClient');
var FullMovieCollection = require('../../Movies/FullMovieCollection');
module.exports = SelectAllCell.extend({
@ -15,7 +14,7 @@ module.exports = SelectAllCell.extend({
this._originalInit.apply(this, arguments);
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.listenTo(this.model, 'change', this._refresh);

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

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

@ -6,6 +6,7 @@ var RootFolders = require('../../AddMovies/RootFolders/RootFolderCollection');
var RootFolderLayout = require('../../AddMovies/RootFolders/RootFolderLayout');
var UpdateFilesMoviesView = require('./Organize/OrganizeFilesView');
var Config = require('../../Config');
var FullMovieCollection = require('../FullMovieCollection');
module.exports = Marionette.ItemView.extend({
template : 'Movies/Editor/MovieEditorFooterViewTemplate',
@ -44,11 +45,16 @@ module.exports = Marionette.ItemView.extend({
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);
this._updateInfo();
});
this.listenTo(FullMovieCollection, 'save', function() {
window.alert(' Done Saving');
var selected = FullMovieCollection.where({ selected : true });
});
this.listenTo(RootFolders, 'all', this.render);
@ -61,14 +67,19 @@ module.exports = Marionette.ItemView.extend({
_updateAndSave : function() {
//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 minAvail = this.ui.minimumAvailability.val();
var profile = this.ui.profile.val();
var seasonFolder = this.ui.seasonFolder.val();
var rootFolder = this.ui.rootFolder.val();
var i = 0;
var b = [];
_.each(selected, function(model) {
b[i] = model.get('tmdbId');
i++;
if (monitored === 'true') {
model.set('monitored', true);
} else if (monitored === 'false') {
@ -96,7 +107,38 @@ module.exports = Marionette.ItemView.extend({
}
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() {

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

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

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

@ -2,8 +2,7 @@ var _ = require('underscore');
var $ = require('jquery');
var vent = require('vent');
var Backbone = require('backbone');
//var FullMovieCollection = require('../Movies/FullMovieCollection');
var MoviesCollectionClient = require('../Movies/MoviesCollectionClient');
var FullMovieCollection = require('../Movies/FullMovieCollection');
require('typeahead');
vent.on(vent.Hotkeys.NavbarSearch, function() {
@ -12,7 +11,7 @@ vent.on(vent.Hotkeys.NavbarSearch, function() {
var substringMatcher = function() {
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;
});
cb(matches);

Loading…
Cancel
Save