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.

235 lines
7.6 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='/svg/icon-process.svg', alt='Rendering', style='width: 80px;')
  7. .admin-header-title
  8. .headline.primary--text.animated.fadeInLeft Rendering
  9. .subtitle-1.grey--text.animated.fadeInLeft.wait-p4s Configure how content is rendered #[v-chip(label, color='primary', small).white--text coming soon]
  10. v-spacer
  11. v-btn.mx-3.animated.fadeInDown.wait-p2s(outlined, color='grey', @click='refresh', large)
  12. v-icon mdi-refresh
  13. v-btn.animated.fadeInDown(color='success', @click='save', depressed, large)
  14. v-icon(left) mdi-check
  15. span {{$t('common:actions.apply')}}
  16. v-flex.animated.fadeInUp(lg3, xs12)
  17. v-toolbar(
  18. color='primary'
  19. dense
  20. flat
  21. dark
  22. )
  23. v-icon.mr-2 mdi-creation
  24. .subtitle-1 Pipeline
  25. v-expansion-panels.adm-rendering-pipeline(
  26. v-model='selectedCore'
  27. accordion
  28. mandatory
  29. )
  30. v-expansion-panel(
  31. v-for='core in renderers'
  32. :key='core.key'
  33. )
  34. v-expansion-panel-header(
  35. hide-actions
  36. ripple
  37. )
  38. v-toolbar(
  39. color='blue'
  40. dense
  41. dark
  42. flat
  43. )
  44. v-spacer
  45. .body-2 {{core.input}}
  46. v-icon.mx-2 mdi-arrow-right-bold-hexagon-outline
  47. .caption {{core.output}}
  48. v-spacer
  49. v-expansion-panel-content
  50. v-list.py-0(two-line, dense)
  51. template(v-for='(rdr, n) in core.children')
  52. v-list-item(
  53. :key='rdr.key'
  54. @click='selectRenderer(rdr.key)'
  55. :class='currentRenderer.key === rdr.key ? (darkMode ? `grey darken-4-l4` : `blue lighten-5`) : ``'
  56. )
  57. v-list-item-avatar(size='24')
  58. v-icon(:color='currentRenderer.key === rdr.key ? "primary" : "grey"') {{rdr.icon}}
  59. v-list-item-content
  60. v-list-item-title {{rdr.title}}
  61. v-list-item-subtitle: .caption {{rdr.description}}
  62. v-list-item-avatar(size='24')
  63. status-indicator(v-if='rdr.isEnabled', positive, pulse)
  64. status-indicator(v-else, negative, pulse)
  65. v-divider.my-0(v-if='n < core.children.length - 1')
  66. v-flex(lg9, xs12)
  67. v-card.wiki-form.animated.fadeInUp
  68. v-toolbar(
  69. color='grey darken-1'
  70. dark
  71. flat
  72. dense
  73. )
  74. v-icon.mr-2 {{currentRenderer.icon}}
  75. .subtitle-1 {{currentRenderer.title}}
  76. v-spacer
  77. v-switch(
  78. dark
  79. color='white'
  80. label='Enabled'
  81. v-model='currentRenderer.isEnabled'
  82. hide-details
  83. inset
  84. )
  85. v-card-text.pb-4.pt-2.pl-4
  86. .overline.my-5 Rendering Module Configuration
  87. .body-2.ml-3(v-if='!currentRenderer.config || currentRenderer.config.length < 1'): em This rendering module has no configuration options you can modify.
  88. template(v-else, v-for='(cfg, idx) in currentRenderer.config')
  89. v-select(
  90. v-if='cfg.value.type === "string" && cfg.value.enum'
  91. outlined
  92. :items='cfg.value.enum'
  93. :key='cfg.key'
  94. :label='cfg.value.title'
  95. v-model='cfg.value.value'
  96. :hint='cfg.value.hint ? cfg.value.hint : ""'
  97. persistent-hint
  98. :class='cfg.value.hint ? "mb-2" : ""'
  99. )
  100. v-switch(
  101. v-else-if='cfg.value.type === "boolean"'
  102. :key='cfg.key'
  103. :label='cfg.value.title'
  104. v-model='cfg.value.value'
  105. color='primary'
  106. :hint='cfg.value.hint ? cfg.value.hint : ""'
  107. persistent-hint
  108. inset
  109. )
  110. v-text-field(
  111. v-else
  112. outlined
  113. :key='cfg.key'
  114. :label='cfg.value.title'
  115. v-model='cfg.value.value'
  116. :hint='cfg.value.hint ? cfg.value.hint : ""'
  117. persistent-hint
  118. :class='cfg.value.hint ? "mb-2" : ""'
  119. )
  120. v-divider.my-5(v-if='idx < currentRenderer.config.length - 1')
  121. v-card-chin
  122. v-spacer
  123. .caption.pr-3.grey--text Module: {{ currentRenderer.key }}
  124. </template>
  125. <script>
  126. import _ from 'lodash'
  127. import { DepGraph } from 'dependency-graph'
  128. import { get } from 'vuex-pathify'
  129. import { StatusIndicator } from 'vue-status-indicator'
  130. import renderersQuery from 'gql/admin/rendering/rendering-query-renderers.gql'
  131. export default {
  132. components: {
  133. StatusIndicator
  134. },
  135. data() {
  136. return {
  137. selectedCore: -1,
  138. renderers: [],
  139. currentRenderer: {}
  140. }
  141. },
  142. computed: {
  143. darkMode: get('site/dark')
  144. },
  145. watch: {
  146. renderers(newValue, oldValue) {
  147. _.delay(() => {
  148. this.selectedCore = _.findIndex(newValue, ['key', 'markdownCore'])
  149. this.selectRenderer('markdownCore')
  150. }, 500)
  151. }
  152. },
  153. methods: {
  154. selectRenderer (key) {
  155. this.renderers.map(rdr => {
  156. if (_.some(rdr.children, ['key', key])) {
  157. this.currentRenderer = _.find(rdr.children, ['key', key])
  158. }
  159. })
  160. },
  161. async refresh () {
  162. this.$store.commit('showNotification', {
  163. style: 'indigo',
  164. message: `Coming soon...`,
  165. icon: 'directions_boat'
  166. })
  167. },
  168. async save () {
  169. this.$store.commit('showNotification', {
  170. style: 'indigo',
  171. message: `Coming soon...`,
  172. icon: 'directions_boat'
  173. })
  174. }
  175. },
  176. apollo: {
  177. renderers: {
  178. query: renderersQuery,
  179. fetchPolicy: 'network-only',
  180. update: (data) => {
  181. let renderers = _.cloneDeep(data.rendering.renderers).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))}))
  182. // Build tree
  183. const graph = new DepGraph({ circular: true })
  184. const rawCores = _.filter(renderers, ['dependsOn', null]).map(core => {
  185. core.children = _.concat([_.cloneDeep(core)], _.filter(renderers, ['dependsOn', core.key]))
  186. return core
  187. })
  188. // Build dependency graph
  189. rawCores.map(core => { graph.addNode(core.key) })
  190. rawCores.map(core => {
  191. rawCores.map(coreTarget => {
  192. if (core.key !== coreTarget.key) {
  193. if (core.output === coreTarget.input) {
  194. graph.addDependency(core.key, coreTarget.key)
  195. }
  196. }
  197. })
  198. })
  199. // Reorder cores in reverse dependency order
  200. let orderedCores = []
  201. _.reverse(graph.overallOrder()).map(coreKey => {
  202. orderedCores.push(_.find(rawCores, ['key', coreKey]))
  203. })
  204. return orderedCores
  205. },
  206. watchLoading (isLoading) {
  207. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-rendering-refresh')
  208. }
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang='scss'>
  214. .adm-rendering-pipeline {
  215. .v-expansion-panel--active .v-expansion-panel-header {
  216. min-height: 0;
  217. }
  218. .v-expansion-panel-header {
  219. padding: 0;
  220. margin-top: 1px;
  221. }
  222. .v-expansion-panel-content__wrap {
  223. padding: 0;
  224. }
  225. }
  226. </style>