UI Cleanup - Updated Series subtree.

pull/4/head
Taloth Saldono 9 years ago
parent 1bf433872a
commit b69ea349ce

@ -2,34 +2,39 @@ var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Series/Delete/DeleteSeriesTemplate', template : 'Series/Delete/DeleteSeriesTemplate',
events : {
"click .x-confirm-delete" : 'removeSeries', events : {
"change .x-delete-files" : 'changeDeletedFiles' 'click .x-confirm-delete' : 'removeSeries',
'change .x-delete-files' : 'changeDeletedFiles'
}, },
ui : {
ui : {
deleteFiles : '.x-delete-files', deleteFiles : '.x-delete-files',
deleteFilesInfo : '.x-delete-files-info', deleteFilesInfo : '.x-delete-files-info',
indicator : '.x-indicator' indicator : '.x-indicator'
}, },
removeSeries : function(){
removeSeries : function() {
var self = this; var self = this;
var deleteFiles = this.ui.deleteFiles.prop('checked'); var deleteFiles = this.ui.deleteFiles.prop('checked');
this.ui.indicator.show(); this.ui.indicator.show();
this.model.destroy({ this.model.destroy({
data : {"deleteFiles" : deleteFiles}, data : { 'deleteFiles' : deleteFiles },
wait : true wait : true
}).done(function(){ }).done(function() {
vent.trigger(vent.Events.SeriesDeleted, {series : self.model}); vent.trigger(vent.Events.SeriesDeleted, { series : self.model });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}); });
}, },
changeDeletedFiles : function(){
changeDeletedFiles : function() {
var deleteFiles = this.ui.deleteFiles.prop('checked'); var deleteFiles = this.ui.deleteFiles.prop('checked');
if(deleteFiles) {
if (deleteFiles) {
this.ui.deleteFilesInfo.show(); this.ui.deleteFilesInfo.show();
} } else {
else {
this.ui.deleteFilesInfo.hide(); this.ui.deleteFilesInfo.hide();
} }
} }

@ -6,27 +6,38 @@ var SeriesCollection = require('../SeriesCollection');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'episode-number-cell', className : 'episode-number-cell',
template : 'Series/Details/EpisodeNumberCellTemplate', template : 'Series/Details/EpisodeNumberCellTemplate',
render : function(){
render : function() {
this.$el.empty(); this.$el.empty();
this.$el.html(this.model.get('episodeNumber')); this.$el.html(this.model.get('episodeNumber'));
var series = SeriesCollection.get(this.model.get('seriesId')); var series = SeriesCollection.get(this.model.get('seriesId'));
if(series.get('seriesType') === 'anime' && this.model.has('absoluteEpisodeNumber')) {
if (series.get('seriesType') === 'anime' && this.model.has('absoluteEpisodeNumber')) {
this.$el.html('{0} ({1})'.format(this.model.get('episodeNumber'), this.model.get('absoluteEpisodeNumber'))); this.$el.html('{0} ({1})'.format(this.model.get('episodeNumber'), this.model.get('absoluteEpisodeNumber')));
} }
var alternateTitles = []; var alternateTitles = [];
if(reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) {
if(this.model.get('sceneSeasonNumber') > 0) { if (reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) {
if (this.model.get('sceneSeasonNumber') > 0) {
alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySeasonNumber, this.model.get('seriesId'), this.model.get('sceneSeasonNumber')); alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySeasonNumber, this.model.get('seriesId'), this.model.get('sceneSeasonNumber'));
} }
if(alternateTitles.length === 0) {
if (alternateTitles.length === 0) {
alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySeasonNumber, this.model.get('seriesId'), this.model.get('seasonNumber')); alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySeasonNumber, this.model.get('seriesId'), this.model.get('seasonNumber'));
} }
} }
if(this.model.get('sceneSeasonNumber') > 0 || this.model.get('sceneEpisodeNumber') > 0 || this.model.has('sceneAbsoluteEpisodeNumber') || alternateTitles.length > 0) {
if (this.model.get('sceneSeasonNumber') > 0 || this.model.get('sceneEpisodeNumber') > 0 || this.model.has('sceneAbsoluteEpisodeNumber') || alternateTitles.length > 0) {
this.templateFunction = Marionette.TemplateCache.get(this.template); this.templateFunction = Marionette.TemplateCache.get(this.template);
var json = this.model.toJSON(); var json = this.model.toJSON();
json.alternateTitles = alternateTitles; json.alternateTitles = alternateTitles;
var html = this.templateFunction(json); var html = this.templateFunction(json);
this.$el.popover({ this.$el.popover({
content : html, content : html,
html : true, html : true,
@ -36,6 +47,7 @@ module.exports = NzbDroneCell.extend({
container : this.$el container : this.$el
}); });
} }
this.delegateEvents(); this.delegateEvents();
return this; return this;
} }

@ -3,13 +3,16 @@ var SeriesCollection = require('../SeriesCollection');
module.exports = NzbDroneCell.extend({ module.exports = NzbDroneCell.extend({
className : 'episode-warning-cell', className : 'episode-warning-cell',
render : function(){
render : function() {
this.$el.empty(); this.$el.empty();
if(SeriesCollection.get(this.model.get('seriesId')).get('seriesType') === 'anime') {
if(this.model.get('seasonNumber') > 0 && !this.model.has('absoluteEpisodeNumber')) { if (SeriesCollection.get(this.model.get('seriesId')).get('seriesType') === 'anime') {
if (this.model.get('seasonNumber') > 0 && !this.model.has('absoluteEpisodeNumber')) {
this.$el.html('<i class="icon-nd-form-warning" title="Episode does not have an absolute episode number"></i>'); this.$el.html('<i class="icon-nd-form-warning" title="Episode does not have an absolute episode number"></i>');
} }
} }
this.delegateEvents(); this.delegateEvents();
return this; return this;
} }

@ -1,13 +1,18 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Series/Details/InfoViewTemplate', template : 'Series/Details/InfoViewTemplate',
initialize : function(options){
initialize : function(options) {
this.episodeFileCollection = options.episodeFileCollection; this.episodeFileCollection = options.episodeFileCollection;
this.listenTo(this.model, 'change', this.render); this.listenTo(this.model, 'change', this.render);
this.listenTo(this.episodeFileCollection, 'sync', this.render); this.listenTo(this.episodeFileCollection, 'sync', this.render);
}, },
templateHelpers : function(){
return {fileCount : this.episodeFileCollection.length}; templateHelpers : function() {
return {
fileCount : this.episodeFileCollection.length
};
} }
}); });

@ -3,34 +3,42 @@ var Marionette = require('marionette');
var SeasonLayout = require('./SeasonLayout'); var SeasonLayout = require('./SeasonLayout');
var AsSortedCollectionView = require('../../Mixins/AsSortedCollectionView'); var AsSortedCollectionView = require('../../Mixins/AsSortedCollectionView');
module.exports = (function(){ var view = Marionette.CollectionView.extend({
var view = Marionette.CollectionView.extend({
itemView : SeasonLayout, itemView : SeasonLayout,
initialize : function(options){
if(!options.episodeCollection) { initialize : function(options) {
throw 'episodeCollection is needed'; if (!options.episodeCollection) {
} throw 'episodeCollection is needed';
this.episodeCollection = options.episodeCollection; }
this.series = options.series;
}, this.episodeCollection = options.episodeCollection;
itemViewOptions : function(){ this.series = options.series;
return { },
episodeCollection : this.episodeCollection,
series : this.series itemViewOptions : function() {
}; return {
}, episodeCollection : this.episodeCollection,
onEpisodeGrabbed : function(message){ series : this.series
if(message.episode.series.id !== this.episodeCollection.seriesId) { };
return; },
}
var self = this; onEpisodeGrabbed : function(message) {
_.each(message.episode.episodes, function(episode){ if (message.episode.series.id !== this.episodeCollection.seriesId) {
var ep = self.episodeCollection.get(episode.id); return;
ep.set('downloading', true);
});
this.render();
} }
});
AsSortedCollectionView.call(view); var self = this;
return view;
}).call(this); _.each(message.episode.episodes, function(episode) {
var ep = self.episodeCollection.get(episode.id);
ep.set('downloading', true);
});
this.render();
}
});
AsSortedCollectionView.call(view);
module.exports = view;

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var Backgrid = require('backgrid'); var Backgrid = require('backgrid');
var ToggleCell = require('../../Cells/EpisodeMonitoredCell'); var ToggleCell = require('../../Cells/EpisodeMonitoredCell');
@ -14,68 +14,86 @@ var _ = require('underscore');
var Messenger = require('../../Shared/Messenger'); var Messenger = require('../../Shared/Messenger');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Series/Details/SeasonLayoutTemplate', template : 'Series/Details/SeasonLayoutTemplate',
ui : {
ui : {
seasonSearch : '.x-season-search', seasonSearch : '.x-season-search',
seasonMonitored : '.x-season-monitored', seasonMonitored : '.x-season-monitored',
seasonRename : '.x-season-rename' seasonRename : '.x-season-rename'
}, },
events : {
"click .x-season-monitored" : '_seasonMonitored', events : {
"click .x-season-search" : '_seasonSearch', 'click .x-season-monitored' : '_seasonMonitored',
"click .x-season-rename" : '_seasonRename', 'click .x-season-search' : '_seasonSearch',
"click .x-show-hide-episodes" : '_showHideEpisodes', 'click .x-season-rename' : '_seasonRename',
"dblclick .series-season h2" : '_showHideEpisodes' 'click .x-show-hide-episodes' : '_showHideEpisodes',
}, 'dblclick .series-season h2' : '_showHideEpisodes'
regions : {episodeGrid : '.x-episode-grid'}, },
columns : [{
name : 'monitored', regions : {
label : '', episodeGrid : '.x-episode-grid'
cell : ToggleCell, },
trueClass : 'icon-bookmark',
falseClass : 'icon-bookmark-empty', columns : [
tooltip : 'Toggle monitored status', {
sortable : false name : 'monitored',
}, { label : '',
name : 'episodeNumber', cell : ToggleCell,
label : '#', trueClass : 'icon-bookmark',
cell : EpisodeNumberCell falseClass : 'icon-bookmark-empty',
}, { tooltip : 'Toggle monitored status',
name : 'this', sortable : false
label : '', },
cell : EpisodeWarningCell, {
sortable : false, name : 'episodeNumber',
className : 'episode-warning-cell' label : '#',
}, { cell : EpisodeNumberCell
name : 'this', },
label : 'Title', {
hideSeriesLink : true, name : 'this',
cell : EpisodeTitleCell, label : '',
sortable : false cell : EpisodeWarningCell,
}, { sortable : false,
name : 'airDateUtc', className : 'episode-warning-cell'
label : 'Air Date', },
cell : RelativeDateCell {
}, { name : 'this',
name : 'status', label : 'Title',
label : 'Status', hideSeriesLink : true,
cell : EpisodeStatusCell, cell : EpisodeTitleCell,
sortable : false sortable : false
}, { },
name : 'this', {
label : '', name : 'airDateUtc',
cell : EpisodeActionsCell, label : 'Air Date',
sortable : false cell : RelativeDateCell
}], },
templateHelpers : function(){ {
var episodeCount = this.episodeCollection.filter(function(episode){ name : 'status',
label : 'Status',
cell : EpisodeStatusCell,
sortable : false
},
{
name : 'this',
label : '',
cell : EpisodeActionsCell,
sortable : false
}
],
templateHelpers : function() {
var episodeCount = this.episodeCollection.filter(function(episode) {
return episode.get('hasFile') || episode.get('monitored') && moment(episode.get('airDateUtc')).isBefore(moment()); return episode.get('hasFile') || episode.get('monitored') && moment(episode.get('airDateUtc')).isBefore(moment());
}).length; }).length;
var episodeFileCount = this.episodeCollection.where({hasFile : true}).length;
var episodeFileCount = this.episodeCollection.where({ hasFile : true }).length;
var percentOfEpisodes = 100; var percentOfEpisodes = 100;
if(episodeCount > 0) {
if (episodeCount > 0) {
percentOfEpisodes = episodeFileCount / episodeCount * 100; percentOfEpisodes = episodeFileCount / episodeCount * 100;
} }
return { return {
showingEpisodes : this.showingEpisodes, showingEpisodes : this.showingEpisodes,
episodeCount : episodeCount, episodeCount : episodeCount,
@ -83,24 +101,32 @@ module.exports = Marionette.Layout.extend({
percentOfEpisodes : percentOfEpisodes percentOfEpisodes : percentOfEpisodes
}; };
}, },
initialize : function(options){
if(!options.episodeCollection) { initialize : function(options) {
if (!options.episodeCollection) {
throw 'episodeCollection is needed'; throw 'episodeCollection is needed';
} }
this.series = options.series; this.series = options.series;
this.fullEpisodeCollection = options.episodeCollection; this.fullEpisodeCollection = options.episodeCollection;
this.episodeCollection = this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber')); this.episodeCollection = this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber'));
this._updateEpisodeCollection(); this._updateEpisodeCollection();
this.showingEpisodes = this._shouldShowEpisodes(); this.showingEpisodes = this._shouldShowEpisodes();
this.listenTo(this.model, 'sync', this._afterSeasonMonitored); this.listenTo(this.model, 'sync', this._afterSeasonMonitored);
this.listenTo(this.episodeCollection, 'sync', this.render); this.listenTo(this.episodeCollection, 'sync', this.render);
this.listenTo(this.fullEpisodeCollection, 'sync', this._refreshEpsiodes); this.listenTo(this.fullEpisodeCollection, 'sync', this._refreshEpsiodes);
}, },
onRender : function(){
if(this.showingEpisodes) { onRender : function() {
if (this.showingEpisodes) {
this._showEpisodes(); this._showEpisodes();
} }
this._setSeasonMonitoredState(); this._setSeasonMonitoredState();
CommandController.bindToCommand({ CommandController.bindToCommand({
element : this.ui.seasonSearch, element : this.ui.seasonSearch,
command : { command : {
@ -109,6 +135,7 @@ module.exports = Marionette.Layout.extend({
seasonNumber : this.model.get('seasonNumber') seasonNumber : this.model.get('seasonNumber')
} }
}); });
CommandController.bindToCommand({ CommandController.bindToCommand({
element : this.ui.seasonRename, element : this.ui.seasonRename,
command : { command : {
@ -118,112 +145,143 @@ module.exports = Marionette.Layout.extend({
} }
}); });
}, },
_seasonSearch : function(){
_seasonSearch : function() {
CommandController.Execute('seasonSearch', { CommandController.Execute('seasonSearch', {
name : 'seasonSearch', name : 'seasonSearch',
seriesId : this.series.id, seriesId : this.series.id,
seasonNumber : this.model.get('seasonNumber') seasonNumber : this.model.get('seasonNumber')
}); });
}, },
_seasonRename : function(){
_seasonRename : function() {
vent.trigger(vent.Commands.ShowRenamePreview, { vent.trigger(vent.Commands.ShowRenamePreview, {
series : this.series, series : this.series,
seasonNumber : this.model.get('seasonNumber') seasonNumber : this.model.get('seasonNumber')
}); });
}, },
_seasonMonitored : function(){
if(!this.series.get('monitored')) { _seasonMonitored : function() {
if (!this.series.get('monitored')) {
Messenger.show({ Messenger.show({
message : 'Unable to change monitored state when series is not monitored', message : 'Unable to change monitored state when series is not monitored',
type : 'error' type : 'error'
}); });
return; return;
} }
var name = 'monitored'; var name = 'monitored';
this.model.set(name, !this.model.get(name)); this.model.set(name, !this.model.get(name));
this.series.setSeasonMonitored(this.model.get('seasonNumber')); this.series.setSeasonMonitored(this.model.get('seasonNumber'));
var savePromise = this.series.save().always(this._afterSeasonMonitored.bind(this)); var savePromise = this.series.save().always(this._afterSeasonMonitored.bind(this));
this.ui.seasonMonitored.spinForPromise(savePromise); this.ui.seasonMonitored.spinForPromise(savePromise);
}, },
_afterSeasonMonitored : function(){
_afterSeasonMonitored : function() {
var self = this; var self = this;
_.each(this.episodeCollection.models, function(episode){
episode.set({monitored : self.model.get('monitored')}); _.each(this.episodeCollection.models, function(episode) {
episode.set({ monitored : self.model.get('monitored') });
}); });
this.render(); this.render();
}, },
_setSeasonMonitoredState : function(){
_setSeasonMonitoredState : function() {
this.ui.seasonMonitored.removeClass('icon-spinner icon-spin'); this.ui.seasonMonitored.removeClass('icon-spinner icon-spin');
if(this.model.get('monitored')) {
if (this.model.get('monitored')) {
this.ui.seasonMonitored.addClass('icon-bookmark'); this.ui.seasonMonitored.addClass('icon-bookmark');
this.ui.seasonMonitored.removeClass('icon-bookmark-empty'); this.ui.seasonMonitored.removeClass('icon-bookmark-empty');
} } else {
else {
this.ui.seasonMonitored.addClass('icon-bookmark-empty'); this.ui.seasonMonitored.addClass('icon-bookmark-empty');
this.ui.seasonMonitored.removeClass('icon-bookmark'); this.ui.seasonMonitored.removeClass('icon-bookmark');
} }
}, },
_showEpisodes : function(){
_showEpisodes : function() {
this.episodeGrid.show(new Backgrid.Grid({ this.episodeGrid.show(new Backgrid.Grid({
columns : this.columns, columns : this.columns,
collection : this.episodeCollection, collection : this.episodeCollection,
className : 'table table-hover season-grid' className : 'table table-hover season-grid'
})); }));
}, },
_shouldShowEpisodes : function(){
_shouldShowEpisodes : function() {
var startDate = moment().add('month', -1); var startDate = moment().add('month', -1);
var endDate = moment().add('year', 1); var endDate = moment().add('year', 1);
return this.episodeCollection.some(function(episode){
return this.episodeCollection.some(function(episode) {
var airDate = episode.get('airDateUtc'); var airDate = episode.get('airDateUtc');
if(airDate) {
if (airDate) {
var airDateMoment = moment(airDate); var airDateMoment = moment(airDate);
if(airDateMoment.isAfter(startDate) && airDateMoment.isBefore(endDate)) {
if (airDateMoment.isAfter(startDate) && airDateMoment.isBefore(endDate)) {
return true; return true;
} }
} }
return false; return false;
}); });
}, },
_showHideEpisodes : function(){
if(this.showingEpisodes) { _showHideEpisodes : function() {
if (this.showingEpisodes) {
this.showingEpisodes = false; this.showingEpisodes = false;
this.episodeGrid.close(); this.episodeGrid.close();
} } else {
else {
this.showingEpisodes = true; this.showingEpisodes = true;
this._showEpisodes(); this._showEpisodes();
} }
this.templateHelpers.showingEpisodes = this.showingEpisodes; this.templateHelpers.showingEpisodes = this.showingEpisodes;
this.render(); this.render();
}, },
_episodeMonitoredToggled : function(options){
_episodeMonitoredToggled : function(options) {
var model = options.model; var model = options.model;
var shiftKey = options.shiftKey; var shiftKey = options.shiftKey;
if(!this.episodeCollection.get(model.get('id'))) {
if (!this.episodeCollection.get(model.get('id'))) {
return; return;
} }
if(!shiftKey) {
if (!shiftKey) {
return; return;
} }
var lastToggled = this.episodeCollection.lastToggled; var lastToggled = this.episodeCollection.lastToggled;
if(!lastToggled) {
if (!lastToggled) {
return; return;
} }
var currentIndex = this.episodeCollection.indexOf(model); var currentIndex = this.episodeCollection.indexOf(model);
var lastIndex = this.episodeCollection.indexOf(lastToggled); var lastIndex = this.episodeCollection.indexOf(lastToggled);
var low = Math.min(currentIndex, lastIndex); var low = Math.min(currentIndex, lastIndex);
var high = Math.max(currentIndex, lastIndex); var high = Math.max(currentIndex, lastIndex);
var range = _.range(low + 1, high); var range = _.range(low + 1, high);
this.episodeCollection.lastToggled = model; this.episodeCollection.lastToggled = model;
}, },
_updateEpisodeCollection : function(){
_updateEpisodeCollection : function() {
var self = this; var self = this;
this.episodeCollection.add(this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber')).models, {merge : true});
this.episodeCollection.each(function(model){ this.episodeCollection.add(this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber')).models, { merge : true });
this.episodeCollection.each(function(model) {
model.episodeCollection = self.episodeCollection; model.episodeCollection = self.episodeCollection;
}); });
}, },
_refreshEpsiodes : function(){
_refreshEpsiodes : function() {
this._updateEpisodeCollection(); this._updateEpisodeCollection();
this.render(); this.render();
} }

@ -16,13 +16,15 @@ require('backstrech');
require('../../Mixins/backbone.signalr.mixin'); require('../../Mixins/backbone.signalr.mixin');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
itemViewContainer : '.x-series-seasons', itemViewContainer : '.x-series-seasons',
template : 'Series/Details/SeriesDetailsTemplate', template : 'Series/Details/SeriesDetailsTemplate',
regions : {
regions : {
seasons : '#seasons', seasons : '#seasons',
info : '#info' info : '#info'
}, },
ui : {
ui : {
header : '.x-header', header : '.x-header',
monitored : '.x-monitored', monitored : '.x-monitored',
edit : '.x-edit', edit : '.x-edit',
@ -30,47 +32,59 @@ module.exports = Marionette.Layout.extend({
rename : '.x-rename', rename : '.x-rename',
search : '.x-search' search : '.x-search'
}, },
events : {
events : {
'click .x-monitored' : '_toggleMonitored', 'click .x-monitored' : '_toggleMonitored',
'click .x-edit' : '_editSeries', 'click .x-edit' : '_editSeries',
'click .x-refresh' : '_refreshSeries', 'click .x-refresh' : '_refreshSeries',
'click .x-rename' : '_renameSeries', 'click .x-rename' : '_renameSeries',
'click .x-search' : '_seriesSearch' 'click .x-search' : '_seriesSearch'
}, },
initialize : function(){
initialize : function() {
this.seriesCollection = SeriesCollection.clone(); this.seriesCollection = SeriesCollection.clone();
this.seriesCollection.shadowCollection.bindSignalR(); this.seriesCollection.shadowCollection.bindSignalR();
this.listenTo(this.model, 'change:monitored', this._setMonitoredState); this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
this.listenTo(this.model, 'remove', this._seriesRemoved); this.listenTo(this.model, 'remove', this._seriesRemoved);
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete); this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
this.listenTo(this.model, 'change', function(model, options){
if(options && options.changeSource === 'signalr') { this.listenTo(this.model, 'change', function(model, options) {
if (options && options.changeSource === 'signalr') {
this._refresh(); this._refresh();
} }
}); });
}, },
onShow : function(){
onShow : function() {
$('body').addClass('backdrop'); $('body').addClass('backdrop');
var fanArt = this._getFanArt(); var fanArt = this._getFanArt();
if(fanArt) {
if (fanArt) {
this._backstrech = $.backstretch(fanArt); this._backstrech = $.backstretch(fanArt);
} } else {
else {
$('body').removeClass('backdrop'); $('body').removeClass('backdrop');
} }
this._showSeasons(); this._showSeasons();
this._setMonitoredState(); this._setMonitoredState();
this._showInfo(); this._showInfo();
}, },
onRender : function(){
onRender : function() {
CommandController.bindToCommand({ CommandController.bindToCommand({
element : this.ui.refresh, element : this.ui.refresh,
command : {name : 'refreshSeries'} command : {
name : 'refreshSeries'
}
}); });
CommandController.bindToCommand({ CommandController.bindToCommand({
element : this.ui.search, element : this.ui.search,
command : {name : 'seriesSearch'} command : {
name : 'seriesSearch'
}
}); });
CommandController.bindToCommand({ CommandController.bindToCommand({
element : this.ui.rename, element : this.ui.rename,
command : { command : {
@ -80,103 +94,129 @@ module.exports = Marionette.Layout.extend({
} }
}); });
}, },
onClose : function(){
if(this._backstrech) { onClose : function() {
if (this._backstrech) {
this._backstrech.destroy(); this._backstrech.destroy();
delete this._backstrech; delete this._backstrech;
} }
$('body').removeClass('backdrop'); $('body').removeClass('backdrop');
reqres.removeHandler(reqres.Requests.GetEpisodeFileById); reqres.removeHandler(reqres.Requests.GetEpisodeFileById);
}, },
_getFanArt : function(){
var fanArt = _.where(this.model.get('images'), {coverType : 'fanart'}); _getFanArt : function() {
if(fanArt && fanArt[0]) { var fanArt = _.where(this.model.get('images'), { coverType : 'fanart' });
if (fanArt && fanArt[0]) {
return fanArt[0].url; return fanArt[0].url;
} }
return undefined; return undefined;
}, },
_toggleMonitored : function(){
var savePromise = this.model.save('monitored', !this.model.get('monitored'), {wait : true}); _toggleMonitored : function() {
var savePromise = this.model.save('monitored', !this.model.get('monitored'), { wait : true });
this.ui.monitored.spinForPromise(savePromise); this.ui.monitored.spinForPromise(savePromise);
}, },
_setMonitoredState : function(){
_setMonitoredState : function() {
var monitored = this.model.get('monitored'); var monitored = this.model.get('monitored');
this.ui.monitored.removeAttr('data-idle-icon'); this.ui.monitored.removeAttr('data-idle-icon');
if(monitored) {
if (monitored) {
this.ui.monitored.addClass('icon-nd-monitored'); this.ui.monitored.addClass('icon-nd-monitored');
this.ui.monitored.removeClass('icon-nd-unmonitored'); this.ui.monitored.removeClass('icon-nd-unmonitored');
this.$el.removeClass('series-not-monitored'); this.$el.removeClass('series-not-monitored');
} } else {
else {
this.ui.monitored.addClass('icon-nd-unmonitored'); this.ui.monitored.addClass('icon-nd-unmonitored');
this.ui.monitored.removeClass('icon-nd-monitored'); this.ui.monitored.removeClass('icon-nd-monitored');
this.$el.addClass('series-not-monitored'); this.$el.addClass('series-not-monitored');
} }
}, },
_editSeries : function(){
vent.trigger(vent.Commands.EditSeriesCommand, {series : this.model}); _editSeries : function() {
vent.trigger(vent.Commands.EditSeriesCommand, { series : this.model });
}, },
_refreshSeries : function(){
_refreshSeries : function() {
CommandController.Execute('refreshSeries', { CommandController.Execute('refreshSeries', {
name : 'refreshSeries', name : 'refreshSeries',
seriesId : this.model.id seriesId : this.model.id
}); });
}, },
_seriesRemoved : function(){
Backbone.history.navigate('/', {trigger : true}); _seriesRemoved : function() {
Backbone.history.navigate('/', { trigger : true });
}, },
_renameSeries : function(){
vent.trigger(vent.Commands.ShowRenamePreview, {series : this.model}); _renameSeries : function() {
vent.trigger(vent.Commands.ShowRenamePreview, { series : this.model });
}, },
_seriesSearch : function(){
_seriesSearch : function() {
CommandController.Execute('seriesSearch', { CommandController.Execute('seriesSearch', {
name : 'seriesSearch', name : 'seriesSearch',
seriesId : this.model.id seriesId : this.model.id
}); });
}, },
_showSeasons : function(){
_showSeasons : function() {
var self = this; var self = this;
this.seasons.show(new LoadingView()); this.seasons.show(new LoadingView());
this.seasonCollection = new SeasonCollection(this.model.get('seasons')); this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
this.episodeCollection = new EpisodeCollection({seriesId : this.model.id}).bindSignalR(); this.episodeCollection = new EpisodeCollection({ seriesId : this.model.id }).bindSignalR();
this.episodeFileCollection = new EpisodeFileCollection({seriesId : this.model.id}).bindSignalR(); this.episodeFileCollection = new EpisodeFileCollection({ seriesId : this.model.id }).bindSignalR();
reqres.setHandler(reqres.Requests.GetEpisodeFileById, function(episodeFileId){
reqres.setHandler(reqres.Requests.GetEpisodeFileById, function(episodeFileId) {
return self.episodeFileCollection.get(episodeFileId); return self.episodeFileCollection.get(episodeFileId);
}); });
reqres.setHandler(reqres.Requests.GetAlternateNameBySeasonNumber, function(seriesId, seasonNumber){
if(self.model.get('id') !== seriesId) { reqres.setHandler(reqres.Requests.GetAlternateNameBySeasonNumber, function(seriesId, seasonNumber) {
if (self.model.get('id') !== seriesId) {
return []; return [];
} }
return _.where(self.model.get('alternateTitles'), {seasonNumber : seasonNumber});
return _.where(self.model.get('alternateTitles'), { seasonNumber : seasonNumber });
}); });
$.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch()).done(function(){
$.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch()).done(function() {
var seasonCollectionView = new SeasonCollectionView({ var seasonCollectionView = new SeasonCollectionView({
collection : self.seasonCollection, collection : self.seasonCollection,
episodeCollection : self.episodeCollection, episodeCollection : self.episodeCollection,
series : self.model series : self.model
}); });
if(!self.isClosed) {
if (!self.isClosed) {
self.seasons.show(seasonCollectionView); self.seasons.show(seasonCollectionView);
} }
}); });
}, },
_showInfo : function(){
_showInfo : function() {
this.info.show(new InfoView({ this.info.show(new InfoView({
model : this.model, model : this.model,
episodeFileCollection : this.episodeFileCollection episodeFileCollection : this.episodeFileCollection
})); }));
}, },
_commandComplete : function(options){
if(options.command.get('name') === 'renamefiles') { _commandComplete : function(options) {
if(options.command.get('seriesId') === this.model.get('id')) { if (options.command.get('name') === 'renamefiles') {
if (options.command.get('seriesId') === this.model.get('id')) {
this._refresh(); this._refresh();
} }
} }
}, },
_refresh : function(){
this.seasonCollection.add(this.model.get('seasons'), {merge : true}); _refresh : function() {
this.seasonCollection.add(this.model.get('seasons'), { merge : true });
this.episodeCollection.fetch(); this.episodeCollection.fetch();
this.episodeFileCollection.fetch(); this.episodeFileCollection.fetch();
this._setMonitoredState(); this._setMonitoredState();
this._showInfo(); this._showInfo();
} }

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var Profiles = require('../../Profile/ProfileCollection'); var Profiles = require('../../Profile/ProfileCollection');
var AsModelBoundView = require('../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../Mixins/AsModelBoundView');
@ -7,39 +7,48 @@ var AsEditModalView = require('../../Mixins/AsEditModalView');
require('../../Mixins/TagInput'); require('../../Mixins/TagInput');
require('../../Mixins/FileBrowser'); require('../../Mixins/FileBrowser');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Series/Edit/EditSeriesViewTemplate',
template : 'Series/Edit/EditSeriesViewTemplate',
ui : { ui : {
profile : '.x-profile', profile : '.x-profile',
path : '.x-path', path : '.x-path',
tags : '.x-tags' tags : '.x-tags'
}, },
events : {"click .x-remove" : '_removeSeries'},
initialize : function(){ events : {
this.model.set('profiles', Profiles); 'click .x-remove' : '_removeSeries'
}, },
onRender : function(){
this.ui.path.fileBrowser(); initialize : function() {
this.ui.tags.tagInput({ this.model.set('profiles', Profiles);
model : this.model, },
property : 'tags'
}); onRender : function() {
}, this.ui.path.fileBrowser();
_onBeforeSave : function(){ this.ui.tags.tagInput({
var profileId = this.ui.profile.val(); model : this.model,
this.model.set({profileId : profileId}); property : 'tags'
}, });
_onAfterSave : function(){ },
this.trigger('saved');
vent.trigger(vent.Commands.CloseModalCommand); _onBeforeSave : function() {
}, var profileId = this.ui.profile.val();
_removeSeries : function(){ this.model.set({ profileId : profileId });
vent.trigger(vent.Commands.DeleteSeriesCommand, {series : this.model}); },
}
}); _onAfterSave : function() {
AsModelBoundView.call(view); this.trigger('saved');
AsValidatedView.call(view); vent.trigger(vent.Commands.CloseModalCommand);
AsEditModalView.call(view); },
return view;
}).call(this); _removeSeries : function() {
vent.trigger(vent.Commands.DeleteSeriesCommand, { series : this.model });
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
module.exports = view;

@ -5,21 +5,28 @@ var Marionette = require('marionette');
var CommandController = require('../../../Commands/CommandController'); var CommandController = require('../../../Commands/CommandController');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Series/Editor/Organize/OrganizeFilesViewTemplate', template : 'Series/Editor/Organize/OrganizeFilesViewTemplate',
events : {"click .x-confirm-organize" : '_organize'},
initialize : function(options){ events : {
'click .x-confirm-organize' : '_organize'
},
initialize : function(options) {
this.series = options.series; this.series = options.series;
this.templateHelpers = { this.templateHelpers = {
numberOfSeries : this.series.length, numberOfSeries : this.series.length,
series : new Backbone.Collection(this.series).toJSON() series : new Backbone.Collection(this.series).toJSON()
}; };
}, },
_organize : function(){
_organize : function() {
var seriesIds = _.pluck(this.series, 'id'); var seriesIds = _.pluck(this.series, 'id');
CommandController.Execute('renameSeries', { CommandController.Execute('renameSeries', {
name : 'renameSeries', name : 'renameSeries',
seriesIds : seriesIds seriesIds : seriesIds
}); });
this.trigger('organizingFiles'); this.trigger('organizingFiles');
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }

@ -10,8 +10,9 @@ var UpdateFilesSeriesView = require('./Organize/OrganizeFilesView');
var Config = require('../../Config'); var Config = require('../../Config');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Series/Editor/SeriesEditorFooterViewTemplate', template : 'Series/Editor/SeriesEditorFooterViewTemplate',
ui : {
ui : {
monitored : '.x-monitored', monitored : '.x-monitored',
profile : '.x-profiles', profile : '.x-profiles',
seasonFolder : '.x-season-folder', seasonFolder : '.x-season-folder',
@ -21,72 +22,87 @@ module.exports = Marionette.ItemView.extend({
organizeFilesButton : '.x-organize-files', organizeFilesButton : '.x-organize-files',
container : '.series-editor-footer' container : '.series-editor-footer'
}, },
events : {
"click .x-save" : '_updateAndSave', events : {
"change .x-root-folder" : '_rootFolderChanged', 'click .x-save' : '_updateAndSave',
"click .x-organize-files" : '_organizeFiles' 'change .x-root-folder' : '_rootFolderChanged',
'click .x-organize-files' : '_organizeFiles'
}, },
templateHelpers : function(){
templateHelpers : function() {
return { return {
profiles : Profiles, profiles : Profiles,
rootFolders : RootFolders.toJSON() rootFolders : RootFolders.toJSON()
}; };
}, },
initialize : function(options){
initialize : function(options) {
this.seriesCollection = options.collection; this.seriesCollection = options.collection;
RootFolders.fetch().done(function(){
RootFolders.fetch().done(function() {
RootFolders.synced = true; RootFolders.synced = true;
}); });
this.editorGrid = options.editorGrid; this.editorGrid = options.editorGrid;
this.listenTo(this.seriesCollection, 'backgrid:selected', this._updateInfo); this.listenTo(this.seriesCollection, 'backgrid:selected', this._updateInfo);
this.listenTo(RootFolders, 'all', this.render); this.listenTo(RootFolders, 'all', this.render);
}, },
onRender : function(){
onRender : function() {
this._updateInfo(); this._updateInfo();
}, },
_updateAndSave : function(){
_updateAndSave : function() {
var selected = this.editorGrid.getSelectedModels(); var selected = this.editorGrid.getSelectedModels();
var monitored = this.ui.monitored.val(); var monitored = this.ui.monitored.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();
_.each(selected, function(model){
if(monitored === 'true') { _.each(selected, function(model) {
if (monitored === 'true') {
model.set('monitored', true); model.set('monitored', true);
} } else if (monitored === 'false') {
else if(monitored === 'false') {
model.set('monitored', false); model.set('monitored', false);
} }
if(profile !== 'noChange') {
if (profile !== 'noChange') {
model.set('profileId', parseInt(profile, 10)); model.set('profileId', parseInt(profile, 10));
} }
if(seasonFolder === 'true') {
if (seasonFolder === 'true') {
model.set('seasonFolder', true); model.set('seasonFolder', true);
} } else if (seasonFolder === 'false') {
else if(seasonFolder === 'false') {
model.set('seasonFolder', false); model.set('seasonFolder', false);
} }
if(rootFolder !== 'noChange') {
if (rootFolder !== 'noChange') {
var rootFolderPath = RootFolders.get(parseInt(rootFolder, 10)); var rootFolderPath = RootFolders.get(parseInt(rootFolder, 10));
model.set('rootFolderPath', rootFolderPath.get('path')); model.set('rootFolderPath', rootFolderPath.get('path'));
} }
model.edited = true; model.edited = true;
}); });
this.seriesCollection.save(); this.seriesCollection.save();
}, },
_updateInfo : function(){
_updateInfo : function() {
var selected = this.editorGrid.getSelectedModels(); var selected = this.editorGrid.getSelectedModels();
var selectedCount = selected.length; var selectedCount = selected.length;
this.ui.selectedCount.html('{0} series selected'.format(selectedCount)); this.ui.selectedCount.html('{0} series selected'.format(selectedCount));
if(selectedCount === 0) {
if (selectedCount === 0) {
this.ui.monitored.attr('disabled', ''); this.ui.monitored.attr('disabled', '');
this.ui.profile.attr('disabled', ''); this.ui.profile.attr('disabled', '');
this.ui.seasonFolder.attr('disabled', ''); this.ui.seasonFolder.attr('disabled', '');
this.ui.rootFolder.attr('disabled', ''); this.ui.rootFolder.attr('disabled', '');
this.ui.saveButton.attr('disabled', ''); this.ui.saveButton.attr('disabled', '');
this.ui.organizeFilesButton.attr('disabled', ''); this.ui.organizeFilesButton.attr('disabled', '');
} } else {
else {
this.ui.monitored.removeAttr('disabled', ''); this.ui.monitored.removeAttr('disabled', '');
this.ui.profile.removeAttr('disabled', ''); this.ui.profile.removeAttr('disabled', '');
this.ui.seasonFolder.removeAttr('disabled', ''); this.ui.seasonFolder.removeAttr('disabled', '');
@ -95,26 +111,29 @@ module.exports = Marionette.ItemView.extend({
this.ui.organizeFilesButton.removeAttr('disabled', ''); this.ui.organizeFilesButton.removeAttr('disabled', '');
} }
}, },
_rootFolderChanged : function(){
_rootFolderChanged : function() {
var rootFolderValue = this.ui.rootFolder.val(); var rootFolderValue = this.ui.rootFolder.val();
if(rootFolderValue === 'addNew') { if (rootFolderValue === 'addNew') {
var rootFolderLayout = new RootFolderLayout(); var rootFolderLayout = new RootFolderLayout();
this.listenToOnce(rootFolderLayout, 'folderSelected', this._setRootFolder); this.listenToOnce(rootFolderLayout, 'folderSelected', this._setRootFolder);
vent.trigger(vent.Commands.OpenModalCommand, rootFolderLayout); vent.trigger(vent.Commands.OpenModalCommand, rootFolderLayout);
} } else {
else {
Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue); Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
} }
}, },
_setRootFolder : function(options){
_setRootFolder : function(options) {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
this.ui.rootFolder.val(options.model.id); this.ui.rootFolder.val(options.model.id);
this._rootFolderChanged(); this._rootFolderChanged();
}, },
_organizeFiles : function(){
_organizeFiles : function() {
var selected = this.editorGrid.getSelectedModels(); var selected = this.editorGrid.getSelectedModels();
var updateFilesSeriesView = new UpdateFilesSeriesView({series : selected}); var updateFilesSeriesView = new UpdateFilesSeriesView({ series : selected });
this.listenToOnce(updateFilesSeriesView, 'updatingFiles', this._afterSave); this.listenToOnce(updateFilesSeriesView, 'updatingFiles', this._afterSave);
vent.trigger(vent.Commands.OpenModalCommand, updateFilesSeriesView); vent.trigger(vent.Commands.OpenModalCommand, updateFilesSeriesView);
} }
}); });

@ -13,135 +13,170 @@ var FooterView = require('./SeriesEditorFooterView');
require('../../Mixins/backbone.signalr.mixin'); require('../../Mixins/backbone.signalr.mixin');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Series/Editor/SeriesEditorLayoutTemplate', template : 'Series/Editor/SeriesEditorLayoutTemplate',
regions : {
regions : {
seriesRegion : '#x-series-editor', seriesRegion : '#x-series-editor',
toolbar : '#x-toolbar' toolbar : '#x-toolbar'
}, },
ui : {
ui : {
monitored : '.x-monitored', monitored : '.x-monitored',
profiles : '.x-profiles', profiles : '.x-profiles',
rootFolder : '.x-root-folder', rootFolder : '.x-root-folder',
selectedCount : '.x-selected-count' selectedCount : '.x-selected-count'
}, },
events : {
"click .x-save" : '_updateAndSave', events : {
"change .x-root-folder" : '_rootFolderChanged' 'click .x-save' : '_updateAndSave',
'change .x-root-folder' : '_rootFolderChanged'
}, },
columns : [{
name : '', columns : [
cell : SelectAllCell, {
headerCell : 'select-all', name : '',
sortable : false cell : SelectAllCell,
}, { headerCell : 'select-all',
name : 'statusWeight', sortable : false
label : '', },
cell : SeriesStatusCell {
}, { name : 'statusWeight',
name : 'title', label : '',
label : 'Title', cell : SeriesStatusCell
cell : SeriesTitleCell, },
cellValue : 'this' {
}, { name : 'title',
name : 'profileId', label : 'Title',
label : 'Profile', cell : SeriesTitleCell,
cell : ProfileCell cellValue : 'this'
}, { },
name : 'seasonFolder', {
label : 'Season Folder', name : 'profileId',
cell : SeasonFolderCell label : 'Profile',
}, { cell : ProfileCell
name : 'path', },
label : 'Path', {
cell : 'string' name : 'seasonFolder',
}], label : 'Season Folder',
cell : SeasonFolderCell
},
{
name : 'path',
label : 'Path',
cell : 'string'
}
],
leftSideButtons : { leftSideButtons : {
type : 'default', type : 'default',
storeState : false, storeState : false,
items : [{ items : [
title : 'Season Pass', {
icon : 'icon-bookmark', title : 'Season Pass',
route : 'seasonpass' icon : 'icon-bookmark',
}, { route : 'seasonpass'
title : 'Update Library', },
icon : 'icon-refresh', {
command : 'refreshseries', title : 'Update Library',
successMessage : 'Library was updated!', icon : 'icon-refresh',
errorMessage : 'Library update failed!' command : 'refreshseries',
}] successMessage : 'Library was updated!',
errorMessage : 'Library update failed!'
}
]
}, },
initialize : function(){
initialize : function() {
this.seriesCollection = SeriesCollection.clone(); this.seriesCollection = SeriesCollection.clone();
this.seriesCollection.shadowCollection.bindSignalR(); this.seriesCollection.shadowCollection.bindSignalR();
this.listenTo(this.seriesCollection, 'save', this.render); this.listenTo(this.seriesCollection, 'save', this.render);
this.filteringOptions = { this.filteringOptions = {
type : 'radio', type : 'radio',
storeState : true, storeState : true,
menuKey : 'serieseditor.filterMode', menuKey : 'serieseditor.filterMode',
defaultAction : 'all', defaultAction : 'all',
items : [{ items : [
key : 'all', {
title : '', key : 'all',
tooltip : 'All', title : '',
icon : 'icon-circle-blank', tooltip : 'All',
callback : this._setFilter icon : 'icon-circle-blank',
}, { callback : this._setFilter
key : 'monitored', },
title : '', {
tooltip : 'Monitored Only', key : 'monitored',
icon : 'icon-nd-monitored', title : '',
callback : this._setFilter tooltip : 'Monitored Only',
}, { icon : 'icon-nd-monitored',
key : 'continuing', callback : this._setFilter
title : '', },
tooltip : 'Continuing Only', {
icon : 'icon-play', key : 'continuing',
callback : this._setFilter title : '',
}, { tooltip : 'Continuing Only',
key : 'ended', icon : 'icon-play',
title : '', callback : this._setFilter
tooltip : 'Ended Only', },
icon : 'icon-stop', {
callback : this._setFilter key : 'ended',
}] title : '',
tooltip : 'Ended Only',
icon : 'icon-stop',
callback : this._setFilter
}
]
}; };
}, },
onRender : function(){
onRender : function() {
this._showToolbar(); this._showToolbar();
this._showTable(); this._showTable();
}, },
onClose : function(){
onClose : function() {
vent.trigger(vent.Commands.CloseControlPanelCommand); vent.trigger(vent.Commands.CloseControlPanelCommand);
}, },
_showTable : function(){
if(this.seriesCollection.shadowCollection.length === 0) { _showTable : function() {
if (this.seriesCollection.shadowCollection.length === 0) {
this.seriesRegion.show(new EmptyView()); this.seriesRegion.show(new EmptyView());
this.toolbar.close(); this.toolbar.close();
return; return;
} }
this.editorGrid = new Backgrid.Grid({ this.editorGrid = new Backgrid.Grid({
collection : this.seriesCollection, collection : this.seriesCollection,
columns : this.columns, columns : this.columns,
className : 'table table-hover' className : 'table table-hover'
}); });
this.seriesRegion.show(this.editorGrid); this.seriesRegion.show(this.editorGrid);
this._showFooter(); this._showFooter();
}, },
_showToolbar : function(){
_showToolbar : function() {
this.toolbar.show(new ToolbarLayout({ this.toolbar.show(new ToolbarLayout({
left : [this.leftSideButtons], left : [
right : [this.filteringOptions], this.leftSideButtons
],
right : [
this.filteringOptions
],
context : this context : this
})); }));
}, },
_showFooter : function(){
_showFooter : function() {
vent.trigger(vent.Commands.OpenControlPanelCommand, new FooterView({ vent.trigger(vent.Commands.OpenControlPanelCommand, new FooterView({
editorGrid : this.editorGrid, editorGrid : this.editorGrid,
collection : this.seriesCollection collection : this.seriesCollection
})); }));
}, },
_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);
} }
}); });

@ -3,42 +3,56 @@ var EpisodeModel = require('./EpisodeModel');
require('./EpisodeCollection'); require('./EpisodeCollection');
module.exports = Backbone.Collection.extend({ module.exports = Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/episode', url : window.NzbDrone.ApiRoot + '/episode',
model : EpisodeModel, model : EpisodeModel,
state : {
state : {
sortKey : 'episodeNumber', sortKey : 'episodeNumber',
order : 1 order : 1
}, },
originalFetch : Backbone.Collection.prototype.fetch, originalFetch : Backbone.Collection.prototype.fetch,
initialize : function(options){
initialize : function(options) {
this.seriesId = options.seriesId; this.seriesId = options.seriesId;
}, },
bySeason : function(season){
var filtered = this.filter(function(episode){ bySeason : function(season) {
var filtered = this.filter(function(episode) {
return episode.get('seasonNumber') === season; return episode.get('seasonNumber') === season;
}); });
var EpisodeCollection = require('./EpisodeCollection'); var EpisodeCollection = require('./EpisodeCollection');
return new EpisodeCollection(filtered); return new EpisodeCollection(filtered);
}, },
comparator : function(model1, model2){
comparator : function(model1, model2) {
var episode1 = model1.get('episodeNumber'); var episode1 = model1.get('episodeNumber');
var episode2 = model2.get('episodeNumber'); var episode2 = model2.get('episodeNumber');
if(episode1 < episode2) {
if (episode1 < episode2) {
return 1; return 1;
} }
if(episode1 > episode2) {
if (episode1 > episode2) {
return -1; return -1;
} }
return 0; return 0;
}, },
fetch : function(options){
if(!this.seriesId) { fetch : function(options) {
if (!this.seriesId) {
throw 'seriesId is required'; throw 'seriesId is required';
} }
if(!options) {
if (!options) {
options = {}; options = {};
} }
options.data = {seriesId : this.seriesId};
options.data = { seriesId : this.seriesId };
return this.originalFetch.call(this, options); return this.originalFetch.call(this, options);
} }
}); });

@ -2,21 +2,27 @@ var Backbone = require('backbone');
var EpisodeFileModel = require('./EpisodeFileModel'); var EpisodeFileModel = require('./EpisodeFileModel');
module.exports = Backbone.Collection.extend({ module.exports = Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/episodefile', url : window.NzbDrone.ApiRoot + '/episodefile',
model : EpisodeFileModel, model : EpisodeFileModel,
originalFetch : Backbone.Collection.prototype.fetch, originalFetch : Backbone.Collection.prototype.fetch,
initialize : function(options){
initialize : function(options) {
this.seriesId = options.seriesId; this.seriesId = options.seriesId;
this.models = []; this.models = [];
}, },
fetch : function(options){
if(!this.seriesId) { fetch : function(options) {
if (!this.seriesId) {
throw 'seriesId is required'; throw 'seriesId is required';
} }
if(!options) {
if (!options) {
options = {}; options = {};
} }
options.data = {seriesId : this.seriesId};
options.data = { seriesId : this.seriesId };
return this.originalFetch.call(this, options); return this.originalFetch.call(this, options);
} }
}); });

@ -1,13 +1,17 @@
var Backbone = require('backbone'); var Backbone = require('backbone');
module.exports = Backbone.Model.extend({ module.exports = Backbone.Model.extend({
defaults : { defaults : {
seasonNumber : 0, seasonNumber : 0,
status : 0 status : 0
}, },
methodUrls : {"update" : window.NzbDrone.ApiRoot + '/episode'},
sync : function(method, model, options){ methodUrls : {
if(model.methodUrls && model.methodUrls[method.toLowerCase()]) { 'update' : window.NzbDrone.ApiRoot + '/episode'
},
sync : function(method, model, options) {
if (model.methodUrls && model.methodUrls[method.toLowerCase()]) {
options = options || {}; options = options || {};
options.url = model.methodUrls[method.toLowerCase()]; options.url = model.methodUrls[method.toLowerCase()];
} }

@ -1,3 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.CompositeView.extend({template : 'Series/Index/EmptyTemplate'}); module.exports = Marionette.CompositeView.extend({
template : 'Series/Index/EmptyTemplate'
});

@ -1,3 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.CompositeView.extend({template : 'Series/Index/FooterViewTemplate'}); module.exports = Marionette.CompositeView.extend({
template : 'Series/Index/FooterViewTemplate'
});

@ -1,5 +1,7 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var SeriesIndexItemView = require('../SeriesIndexItemView'); var SeriesIndexItemView = require('../SeriesIndexItemView');
module.exports = SeriesIndexItemView.extend({template : 'Series/Index/Overview/SeriesOverviewItemViewTemplate'}); module.exports = SeriesIndexItemView.extend({
template : 'Series/Index/Overview/SeriesOverviewItemViewTemplate'
});

@ -1,15 +1,18 @@
var SeriesIndexItemView = require('../SeriesIndexItemView'); var SeriesIndexItemView = require('../SeriesIndexItemView');
module.exports = SeriesIndexItemView.extend({ module.exports = SeriesIndexItemView.extend({
tagName : 'li', tagName : 'li',
template : 'Series/Index/Posters/SeriesPostersItemViewTemplate', template : 'Series/Index/Posters/SeriesPostersItemViewTemplate',
initialize : function(){
initialize : function() {
this.events['mouseenter .x-series-poster'] = 'posterHoverAction'; this.events['mouseenter .x-series-poster'] = 'posterHoverAction';
this.events['mouseleave .x-series-poster'] = 'posterHoverAction'; this.events['mouseleave .x-series-poster'] = 'posterHoverAction';
this.ui.controls = '.x-series-controls'; this.ui.controls = '.x-series-controls';
this.ui.title = '.x-title'; this.ui.title = '.x-title';
}, },
posterHoverAction : function(){
posterHoverAction : function() {
this.ui.controls.slideToggle(); this.ui.controls.slideToggle();
this.ui.title.slideToggle(); this.ui.title.slideToggle();
} }

@ -1,14 +1,18 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var CommandController = require('../../Commands/CommandController'); var CommandController = require('../../Commands/CommandController');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
ui : {refresh : '.x-refresh'}, ui : {
events : { refresh : '.x-refresh'
},
events : {
'click .x-edit' : '_editSeries', 'click .x-edit' : '_editSeries',
'click .x-refresh' : '_refreshSeries' 'click .x-refresh' : '_refreshSeries'
}, },
onRender : function(){
onRender : function() {
CommandController.bindToCommand({ CommandController.bindToCommand({
element : this.ui.refresh, element : this.ui.refresh,
command : { command : {
@ -17,10 +21,12 @@ module.exports = Marionette.ItemView.extend({
} }
}); });
}, },
_editSeries : function(){
vent.trigger(vent.Commands.EditSeriesCommand, {series : this.model}); _editSeries : function() {
vent.trigger(vent.Commands.EditSeriesCommand, { series : this.model });
}, },
_refreshSeries : function(){
_refreshSeries : function() {
CommandController.Execute('refreshSeries', { CommandController.Execute('refreshSeries', {
name : 'refreshSeries', name : 'refreshSeries',
seriesId : this.model.id seriesId : this.model.id

@ -18,229 +18,297 @@ var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
require('../../Mixins/backbone.signalr.mixin'); require('../../Mixins/backbone.signalr.mixin');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Series/Index/SeriesIndexLayoutTemplate', template : 'Series/Index/SeriesIndexLayoutTemplate',
regions : {
regions : {
seriesRegion : '#x-series', seriesRegion : '#x-series',
toolbar : '#x-toolbar', toolbar : '#x-toolbar',
toolbar2 : '#x-toolbar2', toolbar2 : '#x-toolbar2',
footer : '#x-series-footer' footer : '#x-series-footer'
}, },
columns : [{
name : 'statusWeight', columns : [
label : '', {
cell : SeriesStatusCell name : 'statusWeight',
}, { label : '',
name : 'title', cell : SeriesStatusCell
label : 'Title', },
cell : SeriesTitleCell, {
cellValue : 'this', name : 'title',
sortValue : 'sortTitle' label : 'Title',
}, { cell : SeriesTitleCell,
name : 'seasonCount', cellValue : 'this',
label : 'Seasons', sortValue : 'sortTitle'
cell : 'integer' },
}, { {
name : 'profileId', name : 'seasonCount',
label : 'Profile', label : 'Seasons',
cell : ProfileCell cell : 'integer'
}, { },
name : 'network', {
label : 'Network', name : 'profileId',
cell : 'string' label : 'Profile',
}, { cell : ProfileCell
name : 'nextAiring', },
label : 'Next Airing', {
cell : RelativeDateCell name : 'network',
}, { label : 'Network',
name : 'percentOfEpisodes', cell : 'string'
label : 'Episodes', },
cell : EpisodeProgressCell, {
className : 'episode-progress-cell' name : 'nextAiring',
}, { label : 'Next Airing',
name : 'this', cell : RelativeDateCell
label : '', },
sortable : false, {
cell : SeriesActionsCell name : 'percentOfEpisodes',
}], label : 'Episodes',
leftSideButtons : { cell : EpisodeProgressCell,
className : 'episode-progress-cell'
},
{
name : 'this',
label : '',
sortable : false,
cell : SeriesActionsCell
}
],
leftSideButtons : {
type : 'default', type : 'default',
storeState : false, storeState : false,
collapse : true, collapse : true,
items : [{ items : [
title : 'Add Series', {
icon : 'icon-plus', title : 'Add Series',
route : 'addseries' icon : 'icon-plus',
}, { route : 'addseries'
title : 'Season Pass', },
icon : 'icon-bookmark', {
route : 'seasonpass' title : 'Season Pass',
}, { icon : 'icon-bookmark',
title : 'Series Editor', route : 'seasonpass'
icon : 'icon-nd-edit', },
route : 'serieseditor' {
}, { title : 'Series Editor',
title : 'RSS Sync', icon : 'icon-nd-edit',
icon : 'icon-rss', route : 'serieseditor'
command : 'rsssync', },
errorMessage : 'RSS Sync Failed!' {
}, { title : 'RSS Sync',
title : 'Update Library', icon : 'icon-rss',
icon : 'icon-refresh', command : 'rsssync',
command : 'refreshseries', errorMessage : 'RSS Sync Failed!'
successMessage : 'Library was updated!', },
errorMessage : 'Library update failed!' {
}] title : 'Update Library',
icon : 'icon-refresh',
command : 'refreshseries',
successMessage : 'Library was updated!',
errorMessage : 'Library update failed!'
}
]
}, },
initialize : function(){
initialize : function() {
this.seriesCollection = SeriesCollection.clone(); this.seriesCollection = SeriesCollection.clone();
this.seriesCollection.shadowCollection.bindSignalR(); this.seriesCollection.shadowCollection.bindSignalR();
this.listenTo(this.seriesCollection.shadowCollection, 'sync', function(model, collection, options){
this.listenTo(this.seriesCollection.shadowCollection, 'sync', function(model, collection, options) {
this.seriesCollection.fullCollection.resetFiltered(); this.seriesCollection.fullCollection.resetFiltered();
this._renderView(); this._renderView();
}); });
this.listenTo(this.seriesCollection.shadowCollection, 'add', function(model, collection, options){
this.listenTo(this.seriesCollection.shadowCollection, 'add', function(model, collection, options) {
this.seriesCollection.fullCollection.resetFiltered(); this.seriesCollection.fullCollection.resetFiltered();
this._renderView(); this._renderView();
}); });
this.listenTo(this.seriesCollection.shadowCollection, 'remove', function(model, collection, options){
this.listenTo(this.seriesCollection.shadowCollection, 'remove', function(model, collection, options) {
this.seriesCollection.fullCollection.resetFiltered(); this.seriesCollection.fullCollection.resetFiltered();
this._renderView(); this._renderView();
}); });
this.sortingOptions = { this.sortingOptions = {
type : 'sorting', type : 'sorting',
storeState : false, storeState : false,
viewCollection : this.seriesCollection, viewCollection : this.seriesCollection,
items : [{ items : [
title : 'Title', {
name : 'title' title : 'Title',
}, { name : 'title'
title : 'Seasons', },
name : 'seasonCount' {
}, { title : 'Seasons',
title : 'Quality', name : 'seasonCount'
name : 'profileId' },
}, { {
title : 'Network', title : 'Quality',
name : 'network' name : 'profileId'
}, { },
title : 'Next Airing', {
name : 'nextAiring' title : 'Network',
}, { name : 'network'
title : 'Episodes', },
name : 'percentOfEpisodes' {
}] title : 'Next Airing',
name : 'nextAiring'
},
{
title : 'Episodes',
name : 'percentOfEpisodes'
}
]
}; };
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', {
title : '', key : 'all',
tooltip : 'All', title : '',
icon : 'icon-circle-blank', tooltip : 'All',
callback : this._setFilter icon : 'icon-circle-blank',
}, { callback : this._setFilter
key : 'monitored', },
title : '', {
tooltip : 'Monitored Only', key : 'monitored',
icon : 'icon-nd-monitored', title : '',
callback : this._setFilter tooltip : 'Monitored Only',
}, { icon : 'icon-nd-monitored',
key : 'continuing', callback : this._setFilter
title : '', },
tooltip : 'Continuing Only', {
icon : 'icon-play', key : 'continuing',
callback : this._setFilter title : '',
}, { tooltip : 'Continuing Only',
key : 'ended', icon : 'icon-play',
title : '', callback : this._setFilter
tooltip : 'Ended Only', },
icon : 'icon-stop', {
callback : this._setFilter key : 'ended',
}] title : '',
tooltip : 'Ended Only',
icon : 'icon-stop',
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', {
title : '', key : 'posterView',
tooltip : 'Posters', title : '',
icon : 'icon-th-large', tooltip : 'Posters',
callback : this._showPosters icon : 'icon-th-large',
}, { callback : this._showPosters
key : 'listView', },
title : '', {
tooltip : 'Overview List', key : 'listView',
icon : 'icon-th-list', title : '',
callback : this._showList tooltip : 'Overview List',
}, { icon : 'icon-th-list',
key : 'tableView', callback : this._showList
title : '', },
tooltip : 'Table', {
icon : 'icon-table', key : 'tableView',
callback : this._showTable title : '',
}] tooltip : 'Table',
icon : 'icon-table',
callback : this._showTable
}
]
}; };
}, },
onShow : function(){
onShow : function() {
this._showToolbar(); this._showToolbar();
this._fetchCollection(); this._fetchCollection();
}, },
_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._renderView(); this._renderView();
}, },
_showList : function(){
this.currentView = new ListCollectionView({collection : this.seriesCollection}); _showList : function() {
this.currentView = new ListCollectionView({
collection : this.seriesCollection
});
this._renderView(); this._renderView();
}, },
_showPosters : function(){
this.currentView = new PosterCollectionView({collection : this.seriesCollection}); _showPosters : function() {
this.currentView = new PosterCollectionView({
collection : this.seriesCollection
});
this._renderView(); this._renderView();
}, },
_renderView : function(){
if(SeriesCollection.length === 0) { _renderView : function() {
if (SeriesCollection.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.seriesRegion.show(this.currentView); this.seriesRegion.show(this.currentView);
this._showToolbar(); this._showToolbar();
this._showFooter(); this._showFooter();
} }
}, },
_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(){
if(this.toolbar.currentView) { _showToolbar : function() {
if (this.toolbar.currentView) {
return; return;
} }
this.toolbar2.show(new ToolbarLayout({ this.toolbar2.show(new ToolbarLayout({
right : [this.filteringOptions], right : [
this.filteringOptions
],
context : this context : this
})); }));
this.toolbar.show(new ToolbarLayout({ this.toolbar.show(new ToolbarLayout({
right : [this.sortingOptions, this.viewButtons], right : [
left : [this.leftSideButtons], this.sortingOptions,
this.viewButtons
],
left : [
this.leftSideButtons
],
context : this context : this
})); }));
}, },
_showFooter : function(){
_showFooter : function() {
var footerModel = new FooterModel(); var footerModel = new FooterModel();
var series = SeriesCollection.models.length; var series = SeriesCollection.models.length;
var episodes = 0; var episodes = 0;
@ -248,19 +316,22 @@ module.exports = Marionette.Layout.extend({
var ended = 0; var ended = 0;
var continuing = 0; var continuing = 0;
var monitored = 0; var monitored = 0;
_.each(SeriesCollection.models, function(model){
_.each(SeriesCollection.models, function(model) {
episodes += model.get('episodeCount'); episodes += model.get('episodeCount');
episodeFiles += model.get('episodeFileCount'); episodeFiles += model.get('episodeFileCount');
if(model.get('status').toLowerCase() === 'ended') {
if (model.get('status').toLowerCase() === 'ended') {
ended++; ended++;
} } else {
else {
continuing++; continuing++;
} }
if(model.get('monitored')) {
if (model.get('monitored')) {
monitored++; monitored++;
} }
}); });
footerModel.set({ footerModel.set({
series : series, series : series,
ended : ended, ended : ended,
@ -270,6 +341,7 @@ module.exports = Marionette.Layout.extend({
episodes : episodes, episodes : episodes,
episodeFiles : episodeFiles episodeFiles : episodeFiles
}); });
this.footer.show(new FooterView({model : footerModel}));
this.footer.show(new FooterView({ model : footerModel }));
} }
}); });

@ -2,8 +2,9 @@ var Backbone = require('backbone');
var SeasonModel = require('./SeasonModel'); var SeasonModel = require('./SeasonModel');
module.exports = Backbone.Collection.extend({ module.exports = Backbone.Collection.extend({
model : SeasonModel, model : SeasonModel,
comparator : function(season){
comparator : function(season) {
return -season.get('seasonNumber'); return -season.get('seasonNumber');
} }
}); });

@ -1,8 +1,11 @@
var Backbone = require('backbone'); var Backbone = require('backbone');
module.exports = Backbone.Model.extend({ module.exports = Backbone.Model.extend({
defaults : {seasonNumber : 0}, defaults : {
initialize : function(){ seasonNumber : 0
},
initialize : function() {
this.set('id', this.get('seasonNumber')); this.set('id', this.get('seasonNumber'));
} }
}); });

@ -8,68 +8,98 @@ var AsSortedCollection = require('../Mixins/AsSortedCollection');
var AsPersistedStateCollection = require('../Mixins/AsPersistedStateCollection'); var AsPersistedStateCollection = require('../Mixins/AsPersistedStateCollection');
var moment = require('moment'); var moment = require('moment');
module.exports = (function(){ var Collection = PageableCollection.extend({
var Collection = PageableCollection.extend({ url : window.NzbDrone.ApiRoot + '/series',
url : window.NzbDrone.ApiRoot + '/series', model : SeriesModel,
model : SeriesModel, tableName : 'series',
tableName : 'series',
state : { state : {
sortKey : 'sortTitle', sortKey : 'sortTitle',
order : -1, order : -1,
pageSize : 100000, pageSize : 100000,
secondarySortKey : 'sortTitle', secondarySortKey : 'sortTitle',
secondarySortOrder : -1 secondarySortOrder : -1
}, },
mode : 'client',
save : function(){ mode : 'client',
var self = this;
var proxy = _.extend(new Backbone.Model(), { save : function() {
id : '', var self = this;
url : self.url + '/editor',
toJSON : function(){ var proxy = _.extend(new Backbone.Model(), {
return self.filter(function(model){ id : '',
return model.edited;
}); url : self.url + '/editor',
}
}); toJSON : function() {
this.listenTo(proxy, 'sync', function(proxyModel, models){ return self.filter(function(model) {
this.add(models, {merge : true}); return model.edited;
this.trigger('save', this); });
}); }
return proxy.save(); });
},
filterModes : { this.listenTo(proxy, 'sync', function(proxyModel, models) {
"all" : [null, null], this.add(models, { merge : true });
"continuing" : ['status', 'continuing'], this.trigger('save', this);
"ended" : ['status', 'ended'], });
"monitored" : ['monitored', true]
return proxy.save();
},
filterModes : {
'all' : [
null,
null
],
'continuing' : [
'status',
'continuing'
],
'ended' : [
'status',
'ended'
],
'monitored' : [
'monitored',
true
]
},
sortMappings : {
'title' : {
sortKey : 'sortTitle'
}, },
sortMappings : { 'nextAiring' : {
"title" : {sortKey : 'sortTitle'}, sortValue : function(model, attr, order) {
"nextAiring" : { var nextAiring = model.get(attr);
sortValue : function(model, attr, order){
var nextAiring = model.get(attr); if (nextAiring) {
if(nextAiring) { return moment(nextAiring).unix();
return moment(nextAiring).unix();
}
if(order === 1) {
return 0;
}
return Number.MAX_VALUE;
} }
},
percentOfEpisodes : { if (order === 1) {
sortValue : function(model, attr){ return 0;
var percentOfEpisodes = model.get(attr);
var episodeCount = model.get('episodeCount');
return percentOfEpisodes + episodeCount / 1000000;
} }
return Number.MAX_VALUE;
}
},
percentOfEpisodes : {
sortValue : function(model, attr) {
var percentOfEpisodes = model.get(attr);
var episodeCount = model.get('episodeCount');
return percentOfEpisodes + episodeCount / 1000000;
} }
} }
}); }
Collection = AsFilteredCollection.call(Collection); });
Collection = AsSortedCollection.call(Collection);
Collection = AsPersistedStateCollection.call(Collection); Collection = AsFilteredCollection.call(Collection);
var data = ApiData.get('series'); Collection = AsSortedCollection.call(Collection);
return new Collection(data, {full : true}); Collection = AsPersistedStateCollection.call(Collection);
}).call(this);
var data = ApiData.get('series');
module.exports = new Collection(data, { full : true });

@ -6,24 +6,28 @@ var SeriesDetailsLayout = require('./Details/SeriesDetailsLayout');
module.exports = NzbDroneController.extend({ module.exports = NzbDroneController.extend({
_originalInit : NzbDroneController.prototype.initialize, _originalInit : NzbDroneController.prototype.initialize,
initialize : function(){
initialize : function() {
this.route('', this.series); this.route('', this.series);
this.route('series', this.series); this.route('series', this.series);
this.route('series/:query', this.seriesDetails); this.route('series/:query', this.seriesDetails);
this._originalInit.apply(this, arguments); this._originalInit.apply(this, arguments);
}, },
series : function(){
series : function() {
this.setTitle('Sonarr'); this.setTitle('Sonarr');
this.showMainRegion(new SeriesIndexLayout()); this.showMainRegion(new SeriesIndexLayout());
}, },
seriesDetails : function(query){
var series = SeriesCollection.where({titleSlug : query}); seriesDetails : function(query) {
if(series.length !== 0) { var series = SeriesCollection.where({ titleSlug : query });
if (series.length !== 0) {
var targetSeries = series[0]; var targetSeries = series[0];
this.setTitle(targetSeries.get('title')); this.setTitle(targetSeries.get('title'));
this.showMainRegion(new SeriesDetailsLayout({model : targetSeries})); this.showMainRegion(new SeriesDetailsLayout({ model : targetSeries }));
} } else {
else {
this.showNotFound(); this.showNotFound();
} }
} }

@ -2,26 +2,28 @@ var Backbone = require('backbone');
var _ = require('underscore'); var _ = require('underscore');
module.exports = Backbone.Model.extend({ module.exports = Backbone.Model.extend({
urlRoot : window.NzbDrone.ApiRoot + '/series', urlRoot : window.NzbDrone.ApiRoot + '/series',
defaults : {
defaults : {
episodeFileCount : 0, episodeFileCount : 0,
episodeCount : 0, episodeCount : 0,
isExisting : false, isExisting : false,
status : 0 status : 0
}, },
setSeasonMonitored : function(seasonNumber){
_.each(this.get('seasons'), function(season){ setSeasonMonitored : function(seasonNumber) {
if(season.seasonNumber === seasonNumber) { _.each(this.get('seasons'), function(season) {
if (season.seasonNumber === seasonNumber) {
season.monitored = !season.monitored; season.monitored = !season.monitored;
} }
}); });
}, },
setSeasonPass : function(seasonNumber){
_.each(this.get('seasons'), function(season){ setSeasonPass : function(seasonNumber) {
if(season.seasonNumber >= seasonNumber) { _.each(this.get('seasons'), function(season) {
if (season.seasonNumber >= seasonNumber) {
season.monitored = true; season.monitored = true;
} } else {
else {
season.monitored = false; season.monitored = false;
} }
}); });

Loading…
Cancel
Save