diff --git a/UI/Logs/Layout.js b/UI/Logs/Layout.js
index f6965761d..fda86cc62 100644
--- a/UI/Logs/Layout.js
+++ b/UI/Logs/Layout.js
@@ -53,19 +53,6 @@ define(
}
],
- leftSideButtons: {
- type : 'default',
- storeState: false,
- items :
- [
- {
- title: 'Files',
- icon : 'icon-file',
- route: 'logs/files'
- }
- ]
- },
-
initialize: function () {
this.collection = new LogCollection();
this.collection.fetch();
@@ -92,13 +79,48 @@ define(
},
_showToolbar: function () {
+ var leftSideButtons = {
+ type : 'default',
+ storeState: false,
+ items :
+ [
+ {
+ title : 'Refresh',
+ icon : 'icon-refresh',
+ ownerContext : this,
+ callback : this._refreshLogs
+ },
+
+ {
+ title : 'Clear Logs',
+ icon : 'icon-trash',
+ command : 'clearLog',
+ successMessage : 'Logs have been cleared',
+ errorMessage : 'Failed to clear logs',
+ ownerContext : this,
+ successCallback: this._refreshLogs
+ },
+
+ {
+ title: 'Files',
+ icon : 'icon-file',
+ route: 'logs/files'
+ }
+ ]
+ };
+
this.toolbar.show(new ToolbarLayout({
left :
[
- this.leftSideButtons
+ leftSideButtons
],
context: this
}));
+ },
+
+ _refreshLogs: function () {
+ this.collection.fetch({ reset: true });
+ this._showTable();
}
});
});
diff --git a/UI/Shared/Toolbar/Button/ButtonView.js b/UI/Shared/Toolbar/Button/ButtonView.js
index be8639a45..8dc30d6c3 100644
--- a/UI/Shared/Toolbar/Button/ButtonView.js
+++ b/UI/Shared/Toolbar/Button/ButtonView.js
@@ -44,8 +44,9 @@ define(
}
},
-
invokeCommand: function () {
+ //TODO: Use Actioneer to handle icon swapping
+
var command = this.model.get('command');
if (command) {
this.idle = false;
@@ -60,18 +61,35 @@ define(
message: self.model.get('successMessage')
});
}
+
+ if (self.model.get('successCallback')) {
+ if (!self.model.ownerContext) {
+ throw 'ownerContext must be set.';
+ }
+
+ self.model.get('successCallback').call(self.model.ownerContext);
+ }
});
commandPromise.fail(function (options) {
if (options.readyState === 0 || options.status === 0) {
return;
}
+
if (self.model.get('errorMessage')) {
Messenger.show({
message: self.model.get('errorMessage'),
type : 'error'
});
}
+
+ if (self.model.get('failCallback')) {
+ if (!self.model.ownerContext) {
+ throw 'ownerContext must be set.';
+ }
+
+ self.model.get('failCallback').call(self.model.ownerContext);
+ }
});
commandPromise.always(function () {
@@ -81,6 +99,14 @@ define(
self.idle = true;
}
});
+
+ if (self.model.get('alwaysCallback')) {
+ if (!self.model.ownerContext) {
+ throw 'ownerContext must be set.';
+ }
+
+ self.model.get('alwaysCallback').call(self.model.ownerContext);
+ }
}
},
@@ -103,7 +129,6 @@ define(
throw 'ownerContext must be set.';
}
-
var callback = this.model.get('callback');
if (callback) {
callback.call(this.model.ownerContext);