Where to save persistent data in a published node

The easiest way of working (for our users) imho would be that you store the json tree in the flow.json file, as a config node property. Because the eveything works out of the box, like they are used to do.

However, whether or not you can store the json tree in the config node seems to me dependent on how we need to update that static config that is not related to ui nodes (i.e. position of the widgets, and then the config of panels, grids, tabs, ...):

  1. If you need to use an isolated external layout manager, then you need the update the flow via the server side. I have not done that yet, but I assume that is what Nick means with the admin http api above?

  2. If you can somehow integrate a layout manager into the config node's config screen, then a user can use that to change the config node properties. Once done, he can deploy the flow (and the config node changes), and from here on it all works out of the box automatically.

For me option 2 would be the most user friendly, but completely no idea whether something like that is possible.

Hopefully this makes a bit sense...

The layout is a grid (like the current dashboard), so each widget has a width and height in grid units, just like in the current dashboard.

Yes, that's correct. But for export/import to work correctly I have to do the same thing the dashboard currently does, which is to have fd-panel, fd-grid, and fd-tab config nodes (equiv to the ui_group and ui_tab config nodes. To do that I have to invert my data structure: right now a grid has an array of widget IDs, and instead each widget will need to have the ID of the grid that contains it, and like that up the tree. Not the end of the world, but more than JSON.dump...

Right now I'm not a fan of that idea anymore. I'd like to spend my effort on improving the live layout editing in the dashboard directly. That's such a better experience. The result can be stored in the flow. All I need to do to fit the NR model is to keep such edits in memory until the user clicks on a 'save layout' button, or perhaps I can hook into the deploy button...

2 Likes

Sounds better indeed. Good luck with your developments!!

1 Like

This may help you

https://nodered.org/docs/user-guide/context

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.