Opening external links using dashboard buttons

With this flow it is possible to trigger a dashboard ui_template to open external links within the actual or a new window/tab using a dashboard button. With a little modification it is also possible to inject a URL directly as a string into a ui_template node for opening.

It is based on this article:

https://flows.nodered.org/flow/2f1aaf0635f9bf23207152682323240a

[{"id":"7db57965.76d468","type":"ui_button","z":"63cf87a7.f8f618","name":"","group":"ca2272c3.e8396","order":1,"width":"4","height":"1","passthru":false,"label":"Node-RED","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Node-RED","payloadType":"str","topic":"","x":190,"y":120,"wires":[["ece06122.7e762"]]},{"id":"5e1f0081.6dc3c","type":"ui_template","z":"63cf87a7.f8f618","group":"ca2272c3.e8396","name":"window redirect","order":3,"width":0,"height":0,"format":"<script>\n(function(scope) {\n    scope.$watch('msg.payload', function(data) {\n        if (data == \"Node-RED\") {\n          //window.open(\"https://www.nodered.org\");\n          window.location.href = \"https://www.nodered.org\";\n        } \n        if (data == \"GitHub\") {\n          //window.open(\"https://github.com/node-red\");\n          window.location.href = \"https://github.com/node-red\";\n        } \n    });\n})(scope);\n</script>","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":560,"y":140,"wires":[["8582289.2d757d8"]]},{"id":"23caf401.9d6d4c","type":"ui_button","z":"63cf87a7.f8f618","name":"","group":"ca2272c3.e8396","order":2,"width":"4","height":"1","passthru":false,"label":"GitHub","tooltip":"","color":"","bgcolor":"","icon":"","payload":"GitHub","payloadType":"str","topic":"","x":180,"y":160,"wires":[["ece06122.7e762"]]},{"id":"ece06122.7e762","type":"trigger","z":"63cf87a7.f8f618","name":"reset msg","op1":"","op2":"empty","op1type":"pay","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":380,"y":140,"wires":[["5e1f0081.6dc3c"]]},{"id":"8582289.2d757d8","type":"debug","z":"63cf87a7.f8f618","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":140,"wires":[]},{"id":"ca2272c3.e8396","type":"ui_group","name":"Group 1","tab":"d9bf7560.df5e58","order":1,"disp":true,"width":6},{"id":"d9bf7560.df5e58","type":"ui_tab","name":"Test","icon":"dashboard","order":9,"disabled":false,"hidden":false}]

Flow Info

Created 3 years, 9 months ago
Rating: 4.166666666666667 6

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • trigger (x1)
Other
  • ui_button (x2)
  • ui_group (x1)
  • ui_tab (x1)
  • ui_template (x1)

Tags

  • dashboard
  • ui
  • external
  • link
  • button
  • template
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option