From a85ce047727a8839178195b210baaa4fc64a94c4 Mon Sep 17 00:00:00 2001 From: shiminc Date: Wed, 19 Jun 2024 10:57:22 +0100 Subject: [PATCH 1/3] combiningExistingList to markerList --- frontend/src/components/Image.jsx | 8 +++++++- frontend/src/components/PhotoSelection.jsx | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Image.jsx b/frontend/src/components/Image.jsx index 6bf8f4f..0807451 100644 --- a/frontend/src/components/Image.jsx +++ b/frontend/src/components/Image.jsx @@ -15,6 +15,7 @@ function Image (props) { const imgRef = useRef(null); console.log('IN IMAGE COMPONENT') console.log(props.image) + console.log(props.existingLabel) //State for x, y coordinates based on the original image const [coordinate, setCoordinate] = useState({ @@ -27,7 +28,12 @@ function Image (props) { const [markerList, setMarkerList] = useState([]) useEffect (() => { //reset every initial state when image changes - setMarkerList([]) + if(props.existingLabel.length === 0){ + setMarkerList([]) + } else if (props.existingLabel.length > 0 ) { + setMarkerList([props.existingLabel]) + } + setImageSize({ originalWidth : 0, originalHeight : 0, diff --git a/frontend/src/components/PhotoSelection.jsx b/frontend/src/components/PhotoSelection.jsx index 8e43bdc..088d48c 100644 --- a/frontend/src/components/PhotoSelection.jsx +++ b/frontend/src/components/PhotoSelection.jsx @@ -6,6 +6,7 @@ Display a drop-down list of photos to be shown. */ function PhotoSelection(props) { const [currentPhoto, setCurrentPhoto] = useState('') + const [humanLabel, setHumanLabel] = useState([]) /* List the photos for users to choose from */ @@ -21,12 +22,14 @@ function PhotoSelection(props) { console.log(selectedPhoto); // Update the list of photo filenames available in that session - let url = `/api/${selectedPhoto}`; let urlJpeg = '/api/photos/' + selectedPhoto.replace("np", "jpeg"); setCurrentPhoto(urlJpeg); - console.log(currentPhoto) + let urlHumanLabel = '/api/labels/detail?path=' + selectedPhoto + fetch(urlHumanLabel) + .then(response => response.json()) + .then(data => setHumanLabel(data)); } @@ -40,7 +43,7 @@ function PhotoSelection(props) { >