Please help me,
I need help with the following item:
I have a node-red-node-ui-table
This table shows the records I collect from a maria DB database.
This works perfect.
I also made an input text that inserts the data in the table, even after clicking the insert button it also updates the table and shows the text that was inserted in the table.
That part works perfect.
I will even share with you the flow and code.
[
{
"id": "de76bac7029e67af",
"type": "group",
"z": "ea86445f05051d5d",
"name": "View Table",
"style": {
"stroke": "#c8e7a7",
"label": true,
"fill": "#e3f3d3"
},
"nodes": [
"b6a5e5c44c1f92bd",
"acd4288657e0e1e9",
"dcf0460394397d3b",
"a87fae56abb17d99",
"6c44656e0b3661a7",
"92c7e5c4bcdc7ce9"
],
"x": 14,
"y": 19,
"w": 532,
"h": 202
},
{
"id": "b6a5e5c44c1f92bd",
"type": "mysql",
"z": "ea86445f05051d5d",
"g": "de76bac7029e67af",
"mydb": "76d3cd37e56c92e8",
"name": "",
"x": 440,
"y": 120,
"wires": [
[
"a87fae56abb17d99"
]
]
},
{
"id": "acd4288657e0e1e9",
"type": "inject",
"z": "ea86445f05051d5d",
"g": "de76bac7029e67af",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "3",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 100,
"wires": [
[
"dcf0460394397d3b"
]
]
},
{
"id": "dcf0460394397d3b",
"type": "function",
"z": "ea86445f05051d5d",
"g": "de76bac7029e67af",
"name": "f_SQL",
"func": "msg.topic = \"SELECT Mergulhador.*, true as '1' FROM Mergulhador\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 60,
"wires": [
[
"b6a5e5c44c1f92bd"
]
]
},
{
"id": "a87fae56abb17d99",
"type": "ui_table",
"z": "ea86445f05051d5d",
"g": "de76bac7029e67af",
"group": "972474baadf22d9f",
"name": "",
"order": 8,
"width": 14,
"height": 11,
"columns": [
{
"field": "nMergulhador",
"title": "nMergulhador",
"width": "10%",
"align": "left",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "Mergulhador",
"title": "Mergulhador",
"width": "",
"align": "left",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "",
"title": "Apagar",
"width": "15%",
"align": "left",
"formatter": "tickCross",
"formatterParams": {
"target": "_blank"
}
}
],
"outputs": 1,
"cts": true,
"x": 410,
"y": 180,
"wires": [
[
"92c7e5c4bcdc7ce9"
]
]
},
{
"id": "6c44656e0b3661a7",
"type": "link in",
"z": "ea86445f05051d5d",
"g": "de76bac7029e67af",
"name": "Mostra_Tabela",
"links": [
"f7cecf442f2f57d9",
"c7578da38b131f5c"
],
"x": 235,
"y": 120,
"wires": [
[
"dcf0460394397d3b"
]
]
},
{
"id": "92c7e5c4bcdc7ce9",
"type": "link out",
"z": "ea86445f05051d5d",
"g": "de76bac7029e67af",
"name": "Out_ApagaRegistro",
"mode": "link",
"links": [
"a7c5d6a3dcda7933"
],
"x": 505,
"y": 180,
"wires": []
},
{
"id": "76d3cd37e56c92e8",
"type": "MySQLdatabase",
"name": "MariaDB_Local",
"host": "casapendotiba.freeddns.org",
"port": "1000",
"db": "Telemetria_Enervision",
"tz": "-03:00",
"charset": "UTF8"
},
{
"id": "972474baadf22d9f",
"type": "ui_group",
"name": "",
"tab": "657fd39515811ee7",
"order": 1,
"disp": true,
"width": 16,
"collapse": false,
"className": ""
},
{
"id": "657fd39515811ee7",
"type": "ui_tab",
"name": "Mergulhadores",
"icon": "dashboard",
"order": 4,
"disabled": false,
"hidden": false
},
{
"id": "059f04f0839c5d5a",
"type": "group",
"z": "ea86445f05051d5d",
"name": "Insert Row",
"style": {
"label": true,
"stroke": "#0070c0",
"fill": "#bfdbef"
},
"nodes": [
"8757bcd1fc3cb715",
"8a4d2e4459a0b06e",
"f60a40e6b35b34df",
"acce5b075c104af8",
"167c0a8b5cd79911",
"aaaf375cf8695f44",
"ed7226ddb2937935",
"f7cecf442f2f57d9"
],
"x": 14,
"y": 239,
"w": 812,
"h": 262
},
{
"id": "8757bcd1fc3cb715",
"type": "ui_text_input",
"z": "ea86445f05051d5d",
"g": "059f04f0839c5d5a",
"name": "",
"label": "Mergulhador",
"tooltip": "",
"group": "972474baadf22d9f",
"order": 3,
"width": 9,
"height": 1,
"passthru": true,
"mode": "text",
"delay": 300,
"topic": "topic",
"sendOnBlur": true,
"className": "",
"topicType": "msg",
"x": 670,
"y": 340,
"wires": [
[
"167c0a8b5cd79911"
]
]
},
{
"id": "8a4d2e4459a0b06e",
"type": "ui_button",
"z": "ea86445f05051d5d",
"g": "059f04f0839c5d5a",
"name": "",
"group": "972474baadf22d9f",
"order": 4,
"width": 5,
"height": 1,
"passthru": false,
"label": "Inserir",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "topic",
"topicType": "msg",
"x": 90,
"y": 340,
"wires": [
[
"aaaf375cf8695f44"
]
]
},
{
"id": "f60a40e6b35b34df",
"type": "mysql",
"z": "ea86445f05051d5d",
"g": "059f04f0839c5d5a",
"mydb": "76d3cd37e56c92e8",
"name": "",
"x": 480,
"y": 460,
"wires": [
[
"f7cecf442f2f57d9"
]
]
},
{
"id": "acce5b075c104af8",
"type": "function",
"z": "ea86445f05051d5d",
"g": "059f04f0839c5d5a",
"name": "f_SQL",
"func": "let vMergulhador = msg.payload\n\nmsg.topic = \"Insert INTO Mergulhador (Mergulhador) Values ('\" + vMergulhador + \"')\";\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 450,
"y": 400,
"wires": [
[
"f60a40e6b35b34df"
]
]
},
{
"id": "167c0a8b5cd79911",
"type": "change",
"z": "ea86445f05051d5d",
"g": "059f04f0839c5d5a",
"name": "",
"rules": [
{
"t": "set",
"p": "vMergulhador",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 700,
"y": 400,
"wires": [
[]
]
},
{
"id": "aaaf375cf8695f44",
"type": "change",
"z": "ea86445f05051d5d",
"g": "059f04f0839c5d5a",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "vMergulhador",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 300,
"y": 340,
"wires": [
[
"ed7226ddb2937935",
"acce5b075c104af8"
]
]
},
{
"id": "ed7226ddb2937935",
"type": "change",
"z": "ea86445f05051d5d",
"g": "059f04f0839c5d5a",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 480,
"y": 280,
"wires": [
[
"8757bcd1fc3cb715"
]
]
},
{
"id": "f7cecf442f2f57d9",
"type": "link out",
"z": "ea86445f05051d5d",
"g": "059f04f0839c5d5a",
"name": "link out 1",
"mode": "link",
"links": [
"6c44656e0b3661a7"
],
"x": 665,
"y": 460,
"wires": []
},
{
"id": "b5f89aababd0dc2b",
"type": "group",
"z": "ea86445f05051d5d",
"name": "Delete Row",
"style": {
"stroke": "#6f2fa0",
"fill": "#b797cf",
"label": true
},
"nodes": [
"5a6a5fd24ca74cfa",
"965b9fcea32fdc32",
"6f226afdf3cb9346",
"6047941a4bcb42c6",
"f6c496041602c3c0",
"34d8ce1f4f8b96b1",
"c7578da38b131f5c",
"a7c5d6a3dcda7933"
],
"x": 574,
"y": 19,
"w": 512,
"h": 202
},
{
"id": "5a6a5fd24ca74cfa",
"type": "ui_toast",
"z": "ea86445f05051d5d",
"g": "b5f89aababd0dc2b",
"position": "dialog",
"displayTime": "3",
"highlight": "",
"sendall": true,
"outputs": 1,
"ok": "SIM",
"cancel": "NÃO",
"raw": false,
"className": "",
"topic": "",
"name": "",
"x": 730,
"y": 100,
"wires": [
[
"34d8ce1f4f8b96b1"
]
]
},
{
"id": "965b9fcea32fdc32",
"type": "change",
"z": "ea86445f05051d5d",
"g": "b5f89aababd0dc2b",
"name": "",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "Deseja apagar esse registro ?",
"tot": "str"
},
{
"t": "set",
"p": "vnMergulhador",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Esse registro será apagado definitivamente",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 740,
"y": 60,
"wires": [
[
"5a6a5fd24ca74cfa"
]
]
},
{
"id": "6f226afdf3cb9346",
"type": "mysql",
"z": "ea86445f05051d5d",
"g": "b5f89aababd0dc2b",
"mydb": "76d3cd37e56c92e8",
"name": "",
"x": 980,
"y": 100,
"wires": [
[
"c7578da38b131f5c"
]
]
},
{
"id": "6047941a4bcb42c6",
"type": "function",
"z": "ea86445f05051d5d",
"g": "b5f89aababd0dc2b",
"name": "f_SQL",
"func": "let vnMergulhador = msg.payload\n\nmsg.topic = \"DELETE FROM Mergulhador WHERE nMergulhador = \" + vnMergulhador ;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 60,
"wires": [
[
"6f226afdf3cb9346"
]
]
},
{
"id": "f6c496041602c3c0",
"type": "change",
"z": "ea86445f05051d5d",
"g": "b5f89aababd0dc2b",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "vnMergulhador.nMergulhador",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 740,
"y": 180,
"wires": [
[
"6047941a4bcb42c6"
]
]
},
{
"id": "34d8ce1f4f8b96b1",
"type": "switch",
"z": "ea86445f05051d5d",
"g": "b5f89aababd0dc2b",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "SIM",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 710,
"y": 140,
"wires": [
[
"f6c496041602c3c0"
]
]
},
{
"id": "c7578da38b131f5c",
"type": "link out",
"z": "ea86445f05051d5d",
"g": "b5f89aababd0dc2b",
"name": "link out 2",
"mode": "link",
"links": [
"6c44656e0b3661a7"
],
"x": 1005,
"y": 160,
"wires": []
},
{
"id": "a7c5d6a3dcda7933",
"type": "link in",
"z": "ea86445f05051d5d",
"g": "b5f89aababd0dc2b",
"name": "In_ApagaRegistro",
"links": [
"92c7e5c4bcdc7ce9"
],
"x": 615,
"y": 60,
"wires": [
[
"965b9fcea32fdc32"
]
]
}
]
I also made a part that deletes the record from the table in the database.
That part also works really well.
When you click on the table choosing the record it forwards to a dialog box and if you choose yes. He does DELETE in the database, with the environment variable passed via flow.
My request for help is as follows:
When the user clicks on the table it calls a node called "NOTIFICATION".
However, I would like this NODE to be called only when clicking on a certain item in the table.
Like for example in a href link for example.
But I have no idea how to do this with this DASHBOARD component.
Does anyone have any ideas ?
[NOTE: edited by moderator to make the flow importable}