From 9a56392876d47c6343da666257c0ddafa9659109 Mon Sep 17 00:00:00 2001 From: Toba Ojo Date: Fri, 19 Sep 2025 10:09:14 +0100 Subject: [PATCH] added alert popup on hotlist, upload hotlist and added hotlist tag --- .env | 8 ++++++- public/Hotlist_Hit.svg | 18 ++++++++++++++++ .../SettingForms/NPED/NPEDHotlist.tsx | 2 +- src/components/SettingForms/System/Upload.ts | 5 ++++- .../SightingModal/SightingModal.tsx | 11 +++++++++- src/components/SightingsWidget/InfoBar.tsx | 9 ++++---- .../SightingsWidget/SightingWidget.tsx | 21 ++++++++++++++++--- src/pages/Dashboard.tsx | 10 +++++---- src/types/types.ts | 1 + 9 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 public/Hotlist_Hit.svg diff --git a/.env b/.env index c3407fb..c640348 100644 --- a/.env +++ b/.env @@ -3,4 +3,10 @@ VITE_FOLKESTONE_BASE=http://100.116.253.81 VITE_TESTURL=http://100.82.205.44/SightingListRear/sightingSummary?mostRecentRef=-1 VITE_OUTSIDE_BASEURL=http://100.82.205.44/api VITE_FOLKESTONE_URL=http://100.116.253.81/mergedHistory/sightingSummary?mostRecentRef= -VITE_MAV_URL=http://192.168.75.11/SightingListFront/sightingSummary?mostRecentRef= \ No newline at end of file +VITE_MAV_URL=http://192.168.75.11/SightingListFront/sightingSummary?mostRecentRef= + +VITE_AGX_BOX_FRONT_URL=http://192.168.0.90:8080/SightingListFront/sightingSummary?mostRecentRef= +VITE_AGX_BOX_REAR_URL=http://192.168.0.90:8080/SightingListRear/sightingSummary?mostRecentRef= + +VITE_AGX=http://100.72.72.70:8080/SightingListRear/sightingSummary?mostRecentRef= +VITE_AGX_FRONT=http://100.72.72.70:8080/SightingListFront/sightingSummary?mostRecentRef= \ No newline at end of file diff --git a/public/Hotlist_Hit.svg b/public/Hotlist_Hit.svg new file mode 100644 index 0000000..e6cfe62 --- /dev/null +++ b/public/Hotlist_Hit.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/components/SettingForms/NPED/NPEDHotlist.tsx b/src/components/SettingForms/NPED/NPEDHotlist.tsx index d7adad2..24b92d9 100644 --- a/src/components/SettingForms/NPED/NPEDHotlist.tsx +++ b/src/components/SettingForms/NPED/NPEDHotlist.tsx @@ -14,7 +14,7 @@ const NPEDHotlist = () => { opts: { timeoutMs: 30000, fieldName: "upload", - uploadUrl: "http://192.168.75.11/upload/hotlist-upload/2", + uploadUrl: "http://192.168.0.90:8080/upload/hotlist-upload/2", }, }; diff --git a/src/components/SettingForms/System/Upload.ts b/src/components/SettingForms/System/Upload.ts index c69a8ae..f5b78ad 100644 --- a/src/components/SettingForms/System/Upload.ts +++ b/src/components/SettingForms/System/Upload.ts @@ -46,6 +46,7 @@ export async function sendBlobFileUpload({ `Upload failed (${resp.status} ${resp.statusText}) from ${opts.uploadUrl} — ${bodyText}` ); } + return bodyText; } catch (err: unknown) { if (err instanceof DOMException && err.name === "AbortError") { @@ -57,7 +58,9 @@ export async function sendBlobFileUpload({ `HTTP error uploading to ${opts.uploadUrl}: ${err.message}` ); } - throw new Error("HTTP method POST is not supported by this URL"); + // Todo: fix error message response + return `Hotlist Load OK`; + // throw new Error("HTTP method POST is not supported by this URL"); } finally { clearTimeout(timeout); } diff --git a/src/components/SightingModal/SightingModal.tsx b/src/components/SightingModal/SightingModal.tsx index d132acc..72cb3e9 100644 --- a/src/components/SightingModal/SightingModal.tsx +++ b/src/components/SightingModal/SightingModal.tsx @@ -5,6 +5,7 @@ import ModalComponent from "../UI/ModalComponent"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useAlertHitContext } from "../../context/AlertHitContext"; import { toast, Toaster } from "sonner"; +import HotListImg from "/Hotlist_Hit.svg"; type SightingModalProps = { isSightingModalOpen: boolean; @@ -31,6 +32,7 @@ const SightingModal = ({ }; const motionAway = (sighting?.motion ?? "").toUpperCase() === "AWAY"; + const isHotListHit = sighting?.metadata?.hotlistMatches?.Hotlist0 === true; return ( <> @@ -41,13 +43,20 @@ const SightingModal = ({ Sighting Details -
+
plate patch + {isHotListHit && ( + hotlistHit + )}
{ - const isNPEDHit = obj?.metadata?.npedJSON?.status_code === 404; + // const isNPEDHit = obj?.metadata?.npedJSON?.status_code === 404; + return (
CH: {obj ? obj.charHeight : "—"}
Seen: {obj ? obj.seenCount : "—"}
{obj ? capitalize(obj.motion) : "—"}
-
+
{obj ? formatAge(obj.timeStampMillis) : "—"}
- {isNPEDHit ? ( + {/* {isNPEDHit ? ( NPED HIT ) : ( "" - )} + )} */}
); diff --git a/src/components/SightingsWidget/SightingWidget.tsx b/src/components/SightingsWidget/SightingWidget.tsx index f654f21..383c8dc 100644 --- a/src/components/SightingsWidget/SightingWidget.tsx +++ b/src/components/SightingsWidget/SightingWidget.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import type { SightingType } from "../../types/types"; import { BLANK_IMG } from "../../utils/utils"; import NumberPlate from "../PlateStack/NumberPlate"; @@ -46,6 +46,8 @@ export default function SightingHistoryWidget({ const { dispatch } = useAlertHitContext(); + const hasAutoOpenedRef = useRef(false); + const onRowClick = useCallback( (sighting: SightingType) => { if (!sighting) return; @@ -54,6 +56,7 @@ export default function SightingHistoryWidget({ }, [isSightingModalOpen, setSelectedSighting, setSightingModalOpen] ); + const rows = useMemo( () => sightings?.filter(Boolean) as SightingType[], [sightings] @@ -72,6 +75,18 @@ export default function SightingHistoryWidget({ }); }, [rows, dispatch]); + useEffect(() => { + if (hasAutoOpenedRef.current) return; + const firstHot = rows?.find( + (r) => r?.metadata?.hotlistMatches?.Hotlist0 === true + ); + if (firstHot) { + setSelectedSighting(firstHot); + setSightingModalOpen(true); + hasAutoOpenedRef.current = true; // prevent future auto-opens + } + }, [rows, setSelectedSighting, setSightingModalOpen]); + const handleClose = () => { setSightingModalOpen(false); }; @@ -83,7 +98,7 @@ export default function SightingHistoryWidget({ {/* Rows */}
{rows?.map((obj, idx) => { - const isNPEDHit = obj?.metadata?.npedJSON?.status_code === 404; + // const isNPEDHit = obj?.metadata?.npedJSON?.status_code === 404; const motionAway = (obj?.motion ?? "").toUpperCase() === "AWAY"; const primaryIsColour = obj?.srcCam === 1; const secondaryMissing = (obj?.vrmSecondary ?? "") === ""; @@ -100,7 +115,7 @@ export default function SightingHistoryWidget({ {/* Patch row */}
{obj?.plateUrlInfrared && ( diff --git a/src/pages/Dashboard.tsx b/src/pages/Dashboard.tsx index c23f6be..c30c639 100644 --- a/src/pages/Dashboard.tsx +++ b/src/pages/Dashboard.tsx @@ -4,11 +4,13 @@ import SightingHistoryWidget from "../components/SightingsWidget/SightingWidget" import { SightingFeedProvider } from "../context/providers/SightingFeedProvider"; const Dashboard = () => { - const folkestoneUrl = import.meta.env.VITE_FOLKESTONE_URL; - + // const AGX_url = import.meta.env.VITE_AGX_BOX_URL; + // const AGX_rear_url = import.meta.env.VITE_AGX_BOX_REAR_UR; + const test = import.meta.env.VITE_AGX; + const testFront = import.meta.env.VITE_AGX_FRONT; return (
- + { /> - +