Wizzas commited on
Commit
ac4dd3e
·
verified ·
1 Parent(s): 7bf899e

Update verified React dashboard

Browse files
.gitattributes CHANGED
@@ -81,3 +81,6 @@ samples/pcb1_anomalous.jpg filter=lfs diff=lfs merge=lfs -text
81
  samples/pcb1_good.jpg filter=lfs diff=lfs merge=lfs -text
82
  samples/pcb2_anomalous.jpg filter=lfs diff=lfs merge=lfs -text
83
  samples/pcb2_good.jpg filter=lfs diff=lfs merge=lfs -text
 
 
 
 
81
  samples/pcb1_good.jpg filter=lfs diff=lfs merge=lfs -text
82
  samples/pcb2_anomalous.jpg filter=lfs diff=lfs merge=lfs -text
83
  samples/pcb2_good.jpg filter=lfs diff=lfs merge=lfs -text
84
+ frontend/dist/assets/candle-heatmap-VjHcBjw5.jpg filter=lfs diff=lfs merge=lfs -text
85
+ frontend/dist/assets/candle-normal-Cqb2kkRH.jpg filter=lfs diff=lfs merge=lfs -text
86
+ frontend/dist/assets/candle-original-Dqn_yXKt.jpg filter=lfs diff=lfs merge=lfs -text
frontend/dist/assets/TeamWorkspace-Bt2QyqBy.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as te,r,l as Ue,a as ze,b as Me,s as Pe,f as xe,d as T,R as e,e as Ne,n as Ce,g as Oe,h as Fe,w as ye,i as qe,j as Ie,k as je,m as We,o as He,p as Be,v as Ge,q as Ke,t as Qe,u as $e,x as Le,L as Ye,S as Ze,A as Je,y as Ae,z as Xe,B as Ve,C as Te,D as et}from"./index-D1CUAkEx.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const tt=te("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Re=te("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const at=te("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const rt=te("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const nt=te("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const st=te("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const lt=te("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const ct=te("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function it({user:f,inspection:p,notes:G=[],onEvidence:i}){const S=r.useRef(0),E=r.useRef(null),ae=r.useRef(null),[w,F]=r.useState("checking"),[g,P]=r.useState([]),[U,z]=r.useState([]),[de,M]=r.useState(""),[K,q]=r.useState([]),[ue,o]=r.useState([]),[Z,u]=r.useState(""),[I,N]=r.useState(!1),[k,j]=r.useState(""),[re,W]=r.useState(""),[me,Q]=r.useState(""),[ne,y]=r.useState("Normal"),[x,pe]=r.useState(""),[O,n]=r.useState(!1),[h,m]=r.useState(""),[C,b]=r.useState(""),[R,J]=r.useState(0),[$,fe]=r.useState(""),[ge,ke]=r.useState(""),[he,be]=r.useState(""),s=g.find(t=>t.id===de),se=Ue(G),Y=ze(g),we=Me(s,f.id,U.some(t=>t.user_id===f.id&&t.role==="developer"));async function Ee(){const t=++S.current,d=await T(),v=await d.rpc("defectrag_ca_staff");if(t!==S.current)return;if(v.error||v.data!==!0)throw F("denied"),P([]),z([]),M(""),q([]),o([]),new Error("Sign in with an approved Staff account and verify the security code before opening corrective actions.");const L=await Promise.all([d.from("corrective_actions").select("*").order("created_at",{ascending:!1}).limit(500),d.from("staff_members").select("user_id,display_name,role,revoked_at").is("revoked_at",null)]);if(t===S.current){if(L.some(le=>le.error))throw F("unavailable"),P([]),z([]),M(""),q([]),o([]),L.find(le=>le.error).error;F("authorized"),P(L[0].data||[]),z(L[1].data||[]),u(""),J(le=>le+1)}}r.useEffect(()=>{const t=Pe(Ee,{onState:d=>{d.error&&(F("unavailable"),u(d.error),P([]),z([]),M(""),q([]),o([]))}});return()=>{t.stop(),S.current++}},[f.id]),r.useEffect(()=>{const t=()=>{S.current++,F("checking"),P([]),z([]),M(""),q([]),o([]),Ee().catch(d=>u(d.message))};return window.addEventListener("defectrag-auth-change",t),()=>window.removeEventListener("defectrag-auth-change",t)},[f.id]),r.useEffect(()=>{n(!1),j("")},[p==null?void 0:p.id,se==null?void 0:se.id]),r.useEffect(()=>{w==="authorized"&&xe(ae.current)},[w,p==null?void 0:p.id]),r.useEffect(()=>{b(""),m((s==null?void 0:s.state)||""),fe((s==null?void 0:s.owner_id)||""),ke((s==null?void 0:s.supervisor_id)||""),be("")},[s==null?void 0:s.id,s==null?void 0:s.version]),r.useEffect(()=>{s&&xe(E.current)},[s==null?void 0:s.id]),r.useEffect(()=>{let t=!0;const d=S.current;if(q([]),o([]),!(!s||w!=="authorized"))return T().then(v=>Promise.all([v.from("corrective_action_history").select("*").eq("case_id",s.id).order("version"),v.from("corrective_action_events").select("id,case_id,version,kind,status,attempts,last_error,created_at").eq("case_id",s.id).order("created_at",{ascending:!1})])).then(v=>{if(!(!t||d!==S.current)){if(v.some(L=>L.error))throw v.find(L=>L.error).error;q(v[0].data||[]),o(v[1].data||[])}}).catch(v=>{t&&d===S.current&&u(v.message)}),()=>{t=!1}},[s==null?void 0:s.id,s==null?void 0:s.version,R,f.id,w]);async function B(t){if(!I){N(!0),u("");try{await t(),await Ee(),ye()}catch(d){u(d.message||"Corrective action request failed.")}finally{N(!1)}}}const H=t=>{var d;return((d=U.find(v=>v.user_id===t))==null?void 0:d.display_name)||"Former / unavailable staff"};return e.createElement("section",{className:"card",ref:ae,tabIndex:-1,"aria-label":"Corrective Actions workspace"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Corrective Actions"),e.createElement("p",null,"Track work needed after a Staff review confirms a defect. Assign someone to fix it, set a due date, and keep a record of progress.")),e.createElement("button",{className:"secondary",disabled:I,onClick:()=>B(Ee)},"Refresh cases")),Z&&e.createElement("div",{className:"error",role:"alert"},Ne(Z)),w==="checking"&&e.createElement("p",{role:"status"},"Checking Staff access and the security code…"),w!=="checking"&&w!=="authorized"&&e.createElement("p",{className:"note"},"Open Staff workspace to check account approval and enter the security code. Then return here and try again."),w==="authorized"&&e.createElement(e.Fragment,null,e.createElement("p",{className:"caption"},"Showing up to 500 cases available to this account. Open: ",Y.open," · Resolved / closed: ",Y.resolved," · Overdue: ",Y.overdue," · Average resolution: ",Y.averageResolutionHours===null?"No resolved cases":Y.averageResolutionHours.toFixed(1)+" hours",". Email delivery is separate from whether the case has been saved."),p&&!p.archived_at&&e.createElement(e.Fragment,null,e.createElement("h3",null,"Create from inspection ",p.id.slice(0,8)),se?e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),B(async()=>{const d=await T(),v=await qe(d,"defectrag_create_corrective_action",{p_inspection:p.id,p_review:se.id,p_confirmed:O,p_owner:re,p_supervisor:me,p_priority:ne,p_description:k,p_due:new Date(x).toISOString()});M(v),j(""),n(!1)})}},e.createElement("label",{className:"field"},"What needs fixing?",e.createElement("textarea",{required:!0,minLength:10,maxLength:2e3,value:k,onChange:t=>j(t.target.value)})),e.createElement("label",{className:"field"},"Person responsible",e.createElement("select",{required:!0,value:re,onChange:t=>W(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),U.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Supervisor",e.createElement("select",{required:!0,value:me,onChange:t=>Q(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),U.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Priority",e.createElement("select",{value:ne,onChange:t=>y(t.target.value)},["Low","Normal","High","Critical"].map(t=>e.createElement("option",{key:t},t)))),e.createElement("label",{className:"field"},"Due date and time",e.createElement("input",{type:"datetime-local",required:!0,value:x,onChange:t=>pe(t.target.value)})),e.createElement("label",null,e.createElement("input",{type:"checkbox",checked:O,onChange:t=>n(t.target.checked)})," A Staff review has confirmed a defect that needs fixing. An unusual inspection result alone is not enough."),e.createElement("button",{className:"primary",disabled:I||!O},"Create corrective action")):e.createElement("p",{className:"note"},"First open the shared inspection, set the review to Reviewed and Reject, and save it. Then confirm that the defect needs fixing before creating a case.")),!p&&e.createElement("p",{className:"caption"},"To create a case, choose a Team inspection and save its Staff review first. Use Choose a Team inspection above."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Case"),e.createElement("th",null,"Status"),e.createElement("th",null,"Owner"),e.createElement("th",null,"Priority"),e.createElement("th",null,"Due"),e.createElement("th",null))),e.createElement("tbody",null,g.map(t=>e.createElement("tr",{key:t.id},e.createElement("td",null,t.id.slice(0,8)),e.createElement("td",null,t.state,!["Resolved","Closed","Cancelled"].includes(t.state)&&Date.parse(t.due_at)<Date.now()?" · Overdue":""),e.createElement("td",null,H(t.owner_id)),e.createElement("td",null,t.priority),e.createElement("td",null,new Date(t.due_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>M(t.id)},"Details")))))),!g.length&&e.createElement("p",{className:"caption"},"No cases are available to this account yet.")),s&&e.createElement("div",{className:"cloud-message",ref:E,tabIndex:-1,"aria-label":"Corrective action case details"},e.createElement("div",{className:"section-title"},e.createElement("h3",null,"Case ",s.id.slice(0,8)," · ",s.state),e.createElement("button",{className:"text-button",onClick:()=>M("")},"Close details")),e.createElement("p",null,s.description),e.createElement("p",null,"Supervisor: ",H(s.supervisor_id)," · Confirmed by: ",H(s.confirmed_by)),e.createElement("button",{className:"secondary",onClick:()=>i(s.inspection_id)},"Open the linked photo and review"),Ce(s.state).length>0&&!we&&e.createElement("p",{className:"note"},"Only the person responsible, the supervisor or a Developer can change this case after verifying their security code. Other Staff can read it."),Ce(s.state).length>0&&we&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),B(async()=>{const d=await T();await qe(d,"defectrag_update_corrective_action",{p_id:s.id,p_version:s.version,p_state:h,p_note:C,p_owner:$,p_supervisor:ge,p_due:he?new Date(he).toISOString():null}),b("")})}},e.createElement("label",{className:"field"},"Case status",e.createElement("select",{value:h,onChange:t=>m(t.target.value)},Ce(s.state).map(t=>e.createElement("option",{key:t},t)))),e.createElement("label",{className:"field"},"Owner",e.createElement("select",{required:!0,value:$,onChange:t=>fe(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),U.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Supervisor",e.createElement("select",{required:!0,value:ge,onChange:t=>ke(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),U.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Change due date and time (optional)",e.createElement("input",{type:"datetime-local",value:he,onChange:t=>be(t.target.value)})),e.createElement("label",{className:"field"},"What changed or was fixed?",e.createElement("textarea",{required:!0,minLength:3,maxLength:2e3,value:C,onChange:t=>b(t.target.value)})),e.createElement("button",{className:"primary",disabled:I||!h},"Save case update")),e.createElement("h3",null,"Status history"),K.map(t=>e.createElement("p",{key:t.id},e.createElement("strong",null,t.state)," · ",H(t.actor_id)," · ",new Date(t.created_at).toLocaleString(),e.createElement("br",null),t.note,t.snapshot&&e.createElement("small",null,e.createElement("br",null),"Owner: ",H(t.snapshot.owner_id)," · Supervisor: ",H(t.snapshot.supervisor_id)," · Due: ",new Date(t.snapshot.due_at).toLocaleString()))),e.createElement("h3",null,"Email delivery"),e.createElement("p",{className:"caption"},"Waiting emails have not been sent. If delivery fails or is uncertain, contact the workspace administrator. The case stays saved even when the email service is unavailable."),ue.map(t=>e.createElement("p",{key:t.id},Oe(t.kind)," · ",Fe(t.status)," · attempts ",t.attempts,t.last_error?" · "+Ne(t.last_error):"")))))}function ot({client:f,user:p,onChange:G}){var O;const[i,S]=r.useState(null),[E,ae]=r.useState([]),[w,F]=r.useState([]),[g,P]=r.useState(null),[U,z]=r.useState(""),[de,M]=r.useState(""),[K,q]=r.useState(""),[ue,o]=r.useState(""),[Z,u]=r.useState(""),[I,N]=r.useState(""),[k,j]=r.useState(!1),[re,W]=r.useState([]),[me,Q]=r.useState([]),ne=((O=window.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:O.registrationEnabled)===!0;async function y(){if(!p){S(null),W([]),Q([]);return}const n=await Ie(f);S(n);const{data:h,error:m}=await f.auth.mfa.listFactors();if(m)throw m;const C=(h.totp||[]).filter(b=>b.status==="verified");if(ae(C),F((h.all||[]).filter(b=>b.factor_type==="totp"&&b.status==="unverified")),M(b=>{var R;return C.some(J=>J.id===b)?b:((R=C[0])==null?void 0:R.id)||""}),n.role==="developer"&&n.approved&&n.aal2){const[b,R]=await Promise.all([f.rpc("defectrag_access_directory"),f.rpc("defectrag_notification_status")]);if(b.error)throw b.error;if(R.error)throw R.error;W(b.data||[]),Q(R.data||[])}else W([]),Q([])}async function x(n){j(!0),N("");try{await n()}catch(h){N(h.message||"Security request failed.")}finally{j(!1)}}r.useEffect(()=>{let n=!0;return P(null),z(""),W([]),Q([]),f&&p?y().catch(h=>{n&&N(h.message)}):S(null),()=>{n=!1}},[f,p==null?void 0:p.id]);async function pe(){await Ge(f,(g==null?void 0:g.id)||de,U),z(""),P(null),await y(),G(),N("Security code verified. Staff access is available only after the account is approved.")}return e.createElement("div",{className:"section-gap"},e.createElement("h3",null,"Sign-in and account security"),I&&e.createElement("p",{className:"note",role:"status"},Ne(I)),p?e.createElement(e.Fragment,null,e.createElement("p",null,"Access: ",e.createElement("strong",null,i!=null&&i.revoked?"revoked":i!=null&&i.approved?"approved":(i==null?void 0:i.request_status)||"not requested")," · Authenticator: ",e.createElement("strong",null,i!=null&&i.aal2?"security code verified":"enter security code")),e.createElement("button",{className:"secondary",disabled:k,onClick:()=>x(y)},"Refresh account status"),i&&!i.approved&&!i.revoked&&!i.request_status&&e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),x(async()=>{await We(f,K),await y(),N("Request sent. Check back here for Developer approval. Team and private Staff work are not available while the request is waiting."),G()})}},e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:K,maxLength:80,onChange:n=>q(n.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:k||!i.registration_enabled||!i.email_verified},"Request staff access")),e.createElement("p",{className:"caption"},"Use an authenticator app for the extra six-digit sign-in code. Keep access to that app. If it is lost, contact the workspace administrator; resetting the password does not remove this security check."),!g&&!E.length&&!w.length&&e.createElement("button",{className:"secondary",disabled:k,onClick:()=>x(async()=>P(await He(f)))},"Set up a security code app"),!g&&w.map(n=>e.createElement("p",{key:n.id,className:"caption"},"Authenticator setup was not finished. ",e.createElement("button",{className:"text-button",disabled:k,onClick:()=>x(async()=>{const{error:h}=await f.auth.mfa.unenroll({factorId:n.id});if(h)throw h;await y()})},"Cancel incomplete setup"))),g&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("p",null,"Open an authenticator app, scan this private QR code, then enter the six-digit code below to finish. Do not share the QR code or security codes."),e.createElement("img",{src:g.totp.qr_code,width:"200",height:"200",alt:"Private authenticator enrollment QR code"}),e.createElement("button",{className:"text-button",disabled:k,onClick:()=>x(async()=>{const{error:n}=await f.auth.mfa.unenroll({factorId:g.id});if(n)throw n;P(null),z("")})},"Cancel incomplete setup"))),(g||E.length>0)&&e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),x(pe)}},!g&&e.createElement("label",{className:"field"},"Security code app",e.createElement("select",{value:de,onChange:n=>M(n.target.value)},E.map(n=>e.createElement("option",{key:n.id,value:n.id},n.friendly_name||"Authenticator")))),e.createElement("label",{className:"field"},"Six-digit security code",e.createElement("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:U,onChange:n=>z(n.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:k},"Verify security code")),(i==null?void 0:i.role)==="developer"&&i.approved&&i.aal2&&e.createElement(e.Fragment,null,e.createElement("h3",{className:"section-gap"},"Staff access management"),e.createElement("p",null,"Approve or reject requests that are still waiting. Removing access stops new Staff actions but keeps inspection history."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Account"),e.createElement("th",null,"Status"),e.createElement("th",null,"Role"),e.createElement("th",null,"Action"))),e.createElement("tbody",null,re.map(n=>e.createElement("tr",{key:n.user_id},e.createElement("td",null,n.display_name,e.createElement("br",null),e.createElement("small",null,n.email)),e.createElement("td",null,n.status),e.createElement("td",null,n.role||"applicant"),e.createElement("td",null,n.user_id!==p.id&&(n.status==="pending"?["approve","reject"]:n.status==="approved"?["revoke"]:[]).map(h=>e.createElement("button",{key:h,className:"text-button",disabled:k,onClick:()=>{window.confirm(`${h[0].toUpperCase()+h.slice(1)} access for ${n.display_name}?`)&&x(async()=>{await Be(f,n,h),await y(),G(),N("Account access updated. Check Email delivery below separately; saving this change does not confirm an email was sent.")})}},{approve:"Approve",reject:"Reject",revoke:"Remove access"}[h])))))))),e.createElement("h3",{className:"section-gap"},"Email delivery"),e.createElement("p",{className:"caption"},"Waiting emails have not been sent. Delivery depends on administrator settings and the email service being available. Sent means the email service accepted the message; it may still reach Spam or fail to arrive."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Event"),e.createElement("th",null,"Delivery"),e.createElement("th",null,"Attempts"),e.createElement("th",null))),e.createElement("tbody",null,me.map(n=>e.createElement("tr",{key:n.id},e.createElement("td",null,Oe(n.kind)),e.createElement("td",null,Fe(n.status)),e.createElement("td",null,n.attempts),e.createElement("td",null,n.status==="dead"&&e.createElement("button",{className:"text-button",disabled:k,onClick:()=>x(async()=>{const{error:h}=await f.rpc("defectrag_retry_notification",{p_id:n.id});if(h)throw h;await y()})},"Retry delivery"))))))))):ne?e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),x(async()=>{await je(f,{email:ue,password:Z,displayName:K,redirectTo:location.origin+location.pathname}),u(""),N("Check the inbox and Spam folder for a confirmation email. Open its link, sign in, then choose Request staff access. A Developer must approve the request before Staff work is available.")})}},e.createElement("p",null,"New to Staff work? Create an account, confirm the email, then request access. The public demo can be used without an account."),e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:K,onChange:n=>q(n.target.value),maxLength:80,autoComplete:"name",required:!0})),e.createElement("label",{className:"field"},"Email",e.createElement("input",{type:"email",value:ue,onChange:n=>o(n.target.value),autoComplete:"email",required:!0})),e.createElement("label",{className:"field"},"New password",e.createElement("input",{type:"password",minLength:12,value:Z,onChange:n=>u(n.target.value),autoComplete:"new-password",required:!0})),e.createElement("button",{className:"secondary",disabled:k||!f},"Register account")):e.createElement("p",{className:"caption"},"New account registration is currently closed. Existing Staff can sign in below. The public demo is still available."))}function ut({onOpenInspection:f,onOpenCorrectiveActions:p,onChooseInspection:G,casesView:i=!1,initialInspectionId:S=null}){var De;const E=r.useRef(0),ae=r.useRef(null),w=r.useRef(0),F=r.useRef(null),g=r.useRef(0),P=r.useRef(null),U=r.useRef(null),[z,de]=r.useState(0),[M,K]=r.useState(!1),[q,ue]=r.useState({state:"refreshing"}),[o,Z]=r.useState(null),[u,I]=r.useState(null),[N,k]=r.useState([]),[j,re]=r.useState({}),[W,me]=r.useState(""),[Q,ne]=r.useState(""),[y,x]=r.useState(!1),[pe,O]=r.useState(""),[n,h]=r.useState(!1),[m,C]=r.useState(null),[b,R]=r.useState([]),[J,$]=r.useState([]),[fe,ge]=r.useState(""),[ke,he]=r.useState(!1),[be,s]=r.useState(""),[se,Y]=r.useState(!1),[we,Ee]=r.useState(null),B=Ke(),H=Qe(window.DEFECTRAG_PUBLIC_CONFIG);r.useEffect(()=>()=>{b.filter(a=>a.startsWith("blob:")).forEach(a=>URL.revokeObjectURL(a))},[b]),r.useEffect(()=>{F.current=m},[m]),r.useEffect(()=>{m&&xe(P.current)},[z]),r.useEffect(()=>{if(!o||!u||!S)return;const a=o.id+":"+S;U.current!==a&&(U.current=a,L({id:S},{focus:!i}))},[o==null?void 0:o.id,u==null?void 0:u.user_id,S]);const t=$e();async function d(a){x(!0),O("");try{await a()}catch(l){O(l.message||"Team request failed.")}finally{x(!1)}}async function v(){var A;const a=++w.current,l=E.current,c=(A=F.current)==null?void 0:A.id,{client:D,staff:Se}=await et();let _=D.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);_=n?_.not("archived_at","is",null):_.is("archived_at",null);const[{data:X,error:ce},{data:_e,error:V},ve]=await Promise.all([_,D.from("staff_members").select("*"),c?D.from("staff_notes").select("*").eq("inspection_id",c).order("created_at"):{data:[]}]);if(ce)throw ce;if(V)throw V;if(ve.error)throw ve.error;if(a===w.current&&(I(Se),O(""),k(X||[]),re(Object.fromEntries((_e||[]).map(ee=>[ee.user_id,ee.display_name]))),c&&l===E.current)){const ee=(X||[]).find(ie=>ie.id===c);if(!ee)E.current++,C(null),R([]),$([]);else if(C(ee),$(ve.data||[]),Date.now()-g.current>480*1e3)if(B){const ie=await Le(D,ee);a===w.current&&l===E.current?(R(ie),g.current=Date.now()):ie.forEach(oe=>URL.revokeObjectURL(oe))}else{const ie=await Promise.all([ee.image_path,ee.heatmap_path].map(oe=>D.storage.from("team-inspections").createSignedUrl(oe,900)));if(a===w.current&&l===E.current){if(ie.some(oe=>oe.error))throw new Error("Shared image links could not refresh.");R(ie.map(oe=>oe.data.signedUrl)),g.current=Date.now()}}}}r.useEffect(()=>{if(!t)return;let a=!1,l;return T().then(async c=>{!a&&B&&Ee(c),l=c.auth.onAuthStateChange((Se,_)=>{var X;if(!a){const ce=((X=_==null?void 0:_.user)==null?void 0:X.id)||null;ae.current!==ce&&(E.current++,w.current++,C(null),k([]),R([]),$([]),I(null),ae.current=ce),Z((_==null?void 0:_.user)||null),Se==="PASSWORD_RECOVERY"&&he(!0)}}).data.subscription;const{data:D}=await c.auth.getUser();a||Z(D.user)}).catch(c=>{a||O(c.message)}),()=>{a=!0,E.current++,l==null||l.unsubscribe()}},[t]),r.useEffect(()=>{if(!o)return;const a=Pe(v,{onState:l=>{ue(l),l.error&&(O(l.error),B&&(E.current++,k([]),re({}),C(null),R([]),$([]),I(null)))}});return()=>{a.stop(),w.current++}},[o==null?void 0:o.id,n]);async function L(a,{focus:l=!0}={}){const c=++E.current;K(!0);try{await d(async()=>{if(c!==E.current)return;const D=await T(),Se=D.storage.from("team-inspections"),[{data:_,error:X},{data:ce,error:_e}]=await Promise.all([D.from("shared_inspections").select("*").eq("id",a.id).single(),D.from("staff_notes").select("*").eq("inspection_id",a.id).order("created_at")]);if(c!==E.current)return;if(X)throw X;if(_e)throw _e;const V=B?await Le(D,_):null,ve=V?V.map(A=>({data:{signedUrl:A}})):await Promise.all([_.image_path,_.heatmap_path].map(A=>Se.createSignedUrl(A,900)));if(ve.some(A=>A.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");if(c!==E.current){V==null||V.forEach(A=>URL.revokeObjectURL(A));return}F.current=_,g.current=Date.now(),C(_),R(ve.map(A=>A.data.signedUrl)),$(ce||[]),l&&de(A=>A+1)})}finally{c===E.current&&K(!1)}}async function le(){await d(async()=>{const a=await T(),l=N.filter(c=>c.owner_id===o.id).map(c=>c.id);if(l.length){const{error:c}=await a.rpc("archive_team_inspections",{p_ids:l});if(c)throw c}E.current++,C(null),Y(!1),await v(),ye()})}return t?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement(ct,{size:21})," ",i?"Corrective Actions access":"Staff workspace"),e.createElement("p",null,"Sign in to review inspections shared with the team. New inspections start in Personal Workspace and are shared only when chosen.")),e.createElement("span",{className:"subtle-tag"},e.createElement(Re,{size:13})," STAFF ACCESS")),pe&&e.createElement("div",{className:"error",role:"alert"},Ne(pe)),M&&e.createElement("p",{role:"status"},"Opening the shared photo and review…"),i&&!H&&e.createElement("p",{className:"note"},"Corrective Actions has been turned off for this app. Inspections and reviews are still available. Contact the workspace administrator if needed."),B&&we&&(!i||!u)&&e.createElement(ot,{key:(o==null?void 0:o.id)||"anonymous",client:we,user:o,onChange:()=>{ye(),o&&d(v)}}),o?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(Ze,{size:18}),e.createElement("strong",null,(u==null?void 0:u.display_name)||o.email),e.createElement("span",{className:"subtle-tag"},(u==null?void 0:u.role)||"CHECKING ACCESS")),e.createElement("button",{className:"secondary",disabled:y,onClick:()=>d(v)},e.createElement(st,{size:16})," Refresh"),!i&&u&&H&&e.createElement("button",{className:"secondary",onClick:()=>p==null?void 0:p()},"Open Corrective Actions"),i&&u&&e.createElement("button",{className:"secondary",onClick:()=>G==null?void 0:G()},"Choose a Team inspection"),e.createElement("button",{className:"secondary",onClick:()=>d(async()=>{await(await T()).auth.signOut(),k([]),C(null),I(null)})},e.createElement(nt,{size:16})," Sign out")),ke&&e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),d(async()=>{const l=await T(),{error:c}=await l.auth.updateUser({password:be});if(c)throw c;s(""),he(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:be,onChange:a=>s(a.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:y},"Save password")),!i&&e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("span",{role:"status"},"Team Workspace · latest ",N.length," shared inspections · ",q.state==="synced"?"updated at "+new Date(q.at).toLocaleTimeString():q.state==="offline"?"offline; shown results may be out of date":q.state==="stale"?"update failed; shown results may be out of date":"refreshing…"," · checks for changes every 15 seconds"),(u==null?void 0:u.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{h(!n),C(null)}},e.createElement(tt,{size:16}),n?"Active history":"Restore archived team work"),!n&&e.createElement("button",{className:"secondary danger",disabled:y||!N.some(a=>a.owner_id===o.id),onClick:()=>Y(!0)},e.createElement(Je,{size:16})," Archive my shared inspections")),se&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:y,onClick:le},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>Y(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,N.map(a=>{var l;return e.createElement("tr",{key:a.id},e.createElement("td",null,e.createElement("strong",null,a.id.slice(0,8))),e.createElement("td",null,a.payload.category),e.createElement("td",null,e.createElement("span",{className:"badge "+((l=a.payload.verdict)==null?void 0:l.toLowerCase())},Ae(a.payload.verdict))),e.createElement("td",null,j[a.owner_id]||"Staff member"),e.createElement("td",null,new Date(a.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",disabled:y,onClick:()=>L(a)},"Review"),n&&(u==null?void 0:u.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:y,onClick:()=>d(async()=>{const c=await T(),{error:D}=await c.rpc("restore_team_inspections",{p_ids:[a.id]});if(D)throw D;await v(),ye()})},"Restore")))}))),!N.length&&e.createElement("div",{className:"empty"},e.createElement(Re,{size:30}),e.createElement("p",null,n?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with team."))))):e.createElement("form",{className:"login-form",onSubmit:a=>{a.preventDefault(),d(async()=>{const l=await T(),{error:c}=await l.auth.signInWithPassword({email:W,password:Q});if(c)throw c;ne("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:W,onChange:a=>me(a.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:Q,onChange:a=>ne(a.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:y},y?e.createElement(Ye,{className:"spin",size:17}):e.createElement(rt,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!W||y,onClick:()=>d(async()=>{const a=await T(),{error:l}=await a.auth.resetPasswordForEmail(W,{redirectTo:location.origin+location.pathname});if(l)throw l;O("Password reset requested. Check the inbox and Spam folder.")})},"Reset password"),e.createElement("p",{className:"caption"},B?"A new account needs Developer approval before Staff work is available. Approved Staff must also enter their security code when asked.":"The workspace administrator must approve an account before it can access Staff work."))),i&&o&&u&&H&&e.createElement(it,{key:o.id,user:o,inspection:m,notes:J,onEvidence:a=>L({id:a})}),o&&m&&e.createElement("section",{className:"card",ref:P,tabIndex:-1,"aria-labelledby":"shared-inspection-title"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",{id:"shared-inspection-title"},"Shared inspection · ",m.id.slice(0,8)),e.createElement("p",null,"Shared copy from ",j[m.owner_id]||"a colleague",". These are saved results. Opening them does not run another inspection.")),e.createElement("div",{className:"button-row"},f&&!m.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>f(m)},"Open full result and assistant"),!i&&H&&!m.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>p==null?void 0:p(m)},"Create or view corrective actions"),e.createElement("button",{className:"text-button",onClick:()=>{E.current++,F.current=null,C(null),R([]),$([])}},"Close"))),e.createElement("div",{className:"shared-images"},b.map((a,l)=>e.createElement("img",{key:a,src:a,alt:l?"Saved highlighted areas":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED RESULT"),e.createElement("span",null,Ae(m.payload.verdict)," · score ",Number(m.payload.score).toFixed(5)," · review limit ",Number(m.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Saved assistant conversation"),(De=m.conversation)!=null&&De.length?m.conversation.map((a,l)=>e.createElement("p",{className:"cloud-message",key:l},e.createElement("strong",null,a.role==="user"?"Inspector":"Evidence Assistant",": "),a.question||a.answer)):e.createElement("p",{className:"caption"},"No assistant conversation was shared with this inspection."),!m.archived_at&&e.createElement(Xe,{key:m.id+String(J.length),current:J.map(a=>Te(a,j)).filter(Boolean).at(-1),disabled:y,onSave:async a=>{const l=await T(),{error:c}=await l.from("staff_notes").insert({inspection_id:m.id,author_id:o.id,body:Ve(a.status,a.decision,a.note)});if(c)throw c;await L(m),ye()}}),e.createElement("h3",{className:"section-gap"},"Team notes"),J.filter(a=>!Te(a,j)).map(a=>e.createElement("div",{className:"cloud-message",key:a.id},e.createElement("strong",null,j[a.author_id]||"Staff member"),e.createElement("p",null,a.body),e.createElement("small",null,new Date(a.created_at).toLocaleString()))),!m.archived_at&&e.createElement("form",{className:"question-form",onSubmit:a=>{a.preventDefault(),d(async()=>{const l=await T(),{error:c}=await l.from("staff_notes").insert({inspection_id:m.id,author_id:o.id,body:fe.trim()});if(c)throw c;ge(""),await L(m),ye()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a note for the team…",value:fe,onChange:a=>ge(a.target.value)}),e.createElement("button",{className:"primary",disabled:y||!fe.trim()},e.createElement(lt,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(Re,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"Team workspace is not available yet."),e.createElement("p",null,"The workspace administrator needs to connect shared storage before Staff can sign in here."),e.createElement("div",{className:"setup-grid"},[["01","Connect shared storage","The workspace administrator completes this setup."],["02","Set up staff access","The administrator sets up approval and account security."],["03","Connect this dashboard","The administrator connects the app, then Staff can sign in."]].map(([a,l,c])=>e.createElement("div",{key:a},e.createElement("b",null,a),e.createElement("h3",null,l),e.createElement("p",null,c)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Administrator setup ",e.createElement(at,{size:16})),e.createElement("p",{className:"caption"},"Contact the workspace administrator for help. The public demo can be used without Staff access."))}export{ut as default};
frontend/dist/assets/candle-heatmap-VjHcBjw5.jpg ADDED

Git LFS Details

  • SHA256: ebc3563c77c31463c4129c0b73dbf84b08a7c40d11bcb2a94401521fdfeed5fc
  • Pointer size: 131 Bytes
  • Size of remote file: 115 kB
frontend/dist/assets/candle-normal-Cqb2kkRH.jpg ADDED

Git LFS Details

  • SHA256: d68fea68234c27a0f3f4b9131eab8113b52b766e5e5c135faff2f3dd9431ad0b
  • Pointer size: 131 Bytes
  • Size of remote file: 177 kB
frontend/dist/assets/candle-original-Dqn_yXKt.jpg ADDED

Git LFS Details

  • SHA256: 4b7bdcd51e32845bd8e00355b338445b03b322e4357229d6c8334024ccd84c5f
  • Pointer size: 131 Bytes
  • Size of remote file: 166 kB
frontend/dist/assets/index-D1CUAkEx.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/index.html CHANGED
@@ -1,3 +1,3 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#132e32"/><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-DEvENDvs.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-jDRMwSe5.css">
3
  </head><body><div id="root"></div></body></html>
 
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#132e32"/><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-D1CUAkEx.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-jDRMwSe5.css">
3
  </head><body><div id="root"></div></body></html>