Viele Updates, Version angepasst
This commit is contained in:
Vendored
+4
-1
@@ -11,7 +11,10 @@
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}/bin/www.js"
|
||||
"program": "${workspaceFolder}/bin/www.js",
|
||||
"env": {
|
||||
"APIHOST": "https://sensorapi.fuerst-stuttgart.de"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
FROM node:18-alpine
|
||||
|
||||
ADD package.json /tmp/package.json
|
||||
RUN cd /tmp && npm install
|
||||
RUN mkdir -p /opt/app && cp -a /tmp/node_modules /tmp/package.json /opt/app/
|
||||
WORKDIR /opt/app
|
||||
ADD . /opt/app/
|
||||
|
||||
RUN apk add --no-cache tzdata
|
||||
ENV TZ Europe/Berlin
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
RUN deluser --remove-home node
|
||||
|
||||
RUN touch cmds.sh \
|
||||
&& echo 'npm start' >>cmds.sh
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD sh ./cmds.sh
|
||||
|
||||
@@ -38,6 +38,9 @@ app.set('view engine', 'pug');
|
||||
|
||||
app.get('*', (req, res, next) => {
|
||||
const subdom = req.headers.host.split('.')
|
||||
if (subdom[0] === 'laerm') {
|
||||
subdom[0] = 'noise'
|
||||
}
|
||||
app.set('category',subdom[0])
|
||||
next()
|
||||
})
|
||||
@@ -49,6 +52,7 @@ app.use(cookieParser());
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use('/api', apiRouter)
|
||||
app.use('/srv', apiRouter)
|
||||
app.use('/', indexRouter.router);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
# Build Docker-Container
|
||||
#
|
||||
# Call: buildit.sh name [target]
|
||||
#
|
||||
# The Dockerfile must be named like Dockerfile_name
|
||||
#
|
||||
# 2018-09-20 rxf
|
||||
# - before sending docker image to remote, tag actual remote image
|
||||
#
|
||||
# 2018-09-14 rxf
|
||||
# - first Version
|
||||
#
|
||||
|
||||
set -x
|
||||
port=""
|
||||
orgName=noise
|
||||
name=noise
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Usage build_and_copy.sh [-p port] [-n name] target"
|
||||
echo " Build docker container $name and copy to target"
|
||||
echo "Params:"
|
||||
echo " target: Where to copy the container to "
|
||||
echo " -p port: ssh port (default 22)"
|
||||
echo " -n name: new name for container (default: $orgName)"
|
||||
}
|
||||
|
||||
while getopts n:p:h? o
|
||||
do
|
||||
case "$o" in
|
||||
n) name="$OPTARG";;
|
||||
p) port="-p $OPTARG";;
|
||||
h) usage; exit 0;;
|
||||
*) usage; exit 1;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
if [[ -z "$target" ]]; then
|
||||
target=$1
|
||||
shift
|
||||
else
|
||||
echo "bad option $1"
|
||||
# exit 1
|
||||
shift
|
||||
fi
|
||||
done
|
||||
|
||||
docker build -f Dockerfile_$orgName -t $name .
|
||||
|
||||
dat=`date +%Y%m%d%H%M`
|
||||
|
||||
if [ "$target" == "localhost" ]
|
||||
then
|
||||
docker tag $name $name:V_$dat
|
||||
exit
|
||||
fi
|
||||
|
||||
ssh $port $target "docker tag $name $name:V_$dat"
|
||||
docker save $name | bzip2 | pv | ssh $port $target 'bunzip2 | docker load'
|
||||
@@ -0,0 +1,5 @@
|
||||
####Neues Sensor-API
|
||||
|
||||
* Programm **sensor_web_api**. Läuft auf Port 3000
|
||||
* Aufruf über: **laerm.test.me:3000** (oder feinstaub.test... oder multigeiger.test...)
|
||||
* Zugriff auf die DB mit dem Programm **SensorApi**. Dieses reagiert auf Port 3005 und muss im Hintergrund laufen!
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "laerm-web-sensorapi",
|
||||
"version": "3.0.4",
|
||||
"date": "2023-04-24 18:00 UTC",
|
||||
"version": "3.0.5",
|
||||
"date": "2023-11-12 10:00 UTC",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node bin/www.js >>log/laerm_web.log 2>&1"
|
||||
"start": "node bin/www.js >>/var/log/noise.log 2>&1"
|
||||
},
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -17,7 +17,7 @@ export const noise_ymin = 30; // lowest value on y-axis for n
|
||||
export const noise_ymax = 120; // highest value on y-axis for noise
|
||||
export let peaklim = 70; // threshold for peak count
|
||||
|
||||
export const url = '/api'
|
||||
export const url = '/srv'
|
||||
|
||||
export function createGlobObtions() {
|
||||
// Options, die für alle Plots identisch sind
|
||||
@@ -217,7 +217,7 @@ export const fetchfromserver = async (url) => {
|
||||
}
|
||||
|
||||
export const addAddress = async (sid) => {
|
||||
let url = `/api/getaddress?sensorid=${sid}`
|
||||
let url = `/srv/getaddress?sensorid=${sid}`
|
||||
let erg = await fetchfromserver(url)
|
||||
if (!erg.err) {
|
||||
return erg.address
|
||||
|
||||
@@ -116,7 +116,7 @@ import {setCurrentTab, getCurrentTab, showError, fetchfromserver} from "./chart_
|
||||
})
|
||||
|
||||
const getSensorType = async (sid) => {
|
||||
let url = `/api/getoneproperty?sensorid=${sid}`
|
||||
let url = `/srv/getoneproperty?sensorid=${sid}`
|
||||
const data = await fetchfromserver(url)
|
||||
return data.props.type
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ const mapparams = {
|
||||
bounds: null,
|
||||
popuptext: '',
|
||||
clickedSensor: 0,
|
||||
APIURL: '/api/getmapdata?',
|
||||
APIURL: '/srv/getmapdata?',
|
||||
MAXZOOM: 19
|
||||
}
|
||||
|
||||
export async function showMap(params) {
|
||||
if(sysparams.category === 'laerm') {
|
||||
if(sysparams.category === 'noise') {
|
||||
utils.removeTabs()
|
||||
if(mapparams.map && mapparams.map.remove) {
|
||||
mapparams.map.off();
|
||||
@@ -36,7 +36,7 @@ export async function showMap(params) {
|
||||
await buildMarkers(params, mapparams)
|
||||
});
|
||||
|
||||
if(sysparams.category === 'laerm') {
|
||||
if(sysparams.category === 'noise'){
|
||||
mapn.buildLegend(mapparams)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export async function showMap(params) {
|
||||
}
|
||||
|
||||
const buildMarkers = async (params, mapparams) => {
|
||||
if(sysparams.category === 'laerm') {
|
||||
if(sysparams.category === 'noise') {
|
||||
return mapn.buildMarkers(params, mapparams)
|
||||
} else if(sysparams.category === 'multigeiger') {
|
||||
return mapg.buildMarkers(params, mapparams)
|
||||
|
||||
@@ -57,9 +57,9 @@ export async function buildMarkers(params, mpp) {
|
||||
if ((params.weeks > 0) && (x.weeks > params.weeks)) {
|
||||
continue
|
||||
}
|
||||
// if (x.value <= -4) {
|
||||
// continue
|
||||
// }
|
||||
if (x.value <= -5) {
|
||||
continue
|
||||
}
|
||||
let marker = L.marker([x.location[1], x.location[0]], {
|
||||
icon: new L.Icon({
|
||||
iconUrl: buildIcon(getColor(parseInt(x.value)), 0, x.indoor),
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as utils from "./chart_utilities.js"
|
||||
import * as dt from './datetime.js'
|
||||
|
||||
function getColor(d, mapparams) {
|
||||
if(sysparams.category === 'laerm') {
|
||||
if(sysparams.category === 'noise') {
|
||||
return mapn.getColor(d, mapparams)
|
||||
} else if(sysparams.category === 'multigeiger') {
|
||||
return mapg.getColor(d, mapparams)
|
||||
|
||||
@@ -55,7 +55,7 @@ export async function showChart(params, typ, container) {
|
||||
return this.axis.defaultLabelFormatter.call(this);
|
||||
}
|
||||
}
|
||||
let url = `/api/getsensordata?sensorid=${params.sid}&data=${typ}&datetime=${params.datetime}`
|
||||
let url = `/srv/getsensordata?sensorid=${params.sid}&data=${typ}&datetime=${params.datetime}`
|
||||
if (typ === 'live') {
|
||||
url += `&span=${params.span}`
|
||||
} else if ((typ === 'havg') || (typ === 'davg')) {
|
||||
@@ -63,7 +63,7 @@ export async function showChart(params, typ, container) {
|
||||
}
|
||||
let erg = await fetchfromserver(url)
|
||||
if (!erg.err) {
|
||||
if(sysparams.category === 'laerm') {
|
||||
if(sysparams.category === 'noise') {
|
||||
utils.showTabs()
|
||||
}
|
||||
document.querySelector('#odth').style.display = 'none'
|
||||
|
||||
+11
-5
@@ -21,12 +21,13 @@ let APIHOST = process.env.APIHOST || 'http://localhost:3005'
|
||||
/* GET home page. */
|
||||
router.get('/:cmd', async function(req, res, next) {
|
||||
// req.i18n.changeLanguage(req.query.lng)
|
||||
const calledAs = req.baseUrl
|
||||
const cmd = req.params.cmd
|
||||
const pretty = (req.query.pretty !== undefined)
|
||||
const lng = getLanguage()
|
||||
let url = APIHOST
|
||||
url += (req.originalUrl + `&lng=${lng}`)
|
||||
let url = APIHOST + '/api' + req.originalUrl.slice(4) + `&lng=${lng}`
|
||||
try {
|
||||
const response = await axios(encodeURI(url));
|
||||
const response = await axios.get(encodeURI(url));
|
||||
if (response.status !== 200) {
|
||||
res.json({err: `${trans('ESYSCALL')} status=${response.status}`})
|
||||
}
|
||||
@@ -34,9 +35,14 @@ router.get('/:cmd', async function(req, res, next) {
|
||||
res.json(response.data)
|
||||
return
|
||||
}
|
||||
if ((cmd === 'getoneproperty') || (cmd === 'getaddress')) {
|
||||
// if called as '/api' then directly return the data
|
||||
if ((calledAs === '/api') || (cmd === 'getoneproperty') || (cmd === 'getaddress')) {
|
||||
if(pretty) {
|
||||
res.send(JSON.stringify(response.data,null,2))
|
||||
} else {
|
||||
res.json(response.data)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
const options = response.data.options
|
||||
for(let x of disttable) {
|
||||
|
||||
+3
-3
@@ -9,8 +9,8 @@ const renderOpts = (sid, cat) => {
|
||||
let tit = 'Feinstaub'
|
||||
if(cat === 'multigeiger') {
|
||||
tit = 'Geiger'
|
||||
} else if (cat == 'laerm') {
|
||||
tit = 'Lärm'
|
||||
} else if (cat == 'noise') {
|
||||
tit = 'Noise'
|
||||
}
|
||||
return {
|
||||
title: tit,
|
||||
@@ -28,7 +28,7 @@ const translate = (x) => {
|
||||
}
|
||||
|
||||
const getIndex = (cat) => {
|
||||
if (cat === 'laerm') {
|
||||
if (cat == 'noise'){
|
||||
return 'index_noise'
|
||||
} else if (cat === 'multigeiger') {
|
||||
return 'index_geiger'
|
||||
|
||||
Reference in New Issue
Block a user