Skip to content

Commit

Permalink
Merge pull request #456 from hotosm/feat/UI-fixes
Browse files Browse the repository at this point in the history
Feat/UI fixes
  • Loading branch information
nrjadkry authored Jan 30, 2025
2 parents b6e029f + b74b87a commit d6c6db2
Show file tree
Hide file tree
Showing 29 changed files with 1,074 additions and 330 deletions.
1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tooltip": "^1.0.6",
"@react-spring/web": "^9.7.5",
"@reduxjs/toolkit": "^1.9.3",
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/react-query": "^4.32.6",
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function App() {
// add routes where you dont want navigation bar
const routesWithoutNavbar = [
'/',
'/tutorials',
'/login',
'/forgot-password',
'/complete-profile',
Expand Down
28 changes: 14 additions & 14 deletions src/frontend/src/api/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/prefer-default-export */
import {
getIndividualTask,
// getTaskAssetsInfo,
getTaskAssetsInfo,
getTaskWaypoint,
} from '@Services/tasks';
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
Expand Down Expand Up @@ -35,16 +35,16 @@ export const useGetIndividualTaskQuery = (
});
};

// export const useGetTaskAssetsInfo = (
// projectId: string,
// taskId: string,
// queryOptions?: Partial<UseQueryOptions>,
// ) => {
// return useQuery({
// queryKey: ['task-assets-info'],
// enabled: !!taskId,
// queryFn: () => getTaskAssetsInfo(projectId, taskId),
// select: (res: any) => res.data,
// ...queryOptions,
// });
// };
export const useGetTaskAssetsInfo = (
projectId: string,
taskId: string,
queryOptions?: Partial<UseQueryOptions>,
) => {
return useQuery({
queryKey: ['task-assets-info'],
enabled: !!taskId,
queryFn: () => getTaskAssetsInfo(projectId, taskId),
select: (res: any) => res.data,
...queryOptions,
});
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { useEffect, useMemo, useState } from 'react';
import { useParams } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { toast } from 'react-toastify';
import { useGetIndividualTaskQuery, useGetTaskWaypointQuery } from '@Api/tasks';
import {
useGetIndividualTaskQuery,
useGetTaskAssetsInfo,
useGetTaskWaypointQuery,
} from '@Api/tasks';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { postProcessImagery } from '@Services/tasks';
import { formatString } from '@Utils/index';
Expand All @@ -12,7 +16,7 @@ import SwitchTab from '@Components/common/SwitchTab';
import {
resetFilesExifData,
setSelectedTaskDetailToViewOrthophoto,
setTaskAssetsInformation,
// setTaskAssetsInformation,
setUploadedImagesType,
} from '@Store/actions/droneOperatorTask';
import { useTypedSelector } from '@Store/hooks';
Expand Down Expand Up @@ -51,6 +55,14 @@ const DescriptionBox = () => {
},
);

const {
data: taskAssetsInformation,
// isFetching: taskAssetsInfoLoading,
}: Record<string, any> = useGetTaskAssetsInfo(
projectId as string,
taskId as string,
);

const { mutate: updateStatus, isLoading: statusUpdating } = useMutation<
any,
any,
Expand Down Expand Up @@ -169,27 +181,27 @@ const DescriptionBox = () => {
},
],
},
{
total_image_uploaded: taskData?.total_image_uploaded || 0,
assets_url: taskData?.assets_url,
state: taskData?.state,
},
// {
// total_image_uploaded: taskData?.total_image_uploaded || 0,
// assets_url: taskData?.assets_url,
// state: taskData?.state,
// },
];
},
});

const taskAssetsInformation = useMemo(() => {
if (!taskDescription) return {};
dispatch(setTaskAssetsInformation(taskDescription?.[2]));
return taskDescription?.[2];
}, [taskDescription, dispatch]);
// const taskAssetsInformation = useMemo(() => {
// if (!taskDescription) return {};
// dispatch(setTaskAssetsInformation(taskDescription?.[2]));
// return taskDescription?.[2];
// }, [taskDescription, dispatch]);

const handleDownloadResult = () => {
if (!taskAssetsInformation?.assets_url) return;
try {
const link = document.createElement('a');
link.href = taskAssetsInformation?.assets_url;
link.download = `${projectId}-${taskId}.tif`;
link.setAttribute('download', '');
document.body.appendChild(link);
link.click();
link.remove();
Expand All @@ -215,20 +227,20 @@ const DescriptionBox = () => {
))}
</div>

{taskAssetsInformation?.total_image_uploaded === 0 && (
{taskAssetsInformation?.image_count === 0 && (
<QuestionBox
setFlyable={setFlyable}
flyable={flyable}
haveNoImages={taskAssetsInformation?.total_image_uploaded === 0}
haveNoImages={taskAssetsInformation?.image_count === 0}
/>
)}
{taskAssetsInformation?.total_image_uploaded > 0 && (
{taskAssetsInformation?.image_count > 0 && (
<div className="naxatw-flex naxatw-flex-col naxatw-gap-5">
<UploadsInformation
data={[
{
name: 'Image count',
value: taskAssetsInformation?.total_image_uploaded,
value: taskAssetsInformation?.image_count,
},
{
name: 'Orthophoto available',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import getBbox from '@turf/bbox';
import { point } from '@turf/helpers';
import { coordAll } from '@turf/meta';
import { useTypedSelector } from '@Store/hooks';
import { useGetIndividualTaskQuery, useGetTaskWaypointQuery } from '@Api/tasks';
import {
useGetIndividualTaskQuery,
useGetTaskAssetsInfo,
useGetTaskWaypointQuery,
} from '@Api/tasks';
import { postTaskWaypoint } from '@Services/tasks';
import { useMapLibreGLMap } from '@Components/common/MapLibreComponents';
import { GeojsonType } from '@Components/common/MapLibreComponents/types';
Expand Down Expand Up @@ -76,9 +80,9 @@ const MapSection = ({ className }: { className?: string }) => {
const newTakeOffPoint = useTypedSelector(
state => state.droneOperatorTask.selectedTakeOffPoint,
);
const taskAssetsInformation = useTypedSelector(
state => state.droneOperatorTask.taskAssetsInformation,
);
// const taskAssetsInformation = useTypedSelector(
// state => state.droneOperatorTask.taskAssetsInformation,
// );
const rotatedFlightPlanData = useTypedSelector(
state => state.droneOperatorTask.rotatedFlightPlan,
);
Expand Down Expand Up @@ -137,6 +141,14 @@ const MapSection = ({ className }: { className?: string }) => {
},
);

const {
data: taskAssetsInformation,
// isFetching: taskAssetsInfoLoading,
}: Record<string, any> = useGetTaskAssetsInfo(
projectId as string,
taskId as string,
);

const { mutate: postWaypoint, isLoading: isUpdatingTakeOffPoint } =
useMutation<any, any, any, unknown>({
mutationFn: postTaskWaypoint,
Expand Down
Loading

0 comments on commit d6c6db2

Please sign in to comment.