From 2664a3ef52a8299173e7739b32434a6d89a2f259 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 2 Sep 2024 14:06:58 +1200 Subject: [PATCH] implement new power metrics chart for voltage and current --- src/index.js | 6 + src/public/index.html | 387 +++++++++++++++++++----------------------- 2 files changed, 181 insertions(+), 212 deletions(-) diff --git a/src/index.js b/src/index.js index 02c5763..abffab1 100644 --- a/src/index.js +++ b/src/index.js @@ -266,6 +266,8 @@ app.get('/api/v1/nodes/:nodeId/power-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({ @@ -286,6 +288,10 @@ app.get('/api/v1/nodes/:nodeId/power-metrics', async (req, res) => { const powerMetrics = await prisma.powerMetric.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 b12e8ab..d0664ed 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -919,69 +919,67 @@
Power Metrics