mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Log files are viewable in the UI
This commit is contained in:
parent
a9ac2500d5
commit
4c536a077f
21 changed files with 325 additions and 40 deletions
13
UI/Logs/Files/Collection.js
Normal file
13
UI/Logs/Files/Collection.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
define(['Logs/Files/Model' ],
|
||||
function (LogFileModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url : window.ApiRoot + '/log/files',
|
||||
model: LogFileModel,
|
||||
|
||||
state: {
|
||||
sortKey : 'lastWriteTime',
|
||||
order : 1
|
||||
}
|
||||
});
|
||||
});
|
8
UI/Logs/Files/ContentsModel.js
Normal file
8
UI/Logs/Files/ContentsModel.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
11
UI/Logs/Files/ContentsView.js
Normal file
11
UI/Logs/Files/ContentsView.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette'
|
||||
], function (App, Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Logs/Files/ContentsViewTemplate'
|
||||
});
|
||||
});
|
11
UI/Logs/Files/ContentsViewTemplate.html
Normal file
11
UI/Logs/Files/ContentsViewTemplate.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div class="row">
|
||||
<div class="span12">
|
||||
<h3>{{filename}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<pre>{{contents}}</pre>
|
||||
</div>
|
||||
</div>
|
18
UI/Logs/Files/FilenameCell.js
Normal file
18
UI/Logs/Files/FilenameCell.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'log-filename-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var filename = this._getValue();
|
||||
this.$el.html(filename);
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
79
UI/Logs/Files/Layout.js
Normal file
79
UI/Logs/Files/Layout.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Logs/Files/FilenameCell',
|
||||
'Cells/RelativeDateCell',
|
||||
'Logs/Files/Collection',
|
||||
'Logs/Files/Row',
|
||||
'Logs/Files/ContentsView',
|
||||
'Logs/Files/ContentsModel'
|
||||
], function (App, Marionette, Backgrid, FilenameCell, RelativeDateCell, LogFileCollection, LogFileRow, ContentsView, ContentsModel) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Logs/Files/LayoutTemplate',
|
||||
|
||||
regions: {
|
||||
grid : '#x-grid',
|
||||
contents : '#x-contents'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'filename',
|
||||
label: 'Filename',
|
||||
cell : FilenameCell
|
||||
},
|
||||
{
|
||||
name : 'lastWriteTime',
|
||||
label: 'Last Write Time',
|
||||
cell : RelativeDateCell
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new LogFileCollection();
|
||||
this.collectionPromise = this.collection.fetch();
|
||||
|
||||
App.vent.on(App.Commands.ShowLogFile, this._showLogFile, this);
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
var self = this;
|
||||
this._showTable();
|
||||
|
||||
this.collectionPromise.done(function (){
|
||||
self._showLogFile({ model: _.first(self.collection.models) });
|
||||
});
|
||||
},
|
||||
|
||||
_showTable: function () {
|
||||
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row : LogFileRow,
|
||||
columns : this.columns,
|
||||
collection: this.collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
},
|
||||
|
||||
_showLogFile: function (options) {
|
||||
var self = this;
|
||||
var filename = options.model.get('filename');
|
||||
|
||||
$.ajax({
|
||||
url: '/log/' + filename,
|
||||
success: function (data) {
|
||||
var model = new ContentsModel({
|
||||
filename: filename,
|
||||
contents: data
|
||||
});
|
||||
|
||||
self.contents.show(new ContentsView({ model: model }));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
11
UI/Logs/Files/LayoutTemplate.html
Normal file
11
UI/Logs/Files/LayoutTemplate.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div class="row">
|
||||
<div class="span12">
|
||||
<div id="x-grid"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<div id="x-contents"/>
|
||||
</div>
|
||||
</div>
|
8
UI/Logs/Files/Model.js
Normal file
8
UI/Logs/Files/Model.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
19
UI/Logs/Files/Row.js
Normal file
19
UI/Logs/Files/Row.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'backgrid'
|
||||
], function (App, Backgrid) {
|
||||
|
||||
return Backgrid.Row.extend({
|
||||
className: 'log-file-row',
|
||||
|
||||
events: {
|
||||
'click': '_showContents'
|
||||
},
|
||||
|
||||
_showContents: function () {
|
||||
App.vent.trigger(App.Commands.ShowLogFile, { model: this.model });
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue