Settings split according to chart

routes/api.js
   - check type of sensor
   - translate error message

app.js
   - debug = false at i18n

public/javascripts/chart_utilities.js
   - setter/getter for current Tab

public/javascripts/global.js
   - settings dialog completely rearranged
   - if only sensorid is given, check type

routes/index.js
   - set language to global variable

views/index.pug
   - reaggange settings dialog
   - translate 'Error'

views/layout.pug
   - load new datepicker (vanillajs-datepicker)

public/javascripts/map.js
   - fetching from server refactored to function
   - reenable tabs after leaving map

charts/preparecharts
   - typo

public/javascripts/showcharts.js
   - loadAll extended to  load also live and map

public/stylesheets/style.sass
   - a few changes for settinds dialog

locales/[de|en]
   - added a few words

charts/utilities.js
   - setter and getter for language
This commit is contained in:
rxf
2023-05-09 16:10:07 +02:00
parent 58e25bf468
commit 4cea325f56
16 changed files with 190 additions and 106 deletions
+20 -13
View File
@@ -2,7 +2,7 @@ import {logerror} from "./logit.js";
import * as utils from "./chart_utilities.js";
import { DateTime } from './luxon.min.js'
import * as map from "./map.js";
import {showError} from "./chart_utilities.js";
import {fetchfromserver, showError} from "./chart_utilities.js";
// table to distribute the different charts
export const tabtable = [
@@ -55,13 +55,13 @@ export async function showChart(params, typ, container) {
return this.axis.defaultLabelFormatter.call(this);
}
}
const curlang = localStorage.getItem('curlang')
const url = `/api/getsensordata?sensorid=${params.sid}&data=${typ}&span=${params.span}&datetime=${params.datetime.slice(0,-10)}&peak=${params.peak}&lng=en`
let ret = await fetch(url)
.catch(e => {
logerror(e)
});
let erg = await ret.json()
let url = `/api/getsensordata?sensorid=${params.sid}&data=${typ}&datetime=${params.datetime}`
if (typ === 'live') {
url += `&span=${params.span}`
} else if ((typ === 'havg') || (typ === 'davg')) {
url += `&peak=${params.peak}`
}
let erg = await fetchfromserver(url)
if (!erg.err) {
erg.options.xAxis.labels.formatter = xformat
erg.options.tooltip.formatter = form
@@ -96,12 +96,19 @@ export async function showChart(params, typ, container) {
}
}
export const loadAll = async (params) => {
export const loadAll = async (params, start = 2) => {
console.log('now load all in Background')
for (let i = 1; i < tabtable.length; i++) {
let ok = await showChart(params, tabtable[i].type, tabtable[i].container)
if (!ok) {
break;
if (start == 0) {
map.showMap(params)
start++
}
if (params.sid !== -1) {
utils.showTabs()
for (let i = start; i < tabtable.length; i++) {
let ok = await showChart(params, tabtable[i].type, tabtable[i].container)
if (!ok) {
break;
}
}
}
}