Deleting logs will refresh on completion

pull/6/head
Mark McDowall 11 years ago
parent 4dfe201019
commit 0d7097a682

@ -1,6 +1,7 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'marionette', 'marionette',
'backgrid', 'backgrid',
'System/Logs/Table/LogTimeCell', 'System/Logs/Table/LogTimeCell',
@ -9,7 +10,7 @@ define(
'System/Logs/LogsCollection', 'System/Logs/LogsCollection',
'Shared/Toolbar/ToolbarLayout', 'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView' 'Shared/LoadingView'
], function (Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) { ], function (App, Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'System/Logs/Table/LogsTableLayoutTemplate', template: 'System/Logs/Table/LogsTableLayoutTemplate',
@ -57,6 +58,8 @@ define(
initialize: function () { initialize: function () {
this.collection = new LogCollection(); this.collection = new LogCollection();
this.collectionPromise = this.collection.fetch(); this.collectionPromise = this.collection.fetch();
App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
}, },
onRender: function () { onRender: function () {
@ -72,8 +75,6 @@ define(
}); });
}, },
_showTable: function () { _showTable: function () {
this.grid.show(new Backgrid.Grid({ this.grid.show(new Backgrid.Grid({
row : Backgrid.Row, row : Backgrid.Row,
@ -104,11 +105,7 @@ define(
{ {
title : 'Clear Logs', title : 'Clear Logs',
icon : 'icon-trash', icon : 'icon-trash',
command : 'clearLog', command : 'clearLog'
successMessage : 'Logs have been cleared',
errorMessage : 'Failed to clear logs',
ownerContext : this,
onSuccess : this._refreshLogs
} }
] ]
}; };
@ -126,6 +123,12 @@ define(
this.collection.state.currentPage = 1; this.collection.state.currentPage = 1;
this.collection.fetch({ reset: true }); this.collection.fetch({ reset: true });
this._showTable(); this._showTable();
},
_commandComplete: function (options) {
if (options.command.get('name') === 'clearlog') {
this._refreshLogs();
}
} }
}); });
}); });

Loading…
Cancel
Save