1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 08:22:35 +01:00
Sonarr/UI/Series/Index/SeriesIndexLayout.js

189 lines
6.4 KiB
JavaScript
Raw Normal View History

2013-04-23 02:35:04 +02:00
"use strict";
define([
'app',
'Series/Index/List/CollectionView',
2013-04-24 05:11:45 +02:00
'Series/Index/Posters/CollectionView',
2013-04-24 02:30:25 +02:00
'Series/Index/EmptyView',
'Cells/AirDateCell',
'Cells/SeriesTitleCell',
'Cells/TemplatedCell',
2013-04-25 06:27:49 +02:00
'Series/Index/Table/SeriesStatusCell',
'Shared/Toolbar/ToolbarLayout',
2013-06-08 09:57:43 +02:00
'Config',
'Shared/LoadingView'
2013-04-23 02:35:04 +02:00
],
2013-04-23 04:07:21 +02:00
function () {
2013-04-23 02:35:04 +02:00
NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({
template: 'Series/Index/SeriesIndexLayoutTemplate',
regions: {
series : '#x-series',
toolbar: '#x-toolbar'
2013-04-23 02:35:04 +02:00
},
columns: [
{
name : 'status',
label: '',
cell : 'seriesStatus'
},
{
name : 'this',
label: 'Title',
cell : NzbDrone.Cells.SeriesTitleCell
},
{
name : 'seasonCount',
label: 'Seasons',
cell : 'integer'
},
{
name : 'quality',
label: 'Quality',
cell : 'integer'
},
{
name : 'network',
label: 'Network',
cell : 'string'
},
{
name : 'nextAiring',
label: 'Next Airing',
cell : NzbDrone.Cells.AirDateCell
},
{
name : 'this',
label : 'Episodes',
sortable: false,
template: 'Series/EpisodeProgressTemplate',
cell : NzbDrone.Cells.TemplatedCell
},
{
name : 'this',
label : '',
sortable: false,
template: 'Series/Index/Table/ControlsColumnTemplate',
cell : NzbDrone.Cells.TemplatedCell
}
],
2013-04-23 02:35:04 +02:00
2013-06-08 09:57:43 +02: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!'
}
]
},
_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 02:35:04 +02:00
this._fetchCollection(view);
2013-04-23 02:35:04 +02:00
},
_showList: function () {
var view = new NzbDrone.Series.Index.List.CollectionView();
this._fetchCollection(view);
2013-04-23 02:35:04 +02:00
},
_showPosters: function () {
var view = new NzbDrone.Series.Index.Posters.CollectionView();
this._fetchCollection(view);
2013-04-24 05:11:45 +02:00
},
_showEmpty: function () {
2013-04-24 02:30:25 +02:00
this.series.show(new NzbDrone.Series.Index.EmptyView());
},
_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 02:35:04 +02:00
initialize: function () {
this.seriesCollection = new NzbDrone.Series.SeriesCollection();
},
onShow: function () {
2013-06-08 09:57:43 +02:00
//TODO: Move this outside of the function - 'this' is not available for the call back though (use string like events?)
var viewButtons = {
type : 'radio',
storeState : true,
menuKey : 'seriesViewMode',
defaultAction: 'listView',
items : [
{
key : 'tableView',
title : '',
icon : 'icon-table',
callback: this._showTable
},
{
key : 'listView',
title : '',
icon : 'icon-list',
callback: this._showList
},
{
key : 'posterView',
title : '',
icon : 'icon-picture',
callback: this._showPosters
}
]
};
2013-05-11 22:51:32 +02:00
this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({
right : [ viewButtons],
2013-06-08 09:57:43 +02:00
left : [ this.leftSideButtons],
2013-05-11 22:51:32 +02:00
context: this
}));
2013-04-23 02:35:04 +02:00
}
2013-06-08 09:57:43 +02:00
});
});