node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

ui_template: when template is loaded using msg.template, the HTML is sent in each websocket message

Open algardas-sca opened this issue 4 years ago • 3 comments

What are the steps to reproduce?

  1. Connect an inject node with a ui_template node.
  2. Send msg.template="XXX" to the ui_template node.
  3. Open /ui and observe dashboard websocket packets.

What happens?

The initially injected template is sent in every message that is coming to the ui_template node.

What do you expect to happen?

The template HTML should be sent only once to save resources. It is not sent if the template HTML is typed in the ui_template config.

Please tell us about your environment:

  • [x] Node-RED-Dashboard version: 2.30.0
  • [x] Node-RED version: 1.3.5
  • [x] node.js version: 14.17.5

algardas-sca avatar Sep 03 '21 12:09 algardas-sca

Hi, yes that is the way it is working. It is this way on purpose. Say we only sent the template once - then any future client that arrived after then would not receive the template and so would not display as required. Changing this would thus break a lot of existing users.

Currently by saving it in the msg we take advantage of the existing storage replay mechanism that sends the current state to new clients. In order to implement this change we would need to create a new way of storing the latest template for new clients plus the latest payload (msg) to populate it. This would be a non-trivial change and is not in plan.

dceejay avatar Sep 06 '21 11:09 dceejay

@dceejay thanks for your detailed reply.

When the template is specified directly in the node config, it is not sent via websocket. I thought that the same mechanism could be used when the template is specified in msg.template?

algardas-sca avatar Sep 22 '21 15:09 algardas-sca

Sadly no. The two paths are completely separate

dceejay avatar Sep 22 '21 16:09 dceejay