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.

157 lines
5.2 KiB

  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row wrap)
  4. v-flex(xs12)
  5. .admin-header
  6. v-icon(size='80', color='grey lighten-2') palette
  7. .admin-header-title
  8. .headline.primary--text Theme
  9. .subheading.grey--text Modify the look &amp; feel of your wiki
  10. v-spacer
  11. v-btn(color='success', depressed, @click='save', large, :loading='loading')
  12. v-icon(left) check
  13. span {{$t('common:actions.apply')}}
  14. v-form.pt-3
  15. v-layout(row wrap)
  16. v-flex(lg6 xs12)
  17. v-card
  18. v-toolbar(color='primary', dark, dense, flat)
  19. v-toolbar-title
  20. .subheading Theme
  21. v-card-text
  22. v-select(
  23. :items='themes'
  24. outline
  25. background-color='grey lighten-2'
  26. prepend-icon='palette'
  27. v-model='selectedTheme'
  28. label='Site Theme'
  29. persistent-hint
  30. hint='Themes affect how content pages are displayed. Other site sections (such as the editor or admin area) are not affected.'
  31. )
  32. template(slot='item', slot-scope='data')
  33. v-list-tile-avatar
  34. v-icon.blue--text(dark) filter_frames
  35. v-list-tile-content
  36. v-list-tile-title(v-html='data.item.text')
  37. v-list-tile-sub-title(v-html='data.item.author')
  38. v-divider.mt-3
  39. v-switch(
  40. v-model='darkMode'
  41. label='Dark Mode'
  42. color='primary'
  43. persistent-hint
  44. hint='Not recommended for accessibility. May not be supported by all themes.'
  45. )
  46. v-card.mt-3
  47. v-toolbar(color='primary', dark, dense, flat)
  48. v-toolbar-title
  49. .subheading Code Injection
  50. v-card-text
  51. v-textarea(
  52. v-model='injectCSS'
  53. label='CSS Override'
  54. outline
  55. background-color='grey lighten-1'
  56. color='primary'
  57. persistent-hint
  58. hint='CSS code to inject after system default CSS'
  59. auto-grow
  60. )
  61. v-textarea.mt-2(
  62. v-model='injectHeader'
  63. label='Head HTML Injection'
  64. outline
  65. background-color='grey lighten-1'
  66. color='primary'
  67. persistent-hint
  68. hint='HTML code to be injected just before the closing head tag'
  69. auto-grow
  70. )
  71. v-textarea.mt-2(
  72. v-model='injectFooter'
  73. label='Body HTML Injection'
  74. outline
  75. background-color='grey lighten-1'
  76. color='primary'
  77. persistent-hint
  78. hint='HTML code to be injected just before the closing body tag'
  79. auto-grow
  80. )
  81. v-flex(lg6 xs12)
  82. v-card
  83. v-toolbar(color='teal', dark, dense, flat)
  84. v-toolbar-title
  85. .subheading Download Themes
  86. v-card-text.caption -- Coming soon --
  87. </template>
  88. <script>
  89. import _ from 'lodash'
  90. import { sync } from 'vuex-pathify'
  91. import themeSaveMutation from 'gql/admin/theme/theme-mutation-save.gql'
  92. export default {
  93. data() {
  94. return {
  95. loading: false,
  96. themes: [
  97. { text: 'Default', author: 'requarks.io', value: 'default' }
  98. ],
  99. selectedTheme: 'default',
  100. darkModeInitial: false,
  101. injectCSS: '',
  102. injectHeader: '',
  103. injectFooter: ''
  104. }
  105. },
  106. computed: {
  107. darkMode: sync('site/dark')
  108. },
  109. mounted() {
  110. this.darkModeInitial = this.darkMode
  111. },
  112. beforeDestroy() {
  113. this.darkMode = this.darkModeInitial
  114. },
  115. methods: {
  116. async save () {
  117. this.loading = true
  118. this.$store.commit(`loadingStart`, 'admin-theme-save')
  119. try {
  120. const respRaw = await this.$apollo.mutate({
  121. mutation: themeSaveMutation,
  122. variables: {
  123. theme: this.selectedTheme,
  124. darkMode: this.darkMode
  125. }
  126. })
  127. const resp = _.get(respRaw, 'data.theming.setConfig.responseResult', {})
  128. if (resp.succeeded) {
  129. this.darkModeInitial = this.darkMode
  130. this.$store.commit('showNotification', {
  131. message: 'Theme settings updated successfully.',
  132. style: 'success',
  133. icon: 'check'
  134. })
  135. } else {
  136. throw new Error(resp.message)
  137. }
  138. } catch (err) {
  139. this.$store.commit('showNotification', {
  140. message: `Error: ${err.message}`,
  141. style: 'error',
  142. icon: 'warning'
  143. })
  144. }
  145. this.$store.commit(`loadingStop`, 'admin-theme-save')
  146. this.loading = false
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang='scss'>
  152. </style>