diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 87a728f1e9..3b066610a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: # Lint / autoformat: Python code - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.5" + rev: "v0.1.6" hooks: - id: ruff files: ^src/backend/(?:.*/)*.*$ diff --git a/docker-compose.development.yml b/docker-compose.development.yml index b547e0583f..0e975f691a 100644 --- a/docker-compose.development.yml +++ b/docker-compose.development.yml @@ -210,7 +210,7 @@ services: - "5434:5432" networks: - fmtm-net - restart: "on-failure:3" + restart: "unless-stopped" healthcheck: test: pg_isready -U ${CENTRAL_DB_USER} -d ${CENTRAL_DB_NAME} start_period: 5s diff --git a/src/frontend/src/assets/images/something_went_wrong.png b/src/frontend/src/assets/images/something_went_wrong.png index a1fd6704fc..cf08a64d98 100644 Binary files a/src/frontend/src/assets/images/something_went_wrong.png and b/src/frontend/src/assets/images/something_went_wrong.png differ diff --git a/src/frontend/src/components/GenerateBasemap.jsx b/src/frontend/src/components/GenerateBasemap.jsx index a576d331c7..d1091de09b 100644 --- a/src/frontend/src/components/GenerateBasemap.jsx +++ b/src/frontend/src/components/GenerateBasemap.jsx @@ -15,6 +15,7 @@ const GenerateBasemap = ({ setToggleGenerateModal, toggleGenerateModal, projectI const [selectedTileSource, setSelectedTileSource] = useState(null); const [selectedOutputFormat, setSelectedOutputFormat] = useState(null); const [tmsUrl, setTmsUrl] = useState(''); + const [error, setError] = useState([]); const modalStyle = (theme) => ({ width: '90vw', // Responsive modal width using vw @@ -51,6 +52,35 @@ const GenerateBasemap = ({ setToggleGenerateModal, toggleGenerateModal, projectI setTmsUrl(e.target.value); }; + const generateProjectTilesValidation = () => { + const currentError = []; + if (!selectedTileSource) { + currentError.push('selectedTileSource'); + } + if (!selectedOutputFormat) { + currentError.push('selectedOutputFormat'); + } + if (!tmsUrl && selectedTileSource === 'tms') { + currentError.push('tmsUrl'); + } + setError(currentError); + return currentError; + }; + + const generateProjectTiles = () => { + const currentErrors = generateProjectTilesValidation(); + if (currentErrors.length === 0) { + dispatch( + GenerateProjectTiles( + `${ + import.meta.env.VITE_API_URL + }/projects/tiles/${decodedId}?source=${selectedTileSource}&format=${selectedOutputFormat}&tms=${tmsUrl}`, + decodedId, + ), + ); + } + }; + return ( - {/* Output Format Dropdown */} - - - - Select Output Format - - { - setSelectedOutputFormat(e.target.value); - }} - > - {environment.tileOutputFormats?.map((form) => ( - - {form.label} - - ))} - - - + + {/* Output Format Dropdown */} + + + + Select Output Format + + { + setSelectedOutputFormat(e.target.value); + }} + > + {environment.tileOutputFormats?.map((form) => ( + + {form.label} + + ))} + + + {error.includes('selectedOutputFormat') && ( +

Output Format is Required.

+ )} +
- {/* Tile Source Dropdown or TMS URL Input */} - - - - Select Tile Source - - - {environment.baseMapProviders?.map((form) => ( - - {form.label} - - ))} - - {selectedTileSource === 'tms' && ( - + {/* Tile Source Dropdown or TMS URL Input */} + + + + Select Tile Source + + + {environment.baseMapProviders?.map((form) => ( + + {form.label} + + ))} + + + {error.includes('selectedTileSource') && ( +

Tile Source is Required.

+ )} +
+ {selectedTileSource === 'tms' && ( + + - )} -
-
- - {/* Generate Button */} - - { - // Check if 'tms' is selected and tmsUrl is not empty - if (selectedTileSource === 'tms' && !tmsUrl) { - // Handle error, TMS URL is required - console.log('TMS URL is required'); - return; - } + {error.includes('tmsUrl') &&

Tile Source is Required.

} +
+ )} + +
+ {/* Generate Button */} +
+ generateProjectTiles()} + > + Generate + +
- dispatch( - GenerateProjectTiles( - `${ - import.meta.env.VITE_API_URL - }/projects/tiles/${decodedId}?source=${selectedTileSource}&format=${selectedOutputFormat}&tms=${tmsUrl}`, - decodedId, - ), - ); - }} - > - Generate - - - - {/* Refresh Button */} - - { - getTilesList(); - }} - > - Refresh - + {/* Refresh Button */} +
+ { + getTilesList(); + }} + > + Refresh + +
+
+
{/* Table Content */} diff --git a/src/frontend/src/components/common/StepSwitcher.tsx b/src/frontend/src/components/common/StepSwitcher.tsx index 3d9c9e9939..0eb5b22764 100644 --- a/src/frontend/src/components/common/StepSwitcher.tsx +++ b/src/frontend/src/components/common/StepSwitcher.tsx @@ -4,7 +4,7 @@ import { CommonActions } from '../../store/slices/CommonSlice'; import CoreModules from '../../shared/CoreModules.js'; import { useNavigate } from 'react-router-dom'; -const StepSwitcher = ({ data, flag }) => { +const StepSwitcher = ({ data, flag, switchSteps }) => { interface IIndividualStep { url: string; step: number; @@ -39,7 +39,11 @@ const StepSwitcher = ({ data, flag }) => { } lg:fmtm-w-7 lg:fmtm-h-7 xl:fmtm-w-9 xl:fmtm-h-9 fmtm-rounded-full fmtm-flex fmtm-justify-center fmtm-items-center fmtm-border-[0.15rem] fmtm-border-primaryRed hover:fmtm-cursor-pointer ${ currentStep.step >= index ? 'fmtm-bg-primaryRed' : 'fmtm-bg-transparent' }`} - onClick={() => toggleStep(step)} + onClick={() => { + if (switchSteps) { + toggleStep(step); + } + }} > toggleStep(2, '/upload-area')} + onClick={() => toggleStep(3, '/select-form')} className="fmtm-font-bold" />