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)
|
2018-03-03 06:32:58 +00:00
|
|
|
v-layout(row wrap)
|
|
|
|
v-flex(xs12)
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header
|
2019-03-17 17:39:58 +00:00
|
|
|
img.animated.fadeInUp(src='/svg/icon-paint-palette.svg', alt='Theme', style='width: 80px;')
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header-title
|
2019-06-09 01:00:12 +00:00
|
|
|
.headline.primary--text.animated.fadeInLeft {{$t('admin:theme.title')}}
|
2019-08-03 04:48:55 +00:00
|
|
|
.subtitle-1.grey--text.animated.fadeInLeft.wait-p2s {{$t('admin:theme.subtitle')}}
|
2018-09-30 03:30:20 +00:00
|
|
|
v-spacer
|
2019-03-17 17:39:58 +00:00
|
|
|
v-btn.animated.fadeInRight(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)
|
|
|
|
v-flex(lg6 xs12)
|
2019-08-12 03:26:29 +00:00
|
|
|
v-card.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:theme.title')}}
|
2018-03-03 06:32:58 +00:00
|
|
|
v-card-text
|
2018-06-11 03:23:09 +00:00
|
|
|
v-select(
|
|
|
|
:items='themes'
|
2019-07-29 04:50:03 +00:00
|
|
|
outlined
|
|
|
|
prepend-icon='mdi-palette'
|
2019-01-26 02:29:34 +00:00
|
|
|
v-model='config.theme'
|
2019-06-09 01:00:12 +00:00
|
|
|
:label='$t(`admin:theme.siteTheme`)'
|
2018-06-11 03:23:09 +00:00
|
|
|
persistent-hint
|
2019-06-09 01:00:12 +00:00
|
|
|
:hint='$t(`admin:theme.siteThemeHint`)'
|
2018-06-11 03:23:09 +00:00
|
|
|
)
|
2018-03-03 06:32:58 +00:00
|
|
|
template(slot='item', slot-scope='data')
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-avatar
|
2019-08-10 16:18:14 +00:00
|
|
|
v-icon.blue--text(dark) mdi-image-filter-frames
|
2019-07-29 04:50:03 +00:00
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title(v-html='data.item.text')
|
|
|
|
v-list-item-sub-title(v-html='data.item.author')
|
2019-07-13 05:45:03 +00:00
|
|
|
v-select.mt-3(
|
|
|
|
:items='iconsets'
|
2019-07-29 04:50:03 +00:00
|
|
|
outlined
|
|
|
|
prepend-icon='mdi-paw'
|
2019-07-13 05:45:03 +00:00
|
|
|
v-model='config.iconset'
|
|
|
|
:label='$t(`admin:theme.iconset`)'
|
|
|
|
persistent-hint
|
|
|
|
:hint='$t(`admin:theme.iconsetHint`)'
|
|
|
|
)
|
2018-07-08 05:12:43 +00:00
|
|
|
v-divider.mt-3
|
2018-06-11 03:23:09 +00:00
|
|
|
v-switch(
|
2019-09-01 22:33:36 +00:00
|
|
|
inset
|
2018-06-11 03:23:09 +00:00
|
|
|
v-model='darkMode'
|
2019-06-09 01:00:12 +00:00
|
|
|
:label='$t(`admin:theme.darkMode`)'
|
2018-06-11 03:23:09 +00:00
|
|
|
color='primary'
|
|
|
|
persistent-hint
|
2019-06-09 01:00:12 +00:00
|
|
|
:hint='$t(`admin:theme.darkModeHint`)'
|
2018-06-11 03:23:09 +00:00
|
|
|
)
|
2019-07-13 05:45:03 +00:00
|
|
|
|
2019-12-02 03:45:37 +00:00
|
|
|
v-card.mt-3.animated.fadeInUp.wait-p1s
|
|
|
|
v-toolbar(color='primary', dark, dense, flat)
|
|
|
|
v-toolbar-title.subtitle-1 {{$t(`admin:theme.options`)}}
|
|
|
|
v-spacer
|
|
|
|
v-chip(label, color='white', small).primary--text coming soon
|
|
|
|
v-card-text
|
|
|
|
v-select(
|
|
|
|
:items='[]'
|
|
|
|
outlined
|
|
|
|
prepend-icon='mdi-border-vertical'
|
|
|
|
v-model='config.iconset'
|
|
|
|
label='Table of Contents Position'
|
|
|
|
persistent-hint
|
|
|
|
hint='Select whether the table of contents is shown on the left, right or not at all.'
|
|
|
|
disabled
|
|
|
|
)
|
|
|
|
|
|
|
|
v-flex(lg6 xs12)
|
|
|
|
v-card.animated.fadeInUp.wait-p2s
|
|
|
|
v-toolbar(color='teal', dark, dense, flat)
|
|
|
|
v-toolbar-title.subtitle-1 {{$t('admin:theme.downloadThemes')}}
|
|
|
|
v-spacer
|
|
|
|
v-chip(label, color='white', small).teal--text coming soon
|
|
|
|
v-data-table(
|
|
|
|
:headers='headers',
|
|
|
|
:items='themes',
|
|
|
|
hide-default-footer,
|
|
|
|
item-key='value',
|
|
|
|
:items-per-page='1000'
|
|
|
|
)
|
|
|
|
template(v-slot:item='thm')
|
|
|
|
td
|
|
|
|
strong {{thm.item.text}}
|
|
|
|
td
|
|
|
|
span {{ thm.item.author }}
|
|
|
|
td.text-xs-center
|
|
|
|
v-progress-circular(v-if='thm.item.isDownloading', indeterminate, color='blue', size='20', :width='2')
|
|
|
|
v-btn(v-else-if='thm.item.isInstalled && thm.item.installDate < thm.item.updatedAt', icon)
|
|
|
|
v-icon.blue--text mdi-cached
|
|
|
|
v-btn(v-else-if='thm.item.isInstalled', icon)
|
|
|
|
v-icon.green--text mdi-check-bold
|
|
|
|
v-btn(v-else, icon)
|
|
|
|
v-icon.grey--text mdi-cloud-download
|
2019-08-12 03:26:29 +00:00
|
|
|
|
|
|
|
v-card.mt-3.animated.fadeInUp.wait-p2s
|
2018-08-05 15:27:46 +00:00
|
|
|
v-toolbar(color='primary', dark, dense, flat)
|
2019-07-29 04:50:03 +00:00
|
|
|
v-toolbar-title.subtitle-1 {{$t(`admin:theme.codeInjection`)}}
|
2018-08-05 15:27:46 +00:00
|
|
|
v-card-text
|
|
|
|
v-textarea(
|
2019-01-26 02:29:34 +00:00
|
|
|
v-model='config.injectCSS'
|
2019-06-09 01:00:12 +00:00
|
|
|
:label='$t(`admin:theme.cssOverride`)'
|
2019-07-29 04:50:03 +00:00
|
|
|
outlined
|
2018-08-05 15:27:46 +00:00
|
|
|
color='primary'
|
|
|
|
persistent-hint
|
2019-06-09 01:00:12 +00:00
|
|
|
:hint='$t(`admin:theme.cssOverrideHint`)'
|
2018-08-05 15:27:46 +00:00
|
|
|
auto-grow
|
|
|
|
)
|
2019-07-14 20:12:26 +00:00
|
|
|
i18next.caption.pl-2.ml-1(path='admin:theme.cssOverrideWarning', tag='div')
|
|
|
|
strong.red--text(place='caution') {{$t('admin:theme.cssOverrideWarningCaution')}}
|
|
|
|
code(place='cssClass') .contents
|
|
|
|
v-textarea.mt-3(
|
2019-01-26 02:29:34 +00:00
|
|
|
v-model='config.injectHead'
|
2019-06-09 01:00:12 +00:00
|
|
|
:label='$t(`admin:theme.headHtmlInjection`)'
|
2019-07-29 04:50:03 +00:00
|
|
|
outlined
|
2018-08-05 15:27:46 +00:00
|
|
|
color='primary'
|
|
|
|
persistent-hint
|
2019-06-09 01:00:12 +00:00
|
|
|
:hint='$t(`admin:theme.headHtmlInjectionHint`)'
|
2018-08-05 15:27:46 +00:00
|
|
|
auto-grow
|
|
|
|
)
|
|
|
|
v-textarea.mt-2(
|
2019-01-26 02:29:34 +00:00
|
|
|
v-model='config.injectBody'
|
2019-06-09 01:00:12 +00:00
|
|
|
:label='$t(`admin:theme.bodyHtmlInjection`)'
|
2019-07-29 04:50:03 +00:00
|
|
|
outlined
|
2018-08-05 15:27:46 +00:00
|
|
|
color='primary'
|
|
|
|
persistent-hint
|
2019-06-09 01:00:12 +00:00
|
|
|
:hint='$t(`admin:theme.bodyHtmlInjectionHint`)'
|
2018-08-05 15:27:46 +00:00
|
|
|
auto-grow
|
|
|
|
)
|
2018-03-03 06:32:58 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-06-11 03:23:09 +00:00
|
|
|
import _ from 'lodash'
|
2018-07-15 23:16:19 +00:00
|
|
|
import { sync } from 'vuex-pathify'
|
2018-06-11 03:23:09 +00:00
|
|
|
|
2019-01-26 02:29:34 +00:00
|
|
|
import themeConfigQuery from 'gql/admin/theme/theme-query-config.gql'
|
2018-06-25 06:44:40 +00:00
|
|
|
import themeSaveMutation from 'gql/admin/theme/theme-mutation-save.gql'
|
2018-06-11 03:23:09 +00:00
|
|
|
|
2018-03-03 06:32:58 +00:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2018-06-11 03:23:09 +00:00
|
|
|
loading: false,
|
2018-03-03 06:32:58 +00:00
|
|
|
themes: [
|
2019-07-14 20:12:26 +00:00
|
|
|
{ text: 'Default', author: 'requarks.io', value: 'default', isInstalled: true, installDate: '', updatedAt: '' }
|
2018-03-03 06:32:58 +00:00
|
|
|
],
|
2019-07-13 05:45:03 +00:00
|
|
|
iconsets: [
|
2019-07-29 04:50:03 +00:00
|
|
|
{ text: 'Material Design Icons (default)', value: 'mdi' },
|
2019-07-13 05:45:03 +00:00
|
|
|
{ text: 'Font Awesome 5', value: 'fa' },
|
2019-07-29 04:50:03 +00:00
|
|
|
{ text: 'Font Awesome 4', value: 'fa4' }
|
2019-07-13 05:45:03 +00:00
|
|
|
],
|
2019-01-26 02:29:34 +00:00
|
|
|
config: {
|
|
|
|
theme: 'default',
|
|
|
|
darkMode: false,
|
2019-07-13 05:45:03 +00:00
|
|
|
iconset: '',
|
2019-01-26 02:29:34 +00:00
|
|
|
injectCSS: '',
|
|
|
|
injectHead: '',
|
|
|
|
injectBody: ''
|
|
|
|
},
|
|
|
|
darkModeInitial: false
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
2018-06-10 00:11:00 +00:00
|
|
|
},
|
2018-07-15 23:16:19 +00:00
|
|
|
computed: {
|
2019-07-14 20:12:26 +00:00
|
|
|
darkMode: sync('site/dark'),
|
|
|
|
headers() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
text: this.$t('admin:theme.downloadName'),
|
|
|
|
align: 'left',
|
|
|
|
value: 'text'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: this.$t('admin:theme.downloadAuthor'),
|
|
|
|
align: 'left',
|
|
|
|
value: 'author'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: this.$t('admin:theme.downloadDownload'),
|
|
|
|
align: 'center',
|
|
|
|
value: 'value',
|
|
|
|
sortable: false,
|
|
|
|
width: 100
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2018-06-11 03:23:09 +00:00
|
|
|
},
|
2019-08-05 03:53:21 +00:00
|
|
|
watch: {
|
|
|
|
'darkMode' (newValue, oldValue) {
|
|
|
|
this.$vuetify.theme.dark = newValue
|
|
|
|
}
|
|
|
|
},
|
2018-06-11 03:23:09 +00:00
|
|
|
mounted() {
|
|
|
|
this.darkModeInitial = this.darkMode
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-07-15 23:16:19 +00:00
|
|
|
this.darkMode = this.darkModeInitial
|
2019-08-05 03:53:21 +00:00
|
|
|
this.$vuetify.theme.dark = this.darkModeInitial
|
2018-06-11 03:23:09 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async save () {
|
|
|
|
this.loading = true
|
|
|
|
this.$store.commit(`loadingStart`, 'admin-theme-save')
|
|
|
|
try {
|
|
|
|
const respRaw = await this.$apollo.mutate({
|
|
|
|
mutation: themeSaveMutation,
|
|
|
|
variables: {
|
2019-01-26 02:29:34 +00:00
|
|
|
theme: this.config.theme,
|
2019-07-13 05:45:03 +00:00
|
|
|
iconset: this.config.iconset,
|
2019-01-26 02:29:34 +00:00
|
|
|
darkMode: this.darkMode,
|
|
|
|
injectCSS: this.config.injectCSS,
|
|
|
|
injectHead: this.config.injectHead,
|
|
|
|
injectBody: this.config.injectBody
|
2018-06-11 03:23:09 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
const resp = _.get(respRaw, 'data.theming.setConfig.responseResult', {})
|
|
|
|
if (resp.succeeded) {
|
|
|
|
this.darkModeInitial = this.darkMode
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'Theme settings updated successfully.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'check'
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
throw new Error(resp.message)
|
|
|
|
}
|
|
|
|
} catch (err) {
|
2019-01-13 03:33:30 +00:00
|
|
|
this.$store.commit('pushGraphError', err)
|
2018-06-11 03:23:09 +00:00
|
|
|
}
|
|
|
|
this.$store.commit(`loadingStop`, 'admin-theme-save')
|
|
|
|
this.loading = false
|
2018-06-10 00:11:00 +00:00
|
|
|
}
|
2019-01-26 02:29:34 +00:00
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
config: {
|
|
|
|
query: themeConfigQuery,
|
|
|
|
fetchPolicy: 'network-only',
|
|
|
|
update: (data) => data.theming.config,
|
|
|
|
watchLoading (isLoading) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-theme-refresh')
|
|
|
|
}
|
|
|
|
}
|
2018-03-03 06:32:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
|
|
|
|
|
|
|
</style>
|