admin-general.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. .subtitle-1.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. .overline.grey--text.pa-4 {{$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. .overline.grey--text.pa-4 {{$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.theme.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. .overline.grey--text.pa-4 {{$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. .overline.grey--text.pa-4 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='indigo', dark, dense, flat)
  95. v-toolbar-title.subtitle-1 Features
  96. v-spacer
  97. v-chip(label, color='white', small).indigo--text coming soon
  98. v-card-text
  99. v-switch(
  100. label='Asset Image Optimization'
  101. color='indigo'
  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='indigo'
  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='indigo'
  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='indigo'
  139. v-model='config.featurePersonalWikis'
  140. persistent-hint
  141. hint='Allow users to have their own personal wiki.'
  142. disabled
  143. )
  144. v-card.mt-5.animated.fadeInUp.wait-p5s
  145. v-toolbar(color='red darken-2', dark, dense, flat)
  146. v-toolbar-title.subtitle-1 Security
  147. v-card-text
  148. v-alert(outlined, color='red darken-2', icon='mdi-information-outline').body-2 Make sure to understand the implications before turning on / off a security feature.
  149. v-switch.mt-3(
  150. label='Block IFrame Embedding'
  151. color='red darken-2'
  152. v-model='config.securityIframe'
  153. persistent-hint
  154. hint='Prevents other websites from embedding your wiki in an iframe. This provides clickjacking protection.'
  155. )
  156. v-divider.mt-3
  157. v-switch(
  158. label='Same Origin Referrer Policy'
  159. color='red darken-2'
  160. v-model='config.securityReferrerPolicy'
  161. persistent-hint
  162. hint='Limits the referrer header to same origin.'
  163. )
  164. v-divider.mt-3
  165. v-switch(
  166. label='Enforce HSTS'
  167. color='red darken-2'
  168. v-model='config.securityHSTS'
  169. persistent-hint
  170. hint='This ensures the connection cannot be established through an insecure HTTP connection.'
  171. )
  172. v-select.mt-5(
  173. outlined
  174. label='HSTS Max Age'
  175. :items='hstsDurations'
  176. v-model='config.securityHSTSDuration'
  177. prepend-icon='mdi-subdirectory-arrow-right'
  178. :disabled='!config.securityHSTS'
  179. hide-details
  180. style='max-width: 450px;'
  181. )
  182. .pl-11.mt-3
  183. .caption Defines the duration for which the server should only deliver content through HTTPS.
  184. .caption It's a good idea to start with small values and make sure that nothing breaks on your wiki before moving to longer values.
  185. v-divider.mt-3
  186. v-switch(
  187. label='Enforce CSP'
  188. color='red darken-2'
  189. v-model='config.securityCSP'
  190. persistent-hint
  191. hint='Restricts scripts to pre-approved content sources.'
  192. disabled
  193. )
  194. v-textarea.mt-5(
  195. label='CSP Directives'
  196. outlined
  197. v-model='config.securityCSPDirectives'
  198. prepend-icon='mdi-subdirectory-arrow-right'
  199. persistent-hint
  200. hint='One directive per line.'
  201. disabled
  202. )
  203. </template>
  204. <script>
  205. import _ from 'lodash'
  206. import { get, sync } from 'vuex-pathify'
  207. import siteConfigQuery from 'gql/admin/site/site-query-config.gql'
  208. import siteUpdateConfigMutation from 'gql/admin/site/site-mutation-save-config.gql'
  209. export default {
  210. data() {
  211. return {
  212. analyticsServices: [
  213. { text: 'None', value: '' },
  214. { text: 'Elasticsearch APM RUM', value: 'elk' },
  215. { text: 'Google Analytics', value: 'ga' },
  216. { text: 'Google Tag Manager', value: 'gtm' }
  217. ],
  218. config: {
  219. host: '',
  220. title: '',
  221. description: '',
  222. robots: [],
  223. analyticsService: '',
  224. analyticsId: '',
  225. company: '',
  226. hasLogo: false,
  227. logoIsSquare: false,
  228. featureAnalytics: false,
  229. featurePageRatings: false,
  230. featurePageComments: false,
  231. featurePersonalWikis: false,
  232. featureTinyPNG: false,
  233. securityIframe: true,
  234. securityReferrerPolicy: true,
  235. securityHSTS: false,
  236. securityHSTSDuration: 0,
  237. securityCSP: false,
  238. securityCSPDirectives: ''
  239. },
  240. hstsDurations: [
  241. { value: 300, text: '5 minutes' },
  242. { value: 86400, text: '1 day' },
  243. { value: 604800, text: '1 week' },
  244. { value: 2592000, text: '1 month' },
  245. { value: 31536000, text: '1 year' },
  246. { value: 63072000, text: '2 years' }
  247. ],
  248. metaRobots: [
  249. { text: 'Index', value: 'index' },
  250. { text: 'Follow', value: 'follow' },
  251. { text: 'No Index', value: 'noindex' },
  252. { text: 'No Follow', value: 'nofollow' }
  253. ]
  254. }
  255. },
  256. computed: {
  257. darkMode: get('site/dark'),
  258. siteTitle: sync('site/title'),
  259. company: sync('site/company')
  260. },
  261. methods: {
  262. async save () {
  263. try {
  264. await this.$apollo.mutate({
  265. mutation: siteUpdateConfigMutation,
  266. variables: {
  267. host: _.get(this.config, 'host', ''),
  268. title: _.get(this.config, 'title', ''),
  269. description: _.get(this.config, 'description', ''),
  270. robots: _.get(this.config, 'robots', []),
  271. analyticsService: _.get(this.config, 'analyticsService', ''),
  272. analyticsId: _.get(this.config, 'analyticsId', ''),
  273. company: _.get(this.config, 'company', ''),
  274. hasLogo: _.get(this.config, 'hasLogo', false),
  275. logoIsSquare: _.get(this.config, 'logoIsSquare', false),
  276. featurePageRatings: _.get(this.config, 'featurePageRatings', false),
  277. featurePageComments: _.get(this.config, 'featurePageComments', false),
  278. featurePersonalWikis: _.get(this.config, 'featurePersonalWikis', false),
  279. securityIframe: _.get(this.config, 'securityIframe', false),
  280. securityReferrerPolicy: _.get(this.config, 'securityReferrerPolicy', false),
  281. securityHSTS: _.get(this.config, 'securityHSTS', false),
  282. securityHSTSDuration: _.get(this.config, 'securityHSTSDuration', 0),
  283. securityCSP: _.get(this.config, 'securityCSP', false),
  284. securityCSPDirectives: _.get(this.config, 'securityCSPDirectives', '')
  285. },
  286. watchLoading (isLoading) {
  287. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-update')
  288. }
  289. })
  290. this.$store.commit('showNotification', {
  291. style: 'success',
  292. message: 'Configuration saved successfully.',
  293. icon: 'check'
  294. })
  295. this.siteTitle = this.config.title
  296. this.company = this.config.company
  297. } catch (err) {
  298. this.$store.commit('pushGraphError', err)
  299. }
  300. }
  301. },
  302. apollo: {
  303. config: {
  304. query: siteConfigQuery,
  305. fetchPolicy: 'network-only',
  306. update: (data) => _.cloneDeep(data.site.config),
  307. watchLoading (isLoading) {
  308. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-refresh')
  309. }
  310. }
  311. }
  312. }
  313. </script>
  314. <style lang='scss'>
  315. </style>