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.");
        }
    };
````
This commit is contained in:
wdlut 2024-09-15 18:43:37 +02:00 committed by GitHub
parent 59a3a22ea5
commit 8b20f44dd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -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': {