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