add activity view

This commit is contained in:
Girish Ramakrishnan
2016-04-30 18:57:55 -07:00
parent 43051cea3b
commit 5c2a650681
5 changed files with 76 additions and 0 deletions

View File

@@ -169,6 +169,7 @@
<ul class="dropdown-menu" role="menu">
<li><a href="#/account"><i class="fa fa-user fa-fw"></i> Account</a></li>
<li ng-show="user.admin"><a href="#/graphs"><i class="fa fa-bar-chart fa-fw"></i> Graphs</a></li>
<li ng-show="user.admin"><a href="#/activity"><i class="fa fa-list-alt fa-fw"></i> Activity</a></li>
<li><a href="#/support"><i class="fa fa-comment fa-fw"></i> Support</a></li>
<li ng-show="user.admin && config.isCustomDomain"><a href="#/certs"><i class="fa fa-certificate fa-fw"></i> DNS & Certs</a></li>
<li ng-show="user.admin"><a href="#/settings"><i class="fa fa-wrench fa-fw"></i> Settings</a></li>

View File

@@ -379,6 +379,20 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.getEventLogs = function (page, perPage, callback) {
var config = {
params: {
page: page,
per_page: perPage
}
};
$http.get(client.apiOrigin + '/api/v1/eventlog', config).success(function (data, status) {
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
callback(null, data.eventlogs);
}).error(defaultErrorHandler(callback));
};
Client.prototype.getApps = function (callback) {
$http.get(client.apiOrigin + '/api/v1/apps').success(function (data, status) {
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));

View File

@@ -48,6 +48,9 @@ app.config(['$routeProvider', function ($routeProvider) {
}).when('/settings', {
controller: 'SettingsController',
templateUrl: 'views/settings.html'
}).when('/activity', {
controller: 'ActivityController',
templateUrl: 'views/activity.html'
}).when('/support', {
controller: 'SupportController',
templateUrl: 'views/support.html'

View File

@@ -0,0 +1,35 @@
<br/>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1>Activity Log</h1>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="card card-block" style="max-width: 100%">
<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>
</tr>
</thead>
<tbody>
<tr ng-repeat="eventLog in eventLogs">
<td>{{ eventLog.creationTime | prettyDate }}</td>
<th scope="row">{{ eventLog.action }}</td>
<td>{{ eventLog.source.username }} ({{ eventLog.source.ip }})</td>
<td>{{ eventLog.details }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

View File

@@ -0,0 +1,23 @@
'use strict';
angular.module('Application').controller('ActivityController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
$scope.config = Client.getConfig();
$scope.eventLogs = [ ];
function fetchEventLogs() {
Client.getEventLogs(1, 20, function (error, eventLogs) {
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(' ');
});
});
}
Client.onReady(function () {
fetchEventLogs();
});
}]);