import {friendlyError,resultLabel} from './userLanguage.mjs'; import React,{useEffect,useState,useRef} from 'react'; import {startPolling} from './workspace.mjs'; const preview=value=>'data:image/jpeg;base64,'+value; const score=value=>typeof value==='number'?value.toFixed(5):'—'; export function GalleryUnavailableNotice({local=false}){ return
{local?<> Public sharing is not available from this computer yet. Demo results stay here. Account work stays private unless shared separately.{' '} Open the online community gallery to browse existing public copies. Opening it does not publish a local inspection. >:'The public gallery is not available yet. Other inspection features can still be used.'}
; } export function PublishGalleryPanel({record,api}){ const [state,setState]=useState(null),[consent,setConsent]=useState(false),[busy,setBusy]=useState(false),[error,setError]=useState(''); const publishing=useRef(false),version=useRef(0); useEffect(()=>{let active=true;const poll=startPolling(async()=>{if(publishing.current)return;const generation=version.current;try{const value=await api(`/api/inspections/${record.id}/publication`);if(active&&generation===version.current){setState(value);setError('')}}catch(err){if(active&&generation===version.current)setError(err.message);throw err}});return()=>{active=false;poll.stop()}},[record.id,api]); const publication=state?.publication; async function submit(){ if(publishing.current)return; publishing.current=true;version.current++;setBusy(true);setError(''); try{ if(publication?.visible){await api(`/api/gallery/${publication.id}/withdraw`,{method:'POST'});setState({...state,publication:{...publication,visible:false}})} else {const value=await api(`/api/inspections/${record.id}/publication`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({consent})});setState({...state,publication:value});setConsent(false)} }catch(err){setError(err.message)}finally{publishing.current=false;setBusy(false)} } returnPublishing lets anyone see a separate copy of the photo, highlighted areas, product type and result. Private history stays in this workspace.
Names, filenames, batch names, conversations and Staff reviews are not included. Anything visible inside the photo can still be seen. Only publish photos that may be shared publicly.
{!state&&!error&&Checking gallery availability…
} {state?.enabled===false&&{state.runtime==='local'?'Public sharing is not set up on this computer. This is not caused by using the demo. Results remain saved here. The online app has its own public sharing settings.':'Public sharing is not available in this app yet. Once enabled, demo visitors can publish by choice. Private work stays separate.'}
} {state?.enabled&&!publication&&} {publication&&!publication.visible&&This publication was withdrawn or moderated. It remains unavailable in the public gallery.
} {state?.enabled&&(!publication||publication.visible)&&} {publication?.visible&&Published. Other visitors can browse this copy in Community gallery. Withdrawal keeps the private inspection. Downloaded or cached copies cannot be recalled.
} {error&&{friendlyError(error)}
}Only explicitly published inspections appear here. Browsing requires no account. Private guest and staff histories are separate.
These are saved results shared by visitors. They are not new inspections or expert product approvals. Visitors choose the product type, which may be incorrect. VisA sample images: Zou et al., ECCV 2022 · CC BY 4.0.
{error&&{friendlyError(error)}
} {!data&&!error&&Loading public gallery…
} {data?.enabled===false&&| Product | Inspection result | Score | Published | Preview |
|---|---|---|---|---|
| {item.measurement.category} | {resultLabel(item.measurement.verdict)} | {score(item.measurement.score)} | {new Date(item.created_at).toLocaleString()} |
No published inspections on this page. Inspect an image, then choose Publish to community gallery.
}{friendlyError(error)}
} {!detail&&!error&&Loading image and heatmap…
} {detail&&<>{detail.measurement.category} · {resultLabel(detail.measurement.verdict)} · Score {score(detail.measurement.score)} · Threshold {score(detail.measurement.threshold)}
{detail.measurement.model_id} · {detail.measurement.localization}
A higher score means a larger difference from normal examples. It is not an accuracy percentage or the chance of a defect.
To remove a demo publication, use the browser that published it. Staff can remove their own publications using the same approved account. If access is lost, contact the workspace administrator with this public item number: {detail.id}. Staff can hide unsuitable publications. Hidden copies are kept privately for review and are no longer shown publicly.
>}