Skip to content

Commit

Permalink
fix: Dashboards should respect locale for title/title_en/title_de and…
Browse files Browse the repository at this point in the history
… desc
  • Loading branch information
billyc committed Feb 4, 2022
1 parent 5d18cf1 commit f27bf70
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/views/DashBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default class VueComponent extends Vue {
const folderContents = await this.fileApi.getDirectory(this.xsubfolder)
// hide dot folders
const files = folderContents.files.filter((f) => !f.startsWith('.')).sort()
const files = folderContents.files.filter(f => !f.startsWith('.')).sort()
return files
}
Expand Down Expand Up @@ -262,16 +262,15 @@ export default class VueComponent extends Vue {
}
// set header
this.title = this.yaml.header.title || 'Dashboard'
this.description = this.yaml.header.description || ''
this.updateLabels()
// build rows
let numCard = 1
for (const rowId of Object.keys(this.yaml.layout)) {
const cards: any[] = this.yaml.layout[rowId]
cards.forEach((card) => {
cards.forEach(card => {
card.id = `card-id-${numCard}`
card.isLoaded = false
Expand All @@ -286,6 +285,26 @@ export default class VueComponent extends Vue {
}
}
@Watch('$store.state.locale') updateLabels() {
this.title = this.getDashboardLabel('title')
this.description = this.getDashboardLabel('description')
}
private getDashboardLabel(element: 'title' | 'description') {
const header = this.yaml.header
let tag = '...'
if (this.$store.state.locale === 'de') {
tag =
header[`${element}_de`] || header[`${element}`] || header[`${element}_en`] || 'Dashboard'
} else {
tag =
header[`${element}_en`] || header[`${element}`] || header[`${element}_de`] || 'Dashboard'
}
return tag
}
private opacity: any = {}
private async handleCardIsLoaded(card: any) {
Expand Down

0 comments on commit f27bf70

Please sign in to comment.