admin-theme.vue 5.3 KB

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