@eclipse-slm/ui 1.5.0-snapshot.883 → 1.5.0-snapshot.970
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +6 -7
- package/src/api/ansible-service/ansible-service-client.ts +15 -0
- package/src/api/ansible-service/ansible-service-sse.ts +124 -0
- package/src/api/resource-management/resource-management-client.ts +0 -2
- package/src/app/navigation.ts +14 -0
- package/src/app/routes.ts +17 -0
- package/src/components/admin/ansible/AnsibleAdminImages.vue +113 -0
- package/src/components/admin/ansible/AnsibleAdminJobs.vue +179 -0
- package/src/components/admin/ansible/AnsibleAdminOperations.vue +124 -0
- package/src/components/capabilities/CapabilitiesTable.vue +3 -3
- package/src/components/capabilities/CapabilityActionCard.vue +15 -14
- package/src/components/capabilities/CapabilityCreateForm.vue +33 -2
- package/src/components/capabilities/CapabilityImportDialog.vue +16 -7
- package/src/components/capabilities/capabilityForm.ts +65 -22
- package/src/components/jobs/JobDetail.vue +395 -0
- package/src/components/jobs/JobStatusChip.vue +16 -0
- package/src/components/jobs/JobsOverview.vue +59 -72
- package/src/components/profilers/ProfilerDialog.vue +95 -0
- package/src/components/profilers/ProfilerForm.vue +102 -0
- package/src/components/profilers/ProfilersTable.vue +98 -0
- package/src/components/profilers/profilerForm.ts +46 -0
- package/src/docker/entrypoint.sh +2 -2
- package/src/localisation/en.json +90 -0
- package/src/pages/AdminAnsibleServicePage.vue +111 -0
- package/src/pages/AdminProfilersPage.vue +73 -0
- package/src/pages/DashboardPage.vue +28 -56
- package/src/pages/JobDetailPage.vue +7 -0
- package/src/stores/ansibleAdminStore.ts +206 -0
- package/src/stores/environmentStore.ts +3 -3
- package/src/stores/jobsStore.ts +39 -39
- package/src/stores/profilersStore.ts +80 -0
- package/src/stores/resourceDevicesStore.ts +2 -2
- package/src/stores/serviceInstancesStore.ts +0 -1
- package/src/stores/serviceOfferingsStore.ts +1 -1
- package/src/utils/jobStatus.ts +63 -0
- package/vite/dist/apiClients.d.ts +1 -1
- package/vite/dist/apiClients.js +1 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-container fluid>
|
|
3
|
+
<div
|
|
4
|
+
v-if="loading"
|
|
5
|
+
class="text-center"
|
|
6
|
+
>
|
|
7
|
+
<v-progress-circular
|
|
8
|
+
:size="70"
|
|
9
|
+
:width="7"
|
|
10
|
+
color="primary"
|
|
11
|
+
indeterminate
|
|
12
|
+
/>
|
|
13
|
+
</div>
|
|
14
|
+
<v-alert
|
|
15
|
+
v-else-if="notFound"
|
|
16
|
+
type="warning"
|
|
17
|
+
>
|
|
18
|
+
Job not found
|
|
19
|
+
</v-alert>
|
|
20
|
+
|
|
21
|
+
<base-material-card v-else-if="job">
|
|
22
|
+
<template #heading>
|
|
23
|
+
<overview-heading :text="`Job ${job.id}`" />
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<v-row
|
|
27
|
+
align="center"
|
|
28
|
+
class="mb-2"
|
|
29
|
+
>
|
|
30
|
+
<v-col cols="auto">
|
|
31
|
+
<v-btn
|
|
32
|
+
variant="text"
|
|
33
|
+
prepend-icon="mdi-arrow-left"
|
|
34
|
+
to="/jobs"
|
|
35
|
+
>
|
|
36
|
+
Jobs
|
|
37
|
+
</v-btn>
|
|
38
|
+
</v-col>
|
|
39
|
+
<v-col cols="auto">
|
|
40
|
+
<job-status-chip :status="job.status" />
|
|
41
|
+
</v-col>
|
|
42
|
+
<v-col cols="auto">
|
|
43
|
+
{{ formatDuration(jobDurationMs(job, now)) }}
|
|
44
|
+
</v-col>
|
|
45
|
+
<v-spacer />
|
|
46
|
+
<v-col cols="auto">
|
|
47
|
+
<v-btn
|
|
48
|
+
v-if="!isFinal"
|
|
49
|
+
color="error"
|
|
50
|
+
prepend-icon="mdi-cancel"
|
|
51
|
+
:loading="cancelling"
|
|
52
|
+
@click="cancelDialog = true"
|
|
53
|
+
>
|
|
54
|
+
Cancel job
|
|
55
|
+
</v-btn>
|
|
56
|
+
</v-col>
|
|
57
|
+
</v-row>
|
|
58
|
+
|
|
59
|
+
<v-alert
|
|
60
|
+
v-if="cancelError"
|
|
61
|
+
type="error"
|
|
62
|
+
class="mb-2"
|
|
63
|
+
closable
|
|
64
|
+
@click:close="cancelError = ''"
|
|
65
|
+
>
|
|
66
|
+
{{ cancelError }}
|
|
67
|
+
</v-alert>
|
|
68
|
+
|
|
69
|
+
<v-alert
|
|
70
|
+
v-if="job.errorCode || job.errorMessage"
|
|
71
|
+
type="error"
|
|
72
|
+
class="mb-4"
|
|
73
|
+
>
|
|
74
|
+
<strong>{{ job.errorCode }}</strong><span v-if="job.errorCode && job.errorMessage">: </span>
|
|
75
|
+
<span v-if="job.errorMessage">{{ job.errorMessage }}</span>
|
|
76
|
+
</v-alert>
|
|
77
|
+
|
|
78
|
+
<v-table
|
|
79
|
+
density="compact"
|
|
80
|
+
class="mb-4"
|
|
81
|
+
>
|
|
82
|
+
<tbody>
|
|
83
|
+
<tr>
|
|
84
|
+
<th>Service</th>
|
|
85
|
+
<td>{{ job.serviceName }}</td>
|
|
86
|
+
</tr>
|
|
87
|
+
<tr>
|
|
88
|
+
<th>Playbook</th>
|
|
89
|
+
<td>{{ job.playbook }} <span v-if="job.ref">({{ job.ref }})</span></td>
|
|
90
|
+
</tr>
|
|
91
|
+
<tr>
|
|
92
|
+
<th>Repository</th>
|
|
93
|
+
<td>{{ job.repo }}</td>
|
|
94
|
+
</tr>
|
|
95
|
+
<tr>
|
|
96
|
+
<th>Image</th>
|
|
97
|
+
<td>{{ job.image }}</td>
|
|
98
|
+
</tr>
|
|
99
|
+
<tr v-if="job.resourceIds && job.resourceIds.length">
|
|
100
|
+
<th>{{ job.resourceIds.length > 1 ? 'Resources' : 'Resource' }}</th>
|
|
101
|
+
<td>
|
|
102
|
+
<div v-for="resourceId in job.resourceIds" :key="resourceId">{{ resourceId }}</div>
|
|
103
|
+
</td>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<th>Owner</th>
|
|
107
|
+
<td>{{ job.owner }}</td>
|
|
108
|
+
</tr>
|
|
109
|
+
<tr>
|
|
110
|
+
<th>Created</th>
|
|
111
|
+
<td>{{ formatJobDate(job.createdAt) }}</td>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<th>Started</th>
|
|
115
|
+
<td>{{ formatJobDate(job.startedAt) }}</td>
|
|
116
|
+
</tr>
|
|
117
|
+
<tr>
|
|
118
|
+
<th>Finished</th>
|
|
119
|
+
<td>{{ formatJobDate(job.finishedAt) }}</td>
|
|
120
|
+
</tr>
|
|
121
|
+
</tbody>
|
|
122
|
+
</v-table>
|
|
123
|
+
|
|
124
|
+
<v-tabs
|
|
125
|
+
v-model="tab"
|
|
126
|
+
class="mb-2"
|
|
127
|
+
>
|
|
128
|
+
<v-tab value="logs">
|
|
129
|
+
Log
|
|
130
|
+
</v-tab>
|
|
131
|
+
<v-tab value="events">
|
|
132
|
+
Events ({{ events.length }})
|
|
133
|
+
</v-tab>
|
|
134
|
+
<v-tab value="recap">
|
|
135
|
+
Play recap
|
|
136
|
+
</v-tab>
|
|
137
|
+
</v-tabs>
|
|
138
|
+
|
|
139
|
+
<v-window v-model="tab">
|
|
140
|
+
<v-window-item value="logs">
|
|
141
|
+
<div class="d-flex align-center mb-1">
|
|
142
|
+
<v-chip
|
|
143
|
+
v-if="streaming"
|
|
144
|
+
size="x-small"
|
|
145
|
+
color="primary"
|
|
146
|
+
prepend-icon="mdi-access-point"
|
|
147
|
+
>
|
|
148
|
+
live
|
|
149
|
+
</v-chip>
|
|
150
|
+
<v-spacer />
|
|
151
|
+
<v-checkbox
|
|
152
|
+
v-model="followLog"
|
|
153
|
+
label="Follow"
|
|
154
|
+
density="compact"
|
|
155
|
+
hide-details
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
<pre
|
|
159
|
+
ref="logElement"
|
|
160
|
+
class="job-log"
|
|
161
|
+
>{{ logText }}</pre>
|
|
162
|
+
</v-window-item>
|
|
163
|
+
|
|
164
|
+
<v-window-item value="events">
|
|
165
|
+
<v-data-table
|
|
166
|
+
:headers="eventHeaders"
|
|
167
|
+
:items="events"
|
|
168
|
+
item-key="counter"
|
|
169
|
+
density="compact"
|
|
170
|
+
:items-per-page="25"
|
|
171
|
+
>
|
|
172
|
+
<template #item.failed="{ item }">
|
|
173
|
+
<v-icon
|
|
174
|
+
v-if="item.failed"
|
|
175
|
+
color="error"
|
|
176
|
+
>
|
|
177
|
+
mdi-alert-circle-outline
|
|
178
|
+
</v-icon>
|
|
179
|
+
</template>
|
|
180
|
+
<template #item.created="{ item }">
|
|
181
|
+
{{ formatJobDate(item.created) }}
|
|
182
|
+
</template>
|
|
183
|
+
</v-data-table>
|
|
184
|
+
</v-window-item>
|
|
185
|
+
|
|
186
|
+
<v-window-item value="recap">
|
|
187
|
+
<v-data-table
|
|
188
|
+
v-if="recapItems.length > 0"
|
|
189
|
+
:headers="recapHeaders"
|
|
190
|
+
:items="recapItems"
|
|
191
|
+
item-key="host"
|
|
192
|
+
density="compact"
|
|
193
|
+
hide-default-footer
|
|
194
|
+
/>
|
|
195
|
+
<no-item-available-note
|
|
196
|
+
v-else
|
|
197
|
+
item="play recap"
|
|
198
|
+
/>
|
|
199
|
+
</v-window-item>
|
|
200
|
+
</v-window>
|
|
201
|
+
</base-material-card>
|
|
202
|
+
|
|
203
|
+
<v-dialog
|
|
204
|
+
v-model="cancelDialog"
|
|
205
|
+
max-width="420"
|
|
206
|
+
>
|
|
207
|
+
<v-card>
|
|
208
|
+
<v-card-title>Cancel job?</v-card-title>
|
|
209
|
+
<v-card-text>The running playbook will be stopped.</v-card-text>
|
|
210
|
+
<v-card-actions>
|
|
211
|
+
<v-spacer />
|
|
212
|
+
<v-btn @click="cancelDialog = false">
|
|
213
|
+
No
|
|
214
|
+
</v-btn>
|
|
215
|
+
<v-btn
|
|
216
|
+
color="error"
|
|
217
|
+
@click="cancelJob"
|
|
218
|
+
>
|
|
219
|
+
Cancel job
|
|
220
|
+
</v-btn>
|
|
221
|
+
</v-card-actions>
|
|
222
|
+
</v-card>
|
|
223
|
+
</v-dialog>
|
|
224
|
+
</v-container>
|
|
225
|
+
</template>
|
|
226
|
+
|
|
227
|
+
<script setup lang="ts">
|
|
228
|
+
import {computed, nextTick, onBeforeUnmount, onMounted, ref, watch} from "vue";
|
|
229
|
+
import OverviewHeading from "@/components/base/OverviewHeading.vue";
|
|
230
|
+
import NoItemAvailableNote from "@/components/base/NoItemAvailableNote.vue";
|
|
231
|
+
import JobStatusChip from "@/components/jobs/JobStatusChip.vue";
|
|
232
|
+
import AnsibleServiceClient from "@/api/ansible-service/ansible-service-client";
|
|
233
|
+
import {streamJobLogs} from "@/api/ansible-service/ansible-service-sse";
|
|
234
|
+
import type {AnsibleJobDTO, AnsibleJobEventDTO} from "@/api/ansible-service/client";
|
|
235
|
+
import {formatDuration, formatJobDate, isFinalJobStatus, jobDurationMs} from "@/utils/jobStatus";
|
|
236
|
+
import {useJobsStore} from "@/stores/jobsStore";
|
|
237
|
+
|
|
238
|
+
const props = defineProps<{ jobId: string }>();
|
|
239
|
+
|
|
240
|
+
const jobsStore = useJobsStore();
|
|
241
|
+
const job = ref<AnsibleJobDTO | null>(null);
|
|
242
|
+
const events = ref<AnsibleJobEventDTO[]>([]);
|
|
243
|
+
const logLines = ref<string[]>([]);
|
|
244
|
+
const loading = ref(true);
|
|
245
|
+
const notFound = ref(false);
|
|
246
|
+
const streaming = ref(false);
|
|
247
|
+
const tab = ref('logs');
|
|
248
|
+
const followLog = ref(true);
|
|
249
|
+
const cancelDialog = ref(false);
|
|
250
|
+
const cancelling = ref(false);
|
|
251
|
+
const cancelError = ref('');
|
|
252
|
+
const now = ref(Date.now());
|
|
253
|
+
const logElement = ref<HTMLElement | null>(null);
|
|
254
|
+
|
|
255
|
+
let closeStream: (() => void) | null = null;
|
|
256
|
+
let ticker: ReturnType<typeof setInterval> | null = null;
|
|
257
|
+
let poller: ReturnType<typeof setInterval> | null = null;
|
|
258
|
+
|
|
259
|
+
const isFinal = computed(() => isFinalJobStatus(job.value?.status));
|
|
260
|
+
const logText = computed(() => logLines.value.join('\n'));
|
|
261
|
+
|
|
262
|
+
const eventHeaders = [
|
|
263
|
+
{title: '#', key: 'counter'},
|
|
264
|
+
{title: 'Event', key: 'event'},
|
|
265
|
+
{title: 'Host', key: 'host'},
|
|
266
|
+
{title: 'Task', key: 'task'},
|
|
267
|
+
{title: 'Failed', key: 'failed'},
|
|
268
|
+
{title: 'Time', key: 'created'},
|
|
269
|
+
];
|
|
270
|
+
const recapHeaders = [
|
|
271
|
+
{title: 'Host', key: 'host'},
|
|
272
|
+
{title: 'ok', key: 'ok'},
|
|
273
|
+
{title: 'changed', key: 'changed'},
|
|
274
|
+
{title: 'failures', key: 'failures'},
|
|
275
|
+
{title: 'unreachable', key: 'unreachable'},
|
|
276
|
+
{title: 'skipped', key: 'skipped'},
|
|
277
|
+
{title: 'rescued', key: 'rescued'},
|
|
278
|
+
{title: 'ignored', key: 'ignored'},
|
|
279
|
+
];
|
|
280
|
+
const recapItems = computed(() =>
|
|
281
|
+
Object.entries(job.value?.recap ?? {}).map(([host, recap]) => ({host, ...recap})));
|
|
282
|
+
|
|
283
|
+
async function loadJob() {
|
|
284
|
+
try {
|
|
285
|
+
job.value = (await AnsibleServiceClient.jobsApi.getJob(props.jobId)).data;
|
|
286
|
+
} catch (e: any) {
|
|
287
|
+
if (e?.response?.status === 404) notFound.value = true;
|
|
288
|
+
else console.error(e);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async function loadEvents() {
|
|
293
|
+
try {
|
|
294
|
+
events.value = (await AnsibleServiceClient.jobsApi.getJobEvents(props.jobId)).data;
|
|
295
|
+
} catch (e) {
|
|
296
|
+
console.error(e);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function loadFullLog() {
|
|
301
|
+
try {
|
|
302
|
+
const text = (await AnsibleServiceClient.jobsApi.getJobLogs(props.jobId)).data as unknown as string;
|
|
303
|
+
logLines.value = text ? text.replace(/\n$/, '').split('\n') : [];
|
|
304
|
+
} catch (e) {
|
|
305
|
+
console.error(e);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function stopStream() {
|
|
310
|
+
closeStream?.();
|
|
311
|
+
closeStream = null;
|
|
312
|
+
streaming.value = false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function startStream() {
|
|
316
|
+
stopStream();
|
|
317
|
+
streaming.value = true;
|
|
318
|
+
closeStream = streamJobLogs(props.jobId, {
|
|
319
|
+
onLog: (line) => { logLines.value.push(line); },
|
|
320
|
+
// a re-opened stream may replay already known lines: start from an empty buffer
|
|
321
|
+
onReconnect: () => { logLines.value = []; },
|
|
322
|
+
onStatus: async () => {
|
|
323
|
+
stopStream();
|
|
324
|
+
await Promise.all([loadJob(), loadEvents(), loadFullLog()]);
|
|
325
|
+
jobsStore.getJobs().catch(() => undefined);
|
|
326
|
+
},
|
|
327
|
+
onError: (e) => console.warn('Job log stream error', e),
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async function cancelJob() {
|
|
332
|
+
cancelDialog.value = false;
|
|
333
|
+
cancelling.value = true;
|
|
334
|
+
cancelError.value = '';
|
|
335
|
+
try {
|
|
336
|
+
await AnsibleServiceClient.jobsApi.cancelJob(props.jobId);
|
|
337
|
+
await loadJob();
|
|
338
|
+
} catch (e: any) {
|
|
339
|
+
cancelError.value = e?.response?.status === 409
|
|
340
|
+
? (e.response.data?.detail ?? 'Job cannot be canceled any more')
|
|
341
|
+
: 'Cancel failed';
|
|
342
|
+
await loadJob();
|
|
343
|
+
} finally {
|
|
344
|
+
cancelling.value = false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
watch(logLines, () => {
|
|
349
|
+
if (followLog.value) {
|
|
350
|
+
nextTick(() => {
|
|
351
|
+
if (logElement.value) logElement.value.scrollTop = logElement.value.scrollHeight;
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}, {deep: true});
|
|
355
|
+
|
|
356
|
+
onMounted(async () => {
|
|
357
|
+
await loadJob();
|
|
358
|
+
loading.value = false;
|
|
359
|
+
if (!job.value) return;
|
|
360
|
+
await Promise.all([loadEvents(), loadFullLog()]);
|
|
361
|
+
if (!isFinal.value) {
|
|
362
|
+
startStream();
|
|
363
|
+
}
|
|
364
|
+
ticker = setInterval(() => { now.value = Date.now(); }, 1000);
|
|
365
|
+
// job status (PENDING -> RUNNING), events and recap are refreshed while the job is active
|
|
366
|
+
poller = setInterval(async () => {
|
|
367
|
+
if (isFinal.value) return;
|
|
368
|
+
await Promise.all([loadJob(), loadEvents()]);
|
|
369
|
+
if (isFinal.value) {
|
|
370
|
+
stopStream();
|
|
371
|
+
await loadFullLog();
|
|
372
|
+
}
|
|
373
|
+
}, 3000);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
onBeforeUnmount(() => {
|
|
377
|
+
stopStream();
|
|
378
|
+
if (ticker) clearInterval(ticker);
|
|
379
|
+
if (poller) clearInterval(poller);
|
|
380
|
+
});
|
|
381
|
+
</script>
|
|
382
|
+
|
|
383
|
+
<style scoped>
|
|
384
|
+
.job-log {
|
|
385
|
+
background: #1e1e1e;
|
|
386
|
+
color: #d4d4d4;
|
|
387
|
+
font-family: monospace;
|
|
388
|
+
font-size: 0.85rem;
|
|
389
|
+
padding: 12px;
|
|
390
|
+
height: 480px;
|
|
391
|
+
overflow: auto;
|
|
392
|
+
white-space: pre-wrap;
|
|
393
|
+
word-break: break-all;
|
|
394
|
+
}
|
|
395
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-chip
|
|
3
|
+
:color="jobStatusColor(status)"
|
|
4
|
+
size="small"
|
|
5
|
+
variant="flat"
|
|
6
|
+
:prepend-icon="jobStatusIcon(status)"
|
|
7
|
+
>
|
|
8
|
+
{{ jobStatusLabel(status) }}
|
|
9
|
+
</v-chip>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import {jobStatusColor, jobStatusIcon, jobStatusLabel} from "@/utils/jobStatus";
|
|
14
|
+
|
|
15
|
+
defineProps<{ status?: string | null }>();
|
|
16
|
+
</script>
|
|
@@ -21,42 +21,54 @@
|
|
|
21
21
|
<overview-heading text="Jobs" />
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
|
+
<v-select
|
|
25
|
+
v-model="statusFilter"
|
|
26
|
+
:items="statuses"
|
|
27
|
+
label="Status"
|
|
28
|
+
multiple
|
|
29
|
+
chips
|
|
30
|
+
clearable
|
|
31
|
+
density="compact"
|
|
32
|
+
class="mb-2"
|
|
33
|
+
/>
|
|
34
|
+
|
|
24
35
|
<v-data-table
|
|
25
|
-
v-if="
|
|
36
|
+
v-if="filteredJobs.length > 0"
|
|
26
37
|
id="jobsTable"
|
|
27
38
|
v-model:sort-by="sortBy"
|
|
28
|
-
:footer-props="{
|
|
29
|
-
'items-per-page-options': [5, 10, 20, -1],
|
|
30
|
-
}"
|
|
31
39
|
:headers="DataTableHeaders"
|
|
32
40
|
item-key="id"
|
|
33
|
-
:items="
|
|
41
|
+
:items="filteredJobs"
|
|
42
|
+
hover
|
|
43
|
+
@click:row="(_event, row) => openJob(row.item.id)"
|
|
34
44
|
>
|
|
35
45
|
<template #item.id="{ item }">
|
|
36
|
-
<
|
|
37
|
-
:
|
|
38
|
-
|
|
39
|
-
>
|
|
46
|
+
<router-link
|
|
47
|
+
:to="`/jobs/${item.id}`"
|
|
48
|
+
@click.stop
|
|
49
|
+
>
|
|
50
|
+
{{ item.id.substring(0, 8) }}
|
|
51
|
+
</router-link>
|
|
40
52
|
</template>
|
|
41
53
|
|
|
42
54
|
<template #item.name="{ item }">
|
|
43
|
-
{{ item.
|
|
55
|
+
{{ item.serviceName || item.playbook }}
|
|
44
56
|
</template>
|
|
45
57
|
|
|
46
|
-
<template #item.
|
|
47
|
-
{{
|
|
58
|
+
<template #item.createdAt="{ item }">
|
|
59
|
+
{{ formatJobDate(item.createdAt) }}
|
|
48
60
|
</template>
|
|
49
61
|
|
|
50
|
-
<template #item.
|
|
51
|
-
{{
|
|
62
|
+
<template #item.finishedAt="{ item }">
|
|
63
|
+
{{ formatJobDate(item.finishedAt) }}
|
|
52
64
|
</template>
|
|
53
65
|
|
|
54
|
-
<template #item.
|
|
55
|
-
{{
|
|
66
|
+
<template #item.duration="{ item }">
|
|
67
|
+
{{ formatDuration(jobDurationMs(item, now)) }}
|
|
56
68
|
</template>
|
|
57
69
|
|
|
58
70
|
<template #item.status="{ item }">
|
|
59
|
-
|
|
71
|
+
<job-status-chip :status="item.status" />
|
|
60
72
|
</template>
|
|
61
73
|
</v-data-table>
|
|
62
74
|
|
|
@@ -73,26 +85,29 @@
|
|
|
73
85
|
|
|
74
86
|
import OverviewHeading from "@/components/base/OverviewHeading.vue";
|
|
75
87
|
import NoItemAvailableNote from "@/components/base/NoItemAvailableNote.vue";
|
|
88
|
+
import JobStatusChip from "@/components/jobs/JobStatusChip.vue";
|
|
76
89
|
import {useJobsStore} from "@/stores/jobsStore";
|
|
77
90
|
import ApiState from "@/api/apiState";
|
|
78
|
-
import {
|
|
91
|
+
import {JOB_STATUSES, formatDuration, formatJobDate, jobDurationMs} from "@/utils/jobStatus";
|
|
79
92
|
|
|
80
93
|
export default {
|
|
81
94
|
name: 'JobsOverview',
|
|
82
95
|
components: {
|
|
83
96
|
OverviewHeading,
|
|
84
|
-
NoItemAvailableNote
|
|
97
|
+
NoItemAvailableNote,
|
|
98
|
+
JobStatusChip,
|
|
85
99
|
},
|
|
86
100
|
setup(){
|
|
87
|
-
const envStore = useEnvStore();
|
|
88
101
|
const jobsStore = useJobsStore();
|
|
89
|
-
return {
|
|
102
|
+
return {jobsStore, formatJobDate, formatDuration, jobDurationMs}
|
|
90
103
|
},
|
|
91
104
|
data: function () {
|
|
92
105
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
sortBy: [{key: 'createdAt', order: 'desc'}],
|
|
107
|
+
statuses: JOB_STATUSES,
|
|
108
|
+
statusFilter: [],
|
|
109
|
+
now: Date.now(),
|
|
110
|
+
ticker: null,
|
|
96
111
|
}
|
|
97
112
|
},
|
|
98
113
|
computed: {
|
|
@@ -100,7 +115,7 @@ export default {
|
|
|
100
115
|
return this.jobsStore.apiState
|
|
101
116
|
},
|
|
102
117
|
apiStateLoaded () {
|
|
103
|
-
return this.apiStateJobs === ApiState.LOADED
|
|
118
|
+
return this.apiStateJobs === ApiState.LOADED || this.apiStateJobs === ApiState.UPDATING
|
|
104
119
|
},
|
|
105
120
|
apiStateLoading () {
|
|
106
121
|
if (this.apiStateJobs === ApiState.INIT) {
|
|
@@ -114,60 +129,32 @@ export default {
|
|
|
114
129
|
jobs () {
|
|
115
130
|
return this.jobsStore.jobs
|
|
116
131
|
},
|
|
117
|
-
|
|
118
|
-
return this.
|
|
132
|
+
filteredJobs () {
|
|
133
|
+
return this.statusFilter.length > 0
|
|
134
|
+
? this.jobs.filter(job => this.statusFilter.includes(job.status))
|
|
135
|
+
: this.jobs
|
|
119
136
|
},
|
|
120
137
|
DataTableHeaders () {
|
|
121
138
|
return [
|
|
122
|
-
{ title: 'ID',
|
|
123
|
-
{ title: 'Name',
|
|
124
|
-
{ title: '
|
|
125
|
-
{ title: 'Finished at',
|
|
126
|
-
{ title: 'Duration',
|
|
127
|
-
{ title: 'Status',
|
|
139
|
+
{ title: 'ID', key: 'id', sortable: true },
|
|
140
|
+
{ title: 'Name', key: 'name', value: item => item.serviceName || item.playbook, sortable: true },
|
|
141
|
+
{ title: 'Created at', key: 'createdAt', sortable: true },
|
|
142
|
+
{ title: 'Finished at', key: 'finishedAt', sortable: true },
|
|
143
|
+
{ title: 'Duration', key: 'duration', sortable: false },
|
|
144
|
+
{ title: 'Status', key: 'status', sortable: true },
|
|
128
145
|
]
|
|
129
146
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
147
|
+
},
|
|
148
|
+
mounted () {
|
|
149
|
+
this.ticker = setInterval(() => { this.now = Date.now() }, 1000)
|
|
150
|
+
},
|
|
151
|
+
beforeUnmount () {
|
|
152
|
+
clearInterval(this.ticker)
|
|
133
153
|
},
|
|
134
154
|
methods: {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const location = 'de-DE'
|
|
138
|
-
|
|
139
|
-
if (time !== null) {
|
|
140
|
-
const date = new Date(time).toLocaleDateString(location, options)
|
|
141
|
-
return (date == 'Invalid Date') ? '' : date
|
|
142
|
-
} else {
|
|
143
|
-
return ''
|
|
144
|
-
}
|
|
155
|
+
openJob (id) {
|
|
156
|
+
this.$router.push({ path: `/jobs/${id}` })
|
|
145
157
|
},
|
|
146
|
-
|
|
147
|
-
// Hours, minutes and seconds
|
|
148
|
-
const hrs = ~~(duration / 3600);
|
|
149
|
-
const mins = ~~((duration % 3600) / 60);
|
|
150
|
-
const secs = ~~duration % 60;
|
|
151
|
-
|
|
152
|
-
// Output like "1:01" or "4:03:59" or "123:03:59"
|
|
153
|
-
let ret = "";
|
|
154
|
-
|
|
155
|
-
if (hrs > 0) {
|
|
156
|
-
ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
ret += "" + mins + ":" + (secs < 10 ? "0" : "");
|
|
160
|
-
ret += "" + secs;
|
|
161
|
-
|
|
162
|
-
return ret;
|
|
163
|
-
|
|
164
|
-
// // const milliseconds = parseInt((time % 1000))
|
|
165
|
-
// const seconds = parseInt((time / 1000) % 60)
|
|
166
|
-
// const minutes = parseInt((time / (1000 * 60)) % 60)
|
|
167
|
-
// // const hours = parseInt((time / (1000 * 60 * 60)) % 24)
|
|
168
|
-
//
|
|
169
|
-
// return (minutes > 0) ? `${minutes}m ${seconds}s` : `${seconds}s`
|
|
170
|
-
},
|
|
171
|
-
},
|
|
158
|
+
}
|
|
172
159
|
}
|
|
173
160
|
</script>
|