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."); } }; ````

wdlut committed Sep 15, 2024 at 18:43 UTC 8b20f44dd57970dcf5766e606d3fb73abb71e6a2
1 file changed +10
meshuser.js
+10
@@ -4634,6 +4634,16 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4634 if (typeof command.logmsg == 'string') { message.msg = command.logmsg; } else { message.nolog = 1; }
4635 parent.parent.DispatchEvent(['*', user._id], obj, message);
4636 }
4637 +
4638 + if (parent.parent.pluginHandler != null) // If the plugin's are not supported, reject this command.
4639 + {
4640 + command.userid = user._id;
4641 + try {
4642 + for( var pluginName in parent.parent.pluginHandler.plugins)
4643 + if( typeof parent.parent.pluginHandler.plugins[pluginName].uiCustomEvent === 'function' )
4644 + parent.parent.pluginHandler.plugins[pluginName].uiCustomEvent(command, obj);
4645 + } catch (ex) { console.log('Error loading plugin handler (' + ex + ')'); }
4646 + }
4647 break;
4648 }
4649 case 'serverBackup': {