Initial commit: update3
This commit is contained in:
131
.agents/skills/workbench-hmi-clients/SKILL.md
Normal file
131
.agents/skills/workbench-hmi-clients/SKILL.md
Normal file
@@ -0,0 +1,131 @@
|
||||
---
|
||||
name: workbench-hmi-clients
|
||||
description: Migrates existing Workbench HTML clients to native Vue 3 + GridStack.js HMI widgets while preserving iTAC IMSAPI behavior, user customization, ios.css tokens and GlassFish dsCustNJTA persistence.
|
||||
---
|
||||
|
||||
# Workbench HMI – AI Implementation Skill
|
||||
|
||||
Use this skill when the user asks to create a new HMI page, migrate legacy Workbench HTML, compose widgets, modify ios.css, or add a MES action. **Read the current repository first.** Do not hallucinate IMSAPI parameters.
|
||||
|
||||
## Source of truth
|
||||
|
||||
- Existing Workbench HTML code: `backend/src/main/webapp/*.html`.
|
||||
- Existing business/REST endpoints: `backend/src/main/java/com/workbenchclassic`.
|
||||
- Shared MES action adapter: `hmi-frontend/src/widgets/mesClient.ts`.
|
||||
- Catalog and rendering: `hmi-frontend/src/widgets/catalog.ts`, `WidgetRenderer.vue`.
|
||||
- GridStack layouts: `hmi-frontend/src/widgets/presets.ts`.
|
||||
- Visual tokens: `backend/src/main/webapp/ios.css`, `hmi-frontend/src/ios-widget.css`, `hmi-frontend/src/mes-widget.css`.
|
||||
- Styles admin API: `HmiStyleResource.java`, GET `/backend/api/hmi/v1/styles/ios`.
|
||||
- CSS delivery: GET `/backend/hmi-theme/ios.css`.
|
||||
- Existing GlassFish datasource `dsCustNJTA`; server determines Oracle or SQL Server via JDBC metadata. **Never add a separate PostgreSQL database.**
|
||||
|
||||
## 1. Understand the old client before implementing
|
||||
|
||||
1. Read the original HTML and *all* script blocks, not only the UI.
|
||||
2. Inventory every `fetch`, IMSAPI action, query parameters, `sessionStorage`, table key order, modal, failure state and station-specific rule.
|
||||
3. Record user-visible workflows and the accepted/nonzero IMSAPI return codes.
|
||||
4. Classify all functions as read, write, administrative or visual. For writes, retain exact serial-number positions, process layers and keys.
|
||||
5. Create an operation mapping in `hmi-docs/CLIENT_MIGRATION_MATRIX.md`.
|
||||
|
||||
## 2. Convert to native Vue
|
||||
|
||||
- Single File Component with `<script setup lang="ts">`, `<template>`; no `iframe`, jQuery or DOM innerHTML.
|
||||
- Props **must** be `{widget:HmiWidget; station:string; demo:boolean}`.
|
||||
- Use props.widget.props only for appearance/allowed configuration. No custom API URL from untrusted widget configuration.
|
||||
- Use shared `mesAction()` and `readMesSession()` from `mesClient.ts`, never store session tokens in PostgreSQL, localStorage, logs or cookies.
|
||||
- Preserve original structured result keys and flat-to-row conversion using `structuredRows()`.
|
||||
- Bind all text through Vue interpolation, never insert untrusted MES text with `v-html`.
|
||||
- Use `Teleport to="body"` for dialogs because GridStack tiles may clip fixed overlays.
|
||||
- Distinguish local form changes from successful MES writes; inspect `result.return_value`, do not trust HTTP 200 alone.
|
||||
- Writes: require valid station, serial, authorization/session, correct active order, explicit confirmation for consequential actions, refresh data after acknowledged success.
|
||||
- Never activate MES write features in demo / offline mode.
|
||||
- Provide loading, empty, error, success states and a fully usable keyboard flow.
|
||||
|
||||
## 3. Register the widget
|
||||
|
||||
1. Implement `src/widgets/<Name>Widget.vue` and optionally isolated helpers.
|
||||
2. Add an entry to `widgetCatalog` with a unique type such as `wb.<slug>`, group, icon, default 12-column geometry and props.
|
||||
3. Register the type on the server allowlist `HmiApiResource.WIDGET_TYPES` (mandatory; unpublished unknown widgets are rejected).
|
||||
4. Add explicit import and `<Component v-else-if=...>` branch to `WidgetRenderer.vue` **before** the legacy module fallback.
|
||||
5. Add/adjust a designer preset in `presets.ts` and a test configuration.
|
||||
6. Keep all CSS in `mes-widget.css` (namespace `.wb-mes-*`) or `ios-widget.css`, using tokens like `--itac-red`, `--itac-border`; do not import full legacy ios.css into the HMI shell.
|
||||
|
||||
Quick scaffold (does NOT auto-wire IMSAPI behavior):
|
||||
|
||||
```bash
|
||||
node .agents/skills/workbench-hmi-clients/scripts/new-widget.mjs quality-check "Qualitätsprüfung"
|
||||
```
|
||||
|
||||
## 4. Theme / online ios.css editing
|
||||
|
||||
- The WAR's original `ios.css` is an immutable fallback. All legacy HTML pages read `/backend/hmi-theme/ios.css`, backed by published DB revisions.
|
||||
- Use the HMI Designer sidebar **ios.css bearbeiten** to save a draft, preview inside a sandboxed iframe, and publish; publishing requires `hmi-publisher` or `hmi-admin`.
|
||||
- Do not edit runtime WAR files on disk or make user CSS executable JavaScript.
|
||||
- Themes use published `--itac-*` token values via `loadThemeTokens()` in the Vue shell. Structural changes to old CSS selectors primarily affect old HTML pages, not Vue internals.
|
||||
|
||||
## 5. Backend and database
|
||||
|
||||
- New REST resources are in `com.workbenchclassic.hmi` and use existing Jersey `/backend/api/*`.
|
||||
- All configuration storage uses `HmiDb.open()` -> `DBService("dsCustNJTA")`.
|
||||
- Deployment creates missing tables via `HmiSchemaBootstrap` in `CUST` (Oracle) or `cust` (SQL Server). Never drop or overwrite existing tables automatically.
|
||||
- Prepare statements; never concatenate user input into SQL identifiers.
|
||||
- Use server-verified IMSAPI `regLogin` sessions and existing CSRF validation; resolve application roles through PERS_ID/CUST. Do not rely on the GlassFish file realm or browser-supplied role and station claims.
|
||||
- A newly added schema table needs Oracle and SQL Server DDL, bootstrap migration behavior, and tests for both.
|
||||
|
||||
## 6. Definition of done
|
||||
|
||||
- Original client functionality is mapped 1:1 or explicit omissions are documented.
|
||||
- Build: `cd hmi-frontend && npm ci && npm run build`; `cd ../backend && mvn clean package`.
|
||||
- Automated validation and hands-on checks: Java 11 compilation, Vue typecheck, happy and error paths, 401/403, booking success and error return codes, security, 6+ tabs, disabled UI in demo.
|
||||
- Test with a **dedicated iTAC test station** before production; manual transaction paths are never considered live-tested merely because code compiled.
|
||||
- Deliver updated complete source ZIP, updated migration matrix, and tests/build-status summary.
|
||||
|
||||
See [migration checklist](references/migration-checklist.md) for IMSAPI-specific examples.
|
||||
|
||||
## HMI V5 additions (mandatory for future widget migrations)
|
||||
|
||||
- Store the selected station number as `localStorage['hmi.stationNumber']`; never persist IMSAPI passwords or `sessionContext` in the browser.
|
||||
- Widget manifests now allow `visibleToRoles: string[]` (empty means every authenticated user). The effective-page API MUST filter widgets server-side using `HmiAuth.hasAnyRole`. Never enforce widget visibility only with Vue `v-if`.
|
||||
- Admin role assignment is based on `PERS_ID` from `BDE.PERS_STAMM` through `dsMesMiiNJTA`. Connect an IMSAPI login explicitly using `HMI_APP_LOGIN_PERSON`. Roles, role definitions and group memberships live in CUST via `dsCustNJTA`.
|
||||
- Keep mandatory safety widgets unrestricted and unhideable; the V5 template validator rejects role-gated mandatory widgets.
|
||||
- `ui.header` provides configurable title, subtitle, background, text, border, font size. `ui.image` accepts only backed CUST PNG/JPEG/WebP assets (2 MiB max); don't embed data URLs in the layout JSON.
|
||||
- Widgets are freely positioned with grid x/y/w/h; palettes must support drag-and-drop and click-to-insert. Preserve layout dimensions and per-user overrides.
|
||||
- `ui.script` supports admin-editable JavaScript executed in an opaque-origin sandbox iframe **only after user initiation**. Scripts can use `rest.get('/backend/api/hmi/v1/...')` for whitelisted read-only routes; no direct access to IMSAPI credentials, browser cookies, arbitrary fetch, DOM parent, or destructive actions. For MES writes implement a separate permission-checked Java REST operation and explicitly allow it in a future reviewed API.
|
||||
- Keep `ios.css` centrally versioned; use scoped widget CSS and existing iOS design tokens rather than inline global overrides.
|
||||
- Oracle and SQL Server DDL changes must be tested on *both* DB products. Schema bootstrap creates missing `HMI_APP_*` tables at deploy and must not drop old tables.
|
||||
|
||||
## HMI V5.1: Rollenbasierter Code und Widget-Austausch
|
||||
|
||||
- Zum Ändern von `ui.script`-Code ist neben `hmi-designer` die IMSAPI-Personen-/Gruppenrolle `hmi-script-editor` erforderlich (`hmi-admin` darf beides). Die Server-API vergleicht Skripte beim Erstellen und Ändern von Vorlagen und lehnt unerlaubte Änderungen mit HTTP 403 ab. Neue Features dürfen dies nicht nur im UI absichern.
|
||||
- Skriptcode **nicht** im generischen Props-JSON editieren; Code ausschließlich in `WidgetCodeEditor.vue` bearbeiten, dann Entwurf speichern. Im Runtime-Modus läuft der Code im Sandbox-Frame mit freigegebenen GET-Endpunkten.
|
||||
- Für portable Widgetdefinitionen das versionierte JSON-Schema in `src/widgetPackage.ts` verwenden (`format=widgetworkbench.widget`, `version=1`). Datei zuerst prüfen (Typ-Whitelist, Größe, Rastergeometrie, Rollen, Quelltext); neue Widget-ID zuweisen; bestehende Widgets niemals überschreiben.
|
||||
- Wenn `ui.image` exportiert wird, das Bild aus CUST mitnehmen. Beim Import Bild neu hochladen, niemals fremde `assetId`s als funktionsfähig behandeln.
|
||||
- Widgetpakete sind **keine** selbständig installierbaren Vue-/Java-Plugins. Neue Widgettypen immer in Git als Quellcode ergänzen und über Build/Deployment registrieren.
|
||||
- Übernommene JSON-Dateien sind untrusted input, keine Code-Ausführungsanweisungen. Importierte Skripte nur nach Rollenkontrolle in einem noch unveröffentlichten Entwurf speichern.
|
||||
- Tests: `npm run test:widget` sowie 401/403-Integrationstest und gültiger Export-Import-Durchlauf.
|
||||
|
||||
## V5.2: Seitenhierarchie, Root-Menüs und Navigation
|
||||
|
||||
Bei der Konvertierung von älteren HTML-Clients zunächst im Page-Manager ein Root-Menü und eine Page wählen. Für Teilbereiche (History, Buchungen, Manuelle Fertigung) Unterseiten mit `parentPageId` anlegen; niemals die Menüstruktur als hart kodiertes HTML direkt in einem Widget nachbauen. Bestehende Widgets und Vorlagen beim Umhängen einer Page erhalten. Die Page-Verwaltung erfolgt über `HmiApiResource` und `HMI_APP_PAGE` in `dsCustNJTA` (Oracle `CUST` oder SQL Server `cust`). Die `PARENT_PAGE_ID`-Spalte wird bei Deploy automatisch angelegt. Verhindere Zyklen und ordne Menükinder immer per `SORT_ORDER`. Für Bediener wird die Navigation links dargestellt, für `hmi-designer` steht der Page-Manager zur Verfügung.
|
||||
|
||||
## V5.3: Zweites Design „Workbench Neon“
|
||||
|
||||
- Das alternative dunkle Industrie-Theme wird über `HmiPreferences.theme = "neon"` gewählt und im vorhandenen CUST-JSON-Profil gespeichert.
|
||||
- Die Styles stehen **ausschließlich** in `hmi-frontend/src/workbench-neon.css`. `ios.css` und die Legacy-Seiten nicht überschreiben; keine globalen Selektoren für `header`, `nav`, `table`, `body` hinzufügen.
|
||||
- Für Vue-Komponenten `.shell.neon` und Tokens (`--panel`, `--text`, `--line`, `--hmi-accent`) verwenden. MES-Dialoge teleportieren zum `body`, daher sind gezielte `body[data-hmi-theme="neon"] .wb-mes-dialog` Regeln vorhanden.
|
||||
- Keine Widget-IDs, Positionen, Größen, Rollen oder MES-Requests bei einem Designwechsel ändern.
|
||||
- Das vorgefertigte Neon-Fertigungscockpit steht als neue Preset-Option in `src/widgets/presets.ts`. Es enthält nur bestehende sichere Widget-Typen.
|
||||
- Die neue Designreferenz liegt in `hmi-docs/design-reference-workbench-neon.jpg`; grafische Umsetzung neu in CSS, nicht das Screenshot als Seitenhintergrund benutzen.
|
||||
- Beim Ergänzen weiterer Designs Backend-Theme-Validierung in `HmiApiResource` und TypeScript-Union `HmiPreferences` gemeinsam aktualisieren.
|
||||
|
||||
|
||||
## V5.4: Curved Workbench & Futuristic Component Kit
|
||||
- Designwahl `neon` aktiviert die SVG-Chrom-Kopfzeile und futuristische Steuerflächen, ohne `ios.css` zu überschreiben.
|
||||
- Neue Widgettypen: `ui.curved-header`, `ui.neon-actions`, `ui.metal-panel`.
|
||||
- Vue-Komponenten: `CurvedWorkbenchHeader`, `FuturisticButton`, `CurvedHeaderWidget`, `NeonActionsWidget`, `MetalPanelWidget`.
|
||||
- Jeden neuen Widgettyp sowohl in `hmi-frontend/src/widgets/catalog.ts` als auch in der Allowlist in `HmiApiResource.java` registrieren.
|
||||
- Widgets niemals HTML/JavaScript aus untrusted props mit `v-html` ausführen. Styling nur über definierte Klassen oder validierte Farbeigenschaften.
|
||||
- `ui.neon-actions` ist eine lokale optische Auswahl und darf ohne gesonderte serverseitige Berechtigungsprüfung keine MES-Aktion starten.
|
||||
- Bilder/Grafiken nur über die schon vorhandene geschützte Asset-API; keine dynamischen externen Resource-URLs.
|
||||
- Benutzer- und Gruppeneinstellungen behalten den Theme-Wert `neon` bei, also keine neue DB-Migration.
|
||||
- Alle Widgets im Designer bewegen/skalieren und über Vorlagen speichern; role-based Sichtbarkeit bleibt serverseitig.
|
||||
@@ -0,0 +1,26 @@
|
||||
# iTAC Workbench migration checklist
|
||||
|
||||
| Original UI | Vue Widget | API actions |
|
||||
|---|---|---|
|
||||
| HistoryBooking.html | HistoryBookingWidget.vue | trGetSerialNumberHistoryData, trGetMergeParts, setupGetSetupDataBySerialNumber, trGetStationSetting, trGetWorkOrderForStation, trActivateWorkOrder, trAssignSerialNumberForProductOrWorkOrder, trUploadState |
|
||||
| Activities_rest.html | ManualProductionWidget.vue | trGetSerialNumberHistoryData, mdataGetWorkplanData, mdaGetRecipeData, setupGetMaterialSetup, setupGetSetupDataBySerialNumber, mdataGetBomData, attribGetAttributeValues, mdataGetFailureDataForStation, trUploadState, trUploadResultDataAndRecipe, trUploadFailureAndResultData, setupStateChange, setupUpdateMaterialSetup, attribAppendAttributeValues, attribCreateAttributeCode |
|
||||
|
||||
## Parameters never to infer
|
||||
|
||||
- HISTORY: `serialNumberPos:'-1'`, `processLayer:'2'`, `desolvingSerialNumber:'1'`, `desolvingLevel:'0'`.
|
||||
- STATUS UMBUCHUNG: state 0=Gut, 1=Nacharbeit, 2=Ausschuss; use the station and layer from the **selected history booking**.
|
||||
- MANUAL: read `CODE_NUMBER=8310` to determine whether step uses `WORKSTEP_AVO` or `PROCESS_LAYER`.
|
||||
- `mdataGetWorkplanData`: on `-368`, retry without `SKILL_LEVEL` result key.
|
||||
- `mdaGetRecipeData`: treat `-702` as tolerated empty recipe, not a booking error.
|
||||
- `trUploadResultDataAndRecipe`: flatten *keys in exact original order*; inspect result.return_value.
|
||||
- `trUploadState`: validate returned `ERROR_CODE` rows, never treat an HTTP success as confirmed booking.
|
||||
- Missing history `-110`: allow serial assignment only when an active order and valid process layer are verified again.
|
||||
|
||||
## QA examples
|
||||
|
||||
- Missing `globallogin`: reads/writes disabled, helpful message.
|
||||
- Station changes while modal open: forbid write or require re-read of station/active order.
|
||||
- Two browsers: CSS draft remains invisible until publish; previous CSS revision can be republished.
|
||||
- Failed API call: preserve form data; no green success toast.
|
||||
- Database unavailable: CSS falls back to static WAR file; admin modifications return an error.
|
||||
- Oracle/SQL Server: verify schema creation uses permissions and data types supported by respective server.
|
||||
24
.agents/skills/workbench-hmi-clients/scripts/new-widget.mjs
Normal file
24
.agents/skills/workbench-hmi-clients/scripts/new-widget.mjs
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env node
|
||||
/** Scaffolds a native Vue HMI widget plus registries, no external deps. */
|
||||
import fs from 'node:fs';import path from 'node:path';import {fileURLToPath} from 'node:url';
|
||||
const [slug,label]=process.argv.slice(2);
|
||||
if(!slug||!label||!/^[a-z][a-z0-9-]{1,48}$/.test(slug)){console.error('Usage: node new-widget.mjs quality-check "Qualitätsprüfung"');process.exit(2);}
|
||||
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'../../../..');
|
||||
const dir=path.join(root,'hmi-frontend/src/widgets');
|
||||
const type='wb.'+slug;
|
||||
const name=slug.split('-').map(x=>x[0].toUpperCase()+x.slice(1)).join('')+'Widget';
|
||||
const file=path.join(dir,name+'.vue');
|
||||
if(fs.existsSync(file))throw Error('Widget exists: '+file);
|
||||
const catalog=path.join(dir,'catalog.ts'),renderer=path.join(dir,'WidgetRenderer.vue'),resource=path.join(root,'backend/src/main/java/com/workbenchclassic/hmi/HmiApiResource.java');
|
||||
for(const p of [catalog,renderer,resource])if(!fs.existsSync(p))throw Error('Missing '+p);
|
||||
let cat=fs.readFileSync(catalog,'utf8');let render=fs.readFileSync(renderer,'utf8');let java=fs.readFileSync(resource,'utf8');
|
||||
if(cat.includes(`type:'${type}'`)||java.includes(`"${type}"`))throw Error('Widget type already registered');
|
||||
const insert=` {type:'${type}',label:${JSON.stringify(label)},group:'Produktion',icon:'▣',description:'Neues natives Vue-Widget',w:6,h:4,props:{title:${JSON.stringify(label)}}},\n `;
|
||||
const pos=cat.indexOf(" {type:'ui.text'");if(pos<0)throw Error('Cannot find catalog marker');cat=cat.slice(0,pos)+insert+cat.slice(pos);
|
||||
const importPos=render.indexOf("import {catalogByType}");if(importPos<0)throw Error('Cannot find renderer marker');render=render.slice(0,importPos)+`import ${name} from './${name}.vue';\n`+render.slice(importPos);
|
||||
const branch=' <LegacyModuleWidget v-else-if=';
|
||||
const branchPos=render.indexOf(branch);if(branchPos<0)throw Error('Cannot find renderer branch');render=render.slice(0,branchPos)+` <${name} v-else-if="widget.type==='${type}'" :widget="widget" :station="station" :demo="demo"/>\n`+render.slice(branchPos);
|
||||
const javaMarker='"wb.user-import");';if(!java.includes(javaMarker))throw Error('Unknown HMI widget allowlist structure');java=java.replace(javaMarker,`"wb.user-import", "${type}");`);
|
||||
fs.writeFileSync(file,`<script setup lang="ts">\nimport type {HmiWidget} from '../types';\nconst props=defineProps<{widget:HmiWidget;station:string;demo:boolean}>();\n</script>\n<template>\n<section class="wb-mes-client">\n <div class="wb-mes-strip">${label} · {{props.station}}</div>\n <p v-if="props.demo" class="wb-mes-note">Demo – keine MES-Schreibaktionen</p>\n <p class="wb-mes-note">Hier den alten Client mittels mesClient.ts nach Vue migrieren.</p>\n</section>\n</template>\n`);
|
||||
fs.writeFileSync(catalog,cat);fs.writeFileSync(renderer,render);fs.writeFileSync(resource,java);
|
||||
console.log(`Registered ${type} (${name}.vue). Next: implement MES logic and test in Dev.`);
|
||||
Reference in New Issue
Block a user