Skip to content

Commit

Permalink
Fix missing labels for semantic cards (#2029)
Browse files Browse the repository at this point in the history
Fixes #2006.
Probably fixes the issue described in
#1986 (comment).

Reported on the community:
https://community.openhab.org/t/openhab-4-0-release-discussion/147957/86.

Sometimes, the equipment and property cards did not use the
translations.
I found out, that in some cases the equipment and property pages (Main
UI in general) initialized before the translations loaded, this
hopefully solves it.

---------

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
(cherry picked from commit 1dcbaeb)
  • Loading branch information
florian-h05 committed Sep 18, 2023
1 parent a1583af commit 8f8a73d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.ui/web/src/components/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<developer-sidebar />
</f7-panel>

<f7-view main v-show="ready" class="safe-areas" url="/" :master-detail-breakpoint="960" :animate="themeOptions.pageTransitionAnimation !== 'disabled'" />
<f7-view main v-if="ready" class="safe-areas" url="/" :master-detail-breakpoint="960" :animate="themeOptions.pageTransitionAnimation !== 'disabled'" />

<!-- <f7-login-screen id="my-login-screen" :opened="loginScreenOpened">
<f7-view name="login" v-if="$device.cordova">
Expand Down
15 changes: 6 additions & 9 deletions bundles/org.openhab.ui/web/src/js/store/modules/semantics.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@ const getters = {
const actions = {
loadSemantics () {
if (this.getters.apiEndpoint('tags')) {
api.get('/rest/tags')
return api.get('/rest/tags')
.then((tags) => {
state.Locations = tags.filter(t => t.uid.startsWith('Location')).map(t => t.name)
state.Equipment = tags.filter(t => t.uid.startsWith('Equipment')).map(t => t.name)
state.Points = tags.filter(t => t.uid.startsWith('Point')).map(t => t.name)
state.Properties = tags.filter(t => t.uid.startsWith('Property')).map(t => t.name)
// Store i18n labels
Object.values(tags).forEach(t => {
if (t.label) {
state.Labels[t.name] = t.label
} else {
state.Labels[t.name] = t.name
}
})
for (const i in tags) {
const t = tags[i]
state.Labels[t.name] = t.label || t.name
}
// Save as i18n messages
i18n.mergeLocaleMessage(this.getters.locale, state.Labels)
i18n.mergeLocaleMessage(i18n.locale, state.Labels)

return Promise.resolve()
})
Expand Down

0 comments on commit 8f8a73d

Please sign in to comment.