Add one-click GIS workflow run
This commit is contained in:
@@ -218,12 +218,12 @@ interface MapWorkspaceProps {
|
||||
onSetMapLayerOpacity: (opacity: number) => void
|
||||
onSelectMapFeature: (feature: GeoJSON.Feature | null) => void
|
||||
onSetMapSelectionBbox: (bbox: VectorSelectionBBox | null) => void
|
||||
onRunMapSelectionExtract: (bbox: VectorSelectionBBox) => void
|
||||
onRunMapSelectionExtract: (bbox: VectorSelectionBBox) => Promise<VectorSelectionResponse | null>
|
||||
onClearMapSelectionExtract: () => void
|
||||
onExportMapSelection: (bbox: VectorSelectionBBox) => void
|
||||
onDeriveMapSelectionDataset: (bbox: VectorSelectionBBox) => void
|
||||
onExportMapSelection: (bbox: VectorSelectionBBox) => Promise<unknown>
|
||||
onDeriveMapSelectionDataset: (bbox: VectorSelectionBBox) => Promise<DatasetCreateResponse | null>
|
||||
onSelectMapQaReferenceDataset: (datasetId: string) => void
|
||||
onRunMapSelectionQa: () => void
|
||||
onRunMapSelectionQa: (candidateDataset?: DatasetCreateResponse | null) => Promise<QaComparisonResult | null>
|
||||
onOpenMapSelectionQualityEvidence: () => void
|
||||
onClearQualityEvidence?: () => void
|
||||
}
|
||||
@@ -287,6 +287,9 @@ export function MapWorkspace({
|
||||
const [bboxSelectionMode, setBboxSelectionMode] = useState(false)
|
||||
const [firstSelectionCorner, setFirstSelectionCorner] = useState<[number, number] | null>(null)
|
||||
const [bboxInput, setBboxInput] = useState(bboxToInputState(mapSelectionBbox))
|
||||
const [fullWorkflowRunning, setFullWorkflowRunning] = useState(false)
|
||||
const [fullWorkflowStatus, setFullWorkflowStatus] = useState('Ready to run persisted GIS workflow.')
|
||||
const [fullWorkflowError, setFullWorkflowError] = useState<string | null>(null)
|
||||
const selectedMapArea = areas.find((area) => area.id === selectedMapAreaId)
|
||||
const featureProperties = selectedMapFeature?.properties ?? null
|
||||
const featureSummaryEntries = featureProperties
|
||||
@@ -404,6 +407,51 @@ export function MapWorkspace({
|
||||
onRunMapSelectionExtract(bbox)
|
||||
}
|
||||
|
||||
const runFullGisWorkflow = async () => {
|
||||
const bbox = currentSelectionBbox ?? selectedAreaBbox ?? activeLayerBbox
|
||||
if (!selectedMapDataset || !bbox) {
|
||||
setFullWorkflowError('Select a database layer and AOI/layer extent before running the full workflow.')
|
||||
return
|
||||
}
|
||||
|
||||
setFullWorkflowRunning(true)
|
||||
setFullWorkflowError(null)
|
||||
try {
|
||||
setFullWorkflowStatus('1/4 Querying persisted vector_features...')
|
||||
setSelectionBbox(bbox)
|
||||
const selection = await onRunMapSelectionExtract(bbox)
|
||||
if (!selection) {
|
||||
setFullWorkflowError('Persisted vector query did not complete.')
|
||||
setFullWorkflowStatus('Stopped at query.')
|
||||
return
|
||||
}
|
||||
|
||||
setFullWorkflowStatus('2/4 Saving derived result dataset...')
|
||||
const derived = await onDeriveMapSelectionDataset(bbox)
|
||||
if (!derived) {
|
||||
setFullWorkflowError('Derived result dataset was not created.')
|
||||
setFullWorkflowStatus('Stopped at dataset save.')
|
||||
return
|
||||
}
|
||||
|
||||
setFullWorkflowStatus('3/4 Saving GeoJSON export artifact...')
|
||||
await onExportMapSelection(bbox)
|
||||
|
||||
if (selectedMapQaReferenceDatasetId) {
|
||||
setFullWorkflowStatus('4/4 Running QA/QC against selected reference...')
|
||||
const qaResult = await onRunMapSelectionQa(derived)
|
||||
setFullWorkflowStatus(qaResult ? 'Full GIS workflow complete with QA/QC result.' : 'Dataset/export complete; QA/QC did not complete.')
|
||||
} else {
|
||||
setFullWorkflowStatus('Dataset/export complete. Select a reference dataset to add QA/QC.')
|
||||
}
|
||||
} catch (error) {
|
||||
setFullWorkflowError(error instanceof Error ? error.message : 'Full GIS workflow failed.')
|
||||
setFullWorkflowStatus('Workflow stopped.')
|
||||
} finally {
|
||||
setFullWorkflowRunning(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="map-workspace-shell" data-testid="map-workspace">
|
||||
<div className="panel-title-row">
|
||||
@@ -705,6 +753,18 @@ export function MapWorkspace({
|
||||
</div>
|
||||
</div>
|
||||
<div className="guided-gis-actions">
|
||||
<button
|
||||
className="primary-action guided-gis-full-run"
|
||||
disabled={!selectedMapDataset || !mapFeatureCollection || (!currentSelectionBbox && !selectedAreaBbox && !activeLayerBbox) || fullWorkflowRunning}
|
||||
type="button"
|
||||
onClick={runFullGisWorkflow}
|
||||
>
|
||||
{fullWorkflowRunning ? 'Running full workflow...' : 'Run full GIS workflow'}
|
||||
</button>
|
||||
<div className="guided-gis-batch-status" aria-live="polite">
|
||||
<strong>Query, save, QA and export</strong>
|
||||
<span>{fullWorkflowStatus}</span>
|
||||
</div>
|
||||
<button
|
||||
className="secondary-action"
|
||||
disabled={!mapSelectionResult || !currentSelectionBbox || selectionDatasetSaving}
|
||||
@@ -740,7 +800,7 @@ export function MapWorkspace({
|
||||
className="primary-action"
|
||||
disabled={!latestSelectionDatasetName || !selectedMapQaReferenceDatasetId || mapSelectionQaRunning}
|
||||
type="button"
|
||||
onClick={onRunMapSelectionQa}
|
||||
onClick={() => onRunMapSelectionQa()}
|
||||
>
|
||||
{mapSelectionQaRunning ? 'Running QA...' : 'Run QA/QC'}
|
||||
</button>
|
||||
@@ -756,6 +816,7 @@ export function MapWorkspace({
|
||||
{selectionDatasetError ? <p className="error">{selectionDatasetError}</p> : null}
|
||||
{selectionExportError ? <p className="error">{selectionExportError}</p> : null}
|
||||
{mapSelectionQaError ? <p className="error">{mapSelectionQaError}</p> : null}
|
||||
{fullWorkflowError ? <p className="error">{fullWorkflowError}</p> : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="bbox-select-surface" aria-label="Area selection and extract">
|
||||
@@ -915,7 +976,7 @@ export function MapWorkspace({
|
||||
className="primary-action"
|
||||
disabled={!selectedMapQaReferenceDatasetId || mapSelectionQaRunning}
|
||||
type="button"
|
||||
onClick={onRunMapSelectionQa}
|
||||
onClick={() => onRunMapSelectionQa()}
|
||||
>
|
||||
{mapSelectionQaRunning ? 'Running QA...' : 'Run QA on saved dataset'}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user