|
| 1 | +--- |
| 2 | +{ |
| 3 | + "events": [ |
| 4 | + { |
| 5 | + "event": "$pageview", |
| 6 | + "payload": "{ page }", |
| 7 | + "description": "Sent whenever a user <i>views</i> a given page on the Dashboard" |
| 8 | + }, |
| 9 | + { |
| 10 | + "event": "$pageleave", |
| 11 | + "payload": "{ page }", |
| 12 | + "description": "Sent whenever a user <i>leaves</i> a given page on the Dashboard" |
| 13 | + } |
| 14 | + ] |
| 15 | +} |
| 16 | +--- |
| 17 | + |
| 18 | +<script setup> |
| 19 | + import EventsList from '../../components/EventsList.vue' |
| 20 | + import AddedIn from '../../components/AddedIn.vue' |
| 21 | +</script> |
| 22 | + |
| 23 | +# Control `ui-control` <AddedIn version="0.9.0" /> |
| 24 | + |
| 25 | +This widget doesn't render any content into your Dashboard. Instead, it provides an interface for you to control the behaviour of your Dashboard from within the Node-RED Editor. |
| 26 | + |
| 27 | +Functionality is generally divided into two main features: |
| 28 | + |
| 29 | +- **Navigation**: Force the user to move to a new page |
| 30 | +- **Display**: Show/Hide groups and pages |
| 31 | +- **Disability**: Enable/Disable groups and pages, this still shows them, but prevents interaction |
| 32 | + |
| 33 | +## Controls List |
| 34 | + |
| 35 | +Currently, we support the following controls: |
| 36 | + |
| 37 | +### Navigation |
| 38 | + |
| 39 | +You can programmaticaly force navigation with the following payloads with `ui-control`: |
| 40 | + |
| 41 | +#### Change Page |
| 42 | + |
| 43 | +Explicitely choose the page you want to navigate to: |
| 44 | + |
| 45 | +```js |
| 46 | +// String |
| 47 | +msg.payload = '<Page Name>' |
| 48 | + |
| 49 | +// Object |
| 50 | +msg.payload = { |
| 51 | + page: '<Page Name>', |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +#### Next/Previous |
| 56 | + |
| 57 | +Navigate to the next or previous page in the list: |
| 58 | + |
| 59 | +```js |
| 60 | +// Next Page |
| 61 | +msg.payload = "+1" |
| 62 | + |
| 63 | +// Previous Page |
| 64 | +msg.payload = "-1" |
| 65 | +``` |
| 66 | + |
| 67 | +#### Refresh |
| 68 | + |
| 69 | +You can force a refresh of the current view by sending a blank string payload: |
| 70 | + |
| 71 | +```js |
| 72 | +msg.payload = "" |
| 73 | +``` |
| 74 | + |
| 75 | +### Show/Hide |
| 76 | + |
| 77 | +You can programmaticaly show/hide groups and pages with the following payload into `ui-control`: |
| 78 | + |
| 79 | +```js |
| 80 | +msg.payload = { |
| 81 | + pages: { |
| 82 | + show: ['<Page Name>', '<Page Name>'], |
| 83 | + hide: ['<Page Name>'] |
| 84 | + } |
| 85 | + groups: { |
| 86 | + show: ['<Group Name>', '<Group Name>'], |
| 87 | + hide: ['<Group Name>'] |
| 88 | + } |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +_Note:_ `pages` can be subbed with `tabs` as per Dashboard 1.0 and `groups` can also be subbed with `group` as per Dashboard 1.0. |
| 93 | + |
| 94 | +### Enable/Disable |
| 95 | + |
| 96 | +You can programmaticaly disable/enable groups and pages with the following payload into `ui-control`: |
| 97 | + |
| 98 | +```js |
| 99 | +msg.payload = { |
| 100 | + pages: { |
| 101 | + enable: ['<Page Name>', '<Page Name>'], |
| 102 | + disable: ['<Page Name>'] |
| 103 | + } |
| 104 | + groups: { |
| 105 | + enable: ['<Group Name>', '<Group Name>'], |
| 106 | + disable: ['<Group Name>'] |
| 107 | + } |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +_Note:_ `pages` can be subbed with `tabs` as per Dashboard 1.0 and `groups` can also be subbed with `group` as per Dashboard 1.0. |
| 112 | + |
| 113 | +## Events List |
| 114 | + |
| 115 | +In addition to `ui-control` taking input to _control_ the UI, we have also maintained support for all events emitted by `ui-control` from Dashboard 1.0 here too. |
| 116 | + |
| 117 | +### Connection Status |
| 118 | + |
| 119 | +We follow the Dashboard 1.0 convention for emitting socket-based events from the `ui-control` node. |
| 120 | + |
| 121 | +#### .on('connection') |
| 122 | + |
| 123 | +When a new Dashboard client connects to Node-RED, the `ui-control` node will emit: |
| 124 | + |
| 125 | +```js |
| 126 | +msg = { |
| 127 | + payload: 'connect', |
| 128 | + socketid: '<socketid>', |
| 129 | + socketip: '<socketip>' |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +#### .on('disconnect') |
| 134 | + |
| 135 | +When a Dashboard client disconnects from Node-RED, the `ui-control` node will emit: |
| 136 | + |
| 137 | +```js |
| 138 | +msg = { |
| 139 | + payload: 'lost', |
| 140 | + socketid: '<socketid>', |
| 141 | + socketip: '<socketip>' |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +### Change Tab/Page |
| 146 | + |
| 147 | +When a user changes the active tab or page, the `ui-control` node will emit: |
| 148 | + |
| 149 | +```js |
| 150 | +msg = { |
| 151 | + payload: 'change', |
| 152 | + socketid: '<socketid>', |
| 153 | + socketip: '<socketip>', |
| 154 | + tab: '<Page Index>', |
| 155 | + name: '<Page Name>' |
| 156 | +} |
| 157 | +``` |
0 commit comments