From e3bf5855ab670d4a395d641b50e4b9a9a249c77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20X=2E=20F=C3=BCrst?= Date: Mon, 27 Nov 2023 17:26:29 +0000 Subject: [PATCH] remove 'noise_' from values Trigger live tab, if sensorid is given --- .vscode/launch.json | 7 ++++++- charts/preparecharts.js | 12 ++++++------ public/javascripts/global.js | 5 ++++- routes/api.js | 2 ++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 95ab75c..ac98f4e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,12 @@ ], "program": "${workspaceFolder}/bin/www.js", "env": { - "APIHOST": "https://sensorapi.fuerst-stuttgart.de" + // "APIHOST": "http://reception:3000", + // "MONGOHOST": "reception", + // "MONGOUSRP": "admin:mongo4noise", + // "MONGOAUTH": "true", + // "INFLUXHOST": "reception", + // "INFLUXTOKEN": "gHGGgjaK0lmM6keMa01JeuDpqOE_vRq8UimsU4QKb2miI5BDh2PfWynEbwKizdJapXy8jVbTat5mVZLQTNmSdw==", } } ] diff --git a/charts/preparecharts.js b/charts/preparecharts.js index 5656e41..bcf5b7f 100644 --- a/charts/preparecharts.js +++ b/charts/preparecharts.js @@ -24,17 +24,17 @@ export const liveData = (params, values, req) => { let cnt = 0 values.forEach((x) => { let dat = new Date(x.datetime).getTime() - series1.push([dat, x.values.noise_LAeq]) - series2.push([dat, x.values.noise_LA_max]) - series3.push([dat, x.values.noise_LA_min]) // put data and value into series array + series1.push([dat, x.LAeq]) + series2.push([dat, x.LA_max]) + series3.push([dat, x.LA_min]) // put data and value into series array }) if (values.length != 0) { const lastidx = values.length - 1 // Aktuelle Werte speichern - aktVal['LAeq'] = values[lastidx].values.noise_LAeq - aktVal['LAMax'] = values[lastidx].values.noise_LA_max - aktVal['LAMin'] = values[lastidx].values.noise_LA_min + aktVal['LAeq'] = values[lastidx].LAeq + aktVal['LAMax'] = values[lastidx].LA_max + aktVal['LAMin'] = values[lastidx].LA_min // InfoTafel füllen infoTafel = diff --git a/public/javascripts/global.js b/public/javascripts/global.js index b29f0b4..7255116 100644 --- a/public/javascripts/global.js +++ b/public/javascripts/global.js @@ -167,8 +167,11 @@ import {setCurrentTab, getCurrentTab, showError, fetchfromserver} from "./chart_ return } params.sid = csid - let ok = await showChart(params, 'live', 'dlive') + let t = triggerTabList[1] + let tt = new bootstrap.Tab(t) + tt.show() setCurrentTab('livetab') + let ok = await showChart(params, 'live', 'dlive') if (ok) { await loadAll(params) } diff --git a/routes/api.js b/routes/api.js index 48447f3..daa81fc 100644 --- a/routes/api.js +++ b/routes/api.js @@ -38,8 +38,10 @@ router.get('/:cmd', async function(req, res, next) { // if called as '/api' then directly return the data if ((calledAs === '/api') || (cmd === 'getoneproperty') || (cmd === 'getaddress')) { if(pretty) { + res.setHeader('Content-Type', 'text/plain; charset=utf-8'); res.send(JSON.stringify(response.data,null,2)) } else { + res.setHeader('Content-Type', 'application/json; charset=utf-8'); res.json(response.data) } return