admin-general.vue 9.2 KB

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