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.

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