@eclipse-slm/ui 1.5.0-snapshot.1 → 1.5.0-snapshot.1017
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
package/README.md
CHANGED
|
@@ -143,6 +143,9 @@ export default defineConfig({
|
|
|
143
143
|
})
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
+
`npm run dev` and `npm run build` work with this configuration alone; the plugin sets up dependency pre-bundling for
|
|
147
|
+
the package source in `node_modules`, so no extra `optimizeDeps` or CommonJS settings are needed.
|
|
148
|
+
|
|
146
149
|
Plugin options:
|
|
147
150
|
|
|
148
151
|
| Option | Default | Meaning |
|
|
@@ -215,6 +218,10 @@ export default function customizeApp(app: App): void {
|
|
|
215
218
|
}
|
|
216
219
|
```
|
|
217
220
|
|
|
221
|
+
The app instance itself lives in `@/app/appInstance` (`app`, and `globals` = `app.config.globalProperties`, e.g.
|
|
222
|
+
`globals.$keycloak`). `@/main` still re-exports `globals` for backward compatibility, but new code and overrides should
|
|
223
|
+
import from `@/app/appInstance`: any module importing `@/main` makes the dev server evaluate the entry a second time.
|
|
224
|
+
|
|
218
225
|
**`theme.ts`** (`src/customization/theme.ts`) is a default export `{ colors, variables }` used for the Vuetify theme:
|
|
219
226
|
|
|
220
227
|
```ts
|
|
@@ -231,6 +238,7 @@ The package does **not** ship the generated API clients. The consumer must gener
|
|
|
231
238
|
<apiClientsDir>/platform-management/client/index.ts
|
|
232
239
|
<apiClientsDir>/service-management/client/index.ts
|
|
233
240
|
<apiClientsDir>/notification-service/client/index.ts
|
|
241
|
+
<apiClientsDir>/ansible-service/client/index.ts
|
|
234
242
|
```
|
|
235
243
|
|
|
236
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.1017",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"src",
|
|
21
21
|
"!src/api/*/client",
|
|
22
|
+
"!src/**/*.test.ts",
|
|
22
23
|
"index.html",
|
|
23
24
|
"public",
|
|
24
25
|
"vite/dist",
|
|
@@ -29,17 +30,18 @@
|
|
|
29
30
|
"build": "vite build",
|
|
30
31
|
"serve": "vite preview",
|
|
31
32
|
"lint": "eslint --fix src",
|
|
33
|
+
"test:unit": "vitest run --config vitest.config.ts",
|
|
32
34
|
"test:plugin": "vitest run --config vite/vitest.config.ts",
|
|
33
35
|
"build:plugin": "tsc -p vite/tsconfig.json",
|
|
34
36
|
"prepack": "npm run build:plugin"
|
|
35
37
|
},
|
|
36
38
|
"peerDependencies": {
|
|
37
|
-
"vue": "^3.4.27",
|
|
38
|
-
"vuetify": "^3.6.9",
|
|
39
39
|
"pinia": "^2.1.4",
|
|
40
|
-
"
|
|
40
|
+
"vite": "^7.3.1",
|
|
41
|
+
"vue": "^3.4.27",
|
|
41
42
|
"vue-i18n": "^11.2.8",
|
|
42
|
-
"
|
|
43
|
+
"vue-router": "^4.3.2",
|
|
44
|
+
"vuetify": "^3.6.9"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
47
|
"@dsb-norge/vue-keycloak-js": "3.0.3",
|
|
@@ -56,7 +58,7 @@
|
|
|
56
58
|
"cors": "^2.8.6",
|
|
57
59
|
"dot-properties": "^1.0.1",
|
|
58
60
|
"js-base64": "^3.7.7",
|
|
59
|
-
"jsonpath": "^
|
|
61
|
+
"jsonpath-plus": "^11.3.0",
|
|
60
62
|
"localforage": "^1.10.0",
|
|
61
63
|
"lodash": "^4.17.23",
|
|
62
64
|
"material-design-icons-iconfont": "^6.7.0",
|
|
@@ -76,7 +78,6 @@
|
|
|
76
78
|
"vue-enums": "^1.0.0",
|
|
77
79
|
"vue-json-pretty": "1.7.1",
|
|
78
80
|
"vue-toast-notification": "^3.1.2",
|
|
79
|
-
"vue-uuid": "^3.0.0",
|
|
80
81
|
"websocket": "^1.0.34",
|
|
81
82
|
"yaml": "^2.7.0",
|
|
82
83
|
"yup": "^1.4.0"
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
"eslint-plugin-vue": "^9.32.0",
|
|
96
97
|
"eslint-plugin-vuetify": "^2.4.0",
|
|
97
98
|
"pinia": "^2.1.4",
|
|
99
|
+
"playwright": "^1.64.1",
|
|
98
100
|
"vite": "^7.3.1",
|
|
99
101
|
"vitest": "^5.0.5",
|
|
100
102
|
"vue": "^3.4.27",
|
|
@@ -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
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import SockJS from 'sockjs-client/dist/sockjs';
|
|
2
2
|
import Stomp from 'stomp-websocket';
|
|
3
3
|
import {useNotificationStore} from "@/stores/notificationStore";
|
|
4
|
-
import { globals } from '@/
|
|
4
|
+
import { globals } from '@/app/appInstance';
|
|
5
5
|
|
|
6
6
|
const API_URL = '/notification-service';
|
|
7
7
|
|
|
@@ -38,13 +38,13 @@ class NotificationServiceWebsocketClient {
|
|
|
38
38
|
Issuer: `${globals.$keycloak.keycloak.authServerUrl}/realms/${globals.$keycloak.keycloak.realm}`
|
|
39
39
|
},
|
|
40
40
|
() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// direct topic fallback for convertAndSend("/topic/notifications/{userId}", ...)
|
|
41
|
+
// The backend publishes every notification to both destinations, so subscribe to only one
|
|
42
|
+
// of them, otherwise each notification is processed (and toasted) twice
|
|
44
43
|
if (userId) {
|
|
45
44
|
this.stompClient.subscribe(subscriptionName, NotificationServiceWebsocketClient.processNotificationMessage);
|
|
46
45
|
} else {
|
|
47
|
-
console.warn('Unable to resolve websocket user id
|
|
46
|
+
console.warn('Unable to resolve websocket user id, falling back to /user/topic/notifications subscription')
|
|
47
|
+
this.stompClient.subscribe('/user/topic/notifications', NotificationServiceWebsocketClient.processNotificationMessage);
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
(error) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
CredentialManagementApi,
|
|
4
4
|
type UserCreateRequest,
|
|
5
5
|
} from "@/api/platform-management/client";
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ class PlatformManagementClient{
|
|
|
16
16
|
|
|
17
17
|
apiUrl = "/platform-management";
|
|
18
18
|
|
|
19
|
-
credentialsApi = new
|
|
19
|
+
credentialsApi = new CredentialManagementApi(undefined, this.apiUrl);
|
|
20
20
|
|
|
21
21
|
async getUsers(): Promise<UserOverviewResponse[]> {
|
|
22
22
|
return axios
|
|
@@ -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);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createApp } from 'vue';
|
|
2
|
+
import App from '@/App.vue';
|
|
3
|
+
|
|
4
|
+
// The app lives in its own module so that other modules can reach it without importing the entry (main.ts):
|
|
5
|
+
// importing the entry from a module makes Vite (dev, package under node_modules) load a second copy of it.
|
|
6
|
+
export const app = createApp(App);
|
|
7
|
+
|
|
8
|
+
export const globals = app.config.globalProperties;
|
package/src/app/navigation.ts
CHANGED
|
@@ -177,6 +177,27 @@ export const defaultNavigation: NavItem[] = [
|
|
|
177
177
|
to: 'service-vendors',
|
|
178
178
|
visible: isAdmin,
|
|
179
179
|
},
|
|
180
|
+
{
|
|
181
|
+
id: 'main-menu-button-admin-capabilities',
|
|
182
|
+
titleKey: 'drawer.section.admin.capabilities.title',
|
|
183
|
+
icon: 'mdi-puzzle',
|
|
184
|
+
to: 'capabilities',
|
|
185
|
+
visible: isAdmin,
|
|
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
|
+
},
|
|
180
201
|
{
|
|
181
202
|
id: 'main-menu-button-admin-users',
|
|
182
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',
|
|
@@ -181,6 +186,24 @@ export const defaultRoutes: RouteRecordRaw[] = [
|
|
|
181
186
|
component: () => import('@/pages/AdminServiceVendorsPage.vue'),
|
|
182
187
|
meta: { adminPermissionRequired: true },
|
|
183
188
|
},
|
|
189
|
+
{
|
|
190
|
+
name: 'AdminCapabilities',
|
|
191
|
+
path: '/admin/capabilities',
|
|
192
|
+
component: () => import('@/pages/AdminCapabilitiesPage.vue'),
|
|
193
|
+
meta: { adminPermissionRequired: true },
|
|
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
|
+
},
|
|
184
207
|
{
|
|
185
208
|
name: 'AdminUsers',
|
|
186
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>
|