Added HPG validation

This commit is contained in:
PxlLoewe
2025-06-03 13:44:21 -07:00
parent 4acdb48344
commit ebb72c6517
14 changed files with 223 additions and 116 deletions

View File

@@ -41,8 +41,6 @@ export const SituationBoard = () => {
});
const { setOpenAircraftMarker, setOpenMissionMarker, setMap } = useMapStore((state) => state);
console.log("station", connectedAircrafts);
return (
<div className={cn("dropdown dropdown-top", situationTabOpen && "dropdown-open")}>
<div className="indicator">

View File

@@ -1,4 +1,4 @@
import { Marker, useMap } from "react-leaflet";
import { Marker, Polyline, useMap } from "react-leaflet";
import { DivIcon, Marker as LMarker, Popup as LPopup } from "leaflet";
import { useMapStore } from "_store/mapStore";
import { Fragment, useCallback, useEffect, useRef, useState, useMemo } from "react";
@@ -13,7 +13,7 @@ import FMSStatusHistory, {
} from "./_components/AircraftMarkerTabs";
import { ConnectedAircraft, Station } from "@repo/db";
import { useQuery } from "@tanstack/react-query";
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
import { getConnectedAircraftPositionLogAPI, getConnectedAircraftsAPI } from "_querys/aircrafts";
import { getMissionsAPI } from "_querys/missions";
import { checkSimulatorConnected } from "_helpers/simulatorConnected";
@@ -263,9 +263,18 @@ const AircraftMarker = ({ aircraft }: { aircraft: ConnectedAircraft & { Station:
const popupRef = useRef<LPopup>(null);
const { openAircraftMarker, setOpenAircraftMarker } = useMapStore((store) => store);
const { data: positionLog } = useQuery({
queryKey: ["positionlog", aircraft.id],
queryFn: () =>
getConnectedAircraftPositionLogAPI({
id: aircraft.id,
}),
refetchInterval: 10000,
});
useEffect(() => {
const handleClick = () => {
console.log("Marker clicked", aircraft.id);
const open = openAircraftMarker.some((m) => m.id === aircraft.id);
if (open) {
setOpenAircraftMarker({
@@ -289,7 +298,7 @@ const AircraftMarker = ({ aircraft }: { aircraft: ConnectedAircraft & { Station:
return () => {
marker?.off("click", handleClick);
};
}, [aircraft.id, openAircraftMarker, setOpenAircraftMarker]);
}, [aircraft.id, openAircraftMarker, setOpenAircraftMarker, markerRef.current]);
const [anchor, setAnchor] = useState<"topleft" | "topright" | "bottomleft" | "bottomright">(
"topleft",
@@ -372,38 +381,46 @@ const AircraftMarker = ({ aircraft }: { aircraft: ConnectedAircraft & { Station:
</div>`;
};
if (!aircraft.posLat || !aircraft.posLng) return null;
return (
<Fragment key={aircraft.id}>
{
<Marker
ref={markerRef}
position={[aircraft.posLat!, aircraft.posLng!]}
icon={
new DivIcon({
iconAnchor: [0, 0],
html: getMarkerHTML(aircraft, anchor),
})
}
/>
}
<Marker
ref={markerRef}
position={[aircraft.posLat, aircraft.posLng]}
icon={
new DivIcon({
iconAnchor: [0, 0],
html: getMarkerHTML(aircraft, anchor),
})
}
/>
{openAircraftMarker.some((m) => m.id === aircraft.id) && !hideMarker && (
<SmartPopup
options={{
ignoreCluster: true,
}}
id={`aircraft-${aircraft.id}`}
ref={popupRef}
position={[aircraft.posLat!, aircraft.posLng!]}
autoClose={false}
closeOnClick={false}
autoPan={false}
wrapperClassName="relative"
className="w-[502px]"
>
<div style={{ height: "auto", maxHeight: "90vh", overflowY: "auto" }}>
<AircraftPopupContent aircraft={aircraft} />
</div>
</SmartPopup>
<>
<SmartPopup
options={{
ignoreCluster: true,
}}
id={`aircraft-${aircraft.id}`}
ref={popupRef}
position={[aircraft.posLat!, aircraft.posLng!]}
autoClose={false}
closeOnClick={false}
autoPan={false}
wrapperClassName="relative"
className="w-[502px]"
>
<div style={{ height: "auto", maxHeight: "90vh", overflowY: "auto" }}>
<AircraftPopupContent aircraft={aircraft} />
</div>
</SmartPopup>
<Polyline
pathOptions={{
color: "var(--color-rescuetrack)",
weight: 3,
}}
positions={positionLog?.map((pos) => [pos.lat, pos.lng]) || []}
/>
</>
)}
</Fragment>
);

View File

@@ -29,6 +29,7 @@ import {
Hash,
ListCollapse,
LocateFixed,
Lollipop,
MapPin,
Mountain,
Navigation,
@@ -252,6 +253,14 @@ const RettungsmittelTab = ({
<CircleGaugeIcon size={16} /> ALT: {aircraft.posAlt} ft
</span>
</div>
<div className="flex items-center text-sm font-semibold justify-between pr-2 mt-2">
<span className="flex items-center gap-2">
<Lollipop size={16} />{" "}
<span className={cn(aircraft.posH145active && "text-green-500")}>
{aircraft.posH145active ? "H145 Aktiv" : "H145 Inaktiv"}
</span>
</span>
</div>
</div>
);
};
@@ -306,8 +315,14 @@ const SDSTab = ({
const dispatcherConnected = useDispatchConnectionStore((s) => s.status) === "connected";
const sendSdsMutation = useMutation({
mutationFn: async ({ id, message }: { id: number; message: MissionSdsLog }) => {
await sendSdsMessageAPI(id, message);
mutationFn: async ({
missionId,
sdsMessage,
}: {
missionId?: number;
sdsMessage: MissionSdsLog;
}) => {
await sendSdsMessageAPI({ missionId, sdsMessage });
queryClient.invalidateQueries({
queryKey: ["missions"],
});
@@ -348,11 +363,10 @@ const SDSTab = ({
<button
className="btn btn-sm btn-primary btn-outline"
onClick={() => {
if (!mission) return;
sendSdsMutation
.mutateAsync({
id: mission.id,
message: {
missionId: mission?.id,
sdsMessage: {
type: "sds-log",
auto: false,
timeStamp: new Date().toISOString(),