From 8b20f44dd57970dcf5766e606d3fb73abb71e6a2 Mon Sep 17 00:00:00 2001 From: wdlut <97447303+wdlut@users.noreply.github.com> Date: Sun, 15 Sep 2024 18:43:37 +0200 Subject: [PATCH] Update meshuser.js (#6210) Added a hook "uiCustomEvent" to start plug-ins from custom dialog boxes. In the config.json: ```` "CustomUI": { "deviceButtons": { "custom_dialog": { "name": "Show custom dialog", "action": "dialog:customDialog" } }, "dialogs": { "customDialog": { ... ```` In the plug-in: ```` obj.uiCustomEvent = function(command, parent) { switch(command.element) { case 'customDialog': onCustomDialog(command, obj, parent.ws); break; default: console.log("Element "+command.element+ " not supported."); } }; ```` --- meshuser.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/meshuser.js b/meshuser.js index 947c0538..65adc31e 100644 --- a/meshuser.js +++ b/meshuser.js @@ -4634,6 +4634,16 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if (typeof command.logmsg == 'string') { message.msg = command.logmsg; } else { message.nolog = 1; } parent.parent.DispatchEvent(['*', user._id], obj, message); } + + if (parent.parent.pluginHandler != null) // If the plugin's are not supported, reject this command. + { + command.userid = user._id; + try { + for( var pluginName in parent.parent.pluginHandler.plugins) + if( typeof parent.parent.pluginHandler.plugins[pluginName].uiCustomEvent === 'function' ) + parent.parent.pluginHandler.plugins[pluginName].uiCustomEvent(command, obj); + } catch (ex) { console.log('Error loading plugin handler (' + ex + ')'); } + } break; } case 'serverBackup': {