List of string on dashboard

Hi all, I'm working with dashboard and I would like create a text output of a payload composed by many string. Each string had to be shown in different lines. it is possible?

Yes it is -- once you understand that Dashboard uses Angular to generate HTML elements, you can use many techniques e.g. put your multi-line text inside <pre> tags, or use CSS styling to show a pre-formatted paragraph, or replace newlines with <br> tags, etc.

Check out this old post for some other ideas.

Hello
take a look at this sample flow and check if it works for you.
If you need your log to persists restarts, you'll need to use persistent context.

I got this flow in this forum not long ago, but I don't know who is the original author.
Sorry for not giving credit.

[{"id":"c4dd74857a35dbd2","type":"function","z":"58ade23330ac7d0c","name":"Collect outages","func":"// Get the previously stored commands\nvar temp = context.get(\"outages\") || [];\n\n// Prepare date for log\nvar tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset in milliseconds\nvar localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -5);\n\nif (msg.topic===\"--ClearList--\") {\n    // Clear the current list\n    temp = [];\n    context.set(\"outages\", temp);\n} else {\n        // Add the new one \n        temp.push(localISOTime + \" - \" + msg.payload);\n        context.set(\"outages\", temp);\n}\n\n//Format the output\nmsg.payload = \"\";\nfor (var i=0; i<temp.length; i++) {\n    msg.payload += temp[i] + \"<br/>\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":395,"y":240,"wires":[["02d70773c4455783"]],"l":false},{"id":"02d70773c4455783","type":"ui_template","z":"58ade23330ac7d0c","group":"6caa64be625d6e00","name":"Outage log","order":4,"width":9,"height":6,"format":"<div ng-bind-html=\"msg.payload\" height=\"300\" style=\"height: 400px;\"><br/></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":495,"y":240,"wires":[[]],"l":false},{"id":"f04abe539adb8c18","type":"inject","z":"58ade23330ac7d0c","name":"Log data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":240,"wires":[["c4dd74857a35dbd2"]]},{"id":"15c52f83316ddbc3","type":"ui_button","z":"58ade23330ac7d0c","name":"","group":"6caa64be625d6e00","order":1,"width":0,"height":0,"passthru":false,"label":"Clear","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"--ClearList--","payloadType":"str","topic":"--ClearList--","topicType":"str","x":290,"y":200,"wires":[["c4dd74857a35dbd2"]]},{"id":"6caa64be625d6e00","type":"ui_group","name":"Status","tab":"1bacbfa2076f613b","order":1,"disp":false,"width":15,"collapse":false,"className":""},{"id":"1bacbfa2076f613b","type":"ui_tab","name":"UPS","icon":"fa-battery-three-quarters","order":10,"disabled":false,"hidden":false}]

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.