Handling multiple ui-media nodes

You could use a template node

example : https://flows.nodered.org/flow/02c51764b0454f8c3e77bcfe5c87dda5

Or you could serve them up on an endpoint - something like this...

[{"id":"8b297b2a.310d88","type":"ui_template","z":"e360ac5b.0ab79","group":"7c8519ea.62ce78","name":"ui_temlplate - put images dashboard","order":0,"width":"6","height":"10","format":"<div>Images</div>\n\n<div ng-click=\"send({topic:'pic1',payload:'clicked'});\">\n    <img src='/files/pic1.jpg' />\n</div>\n\n<div ng-click=\"send({topic:'pic2',payload:'clicked'});\">\n    <img src='/files/pic2.jpg' />\n</div>\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":530,"y":900,"wires":[["91255cbe.bcbcb"]],"info":"## Title\n### Info...\n- point 1\n- point 2\n\n*More info*"},{"id":"7cf1d3de.fc9fac","type":"function","z":"e360ac5b.0ab79","name":"Set base path","func":"//restrict to c:\\temp\\\nvar basePath = \"c:\\\\temp\\\\\";\nvar filename = msg.req.params.fn;\n\n\nif(filename.includes(\"..\\\\\")){\n    msg.payload = \"Illegal file path\";\n    msg.statusCode = 405;//not allowed\n    return [null, msg];//fire output 2\n} else if(filename.includes(\"../\")){\n    msg.payload = \"Illegal file path\";\n    msg.statusCode = 405;//not allowed\n    return [null, msg];//fire output 2\n} \n//TODO: add more checks\n\nmsg.filename = basePath + filename;\nreturn [msg, null];//fire output 1\n\n\n","outputs":2,"noerr":0,"x":400,"y":740,"wires":[["1517433f.bb21dd"],["f68ec975.1fbf78"]]},{"id":"f68ec975.1fbf78","type":"http response","z":"e360ac5b.0ab79","name":"","statusCode":"","headers":{},"x":750,"y":780,"wires":[]},{"id":"1517433f.bb21dd","type":"file in","z":"e360ac5b.0ab79","name":"","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":590,"y":720,"wires":[["f68ec975.1fbf78"]]},{"id":"87ac48c8.e3ba48","type":"catch","z":"e360ac5b.0ab79","name":"","scope":null,"uncaught":false,"x":220,"y":820,"wires":[["ebb706f2.2cd1e8","3890aca9.df1894"]]},{"id":"ebb706f2.2cd1e8","type":"function","z":"e360ac5b.0ab79","name":"Set 404","func":"msg.payload = msg.error;\nmsg.statusCode = 404;//resource not found\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":820,"wires":[["f68ec975.1fbf78"]]},{"id":"3890aca9.df1894","type":"debug","z":"e360ac5b.0ab79","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":250,"y":860,"wires":[]},{"id":"4cd4d073.fc8dc","type":"comment","z":"e360ac5b.0ab79","name":"Create http endpoint <nodered>/files/xxx  where xxx is the file name to get","info":"","x":420,"y":680,"wires":[]},{"id":"c2258986.6136f8","type":"http in","z":"e360ac5b.0ab79","name":"","url":"/files/:fn","method":"get","upload":false,"swaggerDoc":"","x":230,"y":740,"wires":[["7cf1d3de.fc9fac"]]},{"id":"91255cbe.bcbcb","type":"debug","z":"e360ac5b.0ab79","name":"click events","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":940,"wires":[]},{"id":"7c8519ea.62ce78","type":"ui_group","z":"","name":"files group","tab":"d1a37ab6.d52ac8","disp":true,"width":"6","collapse":false,"info":"## Title\n### Info...\n- point 1\n- point 2\n\n*More info*"},{"id":"d1a37ab6.d52ac8","type":"ui_tab","z":"","name":"Files","icon":"dashboard","disabled":false,"hidden":false,"info":"## Title\n### Info...\n- point 1\n- point 2\n\n*More info*"}]

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