2018-03-03 06:32:58 +00:00
< template lang = 'pug' >
2018-09-30 03:30:20 +00:00
v - container ( fluid , grid - list - lg )
2018-03-03 06:32:58 +00:00
v - layout ( row wrap )
v - flex ( xs12 )
2018-09-30 03:30:20 +00:00
. admin - header
2019-03-17 17:39:58 +00:00
img . animated . fadeInUp ( src = '/svg/icon-paint-palette.svg' , alt = 'Theme' , style = 'width: 80px;' )
2018-09-30 03:30:20 +00:00
. admin - header - title
2019-03-17 17:39:58 +00:00
. headline . primary -- text . animated . fadeInLeft Theme
. subheading . grey -- text . animated . fadeInLeft . wait - p2s Modify the look & amp ; feel of your wiki
2018-09-30 03:30:20 +00:00
v - spacer
2019-03-17 17:39:58 +00:00
v - btn . animated . fadeInRight ( color = 'success' , depressed , @ click = 'save' , large , : loading = 'loading' )
2018-09-30 03:30:20 +00:00
v - icon ( left ) check
span { { $t ( 'common:actions.apply' ) } }
2018-03-03 06:32:58 +00:00
v - form . pt - 3
v - layout ( row wrap )
v - flex ( lg6 xs12 )
2019-03-17 17:39:58 +00:00
v - card . wiki - form . animated . fadeInUp
2018-05-12 20:13:04 +00:00
v - toolbar ( color = 'primary' , dark , dense , flat )
2018-03-03 06:32:58 +00:00
v - toolbar - title
. subheading Theme
v - card - text
2018-06-11 03:23:09 +00:00
v - select (
: items = 'themes'
2018-09-30 03:30:20 +00:00
outline
background - color = 'grey lighten-2'
2018-06-11 03:23:09 +00:00
prepend - icon = 'palette'
2019-01-26 02:29:34 +00:00
v - model = 'config.theme'
2018-06-11 03:23:09 +00:00
label = 'Site Theme'
persistent - hint
hint = 'Themes affect how content pages are displayed. Other site sections (such as the editor or admin area) are not affected.'
)
2018-03-03 06:32:58 +00:00
template ( slot = 'item' , slot - scope = 'data' )
v - list - tile - avatar
v - icon . blue -- text ( dark ) filter _frames
v - list - tile - content
v - list - tile - title ( v - html = 'data.item.text' )
v - list - tile - sub - title ( v - html = 'data.item.author' )
2018-07-08 05:12:43 +00:00
v - divider . mt - 3
2018-06-11 03:23:09 +00:00
v - switch (
v - model = 'darkMode'
label = 'Dark Mode'
color = 'primary'
persistent - hint
hint = 'Not recommended for accessibility. May not be supported by all themes.'
)
2019-03-17 17:39:58 +00:00
v - card . wiki - form . mt - 3. animated . fadeInUp . wait - p2s
2018-08-05 15:27:46 +00:00
v - toolbar ( color = 'primary' , dark , dense , flat )
v - toolbar - title
. subheading Code Injection
v - card - text
v - textarea (
2019-01-26 02:29:34 +00:00
v - model = 'config.injectCSS'
2018-08-05 15:27:46 +00:00
label = 'CSS Override'
outline
background - color = 'grey lighten-1'
color = 'primary'
persistent - hint
2019-01-26 02:29:34 +00:00
hint = 'CSS code to inject after system default CSS. Consider using custom themes if you have a large amount of css code. Injecting too much CSS code will result in poor page load performance! CSS will automatically be minified.'
2018-08-05 15:27:46 +00:00
auto - grow
)
v - textarea . mt - 2 (
2019-01-26 02:29:34 +00:00
v - model = 'config.injectHead'
2018-09-30 03:30:20 +00:00
label = 'Head HTML Injection'
2018-08-05 15:27:46 +00:00
outline
background - color = 'grey lighten-1'
color = 'primary'
persistent - hint
2019-01-26 02:29:34 +00:00
hint = 'HTML code to be injected just before the closing head tag. Usually for script tags.'
2018-08-05 15:27:46 +00:00
auto - grow
)
v - textarea . mt - 2 (
2019-01-26 02:29:34 +00:00
v - model = 'config.injectBody'
2018-09-30 03:30:20 +00:00
label = 'Body HTML Injection'
2018-08-05 15:27:46 +00:00
outline
background - color = 'grey lighten-1'
color = 'primary'
persistent - hint
2019-01-26 02:29:34 +00:00
hint = 'HTML code to be injected just before the closing body tag.'
2018-08-05 15:27:46 +00:00
auto - grow
)
2018-03-03 06:32:58 +00:00
v - flex ( lg6 xs12 )
2019-03-17 17:39:58 +00:00
v - card . animated . fadeInUp . wait - p2s
2018-04-29 21:55:36 +00:00
v - toolbar ( color = 'teal' , dark , dense , flat )
2018-03-03 06:32:58 +00:00
v - toolbar - title
2018-04-29 21:55:36 +00:00
. subheading Download Themes
2019-01-01 06:40:31 +00:00
v - spacer
v - chip ( label , color = 'white' , small ) . teal -- text coming soon
2018-04-29 21:55:36 +00:00
v - card - text . caption -- Coming soon --
2018-03-03 06:32:58 +00:00
< / template >
< script >
2018-06-11 03:23:09 +00:00
import _ from 'lodash'
2018-07-15 23:16:19 +00:00
import { sync } from 'vuex-pathify'
2018-06-11 03:23:09 +00:00
2019-01-26 02:29:34 +00:00
import themeConfigQuery from 'gql/admin/theme/theme-query-config.gql'
2018-06-25 06:44:40 +00:00
import themeSaveMutation from 'gql/admin/theme/theme-mutation-save.gql'
2018-06-11 03:23:09 +00:00
2018-03-03 06:32:58 +00:00
export default {
data ( ) {
return {
2018-06-11 03:23:09 +00:00
loading : false ,
2018-03-03 06:32:58 +00:00
themes : [
{ text : 'Default' , author : 'requarks.io' , value : 'default' }
] ,
2019-01-26 02:29:34 +00:00
config : {
theme : 'default' ,
darkMode : false ,
injectCSS : '' ,
injectHead : '' ,
injectBody : ''
} ,
darkModeInitial : false
2018-03-03 06:32:58 +00:00
}
2018-06-10 00:11:00 +00:00
} ,
2018-07-15 23:16:19 +00:00
computed : {
2018-08-11 22:16:56 +00:00
darkMode : sync ( 'site/dark' )
2018-06-11 03:23:09 +00:00
} ,
mounted ( ) {
this . darkModeInitial = this . darkMode
} ,
beforeDestroy ( ) {
2018-07-15 23:16:19 +00:00
this . darkMode = this . darkModeInitial
2018-06-11 03:23:09 +00:00
} ,
methods : {
async save ( ) {
this . loading = true
this . $store . commit ( ` loadingStart ` , 'admin-theme-save' )
try {
const respRaw = await this . $apollo . mutate ( {
mutation : themeSaveMutation ,
variables : {
2019-01-26 02:29:34 +00:00
theme : this . config . theme ,
darkMode : this . darkMode ,
injectCSS : this . config . injectCSS ,
injectHead : this . config . injectHead ,
injectBody : this . config . injectBody
2018-06-11 03:23:09 +00:00
}
} )
const resp = _ . get ( respRaw , 'data.theming.setConfig.responseResult' , { } )
if ( resp . succeeded ) {
this . darkModeInitial = this . darkMode
this . $store . commit ( 'showNotification' , {
message : 'Theme settings updated successfully.' ,
style : 'success' ,
icon : 'check'
} )
} else {
throw new Error ( resp . message )
}
} catch ( err ) {
2019-01-13 03:33:30 +00:00
this . $store . commit ( 'pushGraphError' , err )
2018-06-11 03:23:09 +00:00
}
this . $store . commit ( ` loadingStop ` , 'admin-theme-save' )
this . loading = false
2018-06-10 00:11:00 +00:00
}
2019-01-26 02:29:34 +00:00
} ,
apollo : {
config : {
query : themeConfigQuery ,
fetchPolicy : 'network-only' ,
update : ( data ) => data . theming . config ,
watchLoading ( isLoading ) {
this . $store . commit ( ` loading ${ isLoading ? 'Start' : 'Stop' } ` , 'admin-theme-refresh' )
}
}
2018-03-03 06:32:58 +00:00
}
}
< / script >
< style lang = 'scss' >
< / style >