From 1c2b0faaad58d407cad1209b40b95fe532f65f73 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sun, 8 Sep 2024 22:30:22 +1200 Subject: [PATCH] implement new environment metrics chart --- src/index.js | 6 + src/public/index.html | 314 +++++++++++++++++++++++------------------- 2 files changed, 179 insertions(+), 141 deletions(-) diff --git a/src/index.js b/src/index.js index cf704fc..a63a626 100644 --- a/src/index.js +++ b/src/index.js @@ -231,6 +231,8 @@ app.get('/api/v1/nodes/:nodeId/environment-metrics', async (req, res) => { const nodeId = parseInt(req.params.nodeId); const count = req.query.count ? parseInt(req.query.count) : undefined; + const timeFrom = req.query.time_from ? parseInt(req.query.time_from) : undefined; + const timeTo = req.query.time_to ? parseInt(req.query.time_to) : undefined; // find node const node = await prisma.node.findFirst({ @@ -251,6 +253,10 @@ app.get('/api/v1/nodes/:nodeId/environment-metrics', async (req, res) => { const environmentMetrics = await prisma.environmentMetric.findMany({ where: { node_id: node.node_id, + created_at: { + gte: timeFrom ? new Date(timeFrom) : undefined, + lte: timeTo ? new Date(timeTo) : undefined, + }, }, orderBy: { id: 'desc', diff --git a/src/public/index.html b/src/public/index.html index 5abb232..844de5c 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -879,60 +879,67 @@
-
Environment Metrics
+
+
Environment Metrics
+
+ +
+