From 7d0aa00e74b1ed2ea2cab9afaf8eb7b7f9280d3d Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sat, 6 Apr 2019 15:27:13 -0400 Subject: Filter sessions in admin --- src/html/admin.html | 40 ++++++++++++++++++++++++++++------------ src/server.js | 5 +++-- 2 files changed, 31 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/html/admin.html b/src/html/admin.html index 1087b51..01a39b4 100644 --- a/src/html/admin.html +++ b/src/html/admin.html @@ -13,7 +13,7 @@ var feed = new Vue({ el: '#stats', data: { - stats: {session: [], url: []}, + stats: { session: [], url: [] }, showSessionTable: false, showUrlTable: false, showLogData: false, @@ -33,10 +33,10 @@
- +
- Tags: + Tags:
Images: @@ -47,7 +47,7 @@ - +
@@ -59,18 +59,29 @@
- - - - - -
HostTotal Requests
{{item.session.substring(0,10)}}...{{item.c}}
+
+ {{stats.total}} total sessions + + + + + + + + + +
HostTotal Requests
{{item.session.substring(0,10)}}...{{item.c}}
+
- + + + + + @@ -82,7 +93,12 @@
MethodPathTotal Requests
MethodPathTotal Requests
{{item.method}} {{item.url.substring(0, Math.min(30, item.url.length))}}
- + + + + + + diff --git a/src/server.js b/src/server.js index 06a3ec5..eae99e4 100644 --- a/src/server.js +++ b/src/server.js @@ -96,10 +96,11 @@ function setUpRoutes(models, jwtFunctions, database) { }) server.get('/admin/stats', async (req, res, next) => { try { - var sessionResult = await database.query("SELECT session, count(id) as c FROM requests GROUP BY session", { type: database.QueryTypes.SELECT }) + var sessionResult = await database.query("SELECT session, count(id) as c FROM requests GROUP BY session HAVING c > 1", { type: database.QueryTypes.SELECT }) + var total = await database.query("select count(distinct session) as t FROM requests", { type: database.QueryTypes.SELECT }) var urlResult = await database.query("SELECT method, url, count(id) as c FROM requests GROUP BY method, url", { type: database.QueryTypes.SELECT }) var logResult = await database.query("SELECT createdAt, session, method, url FROM requests order by createdAt desc limit 15", { type: database.QueryTypes.SELECT }) - res.status(200).send({ session: sessionResult, url: urlResult, log: logResult }); + res.status(200).send({ total: total[0].t, session: sessionResult, url: urlResult, log: logResult }); next(); } catch (e) { res.status(400).send(e.message); -- cgit v1.2.3
DateSessionMethodPath
DateSessionMethodPath
{{item.createdAt.substring(0,19)}} {{item.session.substring(0,10)}}...