2018-03-03 06:32:58 +00:00
|
|
|
<template lang='pug'>
|
2018-09-30 03:30:20 +00:00
|
|
|
v-container(fluid, grid-list-lg)
|
|
|
|
v-layout(row, wrap)
|
2018-03-03 06:32:58 +00:00
|
|
|
v-flex(xs12)
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header
|
2020-05-15 21:05:11 +00:00
|
|
|
img.animated.fadeInUp(src='/_assets/svg/icon-globe-earth.svg', alt='Locale', style='width: 80px;')
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header-title
|
2019-04-07 16:37:33 +00:00
|
|
|
.headline.primary--text.animated.fadeInLeft {{ $t('admin:locale.title') }}
|
2019-08-03 04:48:55 +00:00
|
|
|
.subtitle-1.grey--text.animated.fadeInLeft.wait-p4s {{ $t('admin:locale.subtitle') }}
|
2018-09-30 03:30:20 +00:00
|
|
|
v-spacer
|
2020-06-18 03:05:51 +00:00
|
|
|
v-btn.animated.fadeInDown.wait-p3s(icon, outlined, color='grey', href='https://docs.requarks.io/locales', target='_blank')
|
|
|
|
v-icon mdi-help-circle
|
|
|
|
v-btn.animated.fadeInDown.ml-3(color='success', depressed, @click='save', large, :loading='loading')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-icon(left) mdi-check
|
2018-09-30 03:30:20 +00:00
|
|
|
span {{$t('common:actions.apply')}}
|
2018-03-03 06:32:58 +00:00
|
|
|
v-form.pt-3
|
|
|
|
v-layout(row wrap)
|
2020-09-13 17:51:21 +00:00
|
|
|
v-flex(xl6 lg5 xs12)
|
2019-04-07 16:37:33 +00:00
|
|
|
v-card.wiki-form.animated.fadeInUp
|
2018-05-12 20:13:04 +00:00
|
|
|
v-toolbar(color='primary', dark, dense, flat)
|
2019-07-29 04:50:03 +00:00
|
|
|
v-toolbar-title.subtitle-1 {{ $t('admin:locale.settings') }}
|
2018-03-03 06:32:58 +00:00
|
|
|
v-card-text
|
2018-05-12 22:35:31 +00:00
|
|
|
v-select(
|
2019-07-29 04:50:03 +00:00
|
|
|
outlined
|
2018-05-12 22:35:31 +00:00
|
|
|
:items='installedLocales'
|
2019-07-29 04:50:03 +00:00
|
|
|
prepend-icon='mdi-web'
|
2018-04-29 21:55:36 +00:00
|
|
|
v-model='selectedLocale'
|
2018-05-06 21:33:41 +00:00
|
|
|
item-value='code'
|
2018-06-17 21:29:19 +00:00
|
|
|
item-text='nativeName'
|
|
|
|
:label='namespacing ? $t("admin:locale.base.labelWithNS") : $t("admin:locale.base.label")'
|
2018-04-29 21:55:36 +00:00
|
|
|
persistent-hint
|
2018-06-17 21:29:19 +00:00
|
|
|
:hint='$t("admin:locale.base.hint")'
|
2018-04-29 21:55:36 +00:00
|
|
|
)
|
2018-03-03 06:32:58 +00:00
|
|
|
template(slot='item', slot-scope='data')
|
2018-04-29 21:55:36 +00:00
|
|
|
template(v-if='typeof data.item !== "object"')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content(v-text='data.item')
|
2018-04-29 21:55:36 +00:00
|
|
|
template(v-else)
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-avatar
|
2018-04-29 21:55:36 +00:00
|
|
|
v-avatar.blue.white--text(tile, size='40', v-html='data.item.code.toUpperCase()')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title(v-html='data.item.name')
|
2019-08-10 16:18:14 +00:00
|
|
|
v-list-item-subtitle(v-html='data.item.nativeName')
|
2018-07-08 05:12:43 +00:00
|
|
|
v-divider.mt-3
|
2018-04-29 21:55:36 +00:00
|
|
|
v-switch(
|
2019-09-01 22:33:36 +00:00
|
|
|
inset
|
2018-04-29 21:55:36 +00:00
|
|
|
v-model='autoUpdate'
|
2018-06-17 21:29:19 +00:00
|
|
|
:label='$t("admin:locale.autoUpdate.label")'
|
2018-04-29 21:55:36 +00:00
|
|
|
color='primary'
|
|
|
|
persistent-hint
|
2018-06-17 21:29:19 +00:00
|
|
|
:hint='namespacing ? $t("admin:locale.autoUpdate.hintWithNS") : $t("admin:locale.autoUpdate.hint")'
|
2018-04-29 21:55:36 +00:00
|
|
|
)
|
2018-05-12 22:35:31 +00:00
|
|
|
|
2019-04-07 16:37:33 +00:00
|
|
|
v-card.wiki-form.mt-3.animated.fadeInUp.wait-p2s
|
2018-05-12 22:35:31 +00:00
|
|
|
v-toolbar(color='primary', dark, dense, flat)
|
2019-07-29 04:50:03 +00:00
|
|
|
v-toolbar-title.subtitle-1 {{ $t('admin:locale.namespacing') }}
|
2018-05-12 22:35:31 +00:00
|
|
|
v-card-text
|
|
|
|
v-switch(
|
2019-09-01 22:33:36 +00:00
|
|
|
inset
|
2018-05-12 22:35:31 +00:00
|
|
|
v-model='namespacing'
|
2018-06-17 21:29:19 +00:00
|
|
|
:label='$t("admin:locale.namespaces.label")'
|
2018-05-12 22:35:31 +00:00
|
|
|
color='primary'
|
|
|
|
persistent-hint
|
2018-06-17 21:29:19 +00:00
|
|
|
:hint='$t("admin:locale.namespaces.hint")'
|
2018-05-12 22:35:31 +00:00
|
|
|
)
|
|
|
|
v-alert.mt-3(
|
2019-07-29 04:50:03 +00:00
|
|
|
outlined
|
2018-05-12 22:35:31 +00:00
|
|
|
color='orange'
|
|
|
|
:value='true'
|
2019-07-29 04:50:03 +00:00
|
|
|
icon='mdi-alert'
|
2018-05-12 22:35:31 +00:00
|
|
|
)
|
2018-06-17 21:29:19 +00:00
|
|
|
span {{ $t('admin:locale.namespacingPrefixWarning.title', { langCode: selectedLocale }) }}
|
|
|
|
.caption.grey--text {{ $t('admin:locale.namespacingPrefixWarning.subtitle') }}
|
2018-07-08 05:12:43 +00:00
|
|
|
v-divider.mt-3.mb-4
|
2018-05-12 22:35:31 +00:00
|
|
|
v-select(
|
2019-07-29 04:50:03 +00:00
|
|
|
outlined
|
2018-05-12 22:35:31 +00:00
|
|
|
:disabled='!namespacing'
|
|
|
|
:items='installedLocales'
|
2019-07-29 04:50:03 +00:00
|
|
|
prepend-icon='mdi-web'
|
2018-05-12 22:35:31 +00:00
|
|
|
multiple
|
|
|
|
chips
|
|
|
|
deletable-chips
|
|
|
|
v-model='namespaces'
|
|
|
|
item-value='code'
|
|
|
|
item-text='name'
|
2018-06-17 21:29:19 +00:00
|
|
|
:label='$t("admin:locale.activeNamespaces.label")'
|
2018-05-12 22:35:31 +00:00
|
|
|
persistent-hint
|
2018-12-24 06:03:10 +00:00
|
|
|
small-chips
|
2018-06-17 21:29:19 +00:00
|
|
|
:hint='$t("admin:locale.activeNamespaces.hint")'
|
2018-05-12 22:35:31 +00:00
|
|
|
)
|
|
|
|
template(slot='item', slot-scope='data')
|
|
|
|
template(v-if='typeof data.item !== "object"')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content(v-text='data.item')
|
2018-05-12 22:35:31 +00:00
|
|
|
template(v-else)
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-avatar
|
2018-05-12 22:35:31 +00:00
|
|
|
v-avatar.blue.white--text(tile, size='40', v-html='data.item.code.toUpperCase()')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title(v-html='data.item.name')
|
2019-10-18 21:31:28 +00:00
|
|
|
v-list-item-subtitle(v-html='data.item.nativeName')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-action
|
2019-10-18 21:31:28 +00:00
|
|
|
v-checkbox(:input-value='data.attrs.inputValue', color='primary', value)
|
2020-09-13 17:51:21 +00:00
|
|
|
v-flex(xl6 lg7 xs12)
|
2019-04-07 16:37:33 +00:00
|
|
|
v-card.animated.fadeInUp.wait-p4s
|
2018-03-12 04:09:54 +00:00
|
|
|
v-toolbar(color='teal', dark, dense, flat)
|
2019-07-29 04:50:03 +00:00
|
|
|
v-toolbar-title.subtitle-1 {{ $t('admin:locale.downloadTitle') }}
|
2019-07-13 03:56:44 +00:00
|
|
|
v-data-table(
|
|
|
|
:headers='headers',
|
|
|
|
:items='locales',
|
2019-07-29 04:50:03 +00:00
|
|
|
hide-default-footer,
|
2019-07-13 03:56:44 +00:00
|
|
|
item-key='code',
|
2019-07-29 04:50:03 +00:00
|
|
|
:items-per-page='1000'
|
|
|
|
)
|
|
|
|
template(v-slot:item.code='{ item }')
|
|
|
|
v-chip.white--text(label, color='teal', small) {{item.code}}
|
|
|
|
template(v-slot:item.name='{ item }')
|
|
|
|
strong {{item.name}}
|
|
|
|
template(v-slot:item.isRTL='{ item }')
|
|
|
|
v-icon(v-if='item.isRTL') mdi-check
|
|
|
|
template(v-slot:item.availability='{ item }')
|
|
|
|
.d-flex.align-center.pl-4
|
|
|
|
v-progress-circular(:value='item.availability', width='2', size='20', :color='item.availability <= 33 ? `red` : (item.availability <= 66) ? `orange` : `green`')
|
2019-08-11 04:12:07 +00:00
|
|
|
.caption.mx-2(:class='item.availability <= 33 ? `red--text` : (item.availability <= 66) ? `orange--text` : `green--text`') {{item.availability}}%
|
2019-07-29 04:50:03 +00:00
|
|
|
template(v-slot:item.isInstalled='{ item }')
|
|
|
|
v-progress-circular(v-if='item.isDownloading', indeterminate, color='blue', size='20', :width='2')
|
2019-08-04 17:54:23 +00:00
|
|
|
v-btn(v-else-if='item.isInstalled && item.installDate < item.updatedAt', icon, small, @click='download(item)')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-icon.blue--text mdi-cached
|
2019-08-04 17:54:23 +00:00
|
|
|
v-btn(v-else-if='item.isInstalled', icon, small, @click='download(item)')
|
2019-08-17 22:29:58 +00:00
|
|
|
v-icon.green--text mdi-check-bold
|
2019-07-29 04:50:03 +00:00
|
|
|
v-btn(v-else, icon, small, @click='download(item)')
|
|
|
|
v-icon.grey--text mdi-cloud-download
|
2019-05-12 17:56:47 +00:00
|
|
|
v-card.wiki-form.mt-3.animated.fadeInUp.wait-p5s
|
|
|
|
v-toolbar(color='teal', dark, dense, flat)
|
2019-07-29 04:50:03 +00:00
|
|
|
v-toolbar-title.subtitle-1 {{ $t('admin:locale.sideload') }}
|
2019-05-12 17:56:47 +00:00
|
|
|
v-spacer
|
|
|
|
v-chip(label, color='white', small).teal--text coming soon
|
|
|
|
v-card-text
|
|
|
|
div {{ $t('admin:locale.sideloadHelp') }}
|
|
|
|
v-btn.ml-0.mt-3(color='teal', disabled) {{ $t('common:actions.browse') }}
|
2018-03-03 06:32:58 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-04-29 21:55:36 +00:00
|
|
|
import _ from 'lodash'
|
|
|
|
|
2018-06-17 21:29:19 +00:00
|
|
|
/* global WIKI */
|
|
|
|
|
2018-06-25 06:44:40 +00:00
|
|
|
import localesQuery from 'gql/admin/locale/locale-query-list.gql'
|
|
|
|
import localesDownloadMutation from 'gql/admin/locale/locale-mutation-download.gql'
|
|
|
|
import localesSaveMutation from 'gql/admin/locale/locale-mutation-save.gql'
|
2018-04-29 21:55:36 +00:00
|
|
|
|
2018-03-03 06:32:58 +00:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2018-05-06 21:33:41 +00:00
|
|
|
loading: false,
|
2018-04-29 21:55:36 +00:00
|
|
|
locales: [],
|
2018-03-03 06:32:58 +00:00
|
|
|
selectedLocale: 'en',
|
2018-05-12 22:35:31 +00:00
|
|
|
autoUpdate: false,
|
|
|
|
namespacing: false,
|
|
|
|
namespaces: []
|
2018-04-29 21:55:36 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
installedLocales() {
|
|
|
|
return _.filter(this.locales, ['isInstalled', true])
|
2019-07-13 03:56:44 +00:00
|
|
|
},
|
|
|
|
headers() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
text: this.$t('admin:locale.code'),
|
|
|
|
align: 'left',
|
|
|
|
value: 'code',
|
2019-07-29 04:50:03 +00:00
|
|
|
width: 90
|
2019-07-13 03:56:44 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: this.$t('admin:locale.name'),
|
|
|
|
align: 'left',
|
|
|
|
value: 'name'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: this.$t('admin:locale.nativeName'),
|
|
|
|
align: 'left',
|
|
|
|
value: 'nativeName'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: this.$t('admin:locale.rtl'),
|
|
|
|
align: 'center',
|
|
|
|
value: 'isRTL',
|
|
|
|
sortable: false,
|
|
|
|
width: 10
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: this.$t('admin:locale.availability'),
|
|
|
|
align: 'center',
|
|
|
|
value: 'availability',
|
2019-07-29 04:50:03 +00:00
|
|
|
sortable: false,
|
2019-08-31 19:00:31 +00:00
|
|
|
width: 120
|
2019-07-13 03:56:44 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: this.$t('admin:locale.download'),
|
|
|
|
align: 'center',
|
2019-07-29 04:50:03 +00:00
|
|
|
value: 'isInstalled',
|
2019-07-13 03:56:44 +00:00
|
|
|
sortable: false,
|
|
|
|
width: 100
|
|
|
|
}
|
|
|
|
]
|
2018-04-29 21:55:36 +00:00
|
|
|
}
|
|
|
|
},
|
2018-05-06 21:33:41 +00:00
|
|
|
methods: {
|
2018-05-07 03:21:48 +00:00
|
|
|
async download(lc) {
|
|
|
|
lc.isDownloading = true
|
|
|
|
const respRaw = await this.$apollo.mutate({
|
|
|
|
mutation: localesDownloadMutation,
|
|
|
|
variables: {
|
|
|
|
locale: lc.code
|
|
|
|
}
|
|
|
|
})
|
|
|
|
const resp = _.get(respRaw, 'data.localization.downloadLocale.responseResult', {})
|
|
|
|
if (resp.succeeded) {
|
|
|
|
lc.isDownloading = false
|
|
|
|
lc.isInstalled = true
|
2019-07-13 03:56:44 +00:00
|
|
|
lc.updatedAt = new Date().toISOString()
|
|
|
|
lc.installDate = lc.updatedAt
|
2018-05-07 03:21:48 +00:00
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: `Locale ${lc.name} has been installed successfully.`,
|
|
|
|
style: 'success',
|
|
|
|
icon: 'get_app'
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: `Error: ${resp.message}`,
|
|
|
|
style: 'error',
|
|
|
|
icon: 'warning'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.isDownloading = false
|
|
|
|
},
|
2018-05-06 21:33:41 +00:00
|
|
|
async save() {
|
|
|
|
this.loading = true
|
|
|
|
const respRaw = await this.$apollo.mutate({
|
2018-05-07 03:21:48 +00:00
|
|
|
mutation: localesSaveMutation,
|
2018-05-06 21:33:41 +00:00
|
|
|
variables: {
|
|
|
|
locale: this.selectedLocale,
|
2018-05-28 23:36:35 +00:00
|
|
|
autoUpdate: this.autoUpdate,
|
|
|
|
namespacing: this.namespacing,
|
|
|
|
namespaces: this.namespaces
|
2018-05-06 21:33:41 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
const resp = _.get(respRaw, 'data.localization.updateLocale.responseResult', {})
|
|
|
|
if (resp.succeeded) {
|
2019-06-08 00:04:35 +00:00
|
|
|
// Change UI language
|
2018-06-17 21:29:19 +00:00
|
|
|
WIKI.$i18n.i18next.changeLanguage(this.selectedLocale)
|
2018-06-24 04:20:35 +00:00
|
|
|
WIKI.$moment.locale(this.selectedLocale)
|
2019-06-08 00:04:35 +00:00
|
|
|
|
|
|
|
// Check for RTL
|
|
|
|
const curLocale = _.find(this.locales, ['code', this.selectedLocale])
|
|
|
|
this.$vuetify.rtl = curLocale && curLocale.isRTL
|
|
|
|
|
2018-05-06 21:33:41 +00:00
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'Locale settings updated successfully.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'check'
|
|
|
|
})
|
2019-08-10 16:18:14 +00:00
|
|
|
|
|
|
|
_.delay(() => {
|
|
|
|
window.location.reload(true)
|
2019-08-11 04:12:07 +00:00
|
|
|
}, 1000)
|
2018-05-06 21:33:41 +00:00
|
|
|
} else {
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: `Error: ${resp.message}`,
|
|
|
|
style: 'error',
|
|
|
|
icon: 'warning'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.loading = false
|
|
|
|
}
|
|
|
|
},
|
2018-04-29 21:55:36 +00:00
|
|
|
apollo: {
|
|
|
|
locales: {
|
|
|
|
query: localesQuery,
|
2018-06-24 04:20:35 +00:00
|
|
|
fetchPolicy: 'network-only',
|
2018-05-07 03:21:48 +00:00
|
|
|
update: (data) => data.localization.locales.map(lc => ({ ...lc, isDownloading: false })),
|
2018-04-29 21:55:36 +00:00
|
|
|
watchLoading (isLoading) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-locale-refresh')
|
|
|
|
}
|
2018-05-06 21:33:41 +00:00
|
|
|
},
|
|
|
|
selectedLocale: {
|
|
|
|
query: localesQuery,
|
|
|
|
update: (data) => data.localization.config.locale
|
|
|
|
},
|
|
|
|
autoUpdate: {
|
|
|
|
query: localesQuery,
|
|
|
|
update: (data) => data.localization.config.autoUpdate
|
2018-05-28 23:36:35 +00:00
|
|
|
},
|
|
|
|
namespacing: {
|
|
|
|
query: localesQuery,
|
|
|
|
update: (data) => data.localization.config.namespacing
|
|
|
|
},
|
|
|
|
namespaces: {
|
|
|
|
query: localesQuery,
|
|
|
|
update: (data) => data.localization.config.namespaces
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|