From d8dc59c33ff908c4748fe1e4c60bcf344414c9e7 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Mon, 24 Jul 2023 15:51:21 +0200 Subject: [PATCH 1/7] Fix alert for initial REST request failure & Abort further load Signed-off-by: Florian Hotze --- bundles/org.openhab.ui/web/src/components/app.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 3f41b2883b..45bc739c75 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -475,7 +475,8 @@ export default { }) } } else { - this.$f7.dialog.alert('openHAB REST API connection failed with error ' + err.message || err.status) + alert('openHAB REST API connection failed with error: ' + err.message || err.status) // Framework7 alert does not work, use Window alert() instead + return Promise.reject('openHAB REST API connection failed with error: ' + err.message || err.status) } }) .then((res) => res.data) From 994046dde745b9d74ac728ba90716a3a5d69b68e Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Mon, 11 Sep 2023 18:38:58 +0200 Subject: [PATCH 2/7] Add initial REST connection failure page Signed-off-by: Florian Hotze --- .../web/src/assets/i18n/common/en.json | 5 +- .../org.openhab.ui/web/src/components/app.vue | 122 +++++++++++++++--- 2 files changed, 106 insertions(+), 21 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 e9449f94eb..b6895e956b 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 @@ -8,6 +8,7 @@ "dialogs.copy": "Copy", "dialogs.delete": "Delete", "dialogs.reload": "Reload", + "dialogs.retry": "Try Again", "dialogs.search": "Search", "dialogs.search.items": "Search items", "dialogs.search.things": "Search things", @@ -43,5 +44,7 @@ "page.navbar.edit": "Edit", "admin.notTranslatedYet": "The administration area is not translated yet.", "error.communicationFailure": "Communication failure", - "error.itemNotFound": "%s not found" + "error.itemNotFound": "%s not found", + "error.notReachable.title": "openHAB is offline", + "error.notReachable.msg": "The openHAB server cannot be reached at the moment. Please check your network connection and your server." } diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 45bc739c75..3e6274d28a 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -1,5 +1,5 @@ @@ -395,7 +358,6 @@ export default { pages: null, showSidebar: true, visibleBreakpointDisabled: false, - loginScreenOpened: false, loggedIn: false, themeOptions: { @@ -456,7 +418,6 @@ export default { this.loadData(true) return Promise.reject() } - this.loginScreenOpened = true this.$nextTick(() => { this.$f7.dialog.login( window.location.host, @@ -583,7 +544,6 @@ export default { localStorage.setItem('openhab.ui:username', this.username) localStorage.setItem('openhab.ui:password', this.password) this.loadData().then(() => { - this.loginScreenOpened = false this.loggedIn = true }).catch((err) => { localStorage.removeItem('openhab.ui:serverUrl') @@ -607,7 +567,6 @@ export default { this.$f7.views.main.router.navigate('/', { animate: false, clearPreviousHistory: true }) window.location = window.location.origin if (this.$device.cordova) { - this.loginScreenOpened = true } }).catch((err) => { this.$f7.preloader.hide() @@ -781,12 +740,10 @@ export default { }) } - // this.loginScreenOpened = true const refreshToken = this.getRefreshToken() if (refreshToken) { this.refreshAccessToken().then(() => { this.loggedIn = true - // this.loadData() this.init = true }).catch((err) => { console.warn('Error while using the stored refresh_token to get a new access_token: ' + err + '. Logging out & cleaning session.') From 61154cb8fb7f8c23a77ce677a5e5f987aaaeee55 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Wed, 20 Sep 2023 12:51:11 +0200 Subject: [PATCH 4/7] Refactor connection health stuff to mixin Signed-off-by: Florian Hotze --- .../org.openhab.ui/web/src/components/app.vue | 134 +---------------- .../src/components/connection-health-mixin.js | 139 ++++++++++++++++++ 2 files changed, 142 insertions(+), 131 deletions(-) create mode 100644 bundles/org.openhab.ui/web/src/components/connection-health-mixin.js diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 67247345e5..0b508b7132 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -252,12 +252,13 @@ import { loadLocaleMessages } from '@/js/i18n' import auth from './auth-mixin.js' import i18n from './i18n-mixin.js' +import connectionHealth from './connection-health-mixin.js' import dayjs from 'dayjs' import dayjsLocales from 'dayjs/locale.json' export default { - mixins: [auth, i18n], + mixins: [auth, i18n, connectionHealth], components: { EmptyStatePlaceholder, PanelRight, @@ -368,15 +369,7 @@ export default { showSettingsSubmenu: false, showDeveloperSubmenu: false, showDeveloperSidebar: false, - currentUrl: '', - - // For the communication failure toast - communicationFailureToast: null, - communicationFailureTimeoutId: null, - // For the communication failure page - communicationFailureMsg: null, - - showCachePurgeOption: false + currentUrl: '' } }, i18n: { @@ -654,64 +647,6 @@ export default { function unlock () { audioContext.resume().then(clean) } function clean () { events.forEach(e => b.removeEventListener(e, unlock)) } } - }, - /** - * Creates and opens a toast message that indicates a failure, e.g. of SSE connection - * @param {string} message message to show - * @param {boolean} [reloadButton=false] displays a reload button - * @param {boolean} [autoClose=true] closes toast automatically - * @returns {Toast.Toast} - */ - displayFailureToast (message, reloadButton = false, autoClose = true) { - const toast = this.$f7.toast.create({ - text: message, - closeButton: reloadButton, - closeButtonText: this.$t('dialogs.reload'), - destroyOnClose: autoClose, - closeTimeout: (autoClose) ? 5000 : undefined, - cssClass: 'failure-toast button-outline', - position: 'bottom', - horizontalPosition: 'center' - }) - toast.on('closeButtonClick', () => { - window.location.reload() - }) - toast.open() - return toast - }, - purgeServiceWorkerAndCaches () { - this.$f7.dialog.confirm( - this.$t('about.reload.confirmPurge'), - () => { - navigator.serviceWorker.getRegistrations().then(function (registrations) { - for (let registration of registrations) { - registration.unregister().then(function () { - return self.clients.matchAll() - }).then(function (clients) { - clients.forEach(client => { - if (client.url && 'navigate' in client) { - setTimeout(() => { client.navigate(client.url.split('#')[0]) }, 1000) - } - }) - }) - } - }) - window.caches.keys().then(function (cachesNames) { - console.log('Deleting caches') - return Promise.all(cachesNames.map(function (cacheName) { - return caches.delete(cacheName).then(function () { - console.log('Cache with name ' + cacheName + ' is deleted') - }) - })) - }).then(function () { - console.log('Caches deleted') - setTimeout(() => { location.reload(true) }, 1000) - }) - } - ) - }, - reload () { - document.location.reload() } }, created () { @@ -724,21 +659,6 @@ export default { } catch {} } - if (navigator.serviceWorker) { - navigator.serviceWorker.getRegistrations().then((registrations) => { - if (registrations.length > 0) { - this.showCachePurgeOption = true - } - }) - } - if (window.caches) { - window.caches.keys().then((cachesNames) => { - if (cachesNames.length > 0) { - this.showCachePurgeOption = true - } - }) - } - const refreshToken = this.getRefreshToken() if (refreshToken) { this.refreshAccessToken().then(() => { @@ -824,54 +744,6 @@ export default { } }) - this.$store.subscribe((mutation, state) => { - if (this.ready) { - if (mutation.type === 'sseConnected') { - if (!window.OHApp && this.$f7) { - if (mutation.payload === false) { - if (this.communicationFailureToast === null) { - this.communicationFailureTimeoutId = setTimeout(() => { - if (this.communicationFailureToast !== null) return - this.communicationFailureToast = this.displayFailureToast(this.$t('error.communicationFailure'), true, false) - this.communicationFailureToast.open() - this.communicationFailureTimeoutId = null - }, 1000) - } - } else if (mutation.payload === true) { - if (this.communicationFailureTimeoutId !== null) clearTimeout(this.communicationFailureTimeoutId) - if (this.communicationFailureToast !== null) { - this.communicationFailureToast.close() - this.communicationFailureToast.destroy() - this.communicationFailureToast = null - } - } - } - } - } - }) - - this.$store.subscribeAction({ - error: (action, state, error) => { - if (action.type === 'sendCommand') { - let reloadButton = true - let msg = this.$t('error.communicationFailure') - switch (error) { - case 404: - case 'Not Found': - msg = this.$t('error.itemNotFound').replace('%s', action.payload.itemName) - reloadButton = false - return this.displayFailureToast(msg, reloadButton) - } - if (this.communicationFailureToast === null) { - this.communicationFailureToast = this.displayFailureToast(this.$t('error.communicationFailure'), true, true) - this.communicationFailureToast.on('closed', () => { - this.communicationFailureToast = null - }) - } - } - } - }) - if (window) { window.addEventListener('keydown', this.keyDown) } diff --git a/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js b/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js new file mode 100644 index 0000000000..5118ecef6b --- /dev/null +++ b/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js @@ -0,0 +1,139 @@ +export default { + data () { + return { + // For the communication failure toast + communicationFailureToast: null, + communicationFailureTimeoutId: null, + // For the communication failure page + communicationFailureMsg: null, + showCachePurgeOption: false + } + }, + methods: { + /** + * Creates and opens a toast message that indicates a failure, e.g. of SSE connection + * @param {string} message message to show + * @param {boolean} [reloadButton=false] displays a reload button + * @param {boolean} [autoClose=true] closes toast automatically + * @returns {Toast.Toast} + */ + displayFailureToast (message, reloadButton = false, autoClose = true) { + const toast = this.$f7.toast.create({ + text: message, + closeButton: reloadButton, + closeButtonText: this.$t('dialogs.reload'), + destroyOnClose: autoClose, + closeTimeout: (autoClose) ? 5000 : undefined, + cssClass: 'failure-toast button-outline', + position: 'bottom', + horizontalPosition: 'center' + }) + toast.on('closeButtonClick', () => { + window.location.reload() + }) + toast.open() + return toast + }, + purgeServiceWorkerAndCaches () { + this.$f7.dialog.confirm( + this.$t('about.reload.confirmPurge'), + () => { + navigator.serviceWorker.getRegistrations().then(function (registrations) { + for (let registration of registrations) { + registration.unregister().then(function () { + return self.clients.matchAll() + }).then(function (clients) { + clients.forEach(client => { + if (client.url && 'navigate' in client) { + setTimeout(() => { client.navigate(client.url.split('#')[0]) }, 1000) + } + }) + }) + } + }) + window.caches.keys().then(function (cachesNames) { + console.log('Deleting caches') + return Promise.all(cachesNames.map(function (cacheName) { + return caches.delete(cacheName).then(function () { + console.log('Cache with name ' + cacheName + ' is deleted') + }) + })) + }).then(function () { + console.log('Caches deleted') + setTimeout(() => { location.reload(true) }, 1000) + }) + } + ) + }, + reload () { + document.location.reload() + } + }, + created () { + if (navigator.serviceWorker) { + navigator.serviceWorker.getRegistrations().then((registrations) => { + if (registrations.length > 0) { + this.showCachePurgeOption = true + } + }) + } + if (window.caches) { + window.caches.keys().then((cachesNames) => { + if (cachesNames.length > 0) { + this.showCachePurgeOption = true + } + }) + } + }, + mounted () { + this.$f7ready((f7) => { + this.$store.subscribe((mutation, state) => { + if (this.ready) { + if (mutation.type === 'sseConnected') { + if (!window.OHApp && this.$f7) { + if (mutation.payload === false) { + if (this.communicationFailureToast === null) { + this.communicationFailureTimeoutId = setTimeout(() => { + if (this.communicationFailureToast !== null) return + this.communicationFailureToast = this.displayFailureToast(this.$t('error.communicationFailure'), true, false) + this.communicationFailureToast.open() + this.communicationFailureTimeoutId = null + }, 1000) + } + } else if (mutation.payload === true) { + if (this.communicationFailureTimeoutId !== null) clearTimeout(this.communicationFailureTimeoutId) + if (this.communicationFailureToast !== null) { + this.communicationFailureToast.close() + this.communicationFailureToast.destroy() + this.communicationFailureToast = null + } + } + } + } + } + }) + + this.$store.subscribeAction({ + error: (action, state, error) => { + if (action.type === 'sendCommand') { + let reloadButton = true + let msg = this.$t('error.communicationFailure') + switch (error) { + case 404: + case 'Not Found': + msg = this.$t('error.itemNotFound').replace('%s', action.payload.itemName) + reloadButton = false + return this.displayFailureToast(msg, reloadButton) + } + if (this.communicationFailureToast === null) { + this.communicationFailureToast = this.displayFailureToast(this.$t('error.communicationFailure'), true, true) + this.communicationFailureToast.on('closed', () => { + this.communicationFailureToast = null + }) + } + } + } + }) + }) + } +} From 23c1c7897cfe48620a5838212601387e348b5eb0 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Wed, 20 Sep 2023 13:08:26 +0200 Subject: [PATCH 5/7] Refactor reload methods to mixin Signed-off-by: Florian Hotze --- .../src/components/connection-health-mixin.js | 55 ++-------------- .../web/src/components/reload-mixin.js | 64 +++++++++++++++++++ .../org.openhab.ui/web/src/pages/about.vue | 53 ++------------- 3 files changed, 73 insertions(+), 99 deletions(-) create mode 100644 bundles/org.openhab.ui/web/src/components/reload-mixin.js diff --git a/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js b/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js index 5118ecef6b..96ab684ce8 100644 --- a/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js +++ b/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js @@ -1,12 +1,14 @@ +import mixin from 'reload-mixin.js' + export default { + mixins: [mixin], data () { return { // For the communication failure toast communicationFailureToast: null, communicationFailureTimeoutId: null, // For the communication failure page - communicationFailureMsg: null, - showCachePurgeOption: false + communicationFailureMsg: null } }, methods: { @@ -34,56 +36,9 @@ export default { toast.open() return toast }, - purgeServiceWorkerAndCaches () { - this.$f7.dialog.confirm( - this.$t('about.reload.confirmPurge'), - () => { - navigator.serviceWorker.getRegistrations().then(function (registrations) { - for (let registration of registrations) { - registration.unregister().then(function () { - return self.clients.matchAll() - }).then(function (clients) { - clients.forEach(client => { - if (client.url && 'navigate' in client) { - setTimeout(() => { client.navigate(client.url.split('#')[0]) }, 1000) - } - }) - }) - } - }) - window.caches.keys().then(function (cachesNames) { - console.log('Deleting caches') - return Promise.all(cachesNames.map(function (cacheName) { - return caches.delete(cacheName).then(function () { - console.log('Cache with name ' + cacheName + ' is deleted') - }) - })) - }).then(function () { - console.log('Caches deleted') - setTimeout(() => { location.reload(true) }, 1000) - }) - } - ) - }, - reload () { - document.location.reload() - } }, created () { - if (navigator.serviceWorker) { - navigator.serviceWorker.getRegistrations().then((registrations) => { - if (registrations.length > 0) { - this.showCachePurgeOption = true - } - }) - } - if (window.caches) { - window.caches.keys().then((cachesNames) => { - if (cachesNames.length > 0) { - this.showCachePurgeOption = true - } - }) - } + this.checkPurgeServiceWorkerAndCachesAvailable() }, mounted () { this.$f7ready((f7) => { diff --git a/bundles/org.openhab.ui/web/src/components/reload-mixin.js b/bundles/org.openhab.ui/web/src/components/reload-mixin.js new file mode 100644 index 0000000000..4d41eaf8d6 --- /dev/null +++ b/bundles/org.openhab.ui/web/src/components/reload-mixin.js @@ -0,0 +1,64 @@ +import { loadLocaleMessages } from '@/js/i18n' + +export default { + data () { + return { + showCachePurgeOption: false + } + }, + i18n: { + messages: loadLocaleMessages(require.context('@/assets/i18n/about')) + }, + methods: { + checkPurgeServiceWorkerAndCachesAvailable () { + if (navigator.serviceWorker) { + navigator.serviceWorker.getRegistrations().then((registrations) => { + if (registrations.length > 0) { + this.showCachePurgeOption = true + } + }) + } + if (window.caches) { + window.caches.keys().then((cachesNames) => { + if (cachesNames.length > 0) { + this.showCachePurgeOption = true + } + }) + } + }, + purgeServiceWorkerAndCaches () { + this.$f7.dialog.confirm( + this.$t('about.reload.confirmPurge'), + () => { + navigator.serviceWorker.getRegistrations().then(function (registrations) { + for (let registration of registrations) { + registration.unregister().then(function () { + return self.clients.matchAll() + }).then(function (clients) { + clients.forEach(client => { + if (client.url && 'navigate' in client) { + setTimeout(() => { client.navigate(client.url.split('#')[0]) }, 1000) + } + }) + }) + } + }) + window.caches.keys().then(function (cachesNames) { + console.log('Deleting caches') + return Promise.all(cachesNames.map(function (cacheName) { + return caches.delete(cacheName).then(function () { + console.log('Cache with name ' + cacheName + ' is deleted') + }) + })) + }).then(function () { + console.log('Caches deleted') + setTimeout(() => { location.reload(true) }, 1000) + }) + } + ) + }, + reload () { + document.location.reload() + } + } +} \ No newline at end of file diff --git a/bundles/org.openhab.ui/web/src/pages/about.vue b/bundles/org.openhab.ui/web/src/pages/about.vue index 93875cc995..0461dce5d5 100644 --- a/bundles/org.openhab.ui/web/src/pages/about.vue +++ b/bundles/org.openhab.ui/web/src/pages/about.vue @@ -107,7 +107,10 @@ import ThemeSwitcher from '../components/theme-switcher.vue' import YAML from 'yaml' import { loadLocaleMessages } from '@/js/i18n' +import reloadMixin from '../components/reload-mixin.js' + export default { + mixins: [reloadMixin], components: { ThemeSwitcher }, @@ -115,7 +118,6 @@ export default { return { systemInfo: null, textualSystemInfoOpened: false, - showCachePurgeOption: false, bindings: null } }, @@ -159,54 +161,7 @@ export default { this.$oh.api.get('/rest/systeminfo').then((data) => { this.systemInfo = data.systemInfo }) this.$oh.api.get('/rest/addons').then((data) => { this.addons = data.filter((a) => a.installed).map((a) => a.uid).sort() }) } - if (navigator.serviceWorker) { - navigator.serviceWorker.getRegistrations().then((registrations) => { - if (registrations.length > 0) { - this.showCachePurgeOption = true - } - }) - } - if (window.caches) { - window.caches.keys().then((cachesNames) => { - if (cachesNames.length > 0) { - this.showCachePurgeOption = true - } - }) - } - }, - purgeServiceWorkerAndCaches () { - this.$f7.dialog.confirm( - this.$t('about.reload.confirmPurge'), - () => { - navigator.serviceWorker.getRegistrations().then(function (registrations) { - for (let registration of registrations) { - registration.unregister().then(function () { - return self.clients.matchAll() - }).then(function (clients) { - clients.forEach(client => { - if (client.url && 'navigate' in client) { - setTimeout(() => { client.navigate(client.url.split('#')[0]) }, 1000) - } - }) - }) - } - }) - window.caches.keys().then(function (cachesNames) { - console.log('Deleting caches') - return Promise.all(cachesNames.map(function (cacheName) { - return caches.delete(cacheName).then(function () { - console.log('Cache with name ' + cacheName + ' is deleted') - }) - })) - }).then(function () { - console.log('Caches deleted') - setTimeout(() => { location.reload(true) }, 1000) - }) - } - ) - }, - reload () { - document.location.reload() + this.checkPurgeServiceWorkerAndCachesAvailable() }, copyTextualSystemInfo () { let el = document.getElementById('textual-systeminfo') From 674a90059fb3fef91963375541974fb03079d693 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Wed, 20 Sep 2023 13:16:07 +0200 Subject: [PATCH 6/7] Fix lint Signed-off-by: Florian Hotze --- .../src/components/connection-health-mixin.js | 2 +- .../web/src/components/reload-mixin.js | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js b/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js index 96ab684ce8..74db7b0785 100644 --- a/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js +++ b/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js @@ -35,7 +35,7 @@ export default { }) toast.open() return toast - }, + } }, created () { this.checkPurgeServiceWorkerAndCachesAvailable() diff --git a/bundles/org.openhab.ui/web/src/components/reload-mixin.js b/bundles/org.openhab.ui/web/src/components/reload-mixin.js index 4d41eaf8d6..fddb3b1145 100644 --- a/bundles/org.openhab.ui/web/src/components/reload-mixin.js +++ b/bundles/org.openhab.ui/web/src/components/reload-mixin.js @@ -12,19 +12,19 @@ export default { methods: { checkPurgeServiceWorkerAndCachesAvailable () { if (navigator.serviceWorker) { - navigator.serviceWorker.getRegistrations().then((registrations) => { - if (registrations.length > 0) { - this.showCachePurgeOption = true - } - }) - } - if (window.caches) { - window.caches.keys().then((cachesNames) => { - if (cachesNames.length > 0) { - this.showCachePurgeOption = true - } - }) - } + navigator.serviceWorker.getRegistrations().then((registrations) => { + if (registrations.length > 0) { + this.showCachePurgeOption = true + } + }) + } + if (window.caches) { + window.caches.keys().then((cachesNames) => { + if (cachesNames.length > 0) { + this.showCachePurgeOption = true + } + }) + } }, purgeServiceWorkerAndCaches () { this.$f7.dialog.confirm( @@ -61,4 +61,4 @@ export default { document.location.reload() } } -} \ No newline at end of file +} From 1dc464030f86f33dd42006fc23e0d1b27d2cbe26 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Fri, 22 Sep 2023 01:13:49 +0200 Subject: [PATCH 7/7] Fixes, improvements & address review Signed-off-by: Florian Hotze --- bundles/org.openhab.ui/web/src/components/app.vue | 6 +++--- .../web/src/components/connection-health-mixin.js | 6 +++--- bundles/org.openhab.ui/web/src/components/reload-mixin.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 34cd1f5251..3571730fd9 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -253,9 +253,9 @@ import EmptyStatePlaceholder from '@/components/empty-state-placeholder.vue' import { loadLocaleMessages } from '@/js/i18n' -import auth from './auth-mixin.js' -import i18n from './i18n-mixin.js' -import connectionHealth from './connection-health-mixin.js' +import auth from './auth-mixin' +import i18n from './i18n-mixin' +import connectionHealth from './connection-health-mixin' import dayjs from 'dayjs' import dayjsLocales from 'dayjs/locale.json' diff --git a/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js b/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js index 74db7b0785..914482da6d 100644 --- a/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js +++ b/bundles/org.openhab.ui/web/src/components/connection-health-mixin.js @@ -1,7 +1,7 @@ -import mixin from 'reload-mixin.js' +import reloadMixin from './reload-mixin' export default { - mixins: [mixin], + mixins: [reloadMixin], data () { return { // For the communication failure toast @@ -31,7 +31,7 @@ export default { horizontalPosition: 'center' }) toast.on('closeButtonClick', () => { - window.location.reload() + this.reload() }) toast.open() return toast diff --git a/bundles/org.openhab.ui/web/src/components/reload-mixin.js b/bundles/org.openhab.ui/web/src/components/reload-mixin.js index fddb3b1145..df05485f4b 100644 --- a/bundles/org.openhab.ui/web/src/components/reload-mixin.js +++ b/bundles/org.openhab.ui/web/src/components/reload-mixin.js @@ -58,7 +58,7 @@ export default { ) }, reload () { - document.location.reload() + window.location.reload() } } }