diff --git a/frontend/src/components/Config/ConfigList.vue b/frontend/src/components/Config/ConfigList.vue index e54469a0..1b03c335 100644 --- a/frontend/src/components/Config/ConfigList.vue +++ b/frontend/src/components/Config/ConfigList.vue @@ -40,57 +40,62 @@ /> - - - - - - + + + + + + + + + + - -
-
    -
  • - - -
  • -
  • - - - - -
  • -
  • - - - - -
  • -
  • - -
    + +
    +
      +
    • + + +
    • +
    • + + + + +
    • +
    • + + + + +
    • +
    • + +
      - + +
      +
    • +
    +
    + +
    +
    + {{$t('Run')}} + + {{$t('ExtractFields')}} + + {{$t('Preview')}} + {{$t('Save')}}
    -
  • -
-
+ +
-
-
- {{$t('Run')}} - {{$t('Extract Fields')}} - - {{$t('Preview')}} - {{$t('Save')}} -
-
- - - - - + + + +
+ + + + +
+
+ +
+ @@ -174,6 +190,7 @@ import { mapState } from 'vuex' +import echarts from 'echarts' import FieldsTableView from '../TableView/FieldsTableView' import CrawlConfirmDialog from '../Common/CrawlConfirmDialog' @@ -183,6 +200,13 @@ export default { CrawlConfirmDialog, FieldsTableView }, + watch: { + activeTab () { + setTimeout(() => { + this.renderProcessChart() + }, 0) + } + }, data () { return { crawlTypeList: [ @@ -203,7 +227,9 @@ export default { { name: 'is_attr', label: 'Is Attribute' }, { name: 'attr', label: 'Attribute' }, { name: 'next_stage', label: 'Next Stage' } - ] + ], + activeTab: 'stages', + processChart: undefined } }, computed: { @@ -259,6 +285,35 @@ export default { return 'invalid' } return '' + }, + stageNodes () { + const elChart = document.querySelector('#process-chart') + const totalWidth = Number(getComputedStyle(elChart).width.replace('px', '')) + const stages = Object.values(this.spiderForm.config.stages) + return stages.map((stage, i) => { + return { + name: stage.name, + // x: i * totalWidth / stages.length, + // y: 0, + ...stage + } + }) + }, + stageEdges () { + const edges = [] + const stages = Object.values(this.spiderForm.config.stages) + stages.forEach(stage => { + for (let i = 0; i < stage.fields.length; i++) { + const field = stage.fields[i] + if (field.next_stage) { + edges.push({ + source: stage.name, + target: field.next_stage + }) + } + } + }) + return edges } }, methods: { @@ -432,6 +487,59 @@ export default { fields: [newField] } this.$set(this.spiderForm.config, 'stages', stages) + }, + renderProcessChart () { + const option = { + title: { + text: this.$t('Stage Process') + }, + series: [ + { + type: 'graph', + layout: 'force', + symbolSize: 50, + roam: true, + label: { + normal: { + show: true + } + }, + edgeSymbol: ['circle', 'arrow'], + edgeSymbolSize: [4, 10], + edgeLabel: { + normal: { + textStyle: { + fontSize: 20 + } + } + }, + focusOneNodeAdjacency: true, + force: { + initLayout: 'force', + repulsion: 100, + gravity: 0.01, + edgeLength: 200 + }, + // draggable: true, + data: this.stageNodes, + links: this.stageEdges, + lineStyle: { + normal: { + opacity: 0.9, + width: 2, + curveness: 0 + } + } + } + ] + } + const el = document.querySelector('#process-chart') + this.processChart = echarts.init(el) + this.processChart.setOption(option) + this.processChart.resize() + }, + onTabClick (tab) { + this.activeTab = tab.name } }, created () { @@ -626,4 +734,9 @@ export default { .invalid >>> .el-input__inner { border: 1px solid red !important; } + + #process-chart { + width: 100%; + height: 480px; + }