ioBroker.admin icon indicating copy to clipboard operation
ioBroker.admin copied to clipboard

Add a jsonconfig element to "sendToAndOpenReturnedUrl"

Open Apollon77 opened this issue 3 years ago • 2 comments
trafficstars

I would like to send a message to the adapter to construct an URL that the user needs to visit. The idea is to use this to start an OAuth2 Flow.

Techncially it should support the same like "sendTo" (including sendung data to the server side) and can return an URL or an error. If error is returned the error is displayed. The returned URL is opened in a new windows ("_blank"?)

Ideally we get somehow an option to get the "Admin Base URL" as a value that we can also send to server side. "Admin base URL" being "protocol, host, port and potential "rteverse proxy path parts".

Apollon77 avatar Jul 27 '22 12:07 Apollon77

  • sendto - button that sends request to instance (https://github.com/iobroker-community-adapters/ioBroker.email/blob/master/admin/index_m.html#L128)
    • command - (Default send)
    • jsonData - string - {"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}. You can use special variable _origin to send to instance the caller URL, like http://localhost:8081/admin.
    • data - object - {"subject1": 1, "data": "static"}. You can specify jsonData or data, but not both.
    • result - {result1: {en: 'A'}, result2: {en: 'B'}}
    • error - {error1: {en: 'E'}, error2: {en: 'E2'}}
    • variant - contained, outlined or nothing
    • openUrl - if true - open URL in new tab, if response contains attribute openUrl, like {"openUrl": "http://1.2.3.4:80/aaa", "window": "_blank"}
    • window - if openUrl is true, this is name of new window. Could be overwritten if response consist window attribute. this.props.socket.sendTo(adapterName.instance, command || 'send', data, result => {});

So the simpliest example looks like:

"_send": {
          "newLine": true,
          "label": "SEND",
          type: "sendto",
          "command": "url",
          "openUrl": true,
          "window": "netatmo"
}

GermanBluefox avatar Jul 27 '22 17:07 GermanBluefox

@Apollon77 Can you please check with current admin version if this issue is fixed?

Feuer-sturm avatar Aug 01 '22 17:08 Feuer-sturm