Skip to content

Commit 448c29a

Browse files
authored
Merge pull request #140 from FlowCI/develop
Develop
2 parents e4e3a76 + 4286b48 commit 448c29a

File tree

11 files changed

+173
-63
lines changed

11 files changed

+173
-63
lines changed

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
3+
NPM_CLEAN := npm ci
4+
NPM_BUILD := npm run build
5+
6+
CURRENT_DIR := $(shell pwd)
7+
8+
DOCKER_VOLUME := -v $(CURRENT_DIR):/ws
9+
DOCKER_IMG := node:14
10+
DOCKER_RUN := docker run -it --rm -w /ws $(DOCKER_VOLUME) --network host $(DOCKER_IMG)
11+
DOCKER_BUILD := docker build -f ./Dockerfile -t flowci/web:latest -t flowci/web:$(tag) .
12+
13+
.PHONY: build clean image
14+
15+
build:
16+
$(DOCKER_RUN) $(NPM_BUILD)
17+
18+
image: build
19+
$(DOCKER_BUILD)
20+
21+
clean:
22+
$(DOCKER_RUN) $(NPM_CLEAN)

build.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flow-web-x",
3-
"version": "0.21.21",
3+
"version": "1.21.33",
44
"description": "flow.ci web ui",
55
"author": "Yang Guo <32008001@qq.com>",
66
"private": true,

src/components/Flow/EditYaml.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@
9494
methods: {
9595
reload () {
9696
this.$store.dispatch(actions.flows.yml.load, this.flow.name)
97-
.then()
97+
.then() // handled on watch yml
9898
.catch((e) => {
9999
console.log(e.message)
100+
this.editor.setValue('')
100101
})
101102
},
102103

src/components/Jobs/StepGraphic.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export default {
233233
const node = {
234234
id: step.path,
235235
label: step.name,
236+
size: [10 + (step.name.length * 7), 30],
236237
preRect: {
237238
fill: step.status.config.style.fill,
238239
width: 7,

src/components/Jobs/StepLogging.vue

Lines changed: 113 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default {
3131
},
3232
data() {
3333
return {
34+
steps: {},
3435
buses: {},
3536
emptyStep: EmptyStepWrapper
3637
}
@@ -63,14 +64,6 @@ export default {
6364
}
6465
},
6566
66-
steps() {
67-
let steps = {}
68-
forEachStep(this.root, (step) => {
69-
steps[step.path] = step
70-
})
71-
return steps
72-
},
73-
7467
pathIdMapping() {
7568
let mapping = {}
7669
forEachStep(this.root, (step) => {
@@ -80,8 +73,11 @@ export default {
8073
}
8174
},
8275
watch: {
83-
root(root) {
84-
forEachStep(root, (step) => {
76+
root() {
77+
this.steps = {}
78+
forEachStep(this.root, (step) => {
79+
this.steps[step.path] = step
80+
8581
if (step.isParallel || step.isStage || step.isFlow) {
8682
return
8783
}
@@ -91,6 +87,11 @@ export default {
9187
this.buses[step.path] = new Vue()
9288
}
9389
})
90+
91+
let children = this.$refs.tree.$el.children
92+
if (children.length > 0) {
93+
this.refreshStatus(children)
94+
}
9495
},
9596
9697
// action from pushed log
@@ -121,6 +122,17 @@ export default {
121122
}
122123
},
123124
125+
refreshStatus(treeNodes) {
126+
for (let tn of treeNodes) {
127+
this.fillInStatusColor(tn)
128+
129+
let children = this.getChildrenNodes(tn)
130+
if (children.length > 0) {
131+
this.refreshStatus(children)
132+
}
133+
}
134+
},
135+
124136
onTreeExpanded() {
125137
if (this.nodes.length === 0) {
126138
return
@@ -140,6 +152,7 @@ export default {
140152
cleanTreeviewElement(treeNodes) {
141153
for (let tn of treeNodes) {
142154
this.removeNodeLevelOrButtonFromTreeNode(tn)
155+
this.fillInStatusColor(tn)
143156
144157
let children = this.getChildrenNodes(tn)
145158
if (children.length > 0) {
@@ -167,13 +180,31 @@ export default {
167180
}
168181
},
169182
183+
fillInStatusColor(treeNode) {
184+
const nodeRoot = treeNode.children[0];
185+
if (!nodeRoot) {
186+
return
187+
}
188+
189+
const stepId = this.findIdFromLoggingItem(nodeRoot)
190+
const nodePath = this.pathIdMapping[stepId]
191+
const wrapper = this.steps[nodePath]
192+
193+
if (!wrapper || !wrapper.status) {
194+
return
195+
}
196+
197+
this.addStatusDiv(nodeRoot, wrapper)
198+
this.addDotIndicator(nodeRoot, wrapper)
199+
},
200+
170201
getChildrenNodes(treeNode) {
171202
if (treeNode.children.length !== 2) {
172203
return []
173204
}
174205
175206
const el = treeNode.children[1]
176-
if(el.classList.contains('v-treeview-node__children')) {
207+
if (el.classList.contains('v-treeview-node__children')) {
177208
return el.children
178209
}
179210
@@ -186,6 +217,60 @@ export default {
186217
187218
isToggleBtn(el) {
188219
return el.classList.contains('v-treeview-node__toggle')
220+
},
221+
222+
findIdFromLoggingItem(node) {
223+
let el = node.getElementsByClassName('step-logging-item')
224+
return el[0].id;
225+
},
226+
227+
addStatusDiv(nodeRoot, wrapper) {
228+
const div = document.createElement('div')
229+
div.classList.add("status")
230+
div.style.backgroundColor = wrapper.status.config.style.fill
231+
232+
const levels = nodeRoot.getElementsByClassName('v-treeview-node__level')
233+
if (levels && levels.length > 0) {
234+
this.removeElementsByClass(nodeRoot, 'status')
235+
nodeRoot.prepend(div)
236+
return
237+
}
238+
239+
wrapper.showStatus = true
240+
},
241+
242+
addDotIndicator(nodeRoot, wrapper) {
243+
const levels = nodeRoot.getElementsByClassName('v-treeview-node__level')
244+
if (!levels) {
245+
return
246+
}
247+
248+
for (const level of levels) {
249+
this.removeElementsByClass(level, 'dot-ind')
250+
level.appendChild(this.getDotIndicator(wrapper))
251+
}
252+
},
253+
254+
getDotIndicator(wrapper) {
255+
const div = document.createElement('div')
256+
div.style.border = '2px'
257+
div.style.borderStyle = 'dotted'
258+
div.style.color = wrapper.status.config.style.fill
259+
div.style.width = '100%'
260+
div.style.marginLeft = '2px'
261+
div.classList.add('dot-ind')
262+
return div
263+
},
264+
265+
removeElementsByClass(el, className) {
266+
let all = el.getElementsByClassName(className)
267+
if (!all) {
268+
return
269+
}
270+
271+
for (let item of all) {
272+
item.remove()
273+
}
189274
}
190275
}
191276
}
@@ -201,6 +286,23 @@ export default {
201286
.v-treeview-node__content {
202287
margin-left: 0;
203288
}
289+
290+
.v-treeview-node__level {
291+
max-height: 40px;
292+
min-height: 40px;
293+
display: flex;
294+
justify-content: center;
295+
align-items: center;
296+
}
297+
298+
.status {
299+
position: absolute;
300+
min-width: 4px;
301+
max-width: 4px;
302+
top: 0;
303+
bottom: 0;
304+
left: 0;
305+
}
204306
}
205307
}
206308
</style>

src/components/Jobs/StepLoggingItem.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<template>
2-
<div class="step-logging-item" @click="onPanelClick">
2+
<div class="step-logging-item" @click="onPanelClick" :id="wrapper.id">
33
<v-expansion-panels
44
:readonly="!showLog"
55
accordion
66
focusable>
77
<v-expansion-panel>
88
<v-expansion-panel-header>
99
<template v-slot:default="{ open }">
10-
<div class="status" :style="{backgroundColor: wrapper.status.config.style.fill}"></div>
10+
<div class="status" :style="{backgroundColor: wrapper.status.config.style.fill}" v-if="wrapper.showStatus"></div>
1111

12-
<v-row no-gutters class="ml-4">
12+
<v-row no-gutters class="ml-2">
1313
<!-- step name -->
1414
<v-col cols="5">
1515
<v-icon small v-if="showLog">mdi-chevron-right</v-icon>
@@ -155,7 +155,7 @@ export default {
155155
},
156156
computed: {
157157
showLog() {
158-
return !this.wrapper.children
158+
return this.bus
159159
}
160160
},
161161
watch: {

src/store/module/flows.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ const actions = {
192192
})
193193
},
194194

195-
async confirm ({commit}, {wrapper, yaml}) {
195+
async confirm ({commit}, {wrapper, desc}) {
196196
let gitSettings = {
197197
gitUrl: wrapper.gitUrl,
198198
secret: wrapper.secret
@@ -204,7 +204,8 @@ const actions = {
204204
(flow) => {
205205
console.log('[DONE]: confirmed')
206206
commit('add', new FlowWrapper(flow))
207-
}, {yaml: btoa(yaml)}
207+
},
208+
{desc}
208209
)
209210
}
210211

src/util/steps.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export class StepWrapper {
3737
this.stepName = step.name
3838
this.nextSteps = []
3939
this.parentStep = null
40-
this.isRootFlow = !step.parent;
40+
this.isRootFlow = !step.parent
41+
this.isShowStatus = false
4142

4243
let path = step.nodePath;
4344
if (path) {
@@ -184,13 +185,21 @@ export class StepWrapper {
184185
return this.step.status === STATUS_EXCEPTION
185186
}
186187

188+
get showStatus() {
189+
return this.isShowStatus
190+
}
191+
187192
set rawStatus(newStatus) {
188193
this.step.status = newStatus
189194
}
190195

191196
set parent(p) {
192197
this.parentStep = p
193198
}
199+
200+
set showStatus(val) {
201+
this.isShowStatus = val
202+
}
194203
}
195204

196205
export function isStepFinished(step) {

src/view/Flow/CreateDialog.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
class="ml-2"
3838
:on-back-click="onBackClick"
3939
:on-next-click="onNextClick"
40+
:loading="loading"
4041
></create-select-template>
4142
<span class="error--text" v-if="error">{{ `Error: ${error}` }}</span>
4243
</v-stepper-content>
@@ -61,7 +62,8 @@
6162
data() {
6263
return {
6364
step: 1,
64-
error: ''
65+
error: '',
66+
loading: false
6567
}
6668
},
6769
computed: {
@@ -112,20 +114,18 @@
112114
},
113115
114116
// step 2
115-
2: ({yaml, err}) => {
116-
if (err) {
117-
this.error = err
118-
return
119-
}
120-
117+
2: (desc) => {
121118
// send confirm
122-
let payload = {wrapper: this.flow, yaml};
119+
this.loading = true
120+
let payload = {wrapper: this.flow, desc}
123121
this.$store.dispatch(actions.flows.confirm, payload)
124122
.then(() => {
125123
this.onCancelClick()
124+
this.loading = false
126125
})
127126
.catch((err) => {
128127
this.error = err.message
128+
this.loading = false
129129
})
130130
}
131131
}

0 commit comments

Comments
 (0)