Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
3.67k stars 511 forks source link

Added a hook to process information from custom dialog boxes in plug-ins. #6210

Open wdlut opened 1 week ago

wdlut commented 1 week ago

I found the custom dialog boxes, that you can configure in the config.json very handy. But I haven't found a way to process the input from the dialog box in plug-ins. Therefore I added a hook "uiCustomEvent" to be able to process input from custom dialog boxes in plug-ins. I pass the command-object to have access to all values entered in the custom dialog box.

Maybe there is another easy way to react to dialog boxes in plugins. If not, I recommend the pull request for the merge. It might be interesting for others too.

To use the feature add to the config.json something like:

     "CustomUI": {
        "deviceButtons": {
          "custom_dialog": {
            "name": "Show custom dialog",
            "action": "dialog:customDialog"
          }
        },
        "dialogs": {
          "customDialog": {
...

Implement the hook 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.");
        }
    };