@adcops/autocore-react 3.3.89 → 3.3.91

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 (96) hide show
  1. package/dist/assets/JogXNeg.d.ts +4 -0
  2. package/dist/assets/JogXNeg.d.ts.map +1 -0
  3. package/dist/assets/JogXNeg.js +1 -0
  4. package/dist/assets/JogXPos.d.ts +4 -0
  5. package/dist/assets/JogXPos.d.ts.map +1 -0
  6. package/dist/assets/JogXPos.js +1 -0
  7. package/dist/assets/JogYNeg.d.ts +4 -0
  8. package/dist/assets/JogYNeg.d.ts.map +1 -0
  9. package/dist/assets/JogYNeg.js +1 -0
  10. package/dist/assets/JogYPos.d.ts +4 -0
  11. package/dist/assets/JogYPos.d.ts.map +1 -0
  12. package/dist/assets/JogYPos.js +1 -0
  13. package/dist/assets/JogZNeg.d.ts +4 -0
  14. package/dist/assets/JogZNeg.d.ts.map +1 -0
  15. package/dist/assets/JogZNeg.js +1 -0
  16. package/dist/assets/JogZPos.d.ts +4 -0
  17. package/dist/assets/JogZPos.d.ts.map +1 -0
  18. package/dist/assets/JogZPos.js +1 -0
  19. package/dist/assets/Off.d.ts +4 -0
  20. package/dist/assets/Off.d.ts.map +1 -0
  21. package/dist/assets/Off.js +1 -0
  22. package/dist/assets/On.d.ts +4 -0
  23. package/dist/assets/On.d.ts.map +1 -0
  24. package/dist/assets/On.js +1 -0
  25. package/dist/assets/index.d.ts +8 -0
  26. package/dist/assets/index.d.ts.map +1 -1
  27. package/dist/assets/index.js +1 -1
  28. package/dist/assets/svg/off.svg +2 -0
  29. package/dist/assets/svg/on.svg +11 -0
  30. package/dist/components/JogPanel.d.ts +2 -2
  31. package/dist/components/JogPanel.d.ts.map +1 -1
  32. package/dist/components/JogPanel.js +1 -1
  33. package/dist/components/ams/AssetDetailView.js +1 -1
  34. package/dist/components/ams/AssetEditDialog.d.ts.map +1 -1
  35. package/dist/components/ams/AssetEditDialog.js +1 -1
  36. package/dist/components/ams/AssetRegistryTable.css +12 -0
  37. package/dist/components/ams/AssetRegistryTable.d.ts +1 -0
  38. package/dist/components/ams/AssetRegistryTable.d.ts.map +1 -1
  39. package/dist/components/ams/AssetRegistryTable.js +1 -1
  40. package/dist/components/tis/ConfigurationDialog.d.ts +21 -0
  41. package/dist/components/tis/ConfigurationDialog.d.ts.map +1 -0
  42. package/dist/components/tis/ConfigurationDialog.js +1 -0
  43. package/dist/components/tis/ResultHistoryTable.js +1 -1
  44. package/dist/components/tis/TestDataView.d.ts +47 -0
  45. package/dist/components/tis/TestDataView.d.ts.map +1 -1
  46. package/dist/components/tis/TestDataView.js +1 -1
  47. package/dist/components/tis/TestSetupForm.d.ts +37 -0
  48. package/dist/components/tis/TestSetupForm.d.ts.map +1 -1
  49. package/dist/components/tis/TestSetupForm.js +1 -1
  50. package/dist/components/tis/TisProvider.d.ts +25 -0
  51. package/dist/components/tis/TisProvider.d.ts.map +1 -1
  52. package/dist/components/tis/TisProvider.js +1 -1
  53. package/dist/components/tis/useRawCycleData.d.ts.map +1 -1
  54. package/dist/components/tis/useRawCycleData.js +1 -1
  55. package/dist/components/tis-editor/TisConfigEditor.css +20 -0
  56. package/dist/components/tis-editor/editor/ConfigurationsEditor.d.ts +19 -0
  57. package/dist/components/tis-editor/editor/ConfigurationsEditor.d.ts.map +1 -0
  58. package/dist/components/tis-editor/editor/ConfigurationsEditor.js +1 -0
  59. package/dist/components/tis-editor/editor/MethodFormEditor.d.ts.map +1 -1
  60. package/dist/components/tis-editor/editor/MethodFormEditor.js +1 -1
  61. package/dist/components/tis-editor/types.d.ts +13 -0
  62. package/dist/components/tis-editor/types.d.ts.map +1 -1
  63. package/dist/components/tis-editor/validation.d.ts.map +1 -1
  64. package/dist/components/tis-editor/validation.js +1 -1
  65. package/dist/themes/adc-dark/blue/theme.css +17 -2
  66. package/dist/themes/adc-dark/blue/theme.css.map +1 -1
  67. package/package.json +2 -1
  68. package/src/assets/JogXNeg.tsx +30 -0
  69. package/src/assets/JogXPos.tsx +30 -0
  70. package/src/assets/JogYNeg.tsx +30 -0
  71. package/src/assets/JogYPos.tsx +30 -0
  72. package/src/assets/JogZNeg.tsx +30 -0
  73. package/src/assets/JogZPos.tsx +30 -0
  74. package/src/assets/Off.tsx +14 -0
  75. package/src/assets/On.tsx +26 -0
  76. package/src/assets/index.ts +8 -0
  77. package/src/assets/svg/off.svg +2 -0
  78. package/src/assets/svg/on.svg +11 -0
  79. package/src/components/JogPanel.tsx +18 -28
  80. package/src/components/ams/AssetDetailView.tsx +1 -1
  81. package/src/components/ams/AssetEditDialog.tsx +25 -10
  82. package/src/components/ams/AssetRegistryTable.css +12 -0
  83. package/src/components/ams/AssetRegistryTable.tsx +15 -4
  84. package/src/components/tis/ConfigurationDialog.tsx +128 -0
  85. package/src/components/tis/ResultHistoryTable.tsx +2 -2
  86. package/src/components/tis/TestDataView.tsx +270 -12
  87. package/src/components/tis/TestSetupForm.tsx +167 -10
  88. package/src/components/tis/TisProvider.tsx +53 -0
  89. package/src/components/tis/useRawCycleData.ts +22 -3
  90. package/src/components/tis-editor/TisConfigEditor.css +20 -0
  91. package/src/components/tis-editor/editor/ConfigurationsEditor.tsx +242 -0
  92. package/src/components/tis-editor/editor/MethodFormEditor.tsx +4 -0
  93. package/src/components/tis-editor/types.ts +14 -0
  94. package/src/components/tis-editor/validation.ts +29 -0
  95. package/src/themes/adc-dark/_extensions.scss +20 -0
  96. package/src/themes/theme-base/components/panel/_fieldset.scss +2 -2
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from "react";
2
+ export declare const SvgJogXNeg: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default SvgJogXNeg;
4
+ //# sourceMappingURL=JogXNeg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JogXNeg.d.ts","sourceRoot":"","sources":["../../src/assets/JogXNeg.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,UAAU,GAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,4CAkBxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const SvgJogXNeg=o=>_jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...o,children:[_jsx("path",{d:"M10 6 3 12 10 18Z",fill:"currentColor"}),_jsx("path",{d:"M14 6l8 12M22 6l-8 12"})]});export default SvgJogXNeg;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from "react";
2
+ export declare const SvgJogXPos: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default SvgJogXPos;
4
+ //# sourceMappingURL=JogXPos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JogXPos.d.ts","sourceRoot":"","sources":["../../src/assets/JogXPos.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,UAAU,GAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,4CAkBxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const SvgJogXPos=o=>_jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...o,children:[_jsx("path",{d:"M2 6l8 12M10 6l-8 12"}),_jsx("path",{d:"M14 6 21 12 14 18Z",fill:"currentColor"})]});export default SvgJogXPos;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from "react";
2
+ export declare const SvgJogYPos: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default SvgJogYPos;
4
+ //# sourceMappingURL=JogYNeg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JogYNeg.d.ts","sourceRoot":"","sources":["../../src/assets/JogYNeg.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,UAAU,GAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,4CAkBxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const SvgJogYPos=o=>_jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...o,children:[_jsx("path",{d:"M21 3 21 11 13 3Z",fill:"currentColor"}),_jsx("path",{d:"M4 12l3 4 3-4M7 16v5"})]});export default SvgJogYPos;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from "react";
2
+ export declare const SvgJogYNeg: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default SvgJogYNeg;
4
+ //# sourceMappingURL=JogYPos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JogYPos.d.ts","sourceRoot":"","sources":["../../src/assets/JogYPos.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,UAAU,GAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,4CAkBxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const SvgJogYNeg=o=>_jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...o,children:[_jsx("path",{d:"M20 3l-3 4-3-4M17 7v5"}),_jsx("path",{d:"M3 21 3 13 11 21Z",fill:"currentColor"})]});export default SvgJogYNeg;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from "react";
2
+ export declare const SvgJogZNeg: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default SvgJogZNeg;
4
+ //# sourceMappingURL=JogZNeg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JogZNeg.d.ts","sourceRoot":"","sources":["../../src/assets/JogZNeg.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,UAAU,GAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,4CAkBxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const SvgJogZNeg=o=>_jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...o,children:[_jsx("path",{d:"M6 2h12L6 10h12"}),_jsx("path",{d:"M5 14h14l-7 7Z",fill:"currentColor"})]});export default SvgJogZNeg;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from "react";
2
+ export declare const SvgJogZPos: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default SvgJogZPos;
4
+ //# sourceMappingURL=JogZPos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JogZPos.d.ts","sourceRoot":"","sources":["../../src/assets/JogZPos.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,UAAU,GAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,4CAkBxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const SvgJogZPos=o=>_jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...o,children:[_jsx("path",{d:"M5 10 12 3 19 10Z",fill:"currentColor"}),_jsx("path",{d:"M6 14h12L6 22h12"})]});export default SvgJogZPos;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from "react";
2
+ export declare const Off: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default Off;
4
+ //# sourceMappingURL=Off.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Off.d.ts","sourceRoot":"","sources":["../../src/assets/Off.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,GAAG,GAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,4CASjD,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";export const Off=r=>_jsx("svg",{viewBox:"0 0 354.487 354.487",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:_jsx("path",{d:"M177.241,0C79.504,0,0,79.51,0,177.241c0,97.736,79.51,177.246,177.241,177.246c97.731,0,177.246-79.516,177.246-177.246 C354.487,79.504,274.979,0,177.241,0z M177.241,311.444c-73.994,0-134.198-60.203-134.198-134.203 c0-73.995,60.204-134.199,134.198-134.199c74,0,134.204,60.204,134.204,134.199C311.445,251.241,251.241,311.444,177.241,311.444z"})});export default Off;
@@ -0,0 +1,4 @@
1
+ import type { SVGProps } from "react";
2
+ export declare const On: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
3
+ export default On;
4
+ //# sourceMappingURL=On.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"On.d.ts","sourceRoot":"","sources":["../../src/assets/On.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,EAAE,GAAI,OAAO,QAAQ,CAAC,aAAa,CAAC,4CAchD,CAAC;AAEF,eAAe,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";export const On=r=>_jsx("svg",{viewBox:"0 0 72 72",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:_jsx("path",{d:"M36 16L36 56",stroke:"currentColor",strokeLinecap:"round",strokeWidth:3.6})});export default On;
@@ -3,6 +3,14 @@ export { default as Distance } from "./Distance";
3
3
  export { default as JogLong } from "./JogLong";
4
4
  export { default as JogMedium } from "./JogMedium";
5
5
  export { default as JogShort } from "./JogShort";
6
+ export { default as JogXPos } from "./JogXPos";
7
+ export { default as JogXNeg } from "./JogXNeg";
8
+ export { default as JogYPos } from "./JogYPos";
9
+ export { default as JogYNeg } from "./JogYNeg";
10
+ export { default as JogZPos } from "./JogZPos";
11
+ export { default as JogZNeg } from "./JogZNeg";
12
+ export { default as On } from "./On";
13
+ export { default as Off } from "./Off";
6
14
  export { default as PythonLogo } from "./PythonLogo";
7
15
  export { default as Rotation3D } from "./Rotation3D";
8
16
  export { default as RotationCcw } from "./RotationCcw";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC"}
@@ -1 +1 @@
1
- export{default as BlocklyLogo}from"./BlocklyLogo";export{default as Distance}from"./Distance";export{default as JogLong}from"./JogLong";export{default as JogMedium}from"./JogMedium";export{default as JogShort}from"./JogShort";export{default as PythonLogo}from"./PythonLogo";export{default as Rotation3D}from"./Rotation3D";export{default as RotationCcw}from"./RotationCcw";export{default as RotationCcwA}from"./RotationCcwA";export{default as RotationCcwB}from"./RotationCcwB";export{default as RotationCcwC}from"./RotationCcwC";export{default as RotationCw}from"./RotationCw";export{default as RotationCwA}from"./RotationCwA";export{default as RotationCwB}from"./RotationCwB";export{default as RotationCwC}from"./RotationCwC";export{default as Run}from"./Run";export{default as Speed}from"./Speed";export{default as SpeedFast}from"./SpeedFast";export{default as SpeedMedium}from"./SpeedMedium";export{default as SpeedNone}from"./SpeedNone";export{default as SpeedSlow}from"./SpeedSlow";export{default as Walk}from"./Walk";
1
+ export{default as BlocklyLogo}from"./BlocklyLogo";export{default as Distance}from"./Distance";export{default as JogLong}from"./JogLong";export{default as JogMedium}from"./JogMedium";export{default as JogShort}from"./JogShort";export{default as JogXPos}from"./JogXPos";export{default as JogXNeg}from"./JogXNeg";export{default as JogYPos}from"./JogYPos";export{default as JogYNeg}from"./JogYNeg";export{default as JogZPos}from"./JogZPos";export{default as JogZNeg}from"./JogZNeg";export{default as On}from"./On";export{default as Off}from"./Off";export{default as PythonLogo}from"./PythonLogo";export{default as Rotation3D}from"./Rotation3D";export{default as RotationCcw}from"./RotationCcw";export{default as RotationCcwA}from"./RotationCcwA";export{default as RotationCcwB}from"./RotationCcwB";export{default as RotationCcwC}from"./RotationCcwC";export{default as RotationCw}from"./RotationCw";export{default as RotationCwA}from"./RotationCwA";export{default as RotationCwB}from"./RotationCwB";export{default as RotationCwC}from"./RotationCwC";export{default as Run}from"./Run";export{default as Speed}from"./Speed";export{default as SpeedFast}from"./SpeedFast";export{default as SpeedMedium}from"./SpeedMedium";export{default as SpeedNone}from"./SpeedNone";export{default as SpeedSlow}from"./SpeedSlow";export{default as Walk}from"./Walk";
@@ -0,0 +1,2 @@
1
+ <svg fill="#000000" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg"
2
+ xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 354.487 354.487" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <path d="M177.241,0C79.504,0,0,79.51,0,177.241c0,97.736,79.51,177.246,177.241,177.246c97.731,0,177.246-79.516,177.246-177.246 C354.487,79.504,274.979,0,177.241,0z M177.241,311.444c-73.994,0-134.198-60.203-134.198-134.203 c0-73.995,60.204-134.199,134.198-134.199c74,0,134.204,60.204,134.204,134.199C311.445,251.241,251.241,311.444,177.241,311.444z"></path> </g> </g></svg>
@@ -0,0 +1,11 @@
1
+ <svg viewBox="0 0 72 72" id="emoji" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
3
+ <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC"
4
+ stroke-width="0.43200000000000005"></g>
5
+ <g id="SVGRepo_iconCarrier">
6
+ <g id="color"></g>
7
+ <g id="line">
8
+ <path stroke="#000000" stroke-linecap="round" stroke-width="3.6" d="M36 16L36 56"></path>
9
+ </g>
10
+ </g>
11
+ </svg>
@@ -87,9 +87,9 @@ export declare const DefaultRotationJogButtons: (JogPanelButtonDefinition | unde
87
87
  * Example:
88
88
  * ```
89
89
  * export const kDefaultButtonDefinitions : (JogPanelButtonDefinition | undefined)[][] = [
90
- * [{ icon: "pi pi-arrow-up-left", action: JogPanelAction.yPositive, alt: "Y Positive" }, { icon: "pi pi-arrow-up", action: JogPanelAction.zPositive, alt: "Z Positive" }, undefined],
90
+ * [undefined, { icon: "pi pi-arrow-up", action: JogPanelAction.zPositive, alt: "Z Positive" }, { icon: "pi pi-arrow-down-left", action: JogPanelAction.yNegative, alt: "Y Negative" }],
91
91
  * [{ icon: "pi pi-arrow-left", action: JogPanelAction.xNegative, alt: "X Negative" }, undefined, { icon: "pi pi-arrow-right", action: JogPanelAction.xPositive, alt: "X Positive" }],
92
- * [undefined, { icon: "pi pi-arrow-down", action: JogPanelAction.zNegative, alt: "Z Negative" }, { icon: "pi pi-arrow-down-right", action: JogPanelAction.yNegative, alt: "Y Negative" }],
92
+ * [{ icon: "pi pi-arrow-up-right", action: JogPanelAction.yPositive, alt: "Y Positive" }, { icon: "pi pi-arrow-down", action: JogPanelAction.zNegative, alt: "Z Negative" }, undefined],
93
93
  * ];
94
94
  * ```
95
95
  *
@@ -1 +1 @@
1
- {"version":3,"file":"JogPanel.d.ts","sourceRoot":"","sources":["../../src/components/JogPanel.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,gBAAgB,CAAC;AAQxB;;GAEG;AACH,oBAAY,cAAc;IACtB,mCAAmC;IACnC,OAAO,IAAO;IAEd,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,KAAO;IAEhB,SAAS,KAAO;IAEhB,SAAS,KAAO;IAEhB,2BAA2B;IAC3B,IAAI,MAAO;CACd;AAGD;;GAEG;AACH,oBAAY,iBAAiB;IACzB,KAAK,IAAO;IACZ,MAAM,KAAO;IACb,IAAI,KAAO;CACd;AAED;;GAEG;AACH,oBAAY,cAAc;IACtB,IAAI,IAAO;IACX,MAAM,KAAO;IACb,IAAI,KAAO;CACd;AAGD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,cAAc,CAAA;CACzB;AAkBD;;GAEG;AACH,UAAU,aAAa;IACnB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC3D,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,iBAAiB,EAAE,CAAC,wBAAwB,GAAG,SAAS,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;IAC1E,kBAAkB,EAAG,iBAAiB,CAAC;IACvC,eAAe,EAAG,cAAc,CAAC;IACjC,mBAAmB,EAAG,OAAO,CAAC;IAC9B,gBAAgB,EAAG,OAAO,CAAC;CAC9B;AAGD,UAAU,aAAa;IACnB,WAAW,EAAG,iBAAiB,CAAC;IAChC,QAAQ,EAAG,cAAc,CAAA;CAC5B;AAGD;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAG,CAAC,wBAAwB,GAAG,SAAS,CAAC,EAAE,EAI9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAG,CAAC,wBAAwB,GAAG,SAAS,CAAC,EAAE,EAIhF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,QAAS,SAAQ,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IAEvE,MAAM,CAAC,YAAY,EAAG,aAAa,CAQjC;IAGF,OAAO,CAAC,gBAAgB,CAItB;IAEF,OAAO,CAAC,aAAa,CAInB;gBAGU,KAAK,EAAE,aAAa;IAUhC;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,kBAAkB;IAQ1B,QAAQ;IAQR,OAAO,CAAC,YAAY;IAiDpB,cAAc,CAAC,GAAG,EAAG,MAAM,EAAE,GAAG,EAAG,MAAM;IAmCzC,MAAM;CAiIT;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"JogPanel.d.ts","sourceRoot":"","sources":["../../src/components/JogPanel.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,gBAAgB,CAAC;AASxB;;GAEG;AACH,oBAAY,cAAc;IACtB,mCAAmC;IACnC,OAAO,IAAO;IAEd,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,IAAO;IAEhB,SAAS,KAAO;IAEhB,SAAS,KAAO;IAEhB,SAAS,KAAO;IAEhB,2BAA2B;IAC3B,IAAI,MAAO;CACd;AAGD;;GAEG;AACH,oBAAY,iBAAiB;IACzB,KAAK,IAAO;IACZ,MAAM,KAAO;IACb,IAAI,KAAO;CACd;AAED;;GAEG;AACH,oBAAY,cAAc;IACtB,IAAI,IAAO;IACX,MAAM,KAAO;IACb,IAAI,KAAO;CACd;AAGD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,cAAc,CAAA;CACzB;AAkBD;;GAEG;AACH,UAAU,aAAa;IACnB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC3D,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,iBAAiB,EAAE,CAAC,wBAAwB,GAAG,SAAS,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;IAC1E,kBAAkB,EAAG,iBAAiB,CAAC;IACvC,eAAe,EAAG,cAAc,CAAC;IACjC,mBAAmB,EAAG,OAAO,CAAC;IAC9B,gBAAgB,EAAG,OAAO,CAAC;CAC9B;AAGD,UAAU,aAAa;IACnB,WAAW,EAAG,iBAAiB,CAAC;IAChC,QAAQ,EAAG,cAAc,CAAA;CAC5B;AAGD;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAG,CAAC,wBAAwB,GAAG,SAAS,CAAC,EAAE,EAI9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAG,CAAC,wBAAwB,GAAG,SAAS,CAAC,EAAE,EAIhF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,QAAS,SAAQ,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IAEvE,MAAM,CAAC,YAAY,EAAG,aAAa,CAQjC;IAGF,OAAO,CAAC,gBAAgB,CAItB;IAEF,OAAO,CAAC,aAAa,CAInB;gBAGU,KAAK,EAAE,aAAa;IAUhC;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,kBAAkB;IAQ1B,QAAQ;IAQR,OAAO,CAAC,YAAY;IAiDpB,cAAc,CAAC,GAAG,EAAG,MAAM,EAAE,GAAG,EAAG,MAAM;IAwBzC,MAAM;CAiIT;AAED,eAAe,QAAQ,CAAC"}
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React from"react";import{Button}from"primereact/button";import{SelectButton}from"primereact/selectbutton";import{Tooltip}from"primereact/tooltip";import"./JogPanel.css";import{Distance,JogShort,JogMedium,JogLong}from"../assets";import{Speed,SpeedSlow,SpeedMedium,SpeedFast}from"../assets";import{RotationCcwA,RotationCcwB,RotationCcwC}from"../assets";import{RotationCwA,RotationCwB,RotationCwC}from"../assets";export var JogPanelAction;!function(t){t[t.Invalid=0]="Invalid",t[t.xPositive=1]="xPositive",t[t.xNegative=2]="xNegative",t[t.yPositive=3]="yPositive",t[t.yNegative=4]="yNegative",t[t.zPositive=5]="zPositive",t[t.zNegative=6]="zNegative",t[t.aPositive=7]="aPositive",t[t.aNegative=8]="aNegative",t[t.bPositive=9]="bPositive",t[t.bNegative=16]="bNegative",t[t.cPositive=17]="cPositive",t[t.cNegative=18]="cNegative",t[t.Stop=255]="Stop"}(JogPanelAction||(JogPanelAction={}));export var JogDistanceAction;!function(t){t[t.Short=0]="Short",t[t.Medium=16]="Medium",t[t.Long=32]="Long"}(JogDistanceAction||(JogDistanceAction={}));export var JogSpeedAction;!function(t){t[t.Slow=0]="Slow",t[t.Medium=16]="Medium",t[t.Fast=32]="Fast"}(JogSpeedAction||(JogSpeedAction={}));export const DefaultLinearJogButtons=[[{icon:"pi pi-arrow-up-left",action:JogPanelAction.yPositive,alt:"Y Positive"},{icon:"pi pi-arrow-up",action:JogPanelAction.zPositive,alt:"Z Positive"},void 0],[{icon:"pi pi-arrow-left",action:JogPanelAction.xNegative,alt:"X Negative"},void 0,{icon:"pi pi-arrow-right",action:JogPanelAction.xPositive,alt:"X Positive"}],[void 0,{icon:"pi pi-arrow-down",action:JogPanelAction.zNegative,alt:"Z Negative"},{icon:"pi pi-arrow-down-right",action:JogPanelAction.yNegative,alt:"Y Negative"}]];export const DefaultRotationJogButtons=[[{icon:"pi",action:JogPanelAction.bPositive,alt:"Rot B Positive"},{icon:"pi",action:JogPanelAction.cPositive,alt:"Rot C Positive"},void 0],[{icon:"pi",action:JogPanelAction.aNegative,alt:"Rot A Negative"},void 0,{icon:"pi",action:JogPanelAction.aPositive,alt:"Rot A Positive"}],[void 0,{icon:"pi",action:JogPanelAction.cNegative,alt:"Rot C Negative"},{icon:"pi ",action:JogPanelAction.bNegative,alt:"Rot B Negative"}]];export class JogPanel extends React.Component{constructor(t){super(t),Object.defineProperty(this,"jogDistanceItems",{enumerable:!0,configurable:!0,writable:!0,value:[{name:"S",value:JogDistanceAction.Short},{name:"M",value:JogDistanceAction.Medium},{name:"L",value:JogDistanceAction.Long}]}),Object.defineProperty(this,"jogSpeedItems",{enumerable:!0,configurable:!0,writable:!0,value:[{name:"S",value:JogSpeedAction.Slow},{name:"M",value:JogSpeedAction.Medium},{name:"F",value:JogSpeedAction.Fast}]}),this.state={jogDistance:t.defaultJogDistance,jogSpeed:t.defaultJogSpeed}}handleClicked(t){null!=t&&this.props.onClicked&&this.props.onClicked(t)}handleDistanceChanged(t){this.setState({jogDistance:t}),this.props.onJogDistanceChanged&&this.props.onJogDistanceChanged(t)}handleSpeedChanged(t){this.setState({jogSpeed:t}),this.props.onJogSpeedChanged&&this.props.onJogSpeedChanged(t)}emptyRow(){return _jsxs("div",{className:"grid-row",children:[_jsx("div",{className:"button-item empty-slot"}),_jsx("div",{className:"button-item empty-slot"}),_jsx("div",{className:"button-item empty-slot"})]})}actionToIcon(t){return t==JogPanelAction.Invalid||t==JogPanelAction.Stop?_jsx("i",{}):t==JogPanelAction.xNegative?_jsx("i",{className:"pi pi-arrow-left"}):t==JogPanelAction.xPositive?_jsx("i",{className:"pi pi-arrow-right"}):t==JogPanelAction.yNegative?_jsx("i",{className:"pi pi-arrow-up-left"}):t==JogPanelAction.yPositive?_jsx("i",{className:"pi pi-arrow-down-right"}):t==JogPanelAction.zNegative?_jsx("i",{className:"pi pi-up"}):t==JogPanelAction.zPositive?_jsx("i",{className:"pi pi-down"}):t==JogPanelAction.aNegative?_jsx(RotationCcwA,{}):t==JogPanelAction.aPositive?_jsx(RotationCwA,{}):t==JogPanelAction.bNegative?_jsx(RotationCcwB,{}):t==JogPanelAction.bPositive?_jsx(RotationCwB,{}):t==JogPanelAction.cNegative?_jsx(RotationCcwC,{}):t==JogPanelAction.cPositive?_jsx(RotationCwC,{}):_jsx("i",{})}standardButton(t,i){if(void 0!==this.props.buttonDefinitions&&void 0!==this.props.buttonDefinitions[t]&&void 0!==this.props.buttonDefinitions[t][i]&&void 0!==this.props.buttonDefinitions[t][i]?.action){const o=this.props.buttonDefinitions[t][i]?.action;return void 0!==o&&o<JogPanelAction.aPositive?_jsx(Button,{icon:this.props.buttonDefinitions[t][i]?.icon,tooltip:this.props.buttonDefinitions[t][i]?.alt,onClick:()=>this.handleClicked(o),className:"button-item"},`${t}-${i}`):_jsx(Button,{tooltip:this.props.buttonDefinitions[t][i]?.alt,onClick:()=>this.handleClicked(o),className:"button-item",icon:()=>this.actionToIcon(o)},`${t}-${i}`)}return _jsx(Button,{icon:"pi",disabled:!0,className:"button-item empty-slot"},`${t}-${i}`)}render(){return _jsxs("div",{className:"jogpanel-container",children:[_jsx(Tooltip,{target:".distance-selector-button"}),_jsxs("div",{className:"grid-container",children:[_jsxs("div",{className:"grid-row",children:[this.standardButton(0,0),this.standardButton(0,1),this.standardButton(0,2)]},"0"),_jsxs("div",{className:"grid-row",children:[this.standardButton(1,0),this.standardButton(1,1),this.standardButton(1,2)]},"1"),_jsxs("div",{className:"grid-row",children:[this.standardButton(2,0),this.standardButton(2,1),this.standardButton(2,2)]},"2")]}),this.props.showDistanceControl&&_jsxs("div",{className:"distance-selector p-inputgroup flex-1",children:[_jsx("span",{className:"p-inputgroup-addon",children:_jsx(Distance,{width:16,height:16,fill:"white"})}),_jsx(SelectButton,{value:this.state.jogDistance,onChange:t=>this.handleDistanceChanged(t.value),optionLabel:"name",options:this.jogDistanceItems,allowEmpty:!1,itemTemplate:t=>t.value==JogDistanceAction.Short?_jsx(JogShort,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Short Distance","data-pr-position":"bottom",fill:"white"}):t.value==JogDistanceAction.Medium?_jsx(JogMedium,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Medium Distance","data-pr-position":"bottom",fill:"white"}):_jsx(JogLong,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Long Distance","data-pr-position":"bottom",fill:"white"})})]}),this.props.showSpeedControl&&_jsxs("div",{className:"distance-selector p-inputgroup flex-1",children:[_jsx("span",{className:"p-inputgroup-addon",children:_jsx(Speed,{width:16,height:16,fill:"white"})}),_jsx(SelectButton,{value:this.state.jogSpeed,onChange:t=>this.handleSpeedChanged(t.value),optionLabel:"name",options:this.jogSpeedItems,allowEmpty:!1,itemTemplate:t=>t.value==JogSpeedAction.Slow?_jsx(SpeedSlow,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Slow Speed","data-pr-position":"bottom",fill:"white"}):t.value==JogSpeedAction.Medium?_jsx(SpeedMedium,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Medium Speed","data-pr-position":"bottom",fill:"white"}):_jsx(SpeedFast,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Fast Speed","data-pr-position":"bottom",fill:"white"})})]})]})}}Object.defineProperty(JogPanel,"defaultProps",{enumerable:!0,configurable:!0,writable:!0,value:{onClicked:void 0,onJogDistanceChanged:void 0,buttonDefinitions:DefaultLinearJogButtons,defaultJogDistance:JogDistanceAction.Short,defaultJogSpeed:JogSpeedAction.Medium,showDistanceControl:!0,showSpeedControl:!0}});export default JogPanel;
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React from"react";import{Button}from"primereact/button";import{SelectButton}from"primereact/selectbutton";import{Tooltip}from"primereact/tooltip";import"./JogPanel.css";import{Distance,JogShort,JogMedium,JogLong}from"../assets";import{Speed,SpeedSlow,SpeedMedium,SpeedFast}from"../assets";import{RotationCcwA,RotationCcwB,RotationCcwC}from"../assets";import{RotationCwA,RotationCwB,RotationCwC}from"../assets";import{JogXPos,JogXNeg,JogYPos,JogYNeg,JogZPos,JogZNeg}from"../assets";export var JogPanelAction;!function(t){t[t.Invalid=0]="Invalid",t[t.xPositive=1]="xPositive",t[t.xNegative=2]="xNegative",t[t.yPositive=3]="yPositive",t[t.yNegative=4]="yNegative",t[t.zPositive=5]="zPositive",t[t.zNegative=6]="zNegative",t[t.aPositive=7]="aPositive",t[t.aNegative=8]="aNegative",t[t.bPositive=9]="bPositive",t[t.bNegative=16]="bNegative",t[t.cPositive=17]="cPositive",t[t.cNegative=18]="cNegative",t[t.Stop=255]="Stop"}(JogPanelAction||(JogPanelAction={}));export var JogDistanceAction;!function(t){t[t.Short=0]="Short",t[t.Medium=16]="Medium",t[t.Long=32]="Long"}(JogDistanceAction||(JogDistanceAction={}));export var JogSpeedAction;!function(t){t[t.Slow=0]="Slow",t[t.Medium=16]="Medium",t[t.Fast=32]="Fast"}(JogSpeedAction||(JogSpeedAction={}));export const DefaultLinearJogButtons=[[void 0,{icon:"pi pi-arrow-up",action:JogPanelAction.zPositive,alt:"Z Positive"},{icon:"pi pi-arrow-down-left",action:JogPanelAction.yNegative,alt:"Y Negative"}],[{icon:"pi pi-arrow-left",action:JogPanelAction.xNegative,alt:"X Negative"},void 0,{icon:"pi pi-arrow-right",action:JogPanelAction.xPositive,alt:"X Positive"}],[{icon:"pi pi-arrow-up-right",action:JogPanelAction.yPositive,alt:"Y Positive"},{icon:"pi pi-arrow-down",action:JogPanelAction.zNegative,alt:"Z Negative"},void 0]];export const DefaultRotationJogButtons=[[{icon:"pi",action:JogPanelAction.bPositive,alt:"Rot B Positive"},{icon:"pi",action:JogPanelAction.cPositive,alt:"Rot C Positive"},void 0],[{icon:"pi",action:JogPanelAction.aNegative,alt:"Rot A Negative"},void 0,{icon:"pi",action:JogPanelAction.aPositive,alt:"Rot A Positive"}],[void 0,{icon:"pi",action:JogPanelAction.cNegative,alt:"Rot C Negative"},{icon:"pi ",action:JogPanelAction.bNegative,alt:"Rot B Negative"}]];export class JogPanel extends React.Component{constructor(t){super(t),Object.defineProperty(this,"jogDistanceItems",{enumerable:!0,configurable:!0,writable:!0,value:[{name:"S",value:JogDistanceAction.Short},{name:"M",value:JogDistanceAction.Medium},{name:"L",value:JogDistanceAction.Long}]}),Object.defineProperty(this,"jogSpeedItems",{enumerable:!0,configurable:!0,writable:!0,value:[{name:"S",value:JogSpeedAction.Slow},{name:"M",value:JogSpeedAction.Medium},{name:"F",value:JogSpeedAction.Fast}]}),this.state={jogDistance:t.defaultJogDistance,jogSpeed:t.defaultJogSpeed}}handleClicked(t){null!=t&&this.props.onClicked&&this.props.onClicked(t)}handleDistanceChanged(t){this.setState({jogDistance:t}),this.props.onJogDistanceChanged&&this.props.onJogDistanceChanged(t)}handleSpeedChanged(t){this.setState({jogSpeed:t}),this.props.onJogSpeedChanged&&this.props.onJogSpeedChanged(t)}emptyRow(){return _jsxs("div",{className:"grid-row",children:[_jsx("div",{className:"button-item empty-slot"}),_jsx("div",{className:"button-item empty-slot"}),_jsx("div",{className:"button-item empty-slot"})]})}actionToIcon(t){return t==JogPanelAction.Invalid||t==JogPanelAction.Stop?_jsx("i",{}):t==JogPanelAction.xNegative?_jsx(JogXNeg,{}):t==JogPanelAction.xPositive?_jsx(JogXPos,{}):t==JogPanelAction.yNegative?_jsx(JogYNeg,{}):t==JogPanelAction.yPositive?_jsx(JogYPos,{}):t==JogPanelAction.zNegative?_jsx(JogZNeg,{}):t==JogPanelAction.zPositive?_jsx(JogZPos,{}):t==JogPanelAction.aNegative?_jsx(RotationCcwA,{}):t==JogPanelAction.aPositive?_jsx(RotationCwA,{}):t==JogPanelAction.bNegative?_jsx(RotationCcwB,{}):t==JogPanelAction.bPositive?_jsx(RotationCwB,{}):t==JogPanelAction.cNegative?_jsx(RotationCcwC,{}):t==JogPanelAction.cPositive?_jsx(RotationCwC,{}):_jsx("i",{})}standardButton(t,o){if(void 0!==this.props.buttonDefinitions&&void 0!==this.props.buttonDefinitions[t]&&void 0!==this.props.buttonDefinitions[t][o]&&void 0!==this.props.buttonDefinitions[t][o]?.action){const e=this.props.buttonDefinitions[t][o]?.action;return _jsx(Button,{tooltip:this.props.buttonDefinitions[t][o]?.alt,onClick:()=>this.handleClicked(e),className:"button-item",icon:()=>this.actionToIcon(e)},`${t}-${o}`)}return _jsx(Button,{icon:"pi",disabled:!0,className:"button-item empty-slot"},`${t}-${o}`)}render(){return _jsxs("div",{className:"jogpanel-container",children:[_jsx(Tooltip,{target:".distance-selector-button"}),_jsxs("div",{className:"grid-container",children:[_jsxs("div",{className:"grid-row",children:[this.standardButton(0,0),this.standardButton(0,1),this.standardButton(0,2)]},"0"),_jsxs("div",{className:"grid-row",children:[this.standardButton(1,0),this.standardButton(1,1),this.standardButton(1,2)]},"1"),_jsxs("div",{className:"grid-row",children:[this.standardButton(2,0),this.standardButton(2,1),this.standardButton(2,2)]},"2")]}),this.props.showDistanceControl&&_jsxs("div",{className:"distance-selector p-inputgroup flex-1",children:[_jsx("span",{className:"p-inputgroup-addon",children:_jsx(Distance,{width:16,height:16,fill:"white"})}),_jsx(SelectButton,{value:this.state.jogDistance,onChange:t=>this.handleDistanceChanged(t.value),optionLabel:"name",options:this.jogDistanceItems,allowEmpty:!1,itemTemplate:t=>t.value==JogDistanceAction.Short?_jsx(JogShort,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Short Distance","data-pr-position":"bottom",fill:"white"}):t.value==JogDistanceAction.Medium?_jsx(JogMedium,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Medium Distance","data-pr-position":"bottom",fill:"white"}):_jsx(JogLong,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Long Distance","data-pr-position":"bottom",fill:"white"})})]}),this.props.showSpeedControl&&_jsxs("div",{className:"distance-selector p-inputgroup flex-1",children:[_jsx("span",{className:"p-inputgroup-addon",children:_jsx(Speed,{width:16,height:16,fill:"white"})}),_jsx(SelectButton,{value:this.state.jogSpeed,onChange:t=>this.handleSpeedChanged(t.value),optionLabel:"name",options:this.jogSpeedItems,allowEmpty:!1,itemTemplate:t=>t.value==JogSpeedAction.Slow?_jsx(SpeedSlow,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Slow Speed","data-pr-position":"bottom",fill:"white"}):t.value==JogSpeedAction.Medium?_jsx(SpeedMedium,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Medium Speed","data-pr-position":"bottom",fill:"white"}):_jsx(SpeedFast,{className:"distance-selector-button",width:16,height:16,"data-pr-tooltip":"Fast Speed","data-pr-position":"bottom",fill:"white"})})]})]})}}Object.defineProperty(JogPanel,"defaultProps",{enumerable:!0,configurable:!0,writable:!0,value:{onClicked:void 0,onJogDistanceChanged:void 0,buttonDefinitions:DefaultLinearJogButtons,defaultJogDistance:JogDistanceAction.Short,defaultJogSpeed:JogSpeedAction.Medium,showDistanceControl:!0,showSpeedControl:!0}});export default JogPanel;
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React,{useContext,useEffect,useState}from"react";import{Button}from"primereact/button";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{ConfirmDialog,confirmDialog}from"primereact/confirmdialog";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useAms}from"./AmsProvider";import{CalibrationEntryDialog}from"./CalibrationEntryDialog";import{AssetEditDialog}from"./AssetEditDialog";export const AssetDetailView=()=>{const{selection:e,schemas:t,roles:s,readAsset:i,listCalibrations:a,readCalibration:r,readUsage:l,refreshAssets:n,setSelection:o}=useAms(),{invoke:d}=useContext(EventEmitterContext),[c,m]=useState(null),[p,u]=useState([]),[_,h]=useState(null),[x,f]=useState(!1),[y,j]=useState(null),[b,g]=useState(!1),[v,C]=useState(!1),S=async()=>{if(!e.assetId)return m(null),u([]),void h(null);const t=await i(e.assetId);m(t);const s=await a(e.assetId),n=await Promise.all(s.map(t=>r(e.assetId,t)));u(n.filter(Boolean));const o=await l(e.assetId);h(o)};if(useEffect(()=>{S()},[e.assetId]),!e.assetId)return _jsx("div",{style:{padding:"1rem",color:"#9ca3af"},children:"Select an asset from the registry to see its details."});if(!c)return _jsx("div",{style:{padding:"1rem"},children:"Loading…"});const w=t[c.asset_type]?.label??c.asset_type,A=s[c.asset_type]?.find(e=>e.location===c.location),D=A?A.label??A.location:c.location,E=Array.isArray(t[c.asset_type]?.fields)?t[c.asset_type].fields:[],k=c.custom??{},I=A?.used_by_modules??[];return _jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr auto 1fr",gap:"0.5rem 1.5rem",alignItems:"baseline"},children:[_jsx("strong",{children:"Asset ID"})," ",_jsx("span",{children:c.asset_id}),_jsx("strong",{children:"Type"})," ",_jsx("span",{children:w}),_jsx("strong",{children:"Serial"})," ",_jsx("span",{children:c.serial||_jsx("em",{style:{color:"#9ca3af"},children:"(none)"})}),_jsx("strong",{children:"Role"})," ",_jsx("span",{children:D||_jsx("em",{style:{color:"#9ca3af"},children:"(none)"})}),_jsx("strong",{children:"Status"})," ",_jsx("span",{children:c.status}),_jsx("strong",{children:"Installed"}),_jsx("span",{children:c.install_date?new Date(c.install_date).toLocaleString():"—"}),_jsx("strong",{children:"Current Cal"}),_jsx("span",{children:c.current_calibration_id??_jsx("em",{style:{color:"#f59e0b"},children:"none"})}),_jsx("strong",{children:"Cycles"})," ",_jsx("span",{children:_?.cycles??0})]}),I.length>0&&_jsxs("div",{style:{fontSize:"0.875rem",color:"#34d399"},children:["✓ Feeds module ",1===I.length?"config":"configs",":"," ",_jsx("strong",{children:I.join(", ")})," — ","their ",_jsxs("code",{children:["$","${ams.by_location."+c.location+".*}"]})," ","placeholders will resolve to the values below."]}),E.length>0&&_jsxs("div",{children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:"Nameplate"}),_jsx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",alignItems:"baseline",fontSize:"0.9rem"},children:E.map(e=>{const t=k[e.name],s=null!=t&&""!==t,i=e.label??e.name,a=s?e.units?`${t} ${e.units}`:String(t):"(not set)";return _jsxs(React.Fragment,{children:[_jsx("strong",{title:e.description??void 0,children:i}),_jsx("span",{style:{color:s?void 0:"#f59e0b"},children:a})]},e.name)})})]}),_jsx(SubLocationsPanel,{schema:t[c.asset_type]?.sub_locations,values:c.sub_locations}),_jsx(SubLocationsCalibrationPanel,{schema:t[c.asset_type]?.sub_locations,currentCalibration:p.find(e=>e.cal_id===c.current_calibration_id)}),_jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_jsx("h4",{style:{margin:0},children:"Calibration History"}),_jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[_jsx(Button,{label:"Edit",icon:"pi pi-pencil",outlined:!0,onClick:()=>C(!0),tooltip:"Edit role, nameplate, and per-axis values. Type, serial, and install date are immutable.",tooltipOptions:{position:"left"}}),"active"===c.status&&_jsx(Button,{label:"Retire",icon:"pi pi-power-off",severity:"warning",outlined:!0,onClick:async()=>{if(c)try{const e=await d("ams.update_asset",MessageType.Request,{asset_id:c.asset_id,status:"retired"});e?.success&&(await n(),await S())}catch(e){}},tooltip:"Mark inactive. The asset stays on disk; deletion is a separate action available after retirement.",tooltipOptions:{position:"left"}}),"retired"===c.status&&_jsx(Button,{label:"Delete",icon:"pi pi-trash",severity:"danger",outlined:!0,loading:b,onClick:()=>{c&&confirmDialog({message:_jsxs("div",{children:[_jsxs("p",{style:{marginTop:0},children:["Permanently delete asset ",_jsx("code",{children:c.asset_id}),"?"]}),_jsx("p",{style:{marginBottom:0,fontSize:"0.875rem",color:"#9ca3af"},children:"This removes the AMS record (nameplate, calibration history, usage counters). Historical test records that referenced this asset are unaffected — they carry the full asset and calibration data inline."})]}),header:"Delete asset",icon:"pi pi-exclamation-triangle",acceptLabel:"Delete",rejectLabel:"Cancel",acceptClassName:"p-button-danger",accept:()=>{(async()=>{if(c){g(!0);try{const e=await d("ams.delete_asset",MessageType.Request,{asset_id:c.asset_id});e?.success?(o({assetType:null,assetId:null}),await n()):alert(`Delete failed: ${e?.error_message??"unknown error"}`)}catch(e){alert(`Delete threw: ${e?.message??e}`)}finally{g(!1)}}})()}})},tooltip:"Permanent. Removes the AMS record; historical test snapshots are preserved inline.",tooltipOptions:{position:"left"}}),_jsx(Button,{label:"+ Calibration",icon:"pi pi-plus",onClick:()=>{j(null),f(!0)}})]})]}),_jsx(ConfirmDialog,{}),_jsxs(DataTable,{value:p,size:"small",stripedRows:!0,emptyMessage:"No calibrations recorded for this asset.",children:[_jsx(Column,{field:"cal_id",header:"Cal ID"}),_jsx(Column,{field:"performed_at",header:"Performed",body:e=>e.performed_at?new Date(e.performed_at).toLocaleString():"—"}),_jsx(Column,{field:"performed_by",header:"By"}),_jsx(Column,{field:"expires_at",header:"Expires",body:e=>e.expires_at?new Date(e.expires_at).toLocaleDateString():"—"}),_jsx(Column,{field:"cert_ref",header:"Cert"}),_jsx(Column,{header:"Values",body:e=>_jsx("code",{style:{fontSize:"0.75rem"},children:JSON.stringify(e.values)})}),_jsx(Column,{header:"",style:{width:"5rem"},body:e=>e.cal_id===c.current_calibration_id?_jsx(Button,{icon:"pi pi-pencil",text:!0,rounded:!0,size:"small",tooltip:"Edit this calibration (fixes a typo in place).",tooltipOptions:{position:"left"},onClick:()=>{j(e),f(!0)}}):null})]}),_jsx(CalibrationEntryDialog,{visible:x,assetId:c.asset_id,assetType:c.asset_type,editing:y,onHide:()=>{f(!1),j(null)},onAdded:()=>{S()}}),_jsx(AssetEditDialog,{visible:v,asset:c,onHide:()=>C(!1),onSaved:async()=>{await n(),await S()}})]})};const SubLocationsPanel=({schema:e,values:t})=>{if(!e||!Array.isArray(e.keys)||!Array.isArray(e.fields))return null;const s=t&&"object"==typeof t?t:{};return _jsxs("div",{children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:e.label??"Sub-locations"}),_jsx("div",{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:e.key_label??"Key"}),e.fields.map(e=>_jsxs("th",{title:e.description??void 0,style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:""]},e.name))]})}),_jsx("tbody",{children:e.keys.map(t=>{const i=s[t]??{};return _jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:t}),e.fields.map(e=>{const t=i[e.name],s=null!=t&&""!==t;return _jsx("td",{style:{padding:"0.25rem 0.5rem",color:s?void 0:"#f59e0b"},children:s?String(t):"(not set)"},e.name)})]},t)})})]})})]})},SubLocationsCalibrationPanel=({schema:e,currentCalibration:t})=>{if(!e||!Array.isArray(e.keys)||!Array.isArray(e.calibration_fields)||0===e.calibration_fields.length)return null;if(!t)return null;const s=t.values&&"object"==typeof t.values?t.values:{};return _jsxs("div",{children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:"Current Calibration — Per-axis Values"}),_jsx("div",{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:e.key_label??"Key"}),e.calibration_fields.map(e=>_jsxs("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:""]},e.name))]})}),_jsx("tbody",{children:e.keys.map(t=>{const i=s[t]??{};return _jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:t}),e.calibration_fields.map(e=>{const t=i[e.name],s=null!=t&&""!==t;return _jsx("td",{style:{padding:"0.25rem 0.5rem",color:s?void 0:"#f59e0b"},children:s?String(t):"(not set)"},e.name)})]},t)})})]})})]})};
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React,{useContext,useEffect,useState}from"react";import{Button}from"primereact/button";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{ConfirmDialog,confirmDialog}from"primereact/confirmdialog";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useAms}from"./AmsProvider";import{CalibrationEntryDialog}from"./CalibrationEntryDialog";import{AssetEditDialog}from"./AssetEditDialog";export const AssetDetailView=()=>{const{selection:e,schemas:t,roles:s,readAsset:i,listCalibrations:a,readCalibration:r,readUsage:l,refreshAssets:n,setSelection:o}=useAms(),{invoke:d}=useContext(EventEmitterContext),[c,m]=useState(null),[p,u]=useState([]),[_,h]=useState(null),[x,f]=useState(!1),[y,j]=useState(null),[b,g]=useState(!1),[v,C]=useState(!1),S=async()=>{if(!e.assetId)return m(null),u([]),void h(null);const t=await i(e.assetId);m(t);const s=await a(e.assetId),n=await Promise.all(s.map(t=>r(e.assetId,t)));u(n.filter(Boolean));const o=await l(e.assetId);h(o)};if(useEffect(()=>{S()},[e.assetId]),!e.assetId)return _jsx("div",{style:{padding:"1rem",color:"#9ca3af"},children:"Select an asset from the registry to see its details."});if(!c)return _jsx("div",{style:{padding:"1rem"},children:"Loading…"});const w=t[c.asset_type]?.label??c.asset_type,A=s[c.asset_type]?.find(e=>e.location===c.location),D=A?A.label??A.location:c.location,E=Array.isArray(t[c.asset_type]?.fields)?t[c.asset_type].fields:[],k=c.custom??{},I=A?.used_by_modules??[];return _jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr auto 1fr",gap:"0.5rem 1.5rem",alignItems:"baseline"},children:[_jsx("strong",{children:"Asset ID"})," ",_jsx("span",{children:c.asset_id}),_jsx("strong",{children:"Type"})," ",_jsx("span",{children:w}),_jsx("strong",{children:"Serial"})," ",_jsx("span",{children:c.serial||_jsx("em",{style:{color:"#9ca3af"},children:"(none)"})}),_jsx("strong",{children:"Role"})," ",_jsx("span",{children:D||_jsx("em",{style:{color:"#9ca3af"},children:"(none)"})}),_jsx("strong",{children:"Status"})," ",_jsx("span",{children:c.status}),_jsx("strong",{children:"Installed"}),_jsx("span",{children:c.install_date?new Date(c.install_date).toLocaleString():"—"}),_jsx("strong",{children:"Current Cal"}),_jsx("span",{children:c.current_calibration_id??_jsx("em",{style:{color:"#f59e0b"},children:"none"})}),_jsx("strong",{children:"Cycles"})," ",_jsx("span",{children:_?.cycles??0})]}),I.length>0&&_jsxs("div",{style:{fontSize:"0.875rem",color:"#34d399"},children:["✓ Feeds module ",1===I.length?"config":"configs",":"," ",_jsx("strong",{children:I.join(", ")})," — ","their ",_jsxs("code",{children:["$","${ams.by_location."+c.location+".*}"]})," ","placeholders will resolve to the values below."]}),E.length>0&&_jsxs("div",{children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:"Nameplate"}),_jsx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",alignItems:"baseline",fontSize:"0.9rem"},children:E.map(e=>{const t=k[e.name],s=null!=t&&""!==t,i=e.label??e.name,a=s?e.units?`${t} ${e.units}`:String(t):"(not set)";return _jsxs(React.Fragment,{children:[_jsx("strong",{title:e.description??void 0,children:i}),_jsx("span",{style:{color:s?void 0:"#f59e0b"},children:a})]},e.name)})})]}),_jsx(SubLocationsPanel,{schema:t[c.asset_type]?.sub_locations,values:c.sub_locations}),_jsx(SubLocationsCalibrationPanel,{schema:t[c.asset_type]?.sub_locations,currentCalibration:p.find(e=>e.cal_id===c.current_calibration_id)}),_jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_jsx("h4",{style:{margin:0},children:"Calibration History"}),_jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[_jsx(Button,{label:"Edit",icon:"pi pi-pencil",outlined:!0,onClick:()=>C(!0),tooltip:"Edit serial, role, nameplate, and per-axis values. Type and install date are immutable.",tooltipOptions:{position:"left"}}),"active"===c.status&&_jsx(Button,{label:"Retire",icon:"pi pi-power-off",severity:"warning",outlined:!0,onClick:async()=>{if(c)try{const e=await d("ams.update_asset",MessageType.Request,{asset_id:c.asset_id,status:"retired"});e?.success&&(await n(),await S())}catch(e){}},tooltip:"Mark inactive. The asset stays on disk; deletion is a separate action available after retirement.",tooltipOptions:{position:"left"}}),"retired"===c.status&&_jsx(Button,{label:"Delete",icon:"pi pi-trash",severity:"danger",outlined:!0,loading:b,onClick:()=>{c&&confirmDialog({message:_jsxs("div",{children:[_jsxs("p",{style:{marginTop:0},children:["Permanently delete asset ",_jsx("code",{children:c.asset_id}),"?"]}),_jsx("p",{style:{marginBottom:0,fontSize:"0.875rem",color:"#9ca3af"},children:"This removes the AMS record (nameplate, calibration history, usage counters). Historical test records that referenced this asset are unaffected — they carry the full asset and calibration data inline."})]}),header:"Delete asset",icon:"pi pi-exclamation-triangle",acceptLabel:"Delete",rejectLabel:"Cancel",acceptClassName:"p-button-danger",accept:()=>{(async()=>{if(c){g(!0);try{const e=await d("ams.delete_asset",MessageType.Request,{asset_id:c.asset_id});e?.success?(o({assetType:null,assetId:null}),await n()):alert(`Delete failed: ${e?.error_message??"unknown error"}`)}catch(e){alert(`Delete threw: ${e?.message??e}`)}finally{g(!1)}}})()}})},tooltip:"Permanent. Removes the AMS record; historical test snapshots are preserved inline.",tooltipOptions:{position:"left"}}),_jsx(Button,{label:"+ Calibration",icon:"pi pi-plus",onClick:()=>{j(null),f(!0)}})]})]}),_jsx(ConfirmDialog,{}),_jsxs(DataTable,{value:p,size:"small",stripedRows:!0,emptyMessage:"No calibrations recorded for this asset.",children:[_jsx(Column,{field:"cal_id",header:"Cal ID"}),_jsx(Column,{field:"performed_at",header:"Performed",body:e=>e.performed_at?new Date(e.performed_at).toLocaleString():"—"}),_jsx(Column,{field:"performed_by",header:"By"}),_jsx(Column,{field:"expires_at",header:"Expires",body:e=>e.expires_at?new Date(e.expires_at).toLocaleDateString():"—"}),_jsx(Column,{field:"cert_ref",header:"Cert"}),_jsx(Column,{header:"Values",body:e=>_jsx("code",{style:{fontSize:"0.75rem"},children:JSON.stringify(e.values)})}),_jsx(Column,{header:"",style:{width:"5rem"},body:e=>e.cal_id===c.current_calibration_id?_jsx(Button,{icon:"pi pi-pencil",text:!0,rounded:!0,size:"small",tooltip:"Edit this calibration (fixes a typo in place).",tooltipOptions:{position:"left"},onClick:()=>{j(e),f(!0)}}):null})]}),_jsx(CalibrationEntryDialog,{visible:x,assetId:c.asset_id,assetType:c.asset_type,editing:y,onHide:()=>{f(!1),j(null)},onAdded:()=>{S()}}),_jsx(AssetEditDialog,{visible:v,asset:c,onHide:()=>C(!1),onSaved:async()=>{await n(),await S()}})]})};const SubLocationsPanel=({schema:e,values:t})=>{if(!e||!Array.isArray(e.keys)||!Array.isArray(e.fields))return null;const s=t&&"object"==typeof t?t:{};return _jsxs("div",{children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:e.label??"Sub-locations"}),_jsx("div",{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:e.key_label??"Key"}),e.fields.map(e=>_jsxs("th",{title:e.description??void 0,style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:""]},e.name))]})}),_jsx("tbody",{children:e.keys.map(t=>{const i=s[t]??{};return _jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:t}),e.fields.map(e=>{const t=i[e.name],s=null!=t&&""!==t;return _jsx("td",{style:{padding:"0.25rem 0.5rem",color:s?void 0:"#f59e0b"},children:s?String(t):"(not set)"},e.name)})]},t)})})]})})]})},SubLocationsCalibrationPanel=({schema:e,currentCalibration:t})=>{if(!e||!Array.isArray(e.keys)||!Array.isArray(e.calibration_fields)||0===e.calibration_fields.length)return null;if(!t)return null;const s=t.values&&"object"==typeof t.values?t.values:{};return _jsxs("div",{children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:"Current Calibration — Per-axis Values"}),_jsx("div",{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:e.key_label??"Key"}),e.calibration_fields.map(e=>_jsxs("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:""]},e.name))]})}),_jsx("tbody",{children:e.keys.map(t=>{const i=s[t]??{};return _jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:t}),e.calibration_fields.map(e=>{const t=i[e.name],s=null!=t&&""!==t;return _jsx("td",{style:{padding:"0.25rem 0.5rem",color:s?void 0:"#f59e0b"},children:s?String(t):"(not set)"},e.name)})]},t)})})]})})]})};
@@ -1 +1 @@
1
- {"version":3,"file":"AssetEditDialog.d.ts","sourceRoot":"","sources":["../../../src/components/ams/AssetEditDialog.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAkCxE,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB;;yDAEqD;IACrD,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AA8DD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAypB1D,CAAC"}
1
+ {"version":3,"file":"AssetEditDialog.d.ts","sourceRoot":"","sources":["../../../src/components/ams/AssetEditDialog.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAkCxE,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB;;yDAEqD;IACrD,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AA8DD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAuqB1D,CAAC"}
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import React,{useContext,useEffect,useMemo,useState}from"react";import{Button}from"primereact/button";import{Calendar}from"primereact/calendar";import{Dialog}from"primereact/dialog";import{Dropdown}from"primereact/dropdown";import{InputText}from"primereact/inputtext";import{InputTextarea}from"primereact/inputtextarea";import{TabPanel,TabView}from"primereact/tabview";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useAms}from"./AmsProvider";const ROLE_OTHER="__other__";function fieldsFor(e,t){const r=e?.[t]?.fields;return Array.isArray(r)?r:[]}function subLocationsFor(e,t){const r=e?.[t]?.sub_locations;return r&&Array.isArray(r.keys)&&Array.isArray(r.fields)?r:null}function calibrationFieldsFor(e,t){const r=e?.[t]?.calibration_fields;return Array.isArray(r)?r:[]}function perAxisCalibrationFieldsFor(e){return e?.calibration_fields??[]}function coerceField(e,t){if(void 0!==t&&""!==t)switch(e.type){case"f32":case"f64":case"i8":case"i16":case"i32":case"i64":case"u8":case"u16":case"u32":case"u64":{const e=Number(t);return Number.isFinite(e)?e:void 0}case"bool":return"true"===t||"1"===t;default:return t}}function seedFromCustom(e,t){if(!e)return"";const r=e[t];return null==r?"":String(r)}export const AssetEditDialog=({visible:e,asset:t,onHide:r,onSaved:s})=>{const{schemas:n,roles:a,readCalibration:o}=useAms(),{invoke:i}=useContext(EventEmitterContext),l=t?.asset_type??"",d=useMemo(()=>fieldsFor(n,l),[n,l]),c=useMemo(()=>subLocationsFor(n,l),[n,l]),u=useMemo(()=>calibrationFieldsFor(n,l),[n,l]),m=useMemo(()=>perAxisCalibrationFieldsFor(c),[c]),p=m.length>0,_=p||u.length>0,f=useMemo(()=>l?a[l]??[]:[],[l,a]),x=f.length>0,h=useMemo(()=>{const e=f.map(e=>({label:e.label??e.location,value:e.location}));return e.push({label:"Other (advanced — type a custom role)",value:ROLE_OTHER}),e},[f]),[g,y]=useState(""),[b,v]=useState(""),[j,C]=useState({}),[T,S]=useState({}),[F,E]=useState(!1),[w,A]=useState(null),[R,k]=useState(0),[I,O]=useState(null),[$,L]=useState(""),[M,q]=useState(null),[D,H]=useState(""),[B,P]=useState(""),[z,N]=useState({}),[K,V]=useState({});useEffect(()=>{if(!e||!t)return;A(null),E(!1),k(0);const r="string"==typeof t.location?t.location:"",s=f.find(e=>e.location===r);""===r?(y(""),v("")):s?(y(r),v(r)):(y(ROLE_OTHER),v(r));const n={};for(const e of d)n[e.name]=seedFromCustom(t.custom,e.name);C(n);const a={};if(c){const e=t.sub_locations&&"object"==typeof t.sub_locations?t.sub_locations:{};for(const t of c.keys){const r=e[t]&&"object"==typeof e[t]?e[t]:{},s={};for(const e of c.fields){const t=r[e.name];s[e.name]=null==t?"":String(t)}a[t]=s}}S(a),O(null),L(""),q(null),H(""),P(""),N({}),V({});const i="string"==typeof t.current_calibration_id?t.current_calibration_id:"";if(!i)return;let l=!1;return(async()=>{const e=await o(t.asset_id,i);if(l||!e)return;O(e),L("string"==typeof e.performed_by?e.performed_by:""),H("string"==typeof e.cert_ref?e.cert_ref:""),P("string"==typeof e.notes?e.notes:""),q(e.expires_at?new Date(e.expires_at):null);const r=e.values&&"object"==typeof e.values?e.values:{};if(p&&c){const e={};for(const t of c.keys){const s=r[t]&&"object"==typeof r[t]?r[t]:{},n={};for(const e of m){const t=s[e.name];n[e.name]=null==t?"":String(t)}e[t]=n}V(e)}else{const e={};for(const t of u){const s=r[t.name];e[t.name]=null==s?"":String(s)}N(e)}})(),()=>{l=!0}},[e,t,d,c,f,u,m,p,o]);const W=()=>{if(p&&c){const e={};for(const t of c.keys){const r={};for(const e of m){const s=coerceField(e,K[t]?.[e.name]??"");void 0!==s&&(r[e.name]=s)}e[t]=r}return e}const e={};for(const t of u){const r=coerceField(t,z[t.name]??"");void 0!==r&&(e[t.name]=r)}return e},X=!t?.asset_id||F||x&&(""===g||g===ROLE_OTHER&&!b.trim())||d.some(e=>e.required&&!j[e.name]?.toString().trim())||(c?.keys.some(e=>c.fields.some(t=>t.required&&!T[e]?.[t.name]?.toString().trim()))??!1);if(!t)return null;const G=n[l]?.label??l;return _jsxs(Dialog,{header:`Edit Asset — ${t.asset_id}`,visible:e,style:{width:"32rem"},onHide:()=>{F||r()},footer:_jsxs(_Fragment,{children:[_jsx(Button,{label:"Cancel",severity:"secondary",onClick:r,disabled:F}),_jsx(Button,{label:"Save",icon:"pi pi-check",onClick:async()=>{if(!t?.asset_id)return;E(!0),A(null);const e={};for(const t of d){const r=coerceField(t,j[t.name]??"");void 0!==r&&(e[t.name]=r)}let n;if(c){n={};for(const e of c.keys){const t={};for(const r of c.fields){const s=coerceField(r,T[e]?.[r.name]??"");void 0!==s&&(t[r.name]=s)}n[e]=t}}const a={asset_id:t.asset_id,location:b,custom:e};n&&(a.sub_locations=n);try{const e=await i("ams.update_asset",MessageType.Request,a);if(!e?.success)return void A(e?.error_message??"update_asset failed");if(I){const e={asset_id:t.asset_id,cal_id:I.cal_id,performed_by:$,expires_at:M?M.toISOString():null,cert_ref:D,notes:B,values:W()},r=await i("ams.update_calibration",MessageType.Request,e);if(!r?.success)return A(r?.error_message??"update_calibration failed"),void k(1)}s?.(),r()}catch(e){A(String(e?.message??e))}finally{E(!1)}},loading:F,disabled:X})]}),children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",fontSize:"0.875rem",color:"var(--text-secondary-color)",marginBottom:"0.75rem"},children:[_jsx("span",{children:"Type"})," ",_jsx("span",{children:G}),_jsx("span",{children:"Serial"})," ",_jsx("span",{children:t.serial||_jsx("em",{children:"(none)"})}),t.install_date&&_jsxs(_Fragment,{children:[_jsx("span",{children:"Installed"}),_jsx("span",{children:new Date(t.install_date).toLocaleString()})]})]}),_jsxs(TabView,{activeIndex:R,onTabChange:e=>k(e.index),children:[_jsxs(TabPanel,{header:"Asset",children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",alignItems:"center"},children:[x&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Role *"}),_jsx(Dropdown,{value:g,options:h,onChange:e=>{var t;(t=e.value)===ROLE_OTHER?y(ROLE_OTHER):(y(t),v(t))},placeholder:"Choose where this asset is mounted"}),g===ROLE_OTHER&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Custom role"}),_jsx(InputText,{value:b,placeholder:"e.g. tsdr_secondary",onChange:e=>v(e.target.value)})]})]}),d.map(e=>{const t=e.label??e.name,r=e.units?`${t} [${e.units}]${e.required?" *":""}`:`${t}${e.required?" *":""}`,s="string"!==e.type&&"bool"!==e.type;return _jsxs(React.Fragment,{children:[_jsx("label",{title:e.description??void 0,children:r}),"bool"===e.type?_jsx(Dropdown,{value:j[e.name]??"",options:[{label:"true",value:"true"},{label:"false",value:"false"}],onChange:t=>C(r=>({...r,[e.name]:t.value})),placeholder:"—"}):_jsx(InputText,{value:j[e.name]??"",keyfilter:s?"num":void 0,placeholder:e.description??void 0,onChange:t=>C(r=>({...r,[e.name]:t.target.value}))})]},e.name)})]}),c&&_jsxs("div",{style:{marginTop:"1.5rem"},children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:c.label??"Sub-locations"}),_jsx("div",{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:c.key_label??"Key"}),c.fields.map(e=>_jsxs("th",{title:e.description??void 0,style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:"",e.required?" *":""]},e.name))]})}),_jsx("tbody",{children:c.keys.map(e=>_jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:e}),c.fields.map(t=>{const r=T[e]?.[t.name]??"",s="string"!==t.type&&"bool"!==t.type;return _jsx("td",{style:{padding:"0.25rem 0.5rem"},children:_jsx(InputText,{value:r,keyfilter:s?"num":void 0,onChange:r=>{const s=r.target.value;S(r=>({...r,[e]:{...r[e]??{},[t.name]:s}}))},style:{width:"100%"}})},t.name)})]},e))})]})})]})]}),I&&_jsxs(TabPanel,{header:`Calibration (${I.cal_id})`,children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",alignItems:"center"},children:[_jsx("label",{children:"Performed by"}),_jsx(InputText,{value:$,onChange:e=>L(e.target.value)}),_jsx("label",{children:"Expires at"}),_jsx(Calendar,{value:M,onChange:e=>q(e.value??null),showIcon:!0,dateFormat:"yy-mm-dd"}),_jsx("label",{children:"Certificate ref"}),_jsx(InputText,{value:D,onChange:e=>H(e.target.value),placeholder:"e.g. ADC-CAL-2026-1043"}),_jsx("label",{children:"Notes"}),_jsx(InputTextarea,{value:B,rows:3,onChange:e=>P(e.target.value),autoResize:!0})]}),_&&_jsxs("div",{style:{marginTop:"1rem"},children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:p?c?.label??"Per-axis calibration":"Calibration values"}),_jsx("div",p&&c?{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:c.key_label??"Key"}),m.map(e=>_jsxs("th",{title:e.description??void 0,style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:"",e.required?" *":""]},e.name))]})}),_jsx("tbody",{children:c.keys.map(e=>_jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:e}),m.map(t=>{const r=K[e]?.[t.name]??"",s="string"!==t.type&&"bool"!==t.type;return _jsx("td",{style:{padding:"0.25rem 0.5rem"},children:_jsx(InputText,{value:r,keyfilter:s?"num":void 0,onChange:r=>{const s=r.target.value;V(r=>({...r,[e]:{...r[e]??{},[t.name]:s}}))},style:{width:"100%"}})},t.name)})]},e))})]})}:{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",alignItems:"center"},children:u.map(e=>{const t=e.label??e.name,r=e.units?`${t} [${e.units}]${e.required?" *":""}`:`${t}${e.required?" *":""}`,s="string"!==e.type&&"bool"!==e.type;return _jsxs(React.Fragment,{children:[_jsx("label",{title:e.description??void 0,children:r}),_jsx(InputText,{value:z[e.name]??"",keyfilter:s?"num":void 0,onChange:t=>N(r=>({...r,[e.name]:t.target.value}))})]},e.name)})})]})]})]}),w&&_jsx("div",{style:{marginTop:"1rem",color:"#ef4444"},children:w})]})};
1
+ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import React,{useContext,useEffect,useMemo,useState}from"react";import{Button}from"primereact/button";import{Calendar}from"primereact/calendar";import{Dialog}from"primereact/dialog";import{Dropdown}from"primereact/dropdown";import{InputText}from"primereact/inputtext";import{InputTextarea}from"primereact/inputtextarea";import{TabPanel,TabView}from"primereact/tabview";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useAms}from"./AmsProvider";const ROLE_OTHER="__other__";function fieldsFor(e,t){const r=e?.[t]?.fields;return Array.isArray(r)?r:[]}function subLocationsFor(e,t){const r=e?.[t]?.sub_locations;return r&&Array.isArray(r.keys)&&Array.isArray(r.fields)?r:null}function calibrationFieldsFor(e,t){const r=e?.[t]?.calibration_fields;return Array.isArray(r)?r:[]}function perAxisCalibrationFieldsFor(e){return e?.calibration_fields??[]}function coerceField(e,t){if(void 0!==t&&""!==t)switch(e.type){case"f32":case"f64":case"i8":case"i16":case"i32":case"i64":case"u8":case"u16":case"u32":case"u64":{const e=Number(t);return Number.isFinite(e)?e:void 0}case"bool":return"true"===t||"1"===t;default:return t}}function seedFromCustom(e,t){if(!e)return"";const r=e[t];return null==r?"":String(r)}export const AssetEditDialog=({visible:e,asset:t,onHide:r,onSaved:s})=>{const{schemas:n,roles:a,readCalibration:o}=useAms(),{invoke:i}=useContext(EventEmitterContext),l=t?.asset_type??"",d=useMemo(()=>fieldsFor(n,l),[n,l]),c=useMemo(()=>subLocationsFor(n,l),[n,l]),u=useMemo(()=>calibrationFieldsFor(n,l),[n,l]),m=useMemo(()=>perAxisCalibrationFieldsFor(c),[c]),p=m.length>0,_=p||u.length>0,f=useMemo(()=>l?a[l]??[]:[],[l,a]),x=f.length>0,h=useMemo(()=>{const e=f.map(e=>({label:e.label??e.location,value:e.location}));return e.push({label:"Other (advanced — type a custom role)",value:ROLE_OTHER}),e},[f]),[g,y]=useState(""),[b,v]=useState(""),[j,C]=useState(""),[T,S]=useState({}),[F,E]=useState({}),[w,A]=useState(!1),[R,k]=useState(null),[I,O]=useState(0),[$,L]=useState(null),[M,q]=useState(""),[D,H]=useState(null),[B,P]=useState(""),[z,N]=useState(""),[K,V]=useState({}),[W,X]=useState({});useEffect(()=>{if(!e||!t)return;k(null),A(!1),O(0),C("string"==typeof t.serial?t.serial:"");const r="string"==typeof t.location?t.location:"",s=f.find(e=>e.location===r);""===r?(y(""),v("")):s?(y(r),v(r)):(y(ROLE_OTHER),v(r));const n={};for(const e of d)n[e.name]=seedFromCustom(t.custom,e.name);S(n);const a={};if(c){const e=t.sub_locations&&"object"==typeof t.sub_locations?t.sub_locations:{};for(const t of c.keys){const r=e[t]&&"object"==typeof e[t]?e[t]:{},s={};for(const e of c.fields){const t=r[e.name];s[e.name]=null==t?"":String(t)}a[t]=s}}E(a),L(null),q(""),H(null),P(""),N(""),V({}),X({});const i="string"==typeof t.current_calibration_id?t.current_calibration_id:"";if(!i)return;let l=!1;return(async()=>{const e=await o(t.asset_id,i);if(l||!e)return;L(e),q("string"==typeof e.performed_by?e.performed_by:""),P("string"==typeof e.cert_ref?e.cert_ref:""),N("string"==typeof e.notes?e.notes:""),H(e.expires_at?new Date(e.expires_at):null);const r=e.values&&"object"==typeof e.values?e.values:{};if(p&&c){const e={};for(const t of c.keys){const s=r[t]&&"object"==typeof r[t]?r[t]:{},n={};for(const e of m){const t=s[e.name];n[e.name]=null==t?"":String(t)}e[t]=n}X(e)}else{const e={};for(const t of u){const s=r[t.name];e[t.name]=null==s?"":String(s)}V(e)}})(),()=>{l=!0}},[e,t,d,c,f,u,m,p,o]);const G=()=>{if(p&&c){const e={};for(const t of c.keys){const r={};for(const e of m){const s=coerceField(e,W[t]?.[e.name]??"");void 0!==s&&(r[e.name]=s)}e[t]=r}return e}const e={};for(const t of u){const r=coerceField(t,K[t.name]??"");void 0!==r&&(e[t.name]=r)}return e},J=!t?.asset_id||w||x&&(""===g||g===ROLE_OTHER&&!b.trim())||d.some(e=>e.required&&!T[e.name]?.toString().trim())||(c?.keys.some(e=>c.fields.some(t=>t.required&&!F[e]?.[t.name]?.toString().trim()))??!1);if(!t)return null;const Q=n[l]?.label??l;return _jsxs(Dialog,{header:`Edit Asset — ${t.asset_id}`,visible:e,style:{width:"32rem"},onHide:()=>{w||r()},footer:_jsxs(_Fragment,{children:[_jsx(Button,{label:"Cancel",severity:"secondary",onClick:r,disabled:w}),_jsx(Button,{label:"Save",icon:"pi pi-check",onClick:async()=>{if(!t?.asset_id)return;A(!0),k(null);const e={};for(const t of d){const r=coerceField(t,T[t.name]??"");void 0!==r&&(e[t.name]=r)}let n;if(c){n={};for(const e of c.keys){const t={};for(const r of c.fields){const s=coerceField(r,F[e]?.[r.name]??"");void 0!==s&&(t[r.name]=s)}n[e]=t}}const a={asset_id:t.asset_id,location:b,serial:j,custom:e};n&&(a.sub_locations=n);try{const e=await i("ams.update_asset",MessageType.Request,a);if(!e?.success)return void k(e?.error_message??"update_asset failed");if($){const e={asset_id:t.asset_id,cal_id:$.cal_id,performed_by:M,expires_at:D?D.toISOString():null,cert_ref:B,notes:z,values:G()},r=await i("ams.update_calibration",MessageType.Request,e);if(!r?.success)return k(r?.error_message??"update_calibration failed"),void O(1)}s?.(),r()}catch(e){k(String(e?.message??e))}finally{A(!1)}},loading:w,disabled:J})]}),children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.25rem 1rem",fontSize:"0.875rem",color:"var(--text-secondary-color)",marginBottom:"0.75rem"},children:[_jsx("span",{children:"Type"})," ",_jsx("span",{children:Q}),t.install_date&&_jsxs(_Fragment,{children:[_jsx("span",{children:"Installed"}),_jsx("span",{children:new Date(t.install_date).toLocaleString()})]})]}),_jsxs(TabView,{activeIndex:I,onTabChange:e=>O(e.index),children:[_jsxs(TabPanel,{header:"Asset",children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",alignItems:"center"},children:[_jsx("label",{children:"Serial"}),_jsx(InputText,{value:j,placeholder:"(none)",onChange:e=>C(e.target.value)}),x&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Role *"}),_jsx(Dropdown,{value:g,options:h,onChange:e=>{var t;(t=e.value)===ROLE_OTHER?y(ROLE_OTHER):(y(t),v(t))},placeholder:"Choose where this asset is mounted"}),g===ROLE_OTHER&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Custom role"}),_jsx(InputText,{value:b,placeholder:"e.g. tsdr_secondary",onChange:e=>v(e.target.value)})]})]}),d.map(e=>{const t=e.label??e.name,r=e.units?`${t} [${e.units}]${e.required?" *":""}`:`${t}${e.required?" *":""}`,s="string"!==e.type&&"bool"!==e.type;return _jsxs(React.Fragment,{children:[_jsx("label",{title:e.description??void 0,children:r}),"bool"===e.type?_jsx(Dropdown,{value:T[e.name]??"",options:[{label:"true",value:"true"},{label:"false",value:"false"}],onChange:t=>S(r=>({...r,[e.name]:t.value})),placeholder:"—"}):_jsx(InputText,{value:T[e.name]??"",keyfilter:s?"num":void 0,placeholder:e.description??void 0,onChange:t=>S(r=>({...r,[e.name]:t.target.value}))})]},e.name)})]}),c&&_jsxs("div",{style:{marginTop:"1.5rem"},children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:c.label??"Sub-locations"}),_jsx("div",{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:c.key_label??"Key"}),c.fields.map(e=>_jsxs("th",{title:e.description??void 0,style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:"",e.required?" *":""]},e.name))]})}),_jsx("tbody",{children:c.keys.map(e=>_jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:e}),c.fields.map(t=>{const r=F[e]?.[t.name]??"",s="string"!==t.type&&"bool"!==t.type;return _jsx("td",{style:{padding:"0.25rem 0.5rem"},children:_jsx(InputText,{value:r,keyfilter:s?"num":void 0,onChange:r=>{const s=r.target.value;E(r=>({...r,[e]:{...r[e]??{},[t.name]:s}}))},style:{width:"100%"}})},t.name)})]},e))})]})})]})]}),$&&_jsxs(TabPanel,{header:`Calibration (${$.cal_id})`,children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",alignItems:"center"},children:[_jsx("label",{children:"Performed by"}),_jsx(InputText,{value:M,onChange:e=>q(e.target.value)}),_jsx("label",{children:"Expires at"}),_jsx(Calendar,{value:D,onChange:e=>H(e.value??null),showIcon:!0,dateFormat:"yy-mm-dd"}),_jsx("label",{children:"Certificate ref"}),_jsx(InputText,{value:B,onChange:e=>P(e.target.value),placeholder:"e.g. ADC-CAL-2026-1043"}),_jsx("label",{children:"Notes"}),_jsx(InputTextarea,{value:z,rows:3,onChange:e=>N(e.target.value),autoResize:!0})]}),_&&_jsxs("div",{style:{marginTop:"1rem"},children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:p?c?.label??"Per-axis calibration":"Calibration values"}),_jsx("div",p&&c?{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:c.key_label??"Key"}),m.map(e=>_jsxs("th",{title:e.description??void 0,style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:"",e.required?" *":""]},e.name))]})}),_jsx("tbody",{children:c.keys.map(e=>_jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:e}),m.map(t=>{const r=W[e]?.[t.name]??"",s="string"!==t.type&&"bool"!==t.type;return _jsx("td",{style:{padding:"0.25rem 0.5rem"},children:_jsx(InputText,{value:r,keyfilter:s?"num":void 0,onChange:r=>{const s=r.target.value;X(r=>({...r,[e]:{...r[e]??{},[t.name]:s}}))},style:{width:"100%"}})},t.name)})]},e))})]})}:{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",alignItems:"center"},children:u.map(e=>{const t=e.label??e.name,r=e.units?`${t} [${e.units}]${e.required?" *":""}`:`${t}${e.required?" *":""}`,s="string"!==e.type&&"bool"!==e.type;return _jsxs(React.Fragment,{children:[_jsx("label",{title:e.description??void 0,children:r}),_jsx(InputText,{value:K[e.name]??"",keyfilter:s?"num":void 0,onChange:t=>V(r=>({...r,[e.name]:t.target.value}))})]},e.name)})})]})]})]}),R&&_jsx("div",{style:{marginTop:"1rem",color:"#ef4444"},children:R})]})};
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Touch-friendly row sizing for the AMS asset list.
3
+ *
4
+ * The shop-floor HMI is a touchscreen and operators were mis-tapping
5
+ * the dense default DataTable rows. Adding vertical padding to each
6
+ * body cell enlarges the per-row touch target without changing the
7
+ * column layout or text size.
8
+ */
9
+ .ams-asset-table .p-datatable-tbody > tr > td {
10
+ padding-top: 0.9rem;
11
+ padding-bottom: 0.9rem;
12
+ }
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
+ import './AssetRegistryTable.css';
2
3
  export declare const AssetRegistryTable: React.FC;
3
4
  //# sourceMappingURL=AssetRegistryTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AssetRegistryTable.d.ts","sourceRoot":"","sources":["../../../src/components/ams/AssetRegistryTable.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAuJxE,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAwgBtC,CAAC"}
1
+ {"version":3,"file":"AssetRegistryTable.d.ts","sourceRoot":"","sources":["../../../src/components/ams/AssetRegistryTable.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAUxE,OAAO,0BAA0B,CAAC;AA8IlC,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAkhBtC,CAAC"}
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import React,{useContext,useEffect,useMemo,useState}from"react";import{Button}from"primereact/button";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Dropdown}from"primereact/dropdown";import{InputText}from"primereact/inputtext";import{Dialog}from"primereact/dialog";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useAms}from"./AmsProvider";const ROLE_OTHER="__other__",EMPTY_ADD={open:!1,assetType:"",serial:"",roleSelection:"",location:"",customFields:{},subLocationFields:{}};function roleLabel(e){return e.label??e.location}function roleUsageSummary(e){const s=[];return e.used_by.length>0&&s.push(`Used by test method${1===e.used_by.length?"":"s"}: ${e.used_by.join(", ")}`),e.used_by_modules.length>0&&s.push(`Used by module${1===e.used_by_modules.length?"":"s"}: ${e.used_by_modules.join(", ")}`),0===s.length?"Not referenced by any test method or module.":s.join(" • ")}function fieldsFor(e,s){const t=e?.[s]?.fields;return Array.isArray(t)?t:[]}function subLocationsFor(e,s){const t=e?.[s]?.sub_locations;return t&&Array.isArray(t.keys)&&Array.isArray(t.fields)?t:null}function seedCustomFromRoleDefaults(e,s){const t={};if(!e||!e.defaults)return t;const o=new Set(s.map(e=>e.name));for(const[s,l]of Object.entries(e.defaults))o.has(s)&&null!=l&&(t[s]=String(l));return t}function coerceField(e,s){if(void 0!==s&&""!==s)switch(e.type){case"f32":case"f64":case"i8":case"i16":case"i32":case"i64":case"u8":case"u16":case"u32":case"u64":{const e=Number(s);return Number.isFinite(e)?e:void 0}case"bool":return"true"===s||"1"===s;default:return s}}export const AssetRegistryTable=()=>{const{schemas:e,roles:s,assets:t,refreshAssets:o,setSelection:l,selection:a}=useAms(),{invoke:n}=useContext(EventEmitterContext),[r,i]=useState(null),[c,d]=useState(null),[u,m]=useState(EMPTY_ADD);useEffect(()=>{const t=t=>{const o=t.detail,l=o?.assetType??"",a=o?.location??"";if(!l)return;const n=(s[l]??[]).find(e=>e.location===a),r=fieldsFor(e,l);m({...EMPTY_ADD,open:!0,assetType:l,roleSelection:a,location:a,customFields:seedCustomFromRoleDefaults(n,r)})};return window.addEventListener("ams:prefill-add",t),()=>window.removeEventListener("ams:prefill-add",t)},[s,e]);const p=useMemo(()=>Object.keys(e).map(s=>({label:e[s]?.label??s,value:s})),[e]),y=useMemo(()=>u.assetType?s[u.assetType]??[]:[],[u.assetType,s]),_=y.length>0,h=useMemo(()=>{const e=y.map(e=>({label:roleLabel(e),value:e.location}));return e.push({label:"Other (advanced — type a custom role)",value:ROLE_OTHER}),e},[y]),f=useMemo(()=>u.roleSelection===ROLE_OTHER?null:y.find(e=>e.location===u.roleSelection)??null,[u.roleSelection,y]),b=useMemo(()=>t.filter(e=>(!r||e.asset_type===r)&&(!c||e.status===c)),[t,r,c]),x=useMemo(()=>fieldsFor(e,u.assetType),[e,u.assetType]),g=useMemo(()=>subLocationsFor(e,u.assetType),[e,u.assetType]),j=!u.assetType||_&&(""===u.roleSelection||u.roleSelection===ROLE_OTHER&&!u.location.trim())||x.some(e=>e.required&&!u.customFields[e.name]?.toString().trim())||(g?.keys.some(e=>g.fields.some(s=>s.required&&!u.subLocationFields[e]?.[s.name]?.toString().trim()))??!1);return _jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[_jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:[_jsx(Dropdown,{value:r,options:[{label:"All Types",value:null},...p],onChange:e=>i(e.value),placeholder:"Filter by type"}),_jsx(Dropdown,{value:c,options:[{label:"All Statuses",value:null},{label:"Active",value:"active"},{label:"Out for Service",value:"out_for_service"},{label:"Retired",value:"retired"}],onChange:e=>d(e.value),placeholder:"Filter by status"}),_jsx("span",{style:{marginLeft:"auto"},children:_jsx(Button,{icon:"pi pi-plus",label:"Add Asset",onClick:()=>m(e=>({...e,open:!0})),disabled:0===p.length})})]}),_jsxs(DataTable,{value:b,selectionMode:"single",selection:b.find(e=>e.asset_id===a.assetId)??null,onSelectionChange:e=>{const s=e.value;s&&l({assetType:s.asset_type,assetId:s.asset_id})},dataKey:"asset_id",emptyMessage:0===p.length?"AMS not enabled in this project (no asset_types declared).":"No assets registered yet.",size:"small",stripedRows:!0,children:[_jsx(Column,{field:"asset_id",header:"Asset ID"}),_jsx(Column,{field:"asset_type",header:"Type",body:s=>e[s.asset_type]?.label??s.asset_type}),_jsx(Column,{field:"serial",header:"Serial"}),_jsx(Column,{field:"location",header:"Role",body:e=>e.location?((e,t)=>{const o=(s[e]??[]).find(e=>e.location===t);return o?roleLabel(o):t})(e.asset_type,e.location):_jsx("span",{style:{color:"#9ca3af"},children:"—"})}),_jsx(Column,{field:"status",header:"Status"}),_jsx(Column,{header:"Calibration",body:e=>e.current_calibration_id?_jsx("span",{title:e.current_calibration_id,children:"✓"}):_jsx("span",{style:{color:"#f59e0b"},children:"none"})})]}),_jsxs(Dialog,{header:"Add New Asset",visible:u.open,style:{width:"32rem"},onHide:()=>m(EMPTY_ADD),footer:_jsxs(_Fragment,{children:[_jsx(Button,{label:"Cancel",severity:"secondary",onClick:()=>m(EMPTY_ADD)}),_jsx(Button,{label:"Create",icon:"pi pi-check",onClick:async()=>{if(!u.assetType)return;const e={};for(const s of x){const t=u.customFields[s.name];if(void 0!==t&&""!==t)switch(s.type){case"f32":case"f64":case"i8":case"i16":case"i32":case"i64":case"u8":case"u16":case"u32":case"u64":{const o=Number(t);Number.isFinite(o)&&(e[s.name]=o);break}case"bool":e[s.name]="true"===t||"1"===t;break;default:e[s.name]=t}}const s={};if(g)for(const e of g.keys){const t={};for(const s of g.fields){const o=coerceField(s,u.subLocationFields[e]?.[s.name]??"");void 0!==o&&(t[s.name]=o)}s[e]=t}const t={asset_type:u.assetType,serial:u.serial,location:u.location,custom:e};g&&(t.sub_locations=s);try{const e=await n("ams.create_asset",MessageType.Request,t);e?.success&&(m(EMPTY_ADD),await o(),e.data?.asset_id&&l({assetType:u.assetType,assetId:e.data.asset_id}))}catch(e){}},disabled:j})]}),children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",alignItems:"center"},children:[_jsx("label",{children:"Type *"}),_jsx(Dropdown,{value:u.assetType,options:p,onChange:t=>(t=>{const o=s[t]??[],l=1===o.length?o[0]:void 0,a=l?{roleSelection:l.location,location:l.location}:{roleSelection:"",location:""},n=fieldsFor(e,t);m(e=>({...e,assetType:t,...a,customFields:seedCustomFromRoleDefaults(l,n),subLocationFields:{}}))})(t.value),placeholder:"Choose asset type"}),_jsx("label",{children:"Serial"}),_jsx(InputText,{value:u.serial,onChange:e=>m(s=>({...s,serial:e.target.value}))}),_&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Role *"}),_jsx(Dropdown,{value:u.roleSelection,options:h,onChange:e=>(e=>{if(e===ROLE_OTHER)return void m(e=>({...e,roleSelection:ROLE_OTHER,location:""}));const s=y.find(s=>s.location===e);m(t=>({...t,roleSelection:e,location:e,customFields:seedCustomFromRoleDefaults(s,x)}))})(e.value),placeholder:"Choose where this asset is mounted"}),u.roleSelection===ROLE_OTHER&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Custom role"}),_jsx(InputText,{value:u.location,placeholder:"e.g. tsdr_secondary",onChange:e=>m(s=>({...s,location:e.target.value}))})]})]}),x.map(e=>{const s=e.label??e.name,t=e.units?`${s} [${e.units}]${e.required?" *":""}`:`${s}${e.required?" *":""}`,o="string"!==e.type&&"bool"!==e.type;return _jsxs(React.Fragment,{children:[_jsx("label",{title:e.description??void 0,children:t}),"bool"===e.type?_jsx(Dropdown,{value:u.customFields[e.name]??"",options:[{label:"true",value:"true"},{label:"false",value:"false"}],onChange:s=>m(t=>({...t,customFields:{...t.customFields,[e.name]:s.value}})),placeholder:"—"}):_jsx(InputText,{value:u.customFields[e.name]??"",keyfilter:o?"num":void 0,placeholder:e.description??void 0,onChange:s=>m(t=>({...t,customFields:{...t.customFields,[e.name]:s.target.value}}))})]},e.name)})]}),g&&_jsxs("div",{style:{marginTop:"1.5rem"},children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:g.label??"Sub-locations"}),_jsx("div",{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:g.key_label??"Key"}),g.fields.map(e=>_jsxs("th",{title:e.description??void 0,style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:"",e.required?" *":""]},e.name))]})}),_jsx("tbody",{children:g.keys.map(e=>_jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:e}),g.fields.map(s=>{const t=u.subLocationFields[e]?.[s.name]??"",o="string"!==s.type&&"bool"!==s.type;return _jsx("td",{style:{padding:"0.25rem 0.5rem"},children:_jsx(InputText,{value:t,keyfilter:o?"num":void 0,onChange:t=>{const o=t.target.value;m(t=>({...t,subLocationFields:{...t.subLocationFields,[e]:{...t.subLocationFields[e]??{},[s.name]:o}}}))},style:{width:"100%"}})},s.name)})]},e))})]})})]}),_jsxs("div",{style:{fontSize:"0.875rem",color:"#9ca3af",marginTop:"1rem"},children:[_&&f&&_jsxs(_Fragment,{children:[f.description&&_jsx("p",{style:{margin:"0 0 0.5rem 0"},children:f.description}),_jsxs("p",{style:{margin:"0 0 0.5rem 0",color:"#34d399"},children:["✓ ",roleUsageSummary(f)]})]}),_&&u.roleSelection===ROLE_OTHER&&_jsx("p",{style:{margin:"0 0 0.5rem 0",color:"#f59e0b"},children:"⚠ No test method on this machine references this custom role yet. The asset will be registered but won't be picked up at start_test unless you add an asset_ref to a test method's project.json."}),!_&&u.assetType&&_jsx("p",{style:{margin:"0 0 0.5rem 0"},children:"This asset type isn't selected by physical role on this machine — test methods reference it by ID instead. Just register the asset and pick it by ID on the Test Setup form when running a test."}),_jsxs("p",{style:{margin:0},children:["The asset_id is generated by the server (format:"," ",_jsxs("code",{children:[u.assetType?e[u.assetType]?.id_prefix??"A-":"A-","YYYYMMDDTHHMMSS"]}),"). Manufacturer serial is recorded for traceability but is not used as the unique key."]})]})]})]})};
1
+ import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import React,{useContext,useEffect,useMemo,useState}from"react";import{Button}from"primereact/button";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Dropdown}from"primereact/dropdown";import{InputText}from"primereact/inputtext";import{Dialog}from"primereact/dialog";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useAms}from"./AmsProvider";import"./AssetRegistryTable.css";const ROLE_OTHER="__other__",EMPTY_ADD={open:!1,assetType:"",serial:"",roleSelection:"",location:"",customFields:{},subLocationFields:{}};function roleLabel(e){return e.label??e.location}function roleUsageSummary(e){const s=[];return e.used_by.length>0&&s.push(`Used by test method${1===e.used_by.length?"":"s"}: ${e.used_by.join(", ")}`),e.used_by_modules.length>0&&s.push(`Used by module${1===e.used_by_modules.length?"":"s"}: ${e.used_by_modules.join(", ")}`),0===s.length?"Not referenced by any test method or module.":s.join(" • ")}function fieldsFor(e,s){const t=e?.[s]?.fields;return Array.isArray(t)?t:[]}function subLocationsFor(e,s){const t=e?.[s]?.sub_locations;return t&&Array.isArray(t.keys)&&Array.isArray(t.fields)?t:null}function seedCustomFromRoleDefaults(e,s){const t={};if(!e||!e.defaults)return t;const o=new Set(s.map(e=>e.name));for(const[s,l]of Object.entries(e.defaults))o.has(s)&&null!=l&&(t[s]=String(l));return t}function coerceField(e,s){if(void 0!==s&&""!==s)switch(e.type){case"f32":case"f64":case"i8":case"i16":case"i32":case"i64":case"u8":case"u16":case"u32":case"u64":{const e=Number(s);return Number.isFinite(e)?e:void 0}case"bool":return"true"===s||"1"===s;default:return s}}export const AssetRegistryTable=()=>{const{schemas:e,roles:s,assets:t,refreshAssets:o,setSelection:l,selection:a}=useAms(),{invoke:n}=useContext(EventEmitterContext),[r,i]=useState(null),[c,d]=useState(null),[u,m]=useState(EMPTY_ADD);useEffect(()=>{const t=t=>{const o=t.detail,l=o?.assetType??"",a=o?.location??"";if(!l)return;const n=(s[l]??[]).find(e=>e.location===a),r=fieldsFor(e,l);m({...EMPTY_ADD,open:!0,assetType:l,roleSelection:a,location:a,customFields:seedCustomFromRoleDefaults(n,r)})};return window.addEventListener("ams:prefill-add",t),()=>window.removeEventListener("ams:prefill-add",t)},[s,e]);const p=useMemo(()=>Object.keys(e).map(s=>({label:e[s]?.label??s,value:s})),[e]),y=useMemo(()=>u.assetType?s[u.assetType]??[]:[],[u.assetType,s]),_=y.length>0,h=useMemo(()=>{const e=y.map(e=>({label:roleLabel(e),value:e.location}));return e.push({label:"Other (advanced — type a custom role)",value:ROLE_OTHER}),e},[y]),f=useMemo(()=>u.roleSelection===ROLE_OTHER?null:y.find(e=>e.location===u.roleSelection)??null,[u.roleSelection,y]),b=useMemo(()=>t.filter(e=>(!r||e.asset_type===r)&&(!c||e.status===c)),[t,r,c]),x=useMemo(()=>fieldsFor(e,u.assetType),[e,u.assetType]),g=useMemo(()=>subLocationsFor(e,u.assetType),[e,u.assetType]),j=!u.assetType||_&&(""===u.roleSelection||u.roleSelection===ROLE_OTHER&&!u.location.trim())||x.some(e=>e.required&&!u.customFields[e.name]?.toString().trim())||(g?.keys.some(e=>g.fields.some(s=>s.required&&!u.subLocationFields[e]?.[s.name]?.toString().trim()))??!1);return _jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[_jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:[_jsx(Dropdown,{value:r,options:[{label:"All Types",value:null},...p],onChange:e=>i(e.value),placeholder:"Filter by type"}),_jsx(Dropdown,{value:c,options:[{label:"All Statuses",value:null},{label:"Active",value:"active"},{label:"Out for Service",value:"out_for_service"},{label:"Retired",value:"retired"}],onChange:e=>d(e.value),placeholder:"Filter by status"}),_jsx("span",{style:{marginLeft:"auto"},children:_jsx(Button,{icon:"pi pi-plus",label:"Add Asset",onClick:()=>m(e=>({...e,open:!0})),disabled:0===p.length})})]}),_jsxs(DataTable,{value:b,selectionMode:"single",selection:b.find(e=>e.asset_id===a.assetId)??null,onSelectionChange:e=>{const s=e.value;s&&l({assetType:s.asset_type,assetId:s.asset_id})},dataKey:"asset_id",emptyMessage:0===p.length?"AMS not enabled in this project (no asset_types declared).":"No assets registered yet.",stripedRows:!0,className:"ams-asset-table",children:[_jsx(Column,{field:"asset_id",header:"Asset ID"}),_jsx(Column,{field:"asset_type",header:"Type",body:s=>e[s.asset_type]?.label??s.asset_type}),_jsx(Column,{field:"serial",header:"Serial"}),_jsx(Column,{field:"location",header:"Role",body:e=>e.location?((e,t)=>{const o=(s[e]??[]).find(e=>e.location===t);return o?roleLabel(o):t})(e.asset_type,e.location):_jsx("span",{style:{color:"#9ca3af"},children:"—"})}),_jsx(Column,{field:"status",header:"Status"}),_jsx(Column,{header:"Calibration",body:e=>e.current_calibration_id?_jsx("span",{title:e.current_calibration_id,children:"✓"}):_jsx("span",{style:{color:"#f59e0b"},children:"none"})})]}),_jsxs(Dialog,{header:"Add New Asset",visible:u.open,style:{width:"32rem"},onHide:()=>m(EMPTY_ADD),footer:_jsxs(_Fragment,{children:[_jsx(Button,{label:"Cancel",severity:"secondary",onClick:()=>m(EMPTY_ADD)}),_jsx(Button,{label:"Create",icon:"pi pi-check",onClick:async()=>{if(!u.assetType)return;const e={};for(const s of x){const t=u.customFields[s.name];if(void 0!==t&&""!==t)switch(s.type){case"f32":case"f64":case"i8":case"i16":case"i32":case"i64":case"u8":case"u16":case"u32":case"u64":{const o=Number(t);Number.isFinite(o)&&(e[s.name]=o);break}case"bool":e[s.name]="true"===t||"1"===t;break;default:e[s.name]=t}}const s={};if(g)for(const e of g.keys){const t={};for(const s of g.fields){const o=coerceField(s,u.subLocationFields[e]?.[s.name]??"");void 0!==o&&(t[s.name]=o)}s[e]=t}const t={asset_type:u.assetType,serial:u.serial,location:u.location,custom:e};g&&(t.sub_locations=s);try{const e=await n("ams.create_asset",MessageType.Request,t);e?.success&&(m(EMPTY_ADD),await o(),e.data?.asset_id&&l({assetType:u.assetType,assetId:e.data.asset_id}))}catch(e){}},disabled:j})]}),children:[_jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",alignItems:"center"},children:[_jsx("label",{children:"Type *"}),_jsx(Dropdown,{value:u.assetType,options:p,onChange:t=>(t=>{const o=s[t]??[],l=1===o.length?o[0]:void 0,a=l?{roleSelection:l.location,location:l.location}:{roleSelection:"",location:""},n=fieldsFor(e,t);m(e=>({...e,assetType:t,...a,customFields:seedCustomFromRoleDefaults(l,n),subLocationFields:{}}))})(t.value),placeholder:"Choose asset type"}),u.assetType&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Serial"}),_jsx(InputText,{value:u.serial,onChange:e=>m(s=>({...s,serial:e.target.value}))})]}),_&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Role *"}),_jsx(Dropdown,{value:u.roleSelection,options:h,onChange:e=>(e=>{if(e===ROLE_OTHER)return void m(e=>({...e,roleSelection:ROLE_OTHER,location:""}));const s=y.find(s=>s.location===e);m(t=>({...t,roleSelection:e,location:e,customFields:seedCustomFromRoleDefaults(s,x)}))})(e.value),placeholder:"Choose where this asset is mounted"}),u.roleSelection===ROLE_OTHER&&_jsxs(_Fragment,{children:[_jsx("label",{children:"Custom role"}),_jsx(InputText,{value:u.location,placeholder:"e.g. tsdr_secondary",onChange:e=>m(s=>({...s,location:e.target.value}))})]})]}),x.map(e=>{const s=e.label??e.name,t=e.units?`${s} [${e.units}]${e.required?" *":""}`:`${s}${e.required?" *":""}`,o="string"!==e.type&&"bool"!==e.type;return _jsxs(React.Fragment,{children:[_jsx("label",{title:e.description??void 0,children:t}),"bool"===e.type?_jsx(Dropdown,{value:u.customFields[e.name]??"",options:[{label:"true",value:"true"},{label:"false",value:"false"}],onChange:s=>m(t=>({...t,customFields:{...t.customFields,[e.name]:s.value}})),placeholder:"—"}):_jsx(InputText,{value:u.customFields[e.name]??"",keyfilter:o?"num":void 0,placeholder:e.description??void 0,onChange:s=>m(t=>({...t,customFields:{...t.customFields,[e.name]:s.target.value}}))})]},e.name)})]}),g&&_jsxs("div",{style:{marginTop:"1.5rem"},children:[_jsx("h4",{style:{margin:"0 0 0.5rem 0"},children:g.label??"Sub-locations"}),_jsx("div",{style:{overflowX:"auto"},children:_jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"0.875rem"},children:[_jsx("thead",{children:_jsxs("tr",{children:[_jsx("th",{style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:g.key_label??"Key"}),g.fields.map(e=>_jsxs("th",{title:e.description??void 0,style:{textAlign:"left",padding:"0.25rem 0.5rem",borderBottom:"1px solid var(--surface-border)"},children:[e.label??e.name,e.units?` [${e.units}]`:"",e.required?" *":""]},e.name))]})}),_jsx("tbody",{children:g.keys.map(e=>_jsxs("tr",{children:[_jsx("td",{style:{padding:"0.25rem 0.5rem",fontWeight:600},children:e}),g.fields.map(s=>{const t=u.subLocationFields[e]?.[s.name]??"",o="string"!==s.type&&"bool"!==s.type;return _jsx("td",{style:{padding:"0.25rem 0.5rem"},children:_jsx(InputText,{value:t,keyfilter:o?"num":void 0,onChange:t=>{const o=t.target.value;m(t=>({...t,subLocationFields:{...t.subLocationFields,[e]:{...t.subLocationFields[e]??{},[s.name]:o}}}))},style:{width:"100%"}})},s.name)})]},e))})]})})]}),_jsxs("div",{style:{fontSize:"0.875rem",color:"#9ca3af",marginTop:"1rem"},children:[_&&f&&_jsxs(_Fragment,{children:[f.description&&_jsx("p",{style:{margin:"0 0 0.5rem 0"},children:f.description}),_jsxs("p",{style:{margin:"0 0 0.5rem 0",color:"#34d399"},children:["✓ ",roleUsageSummary(f)]})]}),_&&u.roleSelection===ROLE_OTHER&&_jsx("p",{style:{margin:"0 0 0.5rem 0",color:"#f59e0b"},children:"⚠ No test method on this machine references this custom role yet. The asset will be registered but won't be picked up at start_test unless you add an asset_ref to a test method's project.json."}),!_&&u.assetType&&_jsx("p",{style:{margin:"0 0 0.5rem 0"},children:"This asset type isn't selected by physical role on this machine — test methods reference it by ID instead. Just register the asset and pick it by ID on the Test Setup form when running a test."}),_jsxs("p",{style:{margin:0},children:["The asset_id is generated by the server (format:"," ",_jsxs("code",{children:[u.assetType?e[u.assetType]?.id_prefix??"A-":"A-","YYYYMMDDTHHMMSS"]}),"). Manufacturer serial is recorded for traceability but is not used as the unique key."]})]})]})]})};
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { TestConfiguration } from './TestSetupForm';
3
+ /** Display name for one configuration: prefer `label`, fall back to `name`. */
4
+ export declare const configLabelOf: (cfg: TestConfiguration | undefined) => string;
5
+ export interface ConfigurationDialogProps {
6
+ visible: boolean;
7
+ onHide: () => void;
8
+ /** Configurations declared on the active method. */
9
+ configurations: TestConfiguration[];
10
+ /** `name` of the configuration currently applied on the form. The
11
+ * dropdown opens pointing at this so the dialog reflects state. */
12
+ currentConfigName: string;
13
+ /**
14
+ * Called with the chosen configuration `name` when the operator
15
+ * clicks OK. Cancel does not fire this. The parent applies the
16
+ * configuration's defaults to the fields.
17
+ */
18
+ onSelected: (configName: string) => void;
19
+ }
20
+ export declare const ConfigurationDialog: React.FC<ConfigurationDialogProps>;
21
+ //# sourceMappingURL=ConfigurationDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigurationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/tis/ConfigurationDialog.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAI5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,+EAA+E;AAC/E,eAAO,MAAM,aAAa,GAAI,KAAK,iBAAiB,GAAG,SAAS,KAAG,MACK,CAAC;AAEzE,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,oDAAoD;IACpD,cAAc,EAAE,iBAAiB,EAAE,CAAC;IACpC;wEACoE;IACpE,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAsFlE,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React,{useEffect,useMemo,useState}from"react";import{Button}from"primereact/button";import{Dialog}from"primereact/dialog";import{Dropdown}from"primereact/dropdown";export const configLabelOf=e=>e?.label&&e.label.length>0?e.label:e?.name??"";export const ConfigurationDialog=({visible:e,onHide:o,configurations:i,currentConfigName:t,onSelected:n})=>{const[r,l]=useState(t);useEffect(()=>{e&&l(t)},[e,t]);const a=useMemo(()=>i.map(e=>({label:configLabelOf(e),value:e.name})),[i]),s=i.find(e=>e.name===r),c=s?.description&&s.description.length>0?s.description:null,d=_jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem"},children:[_jsx(Button,{label:"Cancel",icon:"pi pi-times",onClick:o,text:!0}),_jsx(Button,{label:"OK",icon:"pi pi-check",onClick:()=>{r&&r!==t&&n(r),o()},disabled:!r})]});return _jsx(Dialog,{header:"Select Configuration",visible:e,onHide:o,footer:d,modal:!0,style:{width:"min(560px, 90vw)"},children:0===a.length?_jsx("p",{style:{color:"var(--text-secondary-color)"},children:"This test method declares no configurations."}):_jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[_jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[_jsx("label",{htmlFor:"acConfigurationDropdown",style:{flexShrink:0},children:"Configuration:"}),_jsx(Dropdown,{inputId:"acConfigurationDropdown",value:r,options:a,onChange:e=>l(e.value),placeholder:"Select a configuration",style:{flex:1}})]}),_jsx("div",{style:{padding:"0.75rem 1rem",background:"var(--surface-100)",borderRadius:"6px",minHeight:"4.5rem",color:c?"var(--text-color)":"var(--text-secondary-color)",fontStyle:c?"normal":"italic",whiteSpace:"pre-wrap"},children:c??"No description provided for this configuration."})]})})};
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React,{useState,useEffect,useContext}from"react";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Button}from"primereact/button";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useTis}from"./TisProvider";const downloadCsvBlob=(e,t)=>{const o=new Blob([t],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)};export const ResultHistoryTable=e=>{const t=useTis(),o=e.projectId??t.selection.projectId,r=e.methodId,[i,s]=useState([]),[a,n]=useState(!1),[l,d]=useState(null),[c,p]=useState(null),{invoke:m}=useContext(EventEmitterContext),u=async()=>{if(o){n(!0);try{const e={project_id:o};r&&(e.method_id=r);const t=await m("tis.list_tests",MessageType.Request,e);t.success&&t.data&&t.data.tests&&s(t.data.tests)}catch(e){}n(!1)}else s([])};useEffect(()=>{u()},[o,r,t.state.activeRunId]);const f=async(e,t)=>{const i=e?.run_id,s=e?.method_id??r;if(!i||!s||!o)return;const a="report"===t?"tis.export_test_csv":"tis.export_test_data_csv",n="report"===t?"test report":"test data";d({runId:i,kind:t});try{const e=await m(a,MessageType.Request,{project_id:o,method_id:s,run_id:i});if(!e?.success)return void alert(`Failed to build ${n} for ${i}`+(e?.error_message?`: ${e.error_message}`:""));const r="string"==typeof e.data?.csv?e.data.csv:"";if(!r)return void alert(`${n} for ${i} is empty.`);const l="string"==typeof e.data?.filename&&e.data.filename?e.data.filename:`${o}_${s}_${i}_${t}.csv`;downloadCsvBlob(l,r)}catch(e){alert(`Download failed: ${e instanceof Error?e.message:String(e)}`)}finally{d(null)}},_=async e=>{if(!o)return;const t="report"===e?"tis.export_project_csv":"tis.export_project_zip",r="report"===e?"project report":"project archive";p(e);try{const i=await m(t,MessageType.Request,{project_id:o});if(!i?.success)return void alert(`Failed to build ${r}`+(i?.error_message?`: ${i.error_message}`:""));if("report"===e){const e="string"==typeof i.data?.csv?i.data.csv:"";if(!e)return void alert(`Project ${o} has no tests to report.`);const t="string"==typeof i.data?.filename&&i.data.filename?i.data.filename:`${o}_project_report.csv`;downloadCsvBlob(t,e)}else{const e="string"==typeof i.data?.download_url?i.data.download_url:"";if(!e)return void alert(`Server did not return a download URL for ${r}.`);const t=document.createElement("a");t.href=e,t.download="string"==typeof i.data?.filename?i.data.filename:`${o}_project_archive.zip`,document.body.appendChild(t),t.click(),t.remove()}}catch(e){alert(`Download failed: ${e instanceof Error?e.message:String(e)}`)}finally{p(null)}},h=e=>{const t="string"==typeof e?.sample_id?e.sample_id:"";if(t)return t;const o=e?.config;return o&&"object"==typeof o&&"string"==typeof o.sample_id?o.sample_id:""};return _jsxs("div",{style:{width:"100%",maxWidth:"100%",overflow:"hidden",boxSizing:"border-box"},children:[_jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem",gap:"0.5rem",flexWrap:"wrap"},children:[_jsx("h3",{style:{margin:0},children:o?`Test History: ${o}${r?` / ${r}`:""}`:"Test History (no project selected)"}),_jsxs("div",{style:{display:"flex",gap:"0.4rem",alignItems:"center"},children:[_jsx(Button,{icon:"report"===c?"pi pi-spin pi-spinner":"pi pi-file",label:"Download Report",size:"small",outlined:!0,disabled:!o||null!==c,onClick:()=>_("report"),tooltip:"Download a CSV report of every test in this project",tooltipOptions:{position:"bottom"}}),_jsx(Button,{icon:"archive"===c?"pi pi-spin pi-spinner":"pi pi-box",label:"Download Archive",size:"small",outlined:!0,disabled:!o||null!==c,onClick:()=>_("archive"),tooltip:"Download a ZIP of the entire project directory (all tests, raw data, configs)",tooltipOptions:{position:"bottom"}}),_jsx(Button,{icon:"pi pi-refresh",label:"Refresh",size:"small",onClick:u,disabled:a})]})]}),_jsxs(DataTable,{value:i,loading:a,paginator:!0,rows:10,emptyMessage:"No tests found.",scrollable:!0,scrollHeight:"flex",tableStyle:{minWidth:0},style:{width:"100%"},selectionMode:"single",onSelectionChange:e=>{const o=e.value;o?.run_id&&t.setSelection({projectId:o.project_id??null,methodId:o.method_id??null,runId:o.run_id})},children:[_jsx(Column,{header:"Sample ID",sortable:!0,body:h,sortFunction:e=>{const t=[...e.data];return t.sort((t,o)=>h(t).localeCompare(h(o))*(e.order??1)),t},style:{minWidth:"8rem"}}),_jsx(Column,{field:"start_time",header:"Date/Time",sortable:!0,body:e=>{return(t=e.start_time)?new Date(t).toLocaleString():"";var t},style:{minWidth:"12rem"}}),_jsx(Column,{field:"method_id",header:"Test Method",sortable:!0,style:{minWidth:"10rem"}}),_jsx(Column,{field:"run_id",header:"Run ID",sortable:!0,style:{minWidth:"12rem"}}),_jsx(Column,{header:"Download",style:{width:"14rem"},body:e=>{const t=l?.runId===e.run_id&&"data"===l?.kind,o=l?.runId===e.run_id&&"report"===l?.kind,r=null!==l;return _jsxs("div",{style:{display:"flex",gap:"0.4rem"},children:[_jsx(Button,{icon:t?"pi pi-spin pi-spinner":"pi pi-download",label:"Data",size:"small",outlined:!0,disabled:r,onClick:()=>f(e,"data"),tooltip:"Download raw + filtered trace data as one CSV",tooltipOptions:{position:"left"}}),_jsx(Button,{icon:o?"pi pi-spin pi-spinner":"pi pi-file",label:"Report",size:"small",outlined:!0,disabled:r,onClick:()=>f(e,"report"),tooltip:"Download a CSV report (metadata + cycles + results) for this test",tooltipOptions:{position:"left"}})]})}})]})]})};
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React,{useState,useEffect,useContext}from"react";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Button}from"primereact/button";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useTis}from"./TisProvider";const downloadCsvBlob=(e,t)=>{const o=new Blob([t],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)};export const ResultHistoryTable=e=>{const t=useTis(),o=e.projectId??t.selection.projectId,r=e.methodId,[i,s]=useState([]),[a,n]=useState(!1),[l,d]=useState(null),[c,p]=useState(null),{invoke:m}=useContext(EventEmitterContext),u=async()=>{if(o){n(!0);try{const e={project_id:o};r&&(e.method_id=r);const t=await m("tis.list_tests",MessageType.Request,e);t.success&&t.data&&t.data.tests&&s(t.data.tests)}catch(e){}n(!1)}else s([])};useEffect(()=>{u()},[o,r,t.state.activeRunId]);const f=async(e,t)=>{const i=e?.run_id,s=e?.method_id??r;if(!i||!s||!o)return;const a="report"===t?"tis.export_test_csv":"tis.export_test_data_csv",n="report"===t?"test report":"test data";d({runId:i,kind:t});try{const e=await m(a,MessageType.Request,{project_id:o,method_id:s,run_id:i});if(!e?.success)return void alert(`Failed to build ${n} for ${i}`+(e?.error_message?`: ${e.error_message}`:""));const r="string"==typeof e.data?.csv?e.data.csv:"";if(!r)return void alert(`${n} for ${i} is empty.`);const l="string"==typeof e.data?.filename&&e.data.filename?e.data.filename:`${o}_${s}_${i}_${t}.csv`;downloadCsvBlob(l,r)}catch(e){alert(`Download failed: ${e instanceof Error?e.message:String(e)}`)}finally{d(null)}},_=async e=>{if(!o)return;const t="report"===e?"tis.export_project_csv":"tis.export_project_zip",r="report"===e?"project report":"project archive";p(e);try{const i=await m(t,MessageType.Request,{project_id:o});if(!i?.success)return void alert(`Failed to build ${r}`+(i?.error_message?`: ${i.error_message}`:""));if("report"===e){const e="string"==typeof i.data?.csv?i.data.csv:"";if(!e)return void alert(`Project ${o} has no tests to report.`);const t="string"==typeof i.data?.filename&&i.data.filename?i.data.filename:`${o}_project_report.csv`;downloadCsvBlob(t,e)}else{const e="string"==typeof i.data?.download_url?i.data.download_url:"";if(!e)return void alert(`Server did not return a download URL for ${r}.`);const t=document.createElement("a");t.href=e,t.download="string"==typeof i.data?.filename?i.data.filename:`${o}_project_archive.zip`,document.body.appendChild(t),t.click(),t.remove()}}catch(e){alert(`Download failed: ${e instanceof Error?e.message:String(e)}`)}finally{p(null)}},h=e=>{const t="string"==typeof e?.sample_id?e.sample_id:"";if(t)return t;const o=e?.config;return o&&"object"==typeof o&&"string"==typeof o.sample_id?o.sample_id:""};return _jsxs("div",{style:{width:"100%",maxWidth:"100%",overflow:"hidden",boxSizing:"border-box"},children:[_jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem",gap:"0.5rem",flexWrap:"wrap"},children:[_jsx("h3",{style:{margin:0},children:o?`Test History: ${o}${r?` / ${r}`:""}`:"Test History (no project selected)"}),_jsxs("div",{style:{display:"flex",gap:"0.4rem",alignItems:"center"},children:[_jsx(Button,{icon:"report"===c?"pi pi-spin pi-spinner":"pi pi-file",label:"Download Report",size:"small",outlined:!0,disabled:!o||null!==c,onClick:()=>_("report"),tooltip:"Download a CSV report of every test in this project",tooltipOptions:{position:"bottom"}}),_jsx(Button,{icon:"archive"===c?"pi pi-spin pi-spinner":"pi pi-box",label:"Download Archive",size:"small",outlined:!0,disabled:!o||null!==c,onClick:()=>_("archive"),tooltip:"Download a ZIP of the entire project directory (all tests, raw data, configs)",tooltipOptions:{position:"bottom"}}),_jsx(Button,{icon:"pi pi-refresh",label:"Refresh",size:"small",onClick:u,disabled:a})]})]}),_jsxs(DataTable,{value:i,loading:a,paginator:!0,rows:10,emptyMessage:"No tests found.",scrollable:!0,scrollHeight:"flex",tableStyle:{minWidth:0},style:{width:"100%"},selectionMode:"single",onSelectionChange:e=>{const o=e.value;o?.run_id&&t.setSelection({projectId:o.project_id??null,methodId:o.method_id??null,runId:o.run_id})},children:[_jsx(Column,{header:"Sample ID",sortable:!0,body:h,sortFunction:e=>{const t=[...e.data];return t.sort((t,o)=>h(t).localeCompare(h(o))*(e.order??1)),t},style:{minWidth:"8rem"}}),_jsx(Column,{field:"start_time",header:"Date/Time",sortable:!0,body:e=>{return(t=e.start_time)?new Date(t).toLocaleString():"";var t},style:{minWidth:"12rem"}}),_jsx(Column,{field:"method_id",header:"Test Method",sortable:!0,style:{minWidth:"10rem"}}),_jsx(Column,{field:"run_id",header:"Run ID",sortable:!0,style:{minWidth:"12rem"}}),_jsx(Column,{header:"Download",style:{width:"14rem"},body:e=>{const t=l?.runId===e.run_id&&"data"===l?.kind,o=l?.runId===e.run_id&&"report"===l?.kind,r=null!==l;return _jsxs("div",{style:{display:"flex",gap:"0.4rem"},children:[_jsx(Button,{icon:t?"pi pi-spin pi-spinner":"pi pi-download",label:"Raw",size:"small",outlined:!0,disabled:r,onClick:()=>f(e,"data"),tooltip:"Download raw + filtered trace data as one CSV",tooltipOptions:{position:"left"}}),_jsx(Button,{icon:o?"pi pi-spin pi-spinner":"pi pi-file",label:"Results",size:"small",outlined:!0,disabled:r,onClick:()=>f(e,"report"),tooltip:"Download a CSV report (metadata + cycles + results) for this test",tooltipOptions:{position:"left"}})]})}})]})]})};
@@ -22,11 +22,58 @@ export interface ChartSeries {
22
22
  label?: string;
23
23
  y_axis?: 'left' | 'right';
24
24
  }
25
+ /**
26
+ * A shaded X-range band drawn over the plot (rendered as a
27
+ * chartjs-plugin-annotation `box` annotation spanning the full Y height).
28
+ * `xMin`/`xMax` are in the same units as the view's x data — for a
29
+ * `raw_trace` that's the x column's value, for a `cycle_scatter` it's the
30
+ * category index. Used to indicate a processed / region-of-interest span.
31
+ */
32
+ export interface ChartRegion {
33
+ /** Start of the band on the X axis. */
34
+ xMin: number;
35
+ /** End of the band on the X axis. */
36
+ xMax: number;
37
+ /** Optional caption drawn at the top-center of the band. */
38
+ label?: string;
39
+ /** Fill color (any CSS color). Default: translucent theme accent. */
40
+ color?: string;
41
+ /** Optional band-edge border color. Default: no border. */
42
+ borderColor?: string;
43
+ }
25
44
  export interface ChartView {
26
45
  title?: string;
27
46
  type: 'cycle_scatter' | 'raw_trace';
28
47
  x: ChartAxis;
29
48
  y: ChartSeries[];
49
+ /**
50
+ * Display-only line smoothing for `raw_trace` views. `undefined ⇒ true`.
51
+ *
52
+ * When on, each series is passed through a Savitzky–Golay filter (which
53
+ * removes sample-to-sample noise while keeping peak height/shape),
54
+ * lightly decimated, and drawn with monotone-cubic interpolation — a
55
+ * smooth curve that traces the profile instead of a squiggly polyline.
56
+ * The underlying `raw` data is never altered (table, CSV, and any
57
+ * calculations still see the exact samples). Set `false` to render the
58
+ * raw polyline through every sample.
59
+ */
60
+ smooth?: boolean;
61
+ /**
62
+ * Optional Savitzky–Golay window size in samples (odd; clamped to the
63
+ * series length). Larger = smoother. Default is adaptive to the sample
64
+ * count. Ignored when `smooth` is false.
65
+ */
66
+ smoothWindow?: number;
67
+ /**
68
+ * Optional shaded X-range bands drawn over the plot, declared per view
69
+ * in project.json (static). These are drawn on every cycle.
70
+ *
71
+ * For per-cycle dynamic bands (computed at runtime from processed
72
+ * data), the producer instead attaches a `regions` array to the
73
+ * raw-data envelope; the component merges those with these and renders
74
+ * both. See `dynamicRegions` in the component body.
75
+ */
76
+ regions?: ChartRegion[];
30
77
  }
31
78
  export interface RawColumn {
32
79
  source: string;