Hello Good peoples,
I have a small issue opening URL’s
When a user opens a URL or opens for every other user who has the dashboard open.
Is there a way so it only opens for the user that requested it?
Hello Good peoples,
I have a small issue opening URL’s
When a user opens a URL or opens for every other user who has the dashboard open.
Is there a way so it only opens for the user that requested it?
What do you mean by opening a URL?
Please let us know which Dashboard you are using.
Dashboard 1
Thanks, now we need a bit more info on what “opening a URL” means in your setup as Colin has mentioned.
Get the users browser to open a http address
I have that part working but it opens on all users browsers not just on the user that requested it.
You aren’t giving us much to go on.
Assuming that you use something on the Dashboard to trigger a flow that instructs the browser to move to the new URL? If so, you need to remember to include the socket id from the original requesting client.
If you don’t include the socket id from the original Dashboard input, the response goes to all connected clients.
How are you doing that? Are you opening it in an iframe in the dashboard for example?
[
{
"id": "e1dcfd268ac5f6bb",
"type": "ui_button",
"z": "1d021220734c735f",
"name": "",
"group": "bea2c1075a7d3a65",
"order": 8,
"width": 5,
"height": 1,
"passthru": false,
"label": "Open",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "fa-folder-open",
"payload": "",
"payloadType": "str",
"topic": "topic",
"topicType": "msg",
"x": 2760,
"y": 1960,
"wires": [
[
"bbd1715522a68721"
]
]
},
{
"id": "390912bdad30b310",
"type": "ui_template",
"z": "1d021220734c735f",
"group": "bea2c1075a7d3a65",
"name": "window redirect",
"order": 7,
"width": 1,
"height": 1,
"format": "<script>\n (function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg && msg.url) {\n window.open(msg.url, '_blank');\n }\n });\n })(scope);\n</script>",
"storeOutMessages": false,
"fwdInMessages": true,
"resendOnRefresh": false,
"templateScope": "local",
"className": "",
"x": 3340,
"y": 1960,
"wires": [
[]
]
},
{
"id": "bbd1715522a68721",
"type": "function",
"z": "1d021220734c735f",
"name": "test",
"func": "msg.url = \"https://google.com",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 3040,
"y": 1960,
"wires": [
[
"390912bdad30b310"
]
]
},
{
"id": "bea2c1075a7d3a65",
"type": "ui_group",
"name": "test",
"tab": "58c2aa06.ef46e4",
"order": 4,
"disp": false,
"width": 25,
"collapse": false,
"className": ""
},
{
"id": "58c2aa06.ef46e4",
"type": "ui_tab",
"name": "test",
"icon": "fa-umbrella",
"order": 1,
"disabled": false,
"hidden": false
}
]
arr yes.. helpful information..
I will try some code and see how i go
Your function node seems not to have a return msg
so it will not pass anything on.
Corrected your example flow and it works for me, opening a window in only the browser where button is clicked. As @TotallyInformation has pointed out it must be that your flow is removing the socketid
Corrected and working example
[{"id":"e1dcfd268ac5f6bb","type":"ui_button","z":"d1395164b4eec73e","name":"","group":"bea2c1075a7d3a65","order":8,"width":5,"height":1,"passthru":false,"label":"Open","tooltip":"","color":"","bgcolor":"","className":"","icon":"fa-folder-open","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":90,"y":1900,"wires":[["bbd1715522a68721"]]},{"id":"bbd1715522a68721","type":"function","z":"d1395164b4eec73e","name":"test","func":"msg.url = \"https://google.com\"\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":1900,"wires":[["390912bdad30b310"]]},{"id":"390912bdad30b310","type":"ui_template","z":"d1395164b4eec73e","group":"bea2c1075a7d3a65","name":"window redirect","order":7,"width":1,"height":1,"format":"<script>\n (function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg && msg.url) {\n window.open(msg.url, '_blank');\n }\n });\n })(scope);\n</script>","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":400,"y":1900,"wires":[[]]},{"id":"bea2c1075a7d3a65","type":"ui_group","name":"test","tab":"58c2aa06.ef46e4","order":4,"disp":false,"width":25,"collapse":false,"className":""},{"id":"58c2aa06.ef46e4","type":"ui_tab","name":"test","icon":"fa-umbrella","order":1,"disabled":false,"hidden":false}]
Of course, you don’t actually need a flow at all for this. Simply get the browser to change location itself - no need for a round-trip to Node-RED and back. Then you wouldn’t have a problem with other users being triggered.
document.location.href = newUrl;
Is all you need
Thanks Gents.
All Sorted.. As usual when you come to this forum