# Ui\_notification view in a only tab

**URL:** https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922
**Category:** Dashboard
**Created:** [19 July 2023 00:09 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922 "2023-07-19T00:09:15Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![GilbertoSpilma](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilbertospilma/32/81402_2.png) [@GilbertoSpilma](https://discourse.nodered.org/u/GilbertoSpilma)
#### Post date: [19 July 2023 00:09 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/1 "2023-07-19T00:09:15Z")

</div>

Hey guys  
I need help  
I am using ui\_notification in red node. But I don't want it to show on other tabs.  
It should appear in a single tab.  
Can you help me?

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [19 July 2023 10:42 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/2 "2023-07-19T10:42:30Z")

</div>

You can use a UI Template node associated to this tab, with a JS script section which issues an alert() command.  
For example:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/3556b6a2f25ee91f8b076414bfdd27bc67af982d.png)

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [19 July 2023 12:17 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/3 "2023-07-19T12:17:33Z")

</div>

Try this

```auto
[{"id":"bb7ef9863eea1ea9","type":"ui_ui_control","z":"02ca79a9a08a0cf4","name":"","events":"all","x":200,"y":740,"wires":[["98f6f8872fac0320","854585b31749180e"]]},{"id":"f33a6678ec5c0348","type":"change","z":"02ca79a9a08a0cf4","name":"allow notifications","rules":[{"t":"set","p":"notifications","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":660,"wires":[[]]},{"id":"98f6f8872fac0320","type":"switch","z":"02ca79a9a08a0cf4","name":"check for dashboard changes","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"change","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":740,"wires":[["6392474fdfc3ea0f"],["6bc115b9e5e2ec8e"]]},{"id":"6392474fdfc3ea0f","type":"switch","z":"02ca79a9a08a0cf4","name":"allow notifications for tab 0 ","property":"tab","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":620,"y":680,"wires":[["f33a6678ec5c0348"],["6bc115b9e5e2ec8e"]]},{"id":"6bc115b9e5e2ec8e","type":"change","z":"02ca79a9a08a0cf4","name":"disable notifications","rules":[{"t":"set","p":"notifications","pt":"global","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":720,"wires":[[]]},{"id":"e9315c323af950c2","type":"ui_toast","z":"02ca79a9a08a0cf4","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"","topic":"","name":"","x":870,"y":840,"wires":[]},{"id":"5d88b5eb9222e5a0","type":"inject","z":"02ca79a9a08a0cf4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello world","payloadType":"str","x":400,"y":840,"wires":[["e5107f52fa76871c"]]},{"id":"e5107f52fa76871c","type":"switch","z":"02ca79a9a08a0cf4","name":"if notifications enabled","property":"notifications","propertyType":"global","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":620,"y":840,"wires":[["e9315c323af950c2"]]},{"id":"854585b31749180e","type":"debug","z":"02ca79a9a08a0cf4","name":"Dashboard says","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":320,"y":680,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![GilbertoSpilma](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilbertospilma/32/81402_2.png) [@GilbertoSpilma](https://discourse.nodered.org/u/GilbertoSpilma)
#### Post date: [19 July 2023 12:52 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/4 "2023-07-19T12:52:00Z")

</div>

Perfect @hotNipi  
But I have several users connected to the server, and your example is linked to screen switching. It can get confusing if one user doesn't switch screens and another does. 🙂  
but the idea was really good. thank you

---

<div class="post-metadata">

### Author: ![GilbertoSpilma](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilbertospilma/32/81402_2.png) [@GilbertoSpilma](https://discourse.nodered.org/u/GilbertoSpilma)
#### Post date: [19 July 2023 12:52 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/5 "2023-07-19T12:52:50Z")

</div>

Thank you for your help.  
I was trying to get away from an html because I have no experience, but I think it's the only way.  
Thanks

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [19 July 2023 17:20 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/6 "2023-07-19T17:20:11Z")

</div>

I don't see any options to send or limit notifications based on socket I'd so this seems to be end of story. It is not possible.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [19 July 2023 20:02 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/7 "2023-07-19T20:02:57Z")

</div>

Notifications should only go to a single client if the socketId is included. It isn't a terribly robust mechanism though since many things can cause a client to get a new socket id.

---

<div class="post-metadata">

### Author: ![GilbertoSpilma](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilbertospilma/32/81402_2.png) [@GilbertoSpilma](https://discourse.nodered.org/u/GilbertoSpilma)
#### Post date: [19 July 2023 23:36 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/8 "2023-07-19T23:36:09Z")

</div>

Can you help me?

this is my node:

[  
{  
"id": "10df8c489491addf",  
"type": "ui\_button",  
"z": "c61d0d5905659bc7",  
"name": "",  
"group": "50e5db1fad5aad4a",  
"order": 1,  
"width": 3,  
"height": 1,  
"passthru": false,  
"label": "OP",  
"tooltip": "",  
"color": "",  
"bgcolor": "",  
"className": "",  
"icon": "",  
"payload": "DIGITE A OP",  
"payloadType": "str",  
"topic": " ",  
"topicType": "str",  
"x": 70,  
"y": 60,  
"wires": [  
[  
"bcca6b5d3dda1e53"  
]  
]  
},  
{  
"id": "bcca6b5d3dda1e53",  
"type": "ui\_toast",  
"z": "c61d0d5905659bc7",  
"position": "prompt",  
"displayTime": "5",  
"highlight": "",  
"sendall": true,  
"outputs": 1,  
"ok": "OK",  
"cancel": "CANCEL",  
"raw": true,  
"className": " ",  
"topic": "",  
"name": " OP",  
"x": 230,  
"y": 60,  
"wires": [  
[  
"b069222f31e953af",  
"2fe887e4857ec0bb",  
"453135cd52728d3e"  
]  
]  
},  
{  
"id": "b069222f31e953af",  
"type": "change",  
"z": "c61d0d5905659bc7",  
"name": "",  
"rules": [  
{  
"t": "move",  
"p": "payload",  
"pt": "msg",  
"to": "op\_busca",  
"tot": "global"  
}  
],  
"action": "",  
"property": "",  
"from": "",  
"to": "",  
"reg": false,  
"x": 170,  
"y": 140,  
"wires": [  
  
]  
},  
{  
"id": "50e5db1fad5aad4a",  
"type": "ui\_group",  
"name": "SELECIONAR CONSULTA",  
"tab": "01defd39958bdd2d",  
"order": 1,  
"disp": true,  
"width": 15,  
"collapse": false,  
"className": ""  
},  
{  
"id": "01defd39958bdd2d",  
"type": "ui\_tab",  
"name": "CONSULTA PRODUÇÃO",  
"icon": "find\_in\_page",  
"order": 10,  
"disabled": false,  
"hidden": false  
}  
]

how change for ui\_template? Thank you

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [20 July 2023 05:12 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/9 "2023-07-20T05:12:10Z")

</div>

> [@TotallyInformation](#):
>
> Notifications should only go to a single client if the socketId is included

Definitely useful info but didn't find anything in documents.  
Anyway, that makes it kind of possible again...

```auto
[{"id":"bb7ef9863eea1ea9","type":"ui_ui_control","z":"02ca79a9a08a0cf4","name":"","events":"all","x":200,"y":1040,"wires":[["854585b31749180e","95883a3ea9e161b1"]]},{"id":"e9315c323af950c2","type":"ui_toast","z":"02ca79a9a08a0cf4","position":"top right","displayTime":"5","highlight":"","sendall":false,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"","topic":"","name":"","x":730,"y":1080,"wires":[]},{"id":"854585b31749180e","type":"debug","z":"02ca79a9a08a0cf4","name":"Dashboard says","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":1040,"wires":[]},{"id":"c3e698e26b68d589","type":"inject","z":"02ca79a9a08a0cf4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello world from trigger node","payloadType":"str","x":210,"y":1080,"wires":[["a39eeb910b13efe8"]]},{"id":"95883a3ea9e161b1","type":"function","z":"02ca79a9a08a0cf4","name":"store dashboards states","func":"let dashboards = global.get('dashboards') || []\nswitch (msg.payload) {\n case \"connect\":\n dashboards.push({socketid:msg.socketid, tab:-1})\n break;\n case \"lost\":\n dashboards = dashboards.filter(function (d) { return d.socketid != msg.socketid; });\n break;\n case \"change\":\n let changed = false\n dashboards.forEach(function(d) {\n if(d.socketid == msg.socketid){\n d.tab = msg.tab\n changed = true\n } \n });\n if(!changed){\n dashboards.push({ socketid: msg.socketid ,tab:msg.tab});\n }\n break;\n default:\n dashboards = []\n \n}\n\nglobal.set('dashboards',dashboards);\n","outputs":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":1000,"wires":[]},{"id":"ea53ae149ba0da3e","type":"inject","z":"02ca79a9a08a0cf4","name":"clear on init","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":980,"wires":[["95883a3ea9e161b1"]]},{"id":"a39eeb910b13efe8","type":"function","z":"02ca79a9a08a0cf4","name":"check for connected dashboards tabs","func":"let allowedTab = 0;\nlet dashboards = global.get('dashboards') || []\n\ndashboards.forEach(function(d) {\n if(d.tab === allowedTab){\n node.send({payload:msg.payload,topic:msg.topic,socketid:d.socketid})\n }\n});\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":1080,"wires":[["e9315c323af950c2"]]}]

```

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [20 July 2023 08:43 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/10 "2023-07-20T08:43:16Z")

</div>

You can use the following:

```auto
[
    {
        "id": "bde8e413e9664562",
        "type": "ui_template",
        "z": "cc0dc37e13d8db0a",
        "group": "50e5db1fad5aad4a",
        "name": "",
        "order": 1,
        "width": 0,
        "height": 0,
        "format": "<form>\n <md-button style=\"background-color:gray;text-transform:none\" class=\"button\" ng-click=\"buttonClick()\"> OP </md-button>\n</form>\n\n<script>\nvar $scope = this.scope;\n\nthis.scope.buttonClick = function()\n{\n let ok = confirm('OK to proceed?');\n let newMsg = {};\n if (ok)\n newMsg.payload = \"OK\";\n else\n newMsg.payload = \"Cancel\";\n \n $scope.send(newMsg);\n}\n\n</script>",
        "storeOutMessages": false,
        "fwdInMessages": false,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 320,
        "y": 100,
        "wires": [
            [
                "b39e2c5ec3b1750e"
            ]
        ]
    },
    {
        "id": "b39e2c5ec3b1750e",
        "type": "debug",
        "z": "cc0dc37e13d8db0a",
        "name": "debug 57",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 460,
        "y": 100,
        "wires": []
    },
    {
        "id": "50e5db1fad5aad4a",
        "type": "ui_group",
        "name": "SELECIONAR CONSULTA",
        "tab": "01defd39958bdd2d",
        "order": 1,
        "disp": true,
        "width": 15,
        "collapse": false,
        "className": ""
    },
    {
        "id": "01defd39958bdd2d",
        "type": "ui_tab",
        "name": "CONSULTA PRODUÇÃO",
        "icon": "find_in_page",
        "order": 10,
        "disabled": false,
        "hidden": false
    }
]

```

Don't move your result to a global variable, as you might run into concurrency issues (race conditions)

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [20 July 2023 19:46 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/11 "2023-07-20T19:46:04Z")

</div>

> [@hotNipi](#):
>
> Definitely useful info but didn't find anything in documents.

I'm sure I remember seeing it somewhere. But worth remembering that Dashboard uses the [Socket.IO](http://Socket.IO) library to manage its websocket connections. The id is managed by that library.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [19 August 2023 19:46 UTC](https://discourse.nodered.org/t/ui-notification-view-in-a-only-tab/79922/12 "2023-08-19T19:46:50Z")

</div>

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