2018-03-18 02:41:16 +00:00
|
|
|
<template lang='pug'>
|
2018-09-30 03:30:20 +00:00
|
|
|
v-container(fluid, grid-list-lg)
|
|
|
|
v-layout(row, wrap)
|
2018-03-18 02:41:16 +00:00
|
|
|
v-flex(xs12)
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header
|
2020-05-15 21:05:11 +00:00
|
|
|
img.animated.fadeInUp(src='/_assets/svg/icon-process.svg', alt='Rendering', style='width: 80px;')
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header-title
|
2019-04-07 16:37:33 +00:00
|
|
|
.headline.primary--text.animated.fadeInLeft Rendering
|
2018-09-30 03:30:20 +00:00
|
|
|
v-spacer
|
2019-08-05 03:53:21 +00:00
|
|
|
v-btn.mx-3.animated.fadeInDown.wait-p2s(outlined, color='grey', @click='refresh', large)
|
|
|
|
v-icon mdi-refresh
|
2019-04-07 16:37:33 +00:00
|
|
|
v-btn.animated.fadeInDown(color='success', @click='save', depressed, large)
|
2019-08-05 03:53:21 +00:00
|
|
|
v-icon(left) mdi-check
|
2019-01-01 06:40:31 +00:00
|
|
|
span {{$t('common:actions.apply')}}
|
2018-09-30 03:30:20 +00:00
|
|
|
|
2019-04-07 16:37:33 +00:00
|
|
|
v-flex.animated.fadeInUp(lg3, xs12)
|
2018-09-30 03:30:20 +00:00
|
|
|
v-toolbar(
|
|
|
|
color='primary'
|
|
|
|
dense
|
|
|
|
flat
|
|
|
|
dark
|
|
|
|
)
|
2019-08-03 04:48:55 +00:00
|
|
|
.subtitle-1 Pipeline
|
2019-08-05 03:53:21 +00:00
|
|
|
v-expansion-panels.adm-rendering-pipeline(
|
|
|
|
v-model='selectedCore'
|
|
|
|
accordion
|
|
|
|
mandatory
|
|
|
|
)
|
|
|
|
v-expansion-panel(
|
2018-09-30 03:30:20 +00:00
|
|
|
v-for='core in renderers'
|
|
|
|
:key='core.key'
|
|
|
|
)
|
2019-08-05 03:53:21 +00:00
|
|
|
v-expansion-panel-header(
|
|
|
|
hide-actions
|
|
|
|
ripple
|
|
|
|
)
|
|
|
|
v-toolbar(
|
|
|
|
color='blue'
|
|
|
|
dense
|
|
|
|
dark
|
|
|
|
flat
|
|
|
|
)
|
|
|
|
v-spacer
|
|
|
|
.body-2 {{core.input}}
|
|
|
|
v-icon.mx-2 mdi-arrow-right-bold-hexagon-outline
|
|
|
|
.caption {{core.output}}
|
|
|
|
v-spacer
|
|
|
|
v-expansion-panel-content
|
|
|
|
v-list.py-0(two-line, dense)
|
|
|
|
template(v-for='(rdr, n) in core.children')
|
|
|
|
v-list-item(
|
|
|
|
:key='rdr.key'
|
|
|
|
@click='selectRenderer(rdr.key)'
|
2020-05-08 22:48:07 +00:00
|
|
|
:class='currentRenderer.key === rdr.key ? ($vuetify.theme.dark ? `grey darken-4-l4` : `blue lighten-5`) : ``'
|
2019-08-05 03:53:21 +00:00
|
|
|
)
|
2020-04-26 18:06:17 +00:00
|
|
|
v-list-item-avatar(size='24', tile)
|
2019-08-05 03:53:21 +00:00
|
|
|
v-icon(:color='currentRenderer.key === rdr.key ? "primary" : "grey"') {{rdr.icon}}
|
|
|
|
v-list-item-content
|
|
|
|
v-list-item-title {{rdr.title}}
|
|
|
|
v-list-item-subtitle: .caption {{rdr.description}}
|
|
|
|
v-list-item-avatar(size='24')
|
|
|
|
status-indicator(v-if='rdr.isEnabled', positive, pulse)
|
|
|
|
status-indicator(v-else, negative, pulse)
|
|
|
|
v-divider.my-0(v-if='n < core.children.length - 1')
|
2018-07-07 22:09:58 +00:00
|
|
|
|
2018-09-30 03:30:20 +00:00
|
|
|
v-flex(lg9, xs12)
|
2019-04-07 16:37:33 +00:00
|
|
|
v-card.wiki-form.animated.fadeInUp
|
2018-09-30 03:30:20 +00:00
|
|
|
v-toolbar(
|
|
|
|
color='grey darken-1'
|
|
|
|
dark
|
|
|
|
flat
|
|
|
|
dense
|
|
|
|
)
|
|
|
|
v-icon.mr-2 {{currentRenderer.icon}}
|
2019-08-03 04:48:55 +00:00
|
|
|
.subtitle-1 {{currentRenderer.title}}
|
2018-09-30 03:30:20 +00:00
|
|
|
v-spacer
|
2019-08-05 03:53:21 +00:00
|
|
|
v-switch(
|
|
|
|
dark
|
|
|
|
color='white'
|
|
|
|
label='Enabled'
|
|
|
|
v-model='currentRenderer.isEnabled'
|
|
|
|
hide-details
|
2019-09-01 22:33:36 +00:00
|
|
|
inset
|
2019-08-05 03:53:21 +00:00
|
|
|
)
|
2018-09-30 03:30:20 +00:00
|
|
|
v-card-text.pb-4.pt-2.pl-4
|
2019-08-05 03:53:21 +00:00
|
|
|
.overline.my-5 Rendering Module Configuration
|
|
|
|
.body-2.ml-3(v-if='!currentRenderer.config || currentRenderer.config.length < 1'): em This rendering module has no configuration options you can modify.
|
2018-09-30 03:30:20 +00:00
|
|
|
template(v-else, v-for='(cfg, idx) in currentRenderer.config')
|
|
|
|
v-select(
|
|
|
|
v-if='cfg.value.type === "string" && cfg.value.enum'
|
2019-08-05 03:53:21 +00:00
|
|
|
outlined
|
2018-09-30 03:30:20 +00:00
|
|
|
:items='cfg.value.enum'
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.value.title'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
:hint='cfg.value.hint ? cfg.value.hint : ""'
|
|
|
|
persistent-hint
|
|
|
|
:class='cfg.value.hint ? "mb-2" : ""'
|
|
|
|
)
|
|
|
|
v-switch(
|
|
|
|
v-else-if='cfg.value.type === "boolean"'
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.value.title'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
color='primary'
|
|
|
|
:hint='cfg.value.hint ? cfg.value.hint : ""'
|
|
|
|
persistent-hint
|
2019-09-01 22:33:36 +00:00
|
|
|
inset
|
2018-09-30 03:30:20 +00:00
|
|
|
)
|
|
|
|
v-text-field(
|
|
|
|
v-else
|
2019-08-05 03:53:21 +00:00
|
|
|
outlined
|
2018-09-30 03:30:20 +00:00
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.value.title'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
:hint='cfg.value.hint ? cfg.value.hint : ""'
|
|
|
|
persistent-hint
|
|
|
|
:class='cfg.value.hint ? "mb-2" : ""'
|
|
|
|
)
|
2019-08-05 03:53:21 +00:00
|
|
|
v-divider.my-5(v-if='idx < currentRenderer.config.length - 1')
|
2018-09-30 03:30:20 +00:00
|
|
|
v-card-chin
|
|
|
|
v-spacer
|
|
|
|
.caption.pr-3.grey--text Module: {{ currentRenderer.key }}
|
2018-03-18 02:41:16 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-08-27 02:38:08 +00:00
|
|
|
import _ from 'lodash'
|
2018-09-09 00:57:37 +00:00
|
|
|
import { DepGraph } from 'dependency-graph'
|
|
|
|
|
|
|
|
import { StatusIndicator } from 'vue-status-indicator'
|
2018-08-27 02:38:08 +00:00
|
|
|
|
|
|
|
import renderersQuery from 'gql/admin/rendering/rendering-query-renderers.gql'
|
2019-12-21 21:41:03 +00:00
|
|
|
import renderersSaveMutation from 'gql/admin/rendering/rendering-mutation-save-renderers.gql'
|
2018-08-27 02:38:08 +00:00
|
|
|
|
2018-03-18 02:41:16 +00:00
|
|
|
export default {
|
2018-09-09 00:57:37 +00:00
|
|
|
components: {
|
|
|
|
StatusIndicator
|
|
|
|
},
|
2018-03-18 02:41:16 +00:00
|
|
|
data() {
|
2018-07-07 22:09:58 +00:00
|
|
|
return {
|
2018-09-09 00:57:37 +00:00
|
|
|
selectedCore: -1,
|
|
|
|
renderers: [],
|
|
|
|
currentRenderer: {}
|
2018-08-27 02:38:08 +00:00
|
|
|
}
|
|
|
|
},
|
2018-09-04 00:58:54 +00:00
|
|
|
watch: {
|
|
|
|
renderers(newValue, oldValue) {
|
|
|
|
_.delay(() => {
|
2018-09-09 00:57:37 +00:00
|
|
|
this.selectedCore = _.findIndex(newValue, ['key', 'markdownCore'])
|
|
|
|
this.selectRenderer('markdownCore')
|
2018-09-04 00:58:54 +00:00
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
},
|
2018-09-09 00:57:37 +00:00
|
|
|
methods: {
|
|
|
|
selectRenderer (key) {
|
|
|
|
this.renderers.map(rdr => {
|
|
|
|
if (_.some(rdr.children, ['key', key])) {
|
|
|
|
this.currentRenderer = _.find(rdr.children, ['key', key])
|
|
|
|
}
|
|
|
|
})
|
2019-01-01 06:40:31 +00:00
|
|
|
},
|
|
|
|
async refresh () {
|
2019-12-21 21:41:03 +00:00
|
|
|
await this.$apollo.queries.renderers.refetch()
|
2019-01-01 06:40:31 +00:00
|
|
|
this.$store.commit('showNotification', {
|
2019-12-21 21:41:03 +00:00
|
|
|
message: 'Rendering active configuration has been reloaded.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'cached'
|
2019-01-01 06:40:31 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
async save () {
|
2019-12-21 21:41:03 +00:00
|
|
|
this.$store.commit(`loadingStart`, 'admin-rendering-saverenderers')
|
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: renderersSaveMutation,
|
|
|
|
variables: {
|
|
|
|
renderers: _.reduce(this.renderers, (result, core) => {
|
|
|
|
result = _.concat(result, core.children.map(rd => ({
|
|
|
|
key: rd.key,
|
|
|
|
isEnabled: rd.isEnabled,
|
|
|
|
config: rd.config.map(cfg => ({ key: cfg.key, value: JSON.stringify({ v: cfg.value.value }) }))
|
|
|
|
})))
|
|
|
|
return result
|
|
|
|
}, [])
|
|
|
|
}
|
|
|
|
})
|
2019-01-01 06:40:31 +00:00
|
|
|
this.$store.commit('showNotification', {
|
2019-12-21 21:41:03 +00:00
|
|
|
message: 'Rendering configuration saved successfully.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'check'
|
2019-01-01 06:40:31 +00:00
|
|
|
})
|
2019-12-21 21:41:03 +00:00
|
|
|
this.$store.commit(`loadingStop`, 'admin-rendering-saverenderers')
|
2018-09-09 00:57:37 +00:00
|
|
|
}
|
|
|
|
},
|
2018-08-27 02:38:08 +00:00
|
|
|
apollo: {
|
|
|
|
renderers: {
|
|
|
|
query: renderersQuery,
|
|
|
|
fetchPolicy: 'network-only',
|
2018-09-09 00:57:37 +00:00
|
|
|
update: (data) => {
|
2020-04-13 01:19:22 +00:00
|
|
|
let renderers = _.cloneDeep(data.rendering.renderers).map(str => ({
|
|
|
|
...str,
|
|
|
|
config: _.sortBy(str.config.map(cfg => ({
|
|
|
|
...cfg,
|
|
|
|
value: JSON.parse(cfg.value)
|
|
|
|
})), [t => t.value.order])
|
|
|
|
}))
|
2018-09-09 00:57:37 +00:00
|
|
|
// Build tree
|
|
|
|
const graph = new DepGraph({ circular: true })
|
|
|
|
const rawCores = _.filter(renderers, ['dependsOn', null]).map(core => {
|
|
|
|
core.children = _.concat([_.cloneDeep(core)], _.filter(renderers, ['dependsOn', core.key]))
|
|
|
|
return core
|
|
|
|
})
|
|
|
|
// Build dependency graph
|
|
|
|
rawCores.map(core => { graph.addNode(core.key) })
|
|
|
|
rawCores.map(core => {
|
|
|
|
rawCores.map(coreTarget => {
|
|
|
|
if (core.key !== coreTarget.key) {
|
|
|
|
if (core.output === coreTarget.input) {
|
|
|
|
graph.addDependency(core.key, coreTarget.key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// Reorder cores in reverse dependency order
|
|
|
|
let orderedCores = []
|
|
|
|
_.reverse(graph.overallOrder()).map(coreKey => {
|
|
|
|
orderedCores.push(_.find(rawCores, ['key', coreKey]))
|
|
|
|
})
|
|
|
|
return orderedCores
|
|
|
|
},
|
2018-08-27 02:38:08 +00:00
|
|
|
watchLoading (isLoading) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-rendering-refresh')
|
|
|
|
}
|
2018-07-07 22:09:58 +00:00
|
|
|
}
|
2018-03-18 02:41:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
2018-08-27 02:38:08 +00:00
|
|
|
.adm-rendering-pipeline {
|
2019-08-05 03:53:21 +00:00
|
|
|
.v-expansion-panel--active .v-expansion-panel-header {
|
|
|
|
min-height: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.v-expansion-panel-header {
|
|
|
|
padding: 0;
|
|
|
|
margin-top: 1px;
|
|
|
|
}
|
2018-03-18 02:41:16 +00:00
|
|
|
|
2019-08-05 03:53:21 +00:00
|
|
|
.v-expansion-panel-content__wrap {
|
|
|
|
padding: 0;
|
2018-08-27 02:38:08 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-18 02:41:16 +00:00
|
|
|
</style>
|