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

Show warning if SSE connection or send command fails #1808

Merged
merged 9 commits into from
Apr 6, 2023

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Mar 27, 2023

Depends on #1807.

Currently, SSE connection and sending commands fail silently, which makes the user think that everything is fine, but instead outdated values are displayed and commands are not sent.

This implements user warnings for such cases, a large openHAB orange toast "Communication failure" with the option to reload is displayed at the bottom center:

  • as long as SSE connection is broken
  • when sending a command to an Item failed for 5 sec

If the Item does not exist (error code 404), " not found" is displayed for 5 sec

@florian-h05 florian-h05 requested a review from a team as a code owner March 27, 2023 19:41
@florian-h05 florian-h05 force-pushed the sse-command-failure-toast branch from 03780c5 to 9189f1a Compare March 27, 2023 19:44
@florian-h05
Copy link
Contributor Author

/cc @digitaldan WDYT? I've seen that you created #1441.

@relativeci
Copy link

relativeci bot commented Mar 27, 2023

Job #905: Bundle Size — 15.71MiB (+0.28%).

caf46e6(current) vs 591137e main#904(baseline)

⚠️ Bundle contains 16 duplicate packages

Metrics (4 changes)
                 Current
Job #905
     Baseline
Job #904
Initial JS 1.73MiB(+0.59%) 1.72MiB
Initial CSS 608.8KiB(+0.03%) 608.59KiB
Cache Invalidation 93.91% 93.91%
Chunks 219 219
Assets 689 689
Modules 1710(+0.23%) 1706
Duplicate Modules 82 82
Duplicate Code 1.71%(-0.58%) 1.72%
Packages 137 137
Duplicate Packages 15 15
Total size by type (3 changes)
                 Current
Job #905
     Baseline
Job #904
CSS 858.34KiB (+0.06%) 857.87KiB
Fonts 526.1KiB 526.1KiB
HTML 1.23KiB 1.23KiB
IMG 140.74KiB 140.74KiB
JS 9.22MiB (+0.36%) 9.18MiB
Media 295.6KiB 295.6KiB
Other 4.71MiB (+0.21%) 4.7MiB

View job #905 reportView main branch activity

@florian-h05 florian-h05 added rebuild trigger a new Jenkins job and removed rebuild trigger a new Jenkins job labels Mar 27, 2023
@florian-h05 florian-h05 added this to the 4.0 milestone Mar 27, 2023
@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Mar 27, 2023
@digitaldan
Copy link
Contributor

Hi @florian-h05 , thanks for picking this up! Sounds like a good approach, one thing i would want to check is to make sure the Mobile client is not also displaying an error message on top of this one. I'm fine either having the IOS not show something, or possibly have the UI check to see if a mobile client is handling this message (like we do for showing or not showing the top right "other apps" button) . I 'll find some time to play around as i have not really thought this through.

@florian-h05
Copy link
Contributor Author

florian-h05 commented Mar 27, 2023

I’ve already thought of this, the SSE warning is not displayed if window.OHApp is available. The command warning is displayed, but if the iOS displays its own message due to no connection, the iOS toast is displayed on top, so I don’t see a problem there.

FYI #1807 is required to have this PR properly work (the SSE warning is only persistent if the reconnection mechanism is in place).

@florian-h05 florian-h05 marked this pull request as draft March 28, 2023 10:47
@florian-h05 florian-h05 force-pushed the sse-command-failure-toast branch from 0851a0a to b8e41c3 Compare March 28, 2023 15:57
@florian-h05
Copy link
Contributor Author

Screenshots:

image

image

@florian-h05 florian-h05 marked this pull request as ready for review March 28, 2023 16:18
Comment on lines 289 to 291
.failure-toast
background-color #e64a19 !important
font-size 22px !important
Copy link
Member

Choose a reason for hiding this comment

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

I would really prefer finding a Framework7 CSS variable (https://v5.framework7.io/docs/css-variables) instead of hardcoding a color, also I'm not sure about this 22px font size 😅

There are other options for example a centered toast if the app is effectively unusable when the connection is broken (from https://v5.framework7.io/docs/toast#examples):

Screenshot from 2023-04-05 21-21-06

Or maybe a Notification (https://v5.framework7.io/docs/notification#examples)?

Screenshot from 2023-04-05 21-33-10

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This color is the openHAB orange, I have switched to using the --f7-theme-color CSS variable instead of hard-coding it.
I have chosen the 22px font size to make the warning larger.

Regarding the centered toast: I really don‘t like its look without having an icon, and it seems that we can‘t have both icon and reload button. A toast at the bottom seemed the visually best solution to me.

I haven‘t really looked into the notifications, but IMO we should not use them and instead „reserve“ them for real notifications when MainUI supports Web Push one day.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the answer, I don't mind your choices but had to express mine ;)

Follow-up for openhab#1499.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This reverts commit ce201328b7edf1d36cc5f9167f717e415018d9c2.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Note that this commit only works correctly together with another PR.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Fixes background color of toast on iOS, enlarges font size and simplifies messages.
The "Communication failure" toast is shared across SSE and send command (REST) to avoid having the toast popping in and out.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 force-pushed the sse-command-failure-toast branch from b8e41c3 to ad2ff48 Compare April 5, 2023 20:01
@ghys ghys merged commit 4edde23 into openhab:main Apr 6, 2023
@florian-h05 florian-h05 deleted the sse-command-failure-toast branch April 6, 2023 09:26
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