diff --git a/public/javascripts/global.js b/public/javascripts/global.js index 2cc2de0..407049f 100644 --- a/public/javascripts/global.js +++ b/public/javascripts/global.js @@ -27,13 +27,10 @@ import { DateTime } from './luxon.min.js' refresh: 0, } - let status = { - loaded: false - } // END global variables // Register events - document.querySelector('#btnSave').addEventListener('click', () => { + document.querySelector('#btnSave').addEventListener('click', async () => { const selDate = document.getElementById('startday').value let starttime if (selDate === 'today') { @@ -52,8 +49,7 @@ import { DateTime } from './luxon.min.js' if(peak < 130 ) { params.peak = peak } - status.loaded = false - + await loadAll(params) }) @@ -82,14 +78,6 @@ import { DateTime } from './luxon.min.js' triggerEl.addEventListener('click', function (event) { event.preventDefault() tabTrigger.show() - if((!status.loaded) || (this.id === 'kartentab')) { - for (let x of tabtable) { - if (x.id === event.currentTarget.id) { - x.func(params, x.type, x.container) - } - } - logit(`tab changed to ${event.currentTarget.id}`) - } }) }) @@ -108,12 +96,11 @@ import { DateTime } from './luxon.min.js' params.sid = csid let ok = await showChart(params, 'live', 'dlive') if (ok) { - loadAll(params) - status.loaded = true + await loadAll(params) } } else { // show the map - map.showMap(params, status) + map.showMap(params) } } diff --git a/public/javascripts/map.js b/public/javascripts/map.js index 8d7f26e..f9a09bb 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -13,7 +13,7 @@ let clickedcoords = {} const colorscale = ['#d53e4f', '#fc8d59', '#fee08b', '#e6f598', '#99d594', '#3288bd', '#808080']; const dba = [100, 80, 60, 40, 20, 0, -999]; -export async function showMap(params, status) { +export async function showMap(params) { utils.removeTabs() if(map && map.remove) { @@ -60,8 +60,7 @@ export async function showMap(params, status) { bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name let ok = await showChart(params, 'live', 'dlive') if (ok) { - loadAll(params) - status.loaded = true + await loadAll(params) } map.setView([clickedcoords.lat, clickedcoords.lng]); }) diff --git a/public/javascripts/showcharts.js b/public/javascripts/showcharts.js index c5f0499..8ef650f 100644 --- a/public/javascripts/showcharts.js +++ b/public/javascripts/showcharts.js @@ -98,7 +98,7 @@ export async function showChart(params, typ, container) { export const loadAll = async (params) => { console.log('now load all in Background') - for (let i = 2; i < tabtable.length; i++) { + for (let i = 1; i < tabtable.length; i++) { let ok = await showChart(params, tabtable[i].type, tabtable[i].container) if (!ok) { break; diff --git a/routes/api.js b/routes/api.js index ff7c174..45df0c5 100644 --- a/routes/api.js +++ b/routes/api.js @@ -32,6 +32,10 @@ router.get('/:cmd', async function(req, res, next) { if (response.status !== 200) { res.json({err: `Error from servercall: status = ${response.status}`}) } + if(response.data.err) { + res.json(response.data) + return + } const options = response.data.options for(let x of disttable) { if (x.type === options.data) {