From f5b4620067c83b8d12912f49a4dd6c9feb0a19ad Mon Sep 17 00:00:00 2001 From: Bijay Rauniyar Date: Mon, 16 Dec 2024 09:29:32 +0545 Subject: [PATCH 1/4] feat: implement api to save rotated flight plan --- .../DroneOperatorTask/MapSection/index.tsx | 34 +++++++++++++++++-- src/frontend/src/services/tasks.ts | 7 ++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx b/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx index a1afa300..85687da6 100644 --- a/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx @@ -16,7 +16,7 @@ import LocateUser from '@Components/common/MapLibreComponents/LocateUser'; import MapContainer from '@Components/common/MapLibreComponents/MapContainer'; import { GeojsonType } from '@Components/common/MapLibreComponents/types'; import { Button } from '@Components/RadixComponents/Button'; -import { postTaskWaypoint } from '@Services/tasks'; +import { postRotatedTaskWayPoint, postTaskWaypoint } from '@Services/tasks'; import AsyncPopup from '@Components/common/MapLibreComponents/NewAsyncPopup'; import { toggleModal } from '@Store/actions/common'; import { @@ -480,6 +480,31 @@ const MapSection = ({ className }: { className?: string }) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [dragging, isMapLoaded, map]); + const { mutate: postRotatedFlightPlan, isLoading: flighplanIsUpdating } = + useMutation({ + mutationFn: postRotatedTaskWayPoint, + onSuccess: () => { + toast.success('Flight plan rotated successfully'); + queryClient.invalidateQueries(['task-waypoints']); + }, + onError: (err: any) => { + toast.error(err?.response?.data?.detail || err.message); + }, + }); + + function handeSaveRotatedFlightPlan() { + if (!map || !isMapLoaded) return; + const pointsSource = map.getSource('waypoint-points'); + + if (pointsSource && pointsSource instanceof GeoJSONSource) { + const pointsData = pointsSource?._data; + postRotatedFlightPlan({ + taskId, + data: JSON.stringify(pointsData), + }); + } + } + return ( <>
{ withLoader leftIcon="save" className="naxatw-w-[10.8rem] naxatw-bg-red" + isLoading={flighplanIsUpdating} + disabled={rotationAngle === 0} + onClick={() => handeSaveRotatedFlightPlan()} >

Save Rotated Flight Plan

{/*

- Rotated: {rotationAngle.toFixed(2)}° -

*/} + Rotated: {rotationAngle.toFixed(2)}° +

*/}
diff --git a/src/frontend/src/services/tasks.ts b/src/frontend/src/services/tasks.ts index d1bb3d2c..135e62c4 100644 --- a/src/frontend/src/services/tasks.ts +++ b/src/frontend/src/services/tasks.ts @@ -23,3 +23,10 @@ export const getTaskAssetsInfo = (projectId: string, taskId: string) => export const postProcessImagery = (projectId: string, taskId: string) => authenticated(api).post(`/projects/process_imagery/${projectId}/${taskId}/`); + +export const postRotatedTaskWayPoint = (payload: Record) => { + const { taskId, data } = payload; + return authenticated(api).post(`/waypoint/${taskId}/generate-kmz/`, data, { + headers: { 'Content-Type': 'application/json' }, + }); +}; From 095df356d07d45b89a26725c47bd6d1563130c52 Mon Sep 17 00:00:00 2001 From: Bijay Rauniyar Date: Mon, 16 Dec 2024 09:31:24 +0545 Subject: [PATCH 2/4] refactor: remove type from flightPlan mutation --- .../src/components/DroneOperatorTask/MapSection/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx b/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx index 85687da6..81ef5326 100644 --- a/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx @@ -481,7 +481,7 @@ const MapSection = ({ className }: { className?: string }) => { }, [dragging, isMapLoaded, map]); const { mutate: postRotatedFlightPlan, isLoading: flighplanIsUpdating } = - useMutation({ + useMutation({ mutationFn: postRotatedTaskWayPoint, onSuccess: () => { toast.success('Flight plan rotated successfully'); From 7330fffaf75acd97a1a3e184e22339de5d88dea6 Mon Sep 17 00:00:00 2001 From: Bijay Rauniyar Date: Mon, 16 Dec 2024 09:56:21 +0545 Subject: [PATCH 3/4] refactor: update condition to show update image button --- .../DescriptionBox/index.tsx | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/DescriptionBox/index.tsx b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/DescriptionBox/index.tsx index 23673ee9..f87c5cdc 100644 --- a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/DescriptionBox/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/DescriptionBox/index.tsx @@ -291,42 +291,43 @@ const DescriptionBox = () => { )} - {taskAssetsInformation?.state === 'IMAGE_PROCESSING_FAILED' && ( -
-
+ ))} )} From 9f61c057994e7b33545d40f7ceee3e68670ab185 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 04:13:35 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/frontend/src/constants/createProject.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/frontend/src/constants/createProject.tsx b/src/frontend/src/constants/createProject.tsx index 3c3baaad..f5cabcc2 100644 --- a/src/frontend/src/constants/createProject.tsx +++ b/src/frontend/src/constants/createProject.tsx @@ -321,4 +321,3 @@ export const demFileOptions = [ }, { name: 'Upload DEM File', label: 'Upload DEM File', value: 'manual' }, ]; -