@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.
Files changed (67) hide show
  1. package/README.md +8 -0
  2. package/package.json +9 -7
  3. package/src/api/ansible-service/ansible-service-client.ts +15 -0
  4. package/src/api/ansible-service/ansible-service-sse.ts +124 -0
  5. package/src/api/notification-service/notificationServiceWebsocketClient.js +5 -5
  6. package/src/api/platform-management/platform-management-client.ts +2 -2
  7. package/src/api/resource-management/resource-management-client.ts +0 -2
  8. package/src/app/appInstance.ts +8 -0
  9. package/src/app/navigation.ts +21 -0
  10. package/src/app/routes.ts +23 -0
  11. package/src/components/admin/ansible/AnsibleAdminImages.vue +113 -0
  12. package/src/components/admin/ansible/AnsibleAdminJobs.vue +179 -0
  13. package/src/components/admin/ansible/AnsibleAdminOperations.vue +124 -0
  14. package/src/components/base/ConfirmDialog.vue +39 -25
  15. package/src/components/base/CustomDialog.vue +31 -3
  16. package/src/components/base/IconPickerDialog.vue +155 -0
  17. package/src/components/capabilities/CapabilitiesTable.vue +209 -0
  18. package/src/components/capabilities/CapabilityActionCard.vue +77 -0
  19. package/src/components/capabilities/CapabilityCreateDialog.vue +86 -0
  20. package/src/components/capabilities/CapabilityCreateForm.vue +306 -0
  21. package/src/components/capabilities/CapabilityImportDialog.vue +108 -0
  22. package/src/components/capabilities/capabilityForm.ts +244 -0
  23. package/src/components/core/AppBar.vue +1 -1
  24. package/src/components/core/Drawer.vue +12 -2
  25. package/src/components/jobs/JobDetail.vue +413 -0
  26. package/src/components/jobs/JobStatusChip.vue +16 -0
  27. package/src/components/jobs/JobsOverview.vue +59 -72
  28. package/src/components/profilers/ProfilerDialog.vue +95 -0
  29. package/src/components/profilers/ProfilerForm.vue +102 -0
  30. package/src/components/profilers/ProfilersTable.vue +98 -0
  31. package/src/components/profilers/profilerForm.ts +61 -0
  32. package/src/components/resources/deviceinfo/DeviceInfoView.vue +9 -1
  33. package/src/components/resources/dialogs/AddItemChooserDialog.vue +68 -0
  34. package/src/components/service_offerings/ServiceOfferingCardGrid.vue +1 -1
  35. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionDockerCompose.vue +1 -2
  36. package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionKubernetes.vue +1 -2
  37. package/src/components/service_vendors/ServiceVendorDevelopersTable.vue +1 -1
  38. package/src/docker/entrypoint.sh +2 -2
  39. package/src/localisation/en.json +93 -0
  40. package/src/main.ts +3 -6
  41. package/src/pages/AdminAnsibleServicePage.vue +111 -0
  42. package/src/pages/AdminCapabilitiesPage.vue +60 -0
  43. package/src/pages/AdminProfilersPage.vue +73 -0
  44. package/src/pages/DashboardPage.vue +28 -56
  45. package/src/pages/JobDetailPage.vue +7 -0
  46. package/src/pages/ResourceInstancesPage.vue +71 -0
  47. package/src/pages/ServiceOfferingCreateOrEditPage.vue +2 -2
  48. package/src/stores/ansibleAdminStore.ts +206 -0
  49. package/src/stores/capabilitiesStore.ts +45 -2
  50. package/src/stores/environmentStore.ts +3 -3
  51. package/src/stores/jobsStore.ts +39 -39
  52. package/src/stores/notificationStore.ts +15 -1
  53. package/src/stores/profilersStore.ts +80 -0
  54. package/src/stores/resourceDevicesStore.ts +2 -2
  55. package/src/stores/serviceInstancesStore.ts +0 -1
  56. package/src/stores/serviceOfferingsStore.ts +1 -1
  57. package/src/stores/userStore.ts +1 -1
  58. package/src/utils/i18n.ts +4 -2
  59. package/src/utils/imageUtil.js +1 -1
  60. package/src/utils/jobStatus.ts +76 -0
  61. package/src/utils/mdiIcons.ts +49 -0
  62. package/src/utils/notificationTextGenerator.ts +27 -1
  63. package/src/utils/tokenInterceptor.js +1 -1
  64. package/src/utils/updateToken.js +1 -1
  65. package/vite/dist/apiClients.d.ts +1 -1
  66. package/vite/dist/apiClients.js +1 -0
  67. package/vite/dist/index.js +25 -4
@@ -1,5 +1,4 @@
1
1
  import ApiState from '@/api/apiState.js'
2
- import {UUID} from "vue-uuid";
3
2
  import {defineStore} from "pinia";
4
3
  import logRequestError from "@/api/restApiHelper";
5
4
  import ServiceManagementClient from "@/api/service-management/service-management-client";
@@ -1,5 +1,5 @@
1
1
  import ApiState from '@/api/apiState.js'
2
- import {UUID} from "vue-uuid";
2
+ type UUID = string;
3
3
  import {defineStore} from "pinia";
4
4
  import logRequestError from "@/api/restApiHelper";
5
5
  import ServiceManagementClient from "@/api/service-management/service-management-client";
@@ -1,6 +1,6 @@
1
1
  import ApiState from '@/api/apiState'
2
2
  import {defineStore} from "pinia";
3
- import {globals} from "@/main";
3
+ import {globals} from "@/app/appInstance";
4
4
 
5
5
  interface KeycloakLike {
6
6
  authenticated?: boolean,
package/src/utils/i18n.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  import { createI18n } from 'vue-i18n';
2
2
  import {de, en} from "vuetify/locale";
3
3
  import customizeMessages from "@/customization/customizeMessages";
4
+ import enMessages from "@/localisation/en.json";
5
+ import deMessages from "@/localisation/de.json";
4
6
 
5
7
  const messages = customizeMessages({
6
8
  en: {
7
- ...require('@/localisation/en.json'),
9
+ ...enMessages,
8
10
  $vuetify: en,
9
11
  },
10
12
  de: {
11
- ...require('@/localisation/de.json'),
13
+ ...deMessages,
12
14
  $vuetify: de,
13
15
  },
14
16
  });
@@ -33,5 +33,5 @@ export default function getImageUrl (imageData) {
33
33
  return `data:${mimeType};base64,${normalizedImageData}`
34
34
  }
35
35
 
36
- return 'noImage'
36
+ return undefined
37
37
  }
@@ -0,0 +1,76 @@
1
+ import type {AnsibleJobStatus} from "@/api/ansible-service/client";
2
+
3
+ export const JOB_STATUSES: AnsibleJobStatus[] = [
4
+ 'PENDING', 'PREPARING', 'RUNNING', 'SUCCESSFUL', 'FAILED', 'CANCELED', 'TIMED_OUT',
5
+ ] as AnsibleJobStatus[];
6
+
7
+ const FINAL_STATUSES = ['SUCCESSFUL', 'FAILED', 'CANCELED', 'TIMED_OUT'];
8
+
9
+ export function isFinalJobStatus(status?: string | null): boolean {
10
+ return !!status && FINAL_STATUSES.includes(status);
11
+ }
12
+
13
+ export function jobStatusColor(status?: string | null): string {
14
+ switch (status) {
15
+ case 'PENDING': return 'grey';
16
+ case 'PREPARING': return 'info';
17
+ case 'RUNNING': return 'primary';
18
+ case 'SUCCESSFUL': return 'success';
19
+ case 'FAILED': return 'error';
20
+ case 'CANCELED': return 'warning';
21
+ case 'TIMED_OUT': return 'orange-darken-2';
22
+ default: return 'grey';
23
+ }
24
+ }
25
+
26
+ export function jobStatusIcon(status?: string | null): string {
27
+ switch (status) {
28
+ case 'PENDING': return 'mdi-timer-sand-empty';
29
+ case 'PREPARING': return 'mdi-cog-sync-outline';
30
+ case 'RUNNING': return 'mdi-run-fast';
31
+ case 'SUCCESSFUL': return 'mdi-check-circle-outline';
32
+ case 'FAILED': return 'mdi-alert-circle-outline';
33
+ case 'CANCELED': return 'mdi-cancel';
34
+ case 'TIMED_OUT': return 'mdi-clock-alert-outline';
35
+ default: return 'mdi-help-circle-outline';
36
+ }
37
+ }
38
+
39
+ export function jobStatusLabel(status?: string | null): string {
40
+ return (status ?? '').replace('_', ' ');
41
+ }
42
+
43
+ export function formatJobDate(time?: string | Date | null): string {
44
+ if (!time) return '';
45
+ return new Date(time).toLocaleString('de-DE');
46
+ }
47
+
48
+ /** Duration of a job in ms: started to finished, or started to now while it is still running. */
49
+ export function jobDurationMs(job: {startedAt?: string | Date | null, finishedAt?: string | Date | null}, now = Date.now()): number | null {
50
+ if (!job.startedAt) return null;
51
+ const end = job.finishedAt ? new Date(job.finishedAt).getTime() : now;
52
+ return Math.max(0, end - new Date(job.startedAt).getTime());
53
+ }
54
+
55
+ export function formatDuration(ms: number | null): string {
56
+ if (ms === null) return '';
57
+ const totalSeconds = Math.floor(ms / 1000);
58
+ const hours = Math.floor(totalSeconds / 3600);
59
+ const minutes = Math.floor((totalSeconds / 60) % 60);
60
+ const seconds = totalSeconds % 60;
61
+ if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
62
+ return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
63
+ }
64
+
65
+ /**
66
+ * Notice for a job whose log was removed by the log retention of the ansible_service (logsPurgedAt set), or null if
67
+ * the log is available. Tells when it was removed and the retention that applied, so a removed log is not mistaken
68
+ * for a job that never wrote one.
69
+ */
70
+ export function jobLogPurgedNotice(job?: {logsPurgedAt?: string | Date | null, logRetentionDays?: number | null} | null): string | null {
71
+ if (!job?.logsPurgedAt) return null;
72
+ const days = job.logRetentionDays;
73
+ const retention = days != null && days > 0 ? ` (retention ${days} ${days === 1 ? 'day' : 'days'})` : '';
74
+ return `Log removed by the log retention cleanup on ${formatJobDate(job.logsPurgedAt)}${retention}. `
75
+ + 'Status, times, events and play recap of the job are kept.';
76
+ }
@@ -0,0 +1,49 @@
1
+ export const MDI_META_URL = 'https://cdn.jsdelivr.net/npm/@mdi/svg@latest/meta.json'
2
+
3
+ export interface MdiIconMeta {
4
+ name: string
5
+ aliases: string[]
6
+ tags: string[]
7
+ deprecated: boolean
8
+ }
9
+
10
+ let cache: Promise<MdiIconMeta[]> | null = null
11
+
12
+ export function resetMdiIconCache(): void {
13
+ cache = null
14
+ }
15
+
16
+ export function loadMdiIcons(fetchFn: typeof fetch = fetch): Promise<MdiIconMeta[]> {
17
+ if (cache) return cache
18
+ const pending = (async () => {
19
+ const response = await fetchFn(MDI_META_URL)
20
+ if (!response.ok) {
21
+ throw new Error(`Failed to load MDI icon list (HTTP ${response.status})`)
22
+ }
23
+ const data = (await response.json()) as MdiIconMeta[]
24
+ return data
25
+ .filter((icon) => !icon.deprecated)
26
+ .map((icon) => ({
27
+ name: icon.name,
28
+ aliases: icon.aliases ?? [],
29
+ tags: icon.tags ?? [],
30
+ deprecated: false,
31
+ }))
32
+ })()
33
+ cache = pending
34
+ pending.catch(() => {
35
+ if (cache === pending) cache = null
36
+ })
37
+ return pending
38
+ }
39
+
40
+ export function filterIcons(icons: MdiIconMeta[], query: string | null | undefined): MdiIconMeta[] {
41
+ const q = (query ?? '').trim().toLowerCase()
42
+ if (!q) return icons
43
+ return icons.filter(
44
+ (icon) =>
45
+ icon.name.toLowerCase().includes(q) ||
46
+ icon.aliases.some((a) => a.toLowerCase().includes(q)) ||
47
+ icon.tags.some((t) => t.toLowerCase().includes(q)),
48
+ )
49
+ }
@@ -6,7 +6,8 @@ import {
6
6
  FirmwareUpdateJobEventNotification,
7
7
  DiscoveryJobEventNotification,
8
8
  CapabilityJobEventNotification,
9
- ServiceInstanceEventNotification, ServiceInstanceEventType
9
+ ServiceInstanceEventNotification, ServiceInstanceEventType,
10
+ AasEventNotification, AasEventType, AasElementKind
10
11
  } from "@/api/notification-service/client";
11
12
  import {useCapabilitiesStore} from "@/stores/capabilitiesStore";
12
13
  import {useResourceDevicesStore} from "@/stores/resourceDevicesStore";
@@ -71,6 +72,31 @@ class NotificationTextGenerator {
71
72
  }
72
73
  }
73
74
 
75
+ case EVENTCLASS.AasEvent: {
76
+ const aasEventNotification = eventNotification as unknown as AasEventNotification;
77
+ const resourceDevicesStore = useResourceDevicesStore();
78
+ const resource = resourceDevicesStore.resourceById(aasEventNotification.resourceId);
79
+ const resourceName = resource?.hostname ?? aasEventNotification.resourceId;
80
+ const submodelName = aasEventNotification.submodelIdShort ?? aasEventNotification.submodelId;
81
+ const action = aasEventNotification.eventType.toLowerCase();
82
+
83
+ switch (aasEventNotification.elementKind) {
84
+ case AasElementKind.Shell: {
85
+ return `AAS of resource '${resourceName}' ${action}`
86
+ }
87
+ case AasElementKind.Submodel: {
88
+ return `Submodel '${submodelName}' of resource '${resourceName}' ${action}`
89
+ }
90
+ case AasElementKind.SubmodelReference: {
91
+ if (aasEventNotification.eventType === AasEventType.Created) {
92
+ return `Submodel '${submodelName}' added to resource '${resourceName}'`
93
+ }
94
+ return `Submodel '${submodelName}' removed from resource '${resourceName}'`
95
+ }
96
+ }
97
+ break;
98
+ }
99
+
74
100
  default:
75
101
  return "Message not defined"
76
102
  }
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import {globals} from "@/main";
2
+ import {globals} from "@/app/appInstance";
3
3
  import {useEnvStore} from "@/stores/environmentStore";
4
4
  import updateToken from "@/utils/updateToken";
5
5
 
@@ -1,4 +1,4 @@
1
- import {globals} from "@/main";
1
+ import {globals} from "@/app/appInstance";
2
2
 
3
3
  export default async function () {
4
4
  if(globals.$keycloak?.keycloak?.updateToken !== undefined) {
@@ -1,5 +1,5 @@
1
1
  import type { Plugin } from 'vite';
2
2
  import { type SlmPathsSource } from './paths.js';
3
- export declare const API_SERVICES: readonly ["resource-management", "platform-management", "service-management", "notification-service"];
3
+ export declare const API_SERVICES: readonly ["resource-management", "platform-management", "service-management", "notification-service", "ansible-service"];
4
4
  /** Redirects the (gitignored, generated) API clients of the package to the consumer's own generated clients. */
5
5
  export declare function apiClientsPlugin(pathsSource: SlmPathsSource): Plugin;
@@ -6,6 +6,7 @@ export const API_SERVICES = [
6
6
  'platform-management',
7
7
  'service-management',
8
8
  'notification-service',
9
+ 'ansible-service',
9
10
  ];
10
11
  function realIfExists(file) {
11
12
  try {
@@ -10,6 +10,12 @@ import { overridesPlugin } from './overrides.js';
10
10
  import { resolveSlmPaths } from './paths.js';
11
11
  // Under NodeNext the CJS typings expose the module namespace as default; at runtime default is the function.
12
12
  const commonjs = commonjsModule;
13
+ const SCAN_EXTENSIONS = '{vue,ts,js}';
14
+ /** Escapes glob syntax in a literal path (mirrors tinyglobby's `escapePath`, which Vite uses for entries). */
15
+ function escapeGlob(p) {
16
+ return p.replace(/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g, '\\$&');
17
+ }
18
+ const toPosix = (p) => p.split(path.sep).join('/');
13
19
  export function slmUi(options = {}) {
14
20
  const packageRoot = options.__packageRoot ?? path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
15
21
  const version = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8')).version;
@@ -23,6 +29,8 @@ export function slmUi(options = {}) {
23
29
  state.consumerRoot = consumerRoot;
24
30
  state.paths = resolveSlmPaths(options, consumerRoot, packageRoot);
25
31
  const { packageSrc } = state.paths;
32
+ // Lexical (not realpath'd) like `root`, so the root-relative entry glob below stays valid.
33
+ const overridesDir = options.overridesDir && path.resolve(consumerRoot, options.overridesDir);
26
34
  return {
27
35
  root: packageRoot,
28
36
  envDir: consumerRoot,
@@ -36,9 +44,21 @@ export function slmUi(options = {}) {
36
44
  alias: { '@': packageSrc },
37
45
  extensions: ['.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
38
46
  },
39
- // The package src lives under node_modules, so without this Vite's dep scanner would prebundle raw `@/...`
40
- // imports with esbuild, bypassing the slm plugins (API-client redirect, overrides).
41
- optimizeDeps: { exclude: ['@', '@slm-original'] },
47
+ optimizeDeps: {
48
+ // The package src lives under node_modules, so without this Vite's dep scanner would prebundle raw `@/...`
49
+ // imports with esbuild, bypassing the slm plugins (API-client redirect, overrides).
50
+ exclude: ['@', '@slm-original'],
51
+ // That exclude stops the scanner at every `@/...` import, so it would never reach the package's third-party
52
+ // (often CommonJS) imports and they would be served unbundled. Scanning every source file as an entry finds
53
+ // them again. Patterns are relative to the root (the package itself): Vite's `**/node_modules/**` entry
54
+ // ignore is matched against root-relative paths, so it does not hit the package src under node_modules.
55
+ entries: [
56
+ `src/**/*.${SCAN_EXTENSIONS}`,
57
+ ...(overridesDir
58
+ ? [`${escapeGlob(toPosix(path.relative(packageRoot, overridesDir)))}/**/*.${SCAN_EXTENSIONS}`]
59
+ : []),
60
+ ],
61
+ },
42
62
  server: { fs: { allow: [packageRoot, consumerRoot] } },
43
63
  };
44
64
  },
@@ -67,7 +87,8 @@ export function slmUi(options = {}) {
67
87
  overridesPlugin(paths),
68
88
  driftCheckPlugin(paths, { allowNewFiles: options.allowNewFiles ?? false, version }),
69
89
  vue({ template: { transformAssetUrls } }),
70
- commonjs(),
90
+ // vite-plugin-commonjs skips every id containing node_modules, which is where consumers have the package src.
91
+ commonjs({ filter: (id) => (id.startsWith(toPosix(paths().packageSrc) + '/') ? true : undefined) }),
71
92
  vuetify({ autoImport: true }),
72
93
  ];
73
94
  }