@eclipse-slm/ui 1.5.0-snapshot.1 → 1.5.0-snapshot.1024
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 +8 -0
- package/package.json +9 -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/notification-service/notificationServiceWebsocketClient.js +5 -5
- package/src/api/platform-management/platform-management-client.ts +2 -2
- package/src/api/resource-management/resource-management-client.ts +0 -2
- package/src/app/appInstance.ts +8 -0
- package/src/app/navigation.ts +21 -0
- package/src/app/routes.ts +23 -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/base/ConfirmDialog.vue +39 -25
- package/src/components/base/CustomDialog.vue +31 -3
- package/src/components/base/IconPickerDialog.vue +155 -0
- package/src/components/capabilities/CapabilitiesTable.vue +209 -0
- package/src/components/capabilities/CapabilityActionCard.vue +77 -0
- package/src/components/capabilities/CapabilityCreateDialog.vue +86 -0
- package/src/components/capabilities/CapabilityCreateForm.vue +306 -0
- package/src/components/capabilities/CapabilityImportDialog.vue +108 -0
- package/src/components/capabilities/capabilityForm.ts +244 -0
- package/src/components/core/AppBar.vue +1 -1
- package/src/components/core/Drawer.vue +12 -2
- package/src/components/jobs/JobDetail.vue +413 -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 +61 -0
- package/src/components/resources/deviceinfo/DeviceInfoView.vue +9 -1
- package/src/components/resources/dialogs/AddItemChooserDialog.vue +68 -0
- package/src/components/service_offerings/ServiceOfferingCardGrid.vue +1 -1
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionDockerCompose.vue +1 -2
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionKubernetes.vue +1 -2
- package/src/components/service_vendors/ServiceVendorDevelopersTable.vue +1 -1
- package/src/docker/entrypoint.sh +2 -2
- package/src/localisation/en.json +93 -0
- package/src/main.ts +3 -6
- package/src/pages/AdminAnsibleServicePage.vue +111 -0
- package/src/pages/AdminCapabilitiesPage.vue +60 -0
- package/src/pages/AdminProfilersPage.vue +73 -0
- package/src/pages/DashboardPage.vue +28 -56
- package/src/pages/JobDetailPage.vue +7 -0
- package/src/pages/ResourceInstancesPage.vue +71 -0
- package/src/pages/ServiceOfferingCreateOrEditPage.vue +2 -2
- package/src/stores/ansibleAdminStore.ts +206 -0
- package/src/stores/capabilitiesStore.ts +45 -2
- package/src/stores/environmentStore.ts +3 -3
- package/src/stores/jobsStore.ts +39 -39
- package/src/stores/notificationStore.ts +15 -1
- 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/stores/userStore.ts +1 -1
- package/src/utils/i18n.ts +4 -2
- package/src/utils/imageUtil.js +1 -1
- package/src/utils/jobStatus.ts +76 -0
- package/src/utils/mdiIcons.ts +49 -0
- package/src/utils/notificationTextGenerator.ts +27 -1
- package/src/utils/tokenInterceptor.js +1 -1
- package/src/utils/updateToken.js +1 -1
- package/vite/dist/apiClients.d.ts +1 -1
- package/vite/dist/apiClients.js +1 -0
- package/vite/dist/index.js +25 -4
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { GetCapabilities200ResponseInner } from '@/api/resource-management/client'
|
|
2
|
+
|
|
3
|
+
export type CapabilityClass = 'DeploymentCapability' | 'BaseConfigurationCapability'
|
|
4
|
+
export type FormCapabilityType = 'SETUP' | 'DEPLOY'
|
|
5
|
+
export type FormActionType = 'INSTALL' | 'UNINSTALL' | 'DEPLOY' | 'UNDEPLOY'
|
|
6
|
+
|
|
7
|
+
export interface ActionFormData {
|
|
8
|
+
repo: string
|
|
9
|
+
ref: string
|
|
10
|
+
playbook: string
|
|
11
|
+
// Imported action fields the form does not edit (image, connectionTypes, timeoutMinutes, ...); sent unchanged
|
|
12
|
+
extra?: Record<string, unknown>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CapabilityFormData {
|
|
16
|
+
name: string
|
|
17
|
+
logo: string // '' = use fallback
|
|
18
|
+
capabilityClass: CapabilityClass
|
|
19
|
+
supportedDeploymentTypes: string[] // DeploymentType values
|
|
20
|
+
types: FormCapabilityType[]
|
|
21
|
+
actions: Partial<Record<FormActionType, ActionFormData>>
|
|
22
|
+
// Playbook contract (MAJOR.MINOR) the Ansible actions were written for
|
|
23
|
+
playbookContract: string
|
|
24
|
+
// Set by an import: the fixed id of the imported capability, so that importing it again updates it
|
|
25
|
+
id?: string
|
|
26
|
+
// Imported actions the form cannot edit (e.g. UPDATE, SCALE_UP); sent unchanged
|
|
27
|
+
extraActions?: Record<string, unknown>
|
|
28
|
+
// Imported capability fields the form does not edit (e.g. clusterMemberTypes); sent unchanged
|
|
29
|
+
extra?: Record<string, unknown>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface CapabilityForm {
|
|
33
|
+
isFormValid: boolean
|
|
34
|
+
formData: CapabilityFormData
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const DEFAULT_BRANCH = 'main'
|
|
38
|
+
|
|
39
|
+
// Playbook contract supported by this SLM version (see PlaybookContract of the ansible_service)
|
|
40
|
+
export const DEFAULT_PLAYBOOK_CONTRACT = '1.0'
|
|
41
|
+
|
|
42
|
+
export const PLAYBOOK_CONTRACT_PATTERN = /^\d+\.\d+$/
|
|
43
|
+
|
|
44
|
+
const DEFAULT_PLAYBOOKS: Record<FormActionType, string> = {
|
|
45
|
+
INSTALL: 'install.yml',
|
|
46
|
+
UNINSTALL: 'uninstall.yml',
|
|
47
|
+
DEPLOY: 'deploy.yml',
|
|
48
|
+
UNDEPLOY: 'undeploy.yml',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const TYPE_ORDER: FormCapabilityType[] = ['SETUP', 'DEPLOY']
|
|
52
|
+
|
|
53
|
+
export const ACTIONS_BY_TYPE: Record<FormCapabilityType, FormActionType[]> = {
|
|
54
|
+
SETUP: ['INSTALL', 'UNINSTALL'],
|
|
55
|
+
DEPLOY: ['DEPLOY', 'UNDEPLOY'],
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function newActionFormData(actionType?: FormActionType): ActionFormData {
|
|
59
|
+
return { repo: '', ref: DEFAULT_BRANCH, playbook: actionType ? DEFAULT_PLAYBOOKS[actionType] : '' }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function newCapabilityFormData(): CapabilityFormData {
|
|
63
|
+
return {
|
|
64
|
+
name: '',
|
|
65
|
+
logo: '',
|
|
66
|
+
capabilityClass: 'DeploymentCapability',
|
|
67
|
+
supportedDeploymentTypes: [],
|
|
68
|
+
types: [],
|
|
69
|
+
actions: {},
|
|
70
|
+
playbookContract: DEFAULT_PLAYBOOK_CONTRACT,
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function allowedTypes(cls: CapabilityClass): FormCapabilityType[] {
|
|
75
|
+
return cls === 'BaseConfigurationCapability' ? ['SETUP'] : ['SETUP', 'DEPLOY']
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function effectiveTypes(form: CapabilityFormData): FormCapabilityType[] {
|
|
79
|
+
if (form.capabilityClass === 'BaseConfigurationCapability') {
|
|
80
|
+
return ['SETUP']
|
|
81
|
+
}
|
|
82
|
+
const allowed = allowedTypes(form.capabilityClass)
|
|
83
|
+
return TYPE_ORDER.filter(t => allowed.includes(t) && form.types.includes(t))
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function requiredActions(form: CapabilityFormData): FormActionType[] {
|
|
87
|
+
return effectiveTypes(form).flatMap(t => ACTIONS_BY_TYPE[t])
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function hasActionErrors(
|
|
91
|
+
actionType: FormActionType,
|
|
92
|
+
errors: Record<string, string | undefined>,
|
|
93
|
+
): boolean {
|
|
94
|
+
const prefix = `${actionType}.`
|
|
95
|
+
return Object.entries(errors).some(([field, message]) => field.startsWith(prefix) && !!message)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function getActionTabColorProps(
|
|
99
|
+
actionType: FormActionType,
|
|
100
|
+
errors: Record<string, string | undefined>,
|
|
101
|
+
): { color?: 'error'; baseColor?: 'error' } {
|
|
102
|
+
return hasActionErrors(actionType, errors) ? { color: 'error', baseColor: 'error' } : {}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function fallbackLogo(name: string): string {
|
|
106
|
+
const first = name.trim().charAt(0).toLowerCase()
|
|
107
|
+
if (/^[a-z]$/.test(first)) {
|
|
108
|
+
return `mdi-alpha-${first}-box`
|
|
109
|
+
}
|
|
110
|
+
if (/^[0-9]$/.test(first)) {
|
|
111
|
+
return `mdi-numeric-${first}-box`
|
|
112
|
+
}
|
|
113
|
+
return 'mdi-puzzle'
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ownId: id of the capability being edited (an imported capability that may already exist), not counted as a clash
|
|
117
|
+
export function isNameTaken(name: string, existing: { name: string; id?: string }[], ownId?: string): boolean {
|
|
118
|
+
const wanted = name.trim().toLowerCase()
|
|
119
|
+
return existing.some(c => c.name.trim().toLowerCase() === wanted && (ownId === undefined || c.id !== ownId))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function isUntouched(action: ActionFormData, actionType: FormActionType): boolean {
|
|
123
|
+
return action.repo === '' && action.playbook === DEFAULT_PLAYBOOKS[actionType]
|
|
124
|
+
&& action.ref === DEFAULT_BRANCH
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Plain-object copy; structuredClone throws on Vue reactive proxies
|
|
128
|
+
export function cloneActions(
|
|
129
|
+
actions: Partial<Record<FormActionType, ActionFormData>>,
|
|
130
|
+
): Partial<Record<FormActionType, ActionFormData>> {
|
|
131
|
+
const result: Partial<Record<FormActionType, ActionFormData>> = {}
|
|
132
|
+
for (const [key, value] of Object.entries(actions) as [FormActionType, ActionFormData][]) {
|
|
133
|
+
result[key] = { ...value, ...(value.extra ? { extra: { ...value.extra } } : {}) }
|
|
134
|
+
}
|
|
135
|
+
return result
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function prefillUntouchedActions(
|
|
139
|
+
actions: Partial<Record<FormActionType, ActionFormData>>,
|
|
140
|
+
source: FormActionType,
|
|
141
|
+
): Partial<Record<FormActionType, ActionFormData>> {
|
|
142
|
+
const src = actions[source]
|
|
143
|
+
const result: Partial<Record<FormActionType, ActionFormData>> = {}
|
|
144
|
+
for (const [key, value] of Object.entries(actions) as [FormActionType, ActionFormData][]) {
|
|
145
|
+
result[key] = src && key !== source && isUntouched(value, key)
|
|
146
|
+
? { ...value, repo: src.repo, ref: src.ref }
|
|
147
|
+
: { ...value }
|
|
148
|
+
}
|
|
149
|
+
return result
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Capability definition as returned by the git import endpoint
|
|
153
|
+
export interface ImportedCapability {
|
|
154
|
+
id?: string
|
|
155
|
+
capabilityClass?: string
|
|
156
|
+
name?: string
|
|
157
|
+
logo?: string
|
|
158
|
+
type?: string[]
|
|
159
|
+
supportedDeploymentTypes?: string[]
|
|
160
|
+
playbookContract?: string
|
|
161
|
+
actions?: Record<string, ({ repo?: string; ref?: string; playbook?: string } & Record<string, unknown>) | undefined>
|
|
162
|
+
[field: string]: unknown
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Capability fields the form edits itself; every other imported field is passed through in `extra`
|
|
166
|
+
const FORM_CAPABILITY_FIELDS = new Set(['id', 'capabilityClass', 'name', 'logo', 'type', 'supportedDeploymentTypes',
|
|
167
|
+
'playbookContract', 'actions'])
|
|
168
|
+
// Action fields the form edits or sets itself
|
|
169
|
+
const FORM_ACTION_FIELDS = new Set(['repo', 'ref', 'playbook', 'actionClass', 'actionType'])
|
|
170
|
+
|
|
171
|
+
const FORM_ACTION_TYPES: FormActionType[] = ['INSTALL', 'UNINSTALL', 'DEPLOY', 'UNDEPLOY']
|
|
172
|
+
|
|
173
|
+
export function capabilityToFormData(c: ImportedCapability): CapabilityFormData {
|
|
174
|
+
const capabilityClass: CapabilityClass = c.capabilityClass === 'BaseConfigurationCapability'
|
|
175
|
+
? 'BaseConfigurationCapability'
|
|
176
|
+
: 'DeploymentCapability'
|
|
177
|
+
const actions: Partial<Record<FormActionType, ActionFormData>> = {}
|
|
178
|
+
const extraActions: Record<string, unknown> = {}
|
|
179
|
+
for (const [t, a] of Object.entries(c.actions ?? {})) {
|
|
180
|
+
if (!a) continue
|
|
181
|
+
if (!(FORM_ACTION_TYPES as string[]).includes(t)) {
|
|
182
|
+
extraActions[t] = a
|
|
183
|
+
continue
|
|
184
|
+
}
|
|
185
|
+
const extra = Object.fromEntries(Object.entries(a).filter(([k]) => !FORM_ACTION_FIELDS.has(k)))
|
|
186
|
+
actions[t as FormActionType] = {
|
|
187
|
+
repo: a.repo ?? '', ref: a.ref ?? DEFAULT_BRANCH, playbook: a.playbook ?? '',
|
|
188
|
+
...(Object.keys(extra).length ? { extra } : {}),
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const extra = Object.fromEntries(Object.entries(c).filter(([k]) => !FORM_CAPABILITY_FIELDS.has(k)))
|
|
192
|
+
return {
|
|
193
|
+
name: c.name ?? '',
|
|
194
|
+
logo: c.logo ?? '',
|
|
195
|
+
capabilityClass,
|
|
196
|
+
supportedDeploymentTypes: capabilityClass === 'DeploymentCapability' ? [...(c.supportedDeploymentTypes ?? [])] : [],
|
|
197
|
+
types: TYPE_ORDER.filter(t => (c.type ?? []).includes(t)),
|
|
198
|
+
actions,
|
|
199
|
+
playbookContract: c.playbookContract ?? '',
|
|
200
|
+
...(c.id ? { id: c.id } : {}),
|
|
201
|
+
...(Object.keys(extraActions).length ? { extraActions } : {}),
|
|
202
|
+
...(Object.keys(extra).length ? { extra } : {}),
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function importErrorMessage(e: unknown): string {
|
|
207
|
+
const message = (e as { response?: { data?: { message?: unknown } } })?.response?.data?.message
|
|
208
|
+
return typeof message === 'string' && message ? message : 'Failed to import capability'
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// id: used when the form has no id of its own (i.e. the capability was not imported)
|
|
212
|
+
export function buildCapabilityRequest(form: CapabilityFormData, id?: string): GetCapabilities200ResponseInner {
|
|
213
|
+
const name = form.name.trim()
|
|
214
|
+
const actions: Record<string, unknown> = { ...(form.extraActions ?? {}) }
|
|
215
|
+
for (const actionType of requiredActions(form)) {
|
|
216
|
+
const a = form.actions[actionType] ?? newActionFormData()
|
|
217
|
+
actions[actionType] = {
|
|
218
|
+
connectionTypes: ['ssh'],
|
|
219
|
+
skipable: false,
|
|
220
|
+
configParameters: [],
|
|
221
|
+
...(a.extra ?? {}),
|
|
222
|
+
actionClass: 'AnsibleAction',
|
|
223
|
+
actionType,
|
|
224
|
+
repo: a.repo.trim(),
|
|
225
|
+
ref: a.ref.trim(),
|
|
226
|
+
playbook: a.playbook.trim(),
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const effectiveId = form.id ?? id
|
|
230
|
+
const body: Record<string, unknown> = {
|
|
231
|
+
...(form.extra ?? {}),
|
|
232
|
+
...(effectiveId !== undefined ? { id: effectiveId } : {}),
|
|
233
|
+
capabilityClass: form.capabilityClass,
|
|
234
|
+
name,
|
|
235
|
+
logo: form.logo.trim() || fallbackLogo(name),
|
|
236
|
+
type: effectiveTypes(form),
|
|
237
|
+
playbookContract: form.playbookContract.trim(),
|
|
238
|
+
actions,
|
|
239
|
+
}
|
|
240
|
+
if (form.capabilityClass === 'DeploymentCapability') {
|
|
241
|
+
body.supportedDeploymentTypes = form.supportedDeploymentTypes
|
|
242
|
+
}
|
|
243
|
+
return body as unknown as GetCapabilities200ResponseInner
|
|
244
|
+
}
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
import {useTheme} from "vuetify";
|
|
218
218
|
import {useNotificationStore} from "@/stores/notificationStore";
|
|
219
219
|
import {useStore} from "@/stores/store";
|
|
220
|
-
import {globals} from "@/
|
|
220
|
+
import {globals} from "@/app/appInstance";
|
|
221
221
|
|
|
222
222
|
export default {
|
|
223
223
|
name: 'DashboardCoreAppBar',
|
|
@@ -153,6 +153,16 @@ export default {
|
|
|
153
153
|
@use 'vuetify/lib/styles/tools/_rtl.sass' as *
|
|
154
154
|
|
|
155
155
|
#core-navigation-drawer
|
|
156
|
+
// Vuetify adds the group's prepend width (40px) to the child indent. Set it through Vuetify's own
|
|
157
|
+
// variable: overriding --prepend-width directly only works when our CSS happens to load after Vuetify's.
|
|
158
|
+
--v-list-group-prepend: 0px
|
|
159
|
+
|
|
160
|
+
.v-list-group
|
|
161
|
+
--list-indent-size: 8px
|
|
162
|
+
|
|
163
|
+
.v-list-group--sub-group .v-list-group__items
|
|
164
|
+
--indent-padding: 24px
|
|
165
|
+
|
|
156
166
|
.v-list-group__header.v-list-item--active:before
|
|
157
167
|
opacity: .24
|
|
158
168
|
|
|
@@ -180,10 +190,10 @@ export default {
|
|
|
180
190
|
.v-list-group--sub-group
|
|
181
191
|
.v-list-item
|
|
182
192
|
+ltr()
|
|
183
|
-
padding-left:
|
|
193
|
+
padding-left: 4px
|
|
184
194
|
|
|
185
195
|
+rtl()
|
|
186
|
-
padding-right:
|
|
196
|
+
padding-right: 4px
|
|
187
197
|
|
|
188
198
|
.v-list-group__header
|
|
189
199
|
+ltr()
|
|
@@ -0,0 +1,413 @@
|
|
|
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
|
+
<v-alert
|
|
142
|
+
v-if="logPurgedNotice"
|
|
143
|
+
type="info"
|
|
144
|
+
variant="tonal"
|
|
145
|
+
icon="mdi-broom"
|
|
146
|
+
>
|
|
147
|
+
{{ logPurgedNotice }}
|
|
148
|
+
</v-alert>
|
|
149
|
+
<div
|
|
150
|
+
v-else
|
|
151
|
+
class="d-flex align-center mb-1"
|
|
152
|
+
>
|
|
153
|
+
<v-chip
|
|
154
|
+
v-if="streaming"
|
|
155
|
+
size="x-small"
|
|
156
|
+
color="primary"
|
|
157
|
+
prepend-icon="mdi-access-point"
|
|
158
|
+
>
|
|
159
|
+
live
|
|
160
|
+
</v-chip>
|
|
161
|
+
<v-spacer />
|
|
162
|
+
<v-checkbox
|
|
163
|
+
v-model="followLog"
|
|
164
|
+
label="Follow"
|
|
165
|
+
density="compact"
|
|
166
|
+
hide-details
|
|
167
|
+
/>
|
|
168
|
+
</div>
|
|
169
|
+
<pre
|
|
170
|
+
v-if="!logPurgedNotice"
|
|
171
|
+
ref="logElement"
|
|
172
|
+
class="job-log"
|
|
173
|
+
>{{ logText }}</pre>
|
|
174
|
+
</v-window-item>
|
|
175
|
+
|
|
176
|
+
<v-window-item value="events">
|
|
177
|
+
<v-data-table
|
|
178
|
+
:headers="eventHeaders"
|
|
179
|
+
:items="events"
|
|
180
|
+
item-key="counter"
|
|
181
|
+
density="compact"
|
|
182
|
+
:items-per-page="25"
|
|
183
|
+
>
|
|
184
|
+
<template #item.failed="{ item }">
|
|
185
|
+
<v-icon
|
|
186
|
+
v-if="item.failed"
|
|
187
|
+
color="error"
|
|
188
|
+
>
|
|
189
|
+
mdi-alert-circle-outline
|
|
190
|
+
</v-icon>
|
|
191
|
+
</template>
|
|
192
|
+
<template #item.created="{ item }">
|
|
193
|
+
{{ formatJobDate(item.created) }}
|
|
194
|
+
</template>
|
|
195
|
+
</v-data-table>
|
|
196
|
+
</v-window-item>
|
|
197
|
+
|
|
198
|
+
<v-window-item value="recap">
|
|
199
|
+
<v-data-table
|
|
200
|
+
v-if="recapItems.length > 0"
|
|
201
|
+
:headers="recapHeaders"
|
|
202
|
+
:items="recapItems"
|
|
203
|
+
item-key="host"
|
|
204
|
+
density="compact"
|
|
205
|
+
hide-default-footer
|
|
206
|
+
/>
|
|
207
|
+
<no-item-available-note
|
|
208
|
+
v-else
|
|
209
|
+
item="play recap"
|
|
210
|
+
/>
|
|
211
|
+
</v-window-item>
|
|
212
|
+
</v-window>
|
|
213
|
+
</base-material-card>
|
|
214
|
+
|
|
215
|
+
<v-dialog
|
|
216
|
+
v-model="cancelDialog"
|
|
217
|
+
max-width="420"
|
|
218
|
+
>
|
|
219
|
+
<v-card>
|
|
220
|
+
<v-card-title>Cancel job?</v-card-title>
|
|
221
|
+
<v-card-text>The running playbook will be stopped.</v-card-text>
|
|
222
|
+
<v-card-actions>
|
|
223
|
+
<v-spacer />
|
|
224
|
+
<v-btn @click="cancelDialog = false">
|
|
225
|
+
No
|
|
226
|
+
</v-btn>
|
|
227
|
+
<v-btn
|
|
228
|
+
color="error"
|
|
229
|
+
@click="cancelJob"
|
|
230
|
+
>
|
|
231
|
+
Cancel job
|
|
232
|
+
</v-btn>
|
|
233
|
+
</v-card-actions>
|
|
234
|
+
</v-card>
|
|
235
|
+
</v-dialog>
|
|
236
|
+
</v-container>
|
|
237
|
+
</template>
|
|
238
|
+
|
|
239
|
+
<script setup lang="ts">
|
|
240
|
+
import {computed, nextTick, onBeforeUnmount, onMounted, ref, watch} from "vue";
|
|
241
|
+
import OverviewHeading from "@/components/base/OverviewHeading.vue";
|
|
242
|
+
import NoItemAvailableNote from "@/components/base/NoItemAvailableNote.vue";
|
|
243
|
+
import JobStatusChip from "@/components/jobs/JobStatusChip.vue";
|
|
244
|
+
import AnsibleServiceClient from "@/api/ansible-service/ansible-service-client";
|
|
245
|
+
import {streamJobLogs} from "@/api/ansible-service/ansible-service-sse";
|
|
246
|
+
import type {AnsibleJobDTO, AnsibleJobEventDTO} from "@/api/ansible-service/client";
|
|
247
|
+
import {formatDuration, formatJobDate, isFinalJobStatus, jobDurationMs, jobLogPurgedNotice} from "@/utils/jobStatus";
|
|
248
|
+
import {useJobsStore} from "@/stores/jobsStore";
|
|
249
|
+
|
|
250
|
+
const props = defineProps<{ jobId: string }>();
|
|
251
|
+
|
|
252
|
+
const jobsStore = useJobsStore();
|
|
253
|
+
const job = ref<AnsibleJobDTO | null>(null);
|
|
254
|
+
const events = ref<AnsibleJobEventDTO[]>([]);
|
|
255
|
+
const logLines = ref<string[]>([]);
|
|
256
|
+
const loading = ref(true);
|
|
257
|
+
const notFound = ref(false);
|
|
258
|
+
const streaming = ref(false);
|
|
259
|
+
const tab = ref('logs');
|
|
260
|
+
const followLog = ref(true);
|
|
261
|
+
const cancelDialog = ref(false);
|
|
262
|
+
const cancelling = ref(false);
|
|
263
|
+
const cancelError = ref('');
|
|
264
|
+
const now = ref(Date.now());
|
|
265
|
+
const logElement = ref<HTMLElement | null>(null);
|
|
266
|
+
|
|
267
|
+
let closeStream: (() => void) | null = null;
|
|
268
|
+
let ticker: ReturnType<typeof setInterval> | null = null;
|
|
269
|
+
let poller: ReturnType<typeof setInterval> | null = null;
|
|
270
|
+
|
|
271
|
+
const isFinal = computed(() => isFinalJobStatus(job.value?.status));
|
|
272
|
+
const logText = computed(() => logLines.value.join('\n'));
|
|
273
|
+
// the log retention of the ansible_service removed the log (the job and its events are kept)
|
|
274
|
+
const logPurgedNotice = computed(() => jobLogPurgedNotice(job.value));
|
|
275
|
+
|
|
276
|
+
const eventHeaders = [
|
|
277
|
+
{title: '#', key: 'counter'},
|
|
278
|
+
{title: 'Event', key: 'event'},
|
|
279
|
+
{title: 'Host', key: 'host'},
|
|
280
|
+
{title: 'Task', key: 'task'},
|
|
281
|
+
{title: 'Failed', key: 'failed'},
|
|
282
|
+
{title: 'Time', key: 'created'},
|
|
283
|
+
];
|
|
284
|
+
const recapHeaders = [
|
|
285
|
+
{title: 'Host', key: 'host'},
|
|
286
|
+
{title: 'ok', key: 'ok'},
|
|
287
|
+
{title: 'changed', key: 'changed'},
|
|
288
|
+
{title: 'failures', key: 'failures'},
|
|
289
|
+
{title: 'unreachable', key: 'unreachable'},
|
|
290
|
+
{title: 'skipped', key: 'skipped'},
|
|
291
|
+
{title: 'rescued', key: 'rescued'},
|
|
292
|
+
{title: 'ignored', key: 'ignored'},
|
|
293
|
+
];
|
|
294
|
+
const recapItems = computed(() =>
|
|
295
|
+
Object.entries(job.value?.recap ?? {}).map(([host, recap]) => ({host, ...recap})));
|
|
296
|
+
|
|
297
|
+
async function loadJob() {
|
|
298
|
+
try {
|
|
299
|
+
job.value = (await AnsibleServiceClient.jobsApi.getJob(props.jobId)).data;
|
|
300
|
+
} catch (e: any) {
|
|
301
|
+
if (e?.response?.status === 404) notFound.value = true;
|
|
302
|
+
else console.error(e);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
async function loadEvents() {
|
|
307
|
+
try {
|
|
308
|
+
events.value = (await AnsibleServiceClient.jobsApi.getJobEvents(props.jobId)).data;
|
|
309
|
+
} catch (e) {
|
|
310
|
+
console.error(e);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function loadFullLog() {
|
|
315
|
+
if (logPurgedNotice.value) {
|
|
316
|
+
logLines.value = [];
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
try {
|
|
320
|
+
const text = (await AnsibleServiceClient.jobsApi.getJobLogs(props.jobId)).data as unknown as string;
|
|
321
|
+
logLines.value = text ? text.replace(/\n$/, '').split('\n') : [];
|
|
322
|
+
} catch (e) {
|
|
323
|
+
console.error(e);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function stopStream() {
|
|
328
|
+
closeStream?.();
|
|
329
|
+
closeStream = null;
|
|
330
|
+
streaming.value = false;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function startStream() {
|
|
334
|
+
stopStream();
|
|
335
|
+
streaming.value = true;
|
|
336
|
+
closeStream = streamJobLogs(props.jobId, {
|
|
337
|
+
onLog: (line) => { logLines.value.push(line); },
|
|
338
|
+
// a re-opened stream may replay already known lines: start from an empty buffer
|
|
339
|
+
onReconnect: () => { logLines.value = []; },
|
|
340
|
+
onStatus: async () => {
|
|
341
|
+
stopStream();
|
|
342
|
+
await Promise.all([loadJob(), loadEvents(), loadFullLog()]);
|
|
343
|
+
jobsStore.getJobs().catch(() => undefined);
|
|
344
|
+
},
|
|
345
|
+
onError: (e) => console.warn('Job log stream error', e),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async function cancelJob() {
|
|
350
|
+
cancelDialog.value = false;
|
|
351
|
+
cancelling.value = true;
|
|
352
|
+
cancelError.value = '';
|
|
353
|
+
try {
|
|
354
|
+
await AnsibleServiceClient.jobsApi.cancelJob(props.jobId);
|
|
355
|
+
await loadJob();
|
|
356
|
+
} catch (e: any) {
|
|
357
|
+
cancelError.value = e?.response?.status === 409
|
|
358
|
+
? (e.response.data?.detail ?? 'Job cannot be canceled any more')
|
|
359
|
+
: 'Cancel failed';
|
|
360
|
+
await loadJob();
|
|
361
|
+
} finally {
|
|
362
|
+
cancelling.value = false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
watch(logLines, () => {
|
|
367
|
+
if (followLog.value) {
|
|
368
|
+
nextTick(() => {
|
|
369
|
+
if (logElement.value) logElement.value.scrollTop = logElement.value.scrollHeight;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}, {deep: true});
|
|
373
|
+
|
|
374
|
+
onMounted(async () => {
|
|
375
|
+
await loadJob();
|
|
376
|
+
loading.value = false;
|
|
377
|
+
if (!job.value) return;
|
|
378
|
+
await Promise.all([loadEvents(), loadFullLog()]);
|
|
379
|
+
if (!isFinal.value) {
|
|
380
|
+
startStream();
|
|
381
|
+
}
|
|
382
|
+
ticker = setInterval(() => { now.value = Date.now(); }, 1000);
|
|
383
|
+
// job status (PENDING -> RUNNING), events and recap are refreshed while the job is active
|
|
384
|
+
poller = setInterval(async () => {
|
|
385
|
+
if (isFinal.value) return;
|
|
386
|
+
await Promise.all([loadJob(), loadEvents()]);
|
|
387
|
+
if (isFinal.value) {
|
|
388
|
+
stopStream();
|
|
389
|
+
await loadFullLog();
|
|
390
|
+
}
|
|
391
|
+
}, 3000);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
onBeforeUnmount(() => {
|
|
395
|
+
stopStream();
|
|
396
|
+
if (ticker) clearInterval(ticker);
|
|
397
|
+
if (poller) clearInterval(poller);
|
|
398
|
+
});
|
|
399
|
+
</script>
|
|
400
|
+
|
|
401
|
+
<style scoped>
|
|
402
|
+
.job-log {
|
|
403
|
+
background: #1e1e1e;
|
|
404
|
+
color: #d4d4d4;
|
|
405
|
+
font-family: monospace;
|
|
406
|
+
font-size: 0.85rem;
|
|
407
|
+
padding: 12px;
|
|
408
|
+
height: 480px;
|
|
409
|
+
overflow: auto;
|
|
410
|
+
white-space: pre-wrap;
|
|
411
|
+
word-break: break-all;
|
|
412
|
+
}
|
|
413
|
+
</style>
|