You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.6 KiB

  1. <template lang='pug'>
  2. v-container(fluid, fill-height, grid-list-lg)
  3. v-layout(row wrap)
  4. v-flex(xs12)
  5. .headline.primary--text Theme
  6. .subheading.grey--text Modify the look &amp; feel of your wiki
  7. v-form.pt-3
  8. v-layout(row wrap)
  9. v-flex(lg6 xs12)
  10. v-card
  11. v-toolbar(color='primary', dark, dense, flat)
  12. v-toolbar-title
  13. .subheading Theme
  14. v-card-text
  15. v-select(
  16. :items='themes'
  17. prepend-icon='palette'
  18. v-model='selectedTheme'
  19. label='Site Theme'
  20. persistent-hint
  21. hint='Themes affect how content pages are displayed. Other site sections (such as the editor or admin area) are not affected.'
  22. )
  23. template(slot='item', slot-scope='data')
  24. v-list-tile-avatar
  25. v-icon.blue--text(dark) filter_frames
  26. v-list-tile-content
  27. v-list-tile-title(v-html='data.item.text')
  28. v-list-tile-sub-title(v-html='data.item.author')
  29. v-divider.mt-3
  30. v-switch(
  31. v-model='darkMode'
  32. label='Dark Mode'
  33. color='primary'
  34. persistent-hint
  35. hint='Not recommended for accessibility. May not be supported by all themes.'
  36. )
  37. v-card-chin
  38. v-spacer
  39. v-btn(color='primary', :loading='loading', @click='save')
  40. v-icon(left) chevron_right
  41. span Save
  42. v-flex(lg6 xs12)
  43. v-card
  44. v-toolbar(color='teal', dark, dense, flat)
  45. v-toolbar-title
  46. .subheading Download Themes
  47. v-card-text.caption -- Coming soon --
  48. </template>
  49. <script>
  50. import _ from 'lodash'
  51. import { sync } from 'vuex-pathify'
  52. import themeSaveMutation from 'gql/admin/theme/theme-mutation-save.gql'
  53. export default {
  54. data() {
  55. return {
  56. loading: false,
  57. themes: [
  58. { text: 'Default', author: 'requarks.io', value: 'default' }
  59. ],
  60. selectedTheme: 'default',
  61. darkModeInitial: false
  62. }
  63. },
  64. computed: {
  65. darkMode: sync('admin/theme@dark')
  66. },
  67. mounted() {
  68. this.darkModeInitial = this.darkMode
  69. },
  70. beforeDestroy() {
  71. this.darkMode = this.darkModeInitial
  72. },
  73. methods: {
  74. async save () {
  75. this.loading = true
  76. this.$store.commit(`loadingStart`, 'admin-theme-save')
  77. try {
  78. const respRaw = await this.$apollo.mutate({
  79. mutation: themeSaveMutation,
  80. variables: {
  81. theme: this.selectedTheme,
  82. darkMode: this.darkMode
  83. }
  84. })
  85. const resp = _.get(respRaw, 'data.theming.setConfig.responseResult', {})
  86. if (resp.succeeded) {
  87. this.darkModeInitial = this.darkMode
  88. this.$store.commit('showNotification', {
  89. message: 'Theme settings updated successfully.',
  90. style: 'success',
  91. icon: 'check'
  92. })
  93. } else {
  94. throw new Error(resp.message)
  95. }
  96. } catch (err) {
  97. this.$store.commit('showNotification', {
  98. message: `Error: ${err.message}`,
  99. style: 'error',
  100. icon: 'warning'
  101. })
  102. }
  103. this.$store.commit(`loadingStop`, 'admin-theme-save')
  104. this.loading = false
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang='scss'>
  110. </style>