mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
System now uses tabs instead of toolbar
This commit is contained in:
18
UI/System/Logs/Table/LogLevelCell.js
Normal file
18
UI/System/Logs/Table/LogLevelCell.js
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'log-level-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var level = this._getValue();
|
||||
this.$el.html('<i class="icon-{0}" title="{1}"/>'.format(this._getValue().toLowerCase(), level));
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
20
UI/System/Logs/Table/LogTimeCell.js
Normal file
20
UI/System/Logs/Table/LogTimeCell.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'moment'
|
||||
], function (NzbDroneCell, Moment) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'log-time-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var date = Moment(this._getValue());
|
||||
this.$el.html(date.format('LT'));
|
||||
this.$el.attr('title', date.format('LLLL'));
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
131
UI/System/Logs/Table/LogsTableLayout.js
Normal file
131
UI/System/Logs/Table/LogsTableLayout.js
Normal file
@@ -0,0 +1,131 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'System/Logs/Table/LogTimeCell',
|
||||
'System/Logs/Table/LogLevelCell',
|
||||
'Shared/Grid/Pager',
|
||||
'System/Logs/LogsCollection',
|
||||
'Shared/Toolbar/ToolbarLayout',
|
||||
'Shared/LoadingView'
|
||||
], function (Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Logs/Table/LogsTableLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
grid : '#x-grid',
|
||||
toolbar: '#x-toolbar',
|
||||
pager : '#x-pager'
|
||||
},
|
||||
|
||||
attributes: {
|
||||
id: 'logs-screen'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'level',
|
||||
label : '',
|
||||
sortable: true,
|
||||
cell : LogLevelCell
|
||||
},
|
||||
{
|
||||
name : 'logger',
|
||||
label : 'Component',
|
||||
sortable: true,
|
||||
cell : Backgrid.StringCell.extend({
|
||||
className: 'log-logger-cell'
|
||||
})
|
||||
},
|
||||
{
|
||||
name : 'message',
|
||||
label : 'Message',
|
||||
sortable: false,
|
||||
cell : Backgrid.StringCell.extend({
|
||||
className: 'log-message-cell'
|
||||
})
|
||||
},
|
||||
{
|
||||
name : 'time',
|
||||
label: 'Time',
|
||||
cell : LogTimeCell
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new LogCollection();
|
||||
this.collectionPromise = this.collection.fetch();
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.grid.show(new LoadingView());
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
var self = this;
|
||||
this._showToolbar();
|
||||
|
||||
this.collectionPromise.done(function () {
|
||||
self._showTable();
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
_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 GridPager({
|
||||
columns : this.columns,
|
||||
collection: this.collection
|
||||
}));
|
||||
},
|
||||
|
||||
_showToolbar: function () {
|
||||
var rightSideButtons = {
|
||||
type : 'default',
|
||||
storeState: false,
|
||||
items :
|
||||
[
|
||||
{
|
||||
title : 'Refresh',
|
||||
icon : 'icon-refresh',
|
||||
ownerContext : this,
|
||||
callback : this._refreshLogs
|
||||
},
|
||||
|
||||
{
|
||||
title : 'Clear Logs',
|
||||
icon : 'icon-trash',
|
||||
command : 'clearLog',
|
||||
successMessage : 'Logs have been cleared',
|
||||
errorMessage : 'Failed to clear logs',
|
||||
ownerContext : this,
|
||||
onSuccess : this._refreshLogs
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
right :
|
||||
[
|
||||
rightSideButtons
|
||||
],
|
||||
context: this
|
||||
}));
|
||||
},
|
||||
|
||||
_refreshLogs: function () {
|
||||
this.collection.state.currentPage = 1;
|
||||
this.collection.fetch({ reset: true });
|
||||
this._showTable();
|
||||
}
|
||||
});
|
||||
});
|
||||
11
UI/System/Logs/Table/LogsTableLayoutTemplate.html
Normal file
11
UI/System/Logs/Table/LogsTableLayoutTemplate.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<div id="x-toolbar"/>
|
||||
<div class="row">
|
||||
<div class="span10">
|
||||
<div id="x-grid"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span10">
|
||||
<div id="x-pager"/>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user