-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathparams.vue
129 lines (116 loc) · 3.36 KB
/
params.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
<div>
<div class="columns is-multiline">
<template v-for="(arg, index) in args">
<div class="column is-one-third" :key="index">
<div class="content-article params-div">
<h2 v-if="arg.type !== 'boolean'">{{ arg.desc }}</h2>
<p class="control" style="padding-bottom: 5px;" v-if="arg.type === 'textfield'">
<input class="input is-medium input-bar" v-focus v-model="arg.value" :placeholder="arg.key">
</p>
<p class="control" v-else-if="arg.type === 'textarea'">
<textarea class="textarea input-bar" v-model="arg.value" :placeholder="arg.key"></textarea>
</p>
<p class="control" v-else-if="arg.type === 'boolean'">
<label class="checkbox">
<input type="checkbox" v-model="arg.value">
{{ arg.desc }}
</label>
</p>
</div>
</div>
</template>
</div>
<a class="button is-primary" v-on:click="startPipeline" style="margin-top: 5px;">
<span class="icon">
<i class="fa fa-play-circle"></i>
</span>
<span>Start Pipeline</span>
</a>
</div>
</template>
<script>
export default {
data () {
return {
args: [],
pipelineID: null,
docker: false
}
},
mounted () {
// Fetch data from backend
this.fetchData()
},
watch: {
'$route': 'fetchData'
},
methods: {
fetchData () {
// look up url parameters
var pipelineID = this.$route.query.pipelineid
if (!pipelineID) {
return
}
this.pipelineID = pipelineID
this.docker = this.$route.query.docker
// reset args
this.args = []
this.$http
.get('/api/v1/pipeline/' + pipelineID, {
params: {
hideProgressBar: true
}
})
.then(response => {
if (response.data) {
let pipeline = response.data
// Get all arguments
for (let x = 0, y = pipeline.jobs.length; x < y; x++) {
let args = pipeline.jobs[x].args
// we skip vault cause this is automatically filled by the vault.
if (args) {
// iterate all arguments
for (let argID = 0, argTotal = args.length; argID < argTotal; argID++) {
// we skip vault arguments cause they are autofilled in the backend.
if (args[argID].type !== 'vault') {
if (args[argID].type !== 'output') {
this.args.push(args[argID])
}
}
}
}
}
}
})
.catch((error) => {
this.$onError(error)
})
},
startPipeline () {
// Add docker option
this.args.push({ docker: this.docker })
// Send start request
this.$http
.post('/api/v1/pipeline/' + this.pipelineID + '/start', this.args)
.then(response => {
if (response.data) {
this.$router.push({ path: '/pipeline/detail', query: { pipelineid: this.pipelineID, runid: response.data.id } })
}
})
.catch((error) => {
this.$onError(error)
})
}
}
}
</script>
<style lang="scss">
.params-div {
padding: 15px;
width: 100%;
}
.checkbox:hover {
color: #4da2fc;
}
</style>