Send to rado platform; show_dbdata, db loads after start

This commit is contained in:
rasta5man 2024-12-02 16:57:26 +01:00
parent ed0fe5b15d
commit f63ac50497
22 changed files with 6380 additions and 2279 deletions

View file

@ -1,10 +1,6 @@
const { promisifyBuilder, makeMapFromDbResult } = require('./db_helper.js');
const dbNotifications = TABLE("notifications");
//key is device, value = str
let sentValues= {};
let notificationsData = {};
let notificationsData = null;
let ERRWEIGHT = {
EMERGENCY: "emergency", // System unusable
@ -24,12 +20,9 @@ function getKey(map, val) {
//https://stackoverflow.com/questions/41117799/string-interpolation-on-variable
var template = (tpl, args) => tpl.replace(/\${(\w+)}/g, (_, v) => args[v]);
async function initNotifications()
{
let response = await promisifyBuilder(dbNotifications.find());
notificationsData = makeMapFromDbResult(response, "key");
console.log("initNotifications done" );
function initNotification() {
notificationsData = FLOW.GLOBALS.notificationsData;
}
function sendNotification(func, device, key, params, extra, tb_output, instance, saveKey) {
@ -39,7 +32,7 @@ function sendNotification(func, device, key, params, extra, tb_output, instance,
let storeToSendValues = true;
if(saveKey == undefined) storeToSendValues = false;
let lang = FLOW.OMS_language;
let lang = FLOW.GLOBALS.settings.language;
if(lang != "en" || lang != "sk") lang = "en";
let tpl = key;
@ -55,7 +48,8 @@ function sendNotification(func, device, key, params, extra, tb_output, instance,
}
else
{
console.error("sendNotification: Notifications: undefined key", key, func, notificationsData);
//console.error("sendNotification: Notifications: undefined key", key, func, notificationsData);
console.error("sendNotification: Notifications: undefined key", key, func );
return false;
}
@ -91,7 +85,7 @@ function sendNotification(func, device, key, params, extra, tb_output, instance,
if(storeToSendValues) sentValues[saveKey] = tpl;
let str = FLOW.OMS_rvo_name;
let str = FLOW.GLOBALS.settings.rvo_name;
if(str != "") str = str + ": ";
str = str + tpl;
@ -132,6 +126,6 @@ function sendNotification(func, device, key, params, extra, tb_output, instance,
module.exports = {
sendNotification,
initNotifications,
ERRWEIGHT
}
ERRWEIGHT,
initNotification
}