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
+13 -11
View File
@@ -1,6 +1,8 @@
import express from 'express'
import axios from 'axios'
import * as prep from '../charts/preparecharts.js'
import { getLanguage } from '../charts/utilities.js'
import { translate as trans } from '../routes/index.js'
const router = express.Router()
@@ -15,28 +17,28 @@ const disttable = [
let APIHOST = process.env.APIHOST || 'http://localhost:3004'
/* GET home page. */
router.get('/:cmd', async function(req, res, next) {
req.i18n.changeLanguage(req.query.lng)
let l = req.i18n.resolvedLanguage
let txt = req.i18n.t('Settings')
// req.i18n.changeLanguage(req.query.lng)
const cmd = req.params.cmd
const lng = getLanguage()
// console.log('api.js: cmd = ' + cmd + ', language = ' + lng)
let url = APIHOST
if(isNaN(cmd)) {
url += req.originalUrl
} else {
// cmd is a number ==> sid
url += `getsensordata?sid=${cmd}`
}
url += (req.originalUrl + `&lng=${lng}`)
try {
const response = await axios(encodeURI(url));
if (response.status !== 200) {
res.json({err: `Error from servercall: status = ${response.status}`})
res.json({err: `${trans('ESYSCALL')} status=${response.status}`})
}
if(response.data.err) {
res.json(response.data)
return
}
if (cmd === 'getoneproperty') {
res.json(response.data)
return
}
const options = response.data.options
for(let x of disttable) {
if (x.type === options.data) {
@@ -46,7 +48,7 @@ router.get('/:cmd', async function(req, res, next) {
}
}
} catch (e) {
res.json({err: `Error from servercall: ${e}`})
res.json({err: `${trans('ESYSCALL')} ${e}`})
}
})