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.

172 lines
6.1 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. img.animated.fadeInUp(src='/svg/icon-paint-palette.svg', alt='Theme', style='width: 80px;')
  7. .admin-header-title
  8. .headline.primary--text.animated.fadeInLeft Theme
  9. .subheading.grey--text.animated.fadeInLeft.wait-p2s Modify the look &amp; feel of your wiki
  10. v-spacer
  11. v-btn.animated.fadeInRight(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.wiki-form.animated.fadeInUp
  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='config.theme'
  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.wiki-form.mt-3.animated.fadeInUp.wait-p2s
  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='config.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. Consider using custom themes if you have a large amount of css code. Injecting too much CSS code will result in poor page load performance! CSS will automatically be minified.'
  59. auto-grow
  60. )
  61. v-textarea.mt-2(
  62. v-model='config.injectHead'
  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. Usually for script tags.'
  69. auto-grow
  70. )
  71. v-textarea.mt-2(
  72. v-model='config.injectBody'
  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.animated.fadeInUp.wait-p2s
  83. v-toolbar(color='teal', dark, dense, flat)
  84. v-toolbar-title
  85. .subheading Download Themes
  86. v-spacer
  87. v-chip(label, color='white', small).teal--text coming soon
  88. v-card-text.caption -- Coming soon --
  89. </template>
  90. <script>
  91. import _ from 'lodash'
  92. import { sync } from 'vuex-pathify'
  93. import themeConfigQuery from 'gql/admin/theme/theme-query-config.gql'
  94. import themeSaveMutation from 'gql/admin/theme/theme-mutation-save.gql'
  95. export default {
  96. data() {
  97. return {
  98. loading: false,
  99. themes: [
  100. { text: 'Default', author: 'requarks.io', value: 'default' }
  101. ],
  102. config: {
  103. theme: 'default',
  104. darkMode: false,
  105. injectCSS: '',
  106. injectHead: '',
  107. injectBody: ''
  108. },
  109. darkModeInitial: false
  110. }
  111. },
  112. computed: {
  113. darkMode: sync('site/dark')
  114. },
  115. mounted() {
  116. this.darkModeInitial = this.darkMode
  117. },
  118. beforeDestroy() {
  119. this.darkMode = this.darkModeInitial
  120. },
  121. methods: {
  122. async save () {
  123. this.loading = true
  124. this.$store.commit(`loadingStart`, 'admin-theme-save')
  125. try {
  126. const respRaw = await this.$apollo.mutate({
  127. mutation: themeSaveMutation,
  128. variables: {
  129. theme: this.config.theme,
  130. darkMode: this.darkMode,
  131. injectCSS: this.config.injectCSS,
  132. injectHead: this.config.injectHead,
  133. injectBody: this.config.injectBody
  134. }
  135. })
  136. const resp = _.get(respRaw, 'data.theming.setConfig.responseResult', {})
  137. if (resp.succeeded) {
  138. this.darkModeInitial = this.darkMode
  139. this.$store.commit('showNotification', {
  140. message: 'Theme settings updated successfully.',
  141. style: 'success',
  142. icon: 'check'
  143. })
  144. } else {
  145. throw new Error(resp.message)
  146. }
  147. } catch (err) {
  148. this.$store.commit('pushGraphError', err)
  149. }
  150. this.$store.commit(`loadingStop`, 'admin-theme-save')
  151. this.loading = false
  152. }
  153. },
  154. apollo: {
  155. config: {
  156. query: themeConfigQuery,
  157. fetchPolicy: 'network-only',
  158. update: (data) => data.theming.config,
  159. watchLoading (isLoading) {
  160. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-theme-refresh')
  161. }
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang='scss'>
  167. </style>