Log file changes

New: Update log files are available in the UI
Fixed: UI error after clearing log files
This commit is contained in:
Mark McDowall
2014-06-24 16:52:07 -07:00
parent 66873b04d4
commit f5d46ffcd2
20 changed files with 282 additions and 85 deletions

View File

@@ -1,12 +1,11 @@
'use strict';
define(
[
'backbone',
'System/StatusModel'
], function (Backbone, StatusModel) {
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
url: function () {
return StatusModel.get('urlBase') + '/api/log/file/' + this.get('filename');
return this.get('contentsUrl');
},
parse: function (contents) {

View File

@@ -1,16 +1,15 @@
'use strict';
define(
[
'Cells/NzbDroneCell',
'System/StatusModel'
], function (NzbDroneCell, StatusModel) {
'../../../Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({
className: 'download-log-cell',
render: function () {
this.$el.empty();
this.$el.html('<a href="{0}/logfile/{1}" class="no-router" target="_blank">Download</a>'.format(StatusModel.get('urlBase'), this.cellValue));
this.$el.html('<a href="{0}" class="no-router" target="_blank">Download</a>'.format(this.cellValue));
return this;
}

View File

@@ -1,7 +1,7 @@
'use strict';
define(
[
'Cells/NzbDroneCell'
'../../../Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({

View File

@@ -7,7 +7,6 @@ define(
'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',
@@ -20,7 +19,6 @@ define(
FilenameCell,
RelativeDateCell,
DownloadLogCell,
LogFileCollection,
LogFileRow,
ContentsView,
ContentsModel,
@@ -48,18 +46,19 @@ define(
cell : RelativeDateCell
},
{
name : 'filename',
name : 'downloadUrl',
label : '',
cell : DownloadLogCell,
sortable: false
}
],
initialize: function () {
this.collection = new LogFileCollection();
initialize: function (options) {
this.collection = options.collection;
this.deleteFilesCommand = options.deleteFilesCommand;
vent.on(vent.Commands.ShowLogFile, this._fetchLogFileContents, this);
vent.on(vent.Events.CommandComplete, this._commandComplete, this);
this.listenTo(vent, vent.Commands.ShowLogFile, this._fetchLogFileContents);
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
this.listenTo(this.collection, 'sync', this._collectionSynced);
this.collection.fetch();
@@ -83,11 +82,10 @@ define(
ownerContext : this,
callback : this._refreshTable
},
{
title : 'Delete Log Files',
icon : 'icon-trash',
command : 'deleteLogFiles',
command : this.deleteFilesCommand,
successMessage : 'Log files have been deleted',
errorMessage : 'Failed to delete log files'
}
@@ -125,11 +123,7 @@ define(
this.contents.show(new LoadingView());
var model = options.model;
var filename = model.get('filename');
var contentsModel = new ContentsModel({
filename: filename
});
var contentsModel = new ContentsModel(model.toJSON());
this.listenToOnce(contentsModel, 'sync', this._showDetails);
@@ -151,7 +145,7 @@ define(
},
_commandComplete: function (options) {
if (options.command.get('name') === 'deletelogfiles') {
if (options.command.get('name') === this.deleteFilesCommand.toLowerCase()) {
this._refreshTable();
}
}

View File

@@ -1,7 +1,7 @@
'use strict';
define(
[
'vent',
'../../../vent',
'backgrid'
], function (vent, Backgrid) {

View File

@@ -3,24 +3,29 @@ define(
[
'marionette',
'System/Logs/Table/LogsTableLayout',
'System/Logs/Files/LogFileLayout'
], function (Marionette, LogsTableLayout, LogsFileLayout) {
'System/Logs/Files/LogFileLayout',
'System/Logs/Files/LogFileCollection',
'System/Logs/Updates/LogFileCollection'
], function (Marionette, LogsTableLayout, LogsFileLayout, LogFileCollection, UpdateLogFileCollection) {
return Marionette.Layout.extend({
template: 'System/Logs/LogsLayoutTemplate',
ui: {
tableTab: '.x-table-tab',
filesTab: '.x-files-tab'
tableTab : '.x-table-tab',
filesTab : '.x-files-tab',
updateFilesTab : '.x-update-files-tab'
},
regions: {
table: '#table',
files: '#files'
table : '#table',
files : '#files',
updateFiles : '#update-files'
},
events: {
'click .x-table-tab': '_showTable',
'click .x-files-tab': '_showFiles'
'click .x-table-tab' : '_showTable',
'click .x-files-tab' : '_showFiles',
'click .x-update-files-tab' : '_showUpdateFiles'
},
onShow: function () {
@@ -42,7 +47,22 @@ define(
}
this.ui.filesTab.tab('show');
this.files.show(new LogsFileLayout());
this.files.show(new LogsFileLayout({
collection: new LogFileCollection(),
deleteFilesCommand: 'deleteLogFiles'
}));
},
_showUpdateFiles: function (e) {
if (e) {
e.preventDefault();
}
this.ui.updateFilesTab.tab('show');
this.updateFiles.show(new LogsFileLayout({
collection: new UpdateLogFileCollection(),
deleteFilesCommand: 'deleteUpdateLogFiles'
}));
}
});
});

View File

@@ -1,15 +1,17 @@
<div class="row">
<div class="col-md-1 col-sm-2">
<div class="col-md-2 col-sm-2">
<ul class="nav nav-pills nav-stacked">
<li><a href="#table" class="x-table-tab no-router">Table</a></li>
<li><a href="#files" class="x-files-tab no-router">Files</a></li>
<li><a href="#update-files" class="x-update-files-tab no-router">Updates</a></li>
</ul>
</div>
<div class="col-md-11 col-sm-10">
<div class="col-md-10 col-sm-10">
<div class="tab-content">
<div class="tab-pane" id="table"></div>
<div class="tab-pane" id="files"></div>
<div class="tab-pane" id="update-files"></div>
</div>
</div>
</div>

View File

@@ -0,0 +1,17 @@
'use strict';
define(
[
'backbone',
'System/Logs/Updates/LogFileModel'
], function (Backbone, LogFileModel) {
return Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/log/file/update',
model: LogFileModel,
state: {
sortKey: 'lastWriteTime',
order : 1
}
});
});

View File

@@ -0,0 +1,8 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});