Test
This commit is contained in:
parent
c6b5c66546
commit
e39e53fbdd
|
@ -179,8 +179,21 @@ router.get('/delete/:cardNumber', async (req, res) => { // Delete ACL entry. Fai
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/bulk-add', async (req, res) => { // Render form to bulk add ACL entries
|
router.get('/bulk-add', async (req, res) => { // Render form to bulk add ACL entries
|
||||||
res.render('acl-bulk-add', { user: req.session.user });
|
doorList = {}
|
||||||
|
await db.query('SHOW COLUMNS FROM ACL;').then(columns => {
|
||||||
|
columns.forEach(col => {
|
||||||
|
if (col.Field !== 'Name' && col.Field !== 'CardNumber' && col.Field !== 'PIN' && col.Field !== 'StartDate' && col.Field !== 'EndDate') {
|
||||||
|
doorList[col.Field] = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
log.error(`Database error fetching ACL columns: ${err}`);
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
res.render('acl-bulk-add', { user: req.session.user, doorList });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
router.post('/bulk-add', async (req, res) => { // Process bulk add of ACL entries
|
router.post('/bulk-add', async (req, res) => { // Process bulk add of ACL entries
|
||||||
const data = req.body;
|
const data = req.body;
|
||||||
|
@ -230,4 +243,18 @@ router.post('/bulk-add', async (req, res) => { // Process bulk add of ACL entrie
|
||||||
return res.status(200).json({ results });
|
return res.status(200).json({ results });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.ws("/bulk-add", (ws, req) => {
|
||||||
|
log.debug(`Client ${req.sessionID} connected to ACL bulk add WebSocket`);
|
||||||
|
if (!req.session.user) {
|
||||||
|
ws.send(JSON.stringify({ error: 'Not authenticated' }))
|
||||||
|
ws.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global.dbEvent.on('event', (event) => {
|
||||||
|
if (event.EventType != 1 || event.Granted != 0) return; // Only process 'Swipe' events that were denied
|
||||||
|
ws.send(JSON.stringify(event));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
Loading…
Reference in a new issue