2
0

admin-general.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. inset
  101. label='Asset Image Optimization'
  102. color='indigo'
  103. v-model='config.featureTinyPNG'
  104. persistent-hint
  105. hint='Image optimization tool to reduce filesize and bandwidth costs.'
  106. disabled
  107. )
  108. v-text-field.mt-3(
  109. outlined
  110. label='TinyPNG API Key'
  111. :counter='255'
  112. v-model='config.description'
  113. prepend-icon='mdi-subdirectory-arrow-right'
  114. hint='Get your API key at https://tinypng.com/developers'
  115. persistent-hint
  116. disabled
  117. )
  118. v-divider.mt-3
  119. v-switch(
  120. inset
  121. label='Page Ratings'
  122. color='indigo'
  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. inset
  131. label='Page Comments'
  132. color='indigo'
  133. v-model='config.featurePageComments'
  134. persistent-hint
  135. hint='Allow users to leave comments on pages.'
  136. disabled
  137. )
  138. v-divider.mt-3
  139. v-switch(
  140. inset
  141. label='Personal Wikis'
  142. color='indigo'
  143. v-model='config.featurePersonalWikis'
  144. persistent-hint
  145. hint='Allow users to have their own personal wiki.'
  146. disabled
  147. )
  148. v-card.mt-5.animated.fadeInUp.wait-p5s
  149. v-toolbar(color='red darken-2', dark, dense, flat)
  150. v-toolbar-title.subtitle-1 Security
  151. v-card-text
  152. 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.
  153. v-switch.mt-3(
  154. inset
  155. label='Block IFrame Embedding'
  156. color='red darken-2'
  157. v-model='config.securityIframe'
  158. persistent-hint
  159. hint='Prevents other websites from embedding your wiki in an iframe. This provides clickjacking protection.'
  160. )
  161. v-divider.mt-3
  162. v-switch(
  163. inset
  164. label='Same Origin Referrer Policy'
  165. color='red darken-2'
  166. v-model='config.securityReferrerPolicy'
  167. persistent-hint
  168. hint='Limits the referrer header to same origin.'
  169. )
  170. v-divider.mt-3
  171. v-switch(
  172. inset
  173. label='Enforce HSTS'
  174. color='red darken-2'
  175. v-model='config.securityHSTS'
  176. persistent-hint
  177. hint='This ensures the connection cannot be established through an insecure HTTP connection.'
  178. )
  179. v-select.mt-5(
  180. outlined
  181. label='HSTS Max Age'
  182. :items='hstsDurations'
  183. v-model='config.securityHSTSDuration'
  184. prepend-icon='mdi-subdirectory-arrow-right'
  185. :disabled='!config.securityHSTS'
  186. hide-details
  187. style='max-width: 450px;'
  188. )
  189. .pl-11.mt-3
  190. .caption Defines the duration for which the server should only deliver content through HTTPS.
  191. .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.
  192. v-divider.mt-3
  193. v-switch(
  194. inset
  195. label='Enforce CSP'
  196. color='red darken-2'
  197. v-model='config.securityCSP'
  198. persistent-hint
  199. hint='Restricts scripts to pre-approved content sources.'
  200. disabled
  201. )
  202. v-textarea.mt-5(
  203. label='CSP Directives'
  204. outlined
  205. v-model='config.securityCSPDirectives'
  206. prepend-icon='mdi-subdirectory-arrow-right'
  207. persistent-hint
  208. hint='One directive per line.'
  209. disabled
  210. )
  211. </template>
  212. <script>
  213. import _ from 'lodash'
  214. import { get, sync } from 'vuex-pathify'
  215. import siteConfigQuery from 'gql/admin/site/site-query-config.gql'
  216. import siteUpdateConfigMutation from 'gql/admin/site/site-mutation-save-config.gql'
  217. export default {
  218. data() {
  219. return {
  220. analyticsServices: [
  221. { text: 'None', value: '' },
  222. { text: 'Elasticsearch APM RUM', value: 'elk' },
  223. { text: 'Google Analytics', value: 'ga' },
  224. { text: 'Google Tag Manager', value: 'gtm' }
  225. ],
  226. config: {
  227. host: '',
  228. title: '',
  229. description: '',
  230. robots: [],
  231. analyticsService: '',
  232. analyticsId: '',
  233. company: '',
  234. hasLogo: false,
  235. logoIsSquare: false,
  236. featureAnalytics: false,
  237. featurePageRatings: false,
  238. featurePageComments: false,
  239. featurePersonalWikis: false,
  240. featureTinyPNG: false,
  241. securityIframe: true,
  242. securityReferrerPolicy: true,
  243. securityHSTS: false,
  244. securityHSTSDuration: 0,
  245. securityCSP: false,
  246. securityCSPDirectives: ''
  247. },
  248. hstsDurations: [
  249. { value: 300, text: '5 minutes' },
  250. { value: 86400, text: '1 day' },
  251. { value: 604800, text: '1 week' },
  252. { value: 2592000, text: '1 month' },
  253. { value: 31536000, text: '1 year' },
  254. { value: 63072000, text: '2 years' }
  255. ],
  256. metaRobots: [
  257. { text: 'Index', value: 'index' },
  258. { text: 'Follow', value: 'follow' },
  259. { text: 'No Index', value: 'noindex' },
  260. { text: 'No Follow', value: 'nofollow' }
  261. ]
  262. }
  263. },
  264. computed: {
  265. darkMode: get('site/dark'),
  266. siteTitle: sync('site/title'),
  267. company: sync('site/company')
  268. },
  269. methods: {
  270. async save () {
  271. try {
  272. await this.$apollo.mutate({
  273. mutation: siteUpdateConfigMutation,
  274. variables: {
  275. host: _.get(this.config, 'host', ''),
  276. title: _.get(this.config, 'title', ''),
  277. description: _.get(this.config, 'description', ''),
  278. robots: _.get(this.config, 'robots', []),
  279. analyticsService: _.get(this.config, 'analyticsService', ''),
  280. analyticsId: _.get(this.config, 'analyticsId', ''),
  281. company: _.get(this.config, 'company', ''),
  282. hasLogo: _.get(this.config, 'hasLogo', false),
  283. logoIsSquare: _.get(this.config, 'logoIsSquare', false),
  284. featurePageRatings: _.get(this.config, 'featurePageRatings', false),
  285. featurePageComments: _.get(this.config, 'featurePageComments', false),
  286. featurePersonalWikis: _.get(this.config, 'featurePersonalWikis', false),
  287. securityIframe: _.get(this.config, 'securityIframe', false),
  288. securityReferrerPolicy: _.get(this.config, 'securityReferrerPolicy', false),
  289. securityHSTS: _.get(this.config, 'securityHSTS', false),
  290. securityHSTSDuration: _.get(this.config, 'securityHSTSDuration', 0),
  291. securityCSP: _.get(this.config, 'securityCSP', false),
  292. securityCSPDirectives: _.get(this.config, 'securityCSPDirectives', '')
  293. },
  294. watchLoading (isLoading) {
  295. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-update')
  296. }
  297. })
  298. this.$store.commit('showNotification', {
  299. style: 'success',
  300. message: 'Configuration saved successfully.',
  301. icon: 'check'
  302. })
  303. this.siteTitle = this.config.title
  304. this.company = this.config.company
  305. } catch (err) {
  306. this.$store.commit('pushGraphError', err)
  307. }
  308. }
  309. },
  310. apollo: {
  311. config: {
  312. query: siteConfigQuery,
  313. fetchPolicy: 'network-only',
  314. update: (data) => _.cloneDeep(data.site.config),
  315. watchLoading (isLoading) {
  316. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-refresh')
  317. }
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang='scss'>
  323. </style>