diff --git a/bundles/org.openhab.ui/doc/components/oh-aggregate-series.md b/bundles/org.openhab.ui/doc/components/oh-aggregate-series.md index 2f707d73c3..ea41f6be69 100644 --- a/bundles/org.openhab.ui/doc/components/oh-aggregate-series.md +++ b/bundles/org.openhab.ui/doc/components/oh-aggregate-series.md @@ -157,13 +157,14 @@ prev: /docs/ui/components/ - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -171,6 +172,22 @@ prev: /docs/ui/components/ Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-button.md b/bundles/org.openhab.ui/doc/components/oh-button.md index e4bc9e4d61..b873b3c176 100644 --- a/bundles/org.openhab.ui/doc/components/oh-button.md +++ b/bundles/org.openhab.ui/doc/components/oh-button.md @@ -137,13 +137,14 @@ Button performing an action - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -151,6 +152,22 @@ Button performing an action Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on @@ -296,13 +313,14 @@ Button performing an action - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -310,6 +328,22 @@ Button performing an action Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-calendar-axis.md b/bundles/org.openhab.ui/doc/components/oh-calendar-axis.md index c8d18a10f8..8731d6b9d6 100644 --- a/bundles/org.openhab.ui/doc/components/oh-calendar-axis.md +++ b/bundles/org.openhab.ui/doc/components/oh-calendar-axis.md @@ -74,13 +74,14 @@ prev: /docs/ui/components/ - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -88,6 +89,22 @@ prev: /docs/ui/components/ Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-calendar-series.md b/bundles/org.openhab.ui/doc/components/oh-calendar-series.md index da8675b4fc..f7284bef99 100644 --- a/bundles/org.openhab.ui/doc/components/oh-calendar-series.md +++ b/bundles/org.openhab.ui/doc/components/oh-calendar-series.md @@ -119,13 +119,14 @@ prev: /docs/ui/components/ - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -133,6 +134,22 @@ prev: /docs/ui/components/ Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-cell.md b/bundles/org.openhab.ui/doc/components/oh-cell.md index 023bcebdc2..db38deccaf 100644 --- a/bundles/org.openhab.ui/doc/components/oh-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-cell.md @@ -87,13 +87,14 @@ A regular or expandable cell - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -101,6 +102,22 @@ A regular or expandable cell Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-clock-card.md b/bundles/org.openhab.ui/doc/components/oh-clock-card.md index b43e865391..473e64c504 100644 --- a/bundles/org.openhab.ui/doc/components/oh-clock-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-clock-card.md @@ -142,13 +142,14 @@ Display a digital clock in a card - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -156,6 +157,22 @@ Display a digital clock in a card Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md b/bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md index 49f537cc0b..efaca0eda3 100644 --- a/bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md @@ -116,13 +116,14 @@ A cell expanding to a color picker - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -130,6 +131,22 @@ A cell expanding to a color picker Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-data-series.md b/bundles/org.openhab.ui/doc/components/oh-data-series.md index 370e77cd3b..e942b1021e 100644 --- a/bundles/org.openhab.ui/doc/components/oh-data-series.md +++ b/bundles/org.openhab.ui/doc/components/oh-data-series.md @@ -60,13 +60,14 @@ prev: /docs/ui/components/ - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -74,6 +75,22 @@ prev: /docs/ui/components/ Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-gauge-card.md b/bundles/org.openhab.ui/doc/components/oh-gauge-card.md index 48cc372968..e21adc94ba 100644 --- a/bundles/org.openhab.ui/doc/components/oh-gauge-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-gauge-card.md @@ -178,13 +178,14 @@ Display a read-only gauge in a card to visualize a quantifiable item - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -192,6 +193,22 @@ Display a read-only gauge in a card to visualize a quantifiable item Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-icon.md b/bundles/org.openhab.ui/doc/components/oh-icon.md index 8764f2e8a3..bcae5af35f 100644 --- a/bundles/org.openhab.ui/doc/components/oh-icon.md +++ b/bundles/org.openhab.ui/doc/components/oh-icon.md @@ -96,13 +96,14 @@ Display an openHAB icon - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -110,6 +111,22 @@ Display an openHAB icon Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-image-card.md b/bundles/org.openhab.ui/doc/components/oh-image-card.md index bbc94f52a5..91b1004c6a 100644 --- a/bundles/org.openhab.ui/doc/components/oh-image-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-image-card.md @@ -108,13 +108,14 @@ Display an image (URL or Image item ) in a card - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -122,6 +123,22 @@ Display an image (URL or Image item ) in a card Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-image.md b/bundles/org.openhab.ui/doc/components/oh-image.md index 170b262ac2..d4816d27d4 100644 --- a/bundles/org.openhab.ui/doc/components/oh-image.md +++ b/bundles/org.openhab.ui/doc/components/oh-image.md @@ -76,13 +76,14 @@ Displays an image from a URL or an item - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -90,6 +91,22 @@ Displays an image from a URL or an item Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-knob-cell.md b/bundles/org.openhab.ui/doc/components/oh-knob-cell.md index 7754af1e5d..fe77261c11 100644 --- a/bundles/org.openhab.ui/doc/components/oh-knob-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-knob-cell.md @@ -239,13 +239,14 @@ Use the advanced properties to change the appearance from a knob to a rounded sl - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -253,6 +254,22 @@ Use the advanced properties to change the appearance from a knob to a rounded sl Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-label-card.md b/bundles/org.openhab.ui/doc/components/oh-label-card.md index 7a270f7611..650ff36205 100644 --- a/bundles/org.openhab.ui/doc/components/oh-label-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-label-card.md @@ -77,13 +77,14 @@ Display the state of an item in a card - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -91,6 +92,22 @@ Display the state of an item in a card Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on @@ -236,13 +253,14 @@ Display the state of an item in a card - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -250,6 +268,22 @@ Display the state of an item in a card Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-label-cell.md b/bundles/org.openhab.ui/doc/components/oh-label-cell.md index 3990dff97a..83854d6131 100644 --- a/bundles/org.openhab.ui/doc/components/oh-label-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-label-cell.md @@ -103,13 +103,14 @@ A cell with a big label to show a short item state value - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -117,6 +118,22 @@ A cell with a big label to show a short item state value Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-label-item.md b/bundles/org.openhab.ui/doc/components/oh-label-item.md index 6fab1bd498..60199baefd 100644 --- a/bundles/org.openhab.ui/doc/components/oh-label-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-label-item.md @@ -93,13 +93,14 @@ Display the state of an item in a list - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -107,6 +108,22 @@ Display the state of an item in a list Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-link.md b/bundles/org.openhab.ui/doc/components/oh-link.md index e56117d1dc..3b069324fa 100644 --- a/bundles/org.openhab.ui/doc/components/oh-link.md +++ b/bundles/org.openhab.ui/doc/components/oh-link.md @@ -111,13 +111,14 @@ Link performing an action - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -125,6 +126,22 @@ Link performing an action Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-list-item.md b/bundles/org.openhab.ui/doc/components/oh-list-item.md index fb0c71b622..43ab6338be 100644 --- a/bundles/org.openhab.ui/doc/components/oh-list-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-list-item.md @@ -82,13 +82,14 @@ A list item - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -96,6 +97,22 @@ A list item Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-map-circle-marker.md b/bundles/org.openhab.ui/doc/components/oh-map-circle-marker.md index 9b55a641d6..6d9df4473a 100644 --- a/bundles/org.openhab.ui/doc/components/oh-map-circle-marker.md +++ b/bundles/org.openhab.ui/doc/components/oh-map-circle-marker.md @@ -95,13 +95,14 @@ A circle on a map, to represent a radius - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -109,6 +110,22 @@ A circle on a map, to represent a radius Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-map-marker.md b/bundles/org.openhab.ui/doc/components/oh-map-marker.md index 1257844fda..e80538854b 100644 --- a/bundles/org.openhab.ui/doc/components/oh-map-marker.md +++ b/bundles/org.openhab.ui/doc/components/oh-map-marker.md @@ -79,13 +79,14 @@ An icon on a map - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -93,6 +94,22 @@ An icon on a map Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-plan-marker.md b/bundles/org.openhab.ui/doc/components/oh-plan-marker.md index 2ed4822c8a..06eb66a8c4 100644 --- a/bundles/org.openhab.ui/doc/components/oh-plan-marker.md +++ b/bundles/org.openhab.ui/doc/components/oh-plan-marker.md @@ -187,13 +187,14 @@ A marker on a floor plan - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -201,6 +202,22 @@ A marker on a floor plan Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-rollershutter-cell.md b/bundles/org.openhab.ui/doc/components/oh-rollershutter-cell.md index 8706fc23b6..f14b278b0f 100644 --- a/bundles/org.openhab.ui/doc/components/oh-rollershutter-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-rollershutter-cell.md @@ -148,13 +148,14 @@ A cell expanding to rollershutter controls - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -162,6 +163,22 @@ A cell expanding to rollershutter controls Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-slider-cell.md b/bundles/org.openhab.ui/doc/components/oh-slider-cell.md index 83545421b0..867934dd4b 100644 --- a/bundles/org.openhab.ui/doc/components/oh-slider-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-slider-cell.md @@ -163,13 +163,14 @@ A cell expanding to a big vertical slider - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -177,6 +178,22 @@ A cell expanding to a big vertical slider Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-time-series.md b/bundles/org.openhab.ui/doc/components/oh-time-series.md index f038fb2506..34bca7074d 100644 --- a/bundles/org.openhab.ui/doc/components/oh-time-series.md +++ b/bundles/org.openhab.ui/doc/components/oh-time-series.md @@ -111,13 +111,14 @@ prev: /docs/ui/components/ - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -125,6 +126,22 @@ prev: /docs/ui/components/ Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/doc/components/oh-video.md b/bundles/org.openhab.ui/doc/components/oh-video.md index 15f5a2d7fd..eedc8f9f9c 100644 --- a/bundles/org.openhab.ui/doc/components/oh-video.md +++ b/bundles/org.openhab.ui/doc/components/oh-video.md @@ -100,13 +100,14 @@ Displays a video player from a URL or an item - + + - URL to navigate to + URL to navigate to or to send HTTP request to @@ -114,6 +115,22 @@ Displays a video player from a URL or an item Open the URL in the same tab/window instead of a new one. This will exit the app. + + + HTTP method to use for the request + + + + + + + + + + + Body to send with the request + + Item to perform the action on diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/actions.js b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/actions.js index ba8b723515..a0030d1570 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/actions.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/actions.js @@ -26,17 +26,31 @@ export const actionParams = (groupName, paramPrefix) => { { value: 'photos', label: 'Open photo browser' }, { value: 'group', label: 'Group details' }, { value: 'analyzer', label: 'Analyze item(s)' }, - { value: 'url', label: 'External URL' }, + { value: 'url', label: 'Navigate to external URL' }, + { value: 'http', label: 'Send HTTP request' }, { value: 'variable', label: 'Set Variable' } ]), - pt(paramPrefix + 'actionUrl', 'Action URL', 'URL to navigate to').c('url') + pt(paramPrefix + 'actionUrl', 'Action URL', 'URL to navigate to or to send HTTP request to').c('url') .v((value, configuration, configDescription, parameters) => { - return ['url'].indexOf(configuration[paramPrefix + 'action']) >= 0 + return ['url', 'http'].indexOf(configuration[paramPrefix + 'action']) >= 0 }), pb(paramPrefix + 'actionUrlSameWindow', 'Open in same tab/window', 'Open the URL in the same tab/window instead of a new one. This will exit the app.') .v((value, configuration, configDescription, parameters) => { return ['url'].indexOf(configuration[paramPrefix + 'action']) >= 0 }), + po(paramPrefix + 'actionHttpMethod', 'HTTP Method', 'HTTP method to use for the request', [ + { value: 'GET', label: 'GET' }, + { value: 'POST', label: 'POST' }, + { value: 'PUT', label: 'PUT' }, + { value: 'DELETE', label: 'DELETE' } + ]) + .v((value, configuration, configDescription, parameters) => { + return ['http'].indexOf(configuration[paramPrefix + 'action']) >= 0 + }), + pt(paramPrefix + 'actionHttpBody', 'HTTP Body', 'Body to send with the request') + .v((value, configuration, configDescription, parameters) => { + return ['http'].indexOf(configuration[paramPrefix + 'action']) >= 0 + }), pi(paramPrefix + 'actionItem', 'Action Item', 'Item to perform the action on') .v((value, configuration, configDescription, parameters) => { return ['command', 'toggle', 'options'].indexOf(configuration[paramPrefix + 'action']) >= 0 @@ -119,7 +133,7 @@ export const actionParams = (groupName, paramPrefix) => { }), pt(paramPrefix + 'actionFeedback', 'Action feedback', 'Shows a toast popup when the action has been executed. Can either be a text to show or a JSON object including some of the supported parameters').a() .v((value, configuration, configDescription, parameters) => { - return ['command', 'toggle', 'options', 'rule'].indexOf(configuration[paramPrefix + 'action']) >= 0 + return ['command', 'toggle', 'options', 'rule', 'http'].indexOf(configuration[paramPrefix + 'action']) >= 0 }), pt(paramPrefix + 'actionVariable', 'Variable', 'The variable name to set') .v((value, configuration, configDescription, parameters) => { diff --git a/bundles/org.openhab.ui/web/src/components/widgets/widget-actions.js b/bundles/org.openhab.ui/web/src/components/widgets/widget-actions.js index 74e2ae5b20..7b91467dd8 100644 --- a/bundles/org.openhab.ui/web/src/components/widgets/widget-actions.js +++ b/bundles/org.openhab.ui/web/src/components/widgets/widget-actions.js @@ -267,6 +267,17 @@ export const actionsMixin = { const actionUrlSameWindow = actionConfig[prefix + 'actionUrlSameWindow'] window.open(actionUrl, (actionUrlSameWindow) ? '_top' : '_blank') break + case 'http': + const actionHttpUrl = actionConfig[prefix + 'actionUrl'] + const actionHttpMethod = actionConfig[prefix + 'actionHttpMethod'] || 'GET' + const actionHttpBody = actionConfig[prefix + 'actionHttpBody'] + fetch(actionHttpUrl, { + mode: 'no-cors', + method: actionHttpMethod, + body: actionHttpBody + }).then(() => this.showActionFeedback(prefix, actionConfig)) + .catch((e) => this.showActionFeedback(prefix, actionConfig, `Failed to perform HTTP request: ${e.message}`)) + break case 'variable': const actionVariable = actionConfig[prefix + 'actionVariable'] let actionVariableValue = actionConfig[prefix + 'actionVariableValue']