Skip to content

Commit fe93e34

Browse files
authored
Merge pull request #132 from FlowCI/develop
v0.21.21
2 parents 7257306 + 69033fd commit fe93e34

27 files changed

+666
-277
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flow-web-x",
3-
"version": "0.21.05",
3+
"version": "0.21.21",
44
"description": "flow.ci web ui",
55
"author": "Yang Guo <32008001@qq.com>",
66
"private": true,
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@antv/g6": "^4.0.3",
15-
"@mdi/js": "^5.3.45",
15+
"@mdi/js": "^5.9.55",
1616
"axios": "^0.21.1",
1717
"babel-polyfill": "^6.26.0",
1818
"blueimp-md5": "^2.11.0",

src/components/Jobs/ListItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<v-icon size="20" v-bind:class="[wrapper.status.class]">{{ wrapper.status.icon }}</v-icon>
77
</v-col>
88

9-
<v-col cols="1">
9+
<v-col cols="2">
1010
<span class="font-weight-bold"># {{ wrapper.buildNumber }}</span>
1111
<v-tooltip bottom>
1212
<template v-slot:activator="{ on }">
@@ -23,7 +23,7 @@
2323
</v-tooltip>
2424
</v-col>
2525

26-
<v-col cols="8">
26+
<v-col cols="7">
2727
<!-- for push and tag -->
2828
<v-row align="center"
2929
no-gutters

src/components/Jobs/StepGraphic.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ export default {
166166
edges = edges.concat(this.toEdges({}, this.root.next))
167167
168168
for (let step of this.findLastSteps(this.root)) {
169-
console.log(step.name)
170-
171169
edges.push({
172170
source: step.path,
173171
target: end.id
Lines changed: 127 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
<template>
2-
<div>
2+
<div class="step-logging">
33
<v-divider></v-divider>
44

5-
<step-logging-item
6-
v-for="(item) in stepItems"
7-
:key="item.id"
8-
:bus="buses[item.id]"
9-
:on-debug-click="onDebugClick"
10-
:wrapper="item">
11-
</step-logging-item>
12-
13-
<v-divider class="mt-4" v-if="taskItems.length > 0"></v-divider>
14-
<v-subheader class="mb-2" v-if="taskItems.length > 0">Notifications</v-subheader>
15-
16-
<step-logging-item
17-
v-for="(item) in taskItems"
18-
:key="item.id"
19-
:wrapper="item">
20-
</step-logging-item>
5+
<v-treeview dense
6+
ref="tree"
7+
:items="nodes"
8+
@update:open="onTreeExpanded"
9+
item-key="pathAsString"
10+
:open.sync="openIds">
11+
<template v-slot:label={item}>
12+
<step-logging-item :wrapper="steps[item.pathAsString] || emptyStep"
13+
:on-debug-click="onDebugClick"
14+
:bus="buses[item.pathAsString]"
15+
></step-logging-item>
16+
</template>
17+
</v-treeview>
2118
</div>
2219
</template>
2320

2421
<script>
2522
import Vue from 'vue'
2623
import StepLoggingItem from '@/components/Jobs/StepLoggingItem'
27-
import {forEachStep, StepWrapper} from '@/util/steps'
24+
import {EmptyStepWrapper, forEachStep} from '@/util/steps'
2825
import {mapState} from 'vuex'
2926
3027
export default {
@@ -34,9 +31,8 @@ export default {
3431
},
3532
data() {
3633
return {
37-
stepItems: [],
38-
taskItems: [],
39-
buses: {}
34+
buses: {},
35+
emptyStep: EmptyStepWrapper
4036
}
4137
},
4238
props: {
@@ -50,39 +46,45 @@ export default {
5046
root: state => state.steps.root,
5147
tasks: state => state.steps.tasks,
5248
loaded: state => state.logs.loaded,
53-
pushed: state => state.logs.pushed
49+
pushed: state => state.logs.pushed,
50+
nodes: state => state.flows.steps
5451
}),
52+
53+
openIds: {
54+
get() {
55+
let ids = []
56+
this.forEachNodes(this.nodes, (n) => {
57+
ids.push(n.pathAsString)
58+
})
59+
return ids
60+
},
61+
set() {
62+
63+
}
64+
},
65+
66+
steps() {
67+
let steps = {}
68+
forEachStep(this.root, (step) => {
69+
steps[step.path] = step
70+
})
71+
return steps
72+
}
5573
},
5674
watch: {
5775
root(root) {
58-
this.stepItems.length = 0
59-
let added = {}
60-
6176
forEachStep(root, (step) => {
62-
if (step.isStage || step.isFlow) {
77+
if (step.isParallel || step.isStage || step.isFlow) {
6378
return
6479
}
6580
6681
// only init event once, since step-logging-item $on in mounted
67-
if (!this.buses[step.id]) {
68-
this.buses[step.id] = new Vue()
69-
}
70-
71-
if (!added[step.id]) {
72-
this.stepItems.push(step)
73-
added[step.id] = step
82+
if (!this.buses[step.path]) {
83+
this.buses[step.path] = new Vue()
7484
}
7585
})
7686
},
7787
78-
tasks(tasks) {
79-
this.taskItems.length = 0
80-
tasks.forEach((s, index) => {
81-
const wrapper = new StepWrapper(s, index)
82-
this.taskItems.push(wrapper)
83-
})
84-
},
85-
8688
// action from pushed log
8789
pushed(logWrapper) {
8890
this.writeLog(logWrapper)
@@ -101,11 +103,95 @@ export default {
101103
if (bus) {
102104
bus.$emit("writeLog", logWrapper.log)
103105
}
106+
},
107+
108+
forEachNodes(nodes, onNode) {
109+
for (let n of nodes) {
110+
onNode(n)
111+
this.forEachNodes(n.children, onNode)
112+
}
113+
},
114+
115+
onTreeExpanded() {
116+
if (this.nodes.length === 0) {
117+
return
118+
}
119+
120+
let children = this.$refs.tree.$el.children
121+
if (children.length > 0) {
122+
this.cleanTreeviewElement(children)
123+
return
124+
}
125+
126+
setTimeout(() => {
127+
this.cleanTreeviewElement(children)
128+
}, 200)
129+
},
130+
131+
cleanTreeviewElement(treeNodes) {
132+
for (let tn of treeNodes) {
133+
this.removeNodeLevelOrButtonFromTreeNode(tn)
134+
135+
let children = this.getChildrenNodes(tn)
136+
if (children.length > 0) {
137+
this.cleanTreeviewElement(children)
138+
}
139+
}
140+
},
141+
142+
removeNodeLevelOrButtonFromTreeNode(treeNodeLeaf) {
143+
const nodeRoot = treeNodeLeaf.children[0];
144+
if (!nodeRoot) {
145+
return
146+
}
147+
148+
for (let child of nodeRoot.children) {
149+
if (this.isToggleBtn(child)) {
150+
child.remove()
151+
return
152+
}
153+
}
154+
155+
const first = nodeRoot.children[0]
156+
if (this.isNodeLevel(first)) {
157+
first.remove()
158+
}
159+
},
160+
161+
getChildrenNodes(treeNode) {
162+
if (treeNode.children.length !== 2) {
163+
return []
164+
}
165+
166+
const el = treeNode.children[1]
167+
if(el.classList.contains('v-treeview-node__children')) {
168+
return el.children
169+
}
170+
171+
return []
172+
},
173+
174+
isNodeLevel(el) {
175+
return el.classList.contains('v-treeview-node__level')
176+
},
177+
178+
isToggleBtn(el) {
179+
return el.classList.contains('v-treeview-node__toggle')
104180
}
105181
}
106182
}
107183
</script>
108184

109185
<style lang="scss">
186+
.step-logging {
187+
.v-treeview-node {
188+
.v-treeview-node__root {
189+
padding-left: 0;
190+
}
110191
192+
.v-treeview-node__content {
193+
margin-left: 0;
194+
}
195+
}
196+
}
111197
</style>

0 commit comments

Comments
 (0)