wikijs-fork/client/components/admin/admin-general.vue

396 lines
15 KiB
Vue
Raw Normal View History

2018-02-28 05:54:09 +00:00
<template lang='pug'>
v-container(fluid, grid-list-lg)
2018-02-28 05:54:09 +00:00
v-layout(row wrap)
v-flex(xs12)
.admin-header
2019-04-07 16:37:33 +00:00
img.animated.fadeInUp(src='/svg/icon-categorize.svg', alt='General', style='width: 80px;')
.admin-header-title
2019-04-07 16:37:33 +00:00
.headline.primary--text.animated.fadeInLeft {{ $t('admin:general.title') }}
2019-08-03 04:48:55 +00:00
.subtitle-1.grey--text.animated.fadeInLeft {{ $t('admin:general.subtitle') }}
v-spacer
2019-04-07 16:37:33 +00:00
v-btn.animated.fadeInDown(color='success', depressed, @click='save', large)
2019-07-29 04:50:03 +00:00
v-icon(left) mdi-check
span {{$t('common:actions.apply')}}
2018-02-28 05:54:09 +00:00
v-form.pt-3
v-layout(row wrap)
v-flex(lg6 xs12)
v-form
2019-07-29 04:50:03 +00:00
v-card.animated.fadeInUp
v-toolbar(color='primary', dark, dense, flat)
2019-07-29 04:50:03 +00:00
v-toolbar-title.subtitle-1 {{ $t('admin:general.siteInfo') }}
2019-08-03 04:48:55 +00:00
.overline.grey--text.pa-4 {{$t('admin:general.general')}}
.px-3.pb-3
v-text-field(
2019-07-29 04:50:03 +00:00
outlined
2019-06-10 03:39:37 +00:00
:label='$t(`admin:general.siteUrl`)'
2018-12-24 06:03:10 +00:00
required
:counter='255'
v-model='config.host'
2019-07-29 04:50:03 +00:00
prepend-icon='mdi-label-variant-outline'
2019-06-10 03:39:37 +00:00
:hint='$t(`admin:general.siteUrlHint`)'
2018-12-24 06:03:10 +00:00
persistent-hint
)
2019-07-29 04:50:03 +00:00
v-text-field.mt-3(
outlined
2019-06-10 03:39:37 +00:00
:label='$t(`admin:general.siteTitle`)'
required
:counter='50'
2018-12-24 06:03:10 +00:00
v-model='config.title'
2019-07-29 04:50:03 +00:00
prepend-icon='mdi-earth'
2019-06-10 03:39:37 +00:00
:hint='$t(`admin:general.siteTitleHint`)'
2019-01-07 03:03:34 +00:00
persistent-hint
)
v-divider
.overline.grey--text.pa-4 {{$t('admin:general.logo')}}
.pt-2.pb-7.pl-10.pr-3
.d-flex.align-center
v-avatar(size='100', tile)
v-img(
:src='config.logoUrl'
lazy-src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNcWQ8AAdcBKrJda2oAAAAASUVORK5CYII='
aspect-ratio='1'
)
.ml-4(style='flex: 1 1 auto;')
v-text-field(
outlined
:label='$t(`admin:general.logoUrl`)'
v-model='config.logoUrl'
:hint='$t(`admin:general.logoUrlHint`)'
persistent-hint
append-icon='mdi-folder-image'
@click:append='browseLogo'
@keyup.enter='refreshLogo'
)
2019-05-26 01:38:29 +00:00
v-divider
2019-08-03 04:48:55 +00:00
.overline.grey--text.pa-4 {{$t('admin:general.footerCopyright')}}
2019-05-26 01:38:29 +00:00
.px-3.pb-3
v-text-field(
2019-07-29 04:50:03 +00:00
outlined
2019-06-10 03:39:37 +00:00
:label='$t(`admin:general.companyName`)'
2019-05-26 01:38:29 +00:00
v-model='config.company'
:counter='255'
2019-07-29 04:50:03 +00:00
prepend-icon='mdi-domain'
2019-05-26 01:38:29 +00:00
persistent-hint
2019-06-10 03:39:37 +00:00
:hint='$t(`admin:general.companyNameHint`)'
2019-05-26 01:38:29 +00:00
)
v-divider
2019-08-03 04:48:55 +00:00
.overline.grey--text.pa-4 SEO
.px-3.pb-3
v-text-field(
2019-07-29 04:50:03 +00:00
outlined
2019-06-10 03:39:37 +00:00
:label='$t(`admin:general.siteDescription`)'
:counter='255'
2018-12-24 06:03:10 +00:00
v-model='config.description'
2019-07-29 04:50:03 +00:00
prepend-icon='mdi-compass'
2019-06-10 03:39:37 +00:00
:hint='$t(`admin:general.siteDescriptionHint`)'
2019-01-07 03:03:34 +00:00
persistent-hint
)
2019-07-29 04:50:03 +00:00
v-select.mt-3(
outlined
2019-06-10 03:39:37 +00:00
:label='$t(`admin:general.metaRobots`)'
2018-12-24 06:03:10 +00:00
multiple
:items='metaRobots'
2018-12-24 06:03:10 +00:00
v-model='config.robots'
2019-07-29 04:50:03 +00:00
prepend-icon='mdi-compass'
2018-12-24 06:03:10 +00:00
:return-object='false'
2019-06-10 03:39:37 +00:00
:hint='$t(`admin:general.metaRobotsHint`)'
2018-12-24 06:03:10 +00:00
persistent-hint
)
2019-05-26 01:38:29 +00:00
2018-02-28 05:54:09 +00:00
v-flex(lg6 xs12)
2019-07-29 04:50:03 +00:00
v-card.animated.fadeInUp.wait-p4s
v-toolbar(color='indigo', dark, dense, flat)
2019-07-29 04:50:03 +00:00
v-toolbar-title.subtitle-1 Features
2019-05-26 01:38:29 +00:00
v-spacer
v-chip(label, color='white', small).indigo--text coming soon
v-card-text
2019-05-26 01:38:29 +00:00
v-switch(
inset
2019-05-26 01:38:29 +00:00
label='Asset Image Optimization'
color='indigo'
2019-05-26 01:38:29 +00:00
v-model='config.featureTinyPNG'
persistent-hint
hint='Image optimization tool to reduce filesize and bandwidth costs.'
disabled
)
v-text-field.mt-3(
2019-07-29 04:50:03 +00:00
outlined
2019-05-26 01:38:29 +00:00
label='TinyPNG API Key'
:counter='255'
v-model='config.description'
2019-07-29 04:50:03 +00:00
prepend-icon='mdi-subdirectory-arrow-right'
2019-05-26 01:38:29 +00:00
hint='Get your API key at https://tinypng.com/developers'
persistent-hint
disabled
)
v-divider.mt-3
2018-09-04 04:46:24 +00:00
v-switch(
inset
2018-09-04 04:46:24 +00:00
label='Page Ratings'
color='indigo'
2018-12-24 06:03:10 +00:00
v-model='config.featurePageRatings'
2018-09-04 04:46:24 +00:00
persistent-hint
hint='Allow users to rate pages.'
2019-06-10 03:39:37 +00:00
disabled
2018-09-04 04:46:24 +00:00
)
2019-05-26 01:38:29 +00:00
2018-09-04 04:46:24 +00:00
v-divider.mt-3
v-switch(
inset
2018-12-24 06:03:10 +00:00
label='Page Comments'
color='indigo'
2018-12-24 06:03:10 +00:00
v-model='config.featurePageComments'
persistent-hint
hint='Allow users to leave comments on pages.'
2019-06-10 03:39:37 +00:00
disabled
2018-12-24 06:03:10 +00:00
)
2019-05-26 01:38:29 +00:00
2018-12-24 06:03:10 +00:00
v-divider.mt-3
v-switch(
inset
2018-09-04 04:46:24 +00:00
label='Personal Wikis'
color='indigo'
2018-12-24 06:03:10 +00:00
v-model='config.featurePersonalWikis'
2018-09-04 04:46:24 +00:00
persistent-hint
hint='Allow users to have their own personal wiki.'
2019-06-10 03:39:37 +00:00
disabled
2018-09-04 04:46:24 +00:00
)
2018-02-28 05:54:09 +00:00
v-card.mt-5.animated.fadeInUp.wait-p5s
v-toolbar(color='red darken-2', dark, dense, flat)
v-toolbar-title.subtitle-1 Security
v-card-text
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.
v-switch.mt-3(
inset
label='Block IFrame Embedding'
color='red darken-2'
v-model='config.securityIframe'
persistent-hint
hint='Prevents other websites from embedding your wiki in an iframe. This provides clickjacking protection.'
)
v-divider.mt-3
v-switch(
inset
label='Same Origin Referrer Policy'
color='red darken-2'
v-model='config.securityReferrerPolicy'
persistent-hint
hint='Limits the referrer header to same origin.'
)
v-divider.mt-3
v-switch(
inset
label='Trust X-Forwarded-* Proxy Headers'
color='red darken-2'
v-model='config.securityTrustProxy'
persistent-hint
hint='Should be enabled when using a reverse-proxy like nginx, apache, CloudFlare, etc in front of Wiki.js. Turn off otherwise.'
)
2019-10-12 18:41:45 +00:00
v-divider.mt-3
v-switch(
inset
2019-10-14 17:07:49 +00:00
label='Subresource Integrity (SRI)'
2019-10-12 18:41:45 +00:00
color='red darken-2'
v-model='config.securitySRI'
persistent-hint
hint='This ensure that resources such as CSS and JS files are not altered during delivery.'
2020-02-01 21:14:25 +00:00
disabled
2019-10-12 18:41:45 +00:00
)
v-divider.mt-3
v-switch(
inset
label='Enforce HSTS'
color='red darken-2'
v-model='config.securityHSTS'
persistent-hint
hint='This ensures the connection cannot be established through an insecure HTTP connection.'
)
v-select.mt-5(
outlined
label='HSTS Max Age'
:items='hstsDurations'
v-model='config.securityHSTSDuration'
prepend-icon='mdi-subdirectory-arrow-right'
:disabled='!config.securityHSTS'
hide-details
style='max-width: 450px;'
)
.pl-11.mt-3
.caption Defines the duration for which the server should only deliver content through HTTPS.
.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.
v-divider.mt-3
v-switch(
inset
label='Enforce CSP'
color='red darken-2'
v-model='config.securityCSP'
persistent-hint
hint='Restricts scripts to pre-approved content sources.'
disabled
)
v-textarea.mt-5(
label='CSP Directives'
outlined
v-model='config.securityCSPDirectives'
prepend-icon='mdi-subdirectory-arrow-right'
persistent-hint
hint='One directive per line.'
disabled
)
component(:is='activeModal')
2018-02-28 05:54:09 +00:00
</template>
<script>
2018-12-24 06:03:10 +00:00
import _ from 'lodash'
2018-12-03 02:42:43 +00:00
import { get, sync } from 'vuex-pathify'
2018-12-24 06:03:10 +00:00
import siteConfigQuery from 'gql/admin/site/site-query-config.gql'
import siteUpdateConfigMutation from 'gql/admin/site/site-mutation-save-config.gql'
2018-08-04 21:27:55 +00:00
import editorStore from '../../store/editor'
/* global WIKI */
WIKI.$store.registerModule('editor', editorStore)
2018-02-28 05:54:09 +00:00
export default {
i18nOptions: { namespaces: 'editor' },
components: {
editorModalMedia: () => import(/* webpackChunkName: "editor", webpackMode: "lazy" */ '../editor/editor-modal-media.vue')
},
2018-02-28 05:54:09 +00:00
data() {
return {
analyticsServices: [
{ text: 'None', value: '' },
{ text: 'Elasticsearch APM RUM', value: 'elk' },
{ text: 'Google Analytics', value: 'ga' },
2019-04-07 16:37:33 +00:00
{ text: 'Google Tag Manager', value: 'gtm' }
],
2018-12-24 06:03:10 +00:00
config: {
host: '',
title: '',
description: '',
robots: [],
analyticsService: '',
analyticsId: '',
2018-12-24 06:03:10 +00:00
company: '',
logoUrl: '',
2019-05-26 01:38:29 +00:00
featureAnalytics: false,
2018-12-24 06:03:10 +00:00
featurePageRatings: false,
featurePageComments: false,
2019-05-26 01:38:29 +00:00
featurePersonalWikis: false,
featureTinyPNG: false,
securityIframe: true,
securityReferrerPolicy: true,
securityTrustProxy: true,
2019-10-12 18:41:45 +00:00
securitySRI: true,
securityHSTS: false,
securityHSTSDuration: 0,
securityCSP: false,
securityCSPDirectives: ''
},
hstsDurations: [
{ value: 300, text: '5 minutes' },
{ value: 86400, text: '1 day' },
{ value: 604800, text: '1 week' },
{ value: 2592000, text: '1 month' },
{ value: 31536000, text: '1 year' },
{ value: 63072000, text: '2 years' }
],
metaRobots: [
{ text: 'Index', value: 'index' },
{ text: 'Follow', value: 'follow' },
{ text: 'No Index', value: 'noindex' },
{ text: 'No Follow', value: 'nofollow' }
]
}
2018-08-04 21:27:55 +00:00
},
computed: {
2018-12-03 02:42:43 +00:00
darkMode: get('site/dark'),
2018-08-04 21:27:55 +00:00
siteTitle: sync('site/title'),
logoUrl: sync('site/logoUrl'),
company: sync('site/company'),
activeModal: sync('editor/activeModal')
2018-09-04 04:46:24 +00:00
},
methods: {
async save () {
2018-12-24 06:03:10 +00:00
try {
await this.$apollo.mutate({
mutation: siteUpdateConfigMutation,
variables: {
host: _.get(this.config, 'host', ''),
title: _.get(this.config, 'title', ''),
description: _.get(this.config, 'description', ''),
robots: _.get(this.config, 'robots', []),
analyticsService: _.get(this.config, 'analyticsService', ''),
analyticsId: _.get(this.config, 'analyticsId', ''),
company: _.get(this.config, 'company', ''),
logoUrl: _.get(this.config, 'logoUrl', ''),
featurePageRatings: _.get(this.config, 'featurePageRatings', false),
featurePageComments: _.get(this.config, 'featurePageComments', false),
featurePersonalWikis: _.get(this.config, 'featurePersonalWikis', false),
securityIframe: _.get(this.config, 'securityIframe', false),
securityReferrerPolicy: _.get(this.config, 'securityReferrerPolicy', false),
securityTrustProxy: _.get(this.config, 'securityTrustProxy', false),
2019-10-12 18:41:45 +00:00
securitySRI: _.get(this.config, 'securitySRI', false),
securityHSTS: _.get(this.config, 'securityHSTS', false),
securityHSTSDuration: _.get(this.config, 'securityHSTSDuration', 0),
securityCSP: _.get(this.config, 'securityCSP', false),
securityCSPDirectives: _.get(this.config, 'securityCSPDirectives', '')
2018-12-24 06:03:10 +00:00
},
watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-update')
}
})
this.$store.commit('showNotification', {
style: 'success',
message: 'Configuration saved successfully.',
icon: 'check'
})
this.siteTitle = this.config.title
this.company = this.config.company
this.logoUrl = this.config.logoUrl
2018-12-24 06:03:10 +00:00
} catch (err) {
2019-01-13 03:33:30 +00:00
this.$store.commit('pushGraphError', err)
2018-12-24 06:03:10 +00:00
}
},
browseLogo () {
this.$store.set('editor/editorKey', 'common')
this.activeModal = 'editorModalMedia'
},
refreshLogo () {
this.$forceUpdate()
2018-12-24 06:03:10 +00:00
}
},
mounted () {
this.$root.$on('editorInsert', opts => {
this.config.logoUrl = opts.path
})
},
beforeDestroy() {
this.$root.$off('editorInsert')
},
2018-12-24 06:03:10 +00:00
apollo: {
config: {
query: siteConfigQuery,
fetchPolicy: 'network-only',
update: (data) => _.cloneDeep(data.site.config),
watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-refresh')
}
2018-09-04 04:46:24 +00:00
}
2018-02-28 05:54:09 +00:00
}
}
</script>
<style lang='scss'>
</style>