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] Add new sophisticated notification blocks #2672

Merged
merged 11 commits into from
Jul 23, 2024

Conversation

stefan-hoehn
Copy link
Contributor

@stefan-hoehn stefan-hoehn commented Jul 15, 2024

This is probably the most comprehensive block I have provided so far which supports the awesome cloud notification functionality that was provided recently. Kudos to all who have provided the cloud notifications and added them to the apps! ❤️

Thanks for the support during this implementation to Florian, Dan, Danny, Matthias (and the rest of the openHAB foundation gang who provided feedback and nice ideas to make it even better).

I tested all of the above use cases and I hope I covered most of it.

Note that the new blocks can completely replace the old ones (though they will not be automatically converted but it must be done manually). I will document this eventually in the blockly docs.

The new notification blocks:

image

The block can be highly customized by showing or hiding the required inputs:

image

Without user ids, it will result into a broadcast. Individual users can be address with a comma separated list:

image

You can provide actions (directly or further down below via up to three clickable buttons in the notification)

image

Two different types of actions are available to attach to direct action or a button action

Action:
image

Button 1/2/3 Action
image

Action Blocks

image

Actions can be provided via blocks are generically via Strings:

image

Many more examples:
image

Based on

https://www.openhab.org/addons/integrations/openhabcloud/#cloud-notification-actions
https://www.openhab.org/addons/automation/jsscripting/#cloud-notification-actions

Here is an example in the Android app with included media:

image

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
@stefan-hoehn stefan-hoehn requested a review from a team as a code owner July 15, 2024 10:16
Copy link

relativeci bot commented Jul 15, 2024

#2138 Bundle Size — 10.77MiB (+0.91%).

9dc7daf(current) vs bc73c9e main#2134(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes
                 Current
#2138
     Baseline
#2134
No change  Initial JS 1.88MiB 1.88MiB
No change  Initial CSS 607.91KiB 607.91KiB
Change  Cache Invalidation 18.22% 17.96%
No change  Chunks 223 223
No change  Assets 246 246
No change  Modules 2888 2888
No change  Duplicate Modules 149 149
Change  Duplicate Code 1.84%(-0.54%) 1.85%
No change  Packages 97 97
No change  Duplicate Packages 2 2
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#2138
     Baseline
#2134
Regression  JS 8.96MiB (+1.1%) 8.86MiB
No change  CSS 892.47KiB 892.47KiB
No change  Fonts 526.1KiB 526.1KiB
No change  Media 295.6KiB 295.6KiB
No change  IMG 140.74KiB 140.74KiB
No change  HTML 1.24KiB 1.24KiB
No change  Other 871B 871B

Bundle analysis reportBranch stefan-hoehn:blockly_notificatio...Project dashboard

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@maniac103
Copy link

The action button syntax seems a little cumbersome. I assume splitting label and action there is not possible?

@stefan-hoehn
Copy link
Contributor Author

I assume splitting label and action there is not possible?

Kinda correct. I thought about it The problem is that it would require a special designed "command-button" input block that contains two inputs by itself. It would require a special "command block" to be implemented and a very special handling in that case. It could maybe be done but surely is a much more complex implementation while I don't think it is actually not too bad the way it is...

@stefan-hoehn
Copy link
Contributor Author

The action button syntax seems a little cumbersome. I assume splitting label and action there is not possible?

I did a proof-of-concept: this is how it would look like. Do you think this is better?

image

@stefan-hoehn
Copy link
Contributor Author

And one more comment, @maniac103

  • it must be of course "action" and not message in the above screenshot
  • and we had a board meeting today and so I took the change to ask for design ideas and we actually came up with the idea to make it even more sophisticated by providing special blocks of action types where the item-action could for example even support the item picker.

So stay tuned for an update.

@maniac103
Copy link

it must be of course "action" and not message in the above screenshot

I assume you mean 'and not command', right?

But I indeed think that's much better, but...

we actually came up with the idea to make it even more sophisticated by providing special blocks of action types where the item-action could for example even support the item picker.

...is beaten by this approach which sounds awesome 👍

@stefan-hoehn
Copy link
Contributor Author

first idea (only design, still needs to be implemented).

image

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
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.

Overall already looks good, please have a look at my comments.

I also have a few wording remarks:

image

Replace "with Action" -> "with On-Click Action" and rename the action button block's "on-click action" -> "action".

Are shadow blocks inside me screenshot expected to work? I think in blockly-editor.vue are a few input names wrongly defined.

@stefan-hoehn
Copy link
Contributor Author

stefan-hoehn commented Jul 22, 2024

Are shadow blocks inside my screenshot expected to work? I think in blockly-editor.vue are a few input names wrongly defined.

The ones here
image
don't actually have shadow blocks because I would have to create them in the code which would require a lot of extra non-generic code for these blocks. So, no, for these you have to drop in your own blocks. However, you can only add the right block types to them.

@florian-h05 florian-h05 added rebuild trigger a new Jenkins job enhancement New feature or request main ui Main UI and removed rebuild trigger a new Jenkins job labels Jul 23, 2024
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 now, I have just pushed a few minor changes - thanks for your great work!

@florian-h05 florian-h05 added this to the 4.3 milestone Jul 23, 2024
@florian-h05 florian-h05 changed the title [blockly] add new sophisticated notification blocks [blockly] Add new sophisticated notification blocks Jul 23, 2024
@florian-h05 florian-h05 merged commit 4ce4d49 into openhab:main Jul 23, 2024
8 checks passed
@florian-h05 florian-h05 deleted the blockly_notification_update branch July 23, 2024 20:44
@stefan-hoehn
Copy link
Contributor Author

Unfortunately I found a few bugs and I am already working on it. The fix will come very soon.

florian-h05 pushed a commit that referenced this pull request Jul 25, 2024
There was an error on code generation in particular when using vars and
string concat blocks (who sometime generate code instead of pure
strings) which is fixed now.
I also gave notifications its individual color to distinguish them
better from other groups.

Follow-up for #2672.

---------

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
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.

3 participants