mirror of
https://github.com/Sonarr/Sonarr
synced 2025-02-24 15:11:27 +00: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
|
@ -22,8 +22,8 @@ module.exports = function (grunt) {
|
||||||
'src/UI/JsLibraries/backbone.backgrid.paginator.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/extensions/paginator/backgrid-paginator.js',
|
'src/UI/JsLibraries/backbone.backgrid.paginator.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/extensions/paginator/backgrid-paginator.js',
|
||||||
'src/UI/JsLibraries/backbone.backgrid.filter.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/extensions/filter/backgrid-filter.js',
|
'src/UI/JsLibraries/backbone.backgrid.filter.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/extensions/filter/backgrid-filter.js',
|
||||||
|
|
||||||
'src/UI/JsLibraries/backbone.backgrid.selectall.js' : 'http://raw.github.com/wyuenho/backgrid-select-all/master/backgrid-select-all.js',
|
'src/UI/JsLibraries/backbone.backgrid.selectall.js' : 'http://raw.github.com/wyuenho/backgrid-select-all/master/backgrid-select-all.js',
|
||||||
'src/UI/Content/Backgrid/selectall.css' : 'http://raw.github.com/wyuenho/backgrid-select-all/master/backgrid-select-all.css',
|
'src/UI/Content/Backgrid/selectall.css' : 'http://raw.github.com/wyuenho/backgrid-select-all/master/backgrid-select-all.css',
|
||||||
|
|
||||||
'src/UI/JsLibraries/backbone.validation.js' : 'https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation.js',
|
'src/UI/JsLibraries/backbone.validation.js' : 'https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation.js',
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,12 @@ namespace NzbDrone.Api.Frontend
|
||||||
if (context.Request.Path.StartsWith("/signalr", StringComparison.CurrentCultureIgnoreCase)) return false;
|
if (context.Request.Path.StartsWith("/signalr", StringComparison.CurrentCultureIgnoreCase)) return false;
|
||||||
if (context.Request.Path.EndsWith("app.js")) return false;
|
if (context.Request.Path.EndsWith("app.js")) return false;
|
||||||
|
|
||||||
|
if (context.Request.Path.StartsWith("/log", StringComparison.CurrentCultureIgnoreCase) &&
|
||||||
|
context.Request.Path.EndsWith(".txt", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (context.Response != null)
|
if (context.Response != null)
|
||||||
{
|
{
|
||||||
if (context.Response.ContentType.Contains("text/html")) return false;
|
if (context.Response.ContentType.Contains("text/html")) return false;
|
||||||
|
|
|
@ -14,7 +14,7 @@ define(
|
||||||
var date = this.model.get(this.column.get('name'));
|
var date = this.model.get(this.column.get('name'));
|
||||||
|
|
||||||
if (date) {
|
if (date) {
|
||||||
this.$el.html("<span title='" + Moment(date).format('LLLL') + "' >" + FormatHelpers.dateHelper(date) + "</span");
|
this.$el.html('<span title="' + Moment(date).format('LLLL') + '" >' + FormatHelpers.dateHelper(date) + '</span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -101,4 +101,8 @@ td.episode-status-cell, td.quality-cell {
|
||||||
.queue-status-cell {
|
.queue-status-cell {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
text-align: center !important;
|
text-align: center !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-log-cell {
|
||||||
|
width: 80px;
|
||||||
}
|
}
|
|
@ -40,7 +40,7 @@ define(
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateExamples: function () {
|
_updateExamples: function () {
|
||||||
|
//TODO: make this use events/listeners
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var promise = $.ajax({
|
var promise = $.ajax({
|
||||||
|
|
|
@ -4,5 +4,14 @@ define(
|
||||||
'backbone'
|
'backbone'
|
||||||
], function (Backbone) {
|
], function (Backbone) {
|
||||||
return Backbone.Model.extend({
|
return Backbone.Model.extend({
|
||||||
|
url: function () {
|
||||||
|
return '/log/' + this.get('filename');
|
||||||
|
},
|
||||||
|
|
||||||
|
parse: function (contents) {
|
||||||
|
var response = {};
|
||||||
|
response.contents = contents;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
17
src/UI/System/Logs/Files/DownloadLogCell.js
Normal file
17
src/UI/System/Logs/Files/DownloadLogCell.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
'use strict';
|
||||||
|
define(
|
||||||
|
[
|
||||||
|
'Cells/NzbDroneCell'
|
||||||
|
], function (NzbDroneCell) {
|
||||||
|
return NzbDroneCell.extend({
|
||||||
|
|
||||||
|
className: 'download-log-cell',
|
||||||
|
|
||||||
|
render: function () {
|
||||||
|
this.$el.empty();
|
||||||
|
this.$el.html('<a href="/log/{0}" class="no-router" target="_blank">Download</a>'.format(this.cellValue));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -6,13 +6,25 @@ define(
|
||||||
'backgrid',
|
'backgrid',
|
||||||
'System/Logs/Files/FilenameCell',
|
'System/Logs/Files/FilenameCell',
|
||||||
'Cells/RelativeDateCell',
|
'Cells/RelativeDateCell',
|
||||||
|
'System/Logs/Files/DownloadLogCell',
|
||||||
'System/Logs/Files/LogFileCollection',
|
'System/Logs/Files/LogFileCollection',
|
||||||
'System/Logs/Files/Row',
|
'System/Logs/Files/Row',
|
||||||
'System/Logs/Files/ContentsView',
|
'System/Logs/Files/ContentsView',
|
||||||
'System/Logs/Files/ContentsModel',
|
'System/Logs/Files/ContentsModel',
|
||||||
'Shared/Toolbar/ToolbarLayout',
|
'Shared/Toolbar/ToolbarLayout',
|
||||||
'Shared/LoadingView'
|
'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({
|
return Marionette.Layout.extend({
|
||||||
template: 'System/Logs/Files/LogFileLayoutTemplate',
|
template: 'System/Logs/Files/LogFileLayoutTemplate',
|
||||||
|
|
||||||
|
@ -33,35 +45,30 @@ define(
|
||||||
name : 'lastWriteTime',
|
name : 'lastWriteTime',
|
||||||
label: 'Last Write Time',
|
label: 'Last Write Time',
|
||||||
cell : RelativeDateCell
|
cell : RelativeDateCell
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'filename',
|
||||||
|
label : '',
|
||||||
|
cell : DownloadLogCell,
|
||||||
|
sortable: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.collection = new LogFileCollection();
|
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);
|
App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
|
||||||
|
this.listenTo(this.collection, 'sync', this._collectionSynced);
|
||||||
|
|
||||||
|
this.collection.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
this._fetchAndShow();
|
|
||||||
this._showToolbar();
|
this._showToolbar();
|
||||||
this._showTable();
|
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 () {
|
_showToolbar: function () {
|
||||||
|
|
||||||
var rightSideButtons = {
|
var rightSideButtons = {
|
||||||
|
@ -104,31 +111,37 @@ define(
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_showLogFile: function (options) {
|
_collectionSynced: function () {
|
||||||
this.contents.show(new LoadingView());
|
if (!this.collection.any()) {
|
||||||
|
|
||||||
if (!options.model) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var model = this.collection.first();
|
||||||
var filename = options.model.get('filename');
|
this._fetchLogFileContents({ model: model });
|
||||||
|
},
|
||||||
|
|
||||||
$.ajax({
|
_fetchLogFileContents: function (options) {
|
||||||
url: '/log/' + filename,
|
this.contents.show(new LoadingView());
|
||||||
success: function (data) {
|
|
||||||
var model = new ContentsModel({
|
|
||||||
filename: filename,
|
|
||||||
contents: data
|
|
||||||
});
|
|
||||||
|
|
||||||
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 () {
|
_refreshLogs: function () {
|
||||||
this._fetchAndShow();
|
this.contents.close();
|
||||||
|
this.collection.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
_commandComplete: function (options) {
|
_commandComplete: function (options) {
|
||||||
|
|
Loading…
Reference in a new issue