@adcops/autocore-react 3.5.15 → 3.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/tis/TestDataView.d.ts.map +1 -1
- package/dist/components/tis/TestDataView.js +1 -1
- package/dist/components/tis/TisProvider.d.ts.map +1 -1
- package/dist/components/tis/TisProvider.js +1 -1
- package/dist/components/tis-editor/DeleteMethodDialog.d.ts +43 -0
- package/dist/components/tis-editor/DeleteMethodDialog.d.ts.map +1 -0
- package/dist/components/tis-editor/DeleteMethodDialog.js +1 -0
- package/dist/components/tis-editor/MethodTransfer.d.ts +69 -0
- package/dist/components/tis-editor/MethodTransfer.d.ts.map +1 -0
- package/dist/components/tis-editor/MethodTransfer.js +1 -0
- package/dist/components/tis-editor/TisConfigEditor.css +31 -0
- package/dist/components/tis-editor/TisConfigEditor.d.ts +9 -1
- package/dist/components/tis-editor/TisConfigEditor.d.ts.map +1 -1
- package/dist/components/tis-editor/TisConfigEditor.js +1 -1
- package/dist/components/tis-editor/editor/IdentitySection.d.ts.map +1 -1
- package/dist/components/tis-editor/editor/IdentitySection.js +1 -1
- package/dist/components/tis-editor/types.d.ts +11 -0
- package/dist/components/tis-editor/types.d.ts.map +1 -1
- package/dist/components/varpick/VariablePicker.d.ts.map +1 -1
- package/dist/components/varpick/VariablePicker.js +1 -1
- package/dist/components/varpick/varpick.css +84 -30
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useMethodSequence.d.ts +60 -0
- package/dist/hooks/useMethodSequence.d.ts.map +1 -0
- package/dist/hooks/useMethodSequence.js +1 -0
- package/package.json +1 -1
- package/src/components/tis/TestDataView.tsx +39 -1
- package/src/components/tis/TisProvider.tsx +54 -9
- package/src/components/tis-editor/DeleteMethodDialog.tsx +162 -0
- package/src/components/tis-editor/MethodTransfer.ts +138 -0
- package/src/components/tis-editor/TisConfigEditor.css +31 -0
- package/src/components/tis-editor/TisConfigEditor.tsx +305 -7
- package/src/components/tis-editor/editor/IdentitySection.tsx +33 -1
- package/src/components/tis-editor/types.ts +11 -0
- package/src/components/varpick/VariablePicker.tsx +4 -0
- package/src/components/varpick/varpick.css +84 -30
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useMethodSequence.ts +128 -0
- package/tools/tests/dist/{TestFieldDialog-BvHAr2GQ.js → TestFieldDialog-Dph2oPfe.js} +1 -0
- package/tools/tests/dist/autocore-react.css +84 -30
- package/tools/tests/dist/tis-editor.entry.js +1 -1
- package/tools/tests/dist/varpick.entry.js +1 -1
- package/tools/tests/varpick.test.mjs +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestDataView.d.ts","sourceRoot":"","sources":["../../../src/components/tis/TestDataView.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAwE,MAAM,OAAO,CAAC;AAqC7F,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;wEAEoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;sEAEkE;IAClE,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IAC3E;;;;iCAI6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;oCAGgC;IAChC,SAAS,CAAC,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,CAAC,EAAE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C,EAAK,UAAU,CAAC;IACvB,8EAA8E;IAC9E,UAAU,CAAC,EAAG,MAAM,CAAC;IACrB,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;uEACmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAID,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAw0BpD,CAAC;AAmfF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import React,{useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Button}from"primereact/button";import{Column}from"primereact/column";import{DataTable}from"primereact/datatable";import{Dialog}from"primereact/dialog";import{Dropdown}from"primereact/dropdown";import{TabView,TabPanel}from"primereact/tabview";import{Chart as ChartJS,CategoryScale,LinearScale,PointElement,LineElement,Title,Tooltip,Legend}from"chart.js";import zoomPlugin from"chartjs-plugin-zoom";import annotationPlugin from"chartjs-plugin-annotation";import{Line}from"react-chartjs-2";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useTis}from"./TisProvider";import{AutoCoreTagContext}from"../../core/AutoCoreTagContext";import{formatScaled}from"../../core/formatScaled";import{useRawCycleData}from"./useRawCycleData";import{orderedViews}from"./chartViews";import{ScienceTable}from"./ScienceTable";ChartJS.register(CategoryScale,LinearScale,PointElement,LineElement,Title,Tooltip,Legend,zoomPlugin,annotationPlugin);export const TestDataView=e=>{const t=useTis(),r=e.projectId??t.selection.projectId,a=e.methodId??t.selection.methodId,n=e.runId??t.selection.runId,o=e.schema??(a?t.schemas[a]:void 0),{throttleMs:l=100,cycleTableHeight:i="400px",chartHeight:s="320px"}=e,{invoke:c,subscribe:d,unsubscribe:u}=useContext(EventEmitterContext),{scales:m}=useContext(AutoCoreTagContext),[p,y]=useState(null),[f,h]=useState([]),[g,_]=useState({}),[x,b]=useState({}),[j,v]=useState(!1),[w,C]=useState(!1),S=useCallback(async(e,t,o)=>{const l=e?.cycle_index;if(r&&a&&n&&l)try{const e=await c("tis.update_cycle",MessageType.Request,{project_id:r,method_id:a,run_id:n,cycle_index:l,fields:{[t]:o}});if(!1===e?.success)return;h(e=>e.map(e=>e?.cycle_index===l?{...e,[t]:o}:e))}catch(e){}},[c,r,a,n]),T=useRef(null),[R,O]=useState(null),[A,D]=useState(null),[M,E]=useState(!1),[L,I]=useState(null),[N,F]=useState(null),[k,q]=useState(!1),[V,H]=useState([]),[P,z]=useState(null),$=useMemo(()=>orderedViews(o?.views),[o]),[B,G]=useState($.length>0?$[0].name:null);useEffect(()=>{if(0===$.length)return;null!==B&&$.some(e=>e.name===B)||G($[0].name)},[$,B]);const W=$.find(e=>e.name===B)?.view,U="raw_trace"===W?.type,J=useRef([]),X=useRef(null),Y=useRef(null),Z=()=>{Y.current||(Y.current=setTimeout(()=>{if(Y.current=null,J.current.length>0){const e=J.current;J.current=[],h(t=>[...e.slice().reverse(),...t])}X.current&&(_(X.current),X.current=null)},l))};useEffect(()=>{if(!r||!a||!n)return y(null),h([]),void _({});let e=!1;return(async()=>{try{const t=await c("tis.read_test",MessageType.Request,{project_id:r,method_id:a,run_id:n});!e&&t?.success&&(y(t.data),_(t.data.results??{}));const o=await c("tis.read_cycles",MessageType.Request,{project_id:r,method_id:a,run_id:n,offset:0,limit:200,order:"desc"});!e&&o?.success&&h(o.data.cycles??[])}catch(e){}})(),()=>{e=!0}},[r,a,n,c]),useEffect(()=>{const e=e=>e?.project_id===r&&e?.method_id===a&&e?.run_id===n,t=d("tis.cycle_added",t=>{e(t)&&t.cycle&&(J.current.push(t.cycle),Z())}),o=d("tis.results_updated",t=>{e(t)&&(X.current=t.results??{},Z())});return()=>{u(t),u(o),Y.current&&(clearTimeout(Y.current),Y.current=null)}},[r,a,n,l]);const K="string"==typeof p?.sample_id&&p.sample_id?p.sample_id:"string"==typeof p?.config?.sample_id?p.config.sample_id:"";useEffect(()=>{if(!r||!a||!K)return void b({});let e=!1;const t=async()=>{try{const t=await c("tis.sample_summary",MessageType.Request,{project_id:r,method_id:a,sample_id:K,run_id:n});!e&&t?.success&&b(t.data?.summary??{})}catch(e){}};t();const o=[d("tis.sample_summary_updated",e=>{e?.project_id===r&&e?.method_id===a&&e?.sample_id===K&&t()}),d("tis.cycle_added",e=>{e?.project_id===r&&e?.method_id===a&&t()})];return()=>{e=!0,o.forEach(u)}},[r,a,K,n,c,d,u]);const Q=useRawCycleData({projectId:r,methodId:a,runId:n,blobName:o?.raw_data?.blob_name??"trace",source:W?.source??"raw",enabled:U}),ee=useMemo(()=>{if(!W)return null;if("cycle_scatter"===W.type){const e=W.x.field;if(!e)return null;const t=[...f].reverse(),r=m?.[quantityOfField(o,e)??""],a=W.x_decimals??r?.precision??DEFAULT_X_DECIMALS;return{labels:t.map(t=>formatAxisTick(toDisplayValue(t[e],r),a)),datasets:W.y.map((e,r)=>({label:e.label??e.field,data:t.map(t=>toDisplayValue(t[e.field],m?.[quantityOfField(o,e.field)??""])),yAxisID:"right"===e.y_axis?"y1":"y",borderColor:palette(r),backgroundColor:palette(r),tension:.1,pointRadius:2}))}}if("raw_trace"===W.type){if(!Q.raw)return null;const e=W.x.column;if(!e)return null;const t=m?.[quantityOfColumn(o,e)??""],r=Q.raw[e]??[],a=t?r.map(e=>toDisplayValue(e,t)):r,n=!1!==W.smooth;return{datasets:W.y.map((e,t)=>{const r=m?.[quantityOfColumn(o,e.column)??""],l=Q.raw[e.column]??[],i=r?l.map(e=>toDisplayValue(e,r)):l,s=n?smoothTraceForDisplay(a,i,W.smoothWindow):i.map((e,t)=>({x:a[t],y:e}));return{label:e.label??e.column,data:s,yAxisID:"right"===e.y_axis?"y1":"y",borderColor:palette(t),backgroundColor:palette(t),pointRadius:0,borderWidth:1.5,showLine:!0,...n?{cubicInterpolationMode:"monotone"}:{}}})}}return null},[W,f,Q.raw,m,o]),te=W?.y.some(e=>"right"===e.y_axis)??!1,re=useMemo(()=>{if(!U)return[];const e=Q.envelope,t=e?.regions??e?.context?.regions;return Array.isArray(t)?t:[]},[U,Q.envelope]),ae=useMemo(()=>[...W?.regions??[],...re],[W,re]),ne=useMemo(()=>{const e="raw_trace"===W?.type,t=t=>{const r=e?quantityOfColumn(o,t.column):quantityOfField(o,t.field);return r?m?.[r]?.label:void 0},r=e?quantityOfColumn(o,W?.x.column):quantityOfField(o,W?.x.field),a=r?m?.[r]?.label:void 0,n=W?.x.label?a?`${W.x.label} [${a}]`:W.x.label:void 0,l=W?.x_decimals??(r?m?.[r]?.precision:void 0)??DEFAULT_X_DECIMALS,i={callback(t){const r=e?t:this?.getLabelForValue?.(t)??t;return formatAxisTick(r,l)}};return{responsive:!0,maintainAspectRatio:!1,parsing:!e&&void 0,scales:{x:e?{type:"linear",ticks:i,title:{display:!!n,text:n}}:{ticks:i,title:{display:!!n,text:n}},y:{position:"left",title:{display:!0,text:axisLabel(W,"left",t)}},...te?{y1:{position:"right",grid:{drawOnChartArea:!1},title:{display:!0,text:axisLabel(W,"right",t)}}}:{}},plugins:{legend:{display:!0},zoom:{pan:{enabled:!0,mode:"xy"},zoom:{wheel:{enabled:!0},pinch:{enabled:!0},mode:"xy"}},annotation:{annotations:buildRegionAnnotations(ae)}}}},[W,te,ae,m,o]),oe=o?.raw_data?.blob_name??"trace",le=useRef(""),ie=useCallback(async()=>{if(!r||!a||!n)return[];try{const e=await c("tis.list_raw",MessageType.Request,{project_id:r,method_id:a,run_id:n});if(!e?.success)return[];const t=e.data?.cycles??[];return t.filter(e=>e?.name===oe&&"number"==typeof e?.cycle_index).map(e=>e.cycle_index).sort((e,t)=>e-t)}catch{return[]}},[r,a,n,oe,c]),se=useCallback(async e=>{if(!r||!a||!n)return;const t=`${r}|${a}|${n}|${oe}|${e??"latest"}`;if(le.current===t)return;le.current=t;const o={project_id:r,method_id:a,run_id:n,name:oe};null!=e&&(o.cycle_index=e),E(!0),D(null),O(null);try{const e=await c("tis.read_raw",MessageType.Request,o);e?.success?O(e.data??{}):D(e?.error_message??"No raw data on disk for this run.")}catch(e){D(String(e?.message??e))}finally{E(!1)}q(!0),F(null),I(null);try{const e=await c("tis.read_filtered",MessageType.Request,o);e?.success?I(e.data??{}):F(e?.error_message??"No filtered data on disk for this run.")}catch(e){F(String(e?.message??e))}finally{q(!1)}},[r,a,n,oe,c]);useEffect(()=>{le.current="",H([]),z(null)},[r,a,n,oe]);return useEffect(()=>{j&&null!=P&&se(P)},[j,P,se]),r&&a&&n&&o?_jsxs("div",{className:"vblock",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[_jsx(Header,{meta:p,config:p?.config,runId:n,projectId:r,methodId:a,canViewRaw:!!o.raw_data,onViewRaw:async()=>{v(!0);let e=V;0===e.length&&(e=await ie(),H(e));const t=e.length>0?e[e.length-1]:null,r=P??t;P!==r&&z(r),await se(r)},onShowConfig:()=>C(!0)}),_jsxs("div",{className:"p-card",style:{padding:"1rem"},children:[_jsxs("div",{className:"flex",style:{gap:"1rem",alignItems:"center",marginBottom:"0.5rem",flexWrap:"wrap"},children:[_jsx(Dropdown,{value:B,options:$.map(e=>({label:e.view.title??e.name,value:e.name})),onChange:e=>G(e.value),placeholder:0===$.length?"No view defined":"Select a view",disabled:0===$.length}),_jsx("h3",{style:{margin:0},children:W?.title??""}),U&&Q.cycles.length>1&&_jsxs(_Fragment,{children:[_jsx("label",{htmlFor:"chart-cycle-picker",style:{color:"var(--text-secondary-color)"},children:"Cycle:"}),_jsx(Dropdown,{inputId:"chart-cycle-picker",value:Q.selectedCycle,options:Q.cycles.map(e=>({label:`Cycle ${e}`,value:e})),onChange:e=>Q.setSelectedCycle(Number(e.value)),style:{minWidth:"8rem"}}),_jsxs("span",{style:{color:"var(--text-secondary-color)"},children:["of ",Q.cycles.length]})]}),_jsx("div",{style:{flex:1}}),_jsx(Button,{icon:"pi pi-th-large",outlined:!0,rounded:!0,size:"small",onClick:()=>T.current?.resetZoom?.(),disabled:!ee,tooltip:"Reset chart zoom",tooltipOptions:{position:"left"},"aria-label":"Reset chart zoom"})]}),_jsxs("div",{style:{height:s,position:"relative"},children:[U&&Q.loading&&_jsx(ChartOverlay,{children:"Loading raw data…"}),U&&Q.error&&_jsx(ChartOverlay,{children:Q.error}),ee&&_jsx(Line,{ref:T,data:ee,options:ne})]})]}),(()=>{const e=f.length>CYCLE_VIRTUAL_THRESHOLD,t=[...(o.cycle_config_fields??[]).map(e=>toScienceColumn(e,!0,m)),...(o.cycle_fields??[]).map(e=>toScienceColumn(e,!!e.editable,m))];return _jsx(ScienceTable,{title:`Cycle Data (${f.length})`,columns:t,rows:f,indexOrder:"descending",scrollable:e,scrollHeight:e?i:void 0,emptyMessage:"No cycles yet.",onCellEdit:S})})(),(()=>{const e={...g,...x},t=Object.keys(e).length>0,r=o.results_fields??[],a=r.map(e=>toScienceColumn(e,!1,m)),n=r.some(isProjectScoped);return _jsxs(_Fragment,{children:[_jsx(ScienceTable,{title:"Results",columns:a,rows:t?[e]:[],emptyMessage:"No results yet."}),n&&_jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary-color)",margin:"0.25rem 0 0.75rem"},children:"* across every test of this sample in the project. All other values describe this test."})]})})(),o.raw_data&&_jsxs(Dialog,{visible:j,onHide:()=>v(!1),header:`Run Data — ${n}`,style:{width:"90vw",height:"80vh"},maximizable:!0,children:[_jsx(CyclePickerBar,{cycles:V,selected:P,onChange:z}),_jsx(RawEnvelopeHeader,{envelope:R}),_jsxs(TabView,{style:{height:"100%"},children:[_jsx(TabPanel,{header:"Raw Data",children:_jsx(DataBlobTable,{blob:unwrapEnvelope(R),loading:M,error:A,rawData:o.raw_data})}),_jsx(TabPanel,{header:"Filtered Data",children:_jsx(DataBlobTable,{blob:unwrapEnvelope(L),loading:k,error:N,rawData:o.raw_data,emptyMessage:"Filtered data is written by post-processing — none on disk for this run yet."})})]})]}),_jsx(Dialog,{visible:w,onHide:()=>C(!1),header:"Test Configuration",style:{width:"min(640px, 90vw)"},modal:!0,children:_jsx(ConfigList,{config:p?.config})})]}):_jsx("div",{className:"p-card",style:{padding:"1rem",color:"var(--text-secondary-color)"},children:"No test selected. Pick a row from the History tab or start a run."})};const Header=({meta:e,config:t,runId:r,projectId:a,methodId:n,canViewRaw:o,onViewRaw:l,onShowConfig:i})=>{const s="string"==typeof e?.sample_id&&e.sample_id||"string"==typeof e?.config?.sample_id&&e.config.sample_id||"",c=t&&"object"==typeof t&&Object.entries(t).some(([e])=>"sample_id"!==e);return _jsx("div",{className:"p-card",style:{padding:"1rem"},children:_jsxs("div",{className:"flex",style:{justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[_jsxs("div",{children:[_jsxs("h2",{style:{margin:0,display:"flex",alignItems:"center",gap:"0.5rem"},children:[s||r,c&&_jsx(Button,{icon:"pi pi-info-circle",type:"button",rounded:!0,text:!0,onClick:i,tooltip:"Show test configuration",tooltipOptions:{position:"top"},style:{width:"2rem",height:"2rem",padding:0},"aria-label":"Show test configuration"})]}),_jsxs("div",{style:{color:"var(--text-secondary-color)",fontSize:"0.85em"},children:["project: ",a," · method: ",n," · run: ",r,e?.start_time&&_jsxs(_Fragment,{children:[" · started: ",new Date(e.start_time).toLocaleString()]})]})]}),o&&_jsx(Button,{icon:"pi pi-table",label:"View Raw Data",onClick:l,outlined:!0})]})})},ConfigList=({config:e})=>{const t=e&&"object"==typeof e?Object.entries(e).filter(([e])=>"sample_id"!==e):[];return 0===t.length?_jsx("div",{style:{color:"var(--text-secondary-color)"},children:"No configuration recorded for this run."}):_jsx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",fontSize:"0.95em"},children:t.map(([e,t])=>_jsxs(React.Fragment,{children:[_jsx("div",{style:{color:"var(--text-secondary-color)"},children:e}),_jsx("div",{children:formatCell(t,"string")})]},e))})},unwrapEnvelope=e=>e&&"object"==typeof e&&"data"in e&&e.data&&"object"==typeof e.data&&Object.values(e.data).some(e=>Array.isArray(e))?e.data:e,CyclePickerBar=({cycles:e,selected:t,onChange:r})=>e.length<=1?null:_jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.25rem 0.5rem 0.5rem"},children:[_jsx("label",{htmlFor:"raw-cycle-picker",style:{color:"var(--text-secondary-color)"},children:"Cycle:"}),_jsx(Dropdown,{inputId:"raw-cycle-picker",value:t,options:e.map(e=>({label:`Cycle ${e}`,value:e})),onChange:e=>r(Number(e.value)),style:{minWidth:"8rem"}}),_jsxs("span",{style:{color:"var(--text-secondary-color)"},children:["(",e.length," cycles recorded)"]})]}),RawEnvelopeHeader=({envelope:e})=>{if(!e||"object"!=typeof e)return null;const t=e.cycle_index,r=e.cycle_fields,a=e.context;if(null==t&&!r&&!a)return null;const n=e=>{if(!e||"object"!=typeof e)return null;const t=Object.entries(e).filter(([,e])=>null!==e&&"object"!=typeof e);return 0===t.length?null:t.map(([e,t])=>_jsxs("span",{style:{marginRight:"1rem"},children:[_jsxs("span",{style:{color:"var(--text-secondary-color)"},children:[e,": "]}),_jsx("span",{children:String(t)})]},e))};return _jsxs("div",{style:{padding:"0.5rem",borderBottom:"1px solid var(--surface-border)",fontSize:"0.9rem"},children:[null!=t&&_jsx("div",{children:_jsxs("strong",{children:["Cycle ",t]})}),r&&_jsx("div",{style:{marginTop:"0.25rem"},children:n(r)}),a&&_jsx("div",{style:{marginTop:"0.25rem"},children:n(a)})]})},DataBlobTable=({blob:e,loading:t,error:r,rawData:a,emptyMessage:n})=>{if(t)return _jsx("div",{style:{padding:"1rem",color:"var(--text-secondary-color)"},children:"Loading…"});if(r)return _jsx("div",{style:{padding:"1rem",color:"var(--text-secondary-color)"},children:n??r});if(!e||"object"!=typeof e)return _jsx("div",{style:{padding:"1rem",color:"var(--text-secondary-color)"},children:"No data."});const o=Object.keys(a.columns??{}),l=Object.keys(e).filter(t=>Array.isArray(e[t])),i=[];for(const t of o)Array.isArray(e[t])&&i.push(t);for(const e of l)i.includes(e)||i.push(e);if(0===i.length)return _jsx("div",{style:{padding:"1rem",color:"var(--text-secondary-color)"},children:n??"No columnar data in this blob."});const s=i.reduce((t,r)=>Math.min(t,e[r].length),Number.POSITIVE_INFINITY),c=Number.isFinite(s)?s:0,d=Array.from({length:c},(t,r)=>{const a={__i:r};for(const t of i)a[t]=e[t][r];return a}),u=e=>{const t=a.units?.[e];return t?`${e} [${t}]`:e};return _jsxs(DataTable,{value:d,scrollable:!0,scrollHeight:"60vh",virtualScrollerOptions:{itemSize:32},emptyMessage:n??"No data.",size:"small",stripedRows:!0,children:[_jsx(Column,{field:"__i",header:"#",style:{width:"5rem",textAlign:"right"},bodyStyle:{fontVariantNumeric:"tabular-nums",textAlign:"right"}}),i.map(e=>_jsx(Column,{field:e,header:u(e),style:{minWidth:"8rem"},bodyStyle:{fontVariantNumeric:"tabular-nums",textAlign:"right"},body:t=>formatNumeric(t[e])},e))]})},formatNumeric=e=>null==e?"":"number"==typeof e&&Number.isFinite(e)?Number.parseFloat(e.toPrecision(6)).toString():String(e),CYCLE_VIRTUAL_THRESHOLD=30,CHART_COLORS=["#4ea8de","#f59e0b","#22c55e","#a855f7","#ef4444","#14b8a6","#eab308","#ec4899"],palette=e=>CHART_COLORS[e%CHART_COLORS.length],SG_ORDER=3,SMOOTH_TARGET_POINTS=800;function invertMatrix(e){const t=e.length,r=e.map((e,r)=>[...e,...Array.from({length:t},(e,t)=>r===t?1:0)]);for(let e=0;e<t;e++){let a=e;for(let n=e+1;n<t;n++)Math.abs(r[n][e])>Math.abs(r[a][e])&&(a=n);if(Math.abs(r[a][e])<1e-12)return null;[r[e],r[a]]=[r[a],r[e]];const n=r[e][e];for(let a=0;a<2*t;a++)r[e][a]/=n;for(let a=0;a<t;a++){if(a===e)continue;const n=r[a][e];if(0!==n)for(let o=0;o<2*t;o++)r[a][o]-=n*r[e][o]}}return r.map(e=>e.slice(t))}function sgWeights(e,t){const r=2*e+1,a=Math.min(t,r-1),n=[];for(let t=-e;t<=e;t++){const e=[];let r=1;for(let n=0;n<=a;n++)e.push(r),r*=t;n.push(e)}const o=a+1,l=Array.from({length:o},()=>new Array(o).fill(0));for(let e=0;e<o;e++)for(let t=0;t<o;t++){let a=0;for(let o=0;o<r;o++)a+=n[o][e]*n[o][t];l[e][t]=a}const i=invertMatrix(l);if(!i)return new Array(r).fill(1/r);const s=new Array(r);for(let e=0;e<r;e++){let t=0;for(let r=0;r<o;r++)t+=i[0][r]*n[e][r];s[e]=t}return s}function savitzkyGolay(e,t){const r=e.length;if(0===r||t<1)return e.slice();const a=new Map,n=e=>{let t=a.get(e);return t||(t=sgWeights(e,3),a.set(e,t)),t},o=new Array(r);for(let a=0;a<r;a++){const l=Math.min(t,a,r-1-a);if(l<1){o[a]=e[a];continue}const i=n(l);let s=0;for(let t=-l;t<=l;t++)s+=i[t+l]*e[a+t];o[a]=s}return o}function smoothTraceForDisplay(e,t,r){const a=Math.min(e.length,t.length);if(0===a)return[];const n=r&&r>1?Math.max(1,Math.floor((Math.min(r,a)-1)/2)):Math.max(2,Math.min(40,Math.round(a/250))),o=savitzkyGolay(t.slice(0,a),n),l=Math.max(1,Math.ceil(a/SMOOTH_TARGET_POINTS)),i=[];for(let t=0;t<a;t+=l)i.push({x:e[t],y:o[t]});return(a-1)%l!=0&&i.push({x:e[a-1],y:o[a-1]}),i}const DEFAULT_REGION_FILL="rgba(78, 168, 222, 0.15)",REGION_LABEL_COLOR="rgba(226, 232, 240, 0.85)";function buildRegionAnnotations(e){if(!e||0===e.length)return{};const t={};return e.forEach((e,r)=>{const a=!!e.borderColor;t[`region-${r}`]={type:"box",xScaleID:"x",xMin:e.xMin,xMax:e.xMax,backgroundColor:e.color??DEFAULT_REGION_FILL,borderColor:a?e.borderColor:"transparent",borderWidth:a?1:0,drawTime:"beforeDatasetsDraw",...e.label?{label:{display:!0,content:e.label,position:{x:"center",y:"start"},color:REGION_LABEL_COLOR,font:{size:11}}}:{}}}),t}const ChartOverlay=({children:e})=>_jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-secondary-color)",pointerEvents:"none"},children:e});export const DEFAULT_X_DECIMALS=2;const formatAxisTick=(e,t)=>{const r="number"==typeof e?e:Number(e);return Number.isFinite(r)?Number.parseFloat(r.toFixed(t)).toString():null==e?"":String(e)},quantityOfField=(e,t)=>{if(e&&t)for(const r of[e.cycle_config_fields,e.cycle_fields,e.results_fields]){const e=(r??[]).find(e=>e.name===t);if(e?.quantity)return e.quantity}},quantityOfColumn=(e,t)=>{if(e&&t)return e.raw_data?.columns?.[t]?.quantity},toDisplayValue=(e,t)=>t&&"number"==typeof e&&Number.isFinite(e)?e*t.scale+(t.offset??0):e,seriesLabel=e=>e.label??e.field??e.column??"",axisLabel=(e,t,r)=>{const a=e?.y.filter(e=>"right"===e.y_axis==("right"===t))??[],n=a.map(seriesLabel).join(" / "),o=Array.from(new Set(a.map(r).filter(Boolean)));return 1===o.length?`${n} [${o[0]}]`:n},isProjectScoped=e=>"project"===e.aggregate?.scope,toScienceColumn=(e,t=!1,r)=>{const a=e.quantity?r?.[e.quantity]:void 0;return{field:e.name,label:(e.label&&e.label.length>0?e.label:e.name)+(isProjectScoped(e)?" *":""),units:a?a.label:e.units,editable:t,body:t=>formatCell(t[e.name],e.type,e.scale,a)}},formatCell=(e,t,r,a)=>null==e?"":a&&"number"==typeof e&&Number.isFinite(e)?formatScaled(e*a.scale+(a.offset??0),a):(r&&1!==r&&"number"==typeof e&&Number.isFinite(e)&&(e*=r),"f32"===t||"f64"===t?"number"==typeof e?e.toFixed(4):String(e):"object"==typeof e?JSON.stringify(e):String(e));
|
|
1
|
+
import{jsxs as _jsxs,jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import React,{useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Button}from"primereact/button";import{Column}from"primereact/column";import{DataTable}from"primereact/datatable";import{Dialog}from"primereact/dialog";import{Dropdown}from"primereact/dropdown";import{TabView,TabPanel}from"primereact/tabview";import{Chart as ChartJS,CategoryScale,LinearScale,PointElement,LineElement,Title,Tooltip,Legend}from"chart.js";import zoomPlugin from"chartjs-plugin-zoom";import annotationPlugin from"chartjs-plugin-annotation";import{Line}from"react-chartjs-2";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useTis}from"./TisProvider";import{AutoCoreTagContext}from"../../core/AutoCoreTagContext";import{formatScaled}from"../../core/formatScaled";import{useRawCycleData}from"./useRawCycleData";import{orderedViews}from"./chartViews";import{ScienceTable}from"./ScienceTable";ChartJS.register(CategoryScale,LinearScale,PointElement,LineElement,Title,Tooltip,Legend,zoomPlugin,annotationPlugin);export const TestDataView=e=>{const t=useTis(),r=e.projectId??t.selection.projectId,n=e.methodId??t.selection.methodId,a=e.runId??t.selection.runId,o=e.schema??(n?t.schemas[n]:void 0),{throttleMs:l=100,cycleTableHeight:i="400px",chartHeight:s="320px"}=e,{invoke:c,subscribe:d,unsubscribe:u}=useContext(EventEmitterContext),{scales:m}=useContext(AutoCoreTagContext),[p,y]=useState(null),[f,h]=useState([]),[g,_]=useState({}),[x,b]=useState({}),[j,v]=useState(!1),[w,C]=useState(!1),S=useCallback(async(e,t,o)=>{const l=e?.cycle_index;if(r&&n&&a&&l)try{const e=await c("tis.update_cycle",MessageType.Request,{project_id:r,method_id:n,run_id:a,cycle_index:l,fields:{[t]:o}});if(!1===e?.success)return;h(e=>e.map(e=>e?.cycle_index===l?{...e,[t]:o}:e))}catch(e){}},[c,r,n,a]),T=useRef(null),[R,I]=useState(null),[A,M]=useState(null),[O,D]=useState(!1),[E,L]=useState(null),[N,F]=useState(null),[k,q]=useState(!1),[V,P]=useState([]),[H,z]=useState(null),$=useMemo(()=>orderedViews(o?.views),[o]),[B,G]=useState($.length>0?$[0].name:null);useEffect(()=>{if(0===$.length)return;null!==B&&$.some(e=>e.name===B)||G($[0].name)},[$,B]);const W=$.find(e=>e.name===B)?.view,U="raw_trace"===W?.type,J=useRef([]),X=useRef(null),Y=useRef(null),Z=()=>{Y.current||(Y.current=setTimeout(()=>{if(Y.current=null,J.current.length>0){const e=J.current;J.current=[],h(t=>[...e.slice().reverse(),...t])}X.current&&(_(X.current),X.current=null)},l))};useEffect(()=>{if(!r||!n||!a)return y(null),h([]),void _({});let e=!1;return(async()=>{try{const t=await c("tis.read_test",MessageType.Request,{project_id:r,method_id:n,run_id:a});!e&&t?.success&&(y(t.data),_(t.data.results??{}));const o=await c("tis.read_cycles",MessageType.Request,{project_id:r,method_id:n,run_id:a,offset:0,limit:200,order:"desc"});!e&&o?.success&&h(o.data.cycles??[])}catch(e){}})(),()=>{e=!0}},[r,n,a,c]),useEffect(()=>{const e=e=>e?.project_id===r&&e?.method_id===n&&e?.run_id===a,t=d("tis.cycle_added",t=>{e(t)&&t.cycle&&(J.current.push(t.cycle),Z())}),o=d("tis.results_updated",t=>{e(t)&&(X.current=t.results??{},Z())});return()=>{u(t),u(o),Y.current&&(clearTimeout(Y.current),Y.current=null)}},[r,n,a,l]);const K="string"==typeof p?.sample_id&&p.sample_id?p.sample_id:"string"==typeof p?.config?.sample_id?p.config.sample_id:"";useEffect(()=>{if(!r||!n||!K)return void b({});let e=!1;const t=async()=>{try{const t=await c("tis.sample_summary",MessageType.Request,{project_id:r,method_id:n,sample_id:K,run_id:a});!e&&t?.success&&b(t.data?.summary??{})}catch(e){}};t();const o=[d("tis.sample_summary_updated",e=>{e?.project_id===r&&e?.method_id===n&&e?.sample_id===K&&t()}),d("tis.cycle_added",e=>{e?.project_id===r&&e?.method_id===n&&t()})];return()=>{e=!0,o.forEach(u)}},[r,n,K,a,c,d,u]);const Q=useRawCycleData({projectId:r,methodId:n,runId:a,blobName:o?.raw_data?.blob_name??"trace",source:W?.source??"raw",enabled:U}),ee=useMemo(()=>{if(!W)return null;if("cycle_scatter"===W.type){const e=W.x.field;if(!e)return null;const t=[...f].reverse(),r=m?.[quantityOfField(o,e)??""],n=W.x_decimals??r?.precision??DEFAULT_X_DECIMALS;return{labels:t.map(t=>formatAxisTick(toDisplayValue(t[e],r),n)),datasets:W.y.map((e,r)=>({label:e.label??e.field,data:t.map(t=>toDisplayValue(t[e.field],m?.[quantityOfField(o,e.field)??""])),yAxisID:"right"===e.y_axis?"y1":"y",borderColor:palette(r),backgroundColor:palette(r),tension:.1,pointRadius:2}))}}if("raw_trace"===W.type){if(!Q.raw)return null;const e=W.x.column;if(!e)return null;const t=m?.[quantityOfColumn(o,e)??""],r=Q.raw[e]??[],n=t?r.map(e=>toDisplayValue(e,t)):r,a=!1!==W.smooth;return{datasets:W.y.map((e,t)=>{const r=m?.[quantityOfColumn(o,e.column)??""],l=Q.raw[e.column]??[],i=r?l.map(e=>toDisplayValue(e,r)):l,s=a?smoothTraceForDisplay(n,i,W.smoothWindow):i.map((e,t)=>({x:n[t],y:e}));return{label:e.label??e.column,data:s,yAxisID:"right"===e.y_axis?"y1":"y",borderColor:palette(t),backgroundColor:palette(t),pointRadius:0,borderWidth:1.5,showLine:!0,...a?{cubicInterpolationMode:"monotone"}:{}}})}}return null},[W,f,Q.raw,m,o]),te=W?.y.some(e=>"right"===e.y_axis)??!1,re=useMemo(()=>{if(!U)return[];const e=Q.envelope,t=e?.regions??e?.context?.regions;return Array.isArray(t)?t:[]},[U,Q.envelope]),ne=useMemo(()=>[...W?.regions??[],...re],[W,re]),ae=useMemo(()=>{const e="raw_trace"===W?.type,t=t=>{const r=e?quantityOfColumn(o,t.column):quantityOfField(o,t.field);return r?m?.[r]?.label:void 0},r=e?quantityOfColumn(o,W?.x.column):quantityOfField(o,W?.x.field),n=r?m?.[r]?.label:void 0,a=W?.x.label?n?`${W.x.label} [${n}]`:W.x.label:void 0,l=W?.x_decimals??(r?m?.[r]?.precision:void 0)??DEFAULT_X_DECIMALS,i={callback(t){const r=e?t:this?.getLabelForValue?.(t)??t;return formatAxisTick(r,l)}};return{responsive:!0,maintainAspectRatio:!1,parsing:!e&&void 0,scales:{x:e?{type:"linear",ticks:i,title:{display:!!a,text:a}}:{ticks:i,title:{display:!!a,text:a}},y:{position:"left",title:{display:!0,text:axisLabel(W,"left",t)}},...te?{y1:{position:"right",grid:{drawOnChartArea:!1},title:{display:!0,text:axisLabel(W,"right",t)}}}:{}},plugins:{legend:{display:!0},zoom:{pan:{enabled:!0,mode:"xy"},zoom:{wheel:{enabled:!0},pinch:{enabled:!0},mode:"xy"}},annotation:{annotations:buildRegionAnnotations(ne)}}}},[W,te,ne,m,o]),oe=o?.raw_data?.blob_name??"trace",le=useRef(""),ie=useCallback(async()=>{if(!r||!n||!a)return[];try{const e=await c("tis.list_raw",MessageType.Request,{project_id:r,method_id:n,run_id:a});if(!e?.success)return[];const t=e.data?.cycles??[];return t.filter(e=>e?.name===oe&&"number"==typeof e?.cycle_index).map(e=>e.cycle_index).sort((e,t)=>e-t)}catch{return[]}},[r,n,a,oe,c]),se=useCallback(async e=>{if(!r||!n||!a)return;const t=`${r}|${n}|${a}|${oe}|${e??"latest"}`;if(le.current===t)return;le.current=t;const o={project_id:r,method_id:n,run_id:a,name:oe};null!=e&&(o.cycle_index=e),D(!0),M(null),I(null);try{const e=await c("tis.read_raw",MessageType.Request,o);e?.success?I(e.data??{}):M(e?.error_message??"No raw data on disk for this run.")}catch(e){M(String(e?.message??e))}finally{D(!1)}q(!0),F(null),L(null);try{const e=await c("tis.read_filtered",MessageType.Request,o);e?.success?L(e.data??{}):F(e?.error_message??"No filtered data on disk for this run.")}catch(e){F(String(e?.message??e))}finally{q(!1)}},[r,n,a,oe,c]);useEffect(()=>{le.current="",P([]),z(null)},[r,n,a,oe]);if(useEffect(()=>{j&&null!=H&&se(H)},[j,H,se]),!(r&&n&&a&&o)){const e=[!r&&"project",!n&&"method",!a&&"run",!o&&"method definition"].filter(Boolean).join(", "),l=!!t.state.active&&!!t.state.activeRunId;return _jsx("div",{className:"p-card",style:{padding:"1rem",color:"var(--text-secondary-color)"},children:l?_jsxs(_Fragment,{children:[_jsxs("div",{children:["A test is running, but this view has not resolved it yet",e?` (no ${e})`:"","."]}),_jsx(Button,{label:"Show the active test",icon:"pi pi-refresh",style:{marginTop:"0.75rem"},onClick:()=>t.setSelection({projectId:t.state.activeProjectId||null,methodId:t.state.activeMethodId||null,sampleId:t.state.activeSampleId||null,runId:t.state.activeRunId||null})})]}):_jsx(_Fragment,{children:"No test selected. Pick a row from the History tab or start a run."})})}return _jsxs("div",{className:"vblock",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[_jsx(Header,{meta:p,config:p?.config,runId:a,projectId:r,methodId:n,canViewRaw:!!o.raw_data,onViewRaw:async()=>{v(!0);let e=V;0===e.length&&(e=await ie(),P(e));const t=e.length>0?e[e.length-1]:null,r=H??t;H!==r&&z(r),await se(r)},onShowConfig:()=>C(!0)}),_jsxs("div",{className:"p-card",style:{padding:"1rem"},children:[_jsxs("div",{className:"flex",style:{gap:"1rem",alignItems:"center",marginBottom:"0.5rem",flexWrap:"wrap"},children:[_jsx(Dropdown,{value:B,options:$.map(e=>({label:e.view.title??e.name,value:e.name})),onChange:e=>G(e.value),placeholder:0===$.length?"No view defined":"Select a view",disabled:0===$.length}),_jsx("h3",{style:{margin:0},children:W?.title??""}),U&&Q.cycles.length>1&&_jsxs(_Fragment,{children:[_jsx("label",{htmlFor:"chart-cycle-picker",style:{color:"var(--text-secondary-color)"},children:"Cycle:"}),_jsx(Dropdown,{inputId:"chart-cycle-picker",value:Q.selectedCycle,options:Q.cycles.map(e=>({label:`Cycle ${e}`,value:e})),onChange:e=>Q.setSelectedCycle(Number(e.value)),style:{minWidth:"8rem"}}),_jsxs("span",{style:{color:"var(--text-secondary-color)"},children:["of ",Q.cycles.length]})]}),_jsx("div",{style:{flex:1}}),_jsx(Button,{icon:"pi pi-th-large",outlined:!0,rounded:!0,size:"small",onClick:()=>T.current?.resetZoom?.(),disabled:!ee,tooltip:"Reset chart zoom",tooltipOptions:{position:"left"},"aria-label":"Reset chart zoom"})]}),_jsxs("div",{style:{height:s,position:"relative"},children:[U&&Q.loading&&_jsx(ChartOverlay,{children:"Loading raw data…"}),U&&Q.error&&_jsx(ChartOverlay,{children:Q.error}),ee&&_jsx(Line,{ref:T,data:ee,options:ae})]})]}),(()=>{const e=f.length>CYCLE_VIRTUAL_THRESHOLD,t=[...(o.cycle_config_fields??[]).map(e=>toScienceColumn(e,!0,m)),...(o.cycle_fields??[]).map(e=>toScienceColumn(e,!!e.editable,m))];return _jsx(ScienceTable,{title:`Cycle Data (${f.length})`,columns:t,rows:f,indexOrder:"descending",scrollable:e,scrollHeight:e?i:void 0,emptyMessage:"No cycles yet.",onCellEdit:S})})(),(()=>{const e={...g,...x},t=Object.keys(e).length>0,r=o.results_fields??[],n=r.map(e=>toScienceColumn(e,!1,m)),a=r.some(isProjectScoped);return _jsxs(_Fragment,{children:[_jsx(ScienceTable,{title:"Results",columns:n,rows:t?[e]:[],emptyMessage:"No results yet."}),a&&_jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary-color)",margin:"0.25rem 0 0.75rem"},children:"* across every test of this sample in the project. All other values describe this test."})]})})(),o.raw_data&&_jsxs(Dialog,{visible:j,onHide:()=>v(!1),header:`Run Data — ${a}`,style:{width:"90vw",height:"80vh"},maximizable:!0,children:[_jsx(CyclePickerBar,{cycles:V,selected:H,onChange:z}),_jsx(RawEnvelopeHeader,{envelope:R}),_jsxs(TabView,{style:{height:"100%"},children:[_jsx(TabPanel,{header:"Raw Data",children:_jsx(DataBlobTable,{blob:unwrapEnvelope(R),loading:O,error:A,rawData:o.raw_data})}),_jsx(TabPanel,{header:"Filtered Data",children:_jsx(DataBlobTable,{blob:unwrapEnvelope(E),loading:k,error:N,rawData:o.raw_data,emptyMessage:"Filtered data is written by post-processing — none on disk for this run yet."})})]})]}),_jsx(Dialog,{visible:w,onHide:()=>C(!1),header:"Test Configuration",style:{width:"min(640px, 90vw)"},modal:!0,children:_jsx(ConfigList,{config:p?.config})})]})};const Header=({meta:e,config:t,runId:r,projectId:n,methodId:a,canViewRaw:o,onViewRaw:l,onShowConfig:i})=>{const s="string"==typeof e?.sample_id&&e.sample_id||"string"==typeof e?.config?.sample_id&&e.config.sample_id||"",c=t&&"object"==typeof t&&Object.entries(t).some(([e])=>"sample_id"!==e);return _jsx("div",{className:"p-card",style:{padding:"1rem"},children:_jsxs("div",{className:"flex",style:{justifyContent:"space-between",alignItems:"flex-start",gap:"1rem"},children:[_jsxs("div",{children:[_jsxs("h2",{style:{margin:0,display:"flex",alignItems:"center",gap:"0.5rem"},children:[s||r,c&&_jsx(Button,{icon:"pi pi-info-circle",type:"button",rounded:!0,text:!0,onClick:i,tooltip:"Show test configuration",tooltipOptions:{position:"top"},style:{width:"2rem",height:"2rem",padding:0},"aria-label":"Show test configuration"})]}),_jsxs("div",{style:{color:"var(--text-secondary-color)",fontSize:"0.85em"},children:["project: ",n," · method: ",a," · run: ",r,e?.start_time&&_jsxs(_Fragment,{children:[" · started: ",new Date(e.start_time).toLocaleString()]})]})]}),o&&_jsx(Button,{icon:"pi pi-table",label:"View Raw Data",onClick:l,outlined:!0})]})})},ConfigList=({config:e})=>{const t=e&&"object"==typeof e?Object.entries(e).filter(([e])=>"sample_id"!==e):[];return 0===t.length?_jsx("div",{style:{color:"var(--text-secondary-color)"},children:"No configuration recorded for this run."}):_jsx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"0.5rem 1rem",fontSize:"0.95em"},children:t.map(([e,t])=>_jsxs(React.Fragment,{children:[_jsx("div",{style:{color:"var(--text-secondary-color)"},children:e}),_jsx("div",{children:formatCell(t,"string")})]},e))})},unwrapEnvelope=e=>e&&"object"==typeof e&&"data"in e&&e.data&&"object"==typeof e.data&&Object.values(e.data).some(e=>Array.isArray(e))?e.data:e,CyclePickerBar=({cycles:e,selected:t,onChange:r})=>e.length<=1?null:_jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.25rem 0.5rem 0.5rem"},children:[_jsx("label",{htmlFor:"raw-cycle-picker",style:{color:"var(--text-secondary-color)"},children:"Cycle:"}),_jsx(Dropdown,{inputId:"raw-cycle-picker",value:t,options:e.map(e=>({label:`Cycle ${e}`,value:e})),onChange:e=>r(Number(e.value)),style:{minWidth:"8rem"}}),_jsxs("span",{style:{color:"var(--text-secondary-color)"},children:["(",e.length," cycles recorded)"]})]}),RawEnvelopeHeader=({envelope:e})=>{if(!e||"object"!=typeof e)return null;const t=e.cycle_index,r=e.cycle_fields,n=e.context;if(null==t&&!r&&!n)return null;const a=e=>{if(!e||"object"!=typeof e)return null;const t=Object.entries(e).filter(([,e])=>null!==e&&"object"!=typeof e);return 0===t.length?null:t.map(([e,t])=>_jsxs("span",{style:{marginRight:"1rem"},children:[_jsxs("span",{style:{color:"var(--text-secondary-color)"},children:[e,": "]}),_jsx("span",{children:String(t)})]},e))};return _jsxs("div",{style:{padding:"0.5rem",borderBottom:"1px solid var(--surface-border)",fontSize:"0.9rem"},children:[null!=t&&_jsx("div",{children:_jsxs("strong",{children:["Cycle ",t]})}),r&&_jsx("div",{style:{marginTop:"0.25rem"},children:a(r)}),n&&_jsx("div",{style:{marginTop:"0.25rem"},children:a(n)})]})},DataBlobTable=({blob:e,loading:t,error:r,rawData:n,emptyMessage:a})=>{if(t)return _jsx("div",{style:{padding:"1rem",color:"var(--text-secondary-color)"},children:"Loading…"});if(r)return _jsx("div",{style:{padding:"1rem",color:"var(--text-secondary-color)"},children:a??r});if(!e||"object"!=typeof e)return _jsx("div",{style:{padding:"1rem",color:"var(--text-secondary-color)"},children:"No data."});const o=Object.keys(n.columns??{}),l=Object.keys(e).filter(t=>Array.isArray(e[t])),i=[];for(const t of o)Array.isArray(e[t])&&i.push(t);for(const e of l)i.includes(e)||i.push(e);if(0===i.length)return _jsx("div",{style:{padding:"1rem",color:"var(--text-secondary-color)"},children:a??"No columnar data in this blob."});const s=i.reduce((t,r)=>Math.min(t,e[r].length),Number.POSITIVE_INFINITY),c=Number.isFinite(s)?s:0,d=Array.from({length:c},(t,r)=>{const n={__i:r};for(const t of i)n[t]=e[t][r];return n}),u=e=>{const t=n.units?.[e];return t?`${e} [${t}]`:e};return _jsxs(DataTable,{value:d,scrollable:!0,scrollHeight:"60vh",virtualScrollerOptions:{itemSize:32},emptyMessage:a??"No data.",size:"small",stripedRows:!0,children:[_jsx(Column,{field:"__i",header:"#",style:{width:"5rem",textAlign:"right"},bodyStyle:{fontVariantNumeric:"tabular-nums",textAlign:"right"}}),i.map(e=>_jsx(Column,{field:e,header:u(e),style:{minWidth:"8rem"},bodyStyle:{fontVariantNumeric:"tabular-nums",textAlign:"right"},body:t=>formatNumeric(t[e])},e))]})},formatNumeric=e=>null==e?"":"number"==typeof e&&Number.isFinite(e)?Number.parseFloat(e.toPrecision(6)).toString():String(e),CYCLE_VIRTUAL_THRESHOLD=30,CHART_COLORS=["#4ea8de","#f59e0b","#22c55e","#a855f7","#ef4444","#14b8a6","#eab308","#ec4899"],palette=e=>CHART_COLORS[e%CHART_COLORS.length],SG_ORDER=3,SMOOTH_TARGET_POINTS=800;function invertMatrix(e){const t=e.length,r=e.map((e,r)=>[...e,...Array.from({length:t},(e,t)=>r===t?1:0)]);for(let e=0;e<t;e++){let n=e;for(let a=e+1;a<t;a++)Math.abs(r[a][e])>Math.abs(r[n][e])&&(n=a);if(Math.abs(r[n][e])<1e-12)return null;[r[e],r[n]]=[r[n],r[e]];const a=r[e][e];for(let n=0;n<2*t;n++)r[e][n]/=a;for(let n=0;n<t;n++){if(n===e)continue;const a=r[n][e];if(0!==a)for(let o=0;o<2*t;o++)r[n][o]-=a*r[e][o]}}return r.map(e=>e.slice(t))}function sgWeights(e,t){const r=2*e+1,n=Math.min(t,r-1),a=[];for(let t=-e;t<=e;t++){const e=[];let r=1;for(let a=0;a<=n;a++)e.push(r),r*=t;a.push(e)}const o=n+1,l=Array.from({length:o},()=>new Array(o).fill(0));for(let e=0;e<o;e++)for(let t=0;t<o;t++){let n=0;for(let o=0;o<r;o++)n+=a[o][e]*a[o][t];l[e][t]=n}const i=invertMatrix(l);if(!i)return new Array(r).fill(1/r);const s=new Array(r);for(let e=0;e<r;e++){let t=0;for(let r=0;r<o;r++)t+=i[0][r]*a[e][r];s[e]=t}return s}function savitzkyGolay(e,t){const r=e.length;if(0===r||t<1)return e.slice();const n=new Map,a=e=>{let t=n.get(e);return t||(t=sgWeights(e,3),n.set(e,t)),t},o=new Array(r);for(let n=0;n<r;n++){const l=Math.min(t,n,r-1-n);if(l<1){o[n]=e[n];continue}const i=a(l);let s=0;for(let t=-l;t<=l;t++)s+=i[t+l]*e[n+t];o[n]=s}return o}function smoothTraceForDisplay(e,t,r){const n=Math.min(e.length,t.length);if(0===n)return[];const a=r&&r>1?Math.max(1,Math.floor((Math.min(r,n)-1)/2)):Math.max(2,Math.min(40,Math.round(n/250))),o=savitzkyGolay(t.slice(0,n),a),l=Math.max(1,Math.ceil(n/SMOOTH_TARGET_POINTS)),i=[];for(let t=0;t<n;t+=l)i.push({x:e[t],y:o[t]});return(n-1)%l!=0&&i.push({x:e[n-1],y:o[n-1]}),i}const DEFAULT_REGION_FILL="rgba(78, 168, 222, 0.15)",REGION_LABEL_COLOR="rgba(226, 232, 240, 0.85)";function buildRegionAnnotations(e){if(!e||0===e.length)return{};const t={};return e.forEach((e,r)=>{const n=!!e.borderColor;t[`region-${r}`]={type:"box",xScaleID:"x",xMin:e.xMin,xMax:e.xMax,backgroundColor:e.color??DEFAULT_REGION_FILL,borderColor:n?e.borderColor:"transparent",borderWidth:n?1:0,drawTime:"beforeDatasetsDraw",...e.label?{label:{display:!0,content:e.label,position:{x:"center",y:"start"},color:REGION_LABEL_COLOR,font:{size:11}}}:{}}}),t}const ChartOverlay=({children:e})=>_jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-secondary-color)",pointerEvents:"none"},children:e});export const DEFAULT_X_DECIMALS=2;const formatAxisTick=(e,t)=>{const r="number"==typeof e?e:Number(e);return Number.isFinite(r)?Number.parseFloat(r.toFixed(t)).toString():null==e?"":String(e)},quantityOfField=(e,t)=>{if(e&&t)for(const r of[e.cycle_config_fields,e.cycle_fields,e.results_fields]){const e=(r??[]).find(e=>e.name===t);if(e?.quantity)return e.quantity}},quantityOfColumn=(e,t)=>{if(e&&t)return e.raw_data?.columns?.[t]?.quantity},toDisplayValue=(e,t)=>t&&"number"==typeof e&&Number.isFinite(e)?e*t.scale+(t.offset??0):e,seriesLabel=e=>e.label??e.field??e.column??"",axisLabel=(e,t,r)=>{const n=e?.y.filter(e=>"right"===e.y_axis==("right"===t))??[],a=n.map(seriesLabel).join(" / "),o=Array.from(new Set(n.map(r).filter(Boolean)));return 1===o.length?`${a} [${o[0]}]`:a},isProjectScoped=e=>"project"===e.aggregate?.scope,toScienceColumn=(e,t=!1,r)=>{const n=e.quantity?r?.[e.quantity]:void 0;return{field:e.name,label:(e.label&&e.label.length>0?e.label:e.name)+(isProjectScoped(e)?" *":""),units:n?n.label:e.units,editable:t,body:t=>formatCell(t[e.name],e.type,e.scale,n)}},formatCell=(e,t,r,n)=>null==e?"":n&&"number"==typeof e&&Number.isFinite(e)?formatScaled(e*n.scale+(n.offset??0),n):(r&&1!==r&&"number"==typeof e&&Number.isFinite(e)&&(e*=r),"f32"===t||"f64"===t?"number"==typeof e?e.toFixed(4):String(e):"object"==typeof e?JSON.stringify(e):String(e));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TisProvider.d.ts","sourceRoot":"","sources":["../../../src/components/tis/TisProvider.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,EASV,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMrE;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAC;AAErE,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,MAA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AW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAimBlD,CAAC;AAMF,eAAO,MAAM,MAAM,uBAAyC,CAAC;AAC7D,eAAO,MAAM,aAAa,sBAA0C,CAAC;AACrE,eAAO,MAAM,WAAW,oBAA0C,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;uBAvvBI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC;iBAG3C,OAAO,CAAC,IAAI,CAAC;eAtL1B,MAAM;cACP,MAAM;IAChB,gEAAgE;WACzD,gBAAgB;IACvB,yDAAyD;uBACtC,OAAO;IAC1B,uEAAuE;YAC/D,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3B;;mEAE+D;aACtD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IACnC;6DACyD;WAClD,OAAO;IACd,iEAAiE;aACxD,MAAM,EAAE;IACjB;iEAC6D;eAClD,OAAO;CAg6BrB,CAAC;AACF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,wCAv3BF,iBAAiB,KAAK,IAAI,CA03BnD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,YAAY,MAAM,EAAE,WAAW,MAAM;;;;CAY/D,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM;;;;;;;;CAuBvC,CAAC;AAIF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import React,{createContext,useCallback,useContext,useEffect,useMemo,useReducer,useRef,useState}from"react";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";const EMPTY_STATE={staged:!1,stagedProjectId:"",stagedMethodId:"",stagedSampleId:"",active:!1,activeProjectId:"",activeMethodId:"",activeSampleId:"",activeRunId:"",lastStartError:""},EMPTY_SELECTION={projectId:"",methodId:"",sampleId:"",runId:""},EMPTY_CYCLE_CONFIG={projectId:"",methodId:"",scope:"run",promptBeforeCycle:!1,values:{},latched:null,ready:!0,missing:[],promptDue:!1},cycleConfigFromPayload=e=>({projectId:String(e?.project_id??""),methodId:String(e?.method_id??""),scope:"cycle"===e?.scope?"cycle":"run",promptBeforeCycle:!!e?.prompt_before_cycle,values:e?.values&&"object"==typeof e.values?e.values:{},latched:e?.latched&&"object"==typeof e.latched?e.latched:null,ready:!1!==e?.ready,missing:Array.isArray(e?.missing)?e.missing:[],promptDue:!!e?.prompt_due}),TisContext=createContext({schemas:{},projectAssetRefs:[],defaultMethodId:"",schemasLoaded:!1,state:EMPTY_STATE,selection:EMPTY_SELECTION,setSelection:()=>{},existingProjects:[],projectKnown:()=>!1,refreshProjects:async()=>{},markProjectJustCreated:()=>{},projectFields:{},projectFieldsLoaded:!1,loadProjectFields:async()=>null,setProjectFields:()=>{},stagedConfig:{},setStagedConfig:()=>{},clearStagedConfig:()=>{},defaultsAppliedForMethod:"",markDefaultsAppliedForMethod:()=>{},configurationName:"",setConfigurationName:()=>{},cycleConfig:EMPTY_CYCLE_CONFIG,cycleConfigFields:[],setCycleConfigValues:async()=>{},clearCycleConfig:async()=>{},refreshCycleConfig:async()=>{},fetchRuns:async()=>[],fetchRun:async()=>null,runCache:{}});function liveReducer(e,t){switch(t.kind){case"staged":return{...e,staged:t.value};case"staged_project_id":return{...e,stagedProjectId:t.value};case"staged_method_id":return{...e,stagedMethodId:t.value};case"staged_sample_id":return{...e,stagedSampleId:t.value};case"active":return{...e,active:t.value};case"active_project_id":return{...e,activeProjectId:t.value};case"active_method_id":return{...e,activeMethodId:t.value};case"active_sample_id":return{...e,activeSampleId:t.value};case"active_run_id":return{...e,activeRunId:t.value};case"last_start_error":return{...e,lastStartError:t.value}}}export const TisProvider=({children:e,defaultMethodId:t})=>{const{invoke:s,read:c,subscribe:a,unsubscribe:d,isConnected:r}=useContext(EventEmitterContext),[o,i]=useState({}),[n,u]=useState([]),[l,_]=useState(t??""),[f,p]=useState(!1),[m,g]=useReducer(liveReducer,EMPTY_STATE),[C,h]=useState({projectId:null,methodId:null,sampleId:null,runId:null}),y=useCallback(async()=>{try{const e=await s("tis.list_schemas",MessageType.Request,{});if(e?.success&&e.data){const s=e.data.test_methods??{},c=e.data.default_method_id??"",a=Array.isArray(e.data.asset_refs)?e.data.asset_refs:[];i(s),u(a),!t&&c&&_(c),p(!0)}}catch(e){}},[s]);useEffect(()=>{y()},[y]),useEffect(()=>{const e=a("tis.schema_changed",()=>{y()});return()=>{d(e)}},[a,d,y]),useEffect(()=>{let e=!1;return(async()=>{try{const t=await s("gnv.ux.selected_project_id",MessageType.Read,{});if(e)return;const c=t?.success?t.data??"":"";"string"==typeof c&&c.length>0&&h(e=>null===e.projectId?{...e,projectId:c}:e)}catch{}})(),()=>{e=!0}},[]),useEffect(()=>{const e=[a("tis.staged",e=>g({kind:"staged",value:!!e})),a("tis.staged_project_id",e=>g({kind:"staged_project_id",value:String(e??"")})),a("tis.staged_method_id",e=>g({kind:"staged_method_id",value:String(e??"")})),a("tis.staged_sample_id",e=>g({kind:"staged_sample_id",value:String(e??"")})),a("tis.active",e=>g({kind:"active",value:!!e})),a("tis.active_project_id",e=>g({kind:"active_project_id",value:String(e??"")})),a("tis.active_method_id",e=>g({kind:"active_method_id",value:String(e??"")})),a("tis.active_sample_id",e=>g({kind:"active_sample_id",value:String(e??"")})),a("tis.active_run_id",e=>g({kind:"active_run_id",value:String(e??"")})),a("tis.last_start_error",e=>g({kind:"last_start_error",value:String(e??"")}))],t=[{fqdn:"gm.tis_staged",kind:"staged",bool:!0},{fqdn:"gm.tis_staged_project_id",kind:"staged_project_id"},{fqdn:"gm.tis_staged_method_id",kind:"staged_method_id"},{fqdn:"gm.tis_staged_sample_id",kind:"staged_sample_id"},{fqdn:"gm.tis_active",kind:"active",bool:!0},{fqdn:"gm.tis_active_project_id",kind:"active_project_id"},{fqdn:"gm.tis_active_method_id",kind:"active_method_id"},{fqdn:"gm.tis_active_sample_id",kind:"active_sample_id"},{fqdn:"gm.tis_active_run_id",kind:"active_run_id"}];let s=!1;return(async()=>{if(r)for(const{fqdn:e,kind:a,bool:d}of t)try{const t=await c(e);if(s)return;if(t&&!1===t.success)continue;const r=t?.data;if(null==r)continue;g({kind:a,value:d?!!r:String(r)})}catch{}})(),()=>{s=!0,e.forEach(d)}},[a,d,c,r]);const I=useRef({}),[v,j]=useState(0),S=useCallback(()=>j(e=>e+1),[]),T=useCallback((e,t)=>{if(!e)return;const s=I.current[e]??{meta:null,cycles:[],results:{},rawData:{}};I.current[e]={...s,cycles:[...s.cycles,t]},S()},[S]),E=useCallback((e,t)=>{if(!e)return;const s=I.current[e]??{meta:null,cycles:[],results:{},rawData:{}};I.current[e]={...s,results:t},S()},[S]);useEffect(()=>{const e=a("tis.cycle_added",e=>{e?.run_id&&e.cycle&&T(e.run_id,e.cycle)}),t=a("tis.results_updated",e=>{e?.run_id&&E(e.run_id,e.results??{})});return()=>{d(e),d(t)}},[a,d,T,E]);const k=useMemo(()=>({projectId:C.projectId??m.activeProjectId,methodId:C.methodId??(m.activeMethodId||l),sampleId:C.sampleId??m.activeSampleId,runId:C.runId??m.activeRunId}),[C,m,l]),x=useCallback(e=>{h(t=>({projectId:void 0===e.projectId?t.projectId:e.projectId,methodId:void 0===e.methodId?t.methodId:e.methodId,sampleId:void 0===e.sampleId?t.sampleId:e.sampleId,runId:void 0===e.runId?t.runId:e.runId})),void 0!==e.projectId&&s("gnv.ux.selected_project_id",MessageType.Write,e.projectId??"").catch(e=>{})},[s]),M=useRef("");useEffect(()=>{const e=m.activeRunId;e&&e!==M.current&&(M.current=e,h({projectId:null,methodId:null,sampleId:null,runId:null}))},[m.activeRunId]);const R=useCallback(async(e,t)=>{if(!e)return[];const c={project_id:e};t&&(c.method_id=t);try{const e=await s("tis.list_tests",MessageType.Request,c);if(e?.success&&e.data?.tests)return e.data.tests}catch(e){}return[]},[s]),P=useCallback(async(e,t,c)=>{if(!e||!t||!c)return null;try{const a=await s("tis.read_test",MessageType.Request,{project_id:e,method_id:t,run_id:c}),d=await s("tis.read_cycles",MessageType.Request,{project_id:e,method_id:t,run_id:c,offset:0,limit:1e3,order:"asc"});if(!a?.success)return null;const r={meta:a.data??null,cycles:d?.success?d.data?.cycles??[]:[],results:a.data?.results??{},rawData:I.current[c]?.rawData??{}};return I.current[c]=r,S(),r}catch(e){return null}},[s,S]),b=useMemo(()=>({...I.current}),[v]),[F,w]=useState([]),q=useRef(new Set),[Y,A]=useState(0),[L,N]=useState({}),D=useCallback(async()=>{try{const e=await s("tis.list_projects",MessageType.Request,{});e?.success&&e.data?.projects&&w(e.data.projects)}catch(e){}},[s]),O=useCallback(e=>{e&&(q.current.has(e)||(q.current.add(e),A(e=>e+1)))},[]),G=useCallback(e=>!!e&&(!!q.current.has(e)||F.includes(e)),[F,Y]),V=useCallback((e,t)=>{e&&N(s=>({...s,[e]:t}))},[]),B=useCallback(async e=>{if(!e)return null;try{const t=await s("tis.read_project",MessageType.Request,{project_id:e});if(t?.success){const s=t.data?.project_fields??{};return N(t=>({...t,[e]:s})),s}}catch(e){}return N(t=>({...t,[e]:{}})),{}},[s]);useEffect(()=>{D()},[D]),useEffect(()=>{const e=a("tis.project_created",()=>{D()}),t=a("tis.project_updated",e=>{const t="string"==typeof e?.project_id?e.project_id:"";t&&B(t)});return()=>{d(e),d(t)}},[a,d,D,B]),useEffect(()=>{const e=k.projectId;e&&G(e)&&void 0===L[e]&&B(e)},[k.projectId,G,L,B]);const J=L[k.projectId]??{},K=void 0!==L[k.projectId],[W,z]=useState({}),H=useCallback(e=>{z(t=>({...t,...e}))},[]),[Q,U]=useState(""),X=useCallback(e=>{U(e)},[]),[Z,$]=useState(""),ee=useCallback(()=>{z({}),U(""),$("")},[]),[te,se]=useState(EMPTY_CYCLE_CONFIG),ce=useMemo(()=>{const e=k.methodId?o[k.methodId]?.cycle_config_fields:void 0;return Array.isArray(e)?e:[]},[o,k.methodId]),ae=useCallback(async()=>{const e=k.projectId,t=k.methodId;if(t)try{const c=await s("tis.cycle_config",MessageType.Request,{project_id:e,method_id:t});if(c?.success)return void se(cycleConfigFromPayload(c.data));se(EMPTY_CYCLE_CONFIG)}catch(e){se(EMPTY_CYCLE_CONFIG)}else se(EMPTY_CYCLE_CONFIG)},[s,k.projectId,k.methodId]),de=useCallback(async e=>{const t=k.projectId,c=k.methodId;if(c)try{const a=await s("tis.set_cycle_config",MessageType.Request,{project_id:t,method_id:c,values:e});a?.success&&se(cycleConfigFromPayload(a.data))}catch(e){}},[s,k.projectId,k.methodId]),re=useCallback(async()=>{const e=k.projectId,t=k.methodId;if(t)try{const c=await s("tis.clear_cycle_config",MessageType.Request,{project_id:e,method_id:t});c?.success&&se(cycleConfigFromPayload(c.data))}catch(e){}},[s,k.projectId,k.methodId]);useEffect(()=>{ae()},[ae]),useEffect(()=>{const e=a("tis.schema_changed",()=>{ae()});return()=>{d(e)}},[a,d,ae]),useEffect(()=>{const e=a("tis.cycle_config",e=>{const t=String(e?.method_id??"");t&&k.methodId&&t!==k.methodId||se(cycleConfigFromPayload(e))});return()=>{d(e)}},[a,d,k.methodId]);const oe=useMemo(()=>({schemas:o,projectAssetRefs:n,defaultMethodId:l,schemasLoaded:f,state:m,selection:k,setSelection:x,existingProjects:F,projectKnown:G,refreshProjects:D,markProjectJustCreated:O,projectFields:J,projectFieldsLoaded:K,loadProjectFields:B,setProjectFields:V,stagedConfig:W,setStagedConfig:H,clearStagedConfig:ee,defaultsAppliedForMethod:Q,markDefaultsAppliedForMethod:X,configurationName:Z,setConfigurationName:$,cycleConfig:te,cycleConfigFields:ce,setCycleConfigValues:de,clearCycleConfig:re,refreshCycleConfig:ae,fetchRuns:R,fetchRun:P,runCache:b}),[o,n,l,f,m,k,x,F,G,D,O,J,K,B,V,W,H,ee,Q,X,Z,$,te,ce,de,re,ae,R,P,b]);return _jsx(TisContext.Provider,{value:oe,children:e})};export const useTis=()=>useContext(TisContext);export const useTisSchemas=()=>useContext(TisContext).schemas;export const useTisState=()=>useContext(TisContext).state;export const useTisCycleConfig=()=>{const{cycleConfig:e,cycleConfigFields:t,setCycleConfigValues:s,clearCycleConfig:c}=useContext(TisContext);return{...e,fields:t,setValues:s,clear:c}};export const useTisSelection=()=>{const{selection:e,setSelection:t}=useContext(TisContext);return[e,t]};export const useTisRuns=(e,t)=>{const{fetchRuns:s}=useContext(TisContext),[c,a]=useState([]),[d,r]=useState(!1),o=useCallback(async()=>{if(e){r(!0);try{a(await s(e,t))}finally{r(!1)}}else a([])},[e,t,s]);return useEffect(()=>{o()},[o]),{runs:c,loading:d,refresh:o}};export const useTisRun=e=>{const{selection:t,fetchRun:s,runCache:c}=useContext(TisContext),[a,d]=useState(!1),r=e??t.runId;useEffect(()=>{if(!r)return;if(c[r]?.meta)return;const e=t.projectId,a=t.methodId;e&&a&&(d(!0),s(e,a,r).finally(()=>d(!1)))},[r,t.projectId,t.methodId,s,c]);const o=r?c[r]:null;return{meta:o?.meta??null,cycles:o?.cycles??[],results:o?.results??{},rawData:o?.rawData??{},loading:a}};export{TisContext};
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import React,{createContext,useCallback,useContext,useEffect,useMemo,useReducer,useRef,useState}from"react";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";const EMPTY_STATE={staged:!1,stagedProjectId:"",stagedMethodId:"",stagedSampleId:"",active:!1,activeProjectId:"",activeMethodId:"",activeSampleId:"",activeRunId:"",lastStartError:""},EMPTY_SELECTION={projectId:"",methodId:"",sampleId:"",runId:""},EMPTY_CYCLE_CONFIG={projectId:"",methodId:"",scope:"run",promptBeforeCycle:!1,values:{},latched:null,ready:!0,missing:[],promptDue:!1},cycleConfigFromPayload=e=>({projectId:String(e?.project_id??""),methodId:String(e?.method_id??""),scope:"cycle"===e?.scope?"cycle":"run",promptBeforeCycle:!!e?.prompt_before_cycle,values:e?.values&&"object"==typeof e.values?e.values:{},latched:e?.latched&&"object"==typeof e.latched?e.latched:null,ready:!1!==e?.ready,missing:Array.isArray(e?.missing)?e.missing:[],promptDue:!!e?.prompt_due}),TisContext=createContext({schemas:{},projectAssetRefs:[],defaultMethodId:"",schemasLoaded:!1,state:EMPTY_STATE,selection:EMPTY_SELECTION,setSelection:()=>{},existingProjects:[],projectKnown:()=>!1,refreshProjects:async()=>{},markProjectJustCreated:()=>{},projectFields:{},projectFieldsLoaded:!1,loadProjectFields:async()=>null,setProjectFields:()=>{},stagedConfig:{},setStagedConfig:()=>{},clearStagedConfig:()=>{},defaultsAppliedForMethod:"",markDefaultsAppliedForMethod:()=>{},configurationName:"",setConfigurationName:()=>{},cycleConfig:EMPTY_CYCLE_CONFIG,cycleConfigFields:[],setCycleConfigValues:async()=>{},clearCycleConfig:async()=>{},refreshCycleConfig:async()=>{},fetchRuns:async()=>[],fetchRun:async()=>null,runCache:{}});function liveReducer(e,t){switch(t.kind){case"staged":return{...e,staged:t.value};case"staged_project_id":return{...e,stagedProjectId:t.value};case"staged_method_id":return{...e,stagedMethodId:t.value};case"staged_sample_id":return{...e,stagedSampleId:t.value};case"active":return{...e,active:t.value};case"active_project_id":return{...e,activeProjectId:t.value};case"active_method_id":return{...e,activeMethodId:t.value};case"active_sample_id":return{...e,activeSampleId:t.value};case"active_run_id":return{...e,activeRunId:t.value};case"last_start_error":return{...e,lastStartError:t.value}}}export const TisProvider=({children:e,defaultMethodId:t})=>{const{invoke:s,read:c,subscribe:a,unsubscribe:d,isConnected:r}=useContext(EventEmitterContext),[o,i]=useState({}),[n,u]=useState([]),[l,_]=useState(t??""),[f,p]=useState(!1),[m,g]=useReducer(liveReducer,EMPTY_STATE),[C,h]=useState({projectId:null,methodId:null,sampleId:null,runId:null}),y=useCallback(async()=>{try{const e=await s("tis.list_schemas",MessageType.Request,{});if(e?.success&&e.data){const s=e.data.test_methods??{},c=e.data.default_method_id??"",a=Array.isArray(e.data.asset_refs)?e.data.asset_refs:[];i(s),u(a),!t&&c&&_(c),p(!0)}}catch(e){}},[s]);useEffect(()=>{y()},[y]),useEffect(()=>{const e=a("tis.schema_changed",()=>{y()});return()=>{d(e)}},[a,d,y]),useEffect(()=>{let e=!1;return(async()=>{try{const t=await s("gnv.ux.selected_project_id",MessageType.Read,{});if(e)return;const c=t?.success?t.data??"":"";"string"==typeof c&&c.length>0&&h(e=>null===e.projectId?{...e,projectId:c}:e)}catch{}})(),()=>{e=!0}},[]),useEffect(()=>{const e=[a("tis.staged",e=>g({kind:"staged",value:!!e})),a("tis.staged_project_id",e=>g({kind:"staged_project_id",value:String(e??"")})),a("tis.staged_method_id",e=>g({kind:"staged_method_id",value:String(e??"")})),a("tis.staged_sample_id",e=>g({kind:"staged_sample_id",value:String(e??"")})),a("tis.active",e=>g({kind:"active",value:!!e})),a("tis.active_project_id",e=>g({kind:"active_project_id",value:String(e??"")})),a("tis.active_method_id",e=>g({kind:"active_method_id",value:String(e??"")})),a("tis.active_sample_id",e=>g({kind:"active_sample_id",value:String(e??"")})),a("tis.active_run_id",e=>g({kind:"active_run_id",value:String(e??"")})),a("tis.last_start_error",e=>g({kind:"last_start_error",value:String(e??"")}))],t=[{fqdn:"gm.tis_staged",kind:"staged",bool:!0},{fqdn:"gm.tis_staged_project_id",kind:"staged_project_id"},{fqdn:"gm.tis_staged_method_id",kind:"staged_method_id"},{fqdn:"gm.tis_staged_sample_id",kind:"staged_sample_id"},{fqdn:"gm.tis_active",kind:"active",bool:!0},{fqdn:"gm.tis_active_project_id",kind:"active_project_id"},{fqdn:"gm.tis_active_method_id",kind:"active_method_id"},{fqdn:"gm.tis_active_sample_id",kind:"active_sample_id"},{fqdn:"gm.tis_active_run_id",kind:"active_run_id"}];let s,o=!1,i=!1;const n=e=>{o||i||(async()=>{if(!r())return!1;let e=!1;for(const{fqdn:s,kind:a,bool:d}of t)try{const t=await c(s);if(o)return!0;if(t&&!1===t.success)continue;const r=t?.data;if(null==r)continue;e=!0,g({kind:a,value:d?!!r:String(r)})}catch{}return e})().then(t=>{o||(t?i=!0:s=setTimeout(()=>n(Math.min(2*e,5e3)),e))})};n(250);const u=a("HUB/connected",()=>{i=!1,n(250)});return()=>{o=!0,s&&clearTimeout(s),d(u),e.forEach(d)}},[a,d,c,r]);const I=useRef({}),[v,j]=useState(0),S=useCallback(()=>j(e=>e+1),[]),T=useCallback((e,t)=>{if(!e)return;const s=I.current[e]??{meta:null,cycles:[],results:{},rawData:{}};I.current[e]={...s,cycles:[...s.cycles,t]},S()},[S]),E=useCallback((e,t)=>{if(!e)return;const s=I.current[e]??{meta:null,cycles:[],results:{},rawData:{}};I.current[e]={...s,results:t},S()},[S]);useEffect(()=>{const e=a("tis.cycle_added",e=>{e?.run_id&&e.cycle&&T(e.run_id,e.cycle)}),t=a("tis.results_updated",e=>{e?.run_id&&E(e.run_id,e.results??{})});return()=>{d(e),d(t)}},[a,d,T,E]);const k=useMemo(()=>({projectId:C.projectId??m.activeProjectId,methodId:C.methodId??(m.activeMethodId||l),sampleId:C.sampleId??m.activeSampleId,runId:C.runId??m.activeRunId}),[C,m,l]),M=useCallback(e=>{h(t=>({projectId:void 0===e.projectId?t.projectId:e.projectId,methodId:void 0===e.methodId?t.methodId:e.methodId,sampleId:void 0===e.sampleId?t.sampleId:e.sampleId,runId:void 0===e.runId?t.runId:e.runId})),void 0!==e.projectId&&s("gnv.ux.selected_project_id",MessageType.Write,e.projectId??"").catch(e=>{})},[s]),x=useRef("");useEffect(()=>{const e=m.activeRunId;e&&e!==x.current&&(x.current=e,h({projectId:null,methodId:null,sampleId:null,runId:null}))},[m.activeRunId]);const R=useCallback(async(e,t)=>{if(!e)return[];const c={project_id:e};t&&(c.method_id=t);try{const e=await s("tis.list_tests",MessageType.Request,c);if(e?.success&&e.data?.tests)return e.data.tests}catch(e){}return[]},[s]),P=useCallback(async(e,t,c)=>{if(!e||!t||!c)return null;try{const a=await s("tis.read_test",MessageType.Request,{project_id:e,method_id:t,run_id:c}),d=await s("tis.read_cycles",MessageType.Request,{project_id:e,method_id:t,run_id:c,offset:0,limit:1e3,order:"asc"});if(!a?.success)return null;const r={meta:a.data??null,cycles:d?.success?d.data?.cycles??[]:[],results:a.data?.results??{},rawData:I.current[c]?.rawData??{}};return I.current[c]=r,S(),r}catch(e){return null}},[s,S]),b=useMemo(()=>({...I.current}),[v]),[F,w]=useState([]),q=useRef(new Set),[Y,A]=useState(0),[L,N]=useState({}),D=useCallback(async()=>{try{const e=await s("tis.list_projects",MessageType.Request,{});e?.success&&e.data?.projects&&w(e.data.projects)}catch(e){}},[s]),O=useCallback(e=>{e&&(q.current.has(e)||(q.current.add(e),A(e=>e+1)))},[]),G=useCallback(e=>!!e&&(!!q.current.has(e)||F.includes(e)),[F,Y]),V=useCallback((e,t)=>{e&&N(s=>({...s,[e]:t}))},[]),B=useCallback(async e=>{if(!e)return null;try{const t=await s("tis.read_project",MessageType.Request,{project_id:e});if(t?.success){const s=t.data?.project_fields??{};return N(t=>({...t,[e]:s})),s}}catch(e){}return N(t=>({...t,[e]:{}})),{}},[s]);useEffect(()=>{D()},[D]),useEffect(()=>{const e=a("tis.project_created",()=>{D()}),t=a("tis.project_updated",e=>{const t="string"==typeof e?.project_id?e.project_id:"";t&&B(t)});return()=>{d(e),d(t)}},[a,d,D,B]),useEffect(()=>{const e=k.projectId;e&&G(e)&&void 0===L[e]&&B(e)},[k.projectId,G,L,B]);const J=L[k.projectId]??{},K=void 0!==L[k.projectId],[H,U]=useState({}),W=useCallback(e=>{U(t=>({...t,...e}))},[]),[z,Q]=useState(""),X=useCallback(e=>{Q(e)},[]),[Z,$]=useState(""),ee=useCallback(()=>{U({}),Q(""),$("")},[]),[te,se]=useState(EMPTY_CYCLE_CONFIG),ce=useMemo(()=>{const e=k.methodId?o[k.methodId]?.cycle_config_fields:void 0;return Array.isArray(e)?e:[]},[o,k.methodId]),ae=useCallback(async()=>{const e=k.projectId,t=k.methodId;if(t)try{const c=await s("tis.cycle_config",MessageType.Request,{project_id:e,method_id:t});if(c?.success)return void se(cycleConfigFromPayload(c.data));se(EMPTY_CYCLE_CONFIG)}catch(e){se(EMPTY_CYCLE_CONFIG)}else se(EMPTY_CYCLE_CONFIG)},[s,k.projectId,k.methodId]),de=useCallback(async e=>{const t=k.projectId,c=k.methodId;if(c)try{const a=await s("tis.set_cycle_config",MessageType.Request,{project_id:t,method_id:c,values:e});a?.success&&se(cycleConfigFromPayload(a.data))}catch(e){}},[s,k.projectId,k.methodId]),re=useCallback(async()=>{const e=k.projectId,t=k.methodId;if(t)try{const c=await s("tis.clear_cycle_config",MessageType.Request,{project_id:e,method_id:t});c?.success&&se(cycleConfigFromPayload(c.data))}catch(e){}},[s,k.projectId,k.methodId]);useEffect(()=>{ae()},[ae]),useEffect(()=>{const e=a("tis.schema_changed",()=>{ae()});return()=>{d(e)}},[a,d,ae]),useEffect(()=>{const e=a("tis.cycle_config",e=>{const t=String(e?.method_id??"");t&&k.methodId&&t!==k.methodId||se(cycleConfigFromPayload(e))});return()=>{d(e)}},[a,d,k.methodId]);const oe=useMemo(()=>({schemas:o,projectAssetRefs:n,defaultMethodId:l,schemasLoaded:f,state:m,selection:k,setSelection:M,existingProjects:F,projectKnown:G,refreshProjects:D,markProjectJustCreated:O,projectFields:J,projectFieldsLoaded:K,loadProjectFields:B,setProjectFields:V,stagedConfig:H,setStagedConfig:W,clearStagedConfig:ee,defaultsAppliedForMethod:z,markDefaultsAppliedForMethod:X,configurationName:Z,setConfigurationName:$,cycleConfig:te,cycleConfigFields:ce,setCycleConfigValues:de,clearCycleConfig:re,refreshCycleConfig:ae,fetchRuns:R,fetchRun:P,runCache:b}),[o,n,l,f,m,k,M,F,G,D,O,J,K,B,V,H,W,ee,z,X,Z,$,te,ce,de,re,ae,R,P,b]);return _jsx(TisContext.Provider,{value:oe,children:e})};export const useTis=()=>useContext(TisContext);export const useTisSchemas=()=>useContext(TisContext).schemas;export const useTisState=()=>useContext(TisContext).state;export const useTisCycleConfig=()=>{const{cycleConfig:e,cycleConfigFields:t,setCycleConfigValues:s,clearCycleConfig:c}=useContext(TisContext);return{...e,fields:t,setValues:s,clear:c}};export const useTisSelection=()=>{const{selection:e,setSelection:t}=useContext(TisContext);return[e,t]};export const useTisRuns=(e,t)=>{const{fetchRuns:s}=useContext(TisContext),[c,a]=useState([]),[d,r]=useState(!1),o=useCallback(async()=>{if(e){r(!0);try{a(await s(e,t))}finally{r(!1)}}else a([])},[e,t,s]);return useEffect(()=>{o()},[o]),{runs:c,loading:d,refresh:o}};export const useTisRun=e=>{const{selection:t,fetchRun:s,runCache:c}=useContext(TisContext),[a,d]=useState(!1),r=e??t.runId;useEffect(()=>{if(!r)return;if(c[r]?.meta)return;const e=t.projectId,a=t.methodId;e&&a&&(d(!0),s(e,a,r).finally(()=>d(!1)))},[r,t.projectId,t.methodId,s,c]);const o=r?c[r]:null;return{meta:o?.meta??null,cycles:o?.cycles??[],results:o?.results??{},rawData:o?.rawData??{},loading:a}};export{TisContext};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeleteMethodDialog — the three-step method deletion.
|
|
3
|
+
*
|
|
4
|
+
* Deleting a test method destroys more than a config entry. It takes the
|
|
5
|
+
* procedure that produced the numbers with it, and it orphans every run in
|
|
6
|
+
* history from the schema that gives those runs meaning: the column names, the
|
|
7
|
+
* units, the chart definitions. A `window.confirm` is not a proportionate gate
|
|
8
|
+
* on that.
|
|
9
|
+
*
|
|
10
|
+
* So the operator walks three steps and cannot skip any of them:
|
|
11
|
+
*
|
|
12
|
+
* 1. Read what goes. Named, counted, and explicit about the history.
|
|
13
|
+
* 2. Download the archive. MANDATORY, not advisory. `tis.export_method_zip`
|
|
14
|
+
* hands back every run of this method. The button
|
|
15
|
+
* gates step 3, so "I'll do it later" is not a
|
|
16
|
+
* path through this dialog.
|
|
17
|
+
* 3. Type the phrase. `YES I AM SURE`, exactly. A phrase cannot be
|
|
18
|
+
* hit by a mis-touch on a panel, and typing it is
|
|
19
|
+
* the moment the operator reads step 1 properly.
|
|
20
|
+
*
|
|
21
|
+
* The deletion itself is still STAGED — the TIS editor's Save is what persists
|
|
22
|
+
* it — but the sequence file and the operator's confidence are not, so this is
|
|
23
|
+
* where the friction belongs.
|
|
24
|
+
*/
|
|
25
|
+
/** Typed exactly, case-sensitive. */
|
|
26
|
+
export declare const DELETE_PHRASE = "YES I AM SURE";
|
|
27
|
+
export interface DeleteMethodDialogProps {
|
|
28
|
+
visible: boolean;
|
|
29
|
+
methodId: string | null;
|
|
30
|
+
/** True when this method's procedure is a file that will also be removed. */
|
|
31
|
+
hasSequence: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Fetch the archive of this method's runs and hand it to the browser.
|
|
34
|
+
* Resolves true once the download has been started.
|
|
35
|
+
*/
|
|
36
|
+
onDownloadArchive: (methodId: string) => Promise<boolean>;
|
|
37
|
+
onConfirm: () => void;
|
|
38
|
+
onCancel: () => void;
|
|
39
|
+
busy?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare const DeleteMethodDialog: React.FC<DeleteMethodDialogProps>;
|
|
42
|
+
export default DeleteMethodDialog;
|
|
43
|
+
//# sourceMappingURL=DeleteMethodDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteMethodDialog.d.ts","sourceRoot":"","sources":["../../../src/components/tis-editor/DeleteMethodDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,qCAAqC;AACrC,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,6EAA6E;IAC7E,WAAW,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA8GhE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useEffect,useState}from"react";import{Button}from"primereact/button";import{Dialog}from"primereact/dialog";import{InputText}from"primereact/inputtext";import{Message}from"primereact/message";export const DELETE_PHRASE="YES I AM SURE";export const DeleteMethodDialog=({visible:e,methodId:t,hasSequence:s,onDownloadArchive:i,onConfirm:n,onCancel:o,busy:r})=>{const[l,a]=useState(!1),[d,c]=useState(!1),[h,u]=useState(""),[p,m]=useState(null);useEffect(()=>{e&&(a(!1),c(!1),u(""),m(null))},[e,t]);const x=h===DELETE_PHRASE;return _jsxs(Dialog,{header:`Delete test method "${t??""}"`,visible:e,onHide:o,style:{width:"34rem"},modal:!0,children:[_jsxs("ol",{className:"tis-editor__delete-steps",children:[_jsxs("li",{children:[_jsx("strong",{children:"What this removes"}),_jsxs("ul",{children:[_jsx("li",{children:"The method definition: its fields, charts, results and asset references."}),s&&_jsx("li",{children:"Its sequence — the procedure that runs the test."}),_jsx("li",{children:"Nothing in the recorded data is erased, but every past run of this method loses the definition that names its columns. Reports and charts for those runs will no longer render."})]})]}),_jsxs("li",{children:[_jsx("strong",{children:"Download the archive"}),_jsx("p",{children:"Every run recorded under this method, as a ZIP. This is required — the confirmation below stays locked until the download has started."}),_jsx(Button,{label:l?"Archive downloaded":"Download archive",icon:d?"pi pi-spin pi-spinner":l?"pi pi-check":"pi pi-box",severity:l?"success":void 0,disabled:d||r,onClick:async()=>{if(t){c(!0),m(null);try{const e=await i(t);a(e),e||m("The archive could not be built, so nothing has been deleted.")}catch(e){m(`The archive could not be built, so nothing has been deleted: ${e instanceof Error?e.message:String(e)}`)}finally{c(!1)}}}})]}),_jsxs("li",{children:[_jsx("strong",{children:"Confirm"}),_jsxs("p",{children:["Type ",_jsx("code",{children:DELETE_PHRASE})," to enable the delete button."]}),_jsx(InputText,{value:h,onChange:e=>u(e.target.value),placeholder:DELETE_PHRASE,disabled:!l||r,style:{width:"100%"}})]})]}),p&&_jsx(Message,{severity:"error",text:p,style:{width:"100%"}}),_jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[_jsx(Button,{label:"Cancel",className:"p-button-text",onClick:o,disabled:r}),_jsx(Button,{label:"Delete method",icon:"pi pi-trash",className:"p-button-danger",disabled:!l||!x||r,onClick:n})]})]})};export default DeleteMethodDialog;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MethodTransfer — a whole test method as one portable file.
|
|
3
|
+
*
|
|
4
|
+
* ## Why the method and not the sequence
|
|
5
|
+
*
|
|
6
|
+
* A sequence-backed method is two halves with a contract between them: the
|
|
7
|
+
* schema declares the cycle columns, and the procedure's `store_value` steps
|
|
8
|
+
* fill them by name. Exporting either half alone produces something that looks
|
|
9
|
+
* like a method and silently is not — a schema with no producer records blank
|
|
10
|
+
* rows on every cycle forever, and a procedure with no schema stores values
|
|
11
|
+
* nothing displays. Neither failure announces itself.
|
|
12
|
+
*
|
|
13
|
+
* So the exportable unit is the pair. This is the same reasoning that made
|
|
14
|
+
* `acctl push methods` move both files with one verb.
|
|
15
|
+
*
|
|
16
|
+
* ## The file
|
|
17
|
+
*
|
|
18
|
+
* Plain JSON, human-readable, no archive container: it goes on a USB stick
|
|
19
|
+
* between companies and someone will open it in a text editor.
|
|
20
|
+
*
|
|
21
|
+
* {
|
|
22
|
+
* "format": "autocore-method",
|
|
23
|
+
* "version": 1,
|
|
24
|
+
* "method_id": "golf_compression",
|
|
25
|
+
* "schema": { ...test_methods.json entry... },
|
|
26
|
+
* "sequence": { ...seq.json..., or null for a control-backed method }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* `method_id` is a SUGGESTION, not an instruction. The importer offers it and
|
|
30
|
+
* lets the operator rename, because a method list that fills up with
|
|
31
|
+
* `golf_compression_copy_3` is the complaint that follows otherwise.
|
|
32
|
+
*/
|
|
33
|
+
import type { TestMethod } from './types';
|
|
34
|
+
export declare const METHOD_FILE_FORMAT = "autocore-method";
|
|
35
|
+
export declare const METHOD_FILE_VERSION = 1;
|
|
36
|
+
export interface MethodTransferFile {
|
|
37
|
+
format: typeof METHOD_FILE_FORMAT;
|
|
38
|
+
version: number;
|
|
39
|
+
method_id: string;
|
|
40
|
+
schema: TestMethod;
|
|
41
|
+
/** The procedure, or null for a control-backed method. */
|
|
42
|
+
sequence: any | null;
|
|
43
|
+
}
|
|
44
|
+
/** Build the export payload. */
|
|
45
|
+
export declare function buildTransfer(methodId: string, schema: TestMethod, sequence: any | null): MethodTransferFile;
|
|
46
|
+
/**
|
|
47
|
+
* Legal method ids, and why the rule is this strict.
|
|
48
|
+
*
|
|
49
|
+
* The id becomes a path segment (`methods/<id>.seq.json`) and a directory name
|
|
50
|
+
* under the project (`<project>/<method_id>/<run_id>/`), both joined
|
|
51
|
+
* server-side, so anything that could traverse or quote-escape is refused at
|
|
52
|
+
* entry rather than sanitised silently — an id that comes back different from
|
|
53
|
+
* what was typed is how you end up with two methods you believe are one.
|
|
54
|
+
*
|
|
55
|
+
* It is also a Rust identifier stem in generated code, hence the leading-letter
|
|
56
|
+
* rule: `2point_bend` would emit `2pointBendTestManager`, which does not
|
|
57
|
+
* compile.
|
|
58
|
+
*/
|
|
59
|
+
export declare const METHOD_ID_RE: RegExp;
|
|
60
|
+
export declare const METHOD_ID_RULE = "Letters, digits and underscore only; must start with a letter.";
|
|
61
|
+
/** Parse and validate an imported file. Returns the file or a reason. */
|
|
62
|
+
export declare function parseTransfer(text: string): {
|
|
63
|
+
file: MethodTransferFile;
|
|
64
|
+
} | {
|
|
65
|
+
error: string;
|
|
66
|
+
};
|
|
67
|
+
/** Hand the browser a method export to save. */
|
|
68
|
+
export declare function downloadTransfer(file: MethodTransferFile): void;
|
|
69
|
+
//# sourceMappingURL=MethodTransfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodTransfer.d.ts","sourceRoot":"","sources":["../../../src/components/tis-editor/MethodTransfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AACpD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,OAAO,kBAAkB,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,0DAA0D;IAC1D,QAAQ,EAAE,GAAG,GAAG,IAAI,CAAC;CACxB;AAED,gCAAgC;AAChC,wBAAgB,aAAa,CACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,GAAG,GAAG,IAAI,GACrB,kBAAkB,CAQpB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,QAA4B,CAAC;AACtD,eAAO,MAAM,cAAc,mEACyC,CAAC;AAErE,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CA4C5F;AAED,gDAAgD;AAChD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAU/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const METHOD_FILE_FORMAT="autocore-method";export const METHOD_FILE_VERSION=1;export function buildTransfer(e,t,r){return{format:"autocore-method",version:1,method_id:e,schema:t,sequence:r??null}}export const METHOD_ID_RE=/^[A-Za-z][A-Za-z0-9_]*$/;export const METHOD_ID_RULE="Letters, digits and underscore only; must start with a letter.";export function parseTransfer(e){let t;try{t=JSON.parse(e)}catch(e){return{error:`Not valid JSON: ${e instanceof Error?e.message:String(e)}`}}if("object"!=typeof t||null===t)return{error:"File does not contain a method object."};const r=t;if("autocore-method"!==r.format){return{error:Array.isArray(t?.steps)?"This is a sequence file, not a whole method. Import it from a method export, or create the method first and edit its sequence on the Method screen.":'Not an autocore method export (missing "format": "autocore-method").'}}return"number"!=typeof r.version||r.version>1?{error:`This file was written by a newer version (v${r.version}); this machine understands up to v1.`}:"string"==typeof r.method_id&&METHOD_ID_RE.test(r.method_id)?"object"!=typeof r.schema||null===r.schema?{error:"File has no method schema."}:"sequence"!==r.schema.procedure||Array.isArray(r.sequence?.steps)?{file:r}:{error:"This method declares a sequence procedure but the file carries no sequence. Re-export it from the machine it came from."}:{error:`File has no usable method id. ${METHOD_ID_RULE}`}}export function downloadTransfer(e){const t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(t),o=document.createElement("a");o.href=r,o.download=`${e.method_id}.method.json`,o.click(),setTimeout(()=>URL.revokeObjectURL(r),0)}
|
|
@@ -150,3 +150,34 @@
|
|
|
150
150
|
border-bottom: 1px solid var(--surface-d, #e2e8f0);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
+
|
|
154
|
+
/*
|
|
155
|
+
* The three-step method deletion. Numbered because the steps are ordered and
|
|
156
|
+
* gated: the archive download unlocks the confirmation phrase, which unlocks
|
|
157
|
+
* the button. See DeleteMethodDialog for why deleting a method earns this.
|
|
158
|
+
*/
|
|
159
|
+
.tis-editor__delete-steps {
|
|
160
|
+
margin: 0 0 1rem;
|
|
161
|
+
padding-left: 1.4rem;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.tis-editor__delete-steps > li {
|
|
165
|
+
margin-bottom: 1rem;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.tis-editor__delete-steps p {
|
|
169
|
+
margin: 0.35rem 0 0.5rem;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.tis-editor__delete-steps ul {
|
|
173
|
+
margin: 0.35rem 0 0;
|
|
174
|
+
padding-left: 1.1rem;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.tis-editor__delete-steps code {
|
|
178
|
+
padding: 0.1rem 0.35rem;
|
|
179
|
+
border-radius: 3px;
|
|
180
|
+
background: var(--surface-ground);
|
|
181
|
+
font-family: var(--font-family-mono, monospace);
|
|
182
|
+
letter-spacing: 0.04em;
|
|
183
|
+
}
|
|
@@ -4,7 +4,15 @@
|
|
|
4
4
|
* Left: PrimeReact DataTable listing methods (method_id + label).
|
|
5
5
|
* Right: tabbed editor for the selected method. Phase 1 ships a single
|
|
6
6
|
* JSON-via-Monaco tab; Phase 2 layers form editors on top of it.
|
|
7
|
-
* Action bar: New / Duplicate / Delete / Apply / Save / Revert.
|
|
7
|
+
* Action bar: New / Duplicate / Delete / Import / Export / Apply / Save / Revert.
|
|
8
|
+
*
|
|
9
|
+
* ## A method is two files
|
|
10
|
+
*
|
|
11
|
+
* A method whose `procedure` is `"sequence"` also owns
|
|
12
|
+
* `methods/<method_id>.seq.json`. This editor is the only place a method is
|
|
13
|
+
* created, copied, deleted or moved between machines, so it is the only place
|
|
14
|
+
* that can keep the two halves together — see `useMethodSequence` for what goes
|
|
15
|
+
* wrong when they drift. Every lifecycle action below therefore moves both.
|
|
8
16
|
*
|
|
9
17
|
* "Apply" pushes the local Monaco buffer to the server-side stage
|
|
10
18
|
* (`tis.put_method`). "Save" persists the entire stage to test_methods.json
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TisConfigEditor.d.ts","sourceRoot":"","sources":["../../../src/components/tis-editor/TisConfigEditor.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"TisConfigEditor.d.ts","sourceRoot":"","sources":["../../../src/components/tis-editor/TisConfigEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAaH,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAY5E,OAAO,uBAAuB,CAAC;AAM/B,MAAM,WAAW,oBAAoB;IACjC;+EAC2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,OAAO,CAAC,EAAE,aAAa,CAAC;CAC3B;AAmBD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA8jB1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useEffect,useMemo,useState}from"react";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Button}from"primereact/button";import{InputText}from"primereact/inputtext";import{Dialog}from"primereact/dialog";import{useContext}from"react";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useTisConfig}from"../../hooks/useTisConfig";import{useAmsAssetTypes}from"../../hooks/useAmsAssetTypes";import{MethodFormEditor}from"./editor/MethodFormEditor";import{SaveDiffDialog}from"./editor/SaveDiffDialog";import"./TisConfigEditor.css";import{useGmVariables}from"../../hooks/useGmVariables";import{useSequenceProducers}from"../../hooks/useSequenceProducers";import{AuthoringContext}from"./editor/AuthoringContext";import{AutoCoreTagContext}from"../../core/AutoCoreTagContext";const EMPTY_METHOD={label:"",description:"",project_fields:[],config_fields:[],cycle_config_fields:[],cycle_fields:[],results_fields:[],views:{},asset_refs:[]};export const TisConfigEditor=({projectId:e,invoker:t})=>{const s=useContext(EventEmitterContext),i=useMemo(()=>t??(async(e,t)=>await s.invoke(e,MessageType.Request,t)),[t,s]),o=useTisConfig(e,{invoker:i}),{tags:a}=useContext(AutoCoreTagContext),r=useGmVariables({invoker:i,fallbackTags:a}),n=useAmsAssetTypes({invoker:i}),[l,d]=useState(null),[c,m]=useState(null),[u,f]=useState(!1),[p,h]=useState(!1),[g,_]=useState(!1),[x,y]=useState(""),b=useMemo(()=>o.config?Object.entries(o.config.methods).map(([e,t])=>({id:e,label:t?.label??""})):[],[o.config]);useEffect(()=>{if(!l&&o.config){const e=o.config.defaultMethodId||Object.keys(o.config.methods)[0]||null;d(e)}},[o.config,l]),useEffect(()=>{m(null)},[l]);const{producedNames:v}=useSequenceProducers(l),j=useMemo(()=>({variables:r.variables,producedNames:v,partial:r.partial}),[r.variables,v,r.partial]);return _jsx(AuthoringContext.Provider,{value:j,children:_jsxs("div",{className:"tis-editor",children:[_jsxs("header",{className:"tis-editor__header",children:[_jsxs("h2",{children:["Test Methods"," ",o.config?.dirty&&_jsx("span",{className:"tis-editor__dirty-pill",children:"unsaved"})]}),_jsxs("div",{className:"tis-editor__header-actions",children:[_jsx(Button,{label:"Save…",icon:"pi pi-save",disabled:u||!o.config?.dirty,onClick:()=>h(!0)}),_jsx(Button,{label:"Revert",icon:"pi pi-undo",className:"p-button-secondary",disabled:u||!o.config?.dirty,onClick:async()=>{if(window.confirm("Discard all in-progress edits? This cannot be undone.")){f(!0);try{await o.revert()}catch(e){m(String(e?.message??e))}finally{f(!1)}}}})]})]}),o.error&&_jsxs("div",{className:"tis-editor__error",children:[_jsx("strong",{children:"Error:"})," ",_jsx("pre",{children:o.error})]}),r.partial&&_jsx("div",{className:"tis-editor__notice",children:"This server cannot describe its own variables, so the pickers are listing only the variables published to this HMI, without descriptions. Update autocore_server to get the full list."}),_jsxs("div",{className:"tis-editor__body",children:[_jsxs("aside",{className:"tis-editor__sidebar",children:[_jsxs("div",{className:"tis-editor__sidebar-actions",children:[_jsx(Button,{label:"New",icon:"pi pi-plus",disabled:u,onClick:()=>_(!0)}),_jsx(Button,{label:"Duplicate",icon:"pi pi-clone",className:"p-button-secondary",disabled:u||!l,onClick:async()=>{if(!l||!o.config)return;const e=o.config.methods[l];if(!e)return;let t=`${l}_copy`,s=2;for(;o.config.methods[t];)t=`${l}_copy_${s++}`;f(!0);try{await o.putMethod(t,JSON.parse(JSON.stringify(e))),d(t)}catch(e){m(String(e?.message??e))}finally{f(!1)}}}),_jsx(Button,{label:"Delete",icon:"pi pi-trash",className:"p-button-danger",disabled:u||!l,onClick:async()=>{if(l&&window.confirm(`Remove method "${l}"? This is staged — Save persists it.`)){f(!0);try{await o.removeMethod(l),d(null)}catch(e){m(String(e?.message??e))}finally{f(!1)}}}})]}),_jsxs(DataTable,{value:b,selection:b.find(e=>e.id===l)??null,onSelectionChange:e=>d(e.value?.id??null),selectionMode:"single",dataKey:"id",scrollable:!0,scrollHeight:"flex",emptyMessage:o.loading?"Loading…":"No test methods defined.",children:[_jsx(Column,{field:"id",header:"Method ID"}),_jsx(Column,{field:"label",header:"Label"})]})]}),_jsx("section",{className:"tis-editor__detail",children:l&&o.config?.methods[l]?_jsxs(_Fragment,{children:[c&&_jsx("div",{className:"tis-editor__error",children:_jsx("pre",{children:c})}),_jsx(MethodFormEditor,{methodId:l,method:o.config.methods[l],onApply:async e=>{if(l){f(!0);try{await o.putMethod(l,e),m(null)}catch(e){m(String(e?.message??e))}finally{f(!1)}}},busy:u,knownAssetTypes:n.types})]}):_jsx("div",{className:"tis-editor__empty",children:"Select a test method on the left, or create a new one."})})]}),_jsxs(Dialog,{header:"New Test Method",visible:g,onHide:()=>_(!1),style:{width:"24rem"},children:[_jsxs("label",{className:"tis-editor__new-method-label",children:["Method ID",_jsx(InputText,{value:x,onChange:e=>y(e.target.value),placeholder:"e.g. translational_traction",autoFocus:!0})]}),_jsx("small",{children:"Canonical key — appears in wire payloads, on-disk paths, and generated code."}),_jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[_jsx(Button,{label:"Cancel",className:"p-button-text",onClick:()=>_(!1)}),_jsx(Button,{label:"Create",disabled:!x.trim()||u,onClick:async()=>{const e=x.trim();if(e)if(o.config?.methods[e])m(`A method named "${e}" already exists.`);else{f(!0);try{await o.putMethod(e,EMPTY_METHOD),d(e),_(!1),y("")}catch(e){m(String(e?.message??e))}finally{f(!1)}}}})]})]}),_jsx(SaveDiffDialog,{visible:p,staged:o.config?.methods??{},invoker:i,onConfirm:async()=>{f(!0);try{await o.save(),h(!1)}catch(e){m(String(e?.message??e))}finally{f(!1)}},onCancel:()=>h(!1)})]})})};export default TisConfigEditor;
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useEffect,useMemo,useRef,useState}from"react";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Button}from"primereact/button";import{InputText}from"primereact/inputtext";import{Dialog}from"primereact/dialog";import{Message}from"primereact/message";import{SelectButton}from"primereact/selectbutton";import{useContext}from"react";import{EventEmitterContext}from"../../core/EventEmitterContext";import{MessageType}from"../../hub/CommandMessage";import{useTisConfig}from"../../hooks/useTisConfig";import{useAmsAssetTypes}from"../../hooks/useAmsAssetTypes";import{MethodFormEditor}from"./editor/MethodFormEditor";import{SaveDiffDialog}from"./editor/SaveDiffDialog";import{DeleteMethodDialog}from"./DeleteMethodDialog";import{buildTransfer,downloadTransfer,METHOD_ID_RE,METHOD_ID_RULE,parseTransfer}from"./MethodTransfer";import{useMethodSequence,emptySequence}from"../../hooks/useMethodSequence";import"./TisConfigEditor.css";import{useGmVariables}from"../../hooks/useGmVariables";import{useSequenceProducers}from"../../hooks/useSequenceProducers";import{AuthoringContext}from"./editor/AuthoringContext";import{AutoCoreTagContext}from"../../core/AutoCoreTagContext";const EMPTY_METHOD={label:"",description:"",project_fields:[],config_fields:[],cycle_config_fields:[],cycle_fields:[],results_fields:[],views:{},asset_refs:[]};export const TisConfigEditor=({projectId:e,invoker:t})=>{const s=useContext(EventEmitterContext),i=useMemo(()=>t??(async(e,t)=>await s.invoke(e,MessageType.Request,t)),[t,s]),o=useTisConfig(e,{invoker:i}),{tags:a}=useContext(AutoCoreTagContext),r=useGmVariables({invoker:i,fallbackTags:a}),n=useAmsAssetTypes({invoker:i}),[l,d]=useState(null),[c,m]=useState(null),[u,h]=useState(!1),[p,_]=useState(!1),[f,g]=useState(!1),[x,y]=useState(""),[b,j]=useState("sequence"),[v,T]=useState(!1),C=useRef(null),[w,M]=useState(null),[E,D]=useState(""),[S,k]=useState(null),N=useMethodSequence(),I=useMemo(()=>o.config?Object.entries(o.config.methods).map(([e,t])=>({id:e,label:t?.label??""})):[],[o.config]);useEffect(()=>{if(!l&&o.config){const e=o.config.defaultMethodId||Object.keys(o.config.methods)[0]||null;d(e)}},[o.config,l]),useEffect(()=>{m(null)},[l]);const{producedNames:q}=useSequenceProducers(l),A=useMemo(()=>({variables:r.variables,producedNames:q,partial:r.partial}),[r.variables,q,r.partial]),H=async()=>{if(!w)return;const e=E.trim();if(METHOD_ID_RE.test(e)){h(!0);try{w.sequence&&await N.write(e,w.sequence),await o.putMethod(e,w.schema),d(e),M(null),k(null)}catch(e){k(String(e?.message??e))}finally{h(!1)}}else k(`"${e}" is not a valid method id. ${METHOD_ID_RULE}`)};return _jsx(AuthoringContext.Provider,{value:A,children:_jsxs("div",{className:"tis-editor",children:[_jsxs("header",{className:"tis-editor__header",children:[_jsxs("h2",{children:["Test Methods"," ",o.config?.dirty&&_jsx("span",{className:"tis-editor__dirty-pill",children:"unsaved"})]}),_jsxs("div",{className:"tis-editor__header-actions",children:[_jsx(Button,{label:"Save…",icon:"pi pi-save",disabled:u||!o.config?.dirty,onClick:()=>_(!0)}),_jsx(Button,{label:"Revert",icon:"pi pi-undo",className:"p-button-secondary",disabled:u||!o.config?.dirty,onClick:async()=>{if(window.confirm("Discard all in-progress edits? This cannot be undone.")){h(!0);try{await o.revert()}catch(e){m(String(e?.message??e))}finally{h(!1)}}}})]})]}),o.error&&_jsxs("div",{className:"tis-editor__error",children:[_jsx("strong",{children:"Error:"})," ",_jsx("pre",{children:o.error})]}),r.partial&&_jsx("div",{className:"tis-editor__notice",children:"This server cannot describe its own variables, so the pickers are listing only the variables published to this HMI, without descriptions. Update autocore_server to get the full list."}),_jsxs("div",{className:"tis-editor__body",children:[_jsxs("aside",{className:"tis-editor__sidebar",children:[_jsxs("div",{className:"tis-editor__sidebar-actions",children:[_jsx(Button,{label:"New",icon:"pi pi-plus",disabled:u,onClick:()=>g(!0)}),_jsx(Button,{label:"Duplicate",icon:"pi pi-clone",className:"p-button-secondary",disabled:u||!l,onClick:async()=>{if(!l||!o.config)return;const e=o.config.methods[l];if(!e)return;let t=`${l}_copy`,s=2;for(;o.config.methods[t];)t=`${l}_copy_${s++}`;h(!0);try{await N.copy(l,t),await o.putMethod(t,JSON.parse(JSON.stringify(e))),d(t)}catch(e){m(String(e?.message??e))}finally{h(!1)}}}),_jsx(Button,{label:"Delete",icon:"pi pi-trash",className:"p-button-danger",disabled:u||!l,onClick:()=>T(!0)})]}),_jsxs("div",{className:"tis-editor__sidebar-actions",children:[_jsx(Button,{label:"Import",icon:"pi pi-upload",className:"p-button-secondary",disabled:u,onClick:()=>C.current?.click()}),_jsx(Button,{label:"Export",icon:"pi pi-download",className:"p-button-secondary",disabled:u||!l,onClick:async()=>{if(!l||!o.config)return;const e=o.config.methods[l];if(e){h(!0);try{const t="sequence"===e.procedure?await N.read(l):null;downloadTransfer(buildTransfer(l,e,t))}catch(e){m(String(e?.message??e))}finally{h(!1)}}}})]}),S&&_jsx("div",{className:"tis-editor__error",children:_jsx("pre",{children:S})}),_jsx("input",{ref:C,type:"file",accept:".json,.method.json,application/json",style:{display:"none"},onChange:e=>{const t=e.target.files?.[0];e.target.value="",t&&(async e=>{const t=parseTransfer(await e.text());if("error"in t)return k(`${e.name}: ${t.error}`),void M(null);k(null),M(t.file),D(t.file.method_id)})(t)}}),_jsxs(DataTable,{value:I,selection:I.find(e=>e.id===l)??null,onSelectionChange:e=>d(e.value?.id??null),selectionMode:"single",dataKey:"id",scrollable:!0,scrollHeight:"flex",emptyMessage:o.loading?"Loading…":"No test methods defined.",children:[_jsx(Column,{field:"id",header:"Method ID"}),_jsx(Column,{field:"label",header:"Label"})]})]}),_jsx("section",{className:"tis-editor__detail",children:l&&o.config?.methods[l]?_jsxs(_Fragment,{children:[c&&_jsx("div",{className:"tis-editor__error",children:_jsx("pre",{children:c})}),_jsx(MethodFormEditor,{methodId:l,method:o.config.methods[l],onApply:async e=>{if(l){h(!0);try{await o.putMethod(l,e),m(null)}catch(e){m(String(e?.message??e))}finally{h(!1)}}},busy:u,knownAssetTypes:n.types})]}):_jsx("div",{className:"tis-editor__empty",children:"Select a test method on the left, or create a new one."})})]}),_jsxs(Dialog,{header:"New Test Method",visible:f,onHide:()=>g(!1),style:{width:"24rem"},children:[_jsxs("label",{className:"tis-editor__new-method-label",children:["Method ID",_jsx(InputText,{value:x,onChange:e=>y(e.target.value),placeholder:"e.g. translational_traction",autoFocus:!0})]}),_jsx("small",{children:"Canonical key — appears in wire payloads, on-disk paths, and generated code."}),""!==x.trim()&&!METHOD_ID_RE.test(x.trim())&&_jsx(Message,{severity:"warn",text:METHOD_ID_RULE,style:{width:"100%",marginTop:"0.5rem"}}),_jsxs("label",{className:"tis-editor__new-method-label",style:{marginTop:"1rem"},children:["Procedure",_jsx(SelectButton,{value:b,options:[{label:"Sequence",value:"sequence"},{label:"Control program",value:"control"}],allowEmpty:!1,onChange:e=>e.value&&j(e.value)})]}),_jsx("small",{children:"sequence"===b?"The steps are a file you edit on the Method screen. Creating this method also creates an empty sequence.":"The steps are compiled into the control program. A new method of this kind needs a rebuild and redeploy before it will run."}),_jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[_jsx(Button,{label:"Cancel",className:"p-button-text",onClick:()=>g(!1)}),_jsx(Button,{label:"Create",disabled:!METHOD_ID_RE.test(x.trim())||u,onClick:async()=>{const e=x.trim();if(e)if(METHOD_ID_RE.test(e))if(o.config?.methods[e])m(`A method named "${e}" already exists.`);else{h(!0);try{const t="sequence"===b?{...EMPTY_METHOD,procedure:"sequence"}:{...EMPTY_METHOD};"sequence"===b&&await N.write(e,emptySequence(e)),await o.putMethod(e,t),d(e),g(!1),y("")}catch(e){m(String(e?.message??e))}finally{h(!1)}}else m(`"${e}" is not a valid method id. ${METHOD_ID_RULE}`)}})]})]}),_jsx(Dialog,{header:"Import Test Method",visible:null!==w,onHide:()=>{M(null),k(null)},style:{width:"28rem"},children:w&&(()=>{const e=!!o.config?.methods[E.trim()],t=METHOD_ID_RE.test(E.trim());return _jsxs(_Fragment,{children:[_jsxs("p",{style:{marginTop:0},children:[_jsx("strong",{children:w.method_id}),w.schema.label?` — ${w.schema.label}`:"",_jsx("br",{}),_jsx("small",{children:w.sequence?"Includes a sequence procedure.":"Control-program method — no sequence in this file."})]}),_jsxs("label",{className:"tis-editor__new-method-label",children:["Import as",_jsx(InputText,{value:E,onChange:e=>D(e.target.value),autoFocus:!0})]}),!t&&""!==E.trim()&&_jsx(Message,{severity:"warn",text:METHOD_ID_RULE,style:{width:"100%"}}),e&&t&&_jsx(Message,{severity:"warn",text:`"${E.trim()}" already exists. Importing will REPLACE it, including its sequence. Change the name above to keep both.`,style:{width:"100%"}}),S&&_jsx(Message,{severity:"error",text:S,style:{width:"100%"}}),_jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[_jsx(Button,{label:"Cancel",className:"p-button-text",onClick:()=>{M(null),k(null)}}),_jsx(Button,{label:e?"Replace":"Import",className:e?"p-button-danger":void 0,disabled:!t||u,onClick:H})]})]})})()}),_jsx(DeleteMethodDialog,{visible:v,methodId:l,hasSequence:!!l&&"sequence"===o.config?.methods[l]?.procedure,onDownloadArchive:async t=>{const s=await i("tis.export_method_zip",{project_id:e,method_id:t});if(!s?.success)throw new Error(s?.error_message??"export_method_zip failed");const o="string"==typeof s.data?.download_url?s.data.download_url:"";if(!o)throw new Error("the server returned no download URL");const a=document.createElement("a");return a.href=o,a.download="string"==typeof s.data?.filename&&s.data.filename?s.data.filename:`${t}_method_archive.zip`,a.click(),!0},onConfirm:async()=>{if(l){h(!0);try{await o.removeMethod(l),await N.remove(l),d(null),T(!1)}catch(e){m(String(e?.message??e))}finally{h(!1)}}},onCancel:()=>T(!1),busy:u}),_jsx(SaveDiffDialog,{visible:p,staged:o.config?.methods??{},invoker:i,onConfirm:async()=>{h(!0);try{await o.save(),_(!1)}catch(e){m(String(e?.message??e))}finally{h(!1)}},onCancel:()=>_(!1)})]})})};export default TisConfigEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentitySection.d.ts","sourceRoot":"","sources":["../../../../src/components/tis-editor/editor/IdentitySection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IdentitySection.d.ts","sourceRoot":"","sources":["../../../../src/components/tis-editor/editor/IdentitySection.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAuD1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{InputText}from"primereact/inputtext";import{InputTextarea}from"primereact/inputtextarea";import{FormSection}from"../../forms/FormSection";import{FormRow}from"../../forms/FormRow";export const IdentitySection=({method:e,onChange:t})=>_jsxs(FormSection,{title:"Identity",description:"Display label
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{InputText}from"primereact/inputtext";import{InputTextarea}from"primereact/inputtextarea";import{SelectButton}from"primereact/selectbutton";import{FormSection}from"../../forms/FormSection";import{FormRow}from"../../forms/FormRow";export const IdentitySection=({method:e,onChange:t})=>_jsxs(FormSection,{title:"Identity",description:"Display label, operator-facing description, and which engine runs the steps.",children:[_jsx(FormRow,{label:"Label",hint:"Pretty name shown in the Test Method picker.",children:_jsx(InputText,{value:e.label??"",onChange:o=>t({...e,label:o.target.value})})}),_jsx(FormRow,{label:"Description",hint:"Long-form guidance shown beneath the picker when this method is selected.",children:_jsx(InputTextarea,{rows:3,value:e.description??"",onChange:o=>t({...e,description:o.target.value})})}),_jsx(FormRow,{label:"Procedure",hint:"Sequence: the steps are a file you edit on the Method screen. Control program: compiled Rust, requires a rebuild to add or change a method.",children:_jsx(SelectButton,{value:e.procedure??"control",options:[{label:"Control program",value:"control"},{label:"Sequence",value:"sequence"}],allowEmpty:!1,onChange:o=>{const r={...e};"sequence"===o.value?r.procedure="sequence":delete r.procedure,t(r)}})})]});
|
|
@@ -166,6 +166,17 @@ export interface TestMethod {
|
|
|
166
166
|
asset_refs?: AssetRef[];
|
|
167
167
|
analysis?: AnalysisShape | null;
|
|
168
168
|
configurations?: TestConfiguration[];
|
|
169
|
+
/**
|
|
170
|
+
* Which engine runs this method's steps.
|
|
171
|
+
*
|
|
172
|
+
* `"sequence"` means the procedure is data at
|
|
173
|
+
* `methods/<method_id>.seq.json`, authored in the sequence workbench and
|
|
174
|
+
* executed by autocore-seq — so a method can be created on the machine and
|
|
175
|
+
* run without regenerating and rebuilding the control program.
|
|
176
|
+
* `"control"` (the default) means compiled Rust, which is every method that
|
|
177
|
+
* predates this field.
|
|
178
|
+
*/
|
|
179
|
+
procedure?: 'control' | 'sequence';
|
|
169
180
|
[key: string]: unknown;
|
|
170
181
|
}
|
|
171
182
|
export type FieldArrayKey = 'project_fields' | 'config_fields' | 'cycle_config_fields' | 'cycle_fields' | 'results_fields';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/tis-editor/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,SAAS,GACf,QAAQ,GACR,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAC7B,KAAK,GAAG,KAAK,GACb,MAAM,CAAC;AAE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,CAAC,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"VariablePicker.d.ts","sourceRoot":"","sources":["../../../src/components/varpick/VariablePicker.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAGH,KAAK,OAAO,EACZ,KAAK,aAAa,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,eAAe,CAAC;AAEvB,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAoHxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import*as React from"react";import{Dialog}from"primereact/dialog";import{Button}from"primereact/button";import{InputText}from"primereact/inputtext";import{firstChoosable,searchCatalog}from"@adcops/autocore-varpick";import"./varpick.css";export const VariablePicker=({visible:a,catalog:e,title:i,hint:s,initialQuery:c,onCancel:t,onPick:r})=>{const[l,n]=React.useState(c??""),[o,p]=React.useState(null);React.useEffect(()=>{a&&n(c??"")},[a,c]);const d=React.useMemo(()=>searchCatalog(e,l),[e,l]);React.useEffect(()=>{p(firstChoosable(d)?.id??null)},[d]);const _=a=>null===a?void 0:d.flatMap(a=>a.entries).find(e=>e.id===a),m=a=>{const e=a??_(o);e&&!e.disabled&&r(e)},h=_jsxs("div",{className:"ac-varpick__foot",children:[_jsx(Button,{label:"Cancel",className:"p-button-text",onClick:t}),_jsx(Button,{label:"Insert",disabled:void 0===_(o),onClick:()=>m()})]});return _jsxs(Dialog,{header:i??"Insert a variable",visible:a,onHide:t,footer:h,style:{width:"44rem",maxWidth:"95vw"},children:[s&&_jsx("div",{className:"ac-varpick__hint",children:s}),_jsx(InputText,{className:"ac-varpick__search",value:l,autoFocus:!0,placeholder:"name, or what it means — try “load” or “EL3356”",onChange:a=>n(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),m())}}),0===d.length?_jsx("div",{className:"ac-varpick__empty",children:0===e.length?"Nothing to pick from. The machine published no variables — the server may be an older build without gm.get_variables.":`No variable matches “${l}”.`}):_jsx("div",{className:"ac-varpick__list",children:d.map(a=>_jsxs("div",{className:"ac-varpick__group",children:[_jsxs("div",{className:"ac-varpick__grouphead",children:[_jsx("span",{className:"ac-varpick__grouptitle",children:a.title}),a.hint&&_jsx("span",{className:"ac-varpick__grouphint",children:a.hint})]}),a.entries.map(a=>_jsxs("button",{type:"button",className:"ac-varpick__row"+(a.id===o?" ac-varpick__row--on":"")+(a.disabled?" ac-varpick__row--off":""),"aria-pressed":a.id===o,disabled:!!a.disabled,onClick:()=>p(a.id),onDoubleClick:()=>m(a),children:[_jsxs("span",{className:"ac-varpick__line",children:[_jsx("code",{className:"ac-varpick__name",children:a.name}),a.label&&_jsx("span",{className:"ac-varpick__label",children:a.label}),a.unit&&_jsx("span",{className:"ac-varpick__chip",children:a.unit}),a.type&&_jsx("span",{className:"ac-varpick__chip",children:a.type}),void 0!==a.live&&_jsxs("span",{className:"ac-varpick__live",children:["now ",a.live]})]}),a.description&&_jsx("span",{className:"ac-varpick__desc",children:a.description}),a.disabled&&_jsx("span",{className:"ac-varpick__why",children:a.disabled}),a.note&&_jsx("span",{className:"ac-varpick__note",children:a.note})]},a.id))]},a.id))})]})};export default VariablePicker;
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import*as React from"react";import{Dialog}from"primereact/dialog";import{Button}from"primereact/button";import{InputText}from"primereact/inputtext";import{firstChoosable,searchCatalog}from"@adcops/autocore-varpick";import"./varpick.css";export const VariablePicker=({visible:a,catalog:e,title:i,hint:s,initialQuery:c,onCancel:t,onPick:r})=>{const[l,n]=React.useState(c??""),[o,p]=React.useState(null);React.useEffect(()=>{a&&n(c??"")},[a,c]);const d=React.useMemo(()=>searchCatalog(e,l),[e,l]);React.useEffect(()=>{p(firstChoosable(d)?.id??null)},[d]);const _=a=>null===a?void 0:d.flatMap(a=>a.entries).find(e=>e.id===a),m=a=>{const e=a??_(o);e&&!e.disabled&&r(e)},h=_jsxs("div",{className:"ac-varpick__foot",children:[_jsx(Button,{label:"Cancel",className:"p-button-text",onClick:t}),_jsx(Button,{label:"Insert",disabled:void 0===_(o),onClick:()=>m()})]});return _jsxs(Dialog,{header:i??"Insert a variable",visible:a,onHide:t,footer:h,className:"ac-varpick",style:{width:"44rem",maxWidth:"95vw"},children:[s&&_jsx("div",{className:"ac-varpick__hint",children:s}),_jsx(InputText,{className:"ac-varpick__search",value:l,autoFocus:!0,placeholder:"name, or what it means — try “load” or “EL3356”",onChange:a=>n(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),m())}}),0===d.length?_jsx("div",{className:"ac-varpick__empty",children:0===e.length?"Nothing to pick from. The machine published no variables — the server may be an older build without gm.get_variables.":`No variable matches “${l}”.`}):_jsx("div",{className:"ac-varpick__list",children:d.map(a=>_jsxs("div",{className:"ac-varpick__group",children:[_jsxs("div",{className:"ac-varpick__grouphead",children:[_jsx("span",{className:"ac-varpick__grouptitle",children:a.title}),a.hint&&_jsx("span",{className:"ac-varpick__grouphint",children:a.hint})]}),a.entries.map(a=>_jsxs("button",{type:"button",className:"ac-varpick__row"+(a.id===o?" ac-varpick__row--on":"")+(a.disabled?" ac-varpick__row--off":""),"aria-pressed":a.id===o,disabled:!!a.disabled,onClick:()=>p(a.id),onDoubleClick:()=>m(a),children:[_jsxs("span",{className:"ac-varpick__line",children:[_jsx("code",{className:"ac-varpick__name",children:a.name}),a.label&&_jsx("span",{className:"ac-varpick__label",children:a.label}),a.unit&&_jsx("span",{className:"ac-varpick__chip",children:a.unit}),a.type&&_jsx("span",{className:"ac-varpick__chip",children:a.type}),void 0!==a.live&&_jsxs("span",{className:"ac-varpick__live",children:["now ",a.live]})]}),a.description&&_jsx("span",{className:"ac-varpick__desc",children:a.description}),a.disabled&&_jsx("span",{className:"ac-varpick__why",children:a.disabled}),a.note&&_jsx("span",{className:"ac-varpick__note",children:a.note})]},a.id))]},a.id))})]})};export default VariablePicker;
|