Here is the flow
[
{
"id": "fd39c82798061132",
"type": "function",
"z": "185499ce70cfb9ef",
"name": "PC Warning",
"func": "let datetime = new Date();\nlet day = datetime.getDate() //day as a number 1 -31\nlet month = datetime.getMonth() + 1 // month as a number 0-11\nlet year = datetime.getFullYear() //year as a four digit number (yyyy)\nlet hours = datetime.getHours() //the hour (0-23)\nlet minutes = datetime.getMinutes() //-the minute (0-59)\nlet seconds = datetime.getSeconds() //-the seconds (0-59)\n\nif (month < 10) { \n month = \"0\" + month;\n}\nif (seconds < 10) {\n seconds = \"0\" + seconds;\n}\nif (minutes < 10) {\n minutes = \"0\" + minutes;\n}\n\nif (hours < 10) {\n hours = \"0\" + hours;\n}\n\n\ndatetime = day + \"/\" + month + \"/\" + year + \" \" + hours + \":\" + minutes + \":\" + seconds; \n\nif (global.get(\"cpu_temp_warning\") === 0 && global.get(\"cpu_temp_fault_flag\") != 1) {\n global.set(\"cpu_temp_fault_flag\", 1);\n global.set(\"stringtext\", global.get(\"stringtext\") + \"[\" + datetime + \"] \" + \"CPU TEMPERATURE HIGH - RECORDED: \" + msg.payload + \"° <br>\");\n}\nif (global.get(\"cpu_usage_warning\") === 0 && global.get(\"cpu_usage_fault_flag\") != 1) {\n global.set(\"cpu_usage_fault_flag\", 1);\n global.set(\"stringtext\", global.get(\"stringtext\") + \"[\" + datetime + \"] \" + \"CPU USAGE HIGH - RECORDED: \" + msg.payload + \"% <br>\");\n\n}\nif (global.get(\"mem_warning\") === 0 && global.get(\"mem_usage_fault_flag\") != 1) {\n global.set(\"mem_usage_fault_flag\", 1);\n\n global.set(\"stringtext\", global.get(\"stringtext\") + \"[\" + datetime + \"] \" + \" MEMORY USAGE HIGH - RECORDED: \" + msg.payload + \"% <br>\");\n}\nif (global.get(\"hdd_capacity_warning\") === 0 && global.get(\"hdd_usage_fault_flag\") != 1) {\n global.set(\"hdd_usage_fault_flag\", 1);\n global.set(\"stringtext\", global.get(\"stringtext\") + \"[\" + datetime + \"] \" + \" HDD USAGE HIGH - RECORDED: \" + msg.payload + \"% <br>\");\n\n}\n\nmsg.payload = global.get(\"stringtext\");\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 4330,
"y": 4660,
"wires": [
[
"2a67b5bdf5f3f348"
]
]
},
{
"id": "2a67b5bdf5f3f348",
"type": "template",
"z": "185499ce70cfb9ef",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<p>LOG:</p>\n<ul>\n {{#payload}}\n <li>{{.}}</li>\n {{/payload}}\n</ul>",
"output": "str",
"x": 4960,
"y": 4940,
"wires": [
[
"c33ab084033559fb",
"f2ad52505ed94526"
]
]
},
{
"id": "c33ab084033559fb",
"type": "ui_template",
"z": "185499ce70cfb9ef",
"group": "45239af46bedd77d",
"name": "Log text",
"order": 4,
"width": "20",
"height": "5",
"format": "<style>\n .log ul {\n list-style-type: none;\n margin-block: 0px;\n padding-inline: 0px;\n font-size: .725em;\n }\n</style>\n<div ng-bind-html=\"msg.payload\"></div>",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "log",
"x": 5160,
"y": 4940,
"wires": [
[]
]
},
{
"id": "45239af46bedd77d",
"type": "ui_group",
"name": "Server7",
"tab": "65cdc3b7ba4a47b9",
"order": 8,
"disp": false,
"width": "20",
"collapse": false
},
{
"id": "65cdc3b7ba4a47b9",
"type": "ui_tab",
"name": "Server",
"icon": "dashboard",
"order": 11,
"disabled": false,
"hidden": false
}
]
I have a function node injecting stringtext which contains an error message every minute based on a condition. Can a new line constant be added to the end of each array entry?
It displays fine, but each entry is placed on the same line.