From 086b776ad0386590c0ef25cb12fa7f8ead819c6a Mon Sep 17 00:00:00 2001 From: Anuj Gupta <84966248+Anuj-Gupta4@users.noreply.github.com> Date: Fri, 6 Dec 2024 02:28:32 +0545 Subject: [PATCH 1/3] feat(projects): add organisation_logo field to ProjectSummary model (#1956) --- src/backend/app/projects/project_schemas.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/app/projects/project_schemas.py b/src/backend/app/projects/project_schemas.py index 7e7aa8676a..9eba15b46e 100644 --- a/src/backend/app/projects/project_schemas.py +++ b/src/backend/app/projects/project_schemas.py @@ -239,6 +239,7 @@ class ProjectSummary(BaseModel): tasks_mapped: Optional[int] = None tasks_validated: Optional[int] = None tasks_bad: Optional[int] = None + organisation_logo: Optional[str] = None class PaginationInfo(BaseModel): From df454b7293bf35da505daa2b2d5daa5eaa1ff1f0 Mon Sep 17 00:00:00 2001 From: Sujan Adhikari <109404840+Sujanadh@users.noreply.github.com> Date: Fri, 6 Dec 2024 02:33:33 +0545 Subject: [PATCH 2/3] fix: odk credentials are passed without encrypting at first to avoid double encryption (#1957) --- src/backend/app/organisations/organisation_deps.py | 6 +++--- .../app/organisations/organisation_schemas.py | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/backend/app/organisations/organisation_deps.py b/src/backend/app/organisations/organisation_deps.py index cf3b81351e..6db119e028 100644 --- a/src/backend/app/organisations/organisation_deps.py +++ b/src/backend/app/organisations/organisation_deps.py @@ -85,9 +85,9 @@ async def get_org_odk_creds( ) return central_schemas.ODKCentralDecrypted( - odk_central_url=org.odk_central_url, - odk_central_user=org.odk_central_user, - odk_central_password=org.odk_central_password, + odk_central_url=url, + odk_central_user=user, + odk_central_password=password, ) diff --git a/src/backend/app/organisations/organisation_schemas.py b/src/backend/app/organisations/organisation_schemas.py index cc8f86581d..d32e3a8aff 100644 --- a/src/backend/app/organisations/organisation_schemas.py +++ b/src/backend/app/organisations/organisation_schemas.py @@ -79,20 +79,16 @@ def parse_organisation_input( The parsed data is returned as an OrganisationIn instance, with the ODKCentralIn fields merged in. """ - odk_central_data = ODKCentralIn( - odk_central_url=odk_central_url, - odk_central_user=odk_central_user, - odk_central_password=odk_central_password, - ) - org_data = OrganisationUpdate( + return OrganisationUpdate( name=name, slug=slug, created_by=created_by, community_type=community_type, type=type, - **odk_central_data.dict(exclude_unset=True), + odk_central_url=odk_central_url, + odk_central_user=odk_central_user, + odk_central_password=odk_central_password, ) - return org_data class OrganisationOut(BaseModel): From ea196ee86c172a078abc6e54c826b4eab8642aa6 Mon Sep 17 00:00:00 2001 From: Nishit Suwal <81785002+NSUWAL123@users.noreply.github.com> Date: Fri, 6 Dec 2024 02:38:43 +0545 Subject: [PATCH 3/3] fix: Submission Instance Page, Create Project (#1958) * fix(submissionsTable): use task index instead of id * fix(project): organization name add to project info section * fix(createNewProject): pass setAdditionalFeature as prop * fix(uploadArea): reset dataExtract, addGeom, taskSplit geojson to default state on geojson reset * refactor(uploadArea): remove commented code * fix(submission): clear submission details state before api call --- src/frontend/src/api/Project.ts | 1 + src/frontend/src/api/Submission.ts | 1 + .../ProjectDetailsV2/ProjectInfo.tsx | 1 + .../ProjectSubmissions/SubmissionsTable.tsx | 2 +- .../createnewproject/UploadArea.tsx | 45 ++++--------------- .../src/models/project/projectModel.ts | 1 + src/frontend/src/views/CreateNewProject.tsx | 1 + 7 files changed, 15 insertions(+), 37 deletions(-) diff --git a/src/frontend/src/api/Project.ts b/src/frontend/src/api/Project.ts index ac14e5f84f..ab2e46d60e 100755 --- a/src/frontend/src/api/Project.ts +++ b/src/frontend/src/api/Project.ts @@ -48,6 +48,7 @@ export const ProjectById = (projectId: string) => { custom_tms_url: projectResp?.custom_tms_url, organisation_id: projectResp?.organisation_id, organisation_logo: projectResp?.organisation_logo, + organisation_name: projectResp?.organisation_name, created_at: projectResp?.created_at, }), ); diff --git a/src/frontend/src/api/Submission.ts b/src/frontend/src/api/Submission.ts index e1a05122ec..d5d2f1e838 100644 --- a/src/frontend/src/api/Submission.ts +++ b/src/frontend/src/api/Submission.ts @@ -3,6 +3,7 @@ import { SubmissionActions } from '@/store/slices/SubmissionSlice'; export const SubmissionService: Function = (url: string) => { return async (dispatch) => { + dispatch(SubmissionActions.SetSubmissionDetails(null)); dispatch(SubmissionActions.SetSubmissionDetailsLoading(true)); const getSubmissionDetails = async (url: string) => { try { diff --git a/src/frontend/src/components/ProjectDetailsV2/ProjectInfo.tsx b/src/frontend/src/components/ProjectDetailsV2/ProjectInfo.tsx index f55b491c88..bf68787afc 100644 --- a/src/frontend/src/components/ProjectDetailsV2/ProjectInfo.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/ProjectInfo.tsx @@ -106,6 +106,7 @@ const ProjectInfo: React.FC = () => { alt="Organization Photo" /> +

{projectInfo?.organisation_name}

)} diff --git a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx index 48b43bce87..52edfe47bb 100644 --- a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx +++ b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx @@ -464,7 +464,7 @@ const SubmissionsTable = ({ toggleView }) => { headerClassName="updatedHeader !fmtm-sticky fmtm-right-0 fmtm-shadow-[-10px_0px_20px_0px_rgba(0,0,0,0.1)] fmtm-text-center" rowClassName="updatedRow !fmtm-sticky fmtm-right-0 fmtm-bg-white fmtm-shadow-[-10px_0px_20px_0px_rgba(0,0,0,0.1)]" dataFormat={(row) => { - const taskUid = taskList?.find((task) => task?.id == row?.task_id)?.id; + const taskUid = taskList?.find((task) => task?.index == row?.task_id)?.id; return (
diff --git a/src/frontend/src/components/createnewproject/UploadArea.tsx b/src/frontend/src/components/createnewproject/UploadArea.tsx index 993f201f20..549d2ce263 100644 --- a/src/frontend/src/components/createnewproject/UploadArea.tsx +++ b/src/frontend/src/components/createnewproject/UploadArea.tsx @@ -31,11 +31,11 @@ const uploadAreaOptions = [ }, ]; -const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomDataExtractUpload }) => { +const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomDataExtractUpload, setAdditionalFeature }) => { useDocumentTitle('Create Project: Upload Area'); + const dispatch = useDispatch(); const navigate = useNavigate(); - // const [uploadAreaFile, setUploadAreaFile] = useState(null); const [isGeojsonWGS84, setIsGeojsonWG84] = useState(true); const projectDetails = useAppSelector((state) => state.createproject.projectDetails); @@ -66,13 +66,15 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomDataExtractUpl navigate('/upload-survey'); dispatch(CreateProjectActions.SetToggleSplittedGeojsonEdit(false)); }; + const { handleSubmit, handleCustomChange, values: formValues, errors, }: any = useForm(projectDetails, submission, UploadAreaValidation); - const toggleStep = (step, url) => { + + const toggleStep = (step: number, url: string) => { dispatch(CommonActions.SetCurrentStepFormStep({ flag: flag, step: step })); navigate(url); dispatch(CreateProjectActions.SetToggleSplittedGeojsonEdit(false)); @@ -168,11 +170,14 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomDataExtractUpl const resetFile = () => { setGeojsonFile(null); + setCustomDataExtractUpload(null); handleCustomChange('uploadedAreaFile', null); handleCustomChange('drawnGeojson', null); + setAdditionalFeature(null); dispatch(CreateProjectActions.SetDrawnGeojson(null)); dispatch(CreateProjectActions.SetTotalAreaSelection(null)); - dispatch(CreateProjectActions.ClearProjectStepState(formValues)); + dispatch(CreateProjectActions.SetAdditionalFeatureGeojson(null)); + dispatch(CreateProjectActions.ClearProjectStepState({ ...formValues, uploadedAreaFile: null, drawnGeojson: null })); }; useEffect(() => { @@ -279,38 +284,6 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomDataExtractUpl btnText="Upload a Geojson" errorMsg={errors.uploadedAreaFile} /> - //
- //
- // - //
- // resetFile()} /> - //
- //
- // {geojsonFile && ( - //
- //

{geojsonFile?.name}

- //
- // )} - //

- // *The supported file formats are zipped shapefile, geojson or kml files. - //

- //

- // Total Area: 234 sq.km - //

- //
)}
diff --git a/src/frontend/src/models/project/projectModel.ts b/src/frontend/src/models/project/projectModel.ts index 79518ce134..acdfb21793 100644 --- a/src/frontend/src/models/project/projectModel.ts +++ b/src/frontend/src/models/project/projectModel.ts @@ -51,6 +51,7 @@ export type projectInfoType = { total_tasks: any; organisation_id: number; organisation_logo: string; + organisation_name: string; instructions: string; custom_tms_url: string; created_at: string; diff --git a/src/frontend/src/views/CreateNewProject.tsx b/src/frontend/src/views/CreateNewProject.tsx index 19840c1683..90fa1ecb93 100644 --- a/src/frontend/src/views/CreateNewProject.tsx +++ b/src/frontend/src/views/CreateNewProject.tsx @@ -67,6 +67,7 @@ const CreateNewProject = () => { geojsonFile={geojsonFile} setGeojsonFile={setGeojsonFile} setCustomDataExtractUpload={setCustomDataExtractUpload} + setAdditionalFeature={setAdditionalFeature} /> ); case '/upload-survey':