2013-04-23 03:35:04 +03:00
|
|
|
"use strict";
|
|
|
|
define([
|
|
|
|
'app',
|
|
|
|
'Series/Index/List/CollectionView',
|
2013-04-24 06:11:45 +03:00
|
|
|
'Series/Index/Posters/CollectionView',
|
2013-04-24 03:30:25 +03:00
|
|
|
'Series/Index/EmptyView',
|
|
|
|
'Series/Index/Table/AirDateCell',
|
2013-04-25 07:27:49 +03:00
|
|
|
'Series/Index/Table/SeriesStatusCell',
|
2013-04-24 08:56:51 +03:00
|
|
|
'Shared/Toolbar/ToolbarLayout',
|
2013-06-08 10:57:43 +03:00
|
|
|
'Config',
|
|
|
|
'Shared/LoadingView'
|
2013-04-23 03:35:04 +03:00
|
|
|
],
|
2013-04-23 05:07:21 +03:00
|
|
|
function () {
|
2013-04-23 03:35:04 +03:00
|
|
|
NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({
|
|
|
|
template: 'Series/Index/SeriesIndexLayoutTemplate',
|
|
|
|
|
|
|
|
regions: {
|
2013-04-24 04:55:29 +03:00
|
|
|
series : '#x-series',
|
|
|
|
toolbar: '#x-toolbar'
|
2013-04-23 03:35:04 +03:00
|
|
|
},
|
|
|
|
|
2013-05-17 06:47:28 +03:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
name : 'status',
|
|
|
|
label : '',
|
|
|
|
cell : 'seriesStatus'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'title',
|
|
|
|
label : 'Title',
|
|
|
|
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/SeriesTitleTemplate' })
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'seasonCount',
|
|
|
|
label : 'Seasons',
|
|
|
|
cell : 'integer'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'quality',
|
|
|
|
label : 'Quality',
|
|
|
|
cell : 'integer'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'network',
|
|
|
|
label : 'Network',
|
|
|
|
cell : 'string'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'nextAiring',
|
|
|
|
label : 'Next Airing',
|
|
|
|
cell : 'airDate'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'episodes',
|
|
|
|
label : 'Episodes',
|
|
|
|
sortable : false,
|
|
|
|
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/EpisodeProgressTemplate' })
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'edit',
|
|
|
|
label : '',
|
|
|
|
sortable : false,
|
|
|
|
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/ControlsColumnTemplate' })
|
|
|
|
}
|
|
|
|
],
|
2013-04-23 03:35:04 +03:00
|
|
|
|
2013-06-08 10:57:43 +03:00
|
|
|
leftSideButtons: {
|
|
|
|
type : 'default',
|
|
|
|
storeState: false,
|
|
|
|
items : [
|
|
|
|
{
|
|
|
|
title: 'Add Series',
|
|
|
|
icon : 'icon-plus',
|
|
|
|
route: 'series/add'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title : 'RSS Sync',
|
|
|
|
icon : 'icon-rss',
|
|
|
|
command : 'rsssync',
|
|
|
|
successMessage: 'RSS Sync Completed',
|
|
|
|
errorMessage : 'RSS Sync Failed!'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title : 'Update Library',
|
|
|
|
icon : 'icon-refresh',
|
|
|
|
command : 'refreshseries',
|
|
|
|
successMessage: 'Library was updated!',
|
|
|
|
errorMessage : 'Library update failed!'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
_showTable: function () {
|
|
|
|
var view = new Backgrid.Grid(
|
|
|
|
{
|
|
|
|
row : NzbDrone.Series.Index.Table.Row,
|
|
|
|
columns : this.columns,
|
|
|
|
collection: this.seriesCollection,
|
|
|
|
className : 'table table-hover'
|
|
|
|
});
|
2013-04-23 03:35:04 +03:00
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
this._fetchCollection(view);
|
2013-04-23 03:35:04 +03:00
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
_showList: function () {
|
|
|
|
var view = new NzbDrone.Series.Index.List.CollectionView();
|
|
|
|
this._fetchCollection(view);
|
2013-04-23 03:35:04 +03:00
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
_showPosters: function () {
|
|
|
|
var view = new NzbDrone.Series.Index.Posters.CollectionView();
|
|
|
|
this._fetchCollection(view);
|
2013-04-24 06:11:45 +03:00
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
_showEmpty: function () {
|
2013-04-24 03:30:25 +03:00
|
|
|
this.series.show(new NzbDrone.Series.Index.EmptyView());
|
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
_fetchCollection: function (view) {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
if (this.seriesCollection.models.length === 0) {
|
|
|
|
this.series.show(new NzbDrone.Shared.LoadingView());
|
|
|
|
|
|
|
|
this.seriesCollection.fetch()
|
|
|
|
.done(function () {
|
|
|
|
if (self.seriesCollection.models.length === 0) {
|
|
|
|
self._showEmpty();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
view.collection = self.seriesCollection;
|
|
|
|
self.series.show(view);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
view.collection = this.seriesCollection;
|
|
|
|
this.series.show(view);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-04-23 03:35:04 +03:00
|
|
|
initialize: function () {
|
|
|
|
this.seriesCollection = new NzbDrone.Series.SeriesCollection();
|
|
|
|
},
|
|
|
|
|
|
|
|
onShow: function () {
|
2013-04-24 04:55:29 +03:00
|
|
|
|
2013-06-08 10:57:43 +03:00
|
|
|
//TODO: Move this outside of the function - 'this' is not available for the call back though (use string like events?)
|
2013-04-26 07:45:45 +03:00
|
|
|
var viewButtons = {
|
|
|
|
type : 'radio',
|
2013-06-08 10:57:43 +03:00
|
|
|
storeState : true,
|
|
|
|
menuKey : 'seriesViewMode',
|
|
|
|
defaultAction: 'listView',
|
|
|
|
items : [
|
2013-04-26 07:45:45 +03:00
|
|
|
{
|
|
|
|
key : 'tableView',
|
|
|
|
title : '',
|
|
|
|
icon : 'icon-table',
|
2013-06-08 11:59:02 +03:00
|
|
|
callback: this._showTable
|
2013-04-26 07:45:45 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key : 'listView',
|
|
|
|
title : '',
|
|
|
|
icon : 'icon-list',
|
2013-06-08 11:59:02 +03:00
|
|
|
callback: this._showList
|
2013-04-26 07:45:45 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key : 'posterView',
|
|
|
|
title : '',
|
|
|
|
icon : 'icon-picture',
|
2013-06-08 11:59:02 +03:00
|
|
|
callback: this._showPosters
|
2013-04-26 07:45:45 +03:00
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2013-05-11 23:51:32 +03:00
|
|
|
this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({
|
|
|
|
right : [ viewButtons],
|
2013-06-08 10:57:43 +03:00
|
|
|
left : [ this.leftSideButtons],
|
2013-05-11 23:51:32 +03:00
|
|
|
context: this
|
|
|
|
}));
|
2013-04-23 03:35:04 +03:00
|
|
|
}
|
2013-06-08 10:57:43 +03:00
|
|
|
});
|
|
|
|
});
|