From f74b4361d467015fcac828c2c18b7983d1447269 Mon Sep 17 00:00:00 2001 From: Deepak Pradhan Date: Fri, 22 Dec 2023 16:23:27 +0545 Subject: [PATCH 1/7] feat: added formatted message and handled loading after download --- .../components/projectDetail/downloadOsmData.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/projectDetail/downloadOsmData.js b/frontend/src/components/projectDetail/downloadOsmData.js index 350f9d2dc8..016d77f0cd 100644 --- a/frontend/src/components/projectDetail/downloadOsmData.js +++ b/frontend/src/components/projectDetail/downloadOsmData.js @@ -3,6 +3,8 @@ import { RoadIcon, HomeIcon, WavesIcon, TaskIcon, AsteriskIcon } from '../svgIco import FileFormatCard from './fileFormatCard'; import Popup from 'reactjs-popup'; import { EXPORT_TOOL_S3_URL } from '../../config'; +import messages from './messages'; +import { FormattedMessage } from 'react-intl'; export const TITLED_ICONS = [ { Icon: RoadIcon, title: 'roads', value: 'ROADS' }, @@ -22,7 +24,7 @@ const fileFormats = [{ format: 'SHP' }, { format: 'GEOJSON' }, { format: 'KML' } */ export const DownloadOsmData = ({ projectMappingTypes, project }) => { - const [showPopup, setShowPopup] = useState(false); + const [showPopup, setShowPopup] = useState(true); const [isDownloadingState, setIsDownloadingState] = useState(null); /** @@ -47,9 +49,6 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => { // Check if the request was successful if (response.ok) { - // Set the state to indicate that the file download is complete - setIsDownloadingState({ title: title, fileFormat: fileFormat, isDownloading: false }); - // Get the file data as a blob const blob = await response.blob(); @@ -66,6 +65,8 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => { document.body.appendChild(link); link.click(); document.body.removeChild(link); + // Set the state to indicate that the file download is complete + setIsDownloadingState({ title: title, fileFormat: fileFormat, isDownloading: false }); } else { // Show a popup and throw an error if the request was not successful setShowPopup(true); @@ -87,7 +88,12 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => { setShowPopup(false)}> {(close) => (
-

Data Not Available.

+

+ +

+

+ +

{/* Download OSM Data section Start */} - -
- - - -

- -

- -
+ {/* Converted String to Integer */} + {+ENABLE_EXPORT_TOOL === 1 && ( +
+ + + +

+ +

+ +
+ )} {/* Download OSM Data section End */} From 080da1ca15ef0c88c584940f3b9136b725b7e1be Mon Sep 17 00:00:00 2001 From: Deepak Pradhan Date: Fri, 22 Dec 2023 17:08:10 +0545 Subject: [PATCH 6/7] feat: added env bool for enable export tool --- frontend/.env.expand | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/.env.expand b/frontend/.env.expand index 93b6e9df93..58cf2498ab 100644 --- a/frontend/.env.expand +++ b/frontend/.env.expand @@ -44,3 +44,4 @@ REACT_APP_ENVIRONMENT=$TM_ENVIRONMENT REACT_APP_TM_DEFAULT_CHANGESET_COMMENT=$TM_DEFAULT_CHANGESET_COMMENT REACT_APP_RAPID_EDITOR_URL=$RAPID_EDITOR_URL REACT_APP_EXPORT_TOOL_S3_URL=$EXPORT_TOOL_S3_URL +REACT_APP_ENABLE_EXPORT_TOOL=$ENABLE_EXPORT_TOOL From 6d812ed03a38f0e08e893fee9fdfae82a657b236 Mon Sep 17 00:00:00 2001 From: Deepak Pradhan Date: Fri, 22 Dec 2023 17:08:21 +0545 Subject: [PATCH 7/7] feat: config added --- frontend/src/config/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index 16348cf611..343f7c3171 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -60,6 +60,7 @@ export const POTLATCH2_EDITOR_URL = export const RAPID_EDITOR_URL = process.env.REACT_APP_RAPID_EDITOR_URL || 'https://mapwith.ai/rapid'; export const EXPORT_TOOL_S3_URL = process.env.REACT_APP_EXPORT_TOOL_S3_URL || ''; +export const ENABLE_EXPORT_TOOL = process.env.REACT_APP_ENABLE_EXPORT_TOOL || ''; export const TASK_COLOURS = { READY: '#fff',