MRT: Rufgruppenauswahl, Herunterfahren, Hilfe
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { CSSProperties, useRef } from "react";
|
import { CSSProperties, useRef } from "react";
|
||||||
import { useButtons } from "./useButtons";
|
import { useButtons } from "./useButtons";
|
||||||
import { useSounds } from "./useSounds";
|
|
||||||
|
|
||||||
const MRT_BUTTON_STYLES: CSSProperties = {
|
const MRT_BUTTON_STYLES: CSSProperties = {
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
@@ -45,6 +44,34 @@ export const MrtButtons = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{/* BELOW DISPLAY */}
|
||||||
|
<MrtButton
|
||||||
|
onClick={handleKlick("arrow-left")}
|
||||||
|
onHold={handleHold("arrow-left")}
|
||||||
|
style={{ gridArea: "14 / 4 / 15 / 5", ...MRT_BUTTON_STYLES }}
|
||||||
|
/>
|
||||||
|
<MrtButton
|
||||||
|
onClick={handleKlick("arrow-down")}
|
||||||
|
onHold={handleHold("arrow-down")}
|
||||||
|
style={{ gridArea: "14 / 6 / 15 / 7", ...MRT_BUTTON_STYLES }}
|
||||||
|
/>
|
||||||
|
<MrtButton
|
||||||
|
onClick={handleKlick("arrow-up")}
|
||||||
|
onHold={handleHold("arrow-up")}
|
||||||
|
style={{ gridArea: "14 / 8 / 15 / 9", ...MRT_BUTTON_STYLES }}
|
||||||
|
/>
|
||||||
|
<MrtButton
|
||||||
|
onClick={handleKlick("arrow-right")}
|
||||||
|
onHold={handleHold("arrow-right")}
|
||||||
|
style={{ gridArea: "14 / 10 / 15 / 11", ...MRT_BUTTON_STYLES }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<MrtButton
|
||||||
|
onClick={handleKlick("wheel-knob")}
|
||||||
|
onHold={handleHold("wheel-knob")}
|
||||||
|
style={{ gridArea: "14 / 2 / 15 / 4", ...MRT_BUTTON_STYLES }}
|
||||||
|
/>
|
||||||
|
{/* LINE SELECT KEY */}
|
||||||
<MrtButton
|
<MrtButton
|
||||||
onHold={handleHold("3r")}
|
onHold={handleHold("3r")}
|
||||||
onClick={handleKlick("3r")}
|
onClick={handleKlick("3r")}
|
||||||
@@ -55,6 +82,7 @@ export const MrtButtons = () => {
|
|||||||
onClick={handleKlick("3l")}
|
onClick={handleKlick("3l")}
|
||||||
style={{ gridArea: "9 / 2 / 11 / 3", ...MRT_BUTTON_STYLES }}
|
style={{ gridArea: "9 / 2 / 11 / 3", ...MRT_BUTTON_STYLES }}
|
||||||
/>
|
/>
|
||||||
|
{/* NUM PAD */}
|
||||||
<MrtButton
|
<MrtButton
|
||||||
onHold={handleHold("1")}
|
onHold={handleHold("1")}
|
||||||
onClick={handleKlick("1")}
|
onClick={handleKlick("1")}
|
||||||
@@ -105,6 +133,11 @@ export const MrtButtons = () => {
|
|||||||
onClick={handleKlick("0")}
|
onClick={handleKlick("0")}
|
||||||
style={{ gridArea: "11 / 16 / 13 / 17", ...MRT_BUTTON_STYLES }}
|
style={{ gridArea: "11 / 16 / 13 / 17", ...MRT_BUTTON_STYLES }}
|
||||||
/>
|
/>
|
||||||
|
<MrtButton
|
||||||
|
onHold={handleHold("end-call")}
|
||||||
|
onClick={handleKlick("end-call")}
|
||||||
|
style={{ gridArea: "13 / 16 / 15 / 17", ...MRT_BUTTON_STYLES }}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ export const MrtDisplay = () => {
|
|||||||
const DisplayText = ({ pageName }: { pageName: SetPageParams["page"] }) => {
|
const DisplayText = ({ pageName }: { pageName: SetPageParams["page"] }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn("font-semibold text-blue-900", !!popup && "filter")}
|
className={cn("font-semibold text-[#000d60]", !!popup && "filter")}
|
||||||
style={{
|
style={{
|
||||||
fontFamily: "Bahnschrift",
|
fontFamily: "Bahnschrift",
|
||||||
}}
|
}}
|
||||||
@@ -191,7 +191,7 @@ export const MrtDisplay = () => {
|
|||||||
</p>
|
</p>
|
||||||
<p
|
<p
|
||||||
className={cn(
|
className={cn(
|
||||||
"absolute left-[17%] top-[24%] h-[8%] w-[39%] text-center",
|
"absolute left-[17%] top-[25%] h-[8%] w-[39%] text-center",
|
||||||
!connectedAircraft && "text-red-600",
|
!connectedAircraft && "text-red-600",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -203,7 +203,7 @@ export const MrtDisplay = () => {
|
|||||||
)}
|
)}
|
||||||
{!connectedAircraft && <>Keine Verbindung</>}
|
{!connectedAircraft && <>Keine Verbindung</>}
|
||||||
</p>
|
</p>
|
||||||
<p className="absolute left-[22.7%] top-[38%] h-[8%] w-[34%] text-xs">
|
<p className="absolute left-[22.7%] top-[37.8%] flex h-[5%] w-[34%] items-center text-xs">
|
||||||
{room?.name || "Keine RG gefunden"}
|
{room?.name || "Keine RG gefunden"}
|
||||||
</p>
|
</p>
|
||||||
<p className="absolute left-[28%] top-[44.5%] h-[8%] w-[34%] text-xs">
|
<p className="absolute left-[28%] top-[44.5%] h-[8%] w-[34%] text-xs">
|
||||||
@@ -213,7 +213,7 @@ export const MrtDisplay = () => {
|
|||||||
)}
|
)}
|
||||||
{pageName == "voice-call" && (
|
{pageName == "voice-call" && (
|
||||||
<div>
|
<div>
|
||||||
<p className="absolute left-[18%] top-[18.8%] h-[8%] w-[37%]">
|
<p className="absolute left-[18%] top-[18.8%] flex h-[10%] w-[37%] items-center">
|
||||||
{stringifiedData.callTextHeader}
|
{stringifiedData.callTextHeader}
|
||||||
</p>
|
</p>
|
||||||
<p className="absolute left-[18%] top-[35%] h-[8%] w-[38%]">
|
<p className="absolute left-[18%] top-[35%] h-[8%] w-[38%]">
|
||||||
@@ -240,15 +240,25 @@ export const MrtDisplay = () => {
|
|||||||
alt=""
|
alt=""
|
||||||
width={1000}
|
width={1000}
|
||||||
height={1000}
|
height={1000}
|
||||||
className={`z-10 col-span-full row-span-full`}
|
className={cn(popup && "brightness-75 filter", "z-10 col-span-full row-span-full")}
|
||||||
/>
|
/>
|
||||||
{nextImage && (
|
{nextImage && (
|
||||||
<div className="transition-image animate-reveal relative z-20 col-span-full row-span-full">
|
<div
|
||||||
|
className={cn(
|
||||||
|
popup && "brightness-75 filter",
|
||||||
|
"transition-image animate-reveal relative z-20 col-span-full row-span-full",
|
||||||
|
)}
|
||||||
|
>
|
||||||
<Image src={nextImage.src} alt="" width={1000} height={1000} className="h-full w-full" />
|
<Image src={nextImage.src} alt="" width={1000} height={1000} className="h-full w-full" />
|
||||||
<DisplayText pageName={nextImage.name} />
|
<DisplayText pageName={nextImage.name} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="relative z-10 col-span-full row-span-full overflow-hidden">
|
<div
|
||||||
|
className={cn(
|
||||||
|
popup && "brightness-75 filter",
|
||||||
|
"relative z-10 col-span-full row-span-full overflow-hidden",
|
||||||
|
)}
|
||||||
|
>
|
||||||
<DisplayText pageName={pageImage.name} />
|
<DisplayText pageName={pageImage.name} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -2,20 +2,27 @@ import { SetPopupParams, useMrtStore } from "_store/pilot/MrtStore";
|
|||||||
import Image, { StaticImageData } from "next/image";
|
import Image, { StaticImageData } from "next/image";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import IAMGE_POPUP_LOGIN from "./images/POPUP_login.png";
|
import IAMGE_POPUP_LOGIN from "./images/POPUP_login.png";
|
||||||
|
import GROUP_SELECTION_POPUP_LOGIN from "./images/POPUP_group_selection.png";
|
||||||
import IAMGE_POPUP_SDS_RECEIVED from "./images/POPUP_SDS_incomming.png";
|
import IAMGE_POPUP_SDS_RECEIVED from "./images/POPUP_SDS_incomming.png";
|
||||||
import IAMGE_POPUP_SDS_SENT from "./images/POPUP_SDS_sent.png";
|
import IAMGE_POPUP_SDS_SENT from "./images/POPUP_SDS_sent.png";
|
||||||
import IAMGE_POPUP_STATUS_SENT from "./images/POPUP_Status_sent.png";
|
import IAMGE_POPUP_STATUS_SENT from "./images/POPUP_Status_sent.png";
|
||||||
|
import { ROOMS } from "_data/livekitRooms";
|
||||||
import { cn, useDebounce } from "@repo/shared-components";
|
import { cn, useDebounce } from "@repo/shared-components";
|
||||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||||
import { fmsStatusDescription, fmsStatusDescriptionShort } from "_data/fmsStatusDescription";
|
import { fmsStatusDescription, fmsStatusDescriptionShort } from "_data/fmsStatusDescription";
|
||||||
import { pilotSocket } from "(app)/pilot/socket";
|
import { pilotSocket } from "(app)/pilot/socket";
|
||||||
import { StationStatus } from "@repo/db";
|
import { StationStatus } from "@repo/db";
|
||||||
import { useSounds } from "./useSounds";
|
import { useSounds } from "./useSounds";
|
||||||
|
import { useButtons } from "./useButtons";
|
||||||
|
import { useAudioStore } from "_store/audioStore";
|
||||||
|
|
||||||
export const MrtPopups = () => {
|
export const MrtPopups = () => {
|
||||||
const { sdsReceivedSoundRef } = useSounds();
|
const { sdsReceivedSoundRef } = useSounds();
|
||||||
|
const { handleKlick } = useButtons();
|
||||||
const { popup, setPopup, setStringifiedData, stringifiedData } = useMrtStore((state) => state);
|
const { selectedRoom } = useAudioStore();
|
||||||
|
const { popup, page, setPopup, setStringifiedData, stringifiedData } = useMrtStore(
|
||||||
|
(state) => state,
|
||||||
|
);
|
||||||
const { connectedAircraft, status } = usePilotConnectionStore((state) => state);
|
const { connectedAircraft, status } = usePilotConnectionStore((state) => state);
|
||||||
const [popupImage, setPopupImage] = useState<StaticImageData | null>(null);
|
const [popupImage, setPopupImage] = useState<StaticImageData | null>(null);
|
||||||
|
|
||||||
@@ -33,6 +40,9 @@ export const MrtPopups = () => {
|
|||||||
case "login":
|
case "login":
|
||||||
setPopupImage(IAMGE_POPUP_LOGIN);
|
setPopupImage(IAMGE_POPUP_LOGIN);
|
||||||
break;
|
break;
|
||||||
|
case "group-selection":
|
||||||
|
setPopupImage(GROUP_SELECTION_POPUP_LOGIN);
|
||||||
|
break;
|
||||||
case undefined:
|
case undefined:
|
||||||
case null:
|
case null:
|
||||||
setPopupImage(null);
|
setPopupImage(null);
|
||||||
@@ -44,17 +54,32 @@ export const MrtPopups = () => {
|
|||||||
() => {
|
() => {
|
||||||
if (popup == "login") return;
|
if (popup == "login") return;
|
||||||
if (popup == "sds-received") return;
|
if (popup == "sds-received") return;
|
||||||
|
if (popup == "group-selection") return;
|
||||||
setPopup(null);
|
setPopup(null);
|
||||||
},
|
},
|
||||||
3000,
|
3000,
|
||||||
[popup],
|
[popup],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useDebounce(
|
||||||
|
() => {
|
||||||
|
if (popup == "group-selection") {
|
||||||
|
if (selectedRoom?.id === stringifiedData.groupSelectionGroupId) {
|
||||||
|
setPopup(null);
|
||||||
|
} else {
|
||||||
|
handleKlick("3l")();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
5000,
|
||||||
|
[page, stringifiedData.groupSelectionGroupId, selectedRoom],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status === "connecting") {
|
if (status === "connecting" && page !== "off" && page !== "startup") {
|
||||||
setPopup({ popup: "login" });
|
setPopup({ popup: "login" });
|
||||||
}
|
}
|
||||||
}, [status, setPopup]);
|
}, [status, setPopup, page]);
|
||||||
|
|
||||||
useDebounce(
|
useDebounce(
|
||||||
() => {
|
() => {
|
||||||
@@ -80,9 +105,11 @@ export const MrtPopups = () => {
|
|||||||
if (!popupImage || !popup) return null;
|
if (!popupImage || !popup) return null;
|
||||||
|
|
||||||
const DisplayText = ({ pageName }: { pageName: SetPopupParams["popup"] }) => {
|
const DisplayText = ({ pageName }: { pageName: SetPopupParams["popup"] }) => {
|
||||||
|
const group = ROOMS.find((r) => r.id === stringifiedData.groupSelectionGroupId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn("font-semibold text-blue-900", !!popup && "filter")}
|
className={cn("font-semibold text-[#000d60]", !!popup && "filter")}
|
||||||
style={{
|
style={{
|
||||||
fontFamily: "Bahnschrift",
|
fontFamily: "Bahnschrift",
|
||||||
}}
|
}}
|
||||||
@@ -102,13 +129,21 @@ export const MrtPopups = () => {
|
|||||||
{stringifiedData.sdsText}
|
{stringifiedData.sdsText}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{pageName == "group-selection" && (
|
||||||
|
<>
|
||||||
|
<p className="absolute left-[24%] top-[39%] h-[5%] w-[30%]">{group?.name}</p>
|
||||||
|
<p className="absolute left-[24%] top-[50%] flex h-[9%] w-[31%] items-end justify-end">
|
||||||
|
{stringifiedData.groupSelectionGroupId}
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Image src={popupImage} alt="" className="z-20 col-span-full row-span-full" />
|
<Image src={popupImage} alt="" className="z-30 col-span-full row-span-full" />
|
||||||
<div className="relative z-30 col-span-full row-span-full overflow-hidden">
|
<div className="relative z-30 col-span-full row-span-full overflow-hidden">
|
||||||
<DisplayText pageName={popup} />
|
<DisplayText pageName={popup} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.3 MiB |
@@ -8,12 +8,42 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|||||||
import { useSounds } from "./useSounds";
|
import { useSounds } from "./useSounds";
|
||||||
import { sendSdsStatusMessageAPI } from "_querys/missions";
|
import { sendSdsStatusMessageAPI } from "_querys/missions";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
|
import { ROOMS } from "_data/livekitRooms";
|
||||||
|
import { useAudioStore } from "_store/audioStore";
|
||||||
|
|
||||||
|
type ButtonTypes =
|
||||||
|
| "1"
|
||||||
|
| "2"
|
||||||
|
| "3"
|
||||||
|
| "4"
|
||||||
|
| "5"
|
||||||
|
| "6"
|
||||||
|
| "7"
|
||||||
|
| "8"
|
||||||
|
| "9"
|
||||||
|
| "0"
|
||||||
|
| "home"
|
||||||
|
| "3l"
|
||||||
|
| "3r"
|
||||||
|
| "wheel-knob"
|
||||||
|
| "arrow-up"
|
||||||
|
| "arrow-down"
|
||||||
|
| "arrow-left"
|
||||||
|
| "arrow-right"
|
||||||
|
| "end-call";
|
||||||
|
|
||||||
export const useButtons = () => {
|
export const useButtons = () => {
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
|
const { connect, setSelectedRoom, selectedRoom } = useAudioStore((state) => state);
|
||||||
|
|
||||||
const { longBtnPressSoundRef, statusSentSoundRef } = useSounds();
|
const { longBtnPressSoundRef, statusSentSoundRef } = useSounds();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { selectedStation: station, connectedAircraft } = usePilotConnectionStore((state) => state);
|
const {
|
||||||
|
status: pilotState,
|
||||||
|
selectedStation,
|
||||||
|
connectedAircraft,
|
||||||
|
} = usePilotConnectionStore((state) => state);
|
||||||
|
|
||||||
const sendSdsStatusMutation = useMutation({
|
const sendSdsStatusMutation = useMutation({
|
||||||
mutationFn: async ({ sdsMessage }: { sdsMessage: MissionSdsStatusLog }) => {
|
mutationFn: async ({ sdsMessage }: { sdsMessage: MissionSdsStatusLog }) => {
|
||||||
if (!connectedAircraft?.id) throw new Error("No connected aircraft");
|
if (!connectedAircraft?.id) throw new Error("No connected aircraft");
|
||||||
@@ -34,82 +64,161 @@ export const useButtons = () => {
|
|||||||
}) => editConnectedAircraftAPI(aircraftId, data),
|
}) => editConnectedAircraftAPI(aircraftId, data),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { setPage, setPopup, page, popup, setStringifiedData } = useMrtStore((state) => state);
|
const { setPage, setPopup, page, popup, setStringifiedData, stringifiedData } = useMrtStore(
|
||||||
|
(state) => state,
|
||||||
|
);
|
||||||
|
|
||||||
const handleHold =
|
const role =
|
||||||
(button: "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0" | "home" | "3l" | "3r") =>
|
(pilotState == "connected" && selectedStation?.bosCallsignShort) ||
|
||||||
async () => {
|
session.data?.user?.publicId;
|
||||||
/* if (connectionStatus !== "connected") return; */
|
|
||||||
if (button === "1" && page === "off") {
|
const handleHold = (button: ButtonTypes) => async () => {
|
||||||
setPage({ page: "startup" });
|
/* if (connectionStatus !== "connected") return; */
|
||||||
return;
|
if (button === "end-call") {
|
||||||
}
|
setPage({ page: "off" });
|
||||||
if (!station) return;
|
setPopup(null);
|
||||||
if (!session.data?.user) return;
|
}
|
||||||
if (!connectedAircraft?.id) return;
|
if (button === "1" && page === "off") {
|
||||||
if (
|
setPage({ page: "startup" });
|
||||||
button === "1" ||
|
return;
|
||||||
button === "2" ||
|
}
|
||||||
button === "3" ||
|
if (!selectedStation) return;
|
||||||
button === "4" ||
|
if (!session.data?.user) return;
|
||||||
button === "6" ||
|
if (!connectedAircraft?.id) return;
|
||||||
button === "7" ||
|
if (
|
||||||
button === "8"
|
button === "1" ||
|
||||||
) {
|
button === "2" ||
|
||||||
longBtnPressSoundRef.current?.play();
|
button === "3" ||
|
||||||
const delay = Math.random() * 1500 + 500;
|
button === "4" ||
|
||||||
setTimeout(async () => {
|
button === "6" ||
|
||||||
await updateAircraftMutation.mutateAsync({
|
button === "7" ||
|
||||||
aircraftId: connectedAircraft.id,
|
button === "8"
|
||||||
|
) {
|
||||||
|
longBtnPressSoundRef.current?.play();
|
||||||
|
const delay = Math.random() * 1500 + 500;
|
||||||
|
setTimeout(async () => {
|
||||||
|
await updateAircraftMutation.mutateAsync({
|
||||||
|
aircraftId: connectedAircraft.id,
|
||||||
|
data: {
|
||||||
|
fmsStatus: button,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setPopup({ popup: "status-sent" });
|
||||||
|
statusSentSoundRef.current?.play();
|
||||||
|
}, delay);
|
||||||
|
} else if (button === "5" || button === "9" || button === "0") {
|
||||||
|
longBtnPressSoundRef.current?.play();
|
||||||
|
const delay = Math.random() * 1500 + 500;
|
||||||
|
setTimeout(async () => {
|
||||||
|
await sendSdsStatusMutation.mutateAsync({
|
||||||
|
sdsMessage: {
|
||||||
|
type: "sds-status-log",
|
||||||
|
auto: false,
|
||||||
|
timeStamp: new Date().toISOString(),
|
||||||
data: {
|
data: {
|
||||||
fmsStatus: button,
|
direction: "to-lst",
|
||||||
|
stationId: selectedStation.id,
|
||||||
|
station: selectedStation,
|
||||||
|
user: getPublicUser(session.data?.user),
|
||||||
|
status: button,
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
setPopup({ popup: "status-sent" });
|
});
|
||||||
statusSentSoundRef.current?.play();
|
setStringifiedData({ sentSdsText: button });
|
||||||
}, delay);
|
statusSentSoundRef.current?.play();
|
||||||
} else if (button === "5" || button === "9" || button === "0") {
|
setPopup({ popup: "sds-sent" });
|
||||||
longBtnPressSoundRef.current?.play();
|
}, delay);
|
||||||
const delay = Math.random() * 1500 + 500;
|
}
|
||||||
setTimeout(async () => {
|
};
|
||||||
await sendSdsStatusMutation.mutateAsync({
|
|
||||||
sdsMessage: {
|
|
||||||
type: "sds-status-log",
|
|
||||||
auto: false,
|
|
||||||
timeStamp: new Date().toISOString(),
|
|
||||||
data: {
|
|
||||||
direction: "to-lst",
|
|
||||||
stationId: station.id,
|
|
||||||
station,
|
|
||||||
user: getPublicUser(session.data?.user),
|
|
||||||
status: button,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
setStringifiedData({ sentSdsText: button });
|
|
||||||
statusSentSoundRef.current?.play();
|
|
||||||
setPopup({ popup: "sds-sent" });
|
|
||||||
}, delay);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleKlick =
|
const handleKlick = (button: ButtonTypes) => async () => {
|
||||||
(button: "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0" | "home" | "3l" | "3r") =>
|
console.log("Button clicked:", button);
|
||||||
async () => {
|
//implement Kurzwahl when button is clicked short to dial
|
||||||
//implement Kurzwahl when button is clicked short to dial
|
|
||||||
if (popup == "sds-received" && button === "3r") {
|
switch (button) {
|
||||||
setPopup(null);
|
case "0":
|
||||||
}
|
case "1":
|
||||||
return false;
|
case "2":
|
||||||
};
|
case "3":
|
||||||
|
case "4":
|
||||||
|
case "5":
|
||||||
|
case "6":
|
||||||
|
case "7":
|
||||||
|
case "8":
|
||||||
|
case "9":
|
||||||
|
//handle short press number buttons for kurzwahl
|
||||||
|
if (popup === "group-selection") {
|
||||||
|
if (stringifiedData.groupSelectionGroupId?.length === 4) {
|
||||||
|
setStringifiedData({ groupSelectionGroupId: button });
|
||||||
|
} else {
|
||||||
|
setStringifiedData({
|
||||||
|
groupSelectionGroupId: (stringifiedData.groupSelectionGroupId || "") + button,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (page === "home" && !popup) {
|
||||||
|
setPopup({ popup: "group-selection" });
|
||||||
|
setStringifiedData({ groupSelectionGroupId: button });
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "3r":
|
||||||
|
if (popup === "sds-received" || popup === "group-selection") {
|
||||||
|
setPopup(null);
|
||||||
|
} else if (page === "home") {
|
||||||
|
setPopup({ popup: "group-selection" });
|
||||||
|
setStringifiedData({ groupSelectionGroupId: selectedRoom?.id || ROOMS[0]!.id });
|
||||||
|
} else if (page === "voice-call") {
|
||||||
|
setPage({ page: "home" });
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "wheel-knob":
|
||||||
|
setPopup(popup === "group-selection" ? null : { popup: "group-selection" });
|
||||||
|
setStringifiedData({ groupSelectionGroupId: selectedRoom?.id || ROOMS[0]!.id });
|
||||||
|
break;
|
||||||
|
case "arrow-right":
|
||||||
|
if (popup === "group-selection") {
|
||||||
|
let currentGroupIndex = ROOMS.findIndex(
|
||||||
|
(r) => r.id === stringifiedData.groupSelectionGroupId,
|
||||||
|
);
|
||||||
|
if (currentGroupIndex === ROOMS.length - 1) currentGroupIndex = -1;
|
||||||
|
const nextGroup = ROOMS[currentGroupIndex + 1];
|
||||||
|
if (nextGroup) {
|
||||||
|
setStringifiedData({ groupSelectionGroupId: nextGroup.id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "arrow-left":
|
||||||
|
if (popup === "group-selection") {
|
||||||
|
let currentGroupIndex = ROOMS.findIndex(
|
||||||
|
(r) => r.id === stringifiedData.groupSelectionGroupId,
|
||||||
|
);
|
||||||
|
if (currentGroupIndex === 0) currentGroupIndex = ROOMS.length;
|
||||||
|
const previousGroup = ROOMS[currentGroupIndex - 1];
|
||||||
|
if (previousGroup) {
|
||||||
|
setStringifiedData({ groupSelectionGroupId: previousGroup.id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "3l":
|
||||||
|
if (popup === "group-selection") {
|
||||||
|
const group = ROOMS.find((r) => r.id === stringifiedData.groupSelectionGroupId);
|
||||||
|
if (group && role) {
|
||||||
|
setSelectedRoom(group);
|
||||||
|
connect(group, role);
|
||||||
|
setPopup(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
pilotSocket.on("connect", () => {
|
pilotSocket.on("connect", () => {
|
||||||
const { page } = useMrtStore.getState();
|
const { page } = useMrtStore.getState();
|
||||||
if (!station || page !== "off") return;
|
if (!selectedStation || page !== "off") return;
|
||||||
setPage({ page: "startup" });
|
setPage({ page: "startup" });
|
||||||
});
|
});
|
||||||
}, [setPage, station, setPopup]);
|
}, [setPage, selectedStation, setPopup]);
|
||||||
|
|
||||||
return { handleKlick, handleHold };
|
return { handleKlick, handleHold };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -97,7 +97,17 @@ const PilotPage = () => {
|
|||||||
<div className="flex h-full w-1/3 min-w-[500px]">
|
<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>
|
<div className="mb-2 flex items-center justify-end gap-2">
|
||||||
|
<h2 className="card-title">MRT & DME</h2>
|
||||||
|
<a
|
||||||
|
href="https://docs.virtualairrescue.com/allgemein/var-systeme/leitstelle/pilot.html"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="link text-xs text-gray-500 hover:underline"
|
||||||
|
>
|
||||||
|
Hilfe
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
className="tooltip tooltip-left mb-4"
|
className="tooltip tooltip-left mb-4"
|
||||||
data-tip="Dadurch wird der Einsatz erneut an den Desktop-Client gesendet."
|
data-tip="Dadurch wird der Einsatz erneut an den Desktop-Client gesendet."
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { useSounds } from "_components/Audio/useSounds";
|
|||||||
|
|
||||||
export const Audio = () => {
|
export const Audio = () => {
|
||||||
const {
|
const {
|
||||||
|
selectedRoom,
|
||||||
speakingParticipants,
|
speakingParticipants,
|
||||||
resetSpeakingParticipants,
|
resetSpeakingParticipants,
|
||||||
isTalking,
|
isTalking,
|
||||||
@@ -37,8 +38,8 @@ export const Audio = () => {
|
|||||||
room,
|
room,
|
||||||
message,
|
message,
|
||||||
removeMessage,
|
removeMessage,
|
||||||
|
setSelectedRoom,
|
||||||
} = useAudioStore();
|
} = useAudioStore();
|
||||||
const [selectedRoom, setSelectedRoom] = useState<string>("VAR_LST_RD_01");
|
|
||||||
|
|
||||||
useSounds({
|
useSounds({
|
||||||
isReceiving: speakingParticipants.length > 0,
|
isReceiving: speakingParticipants.length > 0,
|
||||||
@@ -48,7 +49,7 @@ export const Audio = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { selectedStation, status: pilotState } = usePilotConnectionStore((state) => state);
|
const { selectedStation, status: pilotState } = usePilotConnectionStore((state) => state);
|
||||||
const { selectedZone, status: dispatcherState } = useDispatchConnectionStore((state) => state);
|
const { status: dispatcherState } = useDispatchConnectionStore((state) => state);
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const [isReceivingBlick, setIsReceivingBlick] = useState(false);
|
const [isReceivingBlick, setIsReceivingBlick] = useState(false);
|
||||||
const [recentSpeakers, setRecentSpeakers] = useState<typeof speakingParticipants>([]);
|
const [recentSpeakers, setRecentSpeakers] = useState<typeof speakingParticipants>([]);
|
||||||
@@ -93,7 +94,7 @@ export const Audio = () => {
|
|||||||
const canStopOtherSpeakers = dispatcherState === "connected";
|
const canStopOtherSpeakers = dispatcherState === "connected";
|
||||||
|
|
||||||
const role =
|
const role =
|
||||||
(dispatcherState === "connected" && selectedZone) ||
|
(dispatcherState === "connected" && "VAR LST") ||
|
||||||
(pilotState == "connected" && selectedStation?.bosCallsignShort) ||
|
(pilotState == "connected" && selectedStation?.bosCallsignShort) ||
|
||||||
session.data?.user?.publicId;
|
session.data?.user?.publicId;
|
||||||
|
|
||||||
@@ -190,9 +191,9 @@ export const Audio = () => {
|
|||||||
className="btn btn-sm btn-ghost relative flex items-center justify-start gap-2 text-left"
|
className="btn btn-sm btn-ghost relative flex items-center justify-start gap-2 text-left"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!role) return;
|
if (!role) return;
|
||||||
if (selectedRoom === r.name) return;
|
if (selectedRoom?.name === r.name) return;
|
||||||
setSelectedRoom(r.name);
|
setSelectedRoom(r);
|
||||||
connect(r.name, role);
|
connect(r, role);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{room?.name === r.name && (
|
{room?.name === r.name && (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export const ROOMS = [
|
export const ROOMS = [
|
||||||
{ name: "VAR_LST_RD_01", id: 2201 },
|
{ name: "VAR_LST_RD_01", id: "2201" },
|
||||||
{ name: "VAR_LST_RD_02", id: 2202 },
|
{ name: "VAR_LST_RD_02", id: "2202" },
|
||||||
{ name: "VAR_LST_RD_03", id: 2203 },
|
{ name: "VAR_LST_RD_03", id: "2203" },
|
||||||
{ name: "VAR_LST_RD_04", id: 2204 },
|
{ name: "VAR_LST_RD_04", id: "2204" },
|
||||||
{ name: "VAR_LST_RD_05", id: 2205 },
|
{ name: "VAR_LST_RD_05", id: "2205" },
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -21,12 +21,15 @@ import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
|||||||
import { changeDispatcherAPI } from "_querys/dispatcher";
|
import { changeDispatcherAPI } from "_querys/dispatcher";
|
||||||
import { getRadioStream } from "_helpers/radioEffect";
|
import { getRadioStream } from "_helpers/radioEffect";
|
||||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||||
|
import { ROOMS } from "_data/livekitRooms";
|
||||||
|
|
||||||
let interval: NodeJS.Timeout;
|
let interval: NodeJS.Timeout;
|
||||||
|
|
||||||
|
const connectedSound = new Audio("/sounds/403.wav");
|
||||||
|
|
||||||
type TalkState = {
|
type TalkState = {
|
||||||
addSpeakingParticipant: (participant: Participant) => void;
|
addSpeakingParticipant: (participant: Participant) => void;
|
||||||
connect: (roomName: string, role: string) => void;
|
connect: (room: (typeof ROOMS)[number] | undefined, role: string) => void;
|
||||||
connectionQuality: ConnectionQuality;
|
connectionQuality: ConnectionQuality;
|
||||||
disconnect: () => void;
|
disconnect: () => void;
|
||||||
isTalking: boolean;
|
isTalking: boolean;
|
||||||
@@ -44,6 +47,8 @@ type TalkState = {
|
|||||||
radioVolume: number;
|
radioVolume: number;
|
||||||
dmeVolume: number;
|
dmeVolume: number;
|
||||||
};
|
};
|
||||||
|
selectedRoom?: (typeof ROOMS)[number];
|
||||||
|
setSelectedRoom: (room: (typeof ROOMS)[number]) => void;
|
||||||
speakingParticipants: Participant[];
|
speakingParticipants: Participant[];
|
||||||
state: "connecting" | "connected" | "disconnected" | "error";
|
state: "connecting" | "connected" | "disconnected" | "error";
|
||||||
toggleTalking: () => void;
|
toggleTalking: () => void;
|
||||||
@@ -72,6 +77,10 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
|||||||
remoteParticipants: 0,
|
remoteParticipants: 0,
|
||||||
connectionQuality: ConnectionQuality.Unknown,
|
connectionQuality: ConnectionQuality.Unknown,
|
||||||
room: null,
|
room: null,
|
||||||
|
selectedRoom: ROOMS[0],
|
||||||
|
setSelectedRoom: (room) => {
|
||||||
|
set({ selectedRoom: room });
|
||||||
|
},
|
||||||
resetSpeakingParticipants: (source: string) => {
|
resetSpeakingParticipants: (source: string) => {
|
||||||
set({
|
set({
|
||||||
speakingParticipants: [],
|
speakingParticipants: [],
|
||||||
@@ -117,11 +126,11 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
|||||||
(oldSettings.micDeviceId !== newSettings.micDeviceId ||
|
(oldSettings.micDeviceId !== newSettings.micDeviceId ||
|
||||||
oldSettings.micVolume !== newSettings.micVolume)
|
oldSettings.micVolume !== newSettings.micVolume)
|
||||||
) {
|
) {
|
||||||
const { room, disconnect, connect } = get();
|
const { room, disconnect, connect, selectedRoom } = get();
|
||||||
const role = room?.localParticipant.attributes.role;
|
const role = room?.localParticipant.attributes.role;
|
||||||
if (room?.name || role) {
|
if (selectedRoom || role) {
|
||||||
disconnect();
|
disconnect();
|
||||||
connect(room?.name || "", role || "user");
|
connect(selectedRoom, role || "user");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -160,7 +169,7 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
|||||||
|
|
||||||
set((state) => ({ isTalking: !state.isTalking, transmitBlocked: false }));
|
set((state) => ({ isTalking: !state.isTalking, transmitBlocked: false }));
|
||||||
},
|
},
|
||||||
connect: async (roomName, role) => {
|
connect: async (_room, role) => {
|
||||||
set({ state: "connecting" });
|
set({ state: "connecting" });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -172,10 +181,12 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
|||||||
connectedRoom.removeAllListeners();
|
connectedRoom.removeAllListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { selectedRoom } = get();
|
||||||
|
|
||||||
const url = process.env.NEXT_PUBLIC_LIVEKIT_URL;
|
const url = process.env.NEXT_PUBLIC_LIVEKIT_URL;
|
||||||
if (!url) return console.error("NEXT_PUBLIC_LIVEKIT_URL not set");
|
if (!url) return console.error("NEXT_PUBLIC_LIVEKIT_URL not set");
|
||||||
|
|
||||||
const token = await getToken(roomName);
|
const token = await getToken(_room?.name || selectedRoom?.name || "VAR_LST_RD_01");
|
||||||
if (!token) throw new Error("Fehlende Berechtigung");
|
if (!token) throw new Error("Fehlende Berechtigung");
|
||||||
const room = new Room({});
|
const room = new Room({});
|
||||||
await room.prepareConnection(url, token);
|
await room.prepareConnection(url, token);
|
||||||
@@ -186,7 +197,7 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
|||||||
|
|
||||||
if (dispatchState.status === "connected" && dispatchState.connectedDispatcher?.id) {
|
if (dispatchState.status === "connected" && dispatchState.connectedDispatcher?.id) {
|
||||||
changeDispatcherAPI(dispatchState.connectedDispatcher?.id, {
|
changeDispatcherAPI(dispatchState.connectedDispatcher?.id, {
|
||||||
zone: roomName,
|
zone: _room?.name || selectedRoom?.name || "VAR_LST_RD_01",
|
||||||
ghostMode: dispatchState.ghostMode,
|
ghostMode: dispatchState.ghostMode,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -208,7 +219,7 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
|||||||
source: Track.Source.Microphone,
|
source: Track.Source.Microphone,
|
||||||
});
|
});
|
||||||
await publishedTrack.mute();
|
await publishedTrack.mute();
|
||||||
|
connectedSound.play().catch((e) => console.error("Fehler beim Abspielen des Sounds", e));
|
||||||
set({ localRadioTrack: publishedTrack });
|
set({ localRadioTrack: publishedTrack });
|
||||||
|
|
||||||
set({ state: "connected", room, isTalking: false, message: null });
|
set({ state: "connected", room, isTalking: false, message: null });
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export const useDispatchConnectionStore = create<ConnectionStore>((set) => ({
|
|||||||
|
|
||||||
dispatchSocket.on("connect", () => {
|
dispatchSocket.on("connect", () => {
|
||||||
const { logoffTime, selectedZone, ghostMode } = useDispatchConnectionStore.getState();
|
const { logoffTime, selectedZone, ghostMode } = useDispatchConnectionStore.getState();
|
||||||
useAudioStore.getState().connect("VAR_LST_RD_01", selectedZone || "Leitstelle");
|
useAudioStore.getState().connect(undefined, selectedZone || "Leitstelle");
|
||||||
dispatchSocket.emit("connect-dispatch", {
|
dispatchSocket.emit("connect-dispatch", {
|
||||||
logoffTime,
|
logoffTime,
|
||||||
selectedZone,
|
selectedZone,
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ interface SetSdsReceivedPopupParams {
|
|||||||
popup: "sds-received";
|
popup: "sds-received";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface SetGroupSelectionPopupParams {
|
||||||
|
popup: "group-selection";
|
||||||
|
}
|
||||||
|
|
||||||
interface SetStatusSentPopupParams {
|
interface SetStatusSentPopupParams {
|
||||||
popup: "status-sent";
|
popup: "status-sent";
|
||||||
}
|
}
|
||||||
@@ -40,6 +44,7 @@ export type SetPageParams =
|
|||||||
export type SetPopupParams =
|
export type SetPopupParams =
|
||||||
| SetStatusSentPopupParams
|
| SetStatusSentPopupParams
|
||||||
| SetSdsSentPopupParams
|
| SetSdsSentPopupParams
|
||||||
|
| SetGroupSelectionPopupParams
|
||||||
| SetSdsReceivedPopupParams
|
| SetSdsReceivedPopupParams
|
||||||
| SetLoginPopupParams;
|
| SetLoginPopupParams;
|
||||||
|
|
||||||
@@ -47,6 +52,7 @@ interface StringifiedData {
|
|||||||
sdsText?: string;
|
sdsText?: string;
|
||||||
sentSdsText?: string;
|
sentSdsText?: string;
|
||||||
|
|
||||||
|
groupSelectionGroupId?: string;
|
||||||
callTextHeader?: string;
|
callTextHeader?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +75,9 @@ interface MrtStore {
|
|||||||
export const useMrtStore = create<MrtStore>((set) => ({
|
export const useMrtStore = create<MrtStore>((set) => ({
|
||||||
page: "off",
|
page: "off",
|
||||||
nightMode: false,
|
nightMode: false,
|
||||||
stringifiedData: {},
|
stringifiedData: {
|
||||||
|
groupSelectionGroupId: "2201",
|
||||||
|
},
|
||||||
setNightMode: (nightMode) => set({ nightMode }),
|
setNightMode: (nightMode) => set({ nightMode }),
|
||||||
setStringifiedData: (data) =>
|
setStringifiedData: (data) =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ pilotSocket.on("connect", () => {
|
|||||||
usePilotConnectionStore.setState({ status: "connected", message: "" });
|
usePilotConnectionStore.setState({ status: "connected", message: "" });
|
||||||
const { logoffTime, selectedStation, debug } = usePilotConnectionStore.getState();
|
const { logoffTime, selectedStation, debug } = usePilotConnectionStore.getState();
|
||||||
dispatchSocket.disconnect();
|
dispatchSocket.disconnect();
|
||||||
useAudioStore.getState().connect("VAR_LST_RD_01", selectedStation?.bosCallsignShort || "pilot");
|
useAudioStore.getState().connect(undefined, selectedStation?.bosCallsignShort || "pilot");
|
||||||
|
|
||||||
pilotSocket.emit("connect-pilot", {
|
pilotSocket.emit("connect-pilot", {
|
||||||
logoffTime,
|
logoffTime,
|
||||||
|
|||||||
Reference in New Issue
Block a user