-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathdetail.vue
277 lines (266 loc) · 10 KB
/
detail.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<template>
<v-container>
<Breadcrumbs :items="breadcrumbItems"></Breadcrumbs>
<v-container class="d-flex justify-space-between align-center mb-2 pt-0">
<v-tabs v-model="tab" class="background">
<v-tab class="background">Overview</v-tab>
<v-tab class="background" :disabled="!hasBuilds">Builds</v-tab>
<v-tab class="background">Metrics</v-tab>
<v-tab class="background">Logs</v-tab>
<v-tab class="background">Events</v-tab>
<v-tab class="background">Vulnerabilities</v-tab>
<v-spacer class="background"></v-spacer>
</v-tabs>
<v-menu offset-y>
<template v-slot:activator="{ props }">
<v-btn
color="primary"
dark
v-bind="props"
>
<v-icon color="white">mdi-menu-open</v-icon>
Actions
</v-btn>
</template>
<v-list>
<v-list-item
@click="ActionEditApp"
prepend-icon="mdi-pencil"
title="Edit">
</v-list-item>
<v-list-item
@click="ActionOpenApp"
prepend-icon="mdi-open-in-new"
title="Open App">
</v-list-item>
<v-list-item
@click="restartApp"
prepend-icon="mdi-reload-alert"
title="Restart">
</v-list-item>
<v-list-item
:disabled="appData.spec.deploymentstrategy != 'docker'"
@click="ActionStartDownload"
prepend-icon="mdi-download"
title="Download Template">
</v-list-item>
<v-list-item
@click="openConsole"
prepend-icon="mdi-console"
:disabled="!kubero.consoleEnabled"
title="Open Console">
</v-list-item>
<v-divider class="my-3"></v-divider>
<v-list-item
@click="deleteApp"
prepend-icon="mdi-delete"
title="Delete">
</v-list-item>
</v-list>
</v-menu>
</v-container>
<v-window v-model="tab">
<v-window-item transition="false" reverse-transition="false" class="background">
<Overview :pipeline="pipeline" :phase="phase" :app="app" :appData="appData" :pipelineData="pipelineData"/>
</v-window-item>
<v-window-item transition="false" reverse-transition="false" class="background">
<Builds :pipeline="pipeline" :phase="phase" :app="app" :appData="appData" :pipelineData="pipelineData"/>
</v-window-item>
<v-window-item transition="false" reverse-transition="false" class="background">
<Metrics :pipeline="pipeline" :phase="phase" :app="app" :host="appData.spec.ingress.hosts[0].host"/>
</v-window-item>
<v-window-item transition="false" reverse-transition="false" class="background">
<LogsTab :pipeline="pipeline" :phase="phase" :app="app" :deploymentstrategy="appData.spec.deploymentstrategy" :buildstrategy="appData.spec.buildstrategy"/>
</v-window-item>
<v-window-item transition="false" reverse-transition="false" class="background">
<Events :pipeline="pipeline" :phase="phase" :app="app"/>
</v-window-item>
<v-window-item transition="false" reverse-transition="false" class="background">
<Vulnerabilities :pipeline="pipeline" :phase="phase" :app="app"/>
</v-window-item>
</v-window>
</v-container>
</template>
<script lang="ts">
import axios from "axios";
import { defineComponent } from 'vue'
import Breadcrumbs from "../breadcrumbs.vue";
import Overview from "./overview.vue";
import Events from "./events.vue";
import LogsTab from "./logstab.vue";
import Metrics from "./metrics.vue";
import Builds from "./builds.vue";
import Vulnerabilities from "./vulnerabilities.vue";
import Swal from 'sweetalert2';
import { useKuberoStore } from '../../stores/kubero'
import { mapState } from 'pinia'
export default defineComponent({
data () {
return {
loadingState: false,
tab: null,
breadcrumbItems: [
{
title: 'Dashboard.Pipelines',
disabled: false,
to: { name: 'Pipelines', params: {}}
},
{
title: 'Pipeline.'+this.pipeline,
disabled: false,
to: { name: 'Pipeline Apps', params: { pipeline: this.pipeline }}
},
{
title: 'Phase.'+this.phase,
disabled: true,
href: `/pipeline/${this.pipeline}/${this.phase}/${this.app}/detail`,
},
{
title: 'App.'+this.app,
disabled: true,
href: `/pipeline/${this.pipeline}/${this.phase}/${this.app}/detail`,
}
],
pipelineData: {},
appData: {
spec: {
deploymentstrategy: "git",
buildstrategy: "plain",
ingress: {
hosts: [{
host: '',
}]
},
}
}
}
},
computed: {
...mapState(useKuberoStore, ['kubero']),
hasBuilds() {
// disable the builds tab if the buildstrategy is plain or external
return this.appData.spec.deploymentstrategy == 'git' && this.appData.spec.buildstrategy != 'plain' && this.appData.spec.buildstrategy != 'external';
}
},
mounted() {
this.loadPipeline();
this.loadApp();
},
methods: {
loadPipeline() {
axios.get('/api/pipelines/'+this.pipeline).then(response => {
this.pipelineData = response.data;
});
},
loadApp() {
axios.get('/api/apps/'+this.pipeline+'/'+this.phase+'/'+this.app).then(response => {
this.appData = response.data;
//console.log(this.appData);
});
},
ActionOpenApp() {
window.open(`https://${this.appData.spec.ingress.hosts[0].host}`, '_blank');
},
ActionEditApp() {
this.$router.push(`/pipeline/${this.pipeline}/${this.phase}/apps/${this.app}`);
},
ActionStartDownload() {
axios.get('/api/apps/'+this.pipeline+'/'+this.phase+'/'+this.app+'/download').then(response => {
//console.log(response.data);
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', this.app+'.yaml');
document.body.appendChild(link);
link.click();
});
},
deleteApp() {
Swal.fire({
title: "Delete App ”" + this.app + "” ?",
text: "Do you want to delete this App? This action cannot be undone. It will delete all the data associated with this app.",
icon: "question",
showCancelButton: true,
confirmButtonText: "Delete",
cancelButtonText: "Cancel",
confirmButtonColor: "rgb(var(--v-theme-kubero))",
background: "rgb(var(--v-theme-cardBackground))",
/*background: "rgb(var(--v-theme-on-surface-variant))",*/
color: "rgba(var(--v-theme-on-background),var(--v-high-emphasis-opacity));",
})
.then((result) => {
if (result.isConfirmed) {
axios.delete(`/api/apps/${this.pipeline}/${this.phase}/${this.app}`)
.then(response => {
// sleep 1 second
setTimeout(() => {
this.$router.push(`/pipeline/${this.pipeline}/apps`);
}, 1000);
//console.log("deleteApp", response);
})
.catch(error => {
console.log(error);
});
return;
}
});
},
async restartApp() {
axios.get(`/api/apps/${this.pipeline}/${this.phase}/${this.app}/restart`)
.then(response => {
//console.log(response);
this.loadingState = true;
})
.catch(error => {
console.log(error);
});
// TODO - this is a hack to wait for the restart to complete. It is not so easy to get the status of the restart.
await new Promise(r => setTimeout(r, 15000));
this.loadingState = false;
},
openConsole() {
window.open(`/popup/console/${this.pipeline}/${this.phase}/${this.app}`, '_blank', 'popup=yes,location=no,height=720,width=900,scrollbars=yes,status=no');
},
},
components: {
Breadcrumbs,
Events,
LogsTab,
Vulnerabilities,
Overview,
Metrics,
Builds
},
props: {
pipeline: {
type: String,
default: "MISSING"
},
phase: {
type: String,
default: "MISSING"
},
app: {
type: String,
default: "new"
}
},
})
</script>
<style scoped>
.v-list-item__icon:first-child {
margin-right: 0px;
margin: 10px
}
.v-list-item {
min-height: 32px;
}
</style>
<style>
.v-window__container {
transition: none !important;
}
canvas {
transition: none !important;
}
</style>