Customizing Node-RED - refreshing the nodes-palette? got stuck!

1,044 views
Skip to first unread message

Sebastian Schmidt

unread,
Jun 24, 2014, 6:38:45 AM6/24/14
to node...@googlegroups.com
Hi Guys,

you did a wonderful work with this service mash-up editor. I like the clean and clear UI, the playful look and that you made it open source. :)
I would be glad if you someone can help me. ^^

I use the version 0.7.2 and try to customize Node-RED to handle my own services. 

What have i done:
I've a back-end where my services and a user management are stored. Each user has his own services.
Currently i can load my custom nodes into Node-Red and they are displayed in the UI. But that only works when my custom services are imported as nodes before Node-RED starts ( RED.start() ). 

The custom services can change. It depends on which user is logged in and on used CRUD operations of the user on his services ( e.g: when a user deletes a service, it has to lead to an update of the Node-RED editor ).

Because of the custom services in the editor can change, i want to refresh the Node-RED editor to be up to date with my services in the back-end. To do that, i request the custom services from my back-end, convert them into the needed .js  and .html nodes structure and register them to the Node-RED config ( registry.js ). And at this point i'm stuck. 

I've found the Nodes are also handled in "RED.palette" and in "RED.nodes" on the client-side scripts ( "public/red/ui/..." ). When i want to refresh the Node-RED editor, did i have to remove the nodes from these scripts too or are they handled by the Node-RED server? Or i'm on the wrong way?

best regards,
Sebastian

Sebastian Schmidt

unread,
Jun 24, 2014, 11:22:59 AM6/24/14
to node...@googlegroups.com
I forgot to tell, that i've reset the old nodes configs in the registry.js by clearing the nodes_config array, just before i register the new converted custom nodes.

I've added a refresh button into the editor which fires a request to the Node-RED server.js where i added a function to handle the reset of "old" nodes. This function is requesting the new services from my back-end and converting them into nodes(.js and .html). Finally the new custom nodes are registered to Node-RED. ( registerConfig in registry.js )

The result of the refresh button is that all old nodes are removed, except the debug and functions nodes. This nodes are now twice in the navigation palette and the debug tab in the sidebar is twice. 

But when i use the refresh function of the browser, the debug node and the function nodes are then only once again. The debug tab in the sidebar is also once again. But my "new" added custom service nodes are twice in the navigation palette. (the old and the new nodes together).

Did someone know how to remove the old nodes from the navigation palette and how to edit the RED.view.redraw() function to display the result without using the browser refresh function ( F5-button ).

best regards,
Sebastian

Nicholas O'Leary

unread,
Jun 24, 2014, 11:43:30 AM6/24/14
to node...@googlegroups.com

Hi Sebastian,

Quick reply as I'm at an airport with no WiFi...

The code doesn't support dynamically updating the nodes in the palette. It's in the plan for the future, but isn't there today. It sounds like you've made some progress hacking it in, but there may well be architectural limitations to achieving it right now.

There isn't, for example, any api available for refreshing the palette in the ui.

Regards
Nick

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sebastian Schmidt

unread,
Jun 25, 2014, 5:55:56 AM6/25/14
to node...@googlegroups.com
Hi Nicholas,

thanks for your fast reply. Yes i try to hack in this feature and i thought that this feature isn't be supported yet.
Anyway can you tell me if my assumption is right? 
When i remove the "old" nodes at the public/red/ui/palette.js and and from public/red/nodes.js, the "old" nodes are cleared from the UI?
I hope by removing the "old" nodes from all listed places and reloading the "new" nodes afterwards, it will match my idea of the refresh function. 

PS: i can't wait to get this feature :)

best regards,
Sebastian

Nicholas O'Leary

unread,
Jun 25, 2014, 6:08:40 AM6/25/14
to node...@googlegroups.com
As it isn't supported in the code, I can't quickly give you a detailed list of everything you may need to do to get it to work.

In the current code, to clear the palette, you would have to also manually remove the node DOM elements - just removing them from the internal registry is not enough.

Nick

Sebastian Schmidt

unread,
Jun 25, 2014, 6:31:56 AM6/25/14
to node...@googlegroups.com
Okay, thanks anyway for your help. i keep trying and let you know if it works.

Sebastian
Reply all
Reply to author
Forward
0 new messages