Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blockly] Provide HTTP request block #2411

Merged
merged 4 commits into from Feb 28, 2024

Conversation

stefan-hoehn
Copy link
Contributor

This is finally the missing HTTP Request block for Blockly.

In this case I tried to make the block as concise as possible. Therefore it contains to block mutation switches that allow hide/unhide timeout and headers if they are needed or not.

image image image

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
@stefan-hoehn stefan-hoehn requested a review from a team as a code owner February 25, 2024 21:13
Copy link

relativeci bot commented Feb 25, 2024

Job #1725: Bundle Size — 11.03MiB (+0.09%).

6b1452e(current) vs 9096d6d main#1724(baseline)

Warning

Bundle contains 19 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes
                 Current
Job #1725
     Baseline
Job #1724
No change  Initial JS 1.85MiB 1.85MiB
No change  Initial CSS 607.92KiB 607.92KiB
Change  Cache Invalidation 17.29% 18.17%
No change  Chunks 220 220
No change  Assets 242 242
Change  Modules 3090(+0.03%) 3089
No change  Duplicate Modules 164 164
No change  Duplicate Code 1.77% 1.77%
No change  Packages 150 150
No change  Duplicate Packages 18 18
Bundle size by type  Change 1 change Regression 1 regression
                 Current
Job #1725
     Baseline
Job #1724
Regression  JS 9.22MiB (+0.11%) 9.21MiB
Not changed  CSS 889.4KiB 889.4KiB
Not changed  Fonts 526.1KiB 526.1KiB
Not changed  Media 295.6KiB 295.6KiB
Not changed  IMG 140.74KiB 140.74KiB
Not changed  HTML 1.24KiB 1.24KiB
Not changed  Other 871B 871B

View job #1725 reportView stefan-hoehn:http_blocks branch activityView project dashboard

@jimtng
Copy link
Contributor

jimtng commented Feb 26, 2024

Can GET also set headers?

Another thing that would be handy is a query builder, ie given a dictionary of key value, append key=Val&key=val to the url

@stefan-hoehn
Copy link
Contributor Author

stefan-hoehn commented Feb 26, 2024

Yes, by clicking on the H button, you can unhide that input. The T button unhides the timout. This allows the block to be very small in case you don't need it.
image

The Query Builder is an interesting idea. I could just add another input for the queries which allows to add another map that supplies it and can be again unhidden by a (Q) button in the block. I like the idea.

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general LGTM, just a few comments, mostly wrt to code style.

@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Feb 28, 2024
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@florian-h05 florian-h05 merged commit 5997c28 into openhab:main Feb 28, 2024
6 checks passed
@florian-h05 florian-h05 deleted the http_blocks branch February 28, 2024 22:04
@florian-h05 florian-h05 added this to the 4.2 milestone Feb 28, 2024
@mherwege
Copy link
Contributor

Another thing that would be handy is a query builder, ie given a dictionary of key value, append key=Val&key=val to the url

I am experimenting with this new functionality. I would be interested in this as well.

And another thing that could be useful in this context: a urlEncode function. Parameters in GET calls will have to be URL encoded. If extending the block with a query builder, the logic could include URL encoding the parameters.

@florian-h05
Copy link
Contributor

The groundwork for this could be done inside openhab-js, where we could also check whether there already are npm modules to encode urls so we don’t have to write the logic ourselves ;-)

@mherwege
Copy link
Contributor

mherwege commented Apr 11, 2024

so we don’t have to write the logic ourselves ;-)

Sure, I think so as well.

To give an idea, here is what I came up with purely in Blockly:

image

I think this can be made nicer. The URL encode function is of course not complete, but covers the need in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants