From 6adf2f77f1179c1792ecc06d601e8c7bcea8f7bc Mon Sep 17 00:00:00 2001 From: Sujit Date: Fri, 6 Sep 2024 10:53:45 +0545 Subject: [PATCH 1/8] fix(project-dashboard): project list responsive --- src/frontend/src/components/Projects/ProjectCard/index.tsx | 2 +- src/frontend/src/views/Projects/index.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/Projects/ProjectCard/index.tsx b/src/frontend/src/components/Projects/ProjectCard/index.tsx index 1e67f1e4..57019075 100644 --- a/src/frontend/src/components/Projects/ProjectCard/index.tsx +++ b/src/frontend/src/components/Projects/ProjectCard/index.tsx @@ -24,7 +24,7 @@ export default function ProjectCard({

{imageUrl ? ( diff --git a/src/frontend/src/views/Projects/index.tsx b/src/frontend/src/views/Projects/index.tsx index eeb8cc06..0431554e 100644 --- a/src/frontend/src/views/Projects/index.tsx +++ b/src/frontend/src/views/Projects/index.tsx @@ -29,10 +29,11 @@ const Projects = () => {

{isLoading ? ( <> - {Array.from({ length: 8 }, (_, index) => ( + {Array.from({ length: 6 }, (_, index) => ( ))} From 1c8d776231b53ac3c38b90513ae85dd9bd8fa356 Mon Sep 17 00:00:00 2001 From: Sujit Date: Fri, 6 Sep 2024 16:03:23 +0545 Subject: [PATCH 2/8] feat(project-dashboard): visible map by default --- src/frontend/src/store/slices/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/store/slices/common.ts b/src/frontend/src/store/slices/common.ts index f3574193..077d5061 100644 --- a/src/frontend/src/store/slices/common.ts +++ b/src/frontend/src/store/slices/common.ts @@ -22,7 +22,7 @@ const initialState: CommonState = { modalContent: null, showPromptDialog: false, promptDialogContent: null, - showMap: false, + showMap: true, openSignInMenu: false, userProfileActiveTab: 1, isCertifiedDroneUser: 'no', From bf630e1b2019576e288654a639715ed1686edefa Mon Sep 17 00:00:00 2001 From: Sujit Date: Fri, 6 Sep 2024 16:04:59 +0545 Subject: [PATCH 3/8] feat(project-dashboard): remove center to nepal and set center to [0, 0] show all projects in the world with clustering --- .../components/Projects/MapSection/index.tsx | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/frontend/src/components/Projects/MapSection/index.tsx b/src/frontend/src/components/Projects/MapSection/index.tsx index b3f67da3..019e7a2d 100644 --- a/src/frontend/src/components/Projects/MapSection/index.tsx +++ b/src/frontend/src/components/Projects/MapSection/index.tsx @@ -4,14 +4,18 @@ import BaseLayerSwitcher from '@Components/common/MapLibreComponents/BaseLayerSw import { useGetProjectsListQuery } from '@Api/projects'; import hasErrorBoundary from '@Utils/hasErrorBoundary'; import centroid from '@turf/centroid'; +import getBbox from '@turf/bbox'; +import { useEffect } from 'react'; +import { FeatureCollection } from 'geojson'; +import { LngLatBoundsLike } from 'maplibre-gl'; import VectorLayerWithCluster from './VectorLayerWithCluster'; const ProjectsMapSection = () => { const { map, isMapLoaded } = useMapLibreGLMap({ containerId: 'dashboard-map', mapOptions: { - zoom: 5, - center: [84.124, 28.3949], + zoom: 0, + center: [0, 0], maxZoom: 19, }, disableRotation: true, @@ -35,11 +39,11 @@ const ProjectsMapSection = () => { }, }); - // useEffect(() => { - // if (!projectsList) return; - // const bbox = getBbox(projectsList as FeatureCollection); - // map?.fitBounds(bbox as LngLatBoundsLike, { padding: 30 }); - // }, [projectsList, map]); + useEffect(() => { + if (!projectsList) return; + const bbox = getBbox(projectsList as FeatureCollection); + map?.fitBounds(bbox as LngLatBoundsLike, { padding: 100 }); + }, [projectsList, map]); return ( { sourceId="clustered-projects" geojson={projectsList} /> - - {/* */} ); }; From 7c9cf9917057019011395bef1be9b485efc3035d Mon Sep 17 00:00:00 2001 From: Sujit Date: Fri, 6 Sep 2024 17:31:17 +0545 Subject: [PATCH 4/8] feat(project-dashboard): increase project centroid pointing circle radius --- .../components/Projects/MapSection/VectorLayerWithCluster.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/components/Projects/MapSection/VectorLayerWithCluster.tsx b/src/frontend/src/components/Projects/MapSection/VectorLayerWithCluster.tsx index 5774e89b..0c4be1a6 100644 --- a/src/frontend/src/components/Projects/MapSection/VectorLayerWithCluster.tsx +++ b/src/frontend/src/components/Projects/MapSection/VectorLayerWithCluster.tsx @@ -60,7 +60,7 @@ export default function VectorLayerWithCluster({ filter: ['!', ['has', 'point_count']], paint: { 'circle-color': '#11b4da', - 'circle-radius': 6, + 'circle-radius': 8, 'circle-stroke-width': 1, 'circle-stroke-color': '#fff', }, From b9112ec82f4701b331cbf8c3621188599d78789a Mon Sep 17 00:00:00 2001 From: Sujit Date: Fri, 6 Sep 2024 17:33:05 +0545 Subject: [PATCH 5/8] feat(project-dashboard): show popup on project click, the popup content has name id and go to project details button --- .../components/Projects/MapSection/index.tsx | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/components/Projects/MapSection/index.tsx b/src/frontend/src/components/Projects/MapSection/index.tsx index 019e7a2d..559d84cd 100644 --- a/src/frontend/src/components/Projects/MapSection/index.tsx +++ b/src/frontend/src/components/Projects/MapSection/index.tsx @@ -1,3 +1,4 @@ +import { useNavigate } from 'react-router-dom'; import { useMapLibreGLMap } from '@Components/common/MapLibreComponents'; import MapContainer from '@Components/common/MapLibreComponents/MapContainer'; import BaseLayerSwitcher from '@Components/common/MapLibreComponents/BaseLayerSwitcher'; @@ -5,12 +6,17 @@ import { useGetProjectsListQuery } from '@Api/projects'; import hasErrorBoundary from '@Utils/hasErrorBoundary'; import centroid from '@turf/centroid'; import getBbox from '@turf/bbox'; -import { useEffect } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { FeatureCollection } from 'geojson'; -import { LngLatBoundsLike } from 'maplibre-gl'; +import AsyncPopup from '@Components/common/MapLibreComponents/AsyncPopup'; +import { LngLatBoundsLike, Map } from 'maplibre-gl'; import VectorLayerWithCluster from './VectorLayerWithCluster'; const ProjectsMapSection = () => { + const [projectProperties, setProjectProperties] = useState< + Record + >({}); + const navigate = useNavigate(); const { map, isMapLoaded } = useMapLibreGLMap({ containerId: 'dashboard-map', mapOptions: { @@ -27,7 +33,17 @@ const ProjectsMapSection = () => { (acc: Record, current: Record) => { return { ...acc, - features: [...acc.features, centroid(current.outline)], + features: [ + ...acc.features, + { + ...centroid(current.outline), + properties: { + id: current?.id, + name: current?.name, + slug: current?.slug, + }, + }, + ], }; }, { @@ -45,6 +61,14 @@ const ProjectsMapSection = () => { map?.fitBounds(bbox as LngLatBoundsLike, { padding: 100 }); }, [projectsList, map]); + const getPopupUI = useCallback(() => { + return ( +
+

{projectProperties?.name}

+
+ ); + }, [projectProperties]); + return ( { sourceId="clustered-projects" geojson={projectsList} /> + + ) => + feature?.layer?.id === 'unclustered-point' + } + popupUI={getPopupUI} + fetchPopupData={(properties: Record) => { + setProjectProperties(properties); + }} + buttonText="Go To Project" + handleBtnClick={() => navigate(`./${projectProperties?.id}`)} + getCoordOnProperties + /> ); }; From dafc5846e8a75e9f1eed99b083ee283b6138667d Mon Sep 17 00:00:00 2001 From: Sujit Date: Fri, 6 Sep 2024 17:51:15 +0545 Subject: [PATCH 6/8] feat(task-description): download waypoint geojson --- .../DescriptionSection/index.tsx | 60 +++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/index.tsx b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/index.tsx index 5af48ae3..b30e3f82 100644 --- a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/index.tsx @@ -4,7 +4,7 @@ import { useParams } from 'react-router-dom'; import { motion } from 'framer-motion'; import { Button } from '@Components/RadixComponents/Button'; import Tab from '@Components/common/Tabs'; -import { useGetIndividualTaskQuery } from '@Api/tasks'; +import { useGetIndividualTaskQuery, useGetTaskWaypointQuery } from '@Api/tasks'; import { useTypedDispatch, useTypedSelector } from '@Store/hooks'; import { setSecondPageState } from '@Store/actions/droneOperatorTask'; import hasErrorBoundary from '@Utils/hasErrorBoundary'; @@ -23,6 +23,16 @@ const DroneOperatorDescriptionBox = () => { const { data: taskDescription }: Record = useGetIndividualTaskQuery(taskId as string); + const { data: taskWayPoints }: any = useGetTaskWaypointQuery( + projectId as string, + taskId as string, + { + select: (data: any) => { + return data.data.features; + }, + }, + ); + useEffect(() => { setAnimated(true); setTimeout(() => { @@ -110,6 +120,25 @@ const DroneOperatorDescriptionBox = () => { ); }; + const downloadGeojson = () => { + if (!taskWayPoints) return; + const waypointGeojson = { + type: 'FeatureCollection', + features: taskWayPoints, + }; + const fileBlob = new Blob([JSON.stringify(waypointGeojson)], { + type: 'application/json', + }); + const url = window.URL.createObjectURL(fileBlob); + const link = document.createElement('a'); + link.href = url; + link.download = 'waypoint.geojson'; + document.body.appendChild(link); + link.click(); + link.remove(); + window.URL.revokeObjectURL(url); + }; + return ( <>
@@ -117,15 +146,26 @@ const DroneOperatorDescriptionBox = () => {

Task #{taskDescription?.project_task_index}

- +
+ + +
{ From 7739ffa11581776f3b44b76bfe87bcfafeffd085 Mon Sep 17 00:00:00 2001 From: Sujit Date: Sun, 8 Sep 2024 10:47:29 +0545 Subject: [PATCH 7/8] feat(user-profile): hide country_code --- .../UserProfile/FormContents/BasicDetails/index.tsx | 4 ++-- src/frontend/src/constants/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/components/UserProfile/FormContents/BasicDetails/index.tsx b/src/frontend/src/components/UserProfile/FormContents/BasicDetails/index.tsx index 32f71cc8..dcbe178b 100644 --- a/src/frontend/src/components/UserProfile/FormContents/BasicDetails/index.tsx +++ b/src/frontend/src/components/UserProfile/FormContents/BasicDetails/index.tsx @@ -67,13 +67,13 @@ export default function BasicDetails({ formProps }: { formProps: any }) {
- + /> */} Date: Sun, 8 Sep 2024 10:49:48 +0545 Subject: [PATCH 8/8] fix(user-profile)-#191: issue on user profile update --- src/frontend/src/views/UserProfile/index.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/frontend/src/views/UserProfile/index.tsx b/src/frontend/src/views/UserProfile/index.tsx index 880fcc6c..207efd5f 100644 --- a/src/frontend/src/views/UserProfile/index.tsx +++ b/src/frontend/src/views/UserProfile/index.tsx @@ -55,20 +55,20 @@ const UserProfile = () => { const userProfileActiveTab = useTypedSelector( state => state.common.userProfileActiveTab, ); - const userProfile = getLocalStorageValue('userprofile'); const initialState = { name: userProfile?.name, - country: '', - city: null, + country: userProfile?.country || null, + city: userProfile?.city || null, password: null, confirm_password: null, - phone_number: null, + // country_code: userProfile?.country_code || null, + phone_number: userProfile?.phone_number || null, // for project creators - organization_name: null, - organization_address: null, - job_title: null, + organization_name: userProfile?.organization_name || null, + organization_address: userProfile?.organization_address || null, + job_title: userProfile?.job_title || null, // for drone operators notify_for_projects_within_km: null, experience_years: null, @@ -92,6 +92,7 @@ const UserProfile = () => { mutationFn: payloadDataObject => postUserProfile(payloadDataObject), onSuccess: () => { toast.success('UserProfile Updated Successfully'); + dispatch(setCommonState({ userProfileActiveTab: 1 })); navigate('/projects'); }, onError: err => { @@ -107,6 +108,7 @@ const UserProfile = () => { ); return; } + const finalFormData = isDroneOperator ? removeKeysFromObject(formData, projectCreatorKeys) : removeKeysFromObject(formData, droneOperatorKeys);