Merge branch 'develop' into MovieEditorFixes

geogolem 8 years ago committed by GitHub
commit d03ee006fc

@ -49,7 +49,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{ {
if (retries == 5) if (retries == 5)
{ {
throw new DownloadClientException("Try to process same request more than 5 times"); throw new DownloadClientException("Try to process request to {0} with {1} more than 5 times", api, arguments.ToJson().ToString());
} }
if (!_authenticated && api != DiskStationApi.Info && api != DiskStationApi.DSMInfo) if (!_authenticated && api != DiskStationApi.Info && api != DiskStationApi.DSMInfo)
@ -72,15 +72,21 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
} }
else else
{ {
var msg = $"Failed to {operation}. Reason: {responseContent.Error.GetMessage(api)}";
_logger.Error(msg);
if (responseContent.Error.SessionError) if (responseContent.Error.SessionError)
{ {
_authenticated = false; _authenticated = false;
return ProcessRequest<T>(api, arguments, settings, operation, method, retries++);
}
var msg = $"Failed to {operation}. Reason: {responseContent.Error.GetMessage(api)}";
_logger.Error(msg);
if (responseContent.Error.Code == 105)
{
throw new DownloadClientAuthenticationException(msg);
}
return ProcessRequest<T>(api, arguments, settings, operation, method, ++retries);
}
throw new DownloadClientException(msg); throw new DownloadClientException(msg);
} }
} }

@ -282,7 +282,17 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{ {
try try
{ {
var downloadDir = GetDownloadDirectory(); var downloadDir = GetDefaultDir();
if (downloadDir == null)
{
return new NzbDroneValidationFailure(nameof(Settings.TvDirectory), "No default destination")
{
DetailedDescription = $"You must login into your Diskstation as {Settings.Username} and manually set it up into DownloadStation settings under BT/HTTP/FTP/NZB -> Location."
};
}
downloadDir = GetDownloadDirectory();
if (downloadDir != null) if (downloadDir != null)
{ {
@ -295,7 +305,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{ {
return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist") return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist")
{ {
DetailedDescription = $"The DownloadStation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?" DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
}; };
} }
@ -310,6 +320,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return null; return null;
} }
catch (DownloadClientAuthenticationException ex) // User could not have permission to access to downloadstation
{
_logger.Error(ex);
return new NzbDroneValidationFailure(string.Empty, ex.Message);
}
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error(ex); _logger.Error(ex);

@ -195,7 +195,17 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{ {
try try
{ {
var downloadDir = GetDownloadDirectory(); var downloadDir = GetDefaultDir();
if (downloadDir == null)
{
return new NzbDroneValidationFailure(nameof(Settings.TvDirectory), "No default destination")
{
DetailedDescription = $"You must login into your Diskstation as {Settings.Username} and manually set it up into DownloadStation settings under BT/HTTP/FTP/NZB -> Location."
};
}
downloadDir = GetDownloadDirectory();
if (downloadDir != null) if (downloadDir != null)
{ {
@ -208,7 +218,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{ {
return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist") return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist")
{ {
DetailedDescription = $"The DownloadStation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?" DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
}; };
} }
@ -223,6 +233,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return null; return null;
} }
catch (DownloadClientAuthenticationException ex) // User could not have permission to access to downloadstation
{
_logger.Error(ex);
return new NzbDroneValidationFailure(string.Empty, ex.Message);
}
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error(ex); _logger.Error(ex);

@ -36,42 +36,34 @@ namespace NzbDrone.Core.MediaFiles
_logger = logger; _logger = logger;
} }
public MovieFileMoveResult UpgradeMovieFile(MovieFile episodeFile, LocalMovie localEpisode, bool copyOnly = false) public MovieFileMoveResult UpgradeMovieFile(MovieFile movieFile, LocalMovie localMovie, bool copyOnly = false)
{ {
_logger.Trace("Upgrading existing episode file."); _logger.Trace("Upgrading existing movie file.");
var moveFileResult = new MovieFileMoveResult(); var moveFileResult = new MovieFileMoveResult();
localEpisode.Movie.MovieFile.LazyLoad();
var existingFile = localEpisode.Movie.MovieFile;
existingFile.LazyLoad();
if (existingFile.IsLoaded && existingFile.Value != null) var existingFile = localMovie.Movie.MovieFile.Value;
if (existingFile != null)
{ {
var file = existingFile.Value; var movieFilePath = Path.Combine(localMovie.Movie.Path, existingFile.RelativePath);
var episodeFilePath = Path.Combine(localEpisode.Movie.Path, file.RelativePath);
if (_diskProvider.FileExists(episodeFilePath)) if (_diskProvider.FileExists(movieFilePath))
{ {
_logger.Debug("Removing existing episode file: {0}", file); _logger.Debug("Removing existing movie file: {0}", existingFile);
_recycleBinProvider.DeleteFile(episodeFilePath); _recycleBinProvider.DeleteFile(movieFilePath);
} }
moveFileResult.OldFiles.Add(file); moveFileResult.OldFiles.Add(existingFile);
_mediaFileService.Delete(file, DeleteMediaFileReason.Upgrade); _mediaFileService.Delete(existingFile, DeleteMediaFileReason.Upgrade);
} }
else
{
//_logger.Warn("The existing movie file was not lazy loaded.");
}
if (copyOnly) if (copyOnly)
{ {
moveFileResult.MovieFile = _movieFileMover.CopyMovieFile(episodeFile, localEpisode); moveFileResult.MovieFile = _movieFileMover.CopyMovieFile(movieFile, localMovie);
} }
else else
{ {
moveFileResult.MovieFile= _movieFileMover.MoveMovieFile(episodeFile, localEpisode); moveFileResult.MovieFile = _movieFileMover.MoveMovieFile(movieFile, localMovie);
} }
return moveFileResult; return moveFileResult;

@ -31,17 +31,17 @@ namespace NzbDrone.Core.Notifications.CustomScript
{ {
var movie = message.Movie; var movie = message.Movie;
var remoteMovie = message.RemoteMovie; var remoteMovie = message.RemoteMovie;
var releaseGroup = remoteMovie.ParsedMovieInfo.ReleaseGroup;
var environmentVariables = new StringDictionary(); var environmentVariables = new StringDictionary();
environmentVariables.Add("Radarr_EventType", "Grab"); environmentVariables.Add("Radarr_EventType", "Grab");
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString()); environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title); environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId.ToString()); environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString());
environmentVariables.Add("Radarr_Release_Title", remoteMovie.Release.Title); environmentVariables.Add("Radarr_Release_Title", remoteMovie.Release.Title);
environmentVariables.Add("Radarr_Release_Indexer", remoteMovie.Release.Indexer); environmentVariables.Add("Radarr_Release_Indexer", remoteMovie.Release.Indexer);
environmentVariables.Add("Radarr_Release_Size", remoteMovie.Release.Size.ToString()); environmentVariables.Add("Radarr_Release_Size", remoteMovie.Release.Size.ToString());
environmentVariables.Add("Radarr_Release_ReleaseGroup", releaseGroup); environmentVariables.Add("Radarr_Release_ReleaseGroup", remoteMovie.ParsedMovieInfo.ReleaseGroup ?? string.Empty);
ExecuteScript(environmentVariables); ExecuteScript(environmentVariables);
} }
@ -57,7 +57,8 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString()); environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title); environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_Path", movie.Path); environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId.ToString()); environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString());
environmentVariables.Add("Radarr_MovieFile_Id", movieFile.Id.ToString()); environmentVariables.Add("Radarr_MovieFile_Id", movieFile.Id.ToString());
environmentVariables.Add("Radarr_MovieFile_RelativePath", movieFile.RelativePath); environmentVariables.Add("Radarr_MovieFile_RelativePath", movieFile.RelativePath);
environmentVariables.Add("Radarr_MovieFile_Path", Path.Combine(movie.Path, movieFile.RelativePath)); environmentVariables.Add("Radarr_MovieFile_Path", Path.Combine(movie.Path, movieFile.RelativePath));
@ -79,7 +80,9 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString()); environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title); environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_Path", movie.Path); environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_TvdbId", movie.ImdbId.ToString()); environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString());
ExecuteScript(environmentVariables); ExecuteScript(environmentVariables);
} }

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

@ -37,7 +37,9 @@
<div class="col-md-8 col-xs-8"> <div class="col-md-8 col-xs-8">
<span class="label label-default">{{GetStatus}}</span> <span class="label label-default">{{GetStatus}}</span>
<span class="label label-default">{{ShortDate inCinemas}}</span> {{#if inCinemas}}
<span class="label label-default">{{RelativeDate inCinemas}}</span>
{{/if}}
{{profile profileId}} {{profile profileId}}

@ -4,7 +4,6 @@ var MoviesCollection = require('./MoviesCollection');
var FullMovieCollection = require("./FullMovieCollection"); var FullMovieCollection = require("./FullMovieCollection");
var MoviesIndexLayout = require('./Index/MoviesIndexLayout'); var MoviesIndexLayout = require('./Index/MoviesIndexLayout');
var MoviesDetailsLayout = require('./Details/MoviesDetailsLayout'); var MoviesDetailsLayout = require('./Details/MoviesDetailsLayout');
var SeriesDetailsLayout = require('../Series/Details/SeriesDetailsLayout');
module.exports = NzbDroneController.extend({ module.exports = NzbDroneController.extend({
_originalInit : NzbDroneController.prototype.initialize, _originalInit : NzbDroneController.prototype.initialize,
@ -23,17 +22,26 @@ module.exports = NzbDroneController.extend({
}, },
seriesDetails : function(query) { seriesDetails : function(query) {
var series = FullMovieCollection.where({ titleSlug : query });
if (series.length !== 0) { if(FullMovieCollection.length > 0) {
var targetMovie = series[0]; this._renderMovieDetails(query);
console.log(AppLayout.mainRegion); } else {
this.listenTo(FullMovieCollection, 'sync', function(model, options) {
this.setTitle(targetMovie.get('title')); this._renderMovieDetails(query);
//this.showNotFound(); });
//this.showMainRegion(new SeriesDetailsLayout({model : targetMovie})); }
this.showMainRegion(new MoviesDetailsLayout({ model : targetMovie })); },
} else {
this.showNotFound();
} _renderMovieDetails: function(query) {
var movies = FullMovieCollection.where({ titleSlug : query });
if (movies.length !== 0) {
var targetMovie = movies[0];
this.setTitle(targetMovie.get('title'));
this.showMainRegion(new MoviesDetailsLayout({ model : targetMovie }));
} else {
this.showNotFound();
}
} }
}); });

Loading…
Cancel
Save