Address on markers and on graph

public/javascripts/chart_utilities.js
   - add address in #addSensorID'
   - function 'addAddress' added

public/javascripts/datetime.js
   - removed unnecessary comment

public/javascripts/global.js
   - refreshrate changed to 5 min
   - typo 'autohide' corrected

views/index.pug
   - removed text 'only for live ...'

views/layout.pug
   - removed superflous links and variables

public/javascripts/maps.js
   - added address to marker popup

charts/preparecharts.js
   - translate legend texts

public/javascripts/showcharts.js
   - dont show selected tab

public/stylesheets/style.sass
   - add style for sensornumber on chart

loclae/[de|en]/translation.json
    - added translations for legend

charts/utilities.js
   - ymax for live set to 120
This commit is contained in:
rxf
2023-06-02 17:16:12 +02:00
parent c32761ed46
commit a596ee557e
14 changed files with 64 additions and 125 deletions
+17 -56
View File
@@ -3,7 +3,7 @@
import * as dt from './datetime.js'
import * as utils from "./chart_utilities.js"
import { showChart, loadAll } from './showcharts.js'
import {fetchfromserver} from "./chart_utilities.js";
import {fetchfromserver, addAddress} from "./chart_utilities.js";
let map = null
let bounds
@@ -51,28 +51,6 @@ export async function showMap(params) {
let lastdate = await buildMarkers(params)
showLastDate(lastdate);
// map.on('popupopen', function () {
// let link = document.querySelector('.speciallink')
// link.addEventListener('click', async function (ev) {
// console.log(`Event clicked: ${clickedSensor}`)
// utils.showTabs()
// document.querySelector('#odth').style.display = 'none'
// document.querySelector('#nbday').style.display = 'inline'
// params.sid = clickedSensor
// let triggerEl = document.querySelector('#livetab')
// bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
// localStorage.setItem('activeTab', 'livetab')
// utils.setCurrentTab('livetab')
// let ok = await showChart(params, 'live', 'dlive')
// if (ok) {
// await loadAll(params)
// }
// params.center = [clickedcoords.lat, clickedcoords.lng]
// map.setView([clickedcoords.lat, clickedcoords.lng]);
// ev.preventDefault()
// })
// })
}
@@ -208,7 +186,6 @@ export async function buildMarkers(params) {
indoor: x.indoor
})
.on('click', e => onMarkerClick(e, true, sensors.popuptxt, params)) // define click- and
.bindPopup(popuptext); // and bind the popup text
markers.addLayer(marker);
}
map.addLayer(markers);
@@ -246,42 +223,26 @@ return popuptext
async function onMarkerClick(e, click, txts, params) {
let item = e.target.options;
let popup = e.target.getPopup();
let popuptext = await bauPopupText(item, txts)
popup.setContent(popuptext); // set text into popup
e.target.openPopup(); // show the popup
let link = document.querySelector('.speciallink')
link.addEventListener('click', async function (ev) {
console.log(`Event clicked: ${clickedSensor}`)
params.sid = item.name
let ok = await showChart(params, 'live', 'dlive')
if (ok) {
params.center = [clickedcoords.lat, clickedcoords.lng]
map.setView([clickedcoords.lat, clickedcoords.lng]);
ev.preventDefault()
await loadAll(params)
}
})
// if (click == true) { // if we clicked
// e.target.closePopup(); // show the popup
// }
e.target.bindPopup(popuptext).openPopup(); // show the popup
let link = document.querySelector('.speciallink')
link.addEventListener('click', async function (ev) {
console.log(`Event clicked: ${clickedSensor}`)
params.sid = item.name
let ok = await showChart(params, 'live', 'dlive')
if (ok) {
let triggerEl = document.querySelector(`#livetab`)
bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
utils.setCurrentTab('livetab')
params.center = [e.latlng.lat, e.latlng.lng]
map.setView([e.latlng.lat, e.latlng.lng]);
ev.preventDefault()
await loadAll(params)
}
})
}
// add address to PopUp
async function addAddress(sid) {
let url = `/api/getaddress?sensorid=${sid}`
let erg = await fetchfromserver(url)
if (!erg.err) {
return erg.address
} else {
return "no address"
}
}
/*
async function getCoords(city) {
let url = NOMINATIM_URL + city;