mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-13 00:23:59 -07:00
No more caching of log files, also better handling of logs on page load
This commit is contained in:
parent
7d9eaf8cfc
commit
ee2973efe7
8 changed files with 85 additions and 36 deletions
|
@ -6,13 +6,25 @@ define(
|
|||
'backgrid',
|
||||
'System/Logs/Files/FilenameCell',
|
||||
'Cells/RelativeDateCell',
|
||||
'System/Logs/Files/DownloadLogCell',
|
||||
'System/Logs/Files/LogFileCollection',
|
||||
'System/Logs/Files/Row',
|
||||
'System/Logs/Files/ContentsView',
|
||||
'System/Logs/Files/ContentsModel',
|
||||
'Shared/Toolbar/ToolbarLayout',
|
||||
'Shared/LoadingView'
|
||||
], function (App, Marionette, Backgrid, FilenameCell, RelativeDateCell, LogFileCollection, LogFileRow, ContentsView, ContentsModel, ToolbarLayout, LoadingView) {
|
||||
], function (App,
|
||||
Marionette,
|
||||
Backgrid,
|
||||
FilenameCell,
|
||||
RelativeDateCell,
|
||||
DownloadLogCell,
|
||||
LogFileCollection,
|
||||
LogFileRow,
|
||||
ContentsView,
|
||||
ContentsModel,
|
||||
ToolbarLayout,
|
||||
LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Logs/Files/LogFileLayoutTemplate',
|
||||
|
||||
|
@ -33,35 +45,30 @@ define(
|
|||
name : 'lastWriteTime',
|
||||
label: 'Last Write Time',
|
||||
cell : RelativeDateCell
|
||||
},
|
||||
{
|
||||
name : 'filename',
|
||||
label : '',
|
||||
cell : DownloadLogCell,
|
||||
sortable: false
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new LogFileCollection();
|
||||
|
||||
App.vent.on(App.Commands.ShowLogFile, this._showLogFile, this);
|
||||
App.vent.on(App.Commands.ShowLogFile, this._fetchLogFileContents, this);
|
||||
App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
|
||||
this.listenTo(this.collection, 'sync', this._collectionSynced);
|
||||
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this._fetchAndShow();
|
||||
this._showToolbar();
|
||||
this._showTable();
|
||||
},
|
||||
|
||||
_fetchAndShow: function () {
|
||||
var self = this;
|
||||
|
||||
this.contents.close();
|
||||
|
||||
var promise = this.collection.fetch();
|
||||
promise.done(function () {
|
||||
if (self.collection.length > 0) {
|
||||
self._showLogFile({ model: self.collection.first() });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_showToolbar: function () {
|
||||
|
||||
var rightSideButtons = {
|
||||
|
@ -104,31 +111,37 @@ define(
|
|||
}));
|
||||
},
|
||||
|
||||
_showLogFile: function (options) {
|
||||
this.contents.show(new LoadingView());
|
||||
|
||||
if (!options.model) {
|
||||
_collectionSynced: function () {
|
||||
if (!this.collection.any()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var filename = options.model.get('filename');
|
||||
var model = this.collection.first();
|
||||
this._fetchLogFileContents({ model: model });
|
||||
},
|
||||
|
||||
$.ajax({
|
||||
url: '/log/' + filename,
|
||||
success: function (data) {
|
||||
var model = new ContentsModel({
|
||||
filename: filename,
|
||||
contents: data
|
||||
});
|
||||
_fetchLogFileContents: function (options) {
|
||||
this.contents.show(new LoadingView());
|
||||
|
||||
self.contents.show(new ContentsView({ model: model }));
|
||||
}
|
||||
var model = options.model;
|
||||
var filename = model.get('filename');
|
||||
|
||||
var contentsModel = new ContentsModel({
|
||||
filename: filename
|
||||
});
|
||||
|
||||
this.listenToOnce(contentsModel, 'sync', this._showContents);
|
||||
|
||||
contentsModel.fetch({ dataType: 'text' });
|
||||
},
|
||||
|
||||
_showContents: function (model) {
|
||||
this.contents.show(new ContentsView({ model: model }));
|
||||
},
|
||||
|
||||
_refreshLogs: function () {
|
||||
this._fetchAndShow();
|
||||
this.contents.close();
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
_commandComplete: function (options) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue