Thank you! I have another challenge, please. My dashboard has a table that is dynamically generated: the "OUT" function receives a new symbol and sends data via msgTable.payload to generate a new row. I want to implement a rowClick callback on the table that would load the corresponding chart on the front end. I found a perfect example of rowClick callback functionality. Just can't put it all together
msgTable = {};
msgChart = {};
msgAction = {};
var listed = flow.get('listed');
var l_coin = flow.get('l_coin');
var price; var change; var f_coin; var g_coin; var b_coin; var c_coin; var id; var token; var coin; var symbol;
if (msg.payload.ftx.price > 0) {
price = msg.payload.ftx.price;
change = (msg.payload.ftx.change * 100).toFixed(2);
id = 739970400;
token = "bae88628-4c8a-4176-a43b-a8dbd5f4f82d00";
coin = msg.payload.ftx.coin;
symbol = "FTX:"+ l_coin + "USD";
}
else if (msg.payload.gate.price > 0) {
price = msg.payload.gate.price;
change = msg.payload.gate.change;
id = 739970400;
token = "bae88628-4c8a-4176-a43b-a8dbd5f4f82d00";
coin = msg.payload.gate.coin;
symbol = "KUCOIN:"+ l_coin + "USD";
}
else if (msg.payload.binance.price > 0) {
price = msg.payload.binance.price;
change = msg.payload.binance.change;
id = 739970400;
token = "bae88628-4c8a-4176-a43b-a8dbd5f4f82d00";
coin = msg.payload.binance.coin;
symbol = "BINANCE:"+ l_coin + "USDT";
}
if (msg.payload.ftx.price > 0) { f_coin = msg.payload.ftx.coin }
if (msg.payload.gate.price > 0) { g_coin = msg.payload.gate.coin }
if (msg.payload.binance.price > 0) { b_coin = msg.payload.binance.coin }
c_coin = msg.payload.coinbase.coin;
msgTable.payload = { "l_coin": l_coin, "listed": listed, "f_coin": f_coin, "g_coin": g_coin, "b_coin": b_coin, "c_coin": c_coin, "price": price, "change": change, "time": msg.time };
msgChart.payload = symbol;
msgAction = { "message_type": "bot", "bot_id": id, "email_token": token, "delay_seconds": "0", "pair": coin};
return [msgTable,msgChart,msgAction];
RowClick
[
{
"id": "a8ef826f4165b6de",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "8a38e79e.e30648",
"type": "function",
"z": "a8ef826f4165b6de",
"name": "Format Table",
"func": "\n//var DT_List = global.get(\"DT_List\");\n//var i;\n//var Line = msg.payload;\n\n\n\n// Can change color in CSS, but not sure where / how to do this:\n //.tabulator .tabulator-row.selected{\n //\tbackground: #f00 !important; /*highlight selected row red, make sure it overrides existing styling*/\n //}\n\n// Display up to 12 rows, select row 0, and highlight in red.\nmsg.ui_control = {\n \"customHeight\":12,\n \"tabulator\": {\n \"selectable\":1,\n \"renderComplete\":\"function(){this.send({ui_control:{callback:'renderComplete'}})}\"\n }\n};\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 650,
"y": 400,
"wires": [
[
"1d03a916.1ea9c7"
]
]
},
{
"id": "1d03a916.1ea9c7",
"type": "ui_table",
"z": "a8ef826f4165b6de",
"group": "58a8895c.e04f28",
"name": "Table1",
"order": 1,
"width": "16",
"height": "10",
"columns": [
{
"field": "RecNo",
"title": "RecNo",
"width": "11px",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "EvtStartTime",
"title": "Event Start Time",
"width": "20px",
"align": "left",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "L_Code",
"title": "L_Code",
"width": "12px",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "Dur",
"title": "Dur",
"width": "10px",
"align": "center",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
}
],
"outputs": 1,
"cts": true,
"x": 1055,
"y": 400,
"wires": [
[
"2e4f7d73.baa142",
"5e0b3d4e.bc9634"
]
]
},
{
"id": "2e4f7d73.baa142",
"type": "debug",
"z": "a8ef826f4165b6de",
"name": "A",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1208,
"y": 383,
"wires": []
},
{
"id": "2ba17e32.afc672",
"type": "function",
"z": "a8ef826f4165b6de",
"name": "InitializeData",
"func": "msg.payload = [{\n\t\t\t\"ID\": 20879,\n\t\t\t\"WO_StartTime\": \"2020-08-01 16:05:29\",\n\t\t\t\"EvtStartTime\": \"2020-08-01 17:29:11\",\n\t\t\t\"WO_No\": \"AUG1B\",\n\t\t\t\"RecNo\": 49,\n\t\t\t\"ModeNo\": 1,\n\t\t\t\"L_Code\": 45,\n\t\t\t\"Dur\": 0.07,\n\t\t\t\"L_Reason\": \"45 - Filler - Idle Blocked - Outfeed Conveyor Full\"\n\t\t},\n\t\t{\n\t\t\t\"ID\": 20878,\n\t\t\t\"WO_StartTime\": \"2020-08-01 16:05:29\",\n\t\t\t\"EvtStartTime\": \"2020-08-01 17:28:43\",\n\t\t\t\"WO_No\": \"AUG1B\",\n\t\t\t\"RecNo\": 48,\n\t\t\t\"ModeNo\": 1,\n\t\t\t\"L_Code\": 144,\n\t\t\t\"Dur\": 0.47,\n\t\t\t\"L_Reason\": \"144 - Labeler - Low Low Labels\"\n\t\t},\n\t\t{\n\t\t\t\"ID\": 20877,\n\t\t\t\"WO_StartTime\": \"2020-08-01 16:05:29\",\n\t\t\t\"EvtStartTime\": \"2020-08-01 17:24:29\",\n\t\t\t\"WO_No\": \"AUG1B\",\n\t\t\t\"RecNo\": 46,\n\t\t\t\"ModeNo\": 1,\n\t\t\t\"L_Code\": 91,\n\t\t\t\"Dur\": 4.22,\n\t\t\t\"L_Reason\": \"91 - Seamer - System Manual Mode\"\n\t\t},\n\t\t{\n\t\t\t\"ID\": 20875,\n\t\t\t\"WO_StartTime\": \"2020-08-01 16:05:29\",\n\t\t\t\"EvtStartTime\": \"2020-08-01 17:24:25\",\n\t\t\t\"WO_No\": \"AUG1B\",\n\t\t\t\"RecNo\": 44,\n\t\t\t\"ModeNo\": 1,\n\t\t\t\"L_Code\": 9,\n\t\t\t\"Dur\": 0.02,\n\t\t\t\"L_Reason\": \"9 - Can Cleaner - Door #2 Open\"\n\t\t},\n\t\t{\n\t\t\t\"ID\": 20874,\n\t\t\t\"WO_StartTime\": \"2020-08-01 16:05:29\",\n\t\t\t\"EvtStartTime\": \"2020-08-01 17:00:00\",\n\t\t\t\"WO_No\": \"AUG1B\",\n\t\t\t\"RecNo\": 42,\n\t\t\t\"ModeNo\": 1,\n\t\t\t\"L_Code\": 35,\n\t\t\t\"Dur\": 9.43,\n\t\t\t\"L_Reason\": \"35 - Filler - Inspection Door 2 Open\"\n\t\t}];\n\t\t\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 650,
"y": 349,
"wires": [
[
"8a38e79e.e30648"
]
]
},
{
"id": "2ebc4a57.75db86",
"type": "inject",
"z": "a8ef826f4165b6de",
"name": "",
"props": [
{
"p": "payload",
"v": "",
"vt": "date"
},
{
"p": "topic",
"v": "",
"vt": "string"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 453,
"y": 332,
"wires": [
[
"2ba17e32.afc672"
]
]
},
{
"id": "13a31094.82261f",
"type": "function",
"z": "a8ef826f4165b6de",
"name": "select row 1",
"func": "if (msg.hasOwnProperty('ui_control') && msg.ui_control.callback === \"renderComplete\") {\n var msgOut={\n payload:{\n command:\"selectRow\",\n arguments: [1],\n returnPromise: false\n }\n }\n return msgOut;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 650,
"y": 468,
"wires": [
[
"1d03a916.1ea9c7",
"c347a95e.b7a9f8"
]
]
},
{
"id": "6bb94a63.257154",
"type": "ui_ui_control",
"z": "a8ef826f4165b6de",
"name": "",
"events": "all",
"x": 453,
"y": 366,
"wires": [
[
"2ba17e32.afc672"
]
]
},
{
"id": "5e0b3d4e.bc9634",
"type": "link out",
"z": "a8ef826f4165b6de",
"name": "",
"links": [
"88bc27e0.a8cb58"
],
"x": 1173,
"y": 434,
"wires": []
},
{
"id": "88bc27e0.a8cb58",
"type": "link in",
"z": "a8ef826f4165b6de",
"name": "",
"links": [
"5e0b3d4e.bc9634"
],
"x": 510,
"y": 468,
"wires": [
[
"13a31094.82261f"
]
]
},
{
"id": "c347a95e.b7a9f8",
"type": "debug",
"z": "a8ef826f4165b6de",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 885,
"y": 468,
"wires": []
},
{
"id": "d919bea9.aba6d",
"type": "function",
"z": "a8ef826f4165b6de",
"name": "callback functions",
"func": "var rowFormatter = function(row){ \n var data = row.getData();\n switch (data.$state) {\n case 'lost': \n row.getElement().style.backgroundColor = '#9e2e66';\n row.getElement().style.color = '#a6a6a6';\n break; \n case 'sleeping':\n row.getElement().style.backgroundColor = '#336699';\n break;\n case 'disconnected':\n row.getElement().style.backgroundColor = '#cc3300';\n row.getElement().style.color = '#a6a6a6';\n break;\n case 'alert': \n row.getElement().style.backgroundColor = '#A6A6DF';\n break; \n case 'init': \n row.getElement().style.backgroundColor = '#f2f20d';\n break; \n case 'ready':\n row.getElement().style.backgroundColor = '';\n row.getElement().style.color = '';\n break; \n \n } \n};\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1095,
"y": 485,
"wires": [
[]
]
},
{
"id": "58a8895c.e04f28",
"type": "ui_group",
"name": "Group 1",
"tab": "1da6d3da.8557bc",
"order": 1,
"disp": true,
"width": "16",
"collapse": false
},
{
"id": "1da6d3da.8557bc",
"type": "ui_tab",
"name": "Test",
"icon": "dashboard",
"order": 6,
"disabled": false,
"hidden": false
}
]