remote control: add /STATE methods
This commit is contained in:
parent
f88fb2529f
commit
f0a79e5c6e
3 changed files with 64 additions and 0 deletions
|
|
@ -5,6 +5,10 @@
|
|||
- bug fixes:
|
||||
- modal: `css` not properly applied if the property was previously empty and the modal had been opened at least once
|
||||
- image: allow overriding css background-image when value is empty
|
||||
- widgets
|
||||
- switchers: new `state` widget
|
||||
- remote control
|
||||
- added `/STATE/[GET|SET|STORE|RECALL]` methods
|
||||
|
||||
## 0.45.7
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,28 @@ Set a widget's value as if it was interacted with from the interface. This is li
|
|||
- `value`: `*`, widget's new value
|
||||
|
||||
|
||||
## `/STATE/GET target`
|
||||
|
||||
Sends back the app's state to specified target
|
||||
|
||||
- `target`: `string`, `ip:port` pair
|
||||
|
||||
## `/STATE/GET state`
|
||||
|
||||
Set widgets' state
|
||||
|
||||
- `state`: `string`, json stringified object (`"widget_id": value` pairs)
|
||||
|
||||
|
||||
## `/STATE/STORE`
|
||||
|
||||
Save the state of all widgets in the temporary slot.
|
||||
|
||||
## `/STATE/RECALL`
|
||||
|
||||
Reload saved state from the temporary slot.
|
||||
|
||||
|
||||
## `/TABS id id etc`
|
||||
|
||||
Open the tabs designated by the `id` parameters.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
var {updateWidget} = require('./editor/data-workers'),
|
||||
editor = require('./editor'),
|
||||
widgetManager = require('./managers/widgets'),
|
||||
stateManager = require('./managers/state'),
|
||||
deepExtend = require('deep-extend')
|
||||
|
||||
var callbacks = {
|
||||
|
|
@ -174,6 +175,43 @@ var callbacks = {
|
|||
|
||||
}
|
||||
|
||||
},
|
||||
'/STATE/GET': function(args) {
|
||||
|
||||
if (Array.isArray(args)) args = args[0]
|
||||
|
||||
var target = args,
|
||||
root = widgetManager.getWidgetById('root')[0],
|
||||
state = stateManager.get()
|
||||
|
||||
root.sendValue({
|
||||
target: [target],
|
||||
address: '/STATE/GET',
|
||||
preArgs: [],
|
||||
v: JSON.stringify(state),
|
||||
noSync: true
|
||||
}, {force: true})
|
||||
|
||||
},
|
||||
'/STATE/SET': function(args) {
|
||||
|
||||
if (Array.isArray(args)) args = args[0]
|
||||
|
||||
var json = args,
|
||||
data = typeof json == 'string' ? JSON.parseFlex(json) : json
|
||||
|
||||
stateManager.set(data)
|
||||
|
||||
},
|
||||
'/STATE/STORE': function(args) {
|
||||
|
||||
stateManager.quickSave()
|
||||
|
||||
},
|
||||
'/STATE/RECALL': function(args) {
|
||||
|
||||
stateManager.quickLoad()
|
||||
|
||||
},
|
||||
'/TABS': function(args) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue