How to print a list in the dashboard?

Hello,

I would like to print a list of the last 5 messages on the node-red dashboard.

Someone knows how can I do this ?

Thnaks.

Do you mean the messages sent from Node-RED to the dashboard?

If so, you will need to define a variable to hold the data, a small script that runs when a msg is received and some Angular code in your HTML (ngRepeat). This will all be defined in a Dashboard Template node.

There are some code examples on my blog that may help you put the jigsaw together.

Yes ! it's exactly this. I'll receive some messages and then I would like to print them in a tableau on dashboard.

So, I need to use a function block to do this ?

I'm beginning on node-red :slight_smile:

No, you need a Dashboard Template node.

In that node, you will need to define a handler function in a script tag such that, when a message is received, you add it to an array then trim the array to 5 entries by popping off the earliest entry if you have >5.

In the same template, you can display that data using standard Angular features such as ngRepeat.

None of this is really Node-RED as such :slight_smile: You will need to learn some Angular if you don't already know any. My blog post has a few recipes that may help you make sense of things but there are plenty of other (better!) examples around.

If you are already somewhat familiar with web front-ends and apps, you could chose to use uibuilder instead of Dashboard. This lets you work with any front-end library or none at all if that is your preference. It manages the communications between your front-end and Node-RED for you and will also manage access to front-end libraries via installed packages. The advantage for you is that the Angular implementation in Dashboard doesn't get in the way. The disadvantage is that you have to build your UI yourself.