added HPG VEhicles Mission, Audio settings; mission Context menu
This commit is contained in:
@@ -114,8 +114,48 @@ router.delete("/:id", async (req, res) => {
|
|||||||
|
|
||||||
router.post("/:id/send-alert", async (req, res) => {
|
router.post("/:id/send-alert", async (req, res) => {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
const { stationId } = req.body as { stationId?: number };
|
const { stationId, vehicleName } = req.body as {
|
||||||
|
stationId?: number;
|
||||||
|
vehicleName?: "ambulance" | "police" | "firebrigade";
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (vehicleName) {
|
||||||
|
const hpgAircrafts = await prisma.connectedAircraft.findMany({
|
||||||
|
where: {
|
||||||
|
stationId: Number(id),
|
||||||
|
logoutTime: null,
|
||||||
|
posH145active: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const newMission = await prisma.mission.update({
|
||||||
|
where: {
|
||||||
|
id: Number(id),
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
hpgAmbulanceState: vehicleName === "ambulance" ? "DISPATCHED" : undefined,
|
||||||
|
hpgFireEngineState: vehicleName === "firebrigade" ? "DISPATCHED" : undefined,
|
||||||
|
hpgPoliceState: vehicleName === "police" ? "DISPATCHED" : undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
hpgAircrafts.forEach((aircraft) => {
|
||||||
|
io.to(`desktop:${aircraft.userId}`).emit("hpg-vehicle-update", {
|
||||||
|
missionId: id,
|
||||||
|
vehicleData: {
|
||||||
|
ambulanceState: newMission.hpgAmbulanceState,
|
||||||
|
fireEngineState: newMission.hpgFireEngineState,
|
||||||
|
policeState: newMission.hpgPoliceState,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
message: `Rettungsmittel disponiert (${hpgAircrafts.length} Nutzer)`,
|
||||||
|
});
|
||||||
|
io.to("dispatchers").emit("update-mission", newMission);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { connectedAircrafts, mission } = await sendAlert(Number(id), {
|
const { connectedAircrafts, mission } = await sendAlert(Number(id), {
|
||||||
stationId,
|
stationId,
|
||||||
});
|
});
|
||||||
@@ -153,7 +193,6 @@ router.post("/:id/send-sds", async (req, res) => {
|
|||||||
|
|
||||||
router.post("/:id/validate-hpg", async (req, res) => {
|
router.post("/:id/validate-hpg", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
console.log(req.user);
|
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
const config = req.body as
|
const config = req.body as
|
||||||
| {
|
| {
|
||||||
@@ -178,37 +217,39 @@ router.post("/:id/validate-hpg", async (req, res) => {
|
|||||||
Station: true,
|
Station: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const user = await prisma.user.findFirst({
|
||||||
|
where: {
|
||||||
|
id: activeAircraftinMission?.userId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const clients = await io.in(`desktop:${activeAircraftinMission?.userId}`).fetchSockets();
|
||||||
|
if (!clients.length) {
|
||||||
|
res.status(400).json({
|
||||||
|
error: `Keine Desktop Verbindung für ${user?.publicId} gefunden`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
res.json({
|
res.json({
|
||||||
message: "HPG validation started",
|
message: "HPG validation started",
|
||||||
});
|
});
|
||||||
|
|
||||||
/* io.to(`desktop:${activeAircraftinMission}`).emit(
|
io.to(`desktop:${activeAircraftinMission}`).emit(
|
||||||
"hpg-validation",
|
"hpg-validation",
|
||||||
{
|
{
|
||||||
hpgMissionType: mission?.hpgMissionString,
|
hpgMissionType: mission?.hpgMissionString,
|
||||||
lat: mission?.addressLat,
|
lat: mission?.addressLat,
|
||||||
lng: mission?.addressLng,
|
lng: mission?.addressLng,
|
||||||
},
|
},
|
||||||
async (result: {
|
async (result: { state: HpgValidationState; lat: number; lng: number }) => {
|
||||||
state: HpgValidationState;
|
|
||||||
lat: number;
|
|
||||||
lng: number;
|
|
||||||
}) => {
|
|
||||||
console.log("response from user:", result);
|
console.log("response from user:", result);
|
||||||
|
|
||||||
const newMission = await prisma.mission.update({
|
const newMission = await prisma.mission.update({
|
||||||
where: { id: Number(id) },
|
where: { id: Number(id) },
|
||||||
data: {
|
data: {
|
||||||
// save position of new mission
|
// save position of new mission
|
||||||
addressLat:
|
addressLat: result.state === "POSITION_AMANDED" ? result.lat : mission.addressLat,
|
||||||
result.state === "POSITION_AMANDED"
|
addressLng: result.state === "POSITION_AMANDED" ? result.lng : mission.addressLng,
|
||||||
? result.lat
|
|
||||||
: mission.addressLat,
|
|
||||||
addressLng:
|
|
||||||
result.state === "POSITION_AMANDED"
|
|
||||||
? result.lng
|
|
||||||
: mission.addressLng,
|
|
||||||
hpgLocationLat: result.lat,
|
hpgLocationLat: result.lat,
|
||||||
hpgLocationLng: result.lng,
|
hpgLocationLng: result.lng,
|
||||||
hpgValidationState: result.state,
|
hpgValidationState: result.state,
|
||||||
@@ -234,7 +275,7 @@ router.post("/:id/validate-hpg", async (req, res) => {
|
|||||||
} as NotificationPayload);
|
} as NotificationPayload);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
); */
|
);
|
||||||
// TODO: remove this after testing
|
// TODO: remove this after testing
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
io.to(`user:${req.user?.id}`).emit("notification", {
|
io.to(`user:${req.user?.id}`).emit("notification", {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getPublicUser, prisma, User } from "@repo/db";
|
import { getPublicUser, HpgState, prisma, User } from "@repo/db";
|
||||||
import { Socket, Server } from "socket.io";
|
import { Socket, Server } from "socket.io";
|
||||||
|
|
||||||
interface PTTData {
|
interface PTTData {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||||
import {
|
import {
|
||||||
Disc,
|
Disc,
|
||||||
@@ -18,10 +18,12 @@ import { useAudioStore } from "_store/audioStore";
|
|||||||
import { cn } from "helpers/cn";
|
import { cn } from "helpers/cn";
|
||||||
import { ConnectionQuality } from "livekit-client";
|
import { ConnectionQuality } from "livekit-client";
|
||||||
import { ROOMS } from "_data/livekitRooms";
|
import { ROOMS } from "_data/livekitRooms";
|
||||||
|
import { useSession } from "next-auth/react";
|
||||||
|
|
||||||
export const Audio = () => {
|
export const Audio = () => {
|
||||||
const connection = usePilotConnectionStore();
|
const connection = usePilotConnectionStore();
|
||||||
const [showSource, setShowSource] = useState(false);
|
const [showSource, setShowSource] = useState(false);
|
||||||
|
const serverSession = useSession();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isTalking,
|
isTalking,
|
||||||
@@ -46,6 +48,7 @@ export const Audio = () => {
|
|||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
};
|
};
|
||||||
}, [source, isTalking]);
|
}, [source, isTalking]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const joinRoom = async () => {
|
const joinRoom = async () => {
|
||||||
if (connection.status != "connected") return;
|
if (connection.status != "connected") return;
|
||||||
@@ -64,17 +67,12 @@ export const Audio = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="bg-base-200 rounded-box flex items-center gap-2 p-1">
|
<div className="bg-base-200 rounded-box flex items-center gap-2 p-1">
|
||||||
{state === "error" && (
|
{state === "error" && <div className="h-4 flex items-center">{message}</div>}
|
||||||
<div className="h-4 flex items-center">{message}</div>
|
{showSource && source && <div className="h-4 flex items-center ml-2">{source}</div>}
|
||||||
)}
|
|
||||||
{showSource && source && (
|
|
||||||
<div className="h-4 flex items-center ml-2">{source}</div>
|
|
||||||
)}
|
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (state === "connected") toggleTalking();
|
if (state === "connected") toggleTalking();
|
||||||
if (state === "error" || state === "disconnected")
|
if (state === "error" || state === "disconnected") connect(selectedRoom);
|
||||||
connect(selectedRoom);
|
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
"btn btn-sm btn-soft border-none hover:bg-inherit",
|
"btn btn-sm btn-soft border-none hover:bg-inherit",
|
||||||
@@ -82,8 +80,7 @@ export const Audio = () => {
|
|||||||
isTalking && "bg-green-700 hover:bg-green-600",
|
isTalking && "bg-green-700 hover:bg-green-600",
|
||||||
state === "disconnected" && "bg-red-500 hover:bg-red-500",
|
state === "disconnected" && "bg-red-500 hover:bg-red-500",
|
||||||
state === "error" && "bg-red-500 hover:bg-red-500",
|
state === "error" && "bg-red-500 hover:bg-red-500",
|
||||||
state === "connecting" &&
|
state === "connecting" && "bg-yellow-500 hover:bg-yellow-500 cursor-default",
|
||||||
"bg-yellow-500 hover:bg-yellow-500 cursor-default",
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{state === "connected" && <Mic className="w-5 h-5" />}
|
{state === "connected" && <Mic className="w-5 h-5" />}
|
||||||
@@ -95,24 +92,14 @@ export const Audio = () => {
|
|||||||
{state === "connected" && (
|
{state === "connected" && (
|
||||||
<details className="dropdown relative z-[1050]">
|
<details className="dropdown relative z-[1050]">
|
||||||
<summary className="dropdown btn btn-ghost flex items-center gap-1">
|
<summary className="dropdown btn btn-ghost flex items-center gap-1">
|
||||||
{connectionQuality === ConnectionQuality.Excellent && (
|
{connectionQuality === ConnectionQuality.Excellent && <Signal className="w-5 h-5" />}
|
||||||
<Signal className="w-5 h-5" />
|
{connectionQuality === ConnectionQuality.Good && <SignalMedium className="w-5 h-5" />}
|
||||||
)}
|
{connectionQuality === ConnectionQuality.Poor && <SignalLow className="w-5 h-5" />}
|
||||||
{connectionQuality === ConnectionQuality.Good && (
|
{connectionQuality === ConnectionQuality.Lost && <ZapOff className="w-5 h-5" />}
|
||||||
<SignalMedium className="w-5 h-5" />
|
|
||||||
)}
|
|
||||||
{connectionQuality === ConnectionQuality.Poor && (
|
|
||||||
<SignalLow className="w-5 h-5" />
|
|
||||||
)}
|
|
||||||
{connectionQuality === ConnectionQuality.Lost && (
|
|
||||||
<ZapOff className="w-5 h-5" />
|
|
||||||
)}
|
|
||||||
{connectionQuality === ConnectionQuality.Unknown && (
|
{connectionQuality === ConnectionQuality.Unknown && (
|
||||||
<ShieldQuestion className="w-5 h-5" />
|
<ShieldQuestion className="w-5 h-5" />
|
||||||
)}
|
)}
|
||||||
<div className="badge badge-sm badge-soft badge-success">
|
<div className="badge badge-sm badge-soft badge-success">{remoteParticipants}</div>
|
||||||
{remoteParticipants}
|
|
||||||
</div>
|
|
||||||
</summary>
|
</summary>
|
||||||
<ul className="menu dropdown-content bg-base-200 rounded-box z-[1050] w-52 p-2 shadow-sm">
|
<ul className="menu dropdown-content bg-base-200 rounded-box z-[1050] w-52 p-2 shadow-sm">
|
||||||
{ROOMS.map((r) => (
|
{ROOMS.map((r) => (
|
||||||
@@ -126,10 +113,7 @@ export const Audio = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{room?.name === r && (
|
{room?.name === r && (
|
||||||
<Disc
|
<Disc className="text-success text-sm absolute left-2" width={15} />
|
||||||
className="text-success text-sm absolute left-2"
|
|
||||||
width={15}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
<span className="flex-1 text-center">{r}</span>
|
<span className="flex-1 text-center">{r}</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -142,10 +126,7 @@ export const Audio = () => {
|
|||||||
disconnect();
|
disconnect();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<WifiOff
|
<WifiOff className="text-error text-sm absolute left-2" width={15} />
|
||||||
className="text-error text-sm absolute left-2"
|
|
||||||
width={15}
|
|
||||||
/>
|
|
||||||
<span className="flex-1 text-center">Disconnect</span>
|
<span className="flex-1 text-center">Disconnect</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
75
apps/dispatch/app/_components/MicVolumeIndication.tsx
Normal file
75
apps/dispatch/app/_components/MicVolumeIndication.tsx
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { cn } from "helpers/cn";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
type MicrophoneLevelProps = {
|
||||||
|
deviceId: string;
|
||||||
|
volumeInput: number; // Verstärkung der Lautstärke
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function MicrophoneLevel({ deviceId, volumeInput }: MicrophoneLevelProps) {
|
||||||
|
const [volumeLevel, setVolumeLevel] = useState(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let audioContext: AudioContext | null = null;
|
||||||
|
let analyser: AnalyserNode | null = null;
|
||||||
|
let source: MediaStreamAudioSourceNode | null = null;
|
||||||
|
let rafId: number;
|
||||||
|
|
||||||
|
async function start() {
|
||||||
|
audioContext = new AudioContext();
|
||||||
|
const stream = await navigator.mediaDevices.getUserMedia({
|
||||||
|
audio: { deviceId: deviceId ? { exact: deviceId } : undefined },
|
||||||
|
});
|
||||||
|
source = audioContext.createMediaStreamSource(stream);
|
||||||
|
analyser = audioContext.createAnalyser();
|
||||||
|
analyser.fftSize = 256;
|
||||||
|
source.connect(analyser);
|
||||||
|
|
||||||
|
const dataArray = new Uint8Array(analyser.frequencyBinCount);
|
||||||
|
|
||||||
|
const updateVolume = () => {
|
||||||
|
if (!analyser) return;
|
||||||
|
analyser.getByteFrequencyData(dataArray);
|
||||||
|
const avg = dataArray.reduce((a, b) => a + b, 0) / dataArray.length;
|
||||||
|
setVolumeLevel(avg * volumeInput);
|
||||||
|
rafId = requestAnimationFrame(updateVolume);
|
||||||
|
};
|
||||||
|
|
||||||
|
updateVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
start();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelAnimationFrame(rafId);
|
||||||
|
audioContext?.close();
|
||||||
|
};
|
||||||
|
}, [deviceId, volumeInput]);
|
||||||
|
|
||||||
|
const barWidth = Math.max((volumeLevel / 70) * 100 - 35, 0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-full">
|
||||||
|
<div className="relative w-full bg-base-300 h-5 rounded">
|
||||||
|
<div
|
||||||
|
className={cn("bg-primary h-full rounded", barWidth > 100 && "bg-red-400")}
|
||||||
|
style={{
|
||||||
|
width: `${barWidth > 100 ? 100 : barWidth}%`,
|
||||||
|
transition: "width 0.2s",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className="absolute top-0 left-[60%] w-[20%] h-full bg-green-500 opacity-40 rounded"
|
||||||
|
style={{
|
||||||
|
transform: "translateX(-50%)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p className="text-gray-500 text-sm">
|
||||||
|
Lautstärke sollte beim Sprechen in dem Grünen bereich bleiben
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
186
apps/dispatch/app/_components/Settings.tsx
Normal file
186
apps/dispatch/app/_components/Settings.tsx
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
"use client";
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import { GearIcon } from "@radix-ui/react-icons";
|
||||||
|
import { SettingsIcon, Volume2 } from "lucide-react";
|
||||||
|
import MicVolumeBar from "_components/MicVolumeIndication";
|
||||||
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { editUserAPI, getUserAPI } from "querys/user";
|
||||||
|
import { Prisma } from "@repo/db";
|
||||||
|
import { useSession } from "next-auth/react";
|
||||||
|
import { useAudioStore } from "_store/audioStore";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
|
export const SettingsBtn = () => {
|
||||||
|
const session = useSession();
|
||||||
|
const { data: user } = useQuery({
|
||||||
|
queryKey: ["user", session.data?.user.id],
|
||||||
|
queryFn: () => getUserAPI(session.data!.user.id),
|
||||||
|
});
|
||||||
|
|
||||||
|
const editUserMutation = useMutation({
|
||||||
|
mutationFn: ({ user }: { user: Prisma.UserUpdateInput }) =>
|
||||||
|
editUserAPI(session.data!.user.id, user),
|
||||||
|
});
|
||||||
|
|
||||||
|
const modalRef = useRef<HTMLDialogElement>(null);
|
||||||
|
|
||||||
|
const [inputDevices, setInputDevices] = useState<MediaDeviceInfo[]>([]);
|
||||||
|
const [selectedDevice, setSelectedDevice] = useState<string | null>(
|
||||||
|
user?.settingsMicDevice || null,
|
||||||
|
);
|
||||||
|
const [showIndication, setShowInducation] = useState<boolean>(false);
|
||||||
|
const [micVol, setMicVol] = useState<number>(1);
|
||||||
|
|
||||||
|
const setMic = useAudioStore((state) => state.setMic);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (user?.settingsMicDevice) {
|
||||||
|
setSelectedDevice(user.settingsMicDevice);
|
||||||
|
setMic(user.settingsMicDevice, user.settingsMicVolume || 1);
|
||||||
|
}
|
||||||
|
}, [user, setMic]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
navigator.mediaDevices.enumerateDevices().then((devices) => {
|
||||||
|
setInputDevices(devices.filter((d) => d.kind === "audioinput"));
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
className="btn btn-ghost"
|
||||||
|
onSubmit={() => false}
|
||||||
|
onClick={() => {
|
||||||
|
modalRef.current?.showModal();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GearIcon className="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<dialog ref={modalRef} className="modal">
|
||||||
|
<div className="modal-box">
|
||||||
|
<h3 className="flex items-center gap-2 text-lg font-bold mb-5">
|
||||||
|
<SettingsIcon size={20} /> Einstellungen
|
||||||
|
</h3>
|
||||||
|
<div className="flex flex-col items-center justify-center">
|
||||||
|
<fieldset className="fieldset w-full">
|
||||||
|
<label className="floating-label w-full text-base">
|
||||||
|
<span>Eingabegerät</span>
|
||||||
|
<select
|
||||||
|
className="input w-full"
|
||||||
|
value={selectedDevice ? selectedDevice : ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSelectedDevice(e.target.value);
|
||||||
|
setShowInducation(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option key={0} value={0} disabled>
|
||||||
|
Bitte wähle ein Eingabegerät...
|
||||||
|
</option>
|
||||||
|
{inputDevices.map((device, index) => (
|
||||||
|
<option key={index} value={device.deviceId}>
|
||||||
|
{device.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
<p className="flex items-center gap-2 text-base mb-2">
|
||||||
|
<Volume2 size={20} /> Microfonlautstärke
|
||||||
|
</p>
|
||||||
|
<div className="w-full">
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min={0}
|
||||||
|
max={3}
|
||||||
|
step={0.01}
|
||||||
|
onChange={(e) => {
|
||||||
|
const value = parseFloat(e.target.value);
|
||||||
|
setMicVol(value);
|
||||||
|
// Hier kannst du den Lautstärkewert verwenden
|
||||||
|
setShowInducation(true);
|
||||||
|
console.log("Lautstärke:", value);
|
||||||
|
}}
|
||||||
|
value={micVol}
|
||||||
|
className="range range-xs range-accent w-full"
|
||||||
|
/>
|
||||||
|
<div className="flex justify-between px-2.5 mt-2 text-xs">
|
||||||
|
<span>0</span>
|
||||||
|
<span>100</span>
|
||||||
|
<span>200</span>
|
||||||
|
<span>300</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{showIndication && (
|
||||||
|
<MicVolumeBar deviceId={selectedDevice ? selectedDevice : ""} volumeInput={micVol} />
|
||||||
|
)}
|
||||||
|
{/* <MicVolumeIndication deviceId={selectedDevice ? selectedDevice : ""} volumeInput={40} /> */}
|
||||||
|
{/* <MicVolumeIndication deviceId={selectedDevice ? selectedDevice : ""} volumeInput={40
|
||||||
|
} />
|
||||||
|
{/* FÜGE HIER BITTE DEN MIKROFONAUSSCHLAG EIN WIE IN DER V1 */}
|
||||||
|
<div className="divider w-full" />
|
||||||
|
</div>
|
||||||
|
<p className="flex items-center gap-2 text-base mb-2">
|
||||||
|
<Volume2 size={20} /> Ausgabelautstärke
|
||||||
|
</p>
|
||||||
|
<div className="w-full">
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min={0}
|
||||||
|
max={100}
|
||||||
|
defaultValue={40}
|
||||||
|
className="range range-xs range-accent w-full"
|
||||||
|
/>
|
||||||
|
<div className="flex justify-between px-2.5 mt-2 text-xs">
|
||||||
|
<span>0</span>
|
||||||
|
<span>25</span>
|
||||||
|
<span>50</span>
|
||||||
|
<span>75</span>
|
||||||
|
<span>100</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-between modal-action">
|
||||||
|
<button
|
||||||
|
className="btn btn-soft"
|
||||||
|
type="submit"
|
||||||
|
onSubmit={() => false}
|
||||||
|
onClick={() => {
|
||||||
|
modalRef.current?.close();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Schließen
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-soft btn-success"
|
||||||
|
type="submit"
|
||||||
|
onSubmit={() => false}
|
||||||
|
onClick={async () => {
|
||||||
|
await editUserMutation.mutateAsync({
|
||||||
|
user: {
|
||||||
|
settingsMicDevice: selectedDevice,
|
||||||
|
settingsMicVolume: micVol,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setMic(selectedDevice, micVol);
|
||||||
|
modalRef.current?.close();
|
||||||
|
toast.success("Einstellungen gespeichert");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Speichern
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Settings = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<SettingsBtn />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -128,6 +128,8 @@ export const ContextMenu = () => {
|
|||||||
setMissionFormValues({
|
setMissionFormValues({
|
||||||
...parsed,
|
...parsed,
|
||||||
state: "draft",
|
state: "draft",
|
||||||
|
addressLat: contextMenu.lat,
|
||||||
|
addressLng: contextMenu.lng,
|
||||||
addressOSMways: [closestToContext],
|
addressOSMways: [closestToContext],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ const MissionPopupContent = ({
|
|||||||
|
|
||||||
const handleTabChange = useCallback(
|
const handleTabChange = useCallback(
|
||||||
(tab: "home" | "details" | "patient" | "log") => {
|
(tab: "home" | "details" | "patient" | "log") => {
|
||||||
console.log("handleTabChange", tab);
|
|
||||||
setMissionMarker({
|
setMissionMarker({
|
||||||
open: [
|
open: [
|
||||||
{
|
{
|
||||||
@@ -284,10 +283,6 @@ const MissionMarker = ({ mission }: { mission: Mission }) => {
|
|||||||
mission: Mission,
|
mission: Mission,
|
||||||
anchor: "topleft" | "topright" | "bottomleft" | "bottomright",
|
anchor: "topleft" | "topright" | "bottomleft" | "bottomright",
|
||||||
) => {
|
) => {
|
||||||
console.log(
|
|
||||||
HPGValidationRequired(mission.missionStationIds, aircrafts, mission.hpgMissionString),
|
|
||||||
);
|
|
||||||
|
|
||||||
const markerColor = needsAction
|
const markerColor = needsAction
|
||||||
? MISSION_STATUS_COLORS["attention"]
|
? MISSION_STATUS_COLORS["attention"]
|
||||||
: MISSION_STATUS_COLORS[mission.state];
|
: MISSION_STATUS_COLORS[mission.state];
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import {
|
import {
|
||||||
getPublicUser,
|
getPublicUser,
|
||||||
|
HpgState,
|
||||||
HpgValidationState,
|
HpgValidationState,
|
||||||
Mission,
|
Mission,
|
||||||
MissionLog,
|
MissionLog,
|
||||||
@@ -37,6 +38,7 @@ import { getStationsAPI } from "querys/stations";
|
|||||||
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||||
import { HPGValidationRequired } from "helpers/hpgValidationRequired";
|
import { HPGValidationRequired } from "helpers/hpgValidationRequired";
|
||||||
import { getOsmAddress } from "querys/osm";
|
import { getOsmAddress } from "querys/osm";
|
||||||
|
import { hpgStateToFMSStatus } from "helpers/hpgStateToFmsStatus";
|
||||||
|
|
||||||
const Einsatzdetails = ({
|
const Einsatzdetails = ({
|
||||||
mission,
|
mission,
|
||||||
@@ -161,10 +163,11 @@ const Einsatzdetails = ({
|
|||||||
<Navigation size={16} /> {mission.addressStreet}
|
<Navigation size={16} /> {mission.addressStreet}
|
||||||
</p>
|
</p>
|
||||||
<p className="flex items-center gap-2">
|
<p className="flex items-center gap-2">
|
||||||
|
<LocateFixed size={16} />
|
||||||
{mission.addressZip && mission.addressCity ? (
|
{mission.addressZip && mission.addressCity ? (
|
||||||
`${mission.addressZip} ${mission.addressCity}`
|
`${mission.addressZip} ${mission.addressCity}`
|
||||||
) : (
|
) : (
|
||||||
<span className="italic text-gray-400">PLZ Ort nicht angegeben</span>
|
<span className="italic text-gray-400">PLZ / Ort nicht angegeben</span>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -366,8 +369,15 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
|
|
||||||
const sendAlertMutation = useMutation({
|
const sendAlertMutation = useMutation({
|
||||||
mutationKey: ["missions"],
|
mutationKey: ["missions"],
|
||||||
mutationFn: ({ id, stationId }: { id: number; stationId?: number }) =>
|
mutationFn: ({
|
||||||
sendMissionAPI(id, { stationId }),
|
id,
|
||||||
|
stationId,
|
||||||
|
vehicleName,
|
||||||
|
}: {
|
||||||
|
id: number;
|
||||||
|
stationId?: number;
|
||||||
|
vehicleName?: "ambulance" | "police" | "firebrigade";
|
||||||
|
}) => sendMissionAPI(id, { stationId, vehicleName }),
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error("Fehler beim Alarmieren");
|
toast.error("Fehler beim Alarmieren");
|
||||||
@@ -379,6 +389,25 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
|
|
||||||
const dispatcherConnected = useDispatchConnectionStore((s) => s.status) === "connected";
|
const dispatcherConnected = useDispatchConnectionStore((s) => s.status) === "connected";
|
||||||
|
|
||||||
|
const HPGVehicle = ({ state, name }: { state: HpgState; name: string }) => (
|
||||||
|
<li className="flex items-center gap-2">
|
||||||
|
<span
|
||||||
|
className="font-bold text-base"
|
||||||
|
style={{
|
||||||
|
color: FMS_STATUS_TEXT_COLORS[hpgStateToFMSStatus(state)],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{hpgStateToFMSStatus(state)}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span className="text-base-content">
|
||||||
|
<div>
|
||||||
|
<span className="font-bold">{name}</span>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4 text-base-content">
|
<div className="p-4 text-base-content">
|
||||||
<div className="flex items-center w-full justify-between mb-2">
|
<div className="flex items-center w-full justify-between mb-2">
|
||||||
@@ -435,6 +464,11 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{mission.hpgAmbulanceState && <HPGVehicle state={mission.hpgAmbulanceState} name="RTW" />}
|
||||||
|
{mission.hpgFireEngineState && (
|
||||||
|
<HPGVehicle state={mission.hpgFireEngineState} name="Feuerwehr" />
|
||||||
|
)}
|
||||||
|
{mission.hpgPoliceState && <HPGVehicle state={mission.hpgPoliceState} name="Polizei" />}
|
||||||
</ul>
|
</ul>
|
||||||
{dispatcherConnected && (
|
{dispatcherConnected && (
|
||||||
<div>
|
<div>
|
||||||
@@ -475,7 +509,10 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
className="btn btn-sm btn-primary btn-outline"
|
className="btn btn-sm btn-primary btn-outline"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (typeof selectedStation === "string") {
|
if (typeof selectedStation === "string") {
|
||||||
toast.error("Fahrzeuge werden aktuell nicht unterstützt");
|
await sendAlertMutation.mutate({
|
||||||
|
id: mission.id,
|
||||||
|
vehicleName: selectedStation,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!selectedStation?.id) return;
|
if (!selectedStation?.id) return;
|
||||||
await updateMissionMutation.mutateAsync({
|
await updateMissionMutation.mutateAsync({
|
||||||
@@ -520,7 +557,6 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
|
|||||||
queryClient.invalidateQueries({ queryKey: ["missions"] });
|
queryClient.invalidateQueries({ queryKey: ["missions"] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log(mission.missionLog);
|
|
||||||
|
|
||||||
if (!session.data?.user) return null;
|
if (!session.data?.user) return null;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { PublicUser } from "@repo/db";
|
import { PublicUser } from "@repo/db";
|
||||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
|
||||||
import { channel } from "diagnostics_channel";
|
|
||||||
import { dispatchSocket } from "dispatch/socket";
|
import { dispatchSocket } from "dispatch/socket";
|
||||||
import { serverApi } from "helpers/axios";
|
import { serverApi } from "helpers/axios";
|
||||||
import {
|
import {
|
||||||
@@ -17,6 +15,8 @@ import { create } from "zustand";
|
|||||||
let interval: NodeJS.Timeout;
|
let interval: NodeJS.Timeout;
|
||||||
|
|
||||||
type TalkState = {
|
type TalkState = {
|
||||||
|
micDeviceId: string | null;
|
||||||
|
micVolume: number;
|
||||||
isTalking: boolean;
|
isTalking: boolean;
|
||||||
source: string;
|
source: string;
|
||||||
state: "connecting" | "connected" | "disconnected" | "error";
|
state: "connecting" | "connected" | "disconnected" | "error";
|
||||||
@@ -24,7 +24,7 @@ type TalkState = {
|
|||||||
connectionQuality: ConnectionQuality;
|
connectionQuality: ConnectionQuality;
|
||||||
remoteParticipants: number;
|
remoteParticipants: number;
|
||||||
toggleTalking: () => void;
|
toggleTalking: () => void;
|
||||||
|
setMic: (micDeviceId: string | null, volume: number) => void;
|
||||||
connect: (roomName: string) => void;
|
connect: (roomName: string) => void;
|
||||||
disconnect: () => void;
|
disconnect: () => void;
|
||||||
room: Room | null;
|
room: Room | null;
|
||||||
@@ -38,15 +38,23 @@ const getToken = async (roomName: string) => {
|
|||||||
export const useAudioStore = create<TalkState>((set, get) => ({
|
export const useAudioStore = create<TalkState>((set, get) => ({
|
||||||
isTalking: false,
|
isTalking: false,
|
||||||
message: null,
|
message: null,
|
||||||
|
micDeviceId: null,
|
||||||
|
micVolume: 1,
|
||||||
state: "disconnected",
|
state: "disconnected",
|
||||||
source: "",
|
source: "",
|
||||||
remoteParticipants: 0,
|
remoteParticipants: 0,
|
||||||
connectionQuality: ConnectionQuality.Unknown,
|
connectionQuality: ConnectionQuality.Unknown,
|
||||||
room: null,
|
room: null,
|
||||||
|
setMic: (micDeviceId, micVolume) => {
|
||||||
|
set({ micDeviceId, micVolume });
|
||||||
|
},
|
||||||
toggleTalking: () => {
|
toggleTalking: () => {
|
||||||
const { room, isTalking } = get();
|
const { room, isTalking, micDeviceId, micVolume } = get();
|
||||||
if (!room) return;
|
if (!room) return;
|
||||||
room.localParticipant.setMicrophoneEnabled(!isTalking);
|
// Todo: use micVolume
|
||||||
|
room.localParticipant.setMicrophoneEnabled(!isTalking, {
|
||||||
|
deviceId: micDeviceId ?? undefined,
|
||||||
|
});
|
||||||
|
|
||||||
if (!isTalking) {
|
if (!isTalking) {
|
||||||
// If old status was not talking, we need to emit the PTT event
|
// If old status was not talking, we need to emit the PTT event
|
||||||
@@ -94,23 +102,19 @@ export const useAudioStore = create<TalkState>((set, get) => ({
|
|||||||
|
|
||||||
handleDisconnect();
|
handleDisconnect();
|
||||||
})
|
})
|
||||||
.on(RoomEvent.ConnectionQualityChanged, (connectionQuality) =>
|
.on(RoomEvent.ConnectionQualityChanged, (connectionQuality) => set({ connectionQuality }))
|
||||||
set({ connectionQuality }),
|
|
||||||
)
|
|
||||||
|
|
||||||
// Track events
|
// Track events
|
||||||
.on(RoomEvent.TrackSubscribed, handleTrackSubscribed)
|
.on(RoomEvent.TrackSubscribed, handleTrackSubscribed)
|
||||||
.on(RoomEvent.TrackUnsubscribed, handleTrackUnsubscribed)
|
.on(RoomEvent.TrackUnsubscribed, handleTrackUnsubscribed)
|
||||||
.on(RoomEvent.ActiveSpeakersChanged, handleActiveSpeakerChange)
|
.on(RoomEvent.ActiveSpeakersChanged, handleActiveSpeakerChange)
|
||||||
.on(RoomEvent.LocalTrackUnpublished, handleLocalTrackUnpublished);
|
.on(RoomEvent.LocalTrackUnpublished, handleLocalTrackUnpublished);
|
||||||
await room.connect(url, token);
|
await room.connect(url, token, {});
|
||||||
console.log(room);
|
|
||||||
set({ room });
|
set({ room });
|
||||||
|
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
set({
|
set({
|
||||||
remoteParticipants:
|
remoteParticipants: room.numParticipants === 0 ? 0 : room.numParticipants - 1, // Unreliable and delayed
|
||||||
room.numParticipants === 0 ? 0 : room.numParticipants - 1, // Unreliable and delayed
|
|
||||||
});
|
});
|
||||||
}, 500);
|
}, 500);
|
||||||
} catch (error: Error | unknown) {
|
} catch (error: Error | unknown) {
|
||||||
@@ -150,11 +154,7 @@ const handlePTT = (data: PTTData) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOtherPTT = (data: {
|
const handleOtherPTT = (data: { publicUser: PublicUser; channel: string; source: string }) => {
|
||||||
publicUser: PublicUser;
|
|
||||||
channel: string;
|
|
||||||
source: string;
|
|
||||||
}) => {
|
|
||||||
const currentChannel = useAudioStore.getState().room?.name;
|
const currentChannel = useAudioStore.getState().room?.name;
|
||||||
console.log("Other PTT", data);
|
console.log("Other PTT", data);
|
||||||
if (data.channel === currentChannel)
|
if (data.channel === currentChannel)
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { dispatchSocket } from "../../dispatch/socket";
|
import { dispatchSocket } from "../../dispatch/socket";
|
||||||
import toast from "react-hot-toast";
|
import { useAudioStore } from "_store/audioStore";
|
||||||
import { HPGnotificationToast } from "_components/customToasts/HPGnotification";
|
|
||||||
import { NotificationPayload } from "@repo/db";
|
|
||||||
|
|
||||||
interface ConnectionStore {
|
interface ConnectionStore {
|
||||||
status: "connected" | "disconnected" | "connecting" | "error";
|
status: "connected" | "disconnected" | "connecting" | "error";
|
||||||
message: string;
|
message: string;
|
||||||
selectedZone: string;
|
selectedZone: string;
|
||||||
logoffTime: string;
|
logoffTime: string;
|
||||||
connect: (
|
connect: (uid: string, selectedZone: string, logoffTime: string) => Promise<void>;
|
||||||
uid: string,
|
|
||||||
selectedZone: string,
|
|
||||||
logoffTime: string,
|
|
||||||
) => Promise<void>;
|
|
||||||
disconnect: () => void;
|
disconnect: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +34,7 @@ export const useDispatchConnectionStore = create<ConnectionStore>((set) => ({
|
|||||||
|
|
||||||
dispatchSocket.on("connect", () => {
|
dispatchSocket.on("connect", () => {
|
||||||
const { logoffTime, selectedZone } = useDispatchConnectionStore.getState();
|
const { logoffTime, selectedZone } = useDispatchConnectionStore.getState();
|
||||||
|
useAudioStore.getInitialState().connect("LST_01");
|
||||||
dispatchSocket.emit("connect-dispatch", {
|
dispatchSocket.emit("connect-dispatch", {
|
||||||
logoffTime,
|
logoffTime,
|
||||||
selectedZone,
|
selectedZone,
|
||||||
|
|||||||
@@ -1,17 +1,10 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { dispatchSocket } from "../../dispatch/socket";
|
import { dispatchSocket } from "../../dispatch/socket";
|
||||||
import {
|
import { ConnectedAircraft, Mission, MissionSdsLog, Station, User } from "@repo/db";
|
||||||
ConnectedAircraft,
|
|
||||||
Mission,
|
|
||||||
MissionSdsLog,
|
|
||||||
NotificationPayload,
|
|
||||||
Station,
|
|
||||||
User,
|
|
||||||
} from "@repo/db";
|
|
||||||
import { pilotSocket } from "pilot/socket";
|
import { pilotSocket } from "pilot/socket";
|
||||||
import { useDmeStore } from "_store/pilot/dmeStore";
|
import { useDmeStore } from "_store/pilot/dmeStore";
|
||||||
import { useMrtStore } from "_store/pilot/MrtStore";
|
import { useMrtStore } from "_store/pilot/MrtStore";
|
||||||
import toast from "react-hot-toast";
|
import { useAudioStore } from "_store/audioStore";
|
||||||
|
|
||||||
interface ConnectionStore {
|
interface ConnectionStore {
|
||||||
status: "connected" | "disconnected" | "connecting" | "error";
|
status: "connected" | "disconnected" | "connecting" | "error";
|
||||||
@@ -71,6 +64,7 @@ pilotSocket.on("connect", () => {
|
|||||||
usePilotConnectionStore.setState({ status: "connected", message: "" });
|
usePilotConnectionStore.setState({ status: "connected", message: "" });
|
||||||
const { logoffTime, selectedStation } = usePilotConnectionStore.getState();
|
const { logoffTime, selectedStation } = usePilotConnectionStore.getState();
|
||||||
dispatchSocket.disconnect();
|
dispatchSocket.disconnect();
|
||||||
|
useAudioStore.getInitialState().connect("LST_01");
|
||||||
|
|
||||||
pilotSocket.emit("connect-pilot", {
|
pilotSocket.emit("connect-pilot", {
|
||||||
logoffTime,
|
logoffTime,
|
||||||
|
|||||||
49
apps/dispatch/app/api/user/route.ts
Normal file
49
apps/dispatch/app/api/user/route.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@repo/db";
|
||||||
|
|
||||||
|
export async function GET(req: NextRequest): Promise<NextResponse> {
|
||||||
|
try {
|
||||||
|
const { searchParams } = new URL(req.url);
|
||||||
|
const id = searchParams.get("id");
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
return NextResponse.json({ error: "User id is required" }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: { id: id },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return NextResponse.json({ error: "User not found" }, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(user, { status: 200 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return NextResponse.json({ error: "Failed to fetch user" }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||||
|
try {
|
||||||
|
const { searchParams } = new URL(req.url);
|
||||||
|
const id = searchParams.get("id");
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
return NextResponse.json({ error: "User id is required" }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = await req.json();
|
||||||
|
|
||||||
|
const updatedUser = await prisma.user.update({
|
||||||
|
where: { id: id },
|
||||||
|
data: body,
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json(updatedUser, { status: 200 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return NextResponse.json({ error: "Failed to update user" }, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import { Audio } from "../../../_components/Audio";
|
|||||||
/* import { useState } from "react"; */
|
/* import { useState } from "react"; */
|
||||||
import { ExitIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
|
import { ExitIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { SettingsBtn } from "./_components/Settings";
|
import { Settings } from "_components/Settings";
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
/* const [isDark, setIsDark] = useState(false);
|
/* const [isDark, setIsDark] = useState(false);
|
||||||
@@ -35,7 +35,7 @@ export default function Navbar() {
|
|||||||
</div>
|
</div>
|
||||||
{/* <ThemeSwap isDark={isDark} toggleTheme={toggleTheme} /> */}
|
{/* <ThemeSwap isDark={isDark} toggleTheme={toggleTheme} /> */}
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<SettingsBtn />
|
<Settings />
|
||||||
<Link
|
<Link
|
||||||
href={process.env.NEXT_PUBLIC_HUB_URL || "#!"}
|
href={process.env.NEXT_PUBLIC_HUB_URL || "#!"}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import { useRef } from "react";
|
|
||||||
import { GearIcon } from "@radix-ui/react-icons";
|
|
||||||
import { SettingsIcon, Volume2 } from "lucide-react";
|
|
||||||
|
|
||||||
export const SettingsBtn = () => {
|
|
||||||
const modalRef = useRef<HTMLDialogElement>(null);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
className="btn btn-ghost"
|
|
||||||
onSubmit={() => false}
|
|
||||||
onClick={() => {
|
|
||||||
modalRef.current?.showModal();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<GearIcon className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<dialog ref={modalRef} className="modal">
|
|
||||||
<div className="modal-box">
|
|
||||||
<h3 className="flex items-center gap-2 text-lg font-bold mb-5">
|
|
||||||
<SettingsIcon size={20} /> Einstellungen
|
|
||||||
</h3>
|
|
||||||
<div className="flex flex-col items-center justify-center">
|
|
||||||
<fieldset className="fieldset w-full">
|
|
||||||
<label className="floating-label w-full text-base">
|
|
||||||
<span>Eingabegerät</span>
|
|
||||||
<select className="input w-full" defaultValue={0}>
|
|
||||||
<option key={0} value={0} disabled>
|
|
||||||
Bitte wähle ein Eingabegerät...
|
|
||||||
</option>
|
|
||||||
<option key={1} value={1}>
|
|
||||||
Audiogerät 1
|
|
||||||
</option>
|
|
||||||
<option key={2} value={2}>
|
|
||||||
Audiogerät 2
|
|
||||||
</option>
|
|
||||||
<option key={3} value={3}>
|
|
||||||
Audiogerät 3
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
{/* FÜGE HIER BITTE DEN MIKROFONAUSSCHLAG EIN WIE IN DER V1 */}
|
|
||||||
<div className="divider w-full" />
|
|
||||||
</div>
|
|
||||||
<p className="flex items-center gap-2 text-base mb-2">
|
|
||||||
<Volume2 size={20} /> Ausgabelautstärke
|
|
||||||
</p>
|
|
||||||
<div className="w-full">
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min={0}
|
|
||||||
max={100}
|
|
||||||
defaultValue={40}
|
|
||||||
className="range range-xs range-accent w-full"
|
|
||||||
/>
|
|
||||||
<div className="flex justify-between px-2.5 mt-2 text-xs">
|
|
||||||
<span>0</span>
|
|
||||||
<span>25</span>
|
|
||||||
<span>50</span>
|
|
||||||
<span>75</span>
|
|
||||||
<span>100</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-between modal-action">
|
|
||||||
<button
|
|
||||||
className="btn btn-soft"
|
|
||||||
type="submit"
|
|
||||||
onSubmit={() => false}
|
|
||||||
onClick={() => {
|
|
||||||
modalRef.current?.close();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Schließen
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="btn btn-soft btn-success"
|
|
||||||
type="submit"
|
|
||||||
onSubmit={() => false}
|
|
||||||
onClick={() => {
|
|
||||||
modalRef.current?.close();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Speichern
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</dialog>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Settings = () => {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<SettingsBtn />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -4,7 +4,7 @@ import { useForm } from "react-hook-form";
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { BellRing, BookmarkPlus } from "lucide-react";
|
import { BellRing, BookmarkPlus } from "lucide-react";
|
||||||
import { Select } from "_components/Select";
|
import { Select } from "_components/Select";
|
||||||
import { KEYWORD_CATEGORY, missionType, Prisma } from "@repo/db";
|
import { KEYWORD_CATEGORY, Mission, missionType, Prisma } from "@repo/db";
|
||||||
import { MissionOptionalDefaults, MissionOptionalDefaultsSchema } from "@repo/db/zod";
|
import { MissionOptionalDefaults, MissionOptionalDefaultsSchema } from "@repo/db/zod";
|
||||||
import { usePannelStore } from "_store/pannelStore";
|
import { usePannelStore } from "_store/pannelStore";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
@@ -21,6 +21,8 @@ import { getStationsAPI } from "querys/stations";
|
|||||||
import { useMapStore } from "_store/mapStore";
|
import { useMapStore } from "_store/mapStore";
|
||||||
import { getConnectedAircraftsAPI } from "querys/aircrafts";
|
import { getConnectedAircraftsAPI } from "querys/aircrafts";
|
||||||
import { HPGValidationRequired } from "helpers/hpgValidationRequired";
|
import { HPGValidationRequired } from "helpers/hpgValidationRequired";
|
||||||
|
import { selectRandomHPGMissionSzenery } from "helpers/selectRandomHPGMission";
|
||||||
|
import { AxiosError } from "axios";
|
||||||
|
|
||||||
export const MissionForm = () => {
|
export const MissionForm = () => {
|
||||||
const { isEditingMission, editingMissionId, setEditingMission } = usePannelStore();
|
const { isEditingMission, editingMissionId, setEditingMission } = usePannelStore();
|
||||||
@@ -93,7 +95,8 @@ export const MissionForm = () => {
|
|||||||
hpgAmbulanceState: null,
|
hpgAmbulanceState: null,
|
||||||
hpgPoliceState: null,
|
hpgPoliceState: null,
|
||||||
hpgMissionString: null,
|
hpgMissionString: null,
|
||||||
|
hpgSelectedMissionString: null,
|
||||||
|
hpg: null,
|
||||||
missionLog: [],
|
missionLog: [],
|
||||||
}) as Partial<MissionOptionalDefaults>,
|
}) as Partial<MissionOptionalDefaults>,
|
||||||
[session.data?.user.id],
|
[session.data?.user.id],
|
||||||
@@ -132,6 +135,47 @@ export const MissionForm = () => {
|
|||||||
}
|
}
|
||||||
}, [missionFormValues, form, defaultFormValues]);
|
}, [missionFormValues, form, defaultFormValues]);
|
||||||
|
|
||||||
|
const saveMission = async (
|
||||||
|
mission: MissionOptionalDefaults,
|
||||||
|
{ alertWhenValid = false, createNewMission = false } = {},
|
||||||
|
) => {
|
||||||
|
const [hpgSzenario, hpgSzenarioCode] = mission.hpgMissionString?.split(":") || [];
|
||||||
|
const szenarioCode = selectRandomHPGMissionSzenery(hpgSzenarioCode || "");
|
||||||
|
let newMission: Mission;
|
||||||
|
if (createNewMission) {
|
||||||
|
newMission = await createMissionMutation.mutateAsync({
|
||||||
|
...(mission as unknown as Prisma.MissionCreateInput),
|
||||||
|
missionAdditionalInfo:
|
||||||
|
!mission.missionAdditionalInfo.length && hpgSzenario
|
||||||
|
? `HPG-Szenario: ${hpgSzenario}`
|
||||||
|
: mission.missionAdditionalInfo,
|
||||||
|
hpgSelectedMissionString: szenarioCode,
|
||||||
|
});
|
||||||
|
if (validationRequired) {
|
||||||
|
await startHpgValidation(newMission.id, {
|
||||||
|
alertWhenValid,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return newMission;
|
||||||
|
} else {
|
||||||
|
newMission = await editMissionMutation.mutateAsync({
|
||||||
|
id: Number(editingMissionId),
|
||||||
|
mission: {
|
||||||
|
...(mission as unknown as Prisma.MissionCreateInput),
|
||||||
|
missionAdditionalInfo:
|
||||||
|
!mission.missionAdditionalInfo.length && hpgSzenario
|
||||||
|
? `HPG-Szenario: ${hpgSzenario}`
|
||||||
|
: mission.missionAdditionalInfo,
|
||||||
|
hpgSelectedMissionString: szenarioCode,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (validationRequired) {
|
||||||
|
await startHpgValidation(newMission.id, {});
|
||||||
|
}
|
||||||
|
return newMission;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="space-y-4">
|
<form className="space-y-4">
|
||||||
{/* Koorinaten Section */}
|
{/* Koorinaten Section */}
|
||||||
@@ -266,7 +310,7 @@ export const MissionForm = () => {
|
|||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
{/* TODO: Nur anzeigen wenn eine Station mit HPG ausgewählt ist */}
|
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<select
|
<select
|
||||||
{...form.register("hpgMissionString")}
|
{...form.register("hpgMissionString")}
|
||||||
@@ -330,29 +374,20 @@ export const MissionForm = () => {
|
|||||||
className="btn btn-primary flex-1"
|
className="btn btn-primary flex-1"
|
||||||
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
||||||
try {
|
try {
|
||||||
const hpgSzenario = mission.hpgMissionString?.split(":")[0];
|
const newMission = await saveMission(mission);
|
||||||
const newMission = await editMissionMutation.mutateAsync({
|
|
||||||
id: Number(editingMissionId),
|
|
||||||
mission: {
|
|
||||||
...(mission as unknown as Prisma.MissionCreateInput),
|
|
||||||
missionAdditionalInfo:
|
|
||||||
!mission.missionAdditionalInfo.length && hpgSzenario
|
|
||||||
? `HPG-Szenario: ${hpgSzenario}`
|
|
||||||
: mission.missionAdditionalInfo,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (validationRequired) {
|
|
||||||
await startHpgValidation(newMission.id);
|
|
||||||
}
|
|
||||||
toast.success(`Einsatz ${newMission.id} erfolgreich aktualisiert`);
|
toast.success(`Einsatz ${newMission.id} erfolgreich aktualisiert`);
|
||||||
setSeachOSMElements([]); // Reset search elements
|
setSeachOSMElements([]); // Reset search elements
|
||||||
setEditingMission(false, null); // Reset editing state
|
setEditingMission(false, null); // Reset editing state
|
||||||
form.reset(); // Reset the form
|
form.reset(); // Reset the form
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof AxiosError) {
|
||||||
toast.error(
|
toast.error(
|
||||||
`Fehler beim Aktualisieren des Einsatzes: ${(error as Error).message}`,
|
`Fehler beim Erstellen des Einsatzes: ${error.response?.data.error}`,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
toast.error(`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
@@ -365,25 +400,24 @@ export const MissionForm = () => {
|
|||||||
className="btn btn-warning"
|
className="btn btn-warning"
|
||||||
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
||||||
try {
|
try {
|
||||||
const hpgSzenario = mission.hpgMissionString?.split(":")[0];
|
const newMission = await saveMission(mission, {
|
||||||
const newMission = await createMissionMutation.mutateAsync({
|
|
||||||
...(mission as unknown as Prisma.MissionCreateInput),
|
|
||||||
missionAdditionalInfo:
|
|
||||||
!mission.missionAdditionalInfo.length && hpgSzenario
|
|
||||||
? `HPG-Szenario: ${hpgSzenario}`
|
|
||||||
: mission.missionAdditionalInfo,
|
|
||||||
});
|
|
||||||
if (validationRequired) {
|
|
||||||
await startHpgValidation(newMission.id, {
|
|
||||||
alertWhenValid: true,
|
alertWhenValid: true,
|
||||||
});
|
});
|
||||||
} else {
|
if (!validationRequired) {
|
||||||
await sendAlertMutation.mutateAsync(newMission.id);
|
await sendAlertMutation.mutateAsync(newMission.id);
|
||||||
}
|
}
|
||||||
setSeachOSMElements([]); // Reset search elements
|
setSeachOSMElements([]); // Reset search elements
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`);
|
if (error instanceof AxiosError) {
|
||||||
|
toast.error(
|
||||||
|
`Fehler beim Erstellen des Einsatzes: ${error.response?.data.error}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
toast.error(
|
||||||
|
`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
@@ -394,21 +428,24 @@ export const MissionForm = () => {
|
|||||||
className="btn btn-primary flex-1"
|
className="btn btn-primary flex-1"
|
||||||
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
||||||
try {
|
try {
|
||||||
const hpgSzenario = mission.hpgMissionString?.split(":")[0];
|
const newMission = await saveMission(mission, {
|
||||||
const newMission = await createMissionMutation.mutateAsync({
|
createNewMission: true,
|
||||||
...(mission as unknown as Prisma.MissionCreateInput),
|
|
||||||
missionAdditionalInfo:
|
|
||||||
!mission.missionAdditionalInfo.length && hpgSzenario
|
|
||||||
? `HPG-Szenario: ${hpgSzenario}`
|
|
||||||
: mission.missionAdditionalInfo,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setSeachOSMElements([]); // Reset search elements
|
setSeachOSMElements([]); // Reset search elements
|
||||||
await startHpgValidation(newMission.id);
|
|
||||||
toast.success(`Einsatz ${newMission.publicId} erstellt`);
|
toast.success(`Einsatz ${newMission.publicId} erstellt`);
|
||||||
form.reset();
|
form.reset();
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`);
|
if (error instanceof AxiosError) {
|
||||||
|
toast.error(
|
||||||
|
`Fehler beim Erstellen des Einsatzes: ${error.response?.data.error}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
toast.error(
|
||||||
|
`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|||||||
11
apps/dispatch/app/helpers/hpgStateToFmsStatus.ts
Normal file
11
apps/dispatch/app/helpers/hpgStateToFmsStatus.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { HpgState } from "@repo/db";
|
||||||
|
|
||||||
|
export const hpgStateToFMSStatus = (state: HpgState): string => {
|
||||||
|
if (state === "DISPATCHED") {
|
||||||
|
return "3";
|
||||||
|
}
|
||||||
|
if (state === "ON_SCENE") {
|
||||||
|
return "4";
|
||||||
|
}
|
||||||
|
return "2";
|
||||||
|
};
|
||||||
62
apps/dispatch/app/helpers/radioAudio.ts
Normal file
62
apps/dispatch/app/helpers/radioAudio.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// Helper function for distortion curve generation
|
||||||
|
function createDistortionCurve(amount: number): Float32Array {
|
||||||
|
const k = typeof amount === "number" ? amount : 50;
|
||||||
|
const nSamples = 44100;
|
||||||
|
const curve = new Float32Array(nSamples);
|
||||||
|
const deg = Math.PI / 180;
|
||||||
|
|
||||||
|
for (let i = 1; i < nSamples; i += 1) {
|
||||||
|
const x = (i * 2) / nSamples - 1;
|
||||||
|
curve[i] = ((3 + k) * x * 20 * deg) / (Math.PI + k * Math.abs(x));
|
||||||
|
}
|
||||||
|
return curve;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getRadioStream = (stream: MediaStream, volume: number): MediaStream | null => {
|
||||||
|
try {
|
||||||
|
const audioContext = new window.AudioContext();
|
||||||
|
const sourceNode = audioContext.createMediaStreamSource(stream);
|
||||||
|
const destinationNode = audioContext.createMediaStreamDestination();
|
||||||
|
const gainNode = audioContext.createGain();
|
||||||
|
|
||||||
|
gainNode.gain.setValueAtTime(volume, audioContext.currentTime); // Lower gain for reduced volume
|
||||||
|
|
||||||
|
// Create distortion node to simulate radio-like audio
|
||||||
|
const distortionNode = audioContext.createWaveShaper();
|
||||||
|
distortionNode.curve = createDistortionCurve(15);
|
||||||
|
distortionNode.oversample = "none";
|
||||||
|
|
||||||
|
// Compressor node for dynamic range compression
|
||||||
|
const compressorNode = audioContext.createDynamicsCompressor();
|
||||||
|
compressorNode.threshold.setValueAtTime(-60, audioContext.currentTime); // Lower threshold for more compression
|
||||||
|
compressorNode.knee.setValueAtTime(30, audioContext.currentTime); // Slightly softer knee for smoother compression
|
||||||
|
compressorNode.ratio.setValueAtTime(15, audioContext.currentTime); // Higher ratio for stronger compression
|
||||||
|
compressorNode.attack.setValueAtTime(0.002, audioContext.currentTime); // Faster attack for more aggressive compression
|
||||||
|
compressorNode.release.setValueAtTime(0.15, audioContext.currentTime); // Faster release for a "snappier" sound
|
||||||
|
|
||||||
|
// Low-pass filter to simulate reduced fidelity
|
||||||
|
const lowPassFilterNode = audioContext.createBiquadFilter();
|
||||||
|
lowPassFilterNode.type = "lowpass";
|
||||||
|
lowPassFilterNode.frequency.setValueAtTime(2800, audioContext.currentTime);
|
||||||
|
|
||||||
|
// High-pass filter to reduce low-end noise
|
||||||
|
const highPassFilterNode = audioContext.createBiquadFilter();
|
||||||
|
highPassFilterNode.type = "highpass";
|
||||||
|
highPassFilterNode.frequency.setValueAtTime(400, audioContext.currentTime);
|
||||||
|
|
||||||
|
// Chain the nodes
|
||||||
|
sourceNode
|
||||||
|
.connect(distortionNode) // Apply distortion first
|
||||||
|
.connect(highPassFilterNode) // Remove low-end noise
|
||||||
|
.connect(lowPassFilterNode) // Simulate reduced fidelity
|
||||||
|
.connect(compressorNode) // Apply compression
|
||||||
|
.connect(gainNode) // Connect to gain node
|
||||||
|
.connect(destinationNode); // Connect to output
|
||||||
|
|
||||||
|
// Return the modified stream
|
||||||
|
return destinationNode.stream;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error processing audio stream:", error);
|
||||||
|
return null; // In case of error, return null so that the page doesn’t hang
|
||||||
|
}
|
||||||
|
};
|
||||||
28
apps/dispatch/app/helpers/selectRandomHPGMission.ts
Normal file
28
apps/dispatch/app/helpers/selectRandomHPGMission.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
export const selectRandomHPGMissionSzenery = (code: string) => {
|
||||||
|
const scenery = code
|
||||||
|
.split("_")
|
||||||
|
.map((n: string) => {
|
||||||
|
const numbers = n.split(",");
|
||||||
|
|
||||||
|
const parsedNumbers = numbers
|
||||||
|
.map((num) => {
|
||||||
|
if (num.includes("-")) {
|
||||||
|
const [min, max] = num.split("-").map(Number);
|
||||||
|
// creae a range of numbers
|
||||||
|
return Array.from(
|
||||||
|
{
|
||||||
|
length: max! - min! + 1,
|
||||||
|
},
|
||||||
|
(_, ai) => ai + min!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Number(num);
|
||||||
|
})
|
||||||
|
.flat();
|
||||||
|
const randomI = Math.floor(Math.random() * parsedNumbers.length);
|
||||||
|
return parsedNumbers[randomI];
|
||||||
|
})
|
||||||
|
.join("_");
|
||||||
|
console.log("scenery", scenery);
|
||||||
|
return scenery;
|
||||||
|
};
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Connection } from "./Connection";
|
import { Connection } from "./_components/Connection";
|
||||||
/* import { ThemeSwap } from "./ThemeSwap"; */
|
/* import { ThemeSwap } from "./ThemeSwap"; */
|
||||||
import { Audio } from "../../../_components/Audio";
|
import { Audio } from "../../../_components/Audio";
|
||||||
/* import { useState } from "react"; */
|
/* import { useState } from "react"; */
|
||||||
import { ExitIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
|
import { ExitIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Settings } from "./Settings";
|
import { Settings } from "_components/Settings";
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
/* const [isDark, setIsDark] = useState(false);
|
/* const [isDark, setIsDark] = useState(false);
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import { useRef } from "react";
|
|
||||||
import { GearIcon } from "@radix-ui/react-icons";
|
|
||||||
import { SettingsIcon, Volume2 } from "lucide-react";
|
|
||||||
|
|
||||||
export const SettingsBtn = () => {
|
|
||||||
const modalRef = useRef<HTMLDialogElement>(null);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
className="btn btn-ghost"
|
|
||||||
onSubmit={() => false}
|
|
||||||
onClick={() => {
|
|
||||||
modalRef.current?.showModal();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<GearIcon className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<dialog ref={modalRef} className="modal">
|
|
||||||
<div className="modal-box">
|
|
||||||
<h3 className="flex items-center gap-2 text-lg font-bold mb-5">
|
|
||||||
<SettingsIcon size={20} /> Einstellungen
|
|
||||||
</h3>
|
|
||||||
<div className="flex flex-col items-center justify-center">
|
|
||||||
<fieldset className="fieldset w-full">
|
|
||||||
<label className="floating-label w-full text-base">
|
|
||||||
<span>Eingabegerät</span>
|
|
||||||
<select className="input w-full" defaultValue={0}>
|
|
||||||
<option key={0} value={0} disabled>
|
|
||||||
Bitte wähle ein Eingabegerät...
|
|
||||||
</option>
|
|
||||||
<option key={1} value={1}>
|
|
||||||
Audiogerät 1
|
|
||||||
</option>
|
|
||||||
<option key={2} value={2}>
|
|
||||||
Audiogerät 2
|
|
||||||
</option>
|
|
||||||
<option key={3} value={3}>
|
|
||||||
Audiogerät 3
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
</fieldset>
|
|
||||||
{/* FÜGE HIER BITTE DEN MIKROFONAUSSCHLAG EIN WIE IN DER V1 */}
|
|
||||||
<div className="divider w-full" />
|
|
||||||
</div>
|
|
||||||
<p className="flex items-center gap-2 text-base mb-2">
|
|
||||||
<Volume2 size={20} /> Ausgabelautstärke
|
|
||||||
</p>
|
|
||||||
<div className="w-full">
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
min={0}
|
|
||||||
max={100}
|
|
||||||
defaultValue={40}
|
|
||||||
className="range range-xs range-accent w-full"
|
|
||||||
/>
|
|
||||||
<div className="flex justify-between px-2.5 mt-2 text-xs">
|
|
||||||
<span>0</span>
|
|
||||||
<span>25</span>
|
|
||||||
<span>50</span>
|
|
||||||
<span>75</span>
|
|
||||||
<span>100</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-between modal-action">
|
|
||||||
<button
|
|
||||||
className="btn btn-soft"
|
|
||||||
type="submit"
|
|
||||||
onSubmit={() => false}
|
|
||||||
onClick={() => {
|
|
||||||
modalRef.current?.close();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Schließen
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="btn btn-soft btn-success"
|
|
||||||
type="submit"
|
|
||||||
onSubmit={() => false}
|
|
||||||
onClick={() => {
|
|
||||||
modalRef.current?.close();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Speichern
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</dialog>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Settings = () => {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<SettingsBtn />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -19,21 +19,12 @@ export const createMissionAPI = async (mission: Prisma.MissionCreateInput) => {
|
|||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const editMissionAPI = async (
|
export const editMissionAPI = async (id: number, mission: Prisma.MissionUpdateInput) => {
|
||||||
id: number,
|
|
||||||
mission: Prisma.MissionUpdateInput,
|
|
||||||
) => {
|
|
||||||
const respone = await serverApi.patch<Mission>(`/mission/${id}`, mission);
|
const respone = await serverApi.patch<Mission>(`/mission/${id}`, mission);
|
||||||
return respone.data;
|
return respone.data;
|
||||||
};
|
};
|
||||||
export const sendSdsMessageAPI = async (
|
export const sendSdsMessageAPI = async (id: number, sdsMessage: MissionSdsLog) => {
|
||||||
id: number,
|
const respone = await serverApi.post<Mission>(`/mission/${id}/send-sds`, sdsMessage);
|
||||||
sdsMessage: MissionSdsLog,
|
|
||||||
) => {
|
|
||||||
const respone = await serverApi.post<Mission>(
|
|
||||||
`/mission/${id}/send-sds`,
|
|
||||||
sdsMessage,
|
|
||||||
);
|
|
||||||
return respone.data;
|
return respone.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,10 +34,7 @@ export const startHpgValidation = async (
|
|||||||
alertWhenValid?: boolean;
|
alertWhenValid?: boolean;
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
const respone = await serverApi.post<Mission>(
|
const respone = await serverApi.post<Mission>(`/mission/${id}/validate-hpg`, config);
|
||||||
`/mission/${id}/validate-hpg`,
|
|
||||||
config,
|
|
||||||
);
|
|
||||||
return respone.data;
|
return respone.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,14 +42,17 @@ export const sendMissionAPI = async (
|
|||||||
id: number,
|
id: number,
|
||||||
{
|
{
|
||||||
stationId,
|
stationId,
|
||||||
|
vehicleName,
|
||||||
}: {
|
}: {
|
||||||
stationId?: number;
|
stationId?: number;
|
||||||
|
vehicleName?: "ambulance" | "police" | "firebrigade";
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
const respone = await serverApi.post<{
|
const respone = await serverApi.post<{
|
||||||
message: string;
|
message: string;
|
||||||
}>(`/mission/${id}/send-alert`, {
|
}>(`/mission/${id}/send-alert`, {
|
||||||
stationId,
|
stationId,
|
||||||
|
vehicleName,
|
||||||
});
|
});
|
||||||
return respone.data;
|
return respone.data;
|
||||||
};
|
};
|
||||||
|
|||||||
12
apps/dispatch/app/querys/user.ts
Normal file
12
apps/dispatch/app/querys/user.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { Prisma, User } from "@repo/db";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
export const editUserAPI = async (id: string, user: Prisma.UserUpdateInput) => {
|
||||||
|
const response = await axios.post<User>(`/api/user?id=${id}`, user);
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getUserAPI = async (id: string) => {
|
||||||
|
const response = await axios.get<User>(`/api/user?id=${id}`);
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@livekit/components-react": "^2.8.1",
|
"@livekit/components-react": "^2.8.1",
|
||||||
"@livekit/components-styles": "^1.1.4",
|
"@livekit/components-styles": "^1.1.4",
|
||||||
|
"@livekit/track-processors": "^0.5.6",
|
||||||
"@radix-ui/react-icons": "^1.3.2",
|
"@radix-ui/react-icons": "^1.3.2",
|
||||||
"@repo/db": "*",
|
"@repo/db": "*",
|
||||||
"@repo/ui": "*",
|
"@repo/ui": "*",
|
||||||
|
|||||||
19
package-lock.json
generated
19
package-lock.json
generated
@@ -23,6 +23,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@livekit/components-react": "^2.8.1",
|
"@livekit/components-react": "^2.8.1",
|
||||||
"@livekit/components-styles": "^1.1.4",
|
"@livekit/components-styles": "^1.1.4",
|
||||||
|
"@livekit/track-processors": "^0.5.6",
|
||||||
"@radix-ui/react-icons": "^1.3.2",
|
"@radix-ui/react-icons": "^1.3.2",
|
||||||
"@repo/db": "*",
|
"@repo/db": "*",
|
||||||
"@repo/ui": "*",
|
"@repo/ui": "*",
|
||||||
@@ -1908,6 +1909,24 @@
|
|||||||
"@bufbuild/protobuf": "^1.10.0"
|
"@bufbuild/protobuf": "^1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@livekit/track-processors": {
|
||||||
|
"version": "0.5.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@livekit/track-processors/-/track-processors-0.5.6.tgz",
|
||||||
|
"integrity": "sha512-TlzObrSlp2PKor4VXqg6iefLRFVEb2T1lXwddBFdkPod60XVgYoMOj7V5xJm+UTE2MEtlE0003vUli9PyQGB1g==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@mediapipe/tasks-vision": "0.10.14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"livekit-client": "^1.12.0 || ^2.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@mediapipe/tasks-vision": {
|
||||||
|
"version": "0.10.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mediapipe/tasks-vision/-/tasks-vision-0.10.14.tgz",
|
||||||
|
"integrity": "sha512-vOifgZhkndgybdvoRITzRkIueWWSiCKuEUXXK6Q4FaJsFvRJuwgg++vqFUMlL0Uox62U5aEXFhHxlhV7Ja5e3Q==",
|
||||||
|
"license": "Apache-2.0"
|
||||||
|
},
|
||||||
"node_modules/@next-auth/prisma-adapter": {
|
"node_modules/@next-auth/prisma-adapter": {
|
||||||
"version": "1.0.7",
|
"version": "1.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/@next-auth/prisma-adapter/-/prisma-adapter-1.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/@next-auth/prisma-adapter/-/prisma-adapter-1.0.7.tgz",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ model Mission {
|
|||||||
missionStationUserIds String[] @default([])
|
missionStationUserIds String[] @default([])
|
||||||
missionLog Json[] @default([])
|
missionLog Json[] @default([])
|
||||||
hpgMissionString String?
|
hpgMissionString String?
|
||||||
|
hpgSelectedMissionString String?
|
||||||
hpgAmbulanceState HpgState?
|
hpgAmbulanceState HpgState?
|
||||||
hpgFireEngineState HpgState?
|
hpgFireEngineState HpgState?
|
||||||
hpgPoliceState HpgState?
|
hpgPoliceState HpgState?
|
||||||
@@ -73,9 +74,9 @@ enum MissionState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum HpgState {
|
enum HpgState {
|
||||||
ready
|
NOT_REQUESTED
|
||||||
arrived
|
ON_SCENE
|
||||||
onway
|
DISPATCHED
|
||||||
}
|
}
|
||||||
|
|
||||||
enum HpgValidationState {
|
enum HpgValidationState {
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ model User {
|
|||||||
|
|
||||||
// Settings:
|
// Settings:
|
||||||
settingsNtfyRoom String? @map(name: "settings_ntfy_room")
|
settingsNtfyRoom String? @map(name: "settings_ntfy_room")
|
||||||
|
settingsMicDevice String? @map(name: "settings_mic_device")
|
||||||
|
settingsMicVolume Int? @map(name: "settings_mic_volume")
|
||||||
|
|
||||||
image String?
|
image String?
|
||||||
badges BADGES[] @default([])
|
badges BADGES[] @default([])
|
||||||
|
|||||||
Reference in New Issue
Block a user