Sprach- und Stadt-Wechsel geht wieder
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
Changes ab AUG-23
|
||||||
|
|
||||||
|
- i18n in /:sid in idex.js rein
|
||||||
|
- Messung und Anzeige auf Console der Ladezeit der 5 Pages im Hintergrund
|
||||||
|
|
||||||
Generated
+1182
-1014
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "laerm-web-sensorapi",
|
"name": "laerm-web-sensorapi",
|
||||||
"version": "3.1.3",
|
"version": "3.1.4",
|
||||||
"date": "2024-08-02 14:15 UTC",
|
"date": "2024-08-14 14:15 UTC",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node bin/www.js >>/var/log/noise.log 2>&1"
|
"start": "node bin/www.js >>/var/log/noise.log 2>&1"
|
||||||
|
|||||||
@@ -7,5 +7,9 @@ if (!selectedLang) {
|
|||||||
} else {
|
} else {
|
||||||
currentLang = selectedLang
|
currentLang = selectedLang
|
||||||
}
|
}
|
||||||
window.location.href = '/?lng=' + currentLang
|
if (sensorid !== '') {
|
||||||
|
window.location.href = `/${sensorid}?lng=${currentLang}`
|
||||||
|
} else {
|
||||||
|
window.location.href = `?lng=${currentLang}`
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import * as utils from "./chart_utilities.js";
|
|||||||
typ: 'maptab',
|
typ: 'maptab',
|
||||||
show: ['ccity', 'odth'],
|
show: ['ccity', 'odth'],
|
||||||
val: ['centercity', 'olderthan'],
|
val: ['centercity', 'olderthan'],
|
||||||
param: ['center.name', 'weeks']
|
param: [["center","name"], 'weeks']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
typ: 'livetab',
|
typ: 'livetab',
|
||||||
@@ -78,8 +78,14 @@ import * as utils from "./chart_utilities.js";
|
|||||||
if(elem.type === 'checkbox') {
|
if(elem.type === 'checkbox') {
|
||||||
val = elem.checked
|
val = elem.checked
|
||||||
}
|
}
|
||||||
|
let x = setting[i].param[j]
|
||||||
|
console.log('x: ', x)
|
||||||
|
if ( Array.isArray(x)) {
|
||||||
|
params[setting[i].param[j][0]][setting[i].param[j][1]] = val
|
||||||
|
} else {
|
||||||
params[setting[i].param[j]] = val
|
params[setting[i].param[j]] = val
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export const tabtable = [
|
|||||||
{id: 'ldentab', type: 'lden', container: 'dlden', func: showChart, div: 1, dformat: "dd.LL"},
|
{id: 'ldentab', type: 'lden', container: 'dlden', func: showChart, div: 1, dformat: "dd.LL"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
export async function showChart(params, typ, container) {
|
export async function showChart(params, typ, container) {
|
||||||
function form() {
|
function form() {
|
||||||
for (let item of tabtable) {
|
for (let item of tabtable) {
|
||||||
@@ -60,6 +59,7 @@ export async function showChart(params, typ, container) {
|
|||||||
} else if ((typ === 'havg') || (typ === 'davg')) {
|
} else if ((typ === 'havg') || (typ === 'davg')) {
|
||||||
url += `&peak=${params.peak}`
|
url += `&peak=${params.peak}`
|
||||||
}
|
}
|
||||||
|
console.log(`fetch ${typ} from server ${url}`)
|
||||||
let erg = await fetchfromserver(url)
|
let erg = await fetchfromserver(url)
|
||||||
if (!erg.err) {
|
if (!erg.err) {
|
||||||
if(sysparams.category === 'noise') {
|
if(sysparams.category === 'noise') {
|
||||||
@@ -91,33 +91,41 @@ export async function showChart(params, typ, container) {
|
|||||||
}).add();
|
}).add();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return true
|
return {error: false}
|
||||||
} else {
|
} else {
|
||||||
showError(erg.err)
|
// showError(erg.err)
|
||||||
return false
|
return {error: erg.err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadAll = async (params, start = 2) => {
|
export const loadAll = async (params, start = 2) => {
|
||||||
console.log('now load all in Background')
|
console.log('now load all in Background')
|
||||||
|
let messzeit = DateTime.now()
|
||||||
if (start == 0) {
|
if (start == 0) {
|
||||||
map.showMap(params)
|
map.showMap(params)
|
||||||
start++
|
start++
|
||||||
}
|
}
|
||||||
if (params.sid !== -1) {
|
if (params.sid !== -1) {
|
||||||
for (let i = start; i < tabtable.length; i++) {
|
for (let i = start; i < tabtable.length; i++) {
|
||||||
let ok = await showChart(params, tabtable[i].type, tabtable[i].container)
|
let err = await showChart(params, tabtable[i].type, tabtable[i].container)
|
||||||
if (!ok) {
|
if (err.error) {
|
||||||
|
if(tabtable[i].type !== 'live') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let dauer = DateTime.now().diff(messzeit,['seconds']).toObject().seconds
|
||||||
|
console.log(`now all loaded. Zeitdauer: ${dauer}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setNoUTC = () => {
|
export const setNoUTC = () => {
|
||||||
Highcharts.setOptions({
|
Highcharts.setOptions({
|
||||||
global: {
|
global: {
|
||||||
useUTC: false // Don't use UTC on the charts
|
useUTC: false // Don't use UTC on the charts
|
||||||
|
},
|
||||||
|
accessibility: { // supress warning concerning accessability
|
||||||
|
enabled: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+14
-9
@@ -7,7 +7,7 @@ const { name, version, date } = pkg
|
|||||||
|
|
||||||
const renderOpts = (sid, cat) => {
|
const renderOpts = (sid, cat) => {
|
||||||
let tit = 'Feinstaub'
|
let tit = 'Feinstaub'
|
||||||
if(cat === 'multigeiger') {
|
if (cat === 'multigeiger') {
|
||||||
tit = 'Geiger'
|
tit = 'Geiger'
|
||||||
} else if (cat == 'noise') {
|
} else if (cat == 'noise') {
|
||||||
tit = 'Noise'
|
tit = 'Noise'
|
||||||
@@ -15,7 +15,7 @@ const renderOpts = (sid, cat) => {
|
|||||||
return {
|
return {
|
||||||
title: tit,
|
title: tit,
|
||||||
version: version,
|
version: version,
|
||||||
date: date.slice(0,10),
|
date: date.slice(0, 10),
|
||||||
csensor: sid,
|
csensor: sid,
|
||||||
category: cat
|
category: cat
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ const translate = (x) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getIndex = (cat) => {
|
const getIndex = (cat) => {
|
||||||
if (cat == 'noise'){
|
if (cat == 'noise') {
|
||||||
return 'index_noise'
|
return 'index_noise'
|
||||||
} else if (cat === 'multigeiger') {
|
} else if (cat === 'multigeiger') {
|
||||||
return 'index_geiger'
|
return 'index_geiger'
|
||||||
@@ -39,10 +39,10 @@ const getIndex = (cat) => {
|
|||||||
/* GET home page. If there is no parameter 'lng=xx', check stored language and call
|
/* GET home page. If there is no parameter 'lng=xx', check stored language and call
|
||||||
te page again with correct language (chglang.js))
|
te page again with correct language (chglang.js))
|
||||||
*/
|
*/
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function (req, res, next) {
|
||||||
// req.i18n.changeLanguage('de')
|
// req.i18n.changeLanguage('de')
|
||||||
if(req.query.lng === undefined) {
|
if (req.query.lng === undefined) {
|
||||||
res.render('chglang')
|
res.render('chglang', {sensorid: ''})
|
||||||
} else {
|
} else {
|
||||||
i18n = req.i18n
|
i18n = req.i18n
|
||||||
let opts = renderOpts(-1, req.app.get('category'))
|
let opts = renderOpts(-1, req.app.get('category'))
|
||||||
@@ -58,15 +58,20 @@ router.get('/', function(req, res, next) {
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
||||||
router.get('/:sid', async function(req, res, next) {
|
router.get('/:sid', async function (req, res, next) {
|
||||||
const sid = req.params.sid
|
const sid = req.params.sid
|
||||||
let opts
|
let opts
|
||||||
if(isNaN(sid)) {
|
if (req.query.lng === undefined) {
|
||||||
|
res.render('chglang', { sensorid: sid })
|
||||||
|
} else {
|
||||||
|
i18n = req.i18n
|
||||||
|
if (isNaN(sid)) {
|
||||||
opts = renderOpts(-1, req.app.get('category'))
|
opts = renderOpts(-1, req.app.get('category'))
|
||||||
} else {
|
} else {
|
||||||
opts = renderOpts(sid, req.app.get('category'))
|
opts = renderOpts(sid, req.app.get('category'))
|
||||||
}
|
}
|
||||||
res.render(getIndex(opts.category), opts)
|
res.render(getIndex(opts.category), opts)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
//export default router
|
//export default router
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ html
|
|||||||
title= title
|
title= title
|
||||||
meta(name="viewport" content="width=device-width, initial-scale=1" charset="utf-8")
|
meta(name="viewport" content="width=device-width, initial-scale=1" charset="utf-8")
|
||||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
link(rel='stylesheet', href='/stylesheets/style.css')
|
||||||
|
script.
|
||||||
|
const sensorid = '#{sensorid}';
|
||||||
|
|
||||||
body
|
body
|
||||||
#first
|
#first
|
||||||
h1 Loading...
|
h1 Loading...
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ block content
|
|||||||
button#btnSave.btn.btn-primary(type="button" data-bs-dismiss="modal") #{t("Save_changes")}
|
button#btnSave.btn.btn-primary(type="button" data-bs-dismiss="modal") #{t("Save_changes")}
|
||||||
|
|
||||||
|
|
||||||
// Error-Dialog
|
// Reset-Dialog
|
||||||
.modal.fade#dialogReset(tabindex="-1" role="dialog" aria-labelledby="Error" aria-hidden="true")
|
.modal.fade#dialogReset(tabindex="-1" role="dialog" aria-labelledby="Error" aria-hidden="true")
|
||||||
.modal-dialog.modal-dialog-centered(role="document")
|
.modal-dialog.modal-dialog-centered(role="document")
|
||||||
.modal-content
|
.modal-content
|
||||||
|
|||||||
Reference in New Issue
Block a user