@eclipse-slm/ui 1.5.0-snapshot.883 → 1.5.0-snapshot.956
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
package/README.md
CHANGED
|
@@ -238,6 +238,7 @@ The package does **not** ship the generated API clients. The consumer must gener
|
|
|
238
238
|
<apiClientsDir>/platform-management/client/index.ts
|
|
239
239
|
<apiClientsDir>/service-management/client/index.ts
|
|
240
240
|
<apiClientsDir>/notification-service/client/index.ts
|
|
241
|
+
<apiClientsDir>/ansible-service/client/index.ts
|
|
241
242
|
```
|
|
242
243
|
|
|
243
244
|
`ui/pom.xml` in this repository is the reference configuration (generator, input specs and output directories). If a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-slm/ui",
|
|
3
|
-
"version": "1.5.0-snapshot.
|
|
3
|
+
"version": "1.5.0-snapshot.956",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"prepack": "npm run build:plugin"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"vue": "^3.4.27",
|
|
40
|
-
"vuetify": "^3.6.9",
|
|
41
39
|
"pinia": "^2.1.4",
|
|
42
|
-
"
|
|
40
|
+
"vite": "^7.3.1",
|
|
41
|
+
"vue": "^3.4.27",
|
|
43
42
|
"vue-i18n": "^11.2.8",
|
|
44
|
-
"
|
|
43
|
+
"vue-router": "^4.3.2",
|
|
44
|
+
"vuetify": "^3.6.9"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@dsb-norge/vue-keycloak-js": "3.0.3",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"cors": "^2.8.6",
|
|
59
59
|
"dot-properties": "^1.0.1",
|
|
60
60
|
"js-base64": "^3.7.7",
|
|
61
|
-
"jsonpath": "^
|
|
61
|
+
"jsonpath-plus": "^11.3.0",
|
|
62
62
|
"localforage": "^1.10.0",
|
|
63
63
|
"lodash": "^4.17.23",
|
|
64
64
|
"material-design-icons-iconfont": "^6.7.0",
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"vue-enums": "^1.0.0",
|
|
79
79
|
"vue-json-pretty": "1.7.1",
|
|
80
80
|
"vue-toast-notification": "^3.1.2",
|
|
81
|
-
"vue-uuid": "^3.0.0",
|
|
82
81
|
"websocket": "^1.0.34",
|
|
83
82
|
"yaml": "^2.7.0",
|
|
84
83
|
"yup": "^1.4.0"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {AdminApi, JobsApi} from "@/api/ansible-service/client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AnsibleServiceClient {
|
|
5
|
+
|
|
6
|
+
api = "/ansible-service";
|
|
7
|
+
|
|
8
|
+
jobsApi = new JobsApi(undefined, this.api);
|
|
9
|
+
|
|
10
|
+
adminApi = new AdminApi(undefined, this.api);
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export default new AnsibleServiceClient();
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {globals} from "@/main";
|
|
2
|
+
import updateToken from "@/utils/updateToken";
|
|
3
|
+
import AnsibleServiceClient from "@/api/ansible-service/ansible-service-client";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Fetch based Server-Sent-Events client for the live log of a job (GET /jobs/{id}/logs/stream).
|
|
7
|
+
* EventSource cannot send an Authorization header, so the stream is read from a fetch response body.
|
|
8
|
+
* The access token is refreshed before every (re)connect; a dropped stream is re-opened with back-off until
|
|
9
|
+
* the final 'status' event arrives or the stream is closed.
|
|
10
|
+
*/
|
|
11
|
+
export interface JobLogStreamHandlers {
|
|
12
|
+
/** One log line. */
|
|
13
|
+
onLog: (line: string) => void;
|
|
14
|
+
/** Final status name; the stream is complete afterwards. */
|
|
15
|
+
onStatus: (status: string) => void;
|
|
16
|
+
/** Called before a re-connect: the server may replay the log, so the consumer should reset its buffer. */
|
|
17
|
+
onReconnect?: () => void;
|
|
18
|
+
onError?: (error: unknown) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface SseMessage {
|
|
22
|
+
event: string;
|
|
23
|
+
data: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Parses one SSE block (text between blank lines). Returns null for comment/keep-alive blocks. */
|
|
27
|
+
export function parseSseBlock(block: string): SseMessage | null {
|
|
28
|
+
let event = 'message';
|
|
29
|
+
const data: string[] = [];
|
|
30
|
+
for (const rawLine of block.split('\n')) {
|
|
31
|
+
const line = rawLine.endsWith('\r') ? rawLine.slice(0, -1) : rawLine;
|
|
32
|
+
if (line === '' || line.startsWith(':')) continue;
|
|
33
|
+
const idx = line.indexOf(':');
|
|
34
|
+
const field = idx === -1 ? line : line.slice(0, idx);
|
|
35
|
+
let value = idx === -1 ? '' : line.slice(idx + 1);
|
|
36
|
+
if (value.startsWith(' ')) value = value.slice(1);
|
|
37
|
+
if (field === 'event') event = value;
|
|
38
|
+
else if (field === 'data') data.push(value);
|
|
39
|
+
}
|
|
40
|
+
return data.length === 0 ? null : {event, data: data.join('\n')};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function readStream(response: Response, signal: AbortSignal, dispatch: (m: SseMessage) => boolean): Promise<boolean> {
|
|
44
|
+
const reader = response.body!.getReader();
|
|
45
|
+
const decoder = new TextDecoder();
|
|
46
|
+
let buffer = '';
|
|
47
|
+
try {
|
|
48
|
+
while (!signal.aborted) {
|
|
49
|
+
const {done, value} = await reader.read();
|
|
50
|
+
if (done) return false;
|
|
51
|
+
buffer += decoder.decode(value, {stream: true}).replace(/\r\n/g, '\n');
|
|
52
|
+
let sep: number;
|
|
53
|
+
while ((sep = buffer.indexOf('\n\n')) !== -1) {
|
|
54
|
+
const message = parseSseBlock(buffer.slice(0, sep));
|
|
55
|
+
buffer = buffer.slice(sep + 2);
|
|
56
|
+
if (message && dispatch(message)) return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
} finally {
|
|
61
|
+
reader.cancel().catch(() => undefined);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const sleep = (ms: number, signal: AbortSignal) => new Promise<void>(resolve => {
|
|
66
|
+
const timer = setTimeout(resolve, ms);
|
|
67
|
+
signal.addEventListener('abort', () => { clearTimeout(timer); resolve(); }, {once: true});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/** Starts streaming; returns a function that closes the stream. */
|
|
71
|
+
export function streamJobLogs(jobId: string, handlers: JobLogStreamHandlers): () => void {
|
|
72
|
+
const controller = new AbortController();
|
|
73
|
+
const signal = controller.signal;
|
|
74
|
+
|
|
75
|
+
const run = async () => {
|
|
76
|
+
let attempt = 0;
|
|
77
|
+
let connectedBefore = false;
|
|
78
|
+
while (!signal.aborted) {
|
|
79
|
+
try {
|
|
80
|
+
await updateToken();
|
|
81
|
+
const token = globals.$keycloak?.token;
|
|
82
|
+
const response = await fetch(`${AnsibleServiceClient.api}/jobs/${encodeURIComponent(jobId)}/logs/stream`, {
|
|
83
|
+
headers: {
|
|
84
|
+
Accept: 'text/event-stream',
|
|
85
|
+
...(token ? {Authorization: `Bearer ${token}`} : {}),
|
|
86
|
+
},
|
|
87
|
+
signal,
|
|
88
|
+
});
|
|
89
|
+
if (response.status === 401) {
|
|
90
|
+
// token expired while connecting: refresh happens at the top of the next attempt
|
|
91
|
+
throw new Error('Unauthorized');
|
|
92
|
+
}
|
|
93
|
+
if (response.status === 404 || response.status === 403) {
|
|
94
|
+
handlers.onError?.(new Error(`Log stream not available (${response.status})`));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!response.ok || !response.body) {
|
|
98
|
+
throw new Error(`Log stream failed (${response.status})`);
|
|
99
|
+
}
|
|
100
|
+
if (connectedBefore) handlers.onReconnect?.();
|
|
101
|
+
connectedBefore = true;
|
|
102
|
+
attempt = 0;
|
|
103
|
+
const finished = await readStream(response, signal, (message) => {
|
|
104
|
+
if (message.event === 'log') {
|
|
105
|
+
handlers.onLog(message.data);
|
|
106
|
+
} else if (message.event === 'status') {
|
|
107
|
+
handlers.onStatus(message.data);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
});
|
|
112
|
+
if (finished) return;
|
|
113
|
+
} catch (e) {
|
|
114
|
+
if (signal.aborted) return;
|
|
115
|
+
handlers.onError?.(e);
|
|
116
|
+
}
|
|
117
|
+
attempt++;
|
|
118
|
+
await sleep(Math.min(1000 * 2 ** Math.min(attempt, 5), 30000), signal);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
run();
|
|
122
|
+
|
|
123
|
+
return () => controller.abort();
|
|
124
|
+
}
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
CapabilityProvidersApi,
|
|
4
4
|
ClustersApi, CredentialsApi,
|
|
5
5
|
DiscoveryApi,
|
|
6
|
-
JobsApi,
|
|
7
6
|
LocationApi,
|
|
8
7
|
MetricsApi,
|
|
9
8
|
ProfilerApi,
|
|
@@ -23,7 +22,6 @@ class ResourceManagementClient{
|
|
|
23
22
|
submodelTemplatesRestControllerApi = new SubmodelTemplatesApi(undefined, this.apiUrl);
|
|
24
23
|
clusterApi = new ClustersApi(undefined, this.apiUrl)
|
|
25
24
|
credentialsApi = new CredentialsApi(undefined, this.apiUrl)
|
|
26
|
-
jobApi = new JobsApi(undefined, this.apiUrl);
|
|
27
25
|
locationApi = new LocationApi(undefined, this.apiUrl);
|
|
28
26
|
metricsApi = new MetricsApi(undefined, this.apiUrl);
|
|
29
27
|
profilerApi = new ProfilerApi(undefined, this.apiUrl);
|
package/src/app/navigation.ts
CHANGED
|
@@ -184,6 +184,20 @@ export const defaultNavigation: NavItem[] = [
|
|
|
184
184
|
to: 'capabilities',
|
|
185
185
|
visible: isAdmin,
|
|
186
186
|
},
|
|
187
|
+
{
|
|
188
|
+
id: 'main-menu-button-admin-profilers',
|
|
189
|
+
titleKey: 'drawer.section.admin.profilers.title',
|
|
190
|
+
icon: 'mdi-file-search-outline',
|
|
191
|
+
to: 'profilers',
|
|
192
|
+
visible: isAdmin,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'main-menu-button-admin-ansible-service',
|
|
196
|
+
titleKey: 'drawer.section.admin.ansible-service.title',
|
|
197
|
+
icon: 'mdi-ansible',
|
|
198
|
+
to: 'ansible-service',
|
|
199
|
+
visible: isAdmin,
|
|
200
|
+
},
|
|
187
201
|
{
|
|
188
202
|
id: 'main-menu-button-admin-users',
|
|
189
203
|
// Original used the literal string 'User Management' (no i18n key); kept as-is.
|
package/src/app/routes.ts
CHANGED
|
@@ -39,6 +39,11 @@ export const defaultRoutes: RouteRecordRaw[] = [
|
|
|
39
39
|
path: '/jobs',
|
|
40
40
|
component: () => import('@/pages/JobsPage.vue'),
|
|
41
41
|
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Job Details',
|
|
44
|
+
path: '/jobs/:id',
|
|
45
|
+
component: () => import('@/pages/JobDetailPage.vue'),
|
|
46
|
+
},
|
|
42
47
|
// Discovery
|
|
43
48
|
{
|
|
44
49
|
name: 'Discovery Inbox',
|
|
@@ -187,6 +192,18 @@ export const defaultRoutes: RouteRecordRaw[] = [
|
|
|
187
192
|
component: () => import('@/pages/AdminCapabilitiesPage.vue'),
|
|
188
193
|
meta: { adminPermissionRequired: true },
|
|
189
194
|
},
|
|
195
|
+
{
|
|
196
|
+
name: 'AdminProfilers',
|
|
197
|
+
path: '/admin/profilers',
|
|
198
|
+
component: () => import('@/pages/AdminProfilersPage.vue'),
|
|
199
|
+
meta: { adminPermissionRequired: true },
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: 'AdminAnsibleService',
|
|
203
|
+
path: '/admin/ansible-service',
|
|
204
|
+
component: () => import('@/pages/AdminAnsibleServicePage.vue'),
|
|
205
|
+
meta: { adminPermissionRequired: true },
|
|
206
|
+
},
|
|
190
207
|
{
|
|
191
208
|
name: 'AdminUsers',
|
|
192
209
|
path: '/admin/users',
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-data-table
|
|
3
|
+
id="ansible-admin-images"
|
|
4
|
+
:headers="headers"
|
|
5
|
+
:items="store.images"
|
|
6
|
+
item-key="image"
|
|
7
|
+
>
|
|
8
|
+
<template #item.image="{ item }">
|
|
9
|
+
{{ item.image }}
|
|
10
|
+
<v-chip
|
|
11
|
+
v-if="item.isDefault"
|
|
12
|
+
size="x-small"
|
|
13
|
+
color="primary"
|
|
14
|
+
class="ml-2"
|
|
15
|
+
>
|
|
16
|
+
{{ t(`${prefix}.default`) }}
|
|
17
|
+
</v-chip>
|
|
18
|
+
</template>
|
|
19
|
+
<template #item.present="{ item }">
|
|
20
|
+
<v-chip
|
|
21
|
+
size="small"
|
|
22
|
+
:color="item.present ? 'success' : 'grey'"
|
|
23
|
+
variant="flat"
|
|
24
|
+
>
|
|
25
|
+
{{ item.present ? t(`${prefix}.present`) : t(`${prefix}.missing`) }}
|
|
26
|
+
</v-chip>
|
|
27
|
+
</template>
|
|
28
|
+
<template #item.usedByJobs="{ item }">
|
|
29
|
+
{{ t(`${prefix}.usedByJobs`, {count: item.usedByJobs ?? 0}) }}
|
|
30
|
+
</template>
|
|
31
|
+
<template #item.lastUsedAt="{ item }">
|
|
32
|
+
{{ formatJobDate(item.lastUsedAt) }}
|
|
33
|
+
</template>
|
|
34
|
+
<template #item.pulling="{ item }">
|
|
35
|
+
<v-chip
|
|
36
|
+
v-if="item.pulling"
|
|
37
|
+
size="small"
|
|
38
|
+
color="info"
|
|
39
|
+
variant="flat"
|
|
40
|
+
>
|
|
41
|
+
<v-progress-circular
|
|
42
|
+
size="14"
|
|
43
|
+
width="2"
|
|
44
|
+
indeterminate
|
|
45
|
+
class="mr-2"
|
|
46
|
+
/>
|
|
47
|
+
{{ t(`${prefix}.pulling`) }}
|
|
48
|
+
</v-chip>
|
|
49
|
+
<v-chip
|
|
50
|
+
v-else-if="item.lastPullError"
|
|
51
|
+
size="small"
|
|
52
|
+
color="error"
|
|
53
|
+
variant="flat"
|
|
54
|
+
>
|
|
55
|
+
{{ t(`${prefix}.pullFailed`) }}
|
|
56
|
+
<v-tooltip
|
|
57
|
+
activator="parent"
|
|
58
|
+
location="top"
|
|
59
|
+
>
|
|
60
|
+
{{ item.lastPullError }}
|
|
61
|
+
</v-tooltip>
|
|
62
|
+
</v-chip>
|
|
63
|
+
<v-chip
|
|
64
|
+
v-else-if="item.present"
|
|
65
|
+
size="small"
|
|
66
|
+
color="success"
|
|
67
|
+
variant="tonal"
|
|
68
|
+
>
|
|
69
|
+
{{ t(`${prefix}.present`) }}
|
|
70
|
+
</v-chip>
|
|
71
|
+
<span v-else>-</span>
|
|
72
|
+
</template>
|
|
73
|
+
<template #item.lastPullError="{ item }">
|
|
74
|
+
<span class="text-error">{{ item.lastPullError }}</span>
|
|
75
|
+
</template>
|
|
76
|
+
<template #item.actions="{ item }">
|
|
77
|
+
<v-btn
|
|
78
|
+
size="small"
|
|
79
|
+
color="primary"
|
|
80
|
+
variant="tonal"
|
|
81
|
+
prepend-icon="mdi-download"
|
|
82
|
+
:disabled="item.pulling"
|
|
83
|
+
@click="store.pullImage(item.image!)"
|
|
84
|
+
>
|
|
85
|
+
{{ t(`${prefix}.pull`) }}
|
|
86
|
+
</v-btn>
|
|
87
|
+
</template>
|
|
88
|
+
<template #no-data>
|
|
89
|
+
{{ t(`${prefix}.empty`) }}
|
|
90
|
+
</template>
|
|
91
|
+
</v-data-table>
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<script setup lang="ts">
|
|
95
|
+
import {computed} from "vue";
|
|
96
|
+
import {useI18n} from "vue-i18n";
|
|
97
|
+
import {useAnsibleAdminStore} from "@/stores/ansibleAdminStore";
|
|
98
|
+
import {formatJobDate} from "@/utils/jobStatus";
|
|
99
|
+
|
|
100
|
+
const {t} = useI18n();
|
|
101
|
+
const store = useAnsibleAdminStore();
|
|
102
|
+
const prefix = 'drawer.section.admin.ansible-service.images';
|
|
103
|
+
|
|
104
|
+
const headers = computed(() => [
|
|
105
|
+
{title: t(`${prefix}.column.image`), key: 'image'},
|
|
106
|
+
{title: t(`${prefix}.column.present`), key: 'present'},
|
|
107
|
+
{title: t(`${prefix}.column.usedByJobs`), key: 'usedByJobs'},
|
|
108
|
+
{title: t(`${prefix}.column.lastUsedAt`), key: 'lastUsedAt'},
|
|
109
|
+
{title: t(`${prefix}.column.pulling`), key: 'pulling'},
|
|
110
|
+
{title: t(`${prefix}.column.lastPullError`), key: 'lastPullError', sortable: false},
|
|
111
|
+
{title: t(`${prefix}.column.actions`), key: 'actions', sortable: false},
|
|
112
|
+
]);
|
|
113
|
+
</script>
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="ansible-admin-jobs">
|
|
3
|
+
<v-row dense>
|
|
4
|
+
<v-col
|
|
5
|
+
cols="12"
|
|
6
|
+
md="3"
|
|
7
|
+
>
|
|
8
|
+
<v-select
|
|
9
|
+
v-model="filter.status"
|
|
10
|
+
:items="JOB_STATUSES"
|
|
11
|
+
:label="t('drawer.section.admin.ansible-service.jobs.filter.status')"
|
|
12
|
+
clearable
|
|
13
|
+
density="compact"
|
|
14
|
+
/>
|
|
15
|
+
</v-col>
|
|
16
|
+
<v-col
|
|
17
|
+
cols="12"
|
|
18
|
+
md="3"
|
|
19
|
+
>
|
|
20
|
+
<v-text-field
|
|
21
|
+
v-model="filter.resourceId"
|
|
22
|
+
:label="t('drawer.section.admin.ansible-service.jobs.filter.resourceId')"
|
|
23
|
+
:rules="[resourceIdRule]"
|
|
24
|
+
clearable
|
|
25
|
+
density="compact"
|
|
26
|
+
/>
|
|
27
|
+
</v-col>
|
|
28
|
+
<v-col
|
|
29
|
+
cols="12"
|
|
30
|
+
md="3"
|
|
31
|
+
>
|
|
32
|
+
<v-text-field
|
|
33
|
+
v-model="filter.user"
|
|
34
|
+
:label="t('drawer.section.admin.ansible-service.jobs.filter.user')"
|
|
35
|
+
clearable
|
|
36
|
+
density="compact"
|
|
37
|
+
/>
|
|
38
|
+
</v-col>
|
|
39
|
+
<v-col
|
|
40
|
+
cols="12"
|
|
41
|
+
md="3"
|
|
42
|
+
>
|
|
43
|
+
<v-select
|
|
44
|
+
v-model="filter.since"
|
|
45
|
+
:items="sinceItems"
|
|
46
|
+
:label="t('drawer.section.admin.ansible-service.jobs.filter.since')"
|
|
47
|
+
density="compact"
|
|
48
|
+
/>
|
|
49
|
+
</v-col>
|
|
50
|
+
</v-row>
|
|
51
|
+
|
|
52
|
+
<v-data-table
|
|
53
|
+
v-model:sort-by="sortBy"
|
|
54
|
+
:headers="headers"
|
|
55
|
+
:items="store.jobs"
|
|
56
|
+
item-key="id"
|
|
57
|
+
hover
|
|
58
|
+
@click:row="(_event: unknown, row: { item: AnsibleJobDTO }) => openJob(row.item.id)"
|
|
59
|
+
>
|
|
60
|
+
<template #item.status="{ item }">
|
|
61
|
+
<job-status-chip :status="item.status" />
|
|
62
|
+
</template>
|
|
63
|
+
<template #item.service="{ item }">
|
|
64
|
+
{{ item.serviceName || '' }}
|
|
65
|
+
</template>
|
|
66
|
+
<template #item.playbook="{ item }">
|
|
67
|
+
<span v-if="item.repo">{{ item.repo }}<span v-if="item.ref">@{{ item.ref }}</span></span>
|
|
68
|
+
<div class="text-caption">
|
|
69
|
+
{{ item.playbook }}
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
72
|
+
<template #item.createdAt="{ item }">
|
|
73
|
+
{{ formatJobDate(item.createdAt) }}
|
|
74
|
+
</template>
|
|
75
|
+
<template #item.duration="{ item }">
|
|
76
|
+
{{ formatDuration(jobDurationMs(item, now)) }}
|
|
77
|
+
</template>
|
|
78
|
+
<template #item.errorCode="{ item }">
|
|
79
|
+
<span :title="item.errorMessage">{{ item.errorCode }}</span>
|
|
80
|
+
</template>
|
|
81
|
+
<template #item.actions="{ item }">
|
|
82
|
+
<v-btn
|
|
83
|
+
v-if="!isFinalJobStatus(item.status)"
|
|
84
|
+
size="small"
|
|
85
|
+
color="warning"
|
|
86
|
+
variant="tonal"
|
|
87
|
+
prepend-icon="mdi-cancel"
|
|
88
|
+
@click.stop="cancel(item.id)"
|
|
89
|
+
>
|
|
90
|
+
{{ t('drawer.section.admin.ansible-service.jobs.cancel') }}
|
|
91
|
+
</v-btn>
|
|
92
|
+
</template>
|
|
93
|
+
<template #no-data>
|
|
94
|
+
{{ t('drawer.section.admin.ansible-service.jobs.empty') }}
|
|
95
|
+
</template>
|
|
96
|
+
</v-data-table>
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
|
|
100
|
+
<script setup lang="ts">
|
|
101
|
+
import {computed, onBeforeUnmount, onMounted, reactive, ref, watch} from "vue";
|
|
102
|
+
import {useRouter} from "vue-router";
|
|
103
|
+
import {useI18n} from "vue-i18n";
|
|
104
|
+
import type {AnsibleJobDTO} from "@/api/ansible-service/client";
|
|
105
|
+
import JobStatusChip from "@/components/jobs/JobStatusChip.vue";
|
|
106
|
+
import {isUuid, useAnsibleAdminStore} from "@/stores/ansibleAdminStore";
|
|
107
|
+
import type {SinceRange} from "@/stores/ansibleAdminStore";
|
|
108
|
+
import {JOB_STATUSES, formatDuration, formatJobDate, isFinalJobStatus, jobDurationMs} from "@/utils/jobStatus";
|
|
109
|
+
|
|
110
|
+
const emit = defineEmits<{ (e: 'cancel-failed', id: string): void }>();
|
|
111
|
+
|
|
112
|
+
const {t} = useI18n();
|
|
113
|
+
const router = useRouter();
|
|
114
|
+
const store = useAnsibleAdminStore();
|
|
115
|
+
|
|
116
|
+
const filter = reactive({...store.filter});
|
|
117
|
+
const sortBy = ref([{key: 'createdAt', order: 'desc' as const}]);
|
|
118
|
+
const now = ref(Date.now());
|
|
119
|
+
let ticker: ReturnType<typeof setInterval> | null = null;
|
|
120
|
+
|
|
121
|
+
const sinceItems = computed(() => (['1h', '24h', '7d', '30d', 'all'] as SinceRange[]).map(value => ({
|
|
122
|
+
value,
|
|
123
|
+
title: t(`drawer.section.admin.ansible-service.jobs.filter.${value === 'all' ? 'sinceAll' : 'since' + value}`),
|
|
124
|
+
})));
|
|
125
|
+
|
|
126
|
+
const headers = computed(() => {
|
|
127
|
+
const col = (key: string) => t(`drawer.section.admin.ansible-service.jobs.column.${key}`);
|
|
128
|
+
return [
|
|
129
|
+
{title: col('status'), key: 'status'},
|
|
130
|
+
{title: col('owner'), key: 'owner'},
|
|
131
|
+
{title: col('service'), key: 'service', value: (item: AnsibleJobDTO) => item.serviceName ?? ''},
|
|
132
|
+
{title: col('playbook'), key: 'playbook', value: (item: AnsibleJobDTO) => `${item.repo ?? ''} ${item.playbook ?? ''}`},
|
|
133
|
+
{title: col('image'), key: 'image'},
|
|
134
|
+
{title: col('createdAt'), key: 'createdAt'},
|
|
135
|
+
{title: col('duration'), key: 'duration', sortable: false},
|
|
136
|
+
{title: col('errorCode'), key: 'errorCode'},
|
|
137
|
+
{title: col('actions'), key: 'actions', sortable: false},
|
|
138
|
+
];
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
function resourceIdRule(value: string | null) {
|
|
142
|
+
return !value || isUuid(value) || t('drawer.section.admin.ansible-service.jobs.filter.resourceIdInvalid');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let debounce: ReturnType<typeof setTimeout> | null = null;
|
|
146
|
+
watch(filter, () => {
|
|
147
|
+
if (debounce) clearTimeout(debounce);
|
|
148
|
+
debounce = setTimeout(() => {
|
|
149
|
+
// a cleared v-text-field yields null
|
|
150
|
+
store.loadAdminJobs({
|
|
151
|
+
status: filter.status ?? null,
|
|
152
|
+
resourceId: filter.resourceId ?? '',
|
|
153
|
+
user: filter.user ?? '',
|
|
154
|
+
since: filter.since,
|
|
155
|
+
}).catch(() => undefined);
|
|
156
|
+
}, 300);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
function openJob(id?: string) {
|
|
160
|
+
if (id) router.push({path: `/jobs/${id}`});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function cancel(id?: string) {
|
|
164
|
+
if (!id) return;
|
|
165
|
+
try {
|
|
166
|
+
await store.cancelJob(id);
|
|
167
|
+
} catch {
|
|
168
|
+
emit('cancel-failed', id);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
onMounted(() => {
|
|
173
|
+
ticker = setInterval(() => { now.value = Date.now(); }, 1000);
|
|
174
|
+
});
|
|
175
|
+
onBeforeUnmount(() => {
|
|
176
|
+
if (ticker) clearInterval(ticker);
|
|
177
|
+
if (debounce) clearTimeout(debounce);
|
|
178
|
+
});
|
|
179
|
+
</script>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="ansible-admin-operations">
|
|
3
|
+
<v-row>
|
|
4
|
+
<v-col
|
|
5
|
+
v-for="card in statCards"
|
|
6
|
+
:key="card.key"
|
|
7
|
+
cols="6"
|
|
8
|
+
md="3"
|
|
9
|
+
>
|
|
10
|
+
<v-card
|
|
11
|
+
:color="card.highlight ? card.color : undefined"
|
|
12
|
+
:variant="card.highlight ? 'tonal' : 'outlined'"
|
|
13
|
+
>
|
|
14
|
+
<v-card-text>
|
|
15
|
+
<div class="text-caption">
|
|
16
|
+
{{ card.title }}
|
|
17
|
+
</div>
|
|
18
|
+
<div class="text-h4">
|
|
19
|
+
{{ card.value }}
|
|
20
|
+
</div>
|
|
21
|
+
</v-card-text>
|
|
22
|
+
</v-card>
|
|
23
|
+
</v-col>
|
|
24
|
+
</v-row>
|
|
25
|
+
|
|
26
|
+
<v-row>
|
|
27
|
+
<v-col
|
|
28
|
+
cols="12"
|
|
29
|
+
md="8"
|
|
30
|
+
>
|
|
31
|
+
<v-card variant="outlined">
|
|
32
|
+
<v-card-title>{{ t('drawer.section.admin.ansible-service.operations.config.title') }}</v-card-title>
|
|
33
|
+
<v-list
|
|
34
|
+
v-if="config"
|
|
35
|
+
density="compact"
|
|
36
|
+
>
|
|
37
|
+
<v-list-item
|
|
38
|
+
v-for="entry in configEntries"
|
|
39
|
+
:key="entry.key"
|
|
40
|
+
:title="entry.title"
|
|
41
|
+
:subtitle="entry.value"
|
|
42
|
+
/>
|
|
43
|
+
</v-list>
|
|
44
|
+
</v-card>
|
|
45
|
+
</v-col>
|
|
46
|
+
<v-col
|
|
47
|
+
cols="12"
|
|
48
|
+
md="4"
|
|
49
|
+
>
|
|
50
|
+
<v-card variant="outlined">
|
|
51
|
+
<v-card-title>{{ t('drawer.section.admin.ansible-service.operations.links.title') }}</v-card-title>
|
|
52
|
+
<v-list density="compact">
|
|
53
|
+
<v-list-item
|
|
54
|
+
href="/ansible-service/swagger-ui/index.html"
|
|
55
|
+
target="_blank"
|
|
56
|
+
rel="noopener"
|
|
57
|
+
prepend-icon="mdi-api"
|
|
58
|
+
:title="t('drawer.section.admin.ansible-service.operations.links.swagger')"
|
|
59
|
+
/>
|
|
60
|
+
<v-list-item
|
|
61
|
+
href="/ansible-service/v3/api-docs"
|
|
62
|
+
target="_blank"
|
|
63
|
+
rel="noopener"
|
|
64
|
+
prepend-icon="mdi-code-json"
|
|
65
|
+
:title="t('drawer.section.admin.ansible-service.operations.links.openapi')"
|
|
66
|
+
/>
|
|
67
|
+
</v-list>
|
|
68
|
+
</v-card>
|
|
69
|
+
</v-col>
|
|
70
|
+
</v-row>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script setup lang="ts">
|
|
75
|
+
import {computed} from "vue";
|
|
76
|
+
import {useI18n} from "vue-i18n";
|
|
77
|
+
import {useAnsibleAdminStore} from "@/stores/ansibleAdminStore";
|
|
78
|
+
import {JOB_STATUSES, jobStatusLabel} from "@/utils/jobStatus";
|
|
79
|
+
|
|
80
|
+
const {t} = useI18n();
|
|
81
|
+
const store = useAnsibleAdminStore();
|
|
82
|
+
const prefix = 'drawer.section.admin.ansible-service.operations';
|
|
83
|
+
|
|
84
|
+
const config = computed(() => store.status?.config);
|
|
85
|
+
|
|
86
|
+
const statCards = computed(() => {
|
|
87
|
+
const status = store.status;
|
|
88
|
+
const counts = status?.jobCounts ?? {};
|
|
89
|
+
const num = (n?: number) => n ?? 0;
|
|
90
|
+
return [
|
|
91
|
+
{key: 'running', title: t(`${prefix}.running`), value: num(status?.runningJobs), highlight: num(status?.runningJobs) > 0, color: 'primary'},
|
|
92
|
+
{key: 'queued', title: t(`${prefix}.queued`), value: num(status?.queuedJobs), highlight: num(status?.queuedJobs) > 0, color: 'warning'},
|
|
93
|
+
{key: 'failed24h', title: t(`${prefix}.failed24h`), value: num(status?.failedLast24h), highlight: num(status?.failedLast24h) > 0, color: 'error'},
|
|
94
|
+
...JOB_STATUSES.map(s => ({
|
|
95
|
+
key: s,
|
|
96
|
+
title: jobStatusLabel(s),
|
|
97
|
+
value: num((counts as Record<string, number>)[s]),
|
|
98
|
+
highlight: false,
|
|
99
|
+
color: 'primary',
|
|
100
|
+
})),
|
|
101
|
+
];
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const configEntries = computed(() => {
|
|
105
|
+
const c = config.value;
|
|
106
|
+
if (!c) return [];
|
|
107
|
+
const row = (key: string, value: unknown) => ({
|
|
108
|
+
key,
|
|
109
|
+
title: t(`${prefix}.config.${key}`),
|
|
110
|
+
value: Array.isArray(value) ? value.join(', ') : String(value ?? ''),
|
|
111
|
+
});
|
|
112
|
+
return [
|
|
113
|
+
row('playbookContract', store.status?.playbookContract),
|
|
114
|
+
row('defaultImage', c.defaultImage),
|
|
115
|
+
row('allowedImagePrefixes', c.allowedImagePrefixes),
|
|
116
|
+
row('parallelism', c.parallelism),
|
|
117
|
+
row('maxQueued', c.maxQueued),
|
|
118
|
+
row('defaultTimeoutMinutes', c.defaultTimeoutMinutes),
|
|
119
|
+
row('maxTimeoutMinutes', c.maxTimeoutMinutes),
|
|
120
|
+
row('maxCpus', c.maxCpus),
|
|
121
|
+
row('maxMemoryMb', c.maxMemoryMb),
|
|
122
|
+
];
|
|
123
|
+
});
|
|
124
|
+
</script>
|