added /logs

This commit is contained in:
Keivan Beigi 2013-06-04 17:49:53 -07:00
commit 9160343a51
16 changed files with 231 additions and 16 deletions

View file

@ -10,6 +10,7 @@ define(['app',
'Series/Details/SeriesDetailsLayout',
'Series/EpisodeCollection',
'Settings/SettingsLayout',
'Logs/Layout',
'Missing/MissingLayout',
'History/HistoryLayout'],
function () {
@ -62,11 +63,17 @@ define(['app',
NzbDrone.mainRegion.show(new NzbDrone.History.HistoryLayout());
},
logs: function () {
this._setTitle('logs');
NzbDrone.mainRegion.show(new NzbDrone.Logs.Layout());
},
notFound: function () {
this._setTitle('Not Found');
NzbDrone.mainRegion.show(new NzbDrone.Shared.NotFoundView(this));
},
_setTitle: function (title) {
//$('#title-region').html(title);

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

@ -0,0 +1,37 @@
"use strict";
define(['app', 'Logs/Model'], function () {
NzbDrone.Logs.Collection = Backbone.PageableCollection.extend({
url : NzbDrone.Constants.ApiRoot + '/log',
model : NzbDrone.Logs.Model,
state: {
pageSize: 50,
sortKey: "time",
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;
}
});
});

72
UI/Logs/Layout.js Normal file
View file

@ -0,0 +1,72 @@
"use strict";
define([
'app',
'Logs/Collection',
'Shared/Toolbar/ToolbarLayout'
],
function () {
NzbDrone.Logs.Layout = Backbone.Marionette.Layout.extend({
template: 'Logs/LayoutTemplate',
regions: {
grid : '#x-grid',
toolbar: '#x-toolbar',
pager : '#x-pager'
},
columns: [
{
name : 'level',
label : 'Level',
sortable: true,
cell : Backgrid.StringCell
},
{
name : 'logger',
label : 'Component',
sortable: true,
cell : Backgrid.StringCell
},
{
name : 'message',
label : 'Message',
sortable: false,
cell : Backgrid.StringCell
},
{
name : 'time',
label: 'Time',
cell : Backgrid.DatetimeCell
}
],
showTable: function () {
this.grid.show(new Backgrid.Grid(
{
row : Backgrid.Row,
columns : this.columns,
collection: this.collection,
className : 'table table-hover'
}));
this.pager.show(new Backgrid.NzbDronePaginator({
columns : this.columns,
collection: this.collection
}));
},
initialize: function () {
this.collection = new NzbDrone.Logs.Collection();
this.collection.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-grid"></div>
</div>
</div>
<div class="row">
<div class="span12">
<div id="x-pager"></div>
</div>
</div>

14
UI/Logs/Model.js Normal file
View file

@ -0,0 +1,14 @@
"use strict";
define(['app'], function (app) {
NzbDrone.Logs.Model = Backbone.Model.extend({
/* mutators: {
seasonNumber: function () {
return this.get('episode').seasonNumber;
},
paddedEpisodeNumber: function () {
return this.get('episode').episodeNumber.pad(2);
}
}*/
});
});

View file

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

View file

@ -82,6 +82,7 @@ define('app', ['shared/modal/region'], function (ModalRegion) {
window.NzbDrone.Missing = {};
window.NzbDrone.History = {};
window.NzbDrone.Logs = {};
window.NzbDrone.Mixins = {};
window.NzbDrone.Events = {