You've already forked Sonarr
mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-07-05 00:49:20 +02:00
UI Cleanup - Updated Series subtree.
This commit is contained in:
@ -3,33 +3,38 @@ var Marionette = require('marionette');
|
|||||||
|
|
||||||
module.exports = Marionette.ItemView.extend({
|
module.exports = Marionette.ItemView.extend({
|
||||||
template : 'Series/Delete/DeleteSeriesTemplate',
|
template : 'Series/Delete/DeleteSeriesTemplate',
|
||||||
|
|
||||||
events : {
|
events : {
|
||||||
"click .x-confirm-delete" : 'removeSeries',
|
'click .x-confirm-delete' : 'removeSeries',
|
||||||
"change .x-delete-files" : 'changeDeletedFiles'
|
'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 (reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) {
|
||||||
|
|
||||||
if (this.model.get('sceneSeasonNumber') > 0) {
|
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 (SeriesCollection.get(this.model.get('seriesId')).get('seriesType') === 'anime') {
|
||||||
if (this.model.get('seasonNumber') > 0 && !this.model.has('absoluteEpisodeNumber')) {
|
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;
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,17 @@ 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() {
|
templateHelpers : function() {
|
||||||
return {fileCount : this.episodeFileCollection.length};
|
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) {
|
initialize : function(options) {
|
||||||
if (!options.episodeCollection) {
|
if (!options.episodeCollection) {
|
||||||
throw 'episodeCollection is needed';
|
throw 'episodeCollection is needed';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.episodeCollection = options.episodeCollection;
|
this.episodeCollection = options.episodeCollection;
|
||||||
this.series = options.series;
|
this.series = options.series;
|
||||||
},
|
},
|
||||||
|
|
||||||
itemViewOptions : function() {
|
itemViewOptions : function() {
|
||||||
return {
|
return {
|
||||||
episodeCollection : this.episodeCollection,
|
episodeCollection : this.episodeCollection,
|
||||||
series : this.series
|
series : this.series
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
onEpisodeGrabbed : function(message) {
|
onEpisodeGrabbed : function(message) {
|
||||||
if (message.episode.series.id !== this.episodeCollection.seriesId) {
|
if (message.episode.series.id !== this.episodeCollection.seriesId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
_.each(message.episode.episodes, function(episode) {
|
_.each(message.episode.episodes, function(episode) {
|
||||||
var ep = self.episodeCollection.get(episode.id);
|
var ep = self.episodeCollection.get(episode.id);
|
||||||
ep.set('downloading', true);
|
ep.set('downloading', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AsSortedCollectionView.call(view);
|
AsSortedCollectionView.call(view);
|
||||||
return view;
|
|
||||||
}).call(this);
|
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');
|
||||||
@ -15,20 +15,27 @@ 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 : {
|
events : {
|
||||||
"click .x-season-monitored" : '_seasonMonitored',
|
'click .x-season-monitored' : '_seasonMonitored',
|
||||||
"click .x-season-search" : '_seasonSearch',
|
'click .x-season-search' : '_seasonSearch',
|
||||||
"click .x-season-rename" : '_seasonRename',
|
'click .x-season-rename' : '_seasonRename',
|
||||||
"click .x-show-hide-episodes" : '_showHideEpisodes',
|
'click .x-show-hide-episodes' : '_showHideEpisodes',
|
||||||
"dblclick .series-season h2" : '_showHideEpisodes'
|
'dblclick .series-season h2' : '_showHideEpisodes'
|
||||||
},
|
},
|
||||||
regions : {episodeGrid : '.x-episode-grid'},
|
|
||||||
columns : [{
|
regions : {
|
||||||
|
episodeGrid : '.x-episode-grid'
|
||||||
|
},
|
||||||
|
|
||||||
|
columns : [
|
||||||
|
{
|
||||||
name : 'monitored',
|
name : 'monitored',
|
||||||
label : '',
|
label : '',
|
||||||
cell : ToggleCell,
|
cell : ToggleCell,
|
||||||
@ -36,46 +43,57 @@ module.exports = Marionette.Layout.extend({
|
|||||||
falseClass : 'icon-bookmark-empty',
|
falseClass : 'icon-bookmark-empty',
|
||||||
tooltip : 'Toggle monitored status',
|
tooltip : 'Toggle monitored status',
|
||||||
sortable : false
|
sortable : false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'episodeNumber',
|
name : 'episodeNumber',
|
||||||
label : '#',
|
label : '#',
|
||||||
cell : EpisodeNumberCell
|
cell : EpisodeNumberCell
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'this',
|
name : 'this',
|
||||||
label : '',
|
label : '',
|
||||||
cell : EpisodeWarningCell,
|
cell : EpisodeWarningCell,
|
||||||
sortable : false,
|
sortable : false,
|
||||||
className : 'episode-warning-cell'
|
className : 'episode-warning-cell'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'this',
|
name : 'this',
|
||||||
label : 'Title',
|
label : 'Title',
|
||||||
hideSeriesLink : true,
|
hideSeriesLink : true,
|
||||||
cell : EpisodeTitleCell,
|
cell : EpisodeTitleCell,
|
||||||
sortable : false
|
sortable : false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'airDateUtc',
|
name : 'airDateUtc',
|
||||||
label : 'Air Date',
|
label : 'Air Date',
|
||||||
cell : RelativeDateCell
|
cell : RelativeDateCell
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'status',
|
name : 'status',
|
||||||
label : 'Status',
|
label : 'Status',
|
||||||
cell : EpisodeStatusCell,
|
cell : EpisodeStatusCell,
|
||||||
sortable : false
|
sortable : false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'this',
|
name : 'this',
|
||||||
label : '',
|
label : '',
|
||||||
cell : EpisodeActionsCell,
|
cell : EpisodeActionsCell,
|
||||||
sortable : false
|
sortable : false
|
||||||
}],
|
}
|
||||||
|
],
|
||||||
|
|
||||||
templateHelpers : function() {
|
templateHelpers : function() {
|
||||||
var episodeCount = this.episodeCollection.filter(function(episode) {
|
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) {
|
initialize : function(options) {
|
||||||
if (!options.episodeCollection) {
|
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() {
|
onRender : function() {
|
||||||
if (this.showingEpisodes) {
|
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,6 +145,7 @@ module.exports = Marionette.Layout.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_seasonSearch : function() {
|
_seasonSearch : function() {
|
||||||
CommandController.Execute('seasonSearch', {
|
CommandController.Execute('seasonSearch', {
|
||||||
name : 'seasonSearch',
|
name : 'seasonSearch',
|
||||||
@ -125,44 +153,56 @@ module.exports = Marionette.Layout.extend({
|
|||||||
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() {
|
_seasonMonitored : function() {
|
||||||
if (!this.series.get('monitored')) {
|
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) {
|
_.each(this.episodeCollection.models, function(episode) {
|
||||||
episode.set({ monitored : self.model.get('monitored') });
|
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,
|
||||||
@ -170,59 +210,77 @@ module.exports = Marionette.Layout.extend({
|
|||||||
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() {
|
_showHideEpisodes : function() {
|
||||||
if (this.showingEpisodes) {
|
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.add(this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber')).models, { merge : true });
|
||||||
|
|
||||||
this.episodeCollection.each(function(model) {
|
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();
|
||||||
|
@ -18,10 +18,12 @@ 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',
|
||||||
@ -30,6 +32,7 @@ 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',
|
||||||
@ -37,40 +40,51 @@ module.exports = Marionette.Layout.extend({
|
|||||||
'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) {
|
this.listenTo(this.model, 'change', function(model, options) {
|
||||||
if (options && options.changeSource === 'signalr') {
|
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,92 +94,116 @@ module.exports = Marionette.Layout.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onClose : function() {
|
onClose : function() {
|
||||||
if (this._backstrech) {
|
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() {
|
_getFanArt : function() {
|
||||||
var fanArt = _.where(this.model.get('images'), { coverType : 'fanart' });
|
var fanArt = _.where(this.model.get('images'), { coverType : 'fanart' });
|
||||||
|
|
||||||
if (fanArt && fanArt[0]) {
|
if (fanArt && fanArt[0]) {
|
||||||
return fanArt[0].url;
|
return fanArt[0].url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
_toggleMonitored : function() {
|
_toggleMonitored : function() {
|
||||||
var savePromise = this.model.save('monitored', !this.model.get('monitored'), { wait : true });
|
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() {
|
_editSeries : function() {
|
||||||
vent.trigger(vent.Commands.EditSeriesCommand, { series : this.model });
|
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() {
|
_seriesRemoved : function() {
|
||||||
Backbone.history.navigate('/', { trigger : true });
|
Backbone.history.navigate('/', { trigger : true });
|
||||||
},
|
},
|
||||||
|
|
||||||
_renameSeries : function() {
|
_renameSeries : function() {
|
||||||
vent.trigger(vent.Commands.ShowRenamePreview, { series : this.model });
|
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) {
|
reqres.setHandler(reqres.Requests.GetAlternateNameBySeasonNumber, function(seriesId, seasonNumber) {
|
||||||
if (self.model.get('id') !== seriesId) {
|
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) {
|
_commandComplete : function(options) {
|
||||||
if (options.command.get('name') === 'renamefiles') {
|
if (options.command.get('name') === 'renamefiles') {
|
||||||
if (options.command.get('seriesId') === this.model.get('id')) {
|
if (options.command.get('seriesId') === this.model.get('id')) {
|
||||||
@ -173,10 +211,12 @@ module.exports = Marionette.Layout.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_refresh : function() {
|
_refresh : function() {
|
||||||
this.seasonCollection.add(this.model.get('seasons'), { merge : true });
|
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,18 +7,23 @@ 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'},
|
|
||||||
|
events : {
|
||||||
|
'click .x-remove' : '_removeSeries'
|
||||||
|
},
|
||||||
|
|
||||||
initialize : function() {
|
initialize : function() {
|
||||||
this.model.set('profiles', Profiles);
|
this.model.set('profiles', Profiles);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender : function() {
|
onRender : function() {
|
||||||
this.ui.path.fileBrowser();
|
this.ui.path.fileBrowser();
|
||||||
this.ui.tags.tagInput({
|
this.ui.tags.tagInput({
|
||||||
@ -26,20 +31,24 @@ module.exports = (function(){
|
|||||||
property : 'tags'
|
property : 'tags'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_onBeforeSave : function() {
|
_onBeforeSave : function() {
|
||||||
var profileId = this.ui.profile.val();
|
var profileId = this.ui.profile.val();
|
||||||
this.model.set({ profileId : profileId });
|
this.model.set({ profileId : profileId });
|
||||||
},
|
},
|
||||||
|
|
||||||
_onAfterSave : function() {
|
_onAfterSave : function() {
|
||||||
this.trigger('saved');
|
this.trigger('saved');
|
||||||
vent.trigger(vent.Commands.CloseModalCommand);
|
vent.trigger(vent.Commands.CloseModalCommand);
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeSeries : function() {
|
_removeSeries : function() {
|
||||||
vent.trigger(vent.Commands.DeleteSeriesCommand, { series : this.model });
|
vent.trigger(vent.Commands.DeleteSeriesCommand, { series : this.model });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AsModelBoundView.call(view);
|
AsModelBoundView.call(view);
|
||||||
AsValidatedView.call(view);
|
AsValidatedView.call(view);
|
||||||
AsEditModalView.call(view);
|
AsEditModalView.call(view);
|
||||||
return view;
|
|
||||||
}).call(this);
|
module.exports = view;
|
@ -6,7 +6,11 @@ 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'},
|
|
||||||
|
events : {
|
||||||
|
'click .x-confirm-organize' : '_organize'
|
||||||
|
},
|
||||||
|
|
||||||
initialize : function(options) {
|
initialize : function(options) {
|
||||||
this.series = options.series;
|
this.series = options.series;
|
||||||
this.templateHelpers = {
|
this.templateHelpers = {
|
||||||
@ -14,12 +18,15 @@ module.exports = Marionette.ItemView.extend({
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ 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',
|
||||||
@ -21,63 +22,79 @@ module.exports = Marionette.ItemView.extend({
|
|||||||
organizeFilesButton : '.x-organize-files',
|
organizeFilesButton : '.x-organize-files',
|
||||||
container : '.series-editor-footer'
|
container : '.series-editor-footer'
|
||||||
},
|
},
|
||||||
|
|
||||||
events : {
|
events : {
|
||||||
"click .x-save" : '_updateAndSave',
|
'click .x-save' : '_updateAndSave',
|
||||||
"change .x-root-folder" : '_rootFolderChanged',
|
'change .x-root-folder' : '_rootFolderChanged',
|
||||||
"click .x-organize-files" : '_organizeFiles'
|
'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) {
|
_.each(selected, function(model) {
|
||||||
if (monitored === 'true') {
|
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', '');
|
||||||
@ -85,8 +102,7 @@ module.exports = Marionette.ItemView.extend({
|
|||||||
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -14,134 +14,169 @@ 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 : {
|
events : {
|
||||||
"click .x-save" : '_updateAndSave',
|
'click .x-save' : '_updateAndSave',
|
||||||
"change .x-root-folder" : '_rootFolderChanged'
|
'change .x-root-folder' : '_rootFolderChanged'
|
||||||
},
|
},
|
||||||
columns : [{
|
|
||||||
|
columns : [
|
||||||
|
{
|
||||||
name : '',
|
name : '',
|
||||||
cell : SelectAllCell,
|
cell : SelectAllCell,
|
||||||
headerCell : 'select-all',
|
headerCell : 'select-all',
|
||||||
sortable : false
|
sortable : false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'statusWeight',
|
name : 'statusWeight',
|
||||||
label : '',
|
label : '',
|
||||||
cell : SeriesStatusCell
|
cell : SeriesStatusCell
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'title',
|
name : 'title',
|
||||||
label : 'Title',
|
label : 'Title',
|
||||||
cell : SeriesTitleCell,
|
cell : SeriesTitleCell,
|
||||||
cellValue : 'this'
|
cellValue : 'this'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'profileId',
|
name : 'profileId',
|
||||||
label : 'Profile',
|
label : 'Profile',
|
||||||
cell : ProfileCell
|
cell : ProfileCell
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'seasonFolder',
|
name : 'seasonFolder',
|
||||||
label : 'Season Folder',
|
label : 'Season Folder',
|
||||||
cell : SeasonFolderCell
|
cell : SeasonFolderCell
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'path',
|
name : 'path',
|
||||||
label : 'Path',
|
label : 'Path',
|
||||||
cell : 'string'
|
cell : 'string'
|
||||||
}],
|
}
|
||||||
|
],
|
||||||
|
|
||||||
leftSideButtons : {
|
leftSideButtons : {
|
||||||
type : 'default',
|
type : 'default',
|
||||||
storeState : false,
|
storeState : false,
|
||||||
items : [{
|
items : [
|
||||||
|
{
|
||||||
title : 'Season Pass',
|
title : 'Season Pass',
|
||||||
icon : 'icon-bookmark',
|
icon : 'icon-bookmark',
|
||||||
route : 'seasonpass'
|
route : 'seasonpass'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Update Library',
|
title : 'Update Library',
|
||||||
icon : 'icon-refresh',
|
icon : 'icon-refresh',
|
||||||
command : 'refreshseries',
|
command : 'refreshseries',
|
||||||
successMessage : 'Library was updated!',
|
successMessage : 'Library was updated!',
|
||||||
errorMessage : 'Library update failed!'
|
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',
|
key : 'all',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'All',
|
tooltip : 'All',
|
||||||
icon : 'icon-circle-blank',
|
icon : 'icon-circle-blank',
|
||||||
callback : this._setFilter
|
callback : this._setFilter
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
key : 'monitored',
|
key : 'monitored',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'Monitored Only',
|
tooltip : 'Monitored Only',
|
||||||
icon : 'icon-nd-monitored',
|
icon : 'icon-nd-monitored',
|
||||||
callback : this._setFilter
|
callback : this._setFilter
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
key : 'continuing',
|
key : 'continuing',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'Continuing Only',
|
tooltip : 'Continuing Only',
|
||||||
icon : 'icon-play',
|
icon : 'icon-play',
|
||||||
callback : this._setFilter
|
callback : this._setFilter
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
key : 'ended',
|
key : 'ended',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'Ended Only',
|
tooltip : 'Ended Only',
|
||||||
icon : 'icon-stop',
|
icon : 'icon-stop',
|
||||||
callback : this._setFilter
|
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() {
|
_showTable : function() {
|
||||||
if (this.seriesCollection.shadowCollection.length === 0) {
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -5,40 +5,54 @@ 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) {
|
bySeason : function(season) {
|
||||||
var filtered = this.filter(function(episode) {
|
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) {
|
fetch : function(options) {
|
||||||
if (!this.seriesId) {
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -4,19 +4,25 @@ 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) {
|
fetch : function(options) {
|
||||||
if (!this.seriesId) {
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -5,7 +5,11 @@ module.exports = Backbone.Model.extend({
|
|||||||
seasonNumber : 0,
|
seasonNumber : 0,
|
||||||
status : 0
|
status : 0
|
||||||
},
|
},
|
||||||
methodUrls : {"update" : window.NzbDrone.ApiRoot + '/episode'},
|
|
||||||
|
methodUrls : {
|
||||||
|
'update' : window.NzbDrone.ApiRoot + '/episode'
|
||||||
|
},
|
||||||
|
|
||||||
sync : function(method, model, options) {
|
sync : function(method, model, options) {
|
||||||
if (model.methodUrls && model.methodUrls[method.toLowerCase()]) {
|
if (model.methodUrls && model.methodUrls[method.toLowerCase()]) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
@ -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,14 +1,17 @@
|
|||||||
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,13 +1,17 @@
|
|||||||
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 : {
|
||||||
|
refresh : '.x-refresh'
|
||||||
|
},
|
||||||
|
|
||||||
events : {
|
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,
|
||||||
@ -17,9 +21,11 @@ module.exports = Marionette.ItemView.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_editSeries : function() {
|
_editSeries : function() {
|
||||||
vent.trigger(vent.Commands.EditSeriesCommand, { series : this.model });
|
vent.trigger(vent.Commands.EditSeriesCommand, { series : this.model });
|
||||||
},
|
},
|
||||||
|
|
||||||
_refreshSeries : function() {
|
_refreshSeries : function() {
|
||||||
CommandController.Execute('refreshSeries', {
|
CommandController.Execute('refreshSeries', {
|
||||||
name : 'refreshSeries',
|
name : 'refreshSeries',
|
||||||
|
@ -19,227 +19,295 @@ 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 : [{
|
|
||||||
|
columns : [
|
||||||
|
{
|
||||||
name : 'statusWeight',
|
name : 'statusWeight',
|
||||||
label : '',
|
label : '',
|
||||||
cell : SeriesStatusCell
|
cell : SeriesStatusCell
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'title',
|
name : 'title',
|
||||||
label : 'Title',
|
label : 'Title',
|
||||||
cell : SeriesTitleCell,
|
cell : SeriesTitleCell,
|
||||||
cellValue : 'this',
|
cellValue : 'this',
|
||||||
sortValue : 'sortTitle'
|
sortValue : 'sortTitle'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'seasonCount',
|
name : 'seasonCount',
|
||||||
label : 'Seasons',
|
label : 'Seasons',
|
||||||
cell : 'integer'
|
cell : 'integer'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'profileId',
|
name : 'profileId',
|
||||||
label : 'Profile',
|
label : 'Profile',
|
||||||
cell : ProfileCell
|
cell : ProfileCell
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'network',
|
name : 'network',
|
||||||
label : 'Network',
|
label : 'Network',
|
||||||
cell : 'string'
|
cell : 'string'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'nextAiring',
|
name : 'nextAiring',
|
||||||
label : 'Next Airing',
|
label : 'Next Airing',
|
||||||
cell : RelativeDateCell
|
cell : RelativeDateCell
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'percentOfEpisodes',
|
name : 'percentOfEpisodes',
|
||||||
label : 'Episodes',
|
label : 'Episodes',
|
||||||
cell : EpisodeProgressCell,
|
cell : EpisodeProgressCell,
|
||||||
className : 'episode-progress-cell'
|
className : 'episode-progress-cell'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
name : 'this',
|
name : 'this',
|
||||||
label : '',
|
label : '',
|
||||||
sortable : false,
|
sortable : false,
|
||||||
cell : SeriesActionsCell
|
cell : SeriesActionsCell
|
||||||
}],
|
}
|
||||||
|
],
|
||||||
|
|
||||||
leftSideButtons : {
|
leftSideButtons : {
|
||||||
type : 'default',
|
type : 'default',
|
||||||
storeState : false,
|
storeState : false,
|
||||||
collapse : true,
|
collapse : true,
|
||||||
items : [{
|
items : [
|
||||||
|
{
|
||||||
title : 'Add Series',
|
title : 'Add Series',
|
||||||
icon : 'icon-plus',
|
icon : 'icon-plus',
|
||||||
route : 'addseries'
|
route : 'addseries'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Season Pass',
|
title : 'Season Pass',
|
||||||
icon : 'icon-bookmark',
|
icon : 'icon-bookmark',
|
||||||
route : 'seasonpass'
|
route : 'seasonpass'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Series Editor',
|
title : 'Series Editor',
|
||||||
icon : 'icon-nd-edit',
|
icon : 'icon-nd-edit',
|
||||||
route : 'serieseditor'
|
route : 'serieseditor'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'RSS Sync',
|
title : 'RSS Sync',
|
||||||
icon : 'icon-rss',
|
icon : 'icon-rss',
|
||||||
command : 'rsssync',
|
command : 'rsssync',
|
||||||
errorMessage : 'RSS Sync Failed!'
|
errorMessage : 'RSS Sync Failed!'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Update Library',
|
title : 'Update Library',
|
||||||
icon : 'icon-refresh',
|
icon : 'icon-refresh',
|
||||||
command : 'refreshseries',
|
command : 'refreshseries',
|
||||||
successMessage : 'Library was updated!',
|
successMessage : 'Library was updated!',
|
||||||
errorMessage : 'Library update failed!'
|
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',
|
title : 'Title',
|
||||||
name : 'title'
|
name : 'title'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Seasons',
|
title : 'Seasons',
|
||||||
name : 'seasonCount'
|
name : 'seasonCount'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Quality',
|
title : 'Quality',
|
||||||
name : 'profileId'
|
name : 'profileId'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Network',
|
title : 'Network',
|
||||||
name : 'network'
|
name : 'network'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Next Airing',
|
title : 'Next Airing',
|
||||||
name : 'nextAiring'
|
name : 'nextAiring'
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
title : 'Episodes',
|
title : 'Episodes',
|
||||||
name : 'percentOfEpisodes'
|
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',
|
key : 'all',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'All',
|
tooltip : 'All',
|
||||||
icon : 'icon-circle-blank',
|
icon : 'icon-circle-blank',
|
||||||
callback : this._setFilter
|
callback : this._setFilter
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
key : 'monitored',
|
key : 'monitored',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'Monitored Only',
|
tooltip : 'Monitored Only',
|
||||||
icon : 'icon-nd-monitored',
|
icon : 'icon-nd-monitored',
|
||||||
callback : this._setFilter
|
callback : this._setFilter
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
key : 'continuing',
|
key : 'continuing',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'Continuing Only',
|
tooltip : 'Continuing Only',
|
||||||
icon : 'icon-play',
|
icon : 'icon-play',
|
||||||
callback : this._setFilter
|
callback : this._setFilter
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
key : 'ended',
|
key : 'ended',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'Ended Only',
|
tooltip : 'Ended Only',
|
||||||
icon : 'icon-stop',
|
icon : 'icon-stop',
|
||||||
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-th-large',
|
icon : 'icon-th-large',
|
||||||
callback : this._showPosters
|
callback : this._showPosters
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
key : 'listView',
|
key : 'listView',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'Overview List',
|
tooltip : 'Overview List',
|
||||||
icon : 'icon-th-list',
|
icon : 'icon-th-list',
|
||||||
callback : this._showList
|
callback : this._showList
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
key : 'tableView',
|
key : 'tableView',
|
||||||
title : '',
|
title : '',
|
||||||
tooltip : 'Table',
|
tooltip : 'Table',
|
||||||
icon : 'icon-table',
|
icon : 'icon-table',
|
||||||
callback : this._showTable
|
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() {
|
_showList : function() {
|
||||||
this.currentView = new ListCollectionView({collection : this.seriesCollection});
|
this.currentView = new ListCollectionView({
|
||||||
|
collection : this.seriesCollection
|
||||||
|
});
|
||||||
|
|
||||||
this._renderView();
|
this._renderView();
|
||||||
},
|
},
|
||||||
|
|
||||||
_showPosters : function() {
|
_showPosters : function() {
|
||||||
this.currentView = new PosterCollectionView({collection : this.seriesCollection});
|
this.currentView = new PosterCollectionView({
|
||||||
|
collection : this.seriesCollection
|
||||||
|
});
|
||||||
|
|
||||||
this._renderView();
|
this._renderView();
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderView : function() {
|
_renderView : function() {
|
||||||
if (SeriesCollection.length === 0) {
|
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() {
|
_showToolbar : function() {
|
||||||
if (this.toolbar.currentView) {
|
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;
|
||||||
@ -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 }));
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -3,6 +3,7 @@ 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,7 +1,10 @@
|
|||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
|
||||||
module.exports = Backbone.Model.extend({
|
module.exports = Backbone.Model.extend({
|
||||||
defaults : {seasonNumber : 0},
|
defaults : {
|
||||||
|
seasonNumber : 0
|
||||||
|
},
|
||||||
|
|
||||||
initialize : function() {
|
initialize : function() {
|
||||||
this.set('id', this.get('seasonNumber'));
|
this.set('id', this.get('seasonNumber'));
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ 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,
|
||||||
@ -20,56 +20,86 @@ module.exports = (function(){
|
|||||||
secondarySortKey : 'sortTitle',
|
secondarySortKey : 'sortTitle',
|
||||||
secondarySortOrder : -1
|
secondarySortOrder : -1
|
||||||
},
|
},
|
||||||
|
|
||||||
mode : 'client',
|
mode : 'client',
|
||||||
|
|
||||||
save : function() {
|
save : function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var proxy = _.extend(new Backbone.Model(), {
|
var proxy = _.extend(new Backbone.Model(), {
|
||||||
id : '',
|
id : '',
|
||||||
|
|
||||||
url : self.url + '/editor',
|
url : self.url + '/editor',
|
||||||
|
|
||||||
toJSON : function() {
|
toJSON : function() {
|
||||||
return self.filter(function(model) {
|
return self.filter(function(model) {
|
||||||
return model.edited;
|
return model.edited;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.listenTo(proxy, 'sync', function(proxyModel, models) {
|
this.listenTo(proxy, 'sync', function(proxyModel, models) {
|
||||||
this.add(models, { merge : true });
|
this.add(models, { merge : true });
|
||||||
this.trigger('save', this);
|
this.trigger('save', this);
|
||||||
});
|
});
|
||||||
|
|
||||||
return proxy.save();
|
return proxy.save();
|
||||||
},
|
},
|
||||||
|
|
||||||
filterModes : {
|
filterModes : {
|
||||||
"all" : [null, null],
|
'all' : [
|
||||||
"continuing" : ['status', 'continuing'],
|
null,
|
||||||
"ended" : ['status', 'ended'],
|
null
|
||||||
"monitored" : ['monitored', true]
|
],
|
||||||
|
'continuing' : [
|
||||||
|
'status',
|
||||||
|
'continuing'
|
||||||
|
],
|
||||||
|
'ended' : [
|
||||||
|
'status',
|
||||||
|
'ended'
|
||||||
|
],
|
||||||
|
'monitored' : [
|
||||||
|
'monitored',
|
||||||
|
true
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
sortMappings : {
|
sortMappings : {
|
||||||
"title" : {sortKey : 'sortTitle'},
|
'title' : {
|
||||||
"nextAiring" : {
|
sortKey : 'sortTitle'
|
||||||
|
},
|
||||||
|
'nextAiring' : {
|
||||||
sortValue : function(model, attr, order) {
|
sortValue : function(model, attr, order) {
|
||||||
var nextAiring = model.get(attr);
|
var nextAiring = model.get(attr);
|
||||||
|
|
||||||
if (nextAiring) {
|
if (nextAiring) {
|
||||||
return moment(nextAiring).unix();
|
return moment(nextAiring).unix();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order === 1) {
|
if (order === 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Number.MAX_VALUE;
|
return Number.MAX_VALUE;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
percentOfEpisodes : {
|
percentOfEpisodes : {
|
||||||
sortValue : function(model, attr) {
|
sortValue : function(model, attr) {
|
||||||
var percentOfEpisodes = model.get(attr);
|
var percentOfEpisodes = model.get(attr);
|
||||||
var episodeCount = model.get('episodeCount');
|
var episodeCount = model.get('episodeCount');
|
||||||
|
|
||||||
return percentOfEpisodes + episodeCount / 1000000;
|
return percentOfEpisodes + episodeCount / 1000000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Collection = AsFilteredCollection.call(Collection);
|
Collection = AsFilteredCollection.call(Collection);
|
||||||
Collection = AsSortedCollection.call(Collection);
|
Collection = AsSortedCollection.call(Collection);
|
||||||
Collection = AsPersistedStateCollection.call(Collection);
|
Collection = AsPersistedStateCollection.call(Collection);
|
||||||
|
|
||||||
var data = ApiData.get('series');
|
var data = ApiData.get('series');
|
||||||
return new Collection(data, {full : true});
|
|
||||||
}).call(this);
|
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) {
|
seriesDetails : function(query) {
|
||||||
var series = SeriesCollection.where({ titleSlug : query });
|
var series = SeriesCollection.where({ titleSlug : query });
|
||||||
|
|
||||||
if (series.length !== 0) {
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,14 @@ 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) {
|
setSeasonMonitored : function(seasonNumber) {
|
||||||
_.each(this.get('seasons'), function(season) {
|
_.each(this.get('seasons'), function(season) {
|
||||||
if (season.seasonNumber === seasonNumber) {
|
if (season.seasonNumber === seasonNumber) {
|
||||||
@ -16,12 +18,12 @@ module.exports = Backbone.Model.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setSeasonPass : function(seasonNumber) {
|
setSeasonPass : function(seasonNumber) {
|
||||||
_.each(this.get('seasons'), function(season) {
|
_.each(this.get('seasons'), function(season) {
|
||||||
if (season.seasonNumber >= seasonNumber) {
|
if (season.seasonNumber >= seasonNumber) {
|
||||||
season.monitored = true;
|
season.monitored = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
season.monitored = false;
|
season.monitored = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user