admin-general.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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-categorize.svg', alt='General', style='width: 80px;')
  7. .admin-header-title
  8. .headline.primary--text.animated.fadeInLeft {{ $t('admin:general.title') }}
  9. .subheading.grey--text.animated.fadeInLeft {{ $t('admin:general.subtitle') }}
  10. v-spacer
  11. v-btn.animated.fadeInDown(color='success', depressed, @click='save', large)
  12. v-icon(left) mdi-check
  13. span {{$t('common:actions.apply')}}
  14. v-form.pt-3
  15. v-layout(row wrap)
  16. v-flex(lg6 xs12)
  17. v-form
  18. v-card.animated.fadeInUp
  19. v-toolbar(color='primary', dark, dense, flat)
  20. v-toolbar-title.subtitle-1 {{ $t('admin:general.siteInfo') }}
  21. v-subheader {{$t('admin:general.general')}}
  22. .px-3.pb-3
  23. v-text-field(
  24. outlined
  25. :label='$t(`admin:general.siteUrl`)'
  26. required
  27. :counter='255'
  28. v-model='config.host'
  29. prepend-icon='mdi-label-variant-outline'
  30. :hint='$t(`admin:general.siteUrlHint`)'
  31. persistent-hint
  32. )
  33. v-text-field.mt-3(
  34. outlined
  35. :label='$t(`admin:general.siteTitle`)'
  36. required
  37. :counter='50'
  38. v-model='config.title'
  39. prepend-icon='mdi-earth'
  40. :hint='$t(`admin:general.siteTitleHint`)'
  41. persistent-hint
  42. )
  43. v-divider
  44. v-subheader {{$t('admin:general.logo')}} #[v-chip.ml-2(label, color='grey', small, outlined) coming soon]
  45. v-card-text.pb-4.pl-5
  46. v-layout.px-3(row, align-center)
  47. v-avatar(size='100', :color='$vuetify.dark ? `grey darken-2` : `grey lighten-3`', :tile='config.logoIsSquare')
  48. .ml-4
  49. v-btn.mr-3(color='teal', depressed, disabled)
  50. v-icon(left) mdi-cloud-upload
  51. span {{$t('admin:general.uploadLogo')}}
  52. v-btn(color='teal', depressed, disabled)
  53. v-icon(left) mdi-close
  54. span {{$t('admin:general.uploadClear')}}
  55. .caption.mt-3.grey--text {{$t('admin:general.uploadSizeHint', { size: '120x120' })}}
  56. .caption.grey--text {{$t('admin:general.uploadTypesHint', { typeList: 'SVG, PNG', lastType: 'JPG' })}}.
  57. v-divider
  58. v-subheader {{$t('admin:general.footerCopyright')}}
  59. .px-3.pb-3
  60. v-text-field(
  61. outlined
  62. :label='$t(`admin:general.companyName`)'
  63. v-model='config.company'
  64. :counter='255'
  65. prepend-icon='mdi-domain'
  66. persistent-hint
  67. :hint='$t(`admin:general.companyNameHint`)'
  68. )
  69. v-divider
  70. v-subheader SEO
  71. .px-3.pb-3
  72. v-text-field(
  73. outlined
  74. :label='$t(`admin:general.siteDescription`)'
  75. :counter='255'
  76. v-model='config.description'
  77. prepend-icon='mdi-compass'
  78. :hint='$t(`admin:general.siteDescriptionHint`)'
  79. persistent-hint
  80. )
  81. v-select.mt-3(
  82. outlined
  83. :label='$t(`admin:general.metaRobots`)'
  84. multiple
  85. :items='metaRobots'
  86. v-model='config.robots'
  87. prepend-icon='mdi-compass'
  88. :return-object='false'
  89. :hint='$t(`admin:general.metaRobotsHint`)'
  90. persistent-hint
  91. )
  92. v-flex(lg6 xs12)
  93. v-card.animated.fadeInUp.wait-p4s
  94. v-toolbar(color='primary', dark, dense, flat)
  95. v-toolbar-title.subtitle-1 Features
  96. v-spacer
  97. v-chip(label, color='white', small).primary--text coming soon
  98. v-card-text
  99. v-switch(
  100. label='Asset Image Optimization'
  101. color='primary'
  102. v-model='config.featureTinyPNG'
  103. persistent-hint
  104. hint='Image optimization tool to reduce filesize and bandwidth costs.'
  105. disabled
  106. )
  107. v-text-field.mt-3(
  108. outlined
  109. label='TinyPNG API Key'
  110. :counter='255'
  111. v-model='config.description'
  112. prepend-icon='mdi-subdirectory-arrow-right'
  113. hint='Get your API key at https://tinypng.com/developers'
  114. persistent-hint
  115. disabled
  116. )
  117. v-divider.mt-3
  118. v-switch(
  119. label='Page Ratings'
  120. color='primary'
  121. v-model='config.featurePageRatings'
  122. persistent-hint
  123. hint='Allow users to rate pages.'
  124. disabled
  125. )
  126. v-divider.mt-3
  127. v-switch(
  128. label='Page Comments'
  129. color='primary'
  130. v-model='config.featurePageComments'
  131. persistent-hint
  132. hint='Allow users to leave comments on pages.'
  133. disabled
  134. )
  135. v-divider.mt-3
  136. v-switch(
  137. label='Personal Wikis'
  138. color='primary'
  139. v-model='config.featurePersonalWikis'
  140. persistent-hint
  141. hint='Allow users to have their own personal wiki.'
  142. disabled
  143. )
  144. </template>
  145. <script>
  146. import _ from 'lodash'
  147. import { get, sync } from 'vuex-pathify'
  148. import siteConfigQuery from 'gql/admin/site/site-query-config.gql'
  149. import siteUpdateConfigMutation from 'gql/admin/site/site-mutation-save-config.gql'
  150. export default {
  151. data() {
  152. return {
  153. analyticsServices: [
  154. { text: 'None', value: '' },
  155. { text: 'Elasticsearch APM RUM', value: 'elk' },
  156. { text: 'Google Analytics', value: 'ga' },
  157. { text: 'Google Tag Manager', value: 'gtm' }
  158. ],
  159. metaRobots: [
  160. { text: 'Index', value: 'index' },
  161. { text: 'Follow', value: 'follow' },
  162. { text: 'No Index', value: 'noindex' },
  163. { text: 'No Follow', value: 'nofollow' }
  164. ],
  165. config: {
  166. host: '',
  167. title: '',
  168. description: '',
  169. robots: [],
  170. analyticsService: '',
  171. analyticsId: '',
  172. company: '',
  173. hasLogo: false,
  174. logoIsSquare: false,
  175. featureAnalytics: false,
  176. featurePageRatings: false,
  177. featurePageComments: false,
  178. featurePersonalWikis: false,
  179. featureTinyPNG: false
  180. }
  181. }
  182. },
  183. computed: {
  184. darkMode: get('site/dark'),
  185. siteTitle: sync('site/title'),
  186. company: sync('site/company')
  187. },
  188. methods: {
  189. async save () {
  190. try {
  191. await this.$apollo.mutate({
  192. mutation: siteUpdateConfigMutation,
  193. variables: {
  194. host: this.config.host || '',
  195. title: this.config.title || '',
  196. description: this.config.description || '',
  197. robots: this.config.robots || [],
  198. analyticsService: this.config.analyticsService || '',
  199. analyticsId: this.config.analyticsId || '',
  200. company: this.config.company || '',
  201. hasLogo: this.config.hasLogo || false,
  202. logoIsSquare: this.config.logoIsSquare || false,
  203. featurePageRatings: this.config.featurePageRatings || false,
  204. featurePageComments: this.config.featurePageComments || false,
  205. featurePersonalWikis: this.config.featurePersonalWikis || false
  206. },
  207. watchLoading (isLoading) {
  208. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-update')
  209. }
  210. })
  211. this.$store.commit('showNotification', {
  212. style: 'success',
  213. message: 'Configuration saved successfully.',
  214. icon: 'check'
  215. })
  216. this.siteTitle = this.config.title
  217. this.company = this.config.company
  218. } catch (err) {
  219. this.$store.commit('pushGraphError', err)
  220. }
  221. }
  222. },
  223. apollo: {
  224. config: {
  225. query: siteConfigQuery,
  226. fetchPolicy: 'network-only',
  227. update: (data) => _.cloneDeep(data.site.config),
  228. watchLoading (isLoading) {
  229. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-refresh')
  230. }
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang='scss'>
  236. </style>