Adding history

This commit is contained in:
Mark McDowall 2013-05-02 23:53:32 -07:00
commit 7ab1084437
20 changed files with 289 additions and 7 deletions

View file

@ -4,7 +4,8 @@ define(['app', 'Shared/ModalRegion', 'AddSeries/AddSeriesLayout',
'Calendar/CalendarCollectionView', 'Shared/NotificationView',
'Shared/NotFoundView', 'MainMenuView',
'Series/Details/SeriesDetailsView', 'Series/EpisodeCollection',
'Settings/SettingsLayout', 'Missing/MissingLayout'],
'Settings/SettingsLayout', 'Missing/MissingLayout',
'History/HistoryLayout'],
function (app, modalRegion) {
var controller = Backbone.Marionette.Controller.extend({
@ -61,6 +62,12 @@ define(['app', 'Shared/ModalRegion', 'AddSeries/AddSeriesLayout',
NzbDrone.mainRegion.show(new NzbDrone.Missing.MissingLayout());
},
history: function () {
this._setTitle('History');
NzbDrone.mainRegion.show(new NzbDrone.History.HistoryLayout());
},
notFound: function () {
this._setTitle('Not Found');
NzbDrone.mainRegion.show(new NzbDrone.Shared.NotFoundView(this));

37
UI/History/Collection.js Normal file
View file

@ -0,0 +1,37 @@
"use strict";
define(['app', 'History/Model'], function () {
NzbDrone.Missing.Collection = Backbone.PageableCollection.extend({
url : NzbDrone.Constants.ApiRoot + '/history',
model : NzbDrone.History.Model,
state: {
pageSize: 10,
sortKey: "date",
order: 1
},
queryParams: {
totalPages: null,
totalRecords: null,
pageSize: 'pageSize',
sortKey: "sortKey",
order: "sortDir",
directions: {
"-1": "asc",
"1": "desc"
}
},
parseState: function (resp, queryParams, state) {
return {totalRecords: resp.totalRecords};
},
parseRecords: function (resp) {
if (resp) {
return resp.records;
}
return resp;
}
});
});

View file

@ -0,0 +1 @@
<i class="icon-search x-search" title="Search"></i>

View file

@ -0,0 +1,2 @@

{{seasonNumber}}x{{paddedEpisodeNumber}}

View file

@ -0,0 +1,89 @@
"use strict";
define([
'app',
'History/Collection',
'Series/Index/Table/AirDateCell',
'Shared/Toolbar/ToolbarView',
'Shared/Toolbar/ToolbarLayout'
],
function () {
NzbDrone.History.HistoryLayout = Backbone.Marionette.Layout.extend({
template: 'History/HistoryLayoutTemplate',
regions: {
history: '#x-history',
toolbar: '#x-toolbar',
pager : '#x-pager'
},
showTable: function () {
var columns = [
{
name : 'seriesTitle',
label : 'Series Title',
editable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/SeriesTitleTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'episode',
label : 'Episode',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/EpisodeColumnTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'title',
label : 'Episode Title',
editable : false,
sortable : false,
cell : 'string',
headerCell: 'nzbDrone'
},
{
name : 'airDate',
label : 'Air Date',
editable : false,
cell : 'airDate',
headerCell: 'nzbDrone'
},
{
name : 'edit',
label : '',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/ControlsColumnTemplate' }),
headerCell: 'nzbDrone'
}
];
this.history.show(new Backgrid.Grid(
{
row : NzbDrone.History.Row,
columns : columns,
collection: this.historyCollection,
className : 'table table-hover'
}));
this.pager.show(new Backgrid.NzbDronePaginator({
columns: columns,
collection: this.historyCollection
}));
},
initialize: function () {
this.historyCollection = new NzbDrone.History.Collection();
this.historyCollection.fetch();
},
onShow: function () {
this.showTable();
//this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this}));
}
})
;
})
;

View file

@ -0,0 +1,11 @@
<div id="x-toolbar"></div>
<div class="row">
<div class="span12">
<div id="x-history"></div>
</div>
</div>
<div class="row">
<div class="span12">
<div id="x-pager"></div>
</div>
</div>

6
UI/History/Model.js Normal file
View file

@ -0,0 +1,6 @@
"use strict";
define(['app'], function (app) {
NzbDrone.History.Model = Backbone.Model.extend({
});
});

9
UI/History/Row.js Normal file
View file

@ -0,0 +1,9 @@
NzbDrone.Missing.Row = Backgrid.Row.extend({
events: {
'click .x-search' : 'search'
},
search: function () {
window.alert('Episode Search');
}
});

View file

@ -0,0 +1 @@
<a href="series/details/{{series.titleSlug}}">{{series.title}}</a>

View file

@ -71,12 +71,11 @@ define([
columns: columns,
collection: this.missingCollection
}));
this.missingCollection.getFirstPage();
},
initialize: function () {
this.missingCollection = new NzbDrone.Missing.Collection();
this.missingCollection.fetch();
},
onShow: function () {

View file

@ -17,6 +17,7 @@ require(['app', 'Controller'], function (app, controller) {
'settings' : 'settings',
'settings/:action(/:query)' : 'settings',
'missing' : 'missing',
'history' : 'history',
':whatever' : 'notFound'
}
});

View file

@ -10,6 +10,11 @@ define(['app', 'Series/SeriesModel'], function () {
sortKey: "title",
order: -1,
pageSize: 1000000
},
queryParams: {
sortKey: null,
order: null
}
});
});

View file

@ -58,6 +58,7 @@ define('app', function () {
window.NzbDrone.Settings.System = {};
window.NzbDrone.Settings.Misc = {};
window.NzbDrone.Missing = {};
window.NzbDrone.History = {};
window.NzbDrone.Events = {
//TODO: Move to commands