You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

364 lines
13 KiB

  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='/_assets/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')}}
  45. .pt-2.pb-7.pl-10.pr-3
  46. .d-flex.align-center
  47. v-avatar(size='100', tile)
  48. v-img(
  49. :src='config.logoUrl'
  50. lazy-src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNcWQ8AAdcBKrJda2oAAAAASUVORK5CYII='
  51. aspect-ratio='1'
  52. )
  53. .ml-4(style='flex: 1 1 auto;')
  54. v-text-field(
  55. outlined
  56. :label='$t(`admin:general.logoUrl`)'
  57. v-model='config.logoUrl'
  58. :hint='$t(`admin:general.logoUrlHint`)'
  59. persistent-hint
  60. append-icon='mdi-folder-image'
  61. @click:append='browseLogo'
  62. @keyup.enter='refreshLogo'
  63. )
  64. v-divider
  65. .overline.grey--text.pa-4 {{$t('admin:general.footerCopyright')}}
  66. .px-3.pb-3
  67. v-text-field(
  68. outlined
  69. :label='$t(`admin:general.companyName`)'
  70. v-model='config.company'
  71. :counter='255'
  72. prepend-icon='mdi-domain'
  73. persistent-hint
  74. :hint='$t(`admin:general.companyNameHint`)'
  75. )
  76. v-select.mt-3(
  77. outlined
  78. :label='$t(`admin:general.contentLicense`)'
  79. :items='contentLicenses'
  80. v-model='config.contentLicense'
  81. prepend-icon='mdi-creative-commons'
  82. :return-object='false'
  83. :hint='$t(`admin:general.contentLicenseHint`)'
  84. persistent-hint
  85. )
  86. v-divider
  87. .overline.grey--text.pa-4 SEO
  88. .px-3.pb-3
  89. v-text-field(
  90. outlined
  91. :label='$t(`admin:general.siteDescription`)'
  92. :counter='255'
  93. v-model='config.description'
  94. prepend-icon='mdi-compass'
  95. :hint='$t(`admin:general.siteDescriptionHint`)'
  96. persistent-hint
  97. )
  98. v-select.mt-3(
  99. outlined
  100. :label='$t(`admin:general.metaRobots`)'
  101. multiple
  102. :items='metaRobots'
  103. v-model='config.robots'
  104. prepend-icon='mdi-compass'
  105. :return-object='false'
  106. :hint='$t(`admin:general.metaRobotsHint`)'
  107. persistent-hint
  108. )
  109. v-flex(lg6 xs12)
  110. v-card.animated.fadeInUp.wait-p4s
  111. v-toolbar(color='indigo', dark, dense, flat)
  112. v-toolbar-title.subtitle-1 Features
  113. v-card-text
  114. //- v-switch(
  115. //- inset
  116. //- label='Asset Image Optimization'
  117. //- color='indigo'
  118. //- v-model='config.featureTinyPNG'
  119. //- persistent-hint
  120. //- hint='Image optimization tool to reduce filesize and bandwidth costs.'
  121. //- disabled
  122. //- )
  123. //- v-text-field.mt-3(
  124. //- outlined
  125. //- label='TinyPNG API Key'
  126. //- :counter='255'
  127. //- v-model='config.description'
  128. //- prepend-icon='mdi-subdirectory-arrow-right'
  129. //- hint='Get your API key at https://tinypng.com/developers'
  130. //- persistent-hint
  131. //- disabled
  132. //- )
  133. //- v-divider.mt-3
  134. //- v-switch(
  135. //- inset
  136. //- label='Page Ratings'
  137. //- color='indigo'
  138. //- v-model='config.featurePageRatings'
  139. //- persistent-hint
  140. //- hint='Allow users to rate pages.'
  141. //- disabled
  142. //- )
  143. //- v-divider.mt-3
  144. v-switch(
  145. inset
  146. label='Comments'
  147. color='indigo'
  148. v-model='config.featurePageComments'
  149. persistent-hint
  150. hint='Allow users to leave comments on pages.'
  151. )
  152. //- v-divider.mt-3
  153. //- v-switch(
  154. //- inset
  155. //- label='Personal Wikis'
  156. //- color='indigo'
  157. //- v-model='config.featurePersonalWikis'
  158. //- persistent-hint
  159. //- hint='Allow users to have their own personal wiki.'
  160. //- disabled
  161. //- )
  162. component(:is='activeModal')
  163. </template>
  164. <script>
  165. import _ from 'lodash'
  166. import { sync } from 'vuex-pathify'
  167. import gql from 'graphql-tag'
  168. import editorStore from '../../store/editor'
  169. /* global WIKI */
  170. WIKI.$store.registerModule('editor', editorStore)
  171. export default {
  172. i18nOptions: { namespaces: 'editor' },
  173. components: {
  174. editorModalMedia: () => import(/* webpackChunkName: "editor", webpackMode: "lazy" */ '../editor/editor-modal-media.vue')
  175. },
  176. data() {
  177. return {
  178. analyticsServices: [
  179. { text: 'None', value: '' },
  180. { text: 'Elasticsearch APM RUM', value: 'elk' },
  181. { text: 'Google Analytics', value: 'ga' },
  182. { text: 'Google Tag Manager', value: 'gtm' }
  183. ],
  184. config: {
  185. host: '',
  186. title: '',
  187. description: '',
  188. robots: [],
  189. analyticsService: '',
  190. analyticsId: '',
  191. company: '',
  192. contentLicense: '',
  193. logoUrl: '',
  194. featureAnalytics: false,
  195. featurePageRatings: false,
  196. featurePageComments: false,
  197. featurePersonalWikis: false,
  198. featureTinyPNG: false
  199. },
  200. metaRobots: [
  201. { text: 'Index', value: 'index' },
  202. { text: 'Follow', value: 'follow' },
  203. { text: 'No Index', value: 'noindex' },
  204. { text: 'No Follow', value: 'nofollow' }
  205. ]
  206. }
  207. },
  208. computed: {
  209. siteTitle: sync('site/title'),
  210. logoUrl: sync('site/logoUrl'),
  211. company: sync('site/company'),
  212. contentLicense: sync('site/contentLicense'),
  213. activeModal: sync('editor/activeModal'),
  214. contentLicenses () {
  215. return [
  216. { value: '', text: this.$t('common:license.none') },
  217. { value: 'alr', text: this.$t('common:license.alr') },
  218. { value: 'cc0', text: this.$t('common:license.cc0') },
  219. { value: 'ccby', text: this.$t('common:license.ccby') },
  220. { value: 'ccbysa', text: this.$t('common:license.ccbysa') },
  221. { value: 'ccbynd', text: this.$t('common:license.ccbynd') },
  222. { value: 'ccbync', text: this.$t('common:license.ccbync') },
  223. { value: 'ccbyncsa', text: this.$t('common:license.ccbyncsa') },
  224. { value: 'ccbyncnd', text: this.$t('common:license.ccbyncnd') }
  225. ]
  226. }
  227. },
  228. methods: {
  229. async save () {
  230. try {
  231. await this.$apollo.mutate({
  232. mutation: gql`
  233. mutation (
  234. $host: String!
  235. $title: String!
  236. $description: String!
  237. $robots: [String]!
  238. $analyticsService: String!
  239. $analyticsId: String!
  240. $company: String!
  241. $contentLicense: String!
  242. $logoUrl: String!
  243. $featurePageRatings: Boolean!
  244. $featurePageComments: Boolean!
  245. $featurePersonalWikis: Boolean!
  246. ) {
  247. site {
  248. updateConfig(
  249. host: $host,
  250. title: $title,
  251. description: $description,
  252. robots: $robots,
  253. analyticsService: $analyticsService,
  254. analyticsId: $analyticsId,
  255. company: $company,
  256. contentLicense: $contentLicense,
  257. logoUrl: $logoUrl,
  258. featurePageRatings: $featurePageRatings,
  259. featurePageComments: $featurePageComments,
  260. featurePersonalWikis: $featurePersonalWikis
  261. ) {
  262. responseResult {
  263. succeeded
  264. errorCode
  265. slug
  266. message
  267. }
  268. }
  269. }
  270. }
  271. `,
  272. variables: {
  273. host: _.get(this.config, 'host', ''),
  274. title: _.get(this.config, 'title', ''),
  275. description: _.get(this.config, 'description', ''),
  276. robots: _.get(this.config, 'robots', []),
  277. analyticsService: _.get(this.config, 'analyticsService', ''),
  278. analyticsId: _.get(this.config, 'analyticsId', ''),
  279. company: _.get(this.config, 'company', ''),
  280. contentLicense: _.get(this.config, 'contentLicense', ''),
  281. logoUrl: _.get(this.config, 'logoUrl', ''),
  282. featurePageRatings: _.get(this.config, 'featurePageRatings', false),
  283. featurePageComments: _.get(this.config, 'featurePageComments', false),
  284. featurePersonalWikis: _.get(this.config, 'featurePersonalWikis', false)
  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. this.contentLicense = this.config.contentLicense
  298. this.logoUrl = this.config.logoUrl
  299. } catch (err) {
  300. this.$store.commit('pushGraphError', err)
  301. }
  302. },
  303. browseLogo () {
  304. this.$store.set('editor/editorKey', 'common')
  305. this.activeModal = 'editorModalMedia'
  306. },
  307. refreshLogo () {
  308. this.$forceUpdate()
  309. }
  310. },
  311. mounted () {
  312. this.$root.$on('editorInsert', opts => {
  313. this.config.logoUrl = opts.path
  314. })
  315. },
  316. beforeDestroy() {
  317. this.$root.$off('editorInsert')
  318. },
  319. apollo: {
  320. config: {
  321. query: gql`
  322. {
  323. site {
  324. config {
  325. host
  326. title
  327. description
  328. robots
  329. analyticsService
  330. analyticsId
  331. company
  332. contentLicense
  333. logoUrl
  334. featurePageRatings
  335. featurePageComments
  336. featurePersonalWikis
  337. }
  338. }
  339. }
  340. `,
  341. fetchPolicy: 'network-only',
  342. update: (data) => _.cloneDeep(data.site.config),
  343. watchLoading (isLoading) {
  344. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-refresh')
  345. }
  346. }
  347. }
  348. }
  349. </script>
  350. <style lang='scss'>
  351. </style>