Stuck making lists on dashboard

I know I have "been down this path before" but I have since learned more and am stuck at another part of the journey.

I have found this ability to make "lists" on the screen.

It is a ui_template node and the code is:

<table id="table" border="1">
 <th>Front door events</th> 
 <tr ng-repeat="row in msg.payload track by $index">
 <td class="text" >{{row}}</td>

I was stuck with this in another way recently but that isn't applicable to the latest task I have.

At random times things will happen.

I want to create a list of them - say 10 lines big - and show the last 10 events.

As they come in, they are formatted and sent to this node and displayed.

Alas as is, this has no memory and so every new event is shown and the previous one wiped.

What I am needing is an array that keeps the last 10 events and when a new one comes in, it shuffles them down one place and sticks the latest one on the queue and re-sends the entire list. I'm guessing.

That would require a function node I also guess.

There aren't any nodes that do this already are there?

I can't seem to resolve any from my search, but it somewhat depends on how the node is described by the person writing it and what I make of it.


This is what I have bashed up (with work in progress)

var new_msg = msg.payload[0];
//node.warn("Incoming message is " + new_msg);
var topic = "Main door events";
//  Set up stack for old messages.
var message1 = context.get("message1");
var message2 = context.get("message2");
var message3 = context.get("message3");
var message4 = context.get("message4");
var message5 = context.get("message5");
var message6 = context.get("message6");
var message7 = context.get("message7");
var message8 = context.get("message8");
var message9 = context.get("message9");

if (msg.wipe === 1)
    //  Wipe all messages.
    //  (work needed)

message9 = message8;
message8 = message7;
message7 = message6;
message6 = message5;
message5 = message4;
message4 = message3;
message3 = message2;
message2 = message1;
message1 = new_msg;



msg = {"topic":topic,"payload":[message1,message2,message3,message4,message5,message6,message7,message8,message9]};
return msg;

I think you will find this node very handy for the purpose: node-red-contrib-ring-buffer

1 Like

I have made more progress on the function node getting it working.

But I will look at it.