Spinner eingebaut
Fehlermeldungen pro TAB getrennt
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
|
||||
import * as map from './map.js'
|
||||
import * as dt from './datetime.js'
|
||||
import {loadAll, showChart, setNoUTC} from './showcharts.js'
|
||||
import {loadAll, showChart, setNoUTC, tabtable} from './showcharts.js'
|
||||
import { DateTime } from './luxon.min.js'
|
||||
import {setCurrentTab, getCurrentTab, showError, fetchfromserver, cityCoords} from "./chart_utilities.js";
|
||||
import * as utils from "./chart_utilities.js";
|
||||
import {ttIndex, setCurrentTab, getCurrentTab, showError, fetchfromserver, cityCoords} from "./chart_utilities.js";
|
||||
import * as spin from './spinner.js'
|
||||
|
||||
|
||||
(async () => {
|
||||
|
||||
@@ -22,10 +23,9 @@ import * as utils from "./chart_utilities.js";
|
||||
refreshRate: 5,
|
||||
sid: -1
|
||||
}
|
||||
// END global variables
|
||||
|
||||
// localStorage.clear()
|
||||
|
||||
let minDate = new Date(2023, 0, 1)
|
||||
|
||||
const setting = [
|
||||
{
|
||||
typ: 'maptab',
|
||||
@@ -60,6 +60,11 @@ import * as utils from "./chart_utilities.js";
|
||||
param: ['seldate']
|
||||
}
|
||||
]
|
||||
// END global variables
|
||||
|
||||
// localStorage.clear()
|
||||
|
||||
|
||||
// Check new map center
|
||||
const checkNewCenter = (oldC, newC) => {
|
||||
if((oldC[0] !== newC[0]) || (oldC[1] !== newC[1])) {
|
||||
@@ -70,6 +75,7 @@ import * as utils from "./chart_utilities.js";
|
||||
// Register events
|
||||
// Button 'Save' pressed
|
||||
document.querySelector('#btnSave').addEventListener('click', async () => {
|
||||
let curtab = getCurrentTab()
|
||||
for(let i = 0; i < setting.length; i++) {
|
||||
if(setting[i].typ === getCurrentTab()) {
|
||||
for(let j = 0; j < setting[i].show.length; j++) {
|
||||
@@ -89,7 +95,7 @@ import * as utils from "./chart_utilities.js";
|
||||
break
|
||||
}
|
||||
}
|
||||
if (getCurrentTab() !== 'maptab') {
|
||||
if (curtab !== 'maptab') {
|
||||
let starttime
|
||||
if ((params.seldate === 'today') || (params.seldate === 'heute') || (DateTime.now().toFormat('yyyy-MM-dd') === params.seldate)) {
|
||||
starttime = ''
|
||||
@@ -109,7 +115,9 @@ import * as utils from "./chart_utilities.js";
|
||||
if(newlng !== oldlng) {
|
||||
location.reload()
|
||||
}
|
||||
await loadAll(params,0)
|
||||
spin.spinner.spin(spin.spindiv)
|
||||
await loadAll(params,0, curtab)
|
||||
spin.spinner.stop()
|
||||
// ToDo:
|
||||
// Load ALL incl. MAP und LIVE hier, d.h. an loadAll einen zusätzlichen Parameter übergeben
|
||||
// if(params.sid !== undefined) {
|
||||
@@ -138,8 +146,7 @@ import * as utils from "./chart_utilities.js";
|
||||
{
|
||||
dateFormat: 'yy-mm-dd',
|
||||
maxDate: new Date(),
|
||||
minDate: new Date(2023, 0, 1),
|
||||
showButtonPanel: true,
|
||||
minDate: minDate,
|
||||
})
|
||||
)
|
||||
document.getElementById('startday').value = params.seldate
|
||||
@@ -221,18 +228,25 @@ import * as utils from "./chart_utilities.js";
|
||||
triggerEl.addEventListener('click', function (event) {
|
||||
event.preventDefault()
|
||||
tabTrigger.show()
|
||||
setCurrentTab(event.currentTarget.id)
|
||||
if (getCurrentTab() === 'maptab') {
|
||||
let newtab = event.currentTarget.id
|
||||
setCurrentTab(newtab)
|
||||
let tab = tabtable.find(tab => tab.id === newtab)
|
||||
if (document.querySelector(`#${tab.id}err`).innerHTML !== '') { // if there is an error message, clear it
|
||||
showError(document.querySelector(`#${tab.id}err`).innerHTML)
|
||||
}
|
||||
if (newtab === 'maptab') {
|
||||
map.showMap(params)
|
||||
}
|
||||
})
|
||||
})
|
||||
const csid = parseInt(sysparams.csid)
|
||||
if(csid !== -1) {
|
||||
spin.spinner.spin(spin.spindiv)
|
||||
// check, if sid is of right type (noise)
|
||||
const props = await getSensorType(csid)
|
||||
if (props.type !== 'noise') {
|
||||
// wrong sensor type
|
||||
spin.spinner.stop()
|
||||
showError('Sensor ID ' + csid + ' is not of type noise')
|
||||
return
|
||||
}
|
||||
@@ -242,7 +256,8 @@ import * as utils from "./chart_utilities.js";
|
||||
let tt = new bootstrap.Tab(t)
|
||||
tt.show()
|
||||
setCurrentTab('livetab')
|
||||
let ok = await showChart(params, 'live', 'dlive')
|
||||
let ok = await showChart(params, ttIndex.live)
|
||||
spin.spinner.stop()
|
||||
if (ok) {
|
||||
await loadAll(params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user