Skip to content

Commit

Permalink
Merge pull request #245 from hotosm/feat/user-profile
Browse files Browse the repository at this point in the history
Feat: Trigger image processing starter api
  • Loading branch information
nrjadkry authored Sep 30, 2024
2 parents 475944c + aee06e9 commit 874ae3e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default function GenerateTask({ formProps }: { formProps: any }) {
onFocus={() => setError('')}
/>
{error && <ErrorMessage message={error} />}
<p className="naxatw-text-[#68707F]">Recommended : 50-700</p>
</FormControl>
<Button
withLoader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-console */
/* eslint-disable no-unused-vars */
import { useMutation } from '@tanstack/react-query';
import { motion } from 'framer-motion';
import { useEffect, useRef, useState } from 'react';

import { motion } from 'framer-motion';
import { toast } from 'react-toastify';
import { Button } from '@Components/RadixComponents/Button';
import { getImageUploadLink } from '@Services/droneOperator';
import { useMutation } from '@tanstack/react-query';
import {
checkAllImages,
setCheckedImages,
Expand All @@ -19,6 +19,8 @@ import callApiSimultaneously from '@Utils/callApiSimultaneously';
import chunkArray from '@Utils/createChunksOfArray';
import delay from '@Utils/createDelay';
import widthCalulator from '@Utils/percentageCalculator';
import { postProcessImagery } from '@Services/tasks';

import FilesUploadingPopOver from '../LoadingBox';
import ImageCard from './ImageCard';
import PreviewImage from './PreviewImage';
Expand All @@ -31,7 +33,6 @@ import PreviewImage from './PreviewImage';
const ImageBoxPopOver = () => {
const dispatch = useTypedDispatch();

// const { taskId, projectId } = useParams();
const pathname = window.location.pathname?.split('/');
const projectId = pathname?.[2];
const taskId = pathname?.[4];
Expand All @@ -50,6 +51,11 @@ const ImageBoxPopOver = () => {
state => state.droneOperatorTask.checkedImages,
);

const { mutate: startImageryProcess } = useMutation({
mutationFn: () => postProcessImagery(projectId, taskId),
onSuccess: () => toast.success('Image processing started'),
});

// function that gets the signed urls for the images and again puts them in chunks of 4
const { mutate } = useMutation({
mutationFn: async (data: any) => {
Expand All @@ -75,6 +81,7 @@ const ImageBoxPopOver = () => {
await delay(500);
}
}
startImageryProcess();
},
});

Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/services/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ export const postTaskWaypoint = (payload: Record<string, any>) => {
};
export const getTaskAssetsInfo = (projectId: string, taskId: string) =>
authenticated(api).get(`/projects/assets/${projectId}/${taskId}/`);

export const postProcessImagery = (projectId: string, taskId: string) =>
authenticated(api).post(`/projects/process_imagery/${projectId}/${taskId}`);

0 comments on commit 874ae3e

Please sign in to comment.