added alert popup on hotlist, upload hotlist and added hotlist tag
This commit is contained in:
8
.env
8
.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_TESTURL=http://100.82.205.44/SightingListRear/sightingSummary?mostRecentRef=-1
|
||||||
VITE_OUTSIDE_BASEURL=http://100.82.205.44/api
|
VITE_OUTSIDE_BASEURL=http://100.82.205.44/api
|
||||||
VITE_FOLKESTONE_URL=http://100.116.253.81/mergedHistory/sightingSummary?mostRecentRef=
|
VITE_FOLKESTONE_URL=http://100.116.253.81/mergedHistory/sightingSummary?mostRecentRef=
|
||||||
VITE_MAV_URL=http://192.168.75.11/SightingListFront/sightingSummary?mostRecentRef=
|
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=
|
||||||
18
public/Hotlist_Hit.svg
Normal file
18
public/Hotlist_Hit.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 18 KiB |
@@ -14,7 +14,7 @@ const NPEDHotlist = () => {
|
|||||||
opts: {
|
opts: {
|
||||||
timeoutMs: 30000,
|
timeoutMs: 30000,
|
||||||
fieldName: "upload",
|
fieldName: "upload",
|
||||||
uploadUrl: "http://192.168.75.11/upload/hotlist-upload/2",
|
uploadUrl: "http://192.168.0.90:8080/upload/hotlist-upload/2",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export async function sendBlobFileUpload({
|
|||||||
`Upload failed (${resp.status} ${resp.statusText}) from ${opts.uploadUrl} — ${bodyText}`
|
`Upload failed (${resp.status} ${resp.statusText}) from ${opts.uploadUrl} — ${bodyText}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bodyText;
|
return bodyText;
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
if (err instanceof DOMException && err.name === "AbortError") {
|
if (err instanceof DOMException && err.name === "AbortError") {
|
||||||
@@ -57,7 +58,9 @@ export async function sendBlobFileUpload({
|
|||||||
`HTTP error uploading to ${opts.uploadUrl}: ${err.message}`
|
`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 {
|
} finally {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import ModalComponent from "../UI/ModalComponent";
|
|||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { useAlertHitContext } from "../../context/AlertHitContext";
|
import { useAlertHitContext } from "../../context/AlertHitContext";
|
||||||
import { toast, Toaster } from "sonner";
|
import { toast, Toaster } from "sonner";
|
||||||
|
import HotListImg from "/Hotlist_Hit.svg";
|
||||||
|
|
||||||
type SightingModalProps = {
|
type SightingModalProps = {
|
||||||
isSightingModalOpen: boolean;
|
isSightingModalOpen: boolean;
|
||||||
@@ -31,6 +32,7 @@ const SightingModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const motionAway = (sighting?.motion ?? "").toUpperCase() === "AWAY";
|
const motionAway = (sighting?.motion ?? "").toUpperCase() === "AWAY";
|
||||||
|
const isHotListHit = sighting?.metadata?.hotlistMatches?.Hotlist0 === true;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -41,13 +43,20 @@ const SightingModal = ({
|
|||||||
Sighting Details
|
Sighting Details
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col md:flex-row gap-3 items-center">
|
<div className="flex flex-col md:flex-row gap-3 items-center mb-2">
|
||||||
<NumberPlate vrm={sighting?.vrm} motion={motionAway} />
|
<NumberPlate vrm={sighting?.vrm} motion={motionAway} />
|
||||||
<img
|
<img
|
||||||
src={sighting?.plateUrlColour}
|
src={sighting?.plateUrlColour}
|
||||||
alt="plate patch"
|
alt="plate patch"
|
||||||
className="h-16 object-contain rounded-md"
|
className="h-16 object-contain rounded-md"
|
||||||
/>
|
/>
|
||||||
|
{isHotListHit && (
|
||||||
|
<img
|
||||||
|
src={HotListImg}
|
||||||
|
alt="hotlistHit"
|
||||||
|
className="h-18 object-contain rounded-md"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col md:flex-row items-center gap-3">
|
<div className="flex flex-col md:flex-row items-center gap-3">
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -5,24 +5,25 @@ type InfoBarprops = {
|
|||||||
obj: SightingType;
|
obj: SightingType;
|
||||||
};
|
};
|
||||||
const InfoBar = ({ obj }: InfoBarprops) => {
|
const InfoBar = ({ obj }: InfoBarprops) => {
|
||||||
const isNPEDHit = obj?.metadata?.npedJSON?.status_code === 404;
|
// const isNPEDHit = obj?.metadata?.npedJSON?.status_code === 404;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3 text-xs bg-neutral-900 px-2 py-1 rounded justify-between">
|
<div className="flex items-center gap-3 text-xs bg-neutral-900 px-2 py-1 rounded justify-between">
|
||||||
<div className="flex items-center gap-3 text-xs">
|
<div className="flex items-center gap-3 text-xs">
|
||||||
<div className="min-w-14">CH: {obj ? obj.charHeight : "—"}</div>
|
<div className="min-w-14">CH: {obj ? obj.charHeight : "—"}</div>
|
||||||
<div className="min-w-14">Seen: {obj ? obj.seenCount : "—"}</div>
|
<div className="min-w-14">Seen: {obj ? obj.seenCount : "—"}</div>
|
||||||
<div className="min-w-20">{obj ? capitalize(obj.motion) : "—"}</div>
|
<div className="min-w-20">{obj ? capitalize(obj.motion) : "—"}</div>
|
||||||
<div className="min-w-14 opacity-80">
|
<div className="min-w-14 opacity-80 text-md">
|
||||||
{obj ? formatAge(obj.timeStampMillis) : "—"}
|
{obj ? formatAge(obj.timeStampMillis) : "—"}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="min-w-14 opacity-80 ">
|
<div className="min-w-14 opacity-80 ">
|
||||||
{isNPEDHit ? (
|
{/* {isNPEDHit ? (
|
||||||
<span className="text-red-500 font-semibold">NPED HIT</span>
|
<span className="text-red-500 font-semibold">NPED HIT</span>
|
||||||
) : (
|
) : (
|
||||||
""
|
""
|
||||||
)}
|
)} */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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 type { SightingType } from "../../types/types";
|
||||||
import { BLANK_IMG } from "../../utils/utils";
|
import { BLANK_IMG } from "../../utils/utils";
|
||||||
import NumberPlate from "../PlateStack/NumberPlate";
|
import NumberPlate from "../PlateStack/NumberPlate";
|
||||||
@@ -46,6 +46,8 @@ export default function SightingHistoryWidget({
|
|||||||
|
|
||||||
const { dispatch } = useAlertHitContext();
|
const { dispatch } = useAlertHitContext();
|
||||||
|
|
||||||
|
const hasAutoOpenedRef = useRef(false);
|
||||||
|
|
||||||
const onRowClick = useCallback(
|
const onRowClick = useCallback(
|
||||||
(sighting: SightingType) => {
|
(sighting: SightingType) => {
|
||||||
if (!sighting) return;
|
if (!sighting) return;
|
||||||
@@ -54,6 +56,7 @@ export default function SightingHistoryWidget({
|
|||||||
},
|
},
|
||||||
[isSightingModalOpen, setSelectedSighting, setSightingModalOpen]
|
[isSightingModalOpen, setSelectedSighting, setSightingModalOpen]
|
||||||
);
|
);
|
||||||
|
|
||||||
const rows = useMemo(
|
const rows = useMemo(
|
||||||
() => sightings?.filter(Boolean) as SightingType[],
|
() => sightings?.filter(Boolean) as SightingType[],
|
||||||
[sightings]
|
[sightings]
|
||||||
@@ -72,6 +75,18 @@ export default function SightingHistoryWidget({
|
|||||||
});
|
});
|
||||||
}, [rows, dispatch]);
|
}, [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 = () => {
|
const handleClose = () => {
|
||||||
setSightingModalOpen(false);
|
setSightingModalOpen(false);
|
||||||
};
|
};
|
||||||
@@ -83,7 +98,7 @@ export default function SightingHistoryWidget({
|
|||||||
{/* Rows */}
|
{/* Rows */}
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
{rows?.map((obj, idx) => {
|
{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 motionAway = (obj?.motion ?? "").toUpperCase() === "AWAY";
|
||||||
const primaryIsColour = obj?.srcCam === 1;
|
const primaryIsColour = obj?.srcCam === 1;
|
||||||
const secondaryMissing = (obj?.vrmSecondary ?? "") === "";
|
const secondaryMissing = (obj?.vrmSecondary ?? "") === "";
|
||||||
@@ -100,7 +115,7 @@ export default function SightingHistoryWidget({
|
|||||||
{/* Patch row */}
|
{/* Patch row */}
|
||||||
<div
|
<div
|
||||||
className={`flex items-center gap-3 mt-2 justify-between
|
className={`flex items-center gap-3 mt-2 justify-between
|
||||||
${isNPEDHit ? "border border-red-600" : ""}
|
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{obj?.plateUrlInfrared && (
|
{obj?.plateUrlInfrared && (
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import SightingHistoryWidget from "../components/SightingsWidget/SightingWidget"
|
|||||||
import { SightingFeedProvider } from "../context/providers/SightingFeedProvider";
|
import { SightingFeedProvider } from "../context/providers/SightingFeedProvider";
|
||||||
|
|
||||||
const Dashboard = () => {
|
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 (
|
return (
|
||||||
<div className="mx-auto grid grid-cols-1 sm:grid-cols-1 lg:grid-cols-2 gap-2 px-1 sm:px-2 lg:px-0 w-full">
|
<div className="mx-auto grid grid-cols-1 sm:grid-cols-1 lg:grid-cols-2 gap-2 px-1 sm:px-2 lg:px-0 w-full">
|
||||||
<SightingFeedProvider url={folkestoneUrl} side="Front">
|
<SightingFeedProvider url={testFront} side="Front">
|
||||||
<FrontCameraOverviewCard className="order-1" />
|
<FrontCameraOverviewCard className="order-1" />
|
||||||
<SightingHistoryWidget
|
<SightingHistoryWidget
|
||||||
className="order-3"
|
className="order-3"
|
||||||
@@ -16,7 +18,7 @@ const Dashboard = () => {
|
|||||||
/>
|
/>
|
||||||
</SightingFeedProvider>
|
</SightingFeedProvider>
|
||||||
|
|
||||||
<SightingFeedProvider url={folkestoneUrl} side="Rear">
|
<SightingFeedProvider url={test} side="Rear">
|
||||||
<RearCameraOverviewCard className="order-2" />
|
<RearCameraOverviewCard className="order-2" />
|
||||||
<SightingHistoryWidget
|
<SightingHistoryWidget
|
||||||
className="order-4"
|
className="order-4"
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ export type VersionFieldType = {
|
|||||||
export type Metadata = {
|
export type Metadata = {
|
||||||
npedJSON: NpedJSON;
|
npedJSON: NpedJSON;
|
||||||
"hotlist-matches": HotlistMatches;
|
"hotlist-matches": HotlistMatches;
|
||||||
|
hotlistMatches: HotlistMatches;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type HotlistMatches = {
|
export type HotlistMatches = {
|
||||||
|
|||||||
Reference in New Issue
Block a user