update So 14. Jun 11:01:01 CEST 2020

This commit is contained in:
Robert Richter 2020-06-14 11:01:01 +02:00
parent c5c1be120f
commit 9bed773384
6 changed files with 41 additions and 23 deletions

11
package-lock.json generated
View File

@ -6546,6 +6546,11 @@
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
}
}
},
@ -7127,9 +7132,9 @@
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
},
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz",
"integrity": "sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg=="
},
"vary": {
"version": "1.1.2",

View File

@ -37,15 +37,15 @@ app.use(bodyParser.urlencoded({
// Scripte einbinden
var sql_cfg = require('./server/sql_cfg')(fs, bcrypt, app_cfg);
var sql = require('./server/sql_qry')(sql_cfg, uuidv4, app_cfg);
var api = '';
var brk = require('./server/broker')(app_cfg, sql, uuidv4);
var proof = require('./server/proof')(app_cfg, sql);
var waip = require('./server/waip')(io, sql, fs, brk, async, app_cfg, api, proof);
var waip = require('./server/waip')(io, sql, fs, brk, async, app_cfg, proof);
var socket = require('./server/socket')(io, sql, app_cfg, waip);
var udp = require('./server/udp')(app_cfg, waip, sql);
var api = require('./server/api')(io, sql, app_cfg, waip);
var udp = require('./server/udp')(app_cfg, waip, sql, api);
var auth = require('./server/auth')(app, app_cfg, sql_cfg, async, bcrypt, passport, io);
var routes = require('./server/routing')(app, sql, uuidv4, app_cfg, passport, auth, waip, udp);
api = require('./server/api')(io, sql, app_cfg, waip);
var routes = require('./server/routing')(app, sql, uuidv4, app_cfg, passport, auth, waip, udp, api);
// Server starten
webserver.listen(app_cfg.global.https_port, function () {

View File

@ -5,12 +5,24 @@ module.exports = function (app_cfg, sql) {
function validate_waip(data, callback) {
// TODO Validierung: Einsatzdaten auf Validität prüfen
// Log
if (app_cfg.global.development) {
console.log('Validierung WAIP: ' + JSON.stringify(data));
};
callback && callback(true);
// SQL-Log
};
function validate_rmld(data, callback) {
// TODO Validierung: Rueckmeldung auf plausibilität
// Log
if (app_cfg.global.development) {
console.log('Validierung RMLD: ' + JSON.stringify(data));
};
callback && callback(true);
// SQL-Log
};

View File

@ -1,4 +1,4 @@
module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp) {
module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp, api) {
/* ########################### */
/* ##### Statische Seiten #### */
@ -247,7 +247,7 @@ module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp)
// Rueckmeldung entgegennehmen
app.post('/rmld/:waip_uuid/:rmld_uuid', function (req, res) {
waip.rmld_speichern(req.body, null, 'web', function (result) {
waip.rmld_speichern(req.body, null, function (result) {
var waip_uuid = req.body.waip_uuid;
var rmld_uuid = req.body.rmld_uuid;
if (result) {
@ -257,6 +257,9 @@ module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp)
req.flash('errorMessage', 'Fehler beim Senden der Rückmeldung!');
res.redirect('/rmld/' + waip_uuid + '/' + rmld_uuid);
};
// TODO TEST: Api WAIP
api.server_to_client_new_rmld(req.body, 'web');
api.client_to_server_new_rmld(req.body, 'web');
});
});

View File

@ -1,4 +1,4 @@
module.exports = function(app_cfg, waip, sql) {
module.exports = function(app_cfg, waip, sql, api) {
// Module laden
var dgram = require('dgram');
@ -25,7 +25,11 @@ module.exports = function(app_cfg, waip, sql) {
udp_server.on('message', function(message, remote) {
if (isValidJSON(message)) {
sql.db_log('WAIP', 'Neuer Einsatz von ' + remote.address + ':' + remote.port + ': ' + message);
waip.waip_speichern(message, 'udp');
waip.waip_speichern(message);
// Einsatzdaten per API weiterleiten (entweder zum Server oder zum verbunden Client)
// TODO TEST: Api WAIP
api.server_to_client_new_waip(message, 'udp');
api.client_to_server_new_waip(message, 'udp');
} else {
sql.db_log('Fehler-WAIP', 'Fehler: Einsatz von ' + remote.address + ':' + remote.port + ' Fehlerhaft: ' + message);
}

View File

@ -1,4 +1,4 @@
module.exports = function (io, sql, fs, brk, async, app_cfg, api, proof) {
module.exports = function (io, sql, fs, brk, async, app_cfg, proof) {
// Module laden
const json2csv = require('json2csv');
@ -6,7 +6,7 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api, proof) {
silent: true
});
function waip_speichern(einsatz_rohdaten, app_id) {
function waip_speichern(einsatz_rohdaten) {
// Einsatzmeldung in Datenbank speichern und verteilen
proof.validate_waip(einsatz_rohdaten, function (valid) {
if (valid) {
@ -48,10 +48,6 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api, proof) {
};
});
});
// Einsatzdaten per API weiterleiten (entweder zum Server oder zum verbunden Client)
// TODO TEST: Api WAIP
api.server_to_client_new_waip(einsatz_rohdaten, app_id);
api.client_to_server_new_waip(einsatz_rohdaten, app_id);
};
});
};
@ -72,7 +68,7 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api, proof) {
einsatzdaten.wgs84_y = '';
};
// pruefen ob Einsatz bereits genau so beim Client angezeigt wurde (Doppelalarmierung)
sql.db_einsatz_check_history(waip_id, einsatzdaten, socket_id, function (result) {
sql.db_einsatz_check_history(waip_id, einsatzdaten, socket.id, function (result) {
if (!result) {
// Einsatz an Client senden
socket.emit('io.new_waip', einsatzdaten);
@ -101,7 +97,7 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api, proof) {
});
};
function rmld_speichern(rueckmeldung, host, app_id, callback) {
function rmld_speichern(rueckmeldung, host, callback) {
// Rueckmeldung speichern und verteilen
proof.validate_rmld(req.body, function (valid) {
if (valid) {
@ -118,9 +114,6 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api, proof) {
callback && callback(result);
};
});
// TODO TEST: Api WAIP
api.server_to_client_new_rmld(rueckmeldung, app_id);
api.client_to_server_new_rmld(rueckmeldung, app_id);
};
});
};
@ -215,6 +208,7 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api, proof) {
} else {
var mp3_bell = process.cwd() + app_cfg.global.soundpath + 'bell_short.mp3';
};
console.log(JSON.stringify(einsatzdaten));
// Zusammensetzen der Sprachansage
async.map(JSON.parse(einsatzdaten.em_alarmiert), sql.db_tts_einsatzmittel, function (err, einsatzmittel) {
// Grunddaten