From d7ce10c5e2ce5a19faedac927b1d3d952f0265f2 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 21 Dec 2017 07:34:23 +0100 Subject: [PATCH] remote control: make /GET reply to /GET (with widget address in args) (issue #56) --- resources/docs/extras/remote-control.md | 40 +++++++++++++++++++++++++ src/browser/js/app/remote-control.js | 8 ++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/resources/docs/extras/remote-control.md b/resources/docs/extras/remote-control.md index 8fea28f0..e2577ee1 100644 --- a/resources/docs/extras/remote-control.md +++ b/resources/docs/extras/remote-control.md @@ -28,6 +28,46 @@ Apply a set of options to an existing widget by merging them to the widget's opt !!! warning "" Editing a widget can be cpu expensive, hence updating the UI continuously is not a good idea +## `/EDIT/GET target id` + +Sends back a widget's data (JSON stringified object), including its children, to specified target. + +- `target`: `string`, `ip:port` pair +- `id`: `string`, widget's `id` + +Returns `/EDIT/GET id data` + +- `id`: `string` +- `data`: `string` + +## `/GET target id` + +Sends back a widget's value to specified target. + +- `target`: `string`, `ip:port` pair +- `id`: `string`, widget's `id` + +Returns `/GET id value` + +- `id`: `string` +- `value`: `*` + +## `/GET target address preArg1 preArg2 ...` + +Sends back a widget's value to specified target. + +- `target`: `string`, `ip:port` pair +- `address`: `string`, widget's `address` +- `preArg[1...]`: `*`, widget's `preArgs` + +Returns `/GET address preArg1 preArg2 ... value` + +- `id`: `string` +- `address`: `string`, widget's `address` +- `preArg[1...]`: `*`, widget's `preArgs` +- `value`: `*` + + ## `/TABS id id etc` Open the tabs designated by the `id` parameters. The target tab link must be accesible (opening a tab located in a disabled tab won't work unless you specify the parent tab's `id` before; the safest way to go is to pass the whole tab tree to enable). diff --git a/src/browser/js/app/remote-control.js b/src/browser/js/app/remote-control.js index 18388d3e..722a6285 100644 --- a/src/browser/js/app/remote-control.js +++ b/src/browser/js/app/remote-control.js @@ -56,7 +56,7 @@ var callbacks = { ], nosync: true }) - + } }, '/GET':function(args) { @@ -76,12 +76,12 @@ var callbacks = { } - if (!widgets.length) return - for (var i = widgets.length - 1; i >= 0; i--) { return widgets[i].sendValue({ - target:[target], + target: [target], + address: '/GET', + preArgs: [idOrAddress, ...preArgs], nosync: true })