From 4187173416e26510a15d2525de9871f4e02c562d Mon Sep 17 00:00:00 2001 From: Victor Assis Date: Mon, 11 Nov 2024 08:11:24 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20Corrige=20bug=20de=20requisi?= =?UTF-8?q?=C3=A7=C3=A3o=20infinita=20das=20imagens=20do=20tixxi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../context-menu/components/camera-info.tsx | 15 +++--- .../map/components/context-menu/index.tsx | 47 +++++++++++++------ .../(app)/vision-ai/components/map/index.tsx | 1 + .../components/schemas/project-schema.ts | 3 +- src/app/(app)/vision-ai/new-project/page.tsx | 3 -- src/app/(app)/vision-ai/project/[id]/page.tsx | 10 ++-- src/server-cache/project.ts | 1 - src/server-cache/projects.ts | 1 - 8 files changed, 47 insertions(+), 34 deletions(-) diff --git a/src/app/(app)/vision-ai/components/map/components/context-menu/components/camera-info.tsx b/src/app/(app)/vision-ai/components/map/components/context-menu/components/camera-info.tsx index cb0b36e..b23fe70 100644 --- a/src/app/(app)/vision-ai/components/map/components/context-menu/components/camera-info.tsx +++ b/src/app/(app)/vision-ai/components/map/components/context-menu/components/camera-info.tsx @@ -33,31 +33,30 @@ const InfoItem = ({ export function CameraInfo({ pickingInfo, }: { - pickingInfo: PickingInfo + pickingInfo: PickingInfo | undefined | null }) { const [isLoading, setIsLoading] = useState(true) - const { object } = pickingInfo useEffect(() => { setIsLoading(true) - }, [object]) + }, [pickingInfo?.object]) return ( -
+

Câmera COR

- +
Streaming diff --git a/src/app/(app)/vision-ai/components/map/components/context-menu/index.tsx b/src/app/(app)/vision-ai/components/map/components/context-menu/index.tsx index 2c18ffc..d96b411 100644 --- a/src/app/(app)/vision-ai/components/map/components/context-menu/index.tsx +++ b/src/app/(app)/vision-ai/components/map/components/context-menu/index.tsx @@ -16,27 +16,26 @@ interface ContextMenuProps { pickingInfo: PickingInfo | null open: boolean onOpenChange: (open: boolean) => void + setContextMenuPickingInfo: (pickingInfo: PickingInfo | null) => void } export function ContextMenu({ pickingInfo, onOpenChange, + setContextMenuPickingInfo, open, }: ContextMenuProps) { const [cardRef, setCardRef] = useState(null) - if (!pickingInfo || !pickingInfo.object) return null - const { top, left } = calculateTooltipAbsolutePosition( - pickingInfo, - cardRef?.clientWidth, - cardRef?.clientHeight, - ) + const { top, left } = pickingInfo + ? calculateTooltipAbsolutePosition( + pickingInfo, + cardRef?.clientWidth, + cardRef?.clientHeight, + ) + : { top: 0, left: 0 } const Content = ({ pickingInfo }: { pickingInfo: PickingInfo }) => { - if (pickingInfo?.layer?.id === 'cameras') { - return - } - if (pickingInfo?.layer?.id === 'AISP') { return } @@ -50,12 +49,18 @@ export function ContextMenu({ } } + function handleOnOpenChange(e: boolean) { + if (e === false) { + setContextMenuPickingInfo(null) + onOpenChange(false) + } + onOpenChange(true) + } + return ( - - {pickingInfo.layer?.id && - ['cameras', 'AISP', 'CISP', 'schools'].includes( - pickingInfo.layer.id, - ) && ( + + {pickingInfo?.layer?.id && + ['AISP', 'CISP', 'schools'].includes(pickingInfo.layer.id) && ( setCardRef(ref)} style={{ @@ -68,6 +73,18 @@ export function ContextMenu({ )} + setCardRef(ref)} + style={{ + position: 'absolute', + top, + left, + width: '400px', + display: pickingInfo ? 'block' : 'none', + }} + > + + ) } diff --git a/src/app/(app)/vision-ai/components/map/index.tsx b/src/app/(app)/vision-ai/components/map/index.tsx index ae0d87f..3970d93 100644 --- a/src/app/(app)/vision-ai/components/map/index.tsx +++ b/src/app/(app)/vision-ai/components/map/index.tsx @@ -102,6 +102,7 @@ export default function Map({ mapboxAccessToken }: MapProps) { diff --git a/src/app/(app)/vision-ai/components/schemas/project-schema.ts b/src/app/(app)/vision-ai/components/schemas/project-schema.ts index c2aa39f..72c0b13 100644 --- a/src/app/(app)/vision-ai/components/schemas/project-schema.ts +++ b/src/app/(app)/vision-ai/components/schemas/project-schema.ts @@ -11,8 +11,7 @@ export const projectFormSchema = z yolo_default_precision: z.coerce .number({ message: 'Obrigatório' }) .min(0, { message: 'Deve ser entre 0 e 1' }) - .max(1, { message: 'Deve ser entre 0 e 1' }) - .optional(), + .max(1, { message: 'Deve ser entre 0 e 1' }), yolo_send_message: z.boolean().optional(), yolo_crowd_count: z .string() diff --git a/src/app/(app)/vision-ai/new-project/page.tsx b/src/app/(app)/vision-ai/new-project/page.tsx index c6cdb56..a299998 100644 --- a/src/app/(app)/vision-ai/new-project/page.tsx +++ b/src/app/(app)/vision-ai/new-project/page.tsx @@ -99,7 +99,6 @@ export default function Page() { useEffect(() => { async function initializeData() { getModelsAction().then((data) => { - console.log({ data }) setModels(data) return data }) @@ -110,8 +109,6 @@ export default function Page() { initializeData() }, []) - console.log({ models }) - return (