better text for action

This commit is contained in:
Girish Ramakrishnan
2016-04-30 19:49:50 -07:00
parent 5c2a650681
commit fd1a00d280
4 changed files with 46 additions and 10 deletions

View File

@@ -210,6 +210,46 @@ app.filter('markdown2html', function () {
};
});
// keep this in sync with eventlog.js
var ACTION_ACTIVATE = 'cloudron.activate';
var ACTION_APP_CONFIGURE = 'app.configure';
var ACTION_APP_INSTALL = 'app.install';
var ACTION_APP_RESTORE = 'app.restore';
var ACTION_APP_UNINSTALL = 'app.uninstall';
var ACTION_APP_UPDATE = 'app.update';
var ACTION_BACKUP = 'cloudron.backup';
var ACTION_CLI_MODE = 'settings.climode';
var ACTION_PROFILE = 'user.profile';
var ACTION_REBOOT = 'cloudron.reboot';
var ACTION_UPDATE = 'cloudron.update';
var ACTION_USER_ADD = 'user.add';
var ACTION_USER_REMOVE = 'user.remove';
var ACTION_USER_UPDATE = 'user.update';
app.filter('eventLogDetails', function() {
return function(eventLog) {
var data = eventLog.data;
switch (eventLog.action) {
case ACTION_ACTIVATE: return 'Cloudron activated by ' + data.username;
case ACTION_APP_CONFIGURE: return 'App at location ' + data.location + ' was re-configured';
case ACTION_APP_INSTALL: return 'App ' + data.appStoreId + '@' + data.version + ' installed at ' + data.location + ' with id ' + data.id;
case ACTION_APP_RESTORE: return 'App ' + data.id + ' restored';
case ACTION_APP_UNINSTALL: return 'App ' + data.id + ' uninstalled';
case ACTION_APP_UPDATE: return 'App ' + data.id + ' updated to version ' + data.appStoreId + '@' + data.toVersion;
case ACTION_BACKUP: return 'Backup';
case ACTION_CLI_MODE: return 'CLI mode was ' + (data.enabled ? 'enabled' : 'disabled');
case ACTION_PROFILE: return 'User profile change';
case ACTION_REBOOT: return 'Reboot';
case ACTION_UPDATE: return 'Update';
case ACTION_USER_ADD: return 'User ' + data.email + ' added';
case ACTION_USER_REMOVE: return 'User ' + (data.username || data.id) + ' removed';
case ACTION_USER_UPDATE: return 'User ' + (data.username || data.id) + ' updated';
default: return eventLog.action;
}
};
});
// custom directive for dynamic names in forms
// See http://stackoverflow.com/questions/23616578/issue-registering-form-control-with-interpolated-name#answer-23617401
app.directive('laterName', function () { // (2)

View File

@@ -15,18 +15,16 @@
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="col-md-1">Time</th>
<th class="col-md-1">Action</th>
<th class="col-md-1">Source</th>
<th class="col-md-5">Details</th>
<th class="col-md-2">Time</th>
<th class="col-md-2">Source</th>
<th class="col-md-6">Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="eventLog in eventLogs">
<td>{{ eventLog.creationTime | prettyDate }}</td>
<th scope="row">{{ eventLog.action }}</td>
<th scope="row">{{ eventLog.creationTime | prettyDate }}</td>
<td>{{ eventLog.source.username }} ({{ eventLog.source.ip }})</td>
<td>{{ eventLog.details }}</td>
<td>{{ eventLog | eventLogDetails }}</td>
</tr>
</tbody>
</table>

View File

@@ -10,9 +10,6 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca
if (error) return console.error(error);
$scope.eventLogs = eventLogs;
$scope.eventLogs.forEach(function (e) {
e.details = Object.keys(e.data).map(function (k) { return k + ':' + e.data[k]; }).join(' ');
});
});
}