Ealisitische Sequenz im HEader vom call-Bildschirm im MRT
This commit is contained in:
@@ -6,7 +6,7 @@ import PAGE_HOME from "./images/PAGE_Home.png";
|
|||||||
import PAGE_Call from "./images/PAGE_Call.png";
|
import PAGE_Call from "./images/PAGE_Call.png";
|
||||||
import PAGE_Off from "./images/PAGE_Off.png";
|
import PAGE_Off from "./images/PAGE_Off.png";
|
||||||
import PAGE_STARTUP from "./images/PAGE_Startup.png";
|
import PAGE_STARTUP from "./images/PAGE_Startup.png";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { cn, useDebounce } from "@repo/shared-components";
|
import { cn, useDebounce } from "@repo/shared-components";
|
||||||
import "./MrtDisplay.css";
|
import "./MrtDisplay.css";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
@@ -16,8 +16,11 @@ import { useAudioStore } from "_store/audioStore";
|
|||||||
import { ROOMS } from "_data/livekitRooms";
|
import { ROOMS } from "_data/livekitRooms";
|
||||||
|
|
||||||
export const MrtDisplay = () => {
|
export const MrtDisplay = () => {
|
||||||
const { page, setPage, popup } = useMrtStore((state) => state);
|
const { page, setPage, popup, setPopup, setStringifiedData, stringifiedData } = useMrtStore(
|
||||||
|
(state) => state,
|
||||||
|
);
|
||||||
|
const callEstablishedRef = useRef(false);
|
||||||
|
const session = useSession();
|
||||||
const { connectedAircraft, selectedStation } = usePilotConnectionStore((state) => state);
|
const { connectedAircraft, selectedStation } = usePilotConnectionStore((state) => state);
|
||||||
const { room, speakingParticipants, isTalking } = useAudioStore((state) => state);
|
const { room, speakingParticipants, isTalking } = useAudioStore((state) => state);
|
||||||
const [pageImage, setPageImage] = useState<{
|
const [pageImage, setPageImage] = useState<{
|
||||||
@@ -35,8 +38,6 @@ export const MrtDisplay = () => {
|
|||||||
| undefined
|
| undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
|
|
||||||
const session = useSession();
|
|
||||||
|
|
||||||
useDebounce(
|
useDebounce(
|
||||||
() => {
|
() => {
|
||||||
if (!nextImage) return;
|
if (!nextImage) return;
|
||||||
@@ -68,6 +69,18 @@ export const MrtDisplay = () => {
|
|||||||
[page, setPage],
|
[page, setPage],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useDebounce(
|
||||||
|
() => {
|
||||||
|
if (page === "startup") {
|
||||||
|
setPopup({
|
||||||
|
popup: "login",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
7500,
|
||||||
|
[page, setPage],
|
||||||
|
);
|
||||||
|
|
||||||
useDebounce(
|
useDebounce(
|
||||||
() => {
|
() => {
|
||||||
if (page === "voice-call" && speakingParticipants.length === 0 && !isTalking) {
|
if (page === "voice-call" && speakingParticipants.length === 0 && !isTalking) {
|
||||||
@@ -81,6 +94,67 @@ export const MrtDisplay = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const timeouts: NodeJS.Timeout[] = [];
|
||||||
|
if (page === "voice-call") {
|
||||||
|
setStringifiedData({
|
||||||
|
callTextHeader: "Wählen",
|
||||||
|
});
|
||||||
|
timeouts.push(
|
||||||
|
setTimeout(() => {
|
||||||
|
setStringifiedData({
|
||||||
|
callTextHeader: "Anruf...",
|
||||||
|
});
|
||||||
|
}, 500),
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setStringifiedData({
|
||||||
|
callTextHeader: "Gruppenruf",
|
||||||
|
});
|
||||||
|
}, 800),
|
||||||
|
setTimeout(() => {
|
||||||
|
callEstablishedRef.current = true;
|
||||||
|
}, 1500),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
timeouts.forEach((t) => clearTimeout(t));
|
||||||
|
};
|
||||||
|
}, [page, setStringifiedData]);
|
||||||
|
|
||||||
|
useDebounce(
|
||||||
|
() => {
|
||||||
|
if (isTalking && page === "voice-call") {
|
||||||
|
setStringifiedData({
|
||||||
|
callTextHeader: "Sprechen",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
1500,
|
||||||
|
[page, isTalking],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isTalking && page === "voice-call" && callEstablishedRef.current) {
|
||||||
|
console.log("SET TO SPRECHEN", stringifiedData.callTextHeader);
|
||||||
|
setStringifiedData({
|
||||||
|
callTextHeader: "Sprechen",
|
||||||
|
});
|
||||||
|
} else if (
|
||||||
|
!isTalking &&
|
||||||
|
page === "voice-call" &&
|
||||||
|
stringifiedData.callTextHeader === "Sprechen"
|
||||||
|
) {
|
||||||
|
setStringifiedData({
|
||||||
|
callTextHeader: "Gruppenruf",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [page, stringifiedData.callTextHeader, isTalking, setStringifiedData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (page !== "voice-call") {
|
||||||
|
callEstablishedRef.current = false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (page) {
|
switch (page) {
|
||||||
case "home":
|
case "home":
|
||||||
setNextImage({ src: PAGE_HOME, name: "home" });
|
setNextImage({ src: PAGE_HOME, name: "home" });
|
||||||
@@ -139,6 +213,9 @@ export const MrtDisplay = () => {
|
|||||||
)}
|
)}
|
||||||
{pageName == "voice-call" && (
|
{pageName == "voice-call" && (
|
||||||
<div>
|
<div>
|
||||||
|
<p className="absolute left-[18%] top-[18.8%] h-[8%] w-[37%]">
|
||||||
|
{stringifiedData.callTextHeader}
|
||||||
|
</p>
|
||||||
<p className="absolute left-[18%] top-[35%] h-[8%] w-[38%]">
|
<p className="absolute left-[18%] top-[35%] h-[8%] w-[38%]">
|
||||||
{isTalking && selectedStation?.bosCallsignShort}
|
{isTalking && selectedStation?.bosCallsignShort}
|
||||||
{speakingParticipants.length > 0 &&
|
{speakingParticipants.length > 0 &&
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const MrtPopups = () => {
|
|||||||
const { sdsReceivedSoundRef } = useSounds();
|
const { sdsReceivedSoundRef } = useSounds();
|
||||||
|
|
||||||
const { popup, setPopup, setStringifiedData, stringifiedData } = useMrtStore((state) => state);
|
const { popup, setPopup, setStringifiedData, stringifiedData } = useMrtStore((state) => state);
|
||||||
const { connectedAircraft } = usePilotConnectionStore((state) => state);
|
const { connectedAircraft, status } = usePilotConnectionStore((state) => state);
|
||||||
const [popupImage, setPopupImage] = useState<StaticImageData | null>(null);
|
const [popupImage, setPopupImage] = useState<StaticImageData | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -42,22 +42,39 @@ export const MrtPopups = () => {
|
|||||||
|
|
||||||
useDebounce(
|
useDebounce(
|
||||||
() => {
|
() => {
|
||||||
if (!popup || popup == "sds-received") return;
|
if (popup == "login") return;
|
||||||
|
if (popup == "sds-received") return;
|
||||||
setPopup(null);
|
setPopup(null);
|
||||||
},
|
},
|
||||||
3000,
|
3000,
|
||||||
[popup],
|
[popup],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (status === "connecting") {
|
||||||
|
setPopup({ popup: "login" });
|
||||||
|
}
|
||||||
|
}, [status, setPopup]);
|
||||||
|
|
||||||
|
useDebounce(
|
||||||
|
() => {
|
||||||
|
if (status === "connected") {
|
||||||
|
setPopup(null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
5000,
|
||||||
|
[status],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
pilotSocket.on("sds-status", (data: StationStatus) => {
|
pilotSocket.on("sds-status", (data: StationStatus) => {
|
||||||
setStringifiedData({ sdsText: data.status + " - " + fmsStatusDescriptionShort[data.status] });
|
setStringifiedData({ sdsText: data.status + " - " + fmsStatusDescriptionShort[data.status] });
|
||||||
setPopup({ popup: "sds-received" });
|
setPopup({ popup: "sds-received" });
|
||||||
|
if (sdsReceivedSoundRef.current) {
|
||||||
|
sdsReceivedSoundRef.current.currentTime = 0;
|
||||||
|
sdsReceivedSoundRef.current.play();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (sdsReceivedSoundRef.current) {
|
|
||||||
sdsReceivedSoundRef.current.currentTime = 0;
|
|
||||||
sdsReceivedSoundRef.current.play();
|
|
||||||
}
|
|
||||||
}, [setPopup, setStringifiedData, sdsReceivedSoundRef]);
|
}, [setPopup, setStringifiedData, sdsReceivedSoundRef]);
|
||||||
|
|
||||||
if (!popupImage || !popup) return null;
|
if (!popupImage || !popup) return null;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.3 MiB After Width: | Height: | Size: 4.3 MiB |
@@ -23,7 +23,7 @@ const Map = dynamic(() => import("_components/map/Map"), {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const PilotPage = () => {
|
const PilotPage = () => {
|
||||||
const { connectedAircraft, status, } = usePilotConnectionStore((state) => state);
|
const { connectedAircraft, status } = usePilotConnectionStore((state) => state);
|
||||||
const { latestMission } = useDmeStore((state) => state);
|
const { latestMission } = useDmeStore((state) => state);
|
||||||
// Query will be cached anyway, due to this, displayed Markers are in sync with own Aircraft connection-warning
|
// Query will be cached anyway, due to this, displayed Markers are in sync with own Aircraft connection-warning
|
||||||
const { data: aircrafts } = useQuery({
|
const { data: aircrafts } = useQuery({
|
||||||
@@ -94,7 +94,7 @@ const PilotPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex h-full w-1/3">
|
<div className="flex h-full w-1/3 min-w-[500px]">
|
||||||
<div className="bg-base-300 flex h-full w-full flex-col p-4">
|
<div className="bg-base-300 flex h-full w-full flex-col p-4">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<h2 className="card-title mb-2">MRT & DME</h2>
|
<h2 className="card-title mb-2">MRT & DME</h2>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { getPublicUser, MissionSdsStatusLog, Prisma, StationStatus } from "@repo/db";
|
import { getPublicUser, MissionSdsStatusLog, StationStatus } from "@repo/db";
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { BaseNotification } from "_components/customToasts/BaseNotification";
|
import { BaseNotification } from "_components/customToasts/BaseNotification";
|
||||||
import { FMS_STATUS_COLORS } from "_helpers/fmsStatusColors";
|
import { FMS_STATUS_COLORS } from "_helpers/fmsStatusColors";
|
||||||
import { editConnectedAircraftAPI, getConnectedAircraftsAPI } from "_querys/aircrafts";
|
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||||
import { getLivekitRooms } from "_querys/livekit";
|
import { getLivekitRooms } from "_querys/livekit";
|
||||||
import { sendSdsStatusMessageAPI } from "_querys/missions";
|
import { sendSdsStatusMessageAPI } from "_querys/missions";
|
||||||
import { getStationsAPI } from "_querys/stations";
|
import { getStationsAPI } from "_querys/stations";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Marker, Polyline, useMap } from "react-leaflet";
|
|||||||
import { DivIcon, Marker as LMarker, Popup as LPopup } from "leaflet";
|
import { DivIcon, Marker as LMarker, Popup as LPopup } from "leaflet";
|
||||||
import { useMapStore } from "_store/mapStore";
|
import { useMapStore } from "_store/mapStore";
|
||||||
import { Fragment, useCallback, useEffect, useRef, useState, useMemo } from "react";
|
import { Fragment, useCallback, useEffect, useRef, useState, useMemo } from "react";
|
||||||
import { checkSimulatorConnected, cn } from "@repo/shared-components";
|
import { cn } from "@repo/shared-components";
|
||||||
import { ChevronsRightLeft, House, MessageSquareText, Minimize2 } from "lucide-react";
|
import { ChevronsRightLeft, House, MessageSquareText, Minimize2 } from "lucide-react";
|
||||||
import { SmartPopup, calculateAnchor, useSmartPopup } from "_components/SmartPopup";
|
import { SmartPopup, calculateAnchor, useSmartPopup } from "_components/SmartPopup";
|
||||||
import FMSStatusHistory, {
|
import FMSStatusHistory, {
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ export type SetPopupParams =
|
|||||||
interface StringifiedData {
|
interface StringifiedData {
|
||||||
sdsText?: string;
|
sdsText?: string;
|
||||||
sentSdsText?: string;
|
sentSdsText?: string;
|
||||||
|
|
||||||
|
callTextHeader?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MrtStore {
|
interface MrtStore {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ pilotSocket.on("connect-message", (data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
pilotSocket.on("disconnect", () => {
|
pilotSocket.on("disconnect", () => {
|
||||||
usePilotConnectionStore.setState({ status: "disconnected" });
|
usePilotConnectionStore.setState({ status: "disconnected", connectedAircraft: null });
|
||||||
useAudioStore.getState().disconnect();
|
useAudioStore.getState().disconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user