-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #408 from FlowFuse/258-ui-control
Widget: UI Control
- Loading branch information
Showing
35 changed files
with
986 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<template> | ||
<a class="added-in" :href="'https://github.com/FlowFuse/node-red-dashboard/releases/tag/v' + version" target="_blank">Added In: v{{ version }}</a> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'AddedIn', | ||
props: { | ||
version: { | ||
type: String, | ||
required: true | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.added-in { | ||
display: inline-flex; | ||
font-size: 14px; | ||
line-height: 20px; | ||
padding: 3px 9px; | ||
color: var(--vp-c-brand-1); | ||
margin-left: 0.5em; | ||
border-radius: 2rem; | ||
background-color: var(--vp-c-brand-soft); | ||
border: 1px solid var(--vp-c-brand-1); | ||
text-decoration: none; | ||
transition: none; | ||
vertical-align: middle; | ||
} | ||
.added-in:hover { | ||
background-color: var(--vp-c-brand-1); | ||
color: #fff; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
--- | ||
{ | ||
"events": [ | ||
{ | ||
"event": "$pageview", | ||
"payload": "{ page }", | ||
"description": "Sent whenever a user <i>views</i> a given page on the Dashboard" | ||
}, | ||
{ | ||
"event": "$pageleave", | ||
"payload": "{ page }", | ||
"description": "Sent whenever a user <i>leaves</i> a given page on the Dashboard" | ||
} | ||
] | ||
} | ||
--- | ||
|
||
<script setup> | ||
import EventsList from '../../components/EventsList.vue' | ||
import AddedIn from '../../components/AddedIn.vue' | ||
</script> | ||
|
||
# Control `ui-control` <AddedIn version="0.9.0" /> | ||
|
||
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. | ||
|
||
Functionality is generally divided into two main features: | ||
|
||
- **Navigation**: Force the user to move to a new page | ||
- **Display**: Show/Hide groups and pages | ||
- **Disability**: Enable/Disable groups and pages, this still shows them, but prevents interaction | ||
|
||
## Controls List | ||
|
||
Currently, we support the following controls: | ||
|
||
### Navigation | ||
|
||
You can programmaticaly force navigation with the following payloads with `ui-control`: | ||
|
||
#### Change Page | ||
|
||
Explicitely choose the page you want to navigate to: | ||
|
||
```js | ||
// String | ||
msg.payload = '<Page Name>' | ||
|
||
// Object | ||
msg.payload = { | ||
page: '<Page Name>', | ||
} | ||
``` | ||
|
||
#### Next/Previous | ||
|
||
Navigate to the next or previous page in the list: | ||
|
||
```js | ||
// Next Page | ||
msg.payload = "+1" | ||
|
||
// Previous Page | ||
msg.payload = "-1" | ||
``` | ||
|
||
#### Refresh | ||
|
||
You can force a refresh of the current view by sending a blank string payload: | ||
|
||
```js | ||
msg.payload = "" | ||
``` | ||
|
||
### Show/Hide | ||
|
||
You can programmaticaly show/hide groups and pages with the following payload into `ui-control`: | ||
|
||
```js | ||
msg.payload = { | ||
pages: { | ||
show: ['<Page Name>', '<Page Name>'], | ||
hide: ['<Page Name>'] | ||
} | ||
groups: { | ||
show: ['<Group Name>', '<Group Name>'], | ||
hide: ['<Group Name>'] | ||
} | ||
} | ||
``` | ||
|
||
_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. | ||
|
||
### Enable/Disable | ||
|
||
You can programmaticaly disable/enable groups and pages with the following payload into `ui-control`: | ||
|
||
```js | ||
msg.payload = { | ||
pages: { | ||
enable: ['<Page Name>', '<Page Name>'], | ||
disable: ['<Page Name>'] | ||
} | ||
groups: { | ||
enable: ['<Group Name>', '<Group Name>'], | ||
disable: ['<Group Name>'] | ||
} | ||
} | ||
``` | ||
|
||
_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. | ||
|
||
## Events List | ||
|
||
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. | ||
|
||
### Connection Status | ||
|
||
We follow the Dashboard 1.0 convention for emitting socket-based events from the `ui-control` node. | ||
|
||
#### .on('connection') | ||
|
||
When a new Dashboard client connects to Node-RED, the `ui-control` node will emit: | ||
|
||
```js | ||
msg = { | ||
payload: 'connect', | ||
socketid: '<socketid>', | ||
socketip: '<socketip>' | ||
} | ||
``` | ||
|
||
#### .on('disconnect') | ||
|
||
When a Dashboard client disconnects from Node-RED, the `ui-control` node will emit: | ||
|
||
```js | ||
msg = { | ||
payload: 'lost', | ||
socketid: '<socketid>', | ||
socketip: '<socketip>' | ||
} | ||
``` | ||
|
||
### Change Tab/Page | ||
|
||
When a user changes the active tab or page, the `ui-control` node will emit: | ||
|
||
```js | ||
msg = { | ||
payload: 'change', | ||
socketid: '<socketid>', | ||
socketip: '<socketip>', | ||
tab: '<Page Index>', | ||
name: '<Page Name>' | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
{ | ||
"node": "ui_button", | ||
"description": "Button", | ||
"description": "Send events to Dashboard in order to show/hide content, disable/enable content and navigate between pages", | ||
"properties": [ | ||
{ | ||
"property": "label", | ||
"changes": "label", | ||
"notes": "label" | ||
"property": "name", | ||
"changes": null, | ||
"notes": null | ||
}, | ||
{ | ||
"property": "events", | ||
"changes": null, | ||
"notes": "All events supported except for the group open/close events. Track <a href=\"https://github.com/FlowFuse/node-red-dashboard/issues/406\" target=\"blank\">#406 progress here</a>." | ||
} | ||
] | ||
} |
Oops, something went wrong.