From b10b45f67c8401c0244d3c56e5735d7c70d03aad Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Tue, 21 Mar 2023 22:06:13 +0100 Subject: [PATCH 1/9] Display a (localized) toast on SSE disconnection with option to reload Follow-up for #1499. Signed-off-by: Florian Hotze --- .../web/src/assets/i18n/common/en.json | 8 ++++--- .../org.openhab.ui/web/src/components/app.vue | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/i18n/common/en.json b/bundles/org.openhab.ui/web/src/assets/i18n/common/en.json index 8043f5ef20..87597b523e 100644 --- a/bundles/org.openhab.ui/web/src/assets/i18n/common/en.json +++ b/bundles/org.openhab.ui/web/src/assets/i18n/common/en.json @@ -7,10 +7,11 @@ "dialogs.close": "Close", "dialogs.copy": "Copy", "dialogs.delete": "Delete", + "dialogs.reload": "Reload", "dialogs.search": "Search", "dialogs.search.items": "Search items", - "dialogs.search.things": "Search things", - "dialogs.search.rules": "Search rules", + "dialogs.search.things": "Search things", + "dialogs.search.rules": "Search rules", "dialogs.search.nothingFound": "Nothing found", "home.overview.title": "Overview", "home.overview.tab": "Overview", @@ -39,5 +40,6 @@ "sidebar.tip.signIn": "Sign in as an administrator to access settings", "page.navbar.back": "Back", "page.navbar.edit": "Edit", - "admin.notTranslatedYet": "The administration area is not translated yet." + "admin.notTranslatedYet": "The administration area is not translated yet.", + "server.sseConnectionFailed": "Server connection (SSE) failed!" } diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 209d34e44e..f786151c97 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -380,7 +380,9 @@ export default { showSettingsSubmenu: false, showDeveloperSubmenu: false, showDeveloperSidebar: false, - currentUrl: '' + currentUrl: '', + + sseFailureToast: null } }, computed: { @@ -400,6 +402,23 @@ export default { try { window.OHApp.sseConnected(connected) } catch {} + } else if (this.$f7) { + if (connected === false) { + this.sseFailureToast = this.$f7.toast.create({ + text: this.$t('server.sseConnectionFailed'), + closeButton: true, + closeButtonText: this.$t('dialogs.reload'), + destroyOnClose: true + }).open() + this.sseFailureToast.on('closed', () => { + window.location.reload() + }) + } else if (connected === true) { + if (this.sseFailureToast !== null) { + this.sseFailureToast.off('closed') + this.sseFailureToast.close() + } + } } }, immediate: true // provides initial (not changed yet) state From 38c60c74c86b7614af7a2388b12d1b9dedb38ecd Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Tue, 21 Mar 2023 23:12:25 +0100 Subject: [PATCH 2/9] Add style for toast Signed-off-by: Florian Hotze --- .../org.openhab.ui/web/src/assets/i18n/common/en.json | 2 +- bundles/org.openhab.ui/web/src/components/app.vue | 9 ++++++--- bundles/org.openhab.ui/web/src/css/app.styl | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/i18n/common/en.json b/bundles/org.openhab.ui/web/src/assets/i18n/common/en.json index 87597b523e..56c132594b 100644 --- a/bundles/org.openhab.ui/web/src/assets/i18n/common/en.json +++ b/bundles/org.openhab.ui/web/src/assets/i18n/common/en.json @@ -41,5 +41,5 @@ "page.navbar.back": "Back", "page.navbar.edit": "Edit", "admin.notTranslatedYet": "The administration area is not translated yet.", - "server.sseConnectionFailed": "Server connection (SSE) failed!" + "server.sseConnectionFailed": "SSE connection failed!" } diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index f786151c97..3aabfc9982 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -408,14 +408,17 @@ export default { text: this.$t('server.sseConnectionFailed'), closeButton: true, closeButtonText: this.$t('dialogs.reload'), - destroyOnClose: true + destroyOnClose: true, + position: 'bottom', + horizontalPosition: 'bottom', + cssClass: 'toast-sse-connection-failed button-outline' }).open() - this.sseFailureToast.on('closed', () => { + this.sseFailureToast.on('closeButtonClick', () => { window.location.reload() }) } else if (connected === true) { if (this.sseFailureToast !== null) { - this.sseFailureToast.off('closed') + this.sseFailureToast.off('closeButtonClick') this.sseFailureToast.close() } } diff --git a/bundles/org.openhab.ui/web/src/css/app.styl b/bundles/org.openhab.ui/web/src/css/app.styl index 480f3ffba2..8f36ae49da 100644 --- a/bundles/org.openhab.ui/web/src/css/app.styl +++ b/bundles/org.openhab.ui/web/src/css/app.styl @@ -285,3 +285,9 @@ html // Disable user dragging of background images in canvas layouts .disable-user-drag user-drag none + +.toast-sse-connection-failed + --f7-toast-bg-color var(--f7-theme-color) + --f7-toast-text-color white + --f7-button-text-color white + --f7-button-border-color white From 68d63ce2881ca05c50238c622a267bd93a8baf5c Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Tue, 21 Mar 2023 23:38:12 +0100 Subject: [PATCH 3/9] Use Floating Action Button (FAB) instead of toast Signed-off-by: Florian Hotze --- .../org.openhab.ui/web/src/components/app.vue | 28 +++++-------------- bundles/org.openhab.ui/web/src/css/app.styl | 6 ---- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 3aabfc9982..5282bc1364 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -136,7 +136,11 @@ - + + + + +