Join specific array field in a string separated by blank space

Export the flow (mark the nodes and use the Menu Export) and paste it here.
Edit: First add a debug node showing what is coming from the first node, just to make sure you are still getting what you think.

I put a debug node after the button (1st node) and it doesn't show anything.

If I export all the flow to post here I won't be able to because of the character limit, do you want me to export the file referring to all the flow?

There is no point if the first node isn't doing anything. In your first post you showed the data that you have, why have you now not got anything?

Here is an example using your original data in ui_control.

[{"id":"496ff00c.abfe5","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"ui_control","v":"{\"rowSelection\":[{\"id\":1,\"filesize\":\"82K\",\"filename\":\"datalog--2021-6-1--13-27--0.csv\"},{\"id\":2,\"filesize\":\"142K\",\"filename\":\"datalog--2021-6-1--13-33--0.csv\"}]}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":4700,"wires":[["14a0bae3.68179d"]]},{"id":"14a0bae3.68179d","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ui_control.rowSelection.filename","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":4720,"wires":[["d2e89779.0dab7"]]},{"id":"d2e89779.0dab7","type":"split","z":"b779de97.b1b46","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":280,"y":4840,"wires":[["4ed3999f.479a4"]]},{"id":"4ed3999f.479a4","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"\"path/tofile/\" & payload","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":4840,"wires":[["131564fb.f801db"]]},{"id":"131564fb.f801db","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":4720,"wires":[]},{"id":"8431f41.aa96388","type":"file","z":"b779de97.b1b46","name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"delete","encoding":"none","x":630,"y":4920,"wires":[[]]}]

[edit]
or if you want to combine the two JSONata expressions

[{"id":"496ff00c.abfe5","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"ui_control","v":"{\"rowSelection\":[{\"id\":1,\"filesize\":\"82K\",\"filename\":\"datalog--2021-6-1--13-27--0.csv\"},{\"id\":2,\"filesize\":\"142K\",\"filename\":\"datalog--2021-6-1--13-33--0.csv\"}]}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":4560,"wires":[["14a0bae3.68179d"]]},{"id":"14a0bae3.68179d","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ui_control.rowSelection.(\"path/to/file/\" & $.filename)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":4580,"wires":[["d2e89779.0dab7"]]},{"id":"d2e89779.0dab7","type":"split","z":"b779de97.b1b46","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":280,"y":4700,"wires":[["4ed3999f.479a4"]]},{"id":"4ed3999f.479a4","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":4700,"wires":[["131564fb.f801db"]]},{"id":"131564fb.f801db","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":4580,"wires":[]},{"id":"8431f41.aa96388","type":"file","z":"b779de97.b1b46","name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"delete","encoding":"none","x":630,"y":4780,"wires":[[]]}]

You may want to rate limit this with a delay node after the split.

First of all, thank you @E1cid for your help and for the time you took.
I understood your example perfectly, I tested it on an empty flow and it works, that is, after triggering the inject I see in the debug node a payload consisting of the path and the filename, for each file.

I transported it to my flow and I think I'm in the same problem as yesterday. Pressing the button (since the button is simulating the same function as the inject node) nothing happens and debug node shows nothing.
image
Could it be because from the button these nodes in question don't know anything related to the ui_control.rowSelection? Do I have to define or declare the ui_control.rowSelection elsewhere?

I don't know if it helps but at the output of my table I have a change node that sets the rowSelection.filename, but below I leave you the properties of that node and the result that is the same as what I posted above.

Thanks again, I know I'm close to achieving it but I'm missing some step

Put a debug on the button node, set to complete msg. Then paste the msg here, as we need to see what output the button produces.

with a debug node (configured to show the complete message) at the button output this is the result.
image

It happened to me yesterday (I even told Colin in a comment above) in some tests I was doing. And that's why I asked you if it could have something related with the fact of that nodes that are from the button inclusive, don't know the ui_control.rowSelection

Thanks again

Where has the ui_control object gone?
This is not the same as your original posts object.
There are no filename values.

The result I put in the first post is a debug node that I have in the change node exit that I mentioned in the previous message, which is at the output of the table to set the ui_control.rowSelection.filename.
In the images below maybe it can be seen better:
image
The following image is the content of that same change node that is following the table:
image
The result of this debug node "new_files_list" is the same as what you say is in the first post and is as follows:
image

That is what you have to pass into the flow with the change and split nodes.

But how can I do this? Linking the change node that is at the table output to the delete button?

We don't know in detail what you are trying to do. Perhaps you need to use the button to trigger the file download. That is only a guess though as you have not provided sufficient information.

As I mentioned above, the idea was not changed. Is to have the filenames of selected files in the table tickbox to remove them from the RPi using that button.
The result I posted above shows that I can already have an array that stores the filenames of the selected ones, adding your suggestion with change, split and fs-delete-ops nodes, pressing the button the idea would be to delete the files from the directory.

I thought you had a space separated string. If you already have an array then you can feed that directly into the delete node (but read that node's help page first to make sure you understand what it does). Or you can feed that array into a split node to split it into separate filenames and feed that to the delete node to do them one at a time.

The strategy of joining the names separated by spaces was impossible because with the command "rm -rf" it would only delete the first file, from that it would not know the directory.

As I found this idea very useful, I am trying to implement it. What I can't do is get the array (rowSelection) to this small flow that has the delete button, change and split nodes.

Looking at your flow, it has alot going on and not sure i have selected the right area, but here is a way to join the output from the table and add a delete button. Untested , but it might inspire you

[{"id":"1c112808.80492","type":"join","z":"98ce568d71c2f635","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1820,"y":580,"wires":[["f54f43cc.5fb888"]]},{"id":"248a85496772c935","type":"change","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"","rules":[{"t":"set","p":"newFileList","pt":"flow","to":"ui_control.rowSelection.filename","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"ui_control.rowSelection.(\"path/to/file/\" & $.filename)","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"filelist","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":960,"wires":[["dbb94f76cbca7b56","1c112808.80492"]]},{"id":"306f1c34bca2cf5e","type":"ui_button","z":"98ce568d71c2f635","name":"","group":"2768d5bb10e62e93","order":10,"width":0,"height":0,"passthru":false,"label":"Delete File","tooltip":"","color":"","bgcolor":"","icon":"","payload":"delete","payloadType":"str","topic":"delete","topicType":"str","x":1640,"y":580,"wires":[["1c112808.80492"]]},{"id":"f54f43cc.5fb888","type":"change","z":"98ce568d71c2f635","name":"","rules":[{"t":"move","p":"payload.filelist","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2060,"y":580,"wires":[["bb68bce4.84b76"]]},{"id":"6b1c46bddf5be4ab","type":"ui_table","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","group":"870a91418c5861d1","name":"File download_v2","order":2,"width":10,"height":9,"columns":[],"outputs":1,"cts":true,"x":1300,"y":860,"wires":[["876cdcdf15120c7e","248a85496772c935"]]},{"id":"dbb94f76cbca7b56","type":"debug","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"new_files_list","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1500,"y":1000,"wires":[]},{"id":"bb68bce4.84b76","type":"split","z":"98ce568d71c2f635","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":2120,"y":700,"wires":[["dde71978.52e8d"]]},{"id":"876cdcdf15120c7e","type":"debug","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"Table Output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1480,"y":780,"wires":[]},{"id":"4bbf97a86f27e830","type":"change","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"","rules":[{"t":"set","p":"ui_control","pt":"msg","to":"{\"customHeight\":12,\"tabulator\":{\"columns\":[{\"title\":\" <div style='text-align:center'>##</div>\",\"field\":\"line_nr\",\"width\":18,\"formatter\":\"rownum\",\"align\":\"center\"},{\"title\":\" <div style='text-align:center'>#</div>\",\"field\":\"id\",\"width\":15,\"formatter\":\"rowSelection\",\"align\":\"center\"},{\"title\":\" <div style='text-align:center'>File Size</div>\",\"field\":\"filesize\",\"align\":\"center\",\"formatter\":\"text\",\"width\":100,\"layout\":\"fitData\"},{\"title\":\" <div style='text-align:center'>File Name</div>\",\"field\":\"filename\",\"formatter\":\"text\",\"width\":330,\"sorter\":\"alphanum\",\"sorterParams\":{\"alignEmptyValues\":\"bottom\"},\"layout\":\"fitData\",\"align\":\"center\"}],\"initialSort\":[{\"column\":\"filename\",\"dir\":\"asc\"}],\"setSort\":[{\"column\":\"filename\",\"dir\":\"asc\"}],\"layout\":\"fitColumns\",\"movableColumns\":false,\"resizableColumns\":false,\"headerVisible\":true,\"headerSort\":false,\"autoColumns\":false,\"selectable\":true}}","tot":"json"},{"t":"set","p":"ui_control.tabulator.rowSelectionChanged","pt":"msg","to":"function(data, rows){this.send({ui_control:{'callback':'rowSelectionChanged','rowSelection':data}});}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":760,"wires":[["6b1c46bddf5be4ab"]]},{"id":"07ae9d6f0024a2be","type":"link in","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"link_table","links":["7bc3dfb3f5738045","a8ace126938e208d"],"x":1165,"y":880,"wires":[["6b1c46bddf5be4ab"]]},{"id":"dde71978.52e8d","type":"change","z":"98ce568d71c2f635","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2320,"y":700,"wires":[["6fb1dcd0.a1514c"]]},{"id":"6616a44c93935cf6","type":"function","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"selectRow","func":"\nmsg.payload={\n    command:\"selectRow\",\n    returnPromise: true\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":940,"y":860,"wires":[["4bbf97a86f27e830"]],"info":"# deleteRow(row / [rows])\n\n`row=singleId`\n\nor\n\n`row=[array of IDs]` // seems there is a bug/issue in tabulator\n\ndelete a single the row with an id in the middle from 1 to lastId, hope it exists.\n\nWill fail on the second hit if you inject this two times because the id wad deleteted on the first"},{"id":"026605d82d27e833","type":"change","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"Load list from context","rules":[{"t":"set","p":"payload","pt":"msg","to":"fileList","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":760,"wires":[["4bbf97a86f27e830"]]},{"id":"99856643e9edfd6a","type":"function","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"deselectRow","func":"\nmsg.payload={\n    command:\"deselectRow\",\n    returnPromise: true\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":940,"y":820,"wires":[["4bbf97a86f27e830"]],"info":"# deleteRow(row / [rows])\n\n`row=singleId`\n\nor\n\n`row=[array of IDs]` // seems there is a bug/issue in tabulator\n\ndelete a single the row with an id in the middle from 1 to lastId, hope it exists.\n\nWill fail on the second hit if you inject this two times because the id wad deleteted on the first"},{"id":"6fb1dcd0.a1514c","type":"debug","z":"98ce568d71c2f635","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2530,"y":580,"wires":[]},{"id":"f595b6ddf68e4783","type":"ui_button","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"","group":"2768d5bb10e62e93","order":5,"width":6,"height":1,"passthru":false,"label":"Select All Files","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":730,"y":860,"wires":[["6616a44c93935cf6"]]},{"id":"972dc40eaff9f1bc","type":"function","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"updateOrAddData (add)","func":"let fileList = flow.get(\"fileList\") || [];\nlet pay = {};\n\nvar check=msg.file_size;\nif(check===\"\"){\n    return null;   \n}\nelse {\n    var id=flow.get(\"lastId\") || 0;\n    ++id;\n    pay = {\n            \"id\":id,\n            \"filesize\":msg.file_size,\n            \"filename\":msg.file_name\n          }\n    fileList.push(pay);\n    flow.set(\"lastId\",id);\n    \n       \n}\n\nflow.set(\"fileList\" , fileList);\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":760,"wires":[["026605d82d27e833"]],"info":"# updateOrAddData([row])\n\nadds a the row with a new id (same as addRow)"},{"id":"643fddd9fb837943","type":"ui_button","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"","group":"2768d5bb10e62e93","order":6,"width":6,"height":1,"passthru":false,"label":"Unselect All Files","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":720,"y":820,"wires":[["99856643e9edfd6a"]]},{"id":"8c2456856ec5b24b","type":"function","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"","func":"var data=msg.payload;\nvar temp=data.split(\"->\");\nmsg.file_size=temp[0];\nmsg.file_name=temp[1];\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":550,"y":760,"wires":[["972dc40eaff9f1bc"]]},{"id":"d73fb4a13f12ab7a","type":"split","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":true,"addname":"key","x":420,"y":760,"wires":[["8c2456856ec5b24b"]]},{"id":"a6dff65466b6a7fb","type":"exec","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"10","oldrc":false,"name":"","x":280,"y":760,"wires":[["d73fb4a13f12ab7a"],[],[]]},{"id":"5662db0254b745eb","type":"function","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"","func":"var user = global.get(\"user\");\nvar ip = global.get(\"host\");\nvar cmd1 = \"ls\";\nvar cmd2 = \"-lvh\";\nvar dir = \"/home/pi/animalTAGS/data/videos/\";\nvar header1 =\"| awk '{print $5 \";\nvar header2 = '\"->\"';\nvar header3 = \" $9}'\";\nvar file = {};\nvar status = {};\n \n//ssh pi@10.42.0.2 ls /home/pi/animalTAGS/data/videos/ -lvh | awk '{print $5 \" -> \" $9}'\nmsg.payload =  `ssh ${user}@${ip} ${cmd1} ${dir} ${cmd2} ${header1}${header2}${header3}`;\n \nreturn msg;\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":150,"y":760,"wires":[["a6dff65466b6a7fb"]]},{"id":"e286697a41b565da","type":"change","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"Restart flow context","rules":[{"t":"set","p":"fileList","pt":"flow","to":"[]","tot":"json"},{"t":"set","p":"lastId","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":880,"wires":[["5662db0254b745eb"]]},{"id":"2c75c54786c83a24","type":"ui_button","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"","group":"2768d5bb10e62e93","order":2,"width":6,"height":1,"passthru":false,"label":"List Video Files","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"test","topicType":"str","x":110,"y":920,"wires":[["e286697a41b565da"]]},{"id":"8e90df1033fd67a1","type":"inject","z":"98ce568d71c2f635","g":"52319e2d3c5564a8","name":"Initialize","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test","x":190,"y":840,"wires":[["e286697a41b565da"]]},{"id":"2768d5bb10e62e93","type":"ui_group","name":"Group 1","tab":"94ff3c5caa315fa9","order":1,"disp":false,"width":6,"collapse":false},{"id":"94ff3c5caa315fa9","type":"ui_tab","name":"Download","icon":"fa-cloud-download fa-2x","order":4,"disabled":false,"hidden":false}]

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