FlowFuse / node-red-dashboard

https://dashboard.flowfuse.com
Apache License 2.0
197 stars 47 forks source link

Provide access to a server side state store from ui-templates #939

Open colinl opened 4 months ago

colinl commented 4 months ago

Description

Currently there is no server side store accessible to ui-templates for the storage of state that must be maintained across a browser refresh. All that is available to the template after a refresh is the contents of the latest message sent to or from the template, so to get round the problem it is necessary to ensure that all messages sent to the node or sent from it include all the data necessary to restore the state after a refresh. [This thread on the forum[(https://discourse.nodered.org/t/help-needed-dashboard-2-vue-reset-values-on-refresh/88393) illustrates the problem and the hoops that must be jumped through to solve it at the moment.

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

Steve-Mcl commented 4 months ago

All that is available to the template after a refresh is the contents of the latest message sent to or from the template

On this ↑ point

I mentioned in a comment of the forum (think it got lost in the noise) but one of the MAJOR hurdles we (@bartbutenaers and I) had when developing the context menu node was actually differentiating a regular message from a replay message.

whatever the outcome of this issue, i would like to see something in the msg that clearly indicates it is a replay message. Something like msg.ui_replay === true. This way the contrib node developer (or even the ui-template user) has a full awareness and has the ability to to use or discard the replay message.

This might however be unnecessary if all nodes get an option to disable replay.

colinl commented 4 months ago

As far as I can see the message replay feature is not mentioned in the ui-template docs.

bartbutenaers commented 4 months ago

@Steve-Mcl,

Yes indeed the msg replay mechanism was nothing more than trouble.

At first sight it seemed to be a brilliant idea: just replay the last message. But in fact it makes completely no sense at all. The state of a ui widget is build by injecting N successive messages. So only replaying the last message of those N messages does tell you really zero.

Thorsten had solved a lot of those troubles in Flexdash. Every ui node had a server side state, which you can manipulate using input messages. The delta was being send to all the existing clients, and the complete state was being send to new clients (or after a refresh). That is it. Very straightforward...

That is the reason I had registered this issue when the developments of this new dashboard had started. I had really hoped Thorsten's design would have been a bit adopted here. Because changing such stuff afterwards is very hard...

colinl commented 4 months ago

I think the server side store available to contributed ui nodes works ok, if that were available to templates then I don't think there would be a big issue.