diff --git a/public/javascripts/chart_utilities.js b/public/javascripts/chart_utilities.js index 6996455..4b5d4c2 100644 --- a/public/javascripts/chart_utilities.js +++ b/public/javascripts/chart_utilities.js @@ -4,7 +4,6 @@ import {DateTime} from './luxon.min.js' export const colors = {'eq': '#0000FF', 'max': '#FF0000', 'min': '#008000', 'peaks': '#DAA520'}; // Defaults für die Mittelwertbildungen -const refreshRate = 5; // Grafik so oft auffrischen (in Minuten) let txtMeldung = false; // falls keine Daten da sind, Text melden const avgTime = 30; // defaul average time für particulate matter let doUpdate = true; // update every 5 min diff --git a/public/javascripts/datetime.js b/public/javascripts/datetime.js index 9dae8dc..aa99aa8 100644 --- a/public/javascripts/datetime.js +++ b/public/javascripts/datetime.js @@ -1,13 +1,25 @@ // all date and time functions import { DateTime } from './luxon.min.js' +import {loadAll, showChart, setNoUTC} from './showcharts.js' +import {getCurrentTab} from "./chart_utilities.js"; + // Show date and time (every minute) -export const showDate = (sofort) => { +// Will be called every second +export const showDate = (sofort, params) => { let d = DateTime.now() if(sofort || d.second === 0) { document.querySelector('#h1datum').innerHTML = d.toFormat('yyyy-MM-dd HH:mm') } - + if (((d.minute % params.refreshRate) == 0) && (d.second == 15)) { // alle ganzen refreshRate Minuten, 15sec danach + let start = 1 + console.log(params.refreshRate, 'Minuten um, Grafik wird erneuert'); + let ct = getCurrentTab() + if (ct === 'maptab') { + start = 0 + } + loadAll(params, start) + } } /* ToDo: diff --git a/public/javascripts/global.js b/public/javascripts/global.js index 9c522eb..099d628 100644 --- a/public/javascripts/global.js +++ b/public/javascripts/global.js @@ -22,8 +22,8 @@ import {setCurrentTab, getCurrentTab, showError, fetchfromserver} from "./chart_ weeks: 4, datetime: '', seldate: '', - refresh: 0, - sid: '' + refreshRate: 1, + sid: -1 } // END global variables @@ -154,9 +154,9 @@ import {setCurrentTab, getCurrentTab, showError, fetchfromserver} from "./chart_ }) }) - dt.showDate(true) + dt.showDate(true, params) // and show date/time every minute - setInterval(() => dt.showDate(false), 1000) + setInterval(() => dt.showDate(false, params), 1000) const csid = parseInt(sysparams.csid) if(csid !== -1) { diff --git a/routes/api.js b/routes/api.js index d36c5e3..039eaec 100644 --- a/routes/api.js +++ b/routes/api.js @@ -15,7 +15,7 @@ const disttable = [ {type: 'map', func: prep.mapData }, ] -let APIHOST = process.env.APIHOST || 'http://localhost:3004' +let APIHOST = process.env.APIHOST || 'http://localhost:3005' /* GET home page. */