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.

164 lines
5.5 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(src='/svg/icon-paint-palette.svg', alt='Theme', style='width: 80px;')
  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.wiki-form
  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.wiki-form.mt-3
  47. v-toolbar(color='primary', dark, dense, flat)
  48. v-toolbar-title
  49. .subheading Code Injection
  50. v-spacer
  51. v-chip(label, color='white', small).primary--text coming soon
  52. v-card-text
  53. v-textarea(
  54. v-model='injectCSS'
  55. label='CSS Override'
  56. outline
  57. background-color='grey lighten-1'
  58. color='primary'
  59. persistent-hint
  60. hint='CSS code to inject after system default CSS'
  61. auto-grow
  62. disabled
  63. )
  64. v-textarea.mt-2(
  65. v-model='injectHeader'
  66. label='Head HTML Injection'
  67. outline
  68. background-color='grey lighten-1'
  69. color='primary'
  70. persistent-hint
  71. hint='HTML code to be injected just before the closing head tag'
  72. auto-grow
  73. disabled
  74. )
  75. v-textarea.mt-2(
  76. v-model='injectFooter'
  77. label='Body HTML Injection'
  78. outline
  79. background-color='grey lighten-1'
  80. color='primary'
  81. persistent-hint
  82. hint='HTML code to be injected just before the closing body tag'
  83. auto-grow
  84. disabled
  85. )
  86. v-flex(lg6 xs12)
  87. v-card
  88. v-toolbar(color='teal', dark, dense, flat)
  89. v-toolbar-title
  90. .subheading Download Themes
  91. v-spacer
  92. v-chip(label, color='white', small).teal--text coming soon
  93. v-card-text.caption -- Coming soon --
  94. </template>
  95. <script>
  96. import _ from 'lodash'
  97. import { sync } from 'vuex-pathify'
  98. import themeSaveMutation from 'gql/admin/theme/theme-mutation-save.gql'
  99. export default {
  100. data() {
  101. return {
  102. loading: false,
  103. themes: [
  104. { text: 'Default', author: 'requarks.io', value: 'default' }
  105. ],
  106. selectedTheme: 'default',
  107. darkModeInitial: false,
  108. injectCSS: '',
  109. injectHeader: '',
  110. injectFooter: ''
  111. }
  112. },
  113. computed: {
  114. darkMode: sync('site/dark')
  115. },
  116. mounted() {
  117. this.darkModeInitial = this.darkMode
  118. },
  119. beforeDestroy() {
  120. this.darkMode = this.darkModeInitial
  121. },
  122. methods: {
  123. async save () {
  124. this.loading = true
  125. this.$store.commit(`loadingStart`, 'admin-theme-save')
  126. try {
  127. const respRaw = await this.$apollo.mutate({
  128. mutation: themeSaveMutation,
  129. variables: {
  130. theme: this.selectedTheme,
  131. darkMode: this.darkMode
  132. }
  133. })
  134. const resp = _.get(respRaw, 'data.theming.setConfig.responseResult', {})
  135. if (resp.succeeded) {
  136. this.darkModeInitial = this.darkMode
  137. this.$store.commit('showNotification', {
  138. message: 'Theme settings updated successfully.',
  139. style: 'success',
  140. icon: 'check'
  141. })
  142. } else {
  143. throw new Error(resp.message)
  144. }
  145. } catch (err) {
  146. this.$store.commit('showNotification', {
  147. message: `Error: ${err.message}`,
  148. style: 'error',
  149. icon: 'warning'
  150. })
  151. }
  152. this.$store.commit(`loadingStop`, 'admin-theme-save')
  153. this.loading = false
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang='scss'>
  159. </style>