Skip to content

Commit 31bac37

Browse files
committed
Merge branch 'activity-logging' into 'development'
Activity logging See merge request !12
2 parents 2c41ec6 + d5102ae commit 31bac37

22 files changed

+734
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
module.exports = ['$http', 'apiUrl',
2+
function ($http, apiUrl) {
3+
4+
var controllerUrl = apiUrl + 'EventLog/';
5+
6+
// GET
7+
// Browse Events.
8+
function browseEvents(options) {
9+
10+
var queryParameters = {};
11+
12+
if (options) {
13+
if (options.pageIndex) {
14+
queryParameters['pageIndex'] = options.pageIndex;
15+
}
16+
17+
if (options.pageSize) {
18+
queryParameters['pageSize'] = options.pageSize;
19+
}
20+
21+
if (options.eventType) {
22+
queryParameters['eventType'] = options.eventType;
23+
}
24+
25+
if (options.severity) {
26+
queryParameters['severity'] = options.severity;
27+
}
28+
}
29+
30+
var queryString = buildQueryString(queryParameters);
31+
32+
// Make request.
33+
return $http.get(controllerUrl + 'Browse' + queryString).then(
34+
function (response) {
35+
36+
// Return unpacked data.
37+
return response.data;
38+
});
39+
}
40+
41+
// GET
42+
// Get event types.
43+
function getEventTypes() {
44+
45+
// Make request.
46+
return $http.get(controllerUrl + 'EventTypes').then(
47+
function (response) {
48+
49+
// Return unpacked data.
50+
return response.data;
51+
});
52+
}
53+
54+
// Builds a query string from the passed object.
55+
function buildQueryString(queryParams) {
56+
57+
var queryString = '';
58+
59+
// Loop properties.
60+
for (var paramName in queryParams) {
61+
62+
// Is it the first parameter?
63+
if (queryString.length === 0) {
64+
65+
// Yes, use '?'.
66+
queryString = queryString + '?';
67+
} else {
68+
69+
// No, use '&'.
70+
queryString = queryString + '&';
71+
}
72+
73+
// Add parameter.
74+
queryString = queryString + paramName + '=' + queryParams[paramName];
75+
}
76+
77+
return queryString;
78+
}
79+
80+
return {
81+
browseEvents: browseEvents,
82+
getEventTypes: getEventTypes
83+
};
84+
85+
}];

PolyDeploy/Clients/Manage/src/css/main.less

+38
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,44 @@
88

99
#cantarus-poly-deploy {
1010

11+
.can-pagination {
12+
position: relative;
13+
height: 20px;
1114

15+
.prev, .next {
16+
position: absolute;
17+
height: 100%;
18+
width: 20px;
19+
top: 0;
20+
text-align: center;
21+
line-height: 30px;
22+
cursor: pointer;
23+
}
1224

25+
.prev {
26+
left: 0;
27+
}
28+
29+
.next {
30+
right: 0;
31+
}
32+
33+
.pages {
34+
list-style: none;
35+
margin: 0 20px;
36+
text-align: center;
37+
38+
li {
39+
display: inline-block;
40+
line-height: 20px;
41+
padding: 0 5px;
42+
margin: 0 5px;
43+
cursor: pointer;
44+
45+
&.current {
46+
font-weight: bold;
47+
}
48+
}
49+
}
50+
}
1351
}

PolyDeploy/Clients/Manage/src/js/config.js

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
url: '/whitelist',
2424
template: require('./templates/whitelist.html'),
2525
controller: 'WhitelistController'
26+
})
27+
.state('menu.events', {
28+
url: '/events',
29+
template: require('./templates/events.html'),
30+
controller: 'EventsController'
2631
});
2732

2833
// Add $http interceptor for DNN Services Framework.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
module.exports = ['$scope', 'EventLogDataService',
2+
function ($scope, EventLogDataService) {
3+
4+
// Defaults.
5+
var options = {
6+
pageIndex: 0,
7+
pageSize: 10,
8+
eventType: undefined,
9+
severity: undefined
10+
};
11+
12+
// Initialise scope variables.
13+
$scope.currentPage = 1;
14+
$scope.pageCount = 1;
15+
$scope.eventLogs = [];
16+
17+
// Add functions to scope.
18+
$scope.hasNextPage = hasNextPage;
19+
$scope.hasPrevPage = hasPrevPage;
20+
$scope.nextPage = nextPage;
21+
$scope.prevPage = prevPage;
22+
$scope.loadPage = loadPage;
23+
$scope.getPages = getPages;
24+
25+
// Fetch first page.
26+
fetchEvents(options);
27+
28+
// Fetch events.
29+
function fetchEvents(opts) {
30+
31+
// Load events based on options.
32+
EventLogDataService.browseEvents(opts).then(
33+
function (response) {
34+
35+
// Place the events on the scope.
36+
$scope.eventLogs = response.Data;
37+
38+
// Place page count on scope.
39+
$scope.pageCount = response.Pagination.Pages;
40+
41+
});
42+
}
43+
44+
// Is there a next page?
45+
function hasNextPage() {
46+
return $scope.currentPage < $scope.pageCount;
47+
}
48+
49+
// Is there a previous page?
50+
function hasPrevPage() {
51+
return $scope.currentPage > 1;
52+
}
53+
54+
// Load the next page.
55+
function nextPage() {
56+
57+
// Is there a next page?
58+
if (hasNextPage()) {
59+
60+
// Yes, increment and fetch events.
61+
$scope.currentPage++;
62+
63+
options.pageIndex = $scope.currentPage - 1;
64+
65+
fetchEvents(options);
66+
}
67+
}
68+
69+
// Load the next page.
70+
function prevPage() {
71+
72+
// Is there a previous page?
73+
if (hasPrevPage()) {
74+
75+
// Yes, decrement and fetch events.
76+
$scope.currentPage--;
77+
78+
options.pageIndex = $scope.currentPage - 1;
79+
80+
fetchEvents(options);
81+
}
82+
}
83+
84+
// Load specified page.
85+
function loadPage(pageNo) {
86+
87+
// Page exists?
88+
if (pageNo > 0 && pageNo <= $scope.pageCount) {
89+
90+
$scope.currentPage = pageNo;
91+
92+
options.pageIndex = pageNo - 1;
93+
94+
fetchEvents(options);
95+
}
96+
}
97+
98+
// Get array for pagination.
99+
function getPages(number) {
100+
return new Array(number);
101+
}
102+
103+
}];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<div id="users">
2+
3+
<!-- Content -->
4+
<div class="row">
5+
6+
<!-- Events Table -->
7+
<div class="col-xs-12">
8+
<div class="panel panel-default">
9+
<div class="panel-heading">
10+
<h3 class="panel-title">Event Logs</h3>
11+
</div>
12+
<div class="panel-body">
13+
<table class="table table-striped table-bordered">
14+
<thead>
15+
<tr>
16+
<th>Date</th>
17+
<th>Type</th>
18+
<th>Message</th>
19+
</tr>
20+
</thead>
21+
<tbody>
22+
<tr ng-repeat="eventLog in eventLogs">
23+
<td>{{ eventLog.Date }}</td>
24+
<td>{{ eventLog.EventType }}</td>
25+
<td>{{ eventLog.Message }}</td>
26+
</tr>
27+
</tbody>
28+
</table>
29+
30+
<!-- Pagination -->
31+
<div class="can-pagination">
32+
<span class="prev"
33+
ng-click="prevPage()"
34+
ng-disable="hasPrevPage()"><</span>
35+
<ul class="pages">
36+
<li ng-repeat="i in getPages(pageCount) track by $index"
37+
ng-click="loadPage($index+1)"
38+
ng-class="{ current: $index+1 === currentPage }">{{ $index+1 }}</li>
39+
</ul>
40+
<span class="next"
41+
ng-click="nextPage()"
42+
ng-disable="hasNextPage()">></span>
43+
</div>
44+
<!-- /Pagination -->
45+
</div>
46+
</div>
47+
</div>
48+
<!-- /Events Table -->
49+
50+
</div>
51+
<!-- /Content -->
52+
53+
</div>

PolyDeploy/Clients/Manage/src/js/templates/menu.html

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<li><a ui-sref="menu.welcome">Welcome</a></li>
99
<li><a ui-sref="menu.users">API Users</a></li>
1010
<li><a ui-sref="menu.whitelist">IP Whitelist</a></li>
11+
<li><a ui-sref="menu.events">Event Log</a></li>
1112
</ul>
1213
</div>
1314
<!-- /Menu -->

0 commit comments

Comments
 (0)