[Announce] node-red-contrib-ui-contextmenu

Sure. Go for it.

Question tho (as it's been quite some time since we wrote this), at this point (menu item click), does $scope.msg have the original msg on it?

Since we "watch" in AngularJs for changes of the "msg" scope variable, I assume it contains the last received message.
Not at my pc, but I also assume it will be undefined if the user doesn't use "msg based" context menus, but instead a fixed context menu...

Hi Chris (@Christian-Me),

Could you please check my fix, by installing it directly from Github:

npm install bartbutenaers/node-red-contrib-ui-contextmenu

The original input message is stored in the output message as a sourceMsg field:

image

@Steve-Mcl Seemed that at server side we did some postprocessing, by adding some more extra fields. Therefore I implemented your idea, to make sure we wouldn't override the original topic ...

1 Like

great! Works! Thank you very much!

image

Just for you to know the installation *over the old version" spit out two warnings:

npm WARN ws@7.2.1 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.2.1 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.

+ node-red-contrib-ui-contextmenu@1.0.8
updated 11 packages in 12.895s

I have updated the info panel and the readme file, and published version 1.0.9 on npm:

image

Seems the ws package is a dependency of some other node that you have installed, and that ws package has peer dependencies (which are not installed automatically anymore since npm version xxx). Cannot do anything about that, since the context-menu node has no dependencies...

1 Like

Sorry to be the one to say (again!!) @BartButenaers but it's not working here.. :slightly_frowning_face:

I've configured the node as per the readme, using a simple fixed menu, but it does not appear in the dashboard group.

Checking my browser console, I see the following;

If I try and load https://nodered.digitalnut.co.uk:8443/ui/ui_context_menu/contextmenu.js?_=1582707759368 in a browser (as per the 401 error above) I get a prompt for auth. If I enter my user/password, then the contents of this file is then displayed.
The same applies with https://nodered.digitalnut.co.uk:8443/ui/ui_context_menu/contextmenu.css, again I'm prompted for auth.

I'm assuming that this is because I've password protected the Node-RED editor, admin API & the node-defined HTTP endpoints using adminAuth & httpNodeAuth (remember we had similar issues with node-red-contrib-xterm).

Hey Paul,
pfffff ...
But the xterm problem was about the admin endpoint with needspermission. For the UI node we use RED.httpNode and that doesn't use needspermission. I have no idea at the moment ...
And my lunch break is over ...

Hey Paul (@Paul-Reed) ,
Sorry for keeping you waiting...
Hopefully somebody can give me a tip where to start searching, because I have no idea :woozy_face:
In my context_menu.js file, I publish my third party (js and css) files to the browser like I do in all my other UI nodes:

    // By default the UI path in the settings.js file will be in comment:
    //     //ui: { path: "ui" },
    // But as soon as the user has specified a custom UI path there, we will need to use that path:
    //     ui: { path: "mypath" },
    var uiPath = ((RED.settings.ui || {}).path) || 'ui';
	
    // Create the complete server-side path
    uiPath = '/' + uiPath + '/ui_context_menu/*';
    
    // Replace a sequence of multiple slashes (e.g. // or ///) by a single one
    uiPath = uiPath.replace(/\/+/g, '/');
	 
    RED.httpNode.get(uiPath, function (req, res) {
        var options = {
            root: __dirname + '/lib/',
            dotfiles: 'deny'
        };
        res.sendFile(req.params[0], options)
    });

I assume that the uiPath is determined correctly, since you can access the RED.httpNode endpoint (after you have entered your credentials).

I'm in no rush :wink: - I'm using a ui-dropdown node in the meantime, but it's a bit ugly!

For info, my node-RED is script installed

  • Node-RED version: v1.0.3
  • Node.js version: v10.19.0
  • Dashboard version 2.19.4
  • Oracle Linux 4.14.35

But other than adding adminAuth & httpNodeAuth, it's a vanilla installation, so assume others with NR security enabled would have the same problem.

I don't know if it helps, but I've just removed all the security settings in node-RED, and the contextmenu node functions without errors.

Adding them back, it appears that when httpNodeAuth is enabled, that is what causes the 401 error messages.

1 Like

Could it be possibly related to the (unsolved) situation seen here?

Hi Lena,
When I set the httpNodeAuth in my settings.js file, it also fails for me. I'm now trying to debug it. Below is the call stack of my endpoint (i.e. the happy path), in case the httpNodeAuth is not activated:

image
So somewhere in between it fails to access the endpoint...

If I can find a moment tomorrow I’ll compare the uibuilder stack with this one. See where it goes out on both... I’m curious for sure what’s causing this

3 Likes

For my issue, this has now been resolved. see Node-red-ui-table fails when httpNodeAuth enabled

2 Likes

Hi Bart, Hi Steve,

I just observed a strange thing. When I do a page refresh in chrome 80.0.3987.122 (64-Bit) on windows 10 (not tested elsewhere) my two context menus pops up on the last position they where used:

perhaps it has something to do with the dashboard replaying the last message when a session connects, because no message is triggering this (checked with debug nodes). Timers are not started / working, only after I hovered over the menus once.

I'm using Node-RED 1.0.3 and dashboard 2.19.4 on windows 10.

BTW: It`s always the last position where it was triggered the last time:

I have the same on Ios, when I change to a tab that contains context menus all context menus I used the last time I was on the tab are displayed until i either tap them away or do a refresh with ui control.

Last week I have created a new version of the contextmenu node, which should have solved that issue ( in combination with dashboard 0.19.4 or above). You are using the latest contextmenu node version?

You can find more details about the solution here.

1 Like

Is there anyway the menu can always be on the uppermost layer.

layer

Can't that be done (@BartButenaers) by adding a ridiculously high z-index on the css?

Hi Paul,
Indeed like @afelix says the z-index could solve it. However I had some problems with that in the past, in combination with other style elements (e.g. position)...

But let's try.... I have added it on the surrounding DIV element:

<div id='div_" + node.config.id + "' style='z-index: 999999;' ...

You can install it directly from my Github repository:

npm install bartbutenaers/node-red-contrib-ui-contextmenu