This repository has been archived by the owner on Feb 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.vue
176 lines (145 loc) · 3.04 KB
/
index.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template>
<div class="jenkins-build-state"
:data-state="state">
<h3>{{ title }}</h3>
<i :class="[icon]"></i>
<div class="build-state">{{ state }}</div>
<div class="build-id">#{{ id }}</div>
<div class="build-duration">{{ duration }}</div>
</div>
</template>
<script>
const iconMap = {
running: 'fa-cog fa-spin',
aborted: 'fa-hand-paper-o',
failure: 'fa-exclamation',
'not-built': 'fa-question',
success: 'fa-check',
unstable: 'fa-exclamation-triangle'
};
export default {
// Props
props: {
title: {
type: String,
required: true
},
data: {
type: Array,
required: true
},
params: {
default: null
}
},
// Computed
computed: {
/**
* Last state
* @returns {Object|null}
*/
lastState () {
return this.data.length ? this.data[this.data.length - 1].state : null;
},
/**
* Id
* @returns {number|null}
*/
id () {
return this.lastState ? this.lastState.id : null;
},
/**
* Duration
* @returns {string|null}
*/
duration () {
return this.lastState ? Date.toHmsFormat(this.lastState.duration) : null;
},
/**
* Result
* @returns {string|null}
*/
result () {
return this.lastState ? this.lastState.result : null;
},
/**
* State
* @returns {}
*/
state () {
/**
null running
ABORTED aborted The build was manually aborted
FAILURE failure The build had a fatal error
NOT_BUILT not-built The module was not built
SUCCESS success The build had no errors
UNSTABLE unstable The build had some errors but they were not fatal
*/
return typeof this.result === 'string' ? this.result.toKebabCase() : 'running';
},
/**
* Icon classes
* @returns {string}
*/
icon () {
return `fa fa-fw ${iconMap[this.state]}`;
}
}
}
</script>
<style lang="less" scoped>
@import '~@less/colors.less';
@state-running: @blue;
@state-aborted: @darker;
@state-failure: @red;
@state-not-built: @yellow;
@state-success: @green;
@state-unstable: @purple;
.jenkins-build-state {
width: auto;
height: 100%;
color: white;
padding: 0 0.5em;
position: relative;
&[data-state='running'] {
background-color: @state-running;
}
&[data-state='aborted'] {
background-color: @state-aborted;
}
&[data-state='failure'] {
background-color: @state-failure;
}
&[data-state='not-built'] {
background-color: @state-not-built;
}
&[data-state='success'] {
background-color: @state-success;
}
&[data-state='unstable'] {
background-color: @state-unstable;
}
h3 {
height: 3.5em;
overflow: hidden;
}
i.fa {
font-size: 4em;
}
.build-state {
font-size: 2em;
}
.build-id {
position: absolute;
bottom: 0.5em;
left: 1em;
opacity: 0.5;
}
.build-duration {
position: absolute;
bottom: 0.5em;
right: 1em;
opacity: 0.5;
}
}
</style>