# Dashboard - Query if someone is viewing only

**URL:** <https://discourse.nodered.org/t/dashboard-query-if-someone-is-viewing-only/34346>\
**Category:** Dashboard\
**Created:** [16 October 2020 12:46 UTC](https://discourse.nodered.org/t/dashboard-query-if-someone-is-viewing-only/34346 "2020-10-16T12:46:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spyder0552](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spyder0552/32/14035_2.png) [@spyder0552](https://discourse.nodered.org/u/spyder0552)\
**Post date:** [16 October 2020 12:46 UTC](https://discourse.nodered.org/t/dashboard-query-if-someone-is-viewing-only/34346/1 "2020-10-16T12:46:04Z")

</div>

Hi all,  
So I have some great dashboards built. However, I have a lot of inject nodes running every few seconds to query a database and display data.

My question is, is there something I can do to check if someone is actually viewing the dashboard page and if so, then run the inject queries.

Right now I am chewing up CPU and RAM by doing all there queries if someone is looking at the dashboard or not.

I am thinking a websocket...but have no idea how that works so any suggestions or examples would be fantastic.

Thanks everyone!!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [16 October 2020 12:55 UTC](https://discourse.nodered.org/t/dashboard-query-if-someone-is-viewing-only/34346/2 "2020-10-16T12:55:52Z")

</div>

look at the `ui_control` node. It outputs an event whenever anyone connects - so you can use that to trigger or start your queries (and then stop when =0)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [16 October 2020 12:56 UTC](https://discourse.nodered.org/t/dashboard-query-if-someone-is-viewing-only/34346/3 "2020-10-16T12:56:09Z")

</div>

The ui\_control node will do what you require.

> When any browser client connects or loses connection, changes tab, or expands or collapses a group this node will emit a `msg` containing:

- `payload` - _connect_ , _lost_ , _change_ , or _group_ .
- `socketid` - the ID of the socket (this will change every time the browser reloads the page).
- `socketip` - the ip address from where the connection originated.
- `tab` - the number of the tab. (only for 'change' event).
- `name` - the name of the tab. (only for 'change' event).
- `group` - the name of the group. (only for 'group' event).
- `open` - the state of the group. (only for 'group' event).

> Optional - report only connect events - useful to use to trigger a resend of data to a new client without needing to filter out other events.

---

<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:** [15 November 2020 12:56 UTC](https://discourse.nodered.org/t/dashboard-query-if-someone-is-viewing-only/34346/4 "2020-11-15T12:56:12Z")

</div>

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