2018-03-18 02:41:16 +00:00
|
|
|
<template lang='pug'>
|
2018-07-07 22:09:58 +00:00
|
|
|
v-container(fluid, fill-height, grid-list-lg)
|
2018-03-18 02:41:16 +00:00
|
|
|
v-layout(row wrap)
|
|
|
|
v-flex(xs12)
|
2018-09-09 00:57:37 +00:00
|
|
|
.admin-header-icon: v-icon(size='80', color='grey lighten-2') system_update_alt
|
2018-06-11 03:23:09 +00:00
|
|
|
.headline.primary--text Rendering
|
2018-03-18 02:41:16 +00:00
|
|
|
.subheading.grey--text Configure how content is rendered
|
2018-07-07 22:09:58 +00:00
|
|
|
v-layout.mt-3(row wrap)
|
|
|
|
v-flex(lg3 xs12)
|
2018-08-27 02:38:08 +00:00
|
|
|
v-toolbar(
|
|
|
|
color='primary'
|
|
|
|
dense
|
|
|
|
flat
|
|
|
|
dark
|
|
|
|
)
|
|
|
|
v-icon.mr-2 line_weight
|
|
|
|
.subheading Pipeline
|
2018-09-04 00:58:54 +00:00
|
|
|
v-expansion-panel.adm-rendering-pipeline(v-model='selectedCore')
|
2018-08-27 02:38:08 +00:00
|
|
|
v-expansion-panel-content(
|
|
|
|
hide-actions
|
2018-09-09 00:57:37 +00:00
|
|
|
v-for='core in renderers'
|
2018-08-27 02:38:08 +00:00
|
|
|
:key='core.key'
|
2018-07-07 22:09:58 +00:00
|
|
|
)
|
2018-08-27 02:38:08 +00:00
|
|
|
v-toolbar(
|
|
|
|
slot='header'
|
|
|
|
color='blue'
|
|
|
|
dense
|
|
|
|
dark
|
|
|
|
flat
|
2018-07-07 22:09:58 +00:00
|
|
|
)
|
2018-09-09 00:57:37 +00:00
|
|
|
v-spacer
|
2018-08-27 02:38:08 +00:00
|
|
|
.body-2 {{core.input}}
|
|
|
|
v-icon.mx-2 arrow_forward
|
|
|
|
.caption {{core.output}}
|
2018-09-09 00:57:37 +00:00
|
|
|
v-spacer
|
|
|
|
v-list.py-0(two-line, dense)
|
2018-09-04 00:58:54 +00:00
|
|
|
template(v-for='(rdr, n) in core.children')
|
|
|
|
v-list-tile(
|
|
|
|
avatar
|
|
|
|
:key='rdr.key'
|
2018-09-09 00:57:37 +00:00
|
|
|
@click='selectRenderer(rdr.key)'
|
|
|
|
:class='currentRenderer.key === rdr.key ? "blue lighten-5" : ""'
|
2018-09-04 00:58:54 +00:00
|
|
|
)
|
|
|
|
v-list-tile-avatar
|
2018-09-09 00:57:37 +00:00
|
|
|
v-icon(:color='currentRenderer.key === rdr.key ? "primary" : "grey"') {{rdr.icon}}
|
2018-09-04 00:58:54 +00:00
|
|
|
v-list-tile-content
|
|
|
|
v-list-tile-title {{rdr.title}}
|
|
|
|
v-list-tile-sub-title {{rdr.description}}
|
|
|
|
v-list-tile-avatar
|
2018-09-09 00:57:37 +00:00
|
|
|
status-indicator(v-if='rdr.isEnabled', positive, pulse)
|
|
|
|
status-indicator(v-else, negative, pulse)
|
2018-09-04 00:58:54 +00:00
|
|
|
v-divider.my-0(v-if='n < core.children.length - 1')
|
2018-07-07 22:09:58 +00:00
|
|
|
|
|
|
|
v-flex(lg9 xs12)
|
|
|
|
v-card
|
|
|
|
v-toolbar(
|
|
|
|
color='grey darken-1'
|
|
|
|
dark
|
|
|
|
flat
|
|
|
|
dense
|
|
|
|
)
|
2018-09-09 00:57:37 +00:00
|
|
|
v-icon.mr-2 {{currentRenderer.icon}}
|
|
|
|
.subheading {{currentRenderer.title}}
|
2018-07-07 22:09:58 +00:00
|
|
|
v-spacer
|
2018-09-09 00:57:37 +00:00
|
|
|
.pt-3.mt-1
|
|
|
|
v-switch(
|
|
|
|
dark
|
|
|
|
color='white'
|
|
|
|
label='Enabled'
|
|
|
|
v-model='currentRenderer.isEnabled'
|
|
|
|
)
|
|
|
|
v-card-text.pb-4.pt-2.pl-4
|
|
|
|
v-subheader.pl-0 Rendering Module Configuration
|
|
|
|
.body-1.ml-3(v-if='!currentRenderer.config || currentRenderer.config.length < 1') This rendering module has no configuration options you can modify.
|
|
|
|
template(v-else, v-for='(cfg, idx) in currentRenderer.config')
|
|
|
|
v-select(
|
|
|
|
v-if='cfg.value.type === "string" && cfg.value.enum'
|
|
|
|
outline
|
|
|
|
background-color='grey lighten-2'
|
|
|
|
: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" : ""'
|
2018-07-07 22:09:58 +00:00
|
|
|
)
|
2018-09-09 00:57:37 +00:00
|
|
|
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
|
|
|
|
)
|
|
|
|
v-text-field(
|
|
|
|
v-else
|
|
|
|
outline
|
|
|
|
background-color='grey lighten-2'
|
|
|
|
: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-divider.my-3(v-if='idx < currentRenderer.config.length - 1')
|
2018-07-07 22:09:58 +00:00
|
|
|
v-card-chin
|
|
|
|
v-btn(
|
|
|
|
color='primary'
|
|
|
|
)
|
|
|
|
v-icon(left) check
|
|
|
|
span Apply Configuration
|
2018-09-09 00:57:37 +00:00
|
|
|
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'
|
|
|
|
|
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])
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
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) => {
|
|
|
|
let renderers = _.cloneDeep(data.rendering.renderers).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))}))
|
|
|
|
// 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 {
|
|
|
|
border-top: 1px solid #FFF;
|
2018-03-18 02:41:16 +00:00
|
|
|
|
2018-08-27 02:38:08 +00:00
|
|
|
.v-expansion-panel__header {
|
|
|
|
padding: 0 0;
|
|
|
|
}
|
|
|
|
}
|
2018-03-18 02:41:16 +00:00
|
|
|
</style>
|