Develop node: button alignment

#1

Hey everyone,

I develop a custom node which connects to a sensor which is locally connected via USB. The node reads the sensor values and sends them as outputs. Now I want the user to be able to deactivate the node so no values are read and sent. I thought I use the same mechanism as the debug nodes provides: this little button at the side of the node to toggle the active state.
The problem is that the debug node has the button on the right side, but I need it to be on the left side, since my node is an input node. Now of the input nodes the inject node also has such a button, but it is not used to toggle the active state and also does not "collapse" as the button on the debug node does.

So my question is: is it possible to create a toggle button on the left side of a node which also "collapses"?

A screenshots for illustration.
This is the node with property align: "right". The button does collapse, if I click it, but the button and the icon are on the wrong side.
right

So what I need is the node as on the screenshot, but with the button and the icon on the left side. Does anyone know how to achieve this?

Thanks!

Benjamin

0 Likes

#2

Is this being used for debugging of the flow as you write it or for general operation of whatever it is you're building? In the past, the general philosophy has been to avoid using the flow editor as an interface for your project whenever possible...

0 Likes

#3

Hello Jay,

thanks for your reply!

Some more background information about what I try to achieve: I have a Bosch CISS which can be connected to a computer (e.g. a Raspberry Pi) via USB. I write a custom node which reads the sensor values provided via USB, parses them and sends them as outputs of the node. This way they can be processed in a flow.

Regarding your questions: it's not being used for debugging, but as a real, custom node I will use in several projects. If finished, the node will output sensor values read via USB. I will then process these values and e.g. display them in the dashboard and send them to a cloud.

Best

Benjamin

0 Likes

#4

Certainly not natively possible. As Jay say's - it is strongly discouraged to use the admin interface for user interactions. The debug is allowed to do it since the debug output is meant for administrators and flow authors not for end users.

I can't comment on whether it would be physically possible as it probably depends how much of the display is generated via D3 and how much is controlled by CSS. In addition, you could not guarantee that your custom solution would work in the future without being broken by future updates to Node-RED.

It would be better to use a simple Dashboard with a switch on it in order to block/release the flow.

0 Likes

#5

One simple solution is to add a checkbox disable in the config.

0 Likes

#6

Ah, now I understand the point. However in my case the flow author and the end user will be the same person. So I guess it still would make sense to go for such a toggle button. However since it seems not to be possible easily, I will go for the solution cflurin mentioned and just use a checkbox. Thanks!

0 Likes

#7

Hi @BGoll

just to clarify, the Node-RED editor does support nodes having buttons - as we all know from the Inject and Debug nodes.

There are two types of buttons - again, as demonstrated by the Inject and Debug nodes. Those types were create in response to the needs of the Inject and Debug nodes. Which is another way of saying... I never wrote the code for the toggle type to work on the left hand side. I see no harm in plugging that gap in the code, but that won't happen until the 0.20 release at the earliest.

Whether its a suitable solution for your node is up to you - but until I fix the left-hand toggle button, there isn't much you can do.

Nick

0 Likes

#8

I already thought of that but I don't find this the most elegant solution. But since it seems to be the only possible solution by now, I will go for it. Thank you!

0 Likes

#9

Hey @knolleary,

that sounds very good, thanks! I would definitely use the left-hand toggle button if it was available! So it would be awesome if you could add that to the backlog. Do you want me to raise this as an official feature request in any way?

Thank you! :grinning:

Benjamin

0 Likes

#10

Or you pass your node a message with msg.enable true or false to enable/disable. Then you can do it with an inject or a dashboard button. Or even pass msg.toggle to toggle the mode. Display the mode in the status obviously.

0 Likes

#11

Just to confirm, I've pushed the fix to the dev branch on git for the 0.20 release.

3 Likes

#12

Hey Nick,

that's totally amazing, thank you so much! Do you already have any idea when 0.20 will be released?

Best

Benjamin

0 Likes