There's is surely a better way than copy-paste the same panel?

Hey guys,

I have a class of the students that must send data through MQTT with an Arduino. Each student has its panel.

When adding a new student, I must duplicate a series of components. I'm pretty sure there's a better way.

My current workflow when adding a new student is :

  1. Create a new group Etd_X in the dashboard
  2. Create a new subflow Etd_X
  3. Copy paste from a previous subflow the nodes into subflow Etd_X
  4. Modify each nodes to match the Etd_X group
  5. In the main flow, modify the Switch to send data to subflow Etd_X

Here's a screen recording of the whole process...

I really feel like a first year student that didn't learn arrays yet and copy paste some variables with _1, _2, suffixes...

Is there a better way?

Yes and no.

firstly, you are creating subflows for individual use - that not only defeats the purpose, it makes things harder to manage. In what you are doing, you may as well make your life easier and not bother copying the dashboard elements to a subflow, but instead, copy them to a new tab in the editor.

Next, I feel your pain having to change the group for each element - luckily, we introduced the ability to set a "Config Type" as an env variable for subflows.

this means, you setup your commonised view once, set the UI "group" as the Env Var, add as many subflows instances as you need - each time, setting the ui-group on the subflow env var properties ONCE (not for every UI node).

This however, is not supported by dashboard 1 (though it will may work). However, for the new Dashboard 2.0, this is supported out of the box.

See here: Subflows | Node-RED Dashboard 2.0

You will need to upgrade your node-red to the latest beta using the tag node-red@next

Though it is not yet fully working. It is not possible to specify the position of the subflow in the group if the subflow is not the only widget in the group: Unable to position a subflow containing a ui-node on the dashboard · Issue #710 · FlowFuse/node-red-dashboard · GitHub

Also, if one has multiple widgets in a subflow, how does one order the widgets within the subflow?

Not currently possible by drag+drop on sidebar*

Something i was toying with was showing a separate tree entries for sublfows templates that contains UI nodes - permitting user to drag-drop sort them. it was out of scope due to not knowing if the feature would be used or desired. Fortunately, this is all in the dashboard side. so once NR4 is "current", and the feature is fully released, an update to dashboard is possible at a later time.

BUT it is quite a large piece of work so not likely to drop any time soon

What MIGHT come before that ^ is exposing the sort number as a number entry field when a UI element is inside a subflow template (like we did for the sizer) - that would be much simpler to deliver and would start being useful sooner rather than later.

* If you really need to sort them, at the moment, you would have to cut them from the subflow, paste onto regular flow, sort in the sidebar, cut and re-paste/re-connect in the subflow. (or export, manually edit, import)

For me this isn't much of an issue as usually I only have one node in the subflow (a ui-template). The fact that I can't position the subflow in the group is the main issue for me.

For the requirement in this thread, however, I think the sorting within the subflow would be the issue.