diff --git a/Gruntfile.js b/Gruntfile.js
index 1e8968fd3..bd0bb243e 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -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.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/Content/Backgrid/selectall.css' : 'http://raw.github.com/wyuenho/backgrid-select-all/master/backgrid-select-all.css',
+ '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/JsLibraries/backbone.validation.js' : 'https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation.js',
diff --git a/src/NzbDrone.Api/Frontend/IsCacheableSpecification.cs b/src/NzbDrone.Api/Frontend/IsCacheableSpecification.cs
index a86768495..aa8dc8e65 100644
--- a/src/NzbDrone.Api/Frontend/IsCacheableSpecification.cs
+++ b/src/NzbDrone.Api/Frontend/IsCacheableSpecification.cs
@@ -24,6 +24,12 @@ namespace NzbDrone.Api.Frontend
if (context.Request.Path.StartsWith("/signalr", StringComparison.CurrentCultureIgnoreCase)) 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.ContentType.Contains("text/html")) return false;
diff --git a/src/UI/Cells/RelativeDateCell.js b/src/UI/Cells/RelativeDateCell.js
index 4f8eb8a30..0ffb11d76 100644
--- a/src/UI/Cells/RelativeDateCell.js
+++ b/src/UI/Cells/RelativeDateCell.js
@@ -14,7 +14,7 @@ define(
var date = this.model.get(this.column.get('name'));
if (date) {
- this.$el.html("" + FormatHelpers.dateHelper(date) + "' + FormatHelpers.dateHelper(date) + '');
}
return this;
diff --git a/src/UI/Cells/cells.less b/src/UI/Cells/cells.less
index b557af740..c85561a67 100644
--- a/src/UI/Cells/cells.less
+++ b/src/UI/Cells/cells.less
@@ -101,4 +101,8 @@ td.episode-status-cell, td.quality-cell {
.queue-status-cell {
width: 20px;
text-align: center !important;
+}
+
+.download-log-cell {
+ width: 80px;
}
\ No newline at end of file
diff --git a/src/UI/Settings/MediaManagement/Naming/View.js b/src/UI/Settings/MediaManagement/Naming/View.js
index 8cd0027d2..1623285fb 100644
--- a/src/UI/Settings/MediaManagement/Naming/View.js
+++ b/src/UI/Settings/MediaManagement/Naming/View.js
@@ -40,7 +40,7 @@ define(
},
_updateExamples: function () {
-
+ //TODO: make this use events/listeners
var self = this;
var promise = $.ajax({
diff --git a/src/UI/System/Logs/Files/ContentsModel.js b/src/UI/System/Logs/Files/ContentsModel.js
index 17c0fd6da..b2c912a7f 100644
--- a/src/UI/System/Logs/Files/ContentsModel.js
+++ b/src/UI/System/Logs/Files/ContentsModel.js
@@ -4,5 +4,14 @@ define(
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
+ url: function () {
+ return '/log/' + this.get('filename');
+ },
+
+ parse: function (contents) {
+ var response = {};
+ response.contents = contents;
+ return response;
+ }
});
});
diff --git a/src/UI/System/Logs/Files/DownloadLogCell.js b/src/UI/System/Logs/Files/DownloadLogCell.js
new file mode 100644
index 000000000..c29335e24
--- /dev/null
+++ b/src/UI/System/Logs/Files/DownloadLogCell.js
@@ -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('Download'.format(this.cellValue));
+
+ return this;
+ }
+ });
+ });
diff --git a/src/UI/System/Logs/Files/LogFileLayout.js b/src/UI/System/Logs/Files/LogFileLayout.js
index 959e1aee3..8af432ce3 100644
--- a/src/UI/System/Logs/Files/LogFileLayout.js
+++ b/src/UI/System/Logs/Files/LogFileLayout.js
@@ -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) {