Test replacing those?
This commit is contained in:
parent
c7874c19a6
commit
7c6a99b6a6
|
@ -4,15 +4,73 @@ const db = global.db;
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const expressWs = require('express-ws')(router);
|
const expressWs = require('express-ws')(router);
|
||||||
// GET /login
|
// GET /login
|
||||||
|
|
||||||
|
dataTypes = {
|
||||||
|
DoorMode: {
|
||||||
|
1: 'NormallyOpen',
|
||||||
|
2: 'NormallyClosed',
|
||||||
|
3: 'Controlled'
|
||||||
|
},
|
||||||
|
|
||||||
|
Direction: {
|
||||||
|
1: 'In',
|
||||||
|
2: 'Out'
|
||||||
|
},
|
||||||
|
EventType: {
|
||||||
|
0: 'None',
|
||||||
|
1: 'Swipe',
|
||||||
|
2: 'Door',
|
||||||
|
3: 'Alarm',
|
||||||
|
255: 'Overwritten'
|
||||||
|
},
|
||||||
|
|
||||||
|
EventReason: {
|
||||||
|
0: 'None',
|
||||||
|
1: 'Swipe',
|
||||||
|
2: 'SwipeOpen',
|
||||||
|
3: 'SwipeClose',
|
||||||
|
5: 'Denied',
|
||||||
|
6: 'NoAccessRights',
|
||||||
|
7: 'IncorrectPassword',
|
||||||
|
8: 'AntiPassback',
|
||||||
|
9: 'MoreCards',
|
||||||
|
10: 'FirstCardOpen',
|
||||||
|
11: 'DoorIsNormallyClosed',
|
||||||
|
12: 'Interlock',
|
||||||
|
13: 'NotInAllowedTimePeriod',
|
||||||
|
15: 'InvalidTimezone',
|
||||||
|
18: 'AccessDenied',
|
||||||
|
20: 'PushbuttonOk',
|
||||||
|
23: 'DoorOpened',
|
||||||
|
24: 'DoorClosed',
|
||||||
|
25: 'DoorOpenedSupervisorPassword',
|
||||||
|
28: 'ControllerPowerOn',
|
||||||
|
29: 'ControllerReset',
|
||||||
|
31: 'PushbuttonInvalidDoorLocked',
|
||||||
|
32: 'PushbuttonInvalidOffline',
|
||||||
|
33: 'PushbuttonInvalidInterlock',
|
||||||
|
34: 'PushbuttonInvalidThreat',
|
||||||
|
37: 'DoorOpenTooLong',
|
||||||
|
38: 'ForcedOpen',
|
||||||
|
39: 'Fire',
|
||||||
|
40: 'ForcedClosed',
|
||||||
|
41: 'TheftPrevention',
|
||||||
|
42: 'Zone24x7',
|
||||||
|
43: 'Emergency',
|
||||||
|
44: 'RemoteOpenDoor',
|
||||||
|
45: 'RemoteOpenDoorUSBReader'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
router.get('/', async (req, res) => {
|
router.get('/', async (req, res) => {
|
||||||
const logs = await db.query('SELECT * FROM Events ORDER BY EventIndex DESC LIMIT 100');
|
const logs = await db.query('SELECT * FROM Events ORDER BY EventIndex DESC LIMIT 100');
|
||||||
res.render('event-logs', { logs, user: req.session.user });
|
res.render('event-logs', { logs, user: req.session.user, dataTypes });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.ws('/', (ws, req) => {
|
router.ws('/', (ws, req) => {
|
||||||
log.debug(`Client ${req.sessionID} connected to event logs WebSocket`);
|
log.debug(`Client ${req.sessionID} connected to event logs WebSocket`);
|
||||||
if (!req.session.user) {
|
if (!req.session.user) {
|
||||||
ws.send(JSON.stringify({ error: 'Not authenticated' }))
|
ws.send(JSON.stringify({ error: 'Not authenticated' }))
|
||||||
ws.close();
|
ws.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
<th>Granted</th>
|
<th>Granted</th>
|
||||||
<th>Door</th>
|
<th>Door</th>
|
||||||
<th>Direction</th>
|
<th>Direction</th>
|
||||||
<th>Card Number</th>
|
<th>Data</th>
|
||||||
<th>Reason</th>
|
<th>Reason</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -102,12 +102,12 @@
|
||||||
%>
|
%>
|
||||||
<%= `${yyyy}-${mm}-${dd} ${HH}:${MM}:${ss} ${tz}` %>
|
<%= `${yyyy}-${mm}-${dd} ${HH}:${MM}:${ss} ${tz}` %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= log.Type %></td>
|
<td><%= dataTypes.EventType[log.Type] %></td>
|
||||||
<td><%= log.Granted %></td>
|
<td><%= log.Granted ? "True" : "False" %></td>
|
||||||
<td><%= log.Door %></td>
|
<td><%= log.Door %></td>
|
||||||
<td><%= log.Direction %></td>
|
<td><%= dataTypes.Direction[log.Direction] %></td>
|
||||||
<td><%= log.CardNumber %></td>
|
<td><%= log.CardNumber %></td>
|
||||||
<td><%= log.Reason %></td>
|
<td><%= dataTypes.EventReason[log.Reason] %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in a new issue