From 20cbea3d96e6af1d01b53154c23638ef3a0e706b Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Tue, 2 Mar 2021 15:56:56 +0800 Subject: [PATCH] feat(pipeline): use really data for pipeline --- web/public/js/index.js | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/web/public/js/index.js b/web/public/js/index.js index a4bc64f8..f9928e31 100644 --- a/web/public/js/index.js +++ b/web/public/js/index.js @@ -69,36 +69,20 @@ d3.json("data/struct.json").then(function (data) { }); d3.json("fake/pipeline.json").then(function (data) { - let testdata = [ - { - name: 'Initialize', - children: [ - { name: 'Initialize' } - ] - }, - { - name: 'Build', children: [ - { name: 'Pull code' }, - { name: 'Test' }, - { name: 'Build' } - ] - }, - { - name: 'Deploy', children: [ - { name: 'QA' }, - { name: 'UAT' }, - { name: 'STAGING' }, - { name: 'PROD' } - ] - }, - { - name: 'Finish', children: [ - { name: 'Finish' } - ] + if (!!data) { + let pipeline = []; + let first_pipeline = data[0]; + for (let stage of first_pipeline.stages) { + let jobs = []; + for (let step of stage.steps) { + jobs.push({name: step}); + } + pipeline.push({ + name: stage.name, + children: jobs + }) } - ]; - if (!!testdata) { - visualizationPipeline(testdata, '#pipeline'); + visualizationPipeline(pipeline, '#pipeline'); } });