Notification Shows on Multiple Sessions

I noticed that when I generate a Notification popup on one web/session instance, it shows up on other web/sessions on another PC.

I thought there was a way to localize it, but could not find anything.

Any suggestions?

Thanks...

You need to give a lot more context. We have no idea how you are generating popups nor against what ui (admin, dashbord, ...)

Sure, the ui_notification widget in the dashboard. Basically when it gets fired, the notification will appear on all connected PC to the NR server instead of the one that triggered it (Basically a button press).

I don't believe that the Dashboard is multi-user. So all connected clients will receive the same information.

If you wish to do more, you will need to forgo the easy layout offered by Dashboard and roll your own interface using uibuilder I think.

I Guess there is no session ID filtering then?

Nope. :frowning:

Dashboard is fabulous for getting going quickly but you eventually tend to hit a cliff. That's why I created uibuilder. No cliff but no hand-holding either I'm afraid. Still there are plenty of tools around that will design a layout for you.

It should work to alert to the session . can you share your flow from button to alert ?

Sure here is the flow...

[{"id":"8465fd14.c6b5f","type":"function","z":"5ac8df83.57bca","name":"Send Switch Logic","func":"var canopy = global.get(\"Canopy_Override\").toString();\n\nif(canopy === \"ON\")\n{\n    msg.newValue = \"0\";\n}\nelse if(canopy === \"OFF\")\n{\n    msg.newValue = \"1\";\n}\nelse\n{\n    msg.newValue = \"0\";\n}\nvar msg1;\nmsg1 = {payload:\"Sending Request, Stby...\"};\n\nreturn [msg,msg1];","outputs":2,"noerr":0,"x":350,"y":2650,"wires":[["adba7273.42ac8"],["c4af39fe.323b18"]]},{"id":"c4af39fe.323b18","type":"ui_toast","z":"5ac8df83.57bca","position":"top right","displayTime":"5","highlight":"sandybrown","outputs":0,"ok":"OK","cancel":"","topic":"Lighting Override Request","name":"Override Request","x":590,"y":2690,"wires":[]}]

Hi,

so that doesn't include the button - but no matter... the output you have the notification on is the second one. You are creating a completely new msg1 for that output that doesn't include the msg.socketid that would have come from the button to indicate which browser to send the notification to...

So if you include msg1.socketid = msg.socketid; it should work

1 Like

Just tried it... Did not work. Notification still appears on the other PC.
:frowning:

Post a flow that we can try that shows the problem. Your last one didn't include the button apparently.

OK,

[{"id":"593fa17d.0a7f2","type":"ui_button","z":"5ac8df83.57bca","name":"Canopy Override","group":"1218f184.feaaae","order":6,"width":0,"height":0,"passthru":false,"label":"{{msg.topic}}","tooltip":"","color":"{{msg.colour}}","bgcolor":"{{msg.background}}","icon":"","payload":"Clicked","payloadType":"str","topic":"","x":140,"y":2650,"wires":[["8465fd14.c6b5f"]]},{"id":"8465fd14.c6b5f","type":"function","z":"5ac8df83.57bca","name":"Send Switch Logic","func":"var canopy = global.get(\"Canopy_Override\").toString();\n\nif(canopy === \"ON\")\n{\n    msg.newValue = \"0\";\n}\nelse if(canopy === \"OFF\")\n{\n    msg.newValue = \"1\";\n}\nelse\n{\n    msg.newValue = \"0\";\n}\nvar msg1;\nmsg1 = {payload:\"Sending Request, Stby...\"};\n\nreturn [msg,msg1];","outputs":2,"noerr":0,"x":350,"y":2650,"wires":[["adba7273.42ac8"],["c4af39fe.323b18"]]},{"id":"c4af39fe.323b18","type":"ui_toast","z":"5ac8df83.57bca","position":"top right","displayTime":"5","highlight":"sandybrown","outputs":0,"ok":"OK","cancel":"","topic":"Lighting Override Request","name":"Override Request","x":590,"y":2690,"wires":[]},{"id":"1218f184.feaaae","type":"ui_group","z":"","name":"Lighting","tab":"e012b214.41c0d","order":6,"disp":true,"width":"4","collapse":false},{"id":"e012b214.41c0d","type":"ui_tab","z":"","name":"Site Supervisor Manager's Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Hope this helps...Thanks..

You don't seem to have made the change to msg1 that @dceejay suggested

Oh, crap. I sent the wrong flow... Here ya go...

[{"id":"6c70282b.192b88","type":"ui_button","z":"5ac8df83.57bca","name":"Sign Override","group":"1218f184.feaaae","order":2,"width":0,"height":0,"passthru":false,"label":"{{msg.topic}}","tooltip":"","color":"{{msg.colour}}","bgcolor":"{{msg.background}}","icon":"","payload":"Clicked","payloadType":"str","topic":"","x":130,"y":2260,"wires":[["ac65c7e1.c10198"]]},{"id":"ac65c7e1.c10198","type":"function","z":"5ac8df83.57bca","name":"Send Switch Logic","func":"var sign = global.get(\"Sign_Override\").toString();\n\nif(sign === \"ON\")\n{\n    msg.newValue = \"0\";\n}\nelse if(sign === \"OFF\")\n{\n    msg.newValue = \"1\";\n}\nelse\n{\n    msg.newValue = \"0\";\n}\nvar msg1;\nmsg1 = {payload:\"Sending Request, Stby...\"};\nmsg1.socketid = msg.socketid;\nreturn [msg,msg1];","outputs":2,"noerr":0,"x":330,"y":2260,"wires":[["21b106d3.fd0b9a"],["5cd04b19.c9cd14"]]},{"id":"5cd04b19.c9cd14","type":"ui_toast","z":"5ac8df83.57bca","position":"top right","displayTime":"5","highlight":"sandybrown","outputs":0,"ok":"OK","cancel":"","topic":"Lighting Override Request","name":"Override Request","x":580,"y":2300,"wires":[]},{"id":"1218f184.feaaae","type":"ui_group","z":"","name":"Lighting","tab":"e012b214.41c0d","order":6,"disp":true,"width":"4","collapse":false},{"id":"e012b214.41c0d","type":"ui_tab","z":"","name":"Site Supervisor Manager's Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I had to remove the code referencing the global context variable in order to get it to run (I hate global and flow context and never use them, but that is just a pet hate of mine, there are almost always other ways), but yes you are right, the notification does appear in all sessions. Over to @dceejay I think.

Ah - so... double checking the code :-)... alerts DO go to all clients... - but OK/Cancel dialogs don't. hmm - maybe should make that optional in next version ?

2 Likes

I can imagine that sometimes one would want notification on all windows, and sometimes not, so making it optional sounds like a good idea.

I agree, maybe a checkbox in the UI interface something like "Notify in All Sessions"

Thanks...

in master - not yet on npm

5 Likes

When can we expect a npm release?