|
|
|
@ -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) {
|
|
|
|
|