-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Implement gcp editor package (#424)
* feat: add gcp editor package * feat: add start processing button on project description about section * feat(individual-project): create GcpEditor react component from the web component * feat: add services for all imagery porcess * feat: store gcp editor visible control and gcp data on redux * feat(individual-project): show gcp editor
- Loading branch information
Showing
6 changed files
with
151 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/frontend/src/components/IndividualProject/GcpEditor/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { useEffect, createElement } from 'react'; | ||
import '@hotosm/gcp-editor'; | ||
import '@hotosm/gcp-editor/style.css'; | ||
import { useDispatch } from 'react-redux'; | ||
import { setProjectState } from '@Store/actions/project'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { processAllImagery } from '@Services/project'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
const GcpEditor = ({ | ||
cogUrl, | ||
finalButtonText, | ||
// handleProcessingStart, | ||
rawImageUrl, | ||
}: any) => { | ||
const { id } = useParams(); | ||
const dispatch = useDispatch(); | ||
const CUSTOM_EVENT: any = 'start-processing-click'; | ||
|
||
const { mutate: startImageProcessing } = useMutation({ | ||
mutationFn: processAllImagery, | ||
onSuccess: () => { | ||
dispatch(setProjectState({ showGcpEditor: false })); | ||
}, | ||
}); | ||
|
||
const startProcessing = (data: any) => { | ||
const gcpData = data.detail; | ||
const blob = new Blob([gcpData], { type: 'text/plain;charset=utf-8;' }); | ||
const gcpFile = new File([blob], 'gcp.txt'); | ||
startImageProcessing({ projectId: id, gcp_file: gcpFile }); | ||
}; | ||
|
||
useEffect(() => { | ||
document.addEventListener(CUSTOM_EVENT, data => { | ||
startProcessing(data); | ||
}); | ||
return document.removeEventListener(CUSTOM_EVENT, data => { | ||
startProcessing(data); | ||
}); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [CUSTOM_EVENT, dispatch]); | ||
|
||
return createElement('gcp-editor', { | ||
cogUrl, | ||
customEvent: CUSTOM_EVENT, | ||
finalButtonText, | ||
rawImageUrl, | ||
}); | ||
}; | ||
|
||
export default GcpEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters