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) => {
|
||||
const { id } = req.params;
|
||||
const { stationId } = req.body as { stationId?: number };
|
||||
const { stationId, vehicleName } = req.body as {
|
||||
stationId?: number;
|
||||
vehicleName?: "ambulance" | "police" | "firebrigade";
|
||||
};
|
||||
|
||||
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), {
|
||||
stationId,
|
||||
});
|
||||
@@ -153,7 +193,6 @@ router.post("/:id/send-sds", async (req, res) => {
|
||||
|
||||
router.post("/:id/validate-hpg", async (req, res) => {
|
||||
try {
|
||||
console.log(req.user);
|
||||
const { id } = req.params;
|
||||
const config = req.body as
|
||||
| {
|
||||
@@ -178,37 +217,39 @@ router.post("/:id/validate-hpg", async (req, res) => {
|
||||
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({
|
||||
message: "HPG validation started",
|
||||
});
|
||||
|
||||
/* io.to(`desktop:${activeAircraftinMission}`).emit(
|
||||
io.to(`desktop:${activeAircraftinMission}`).emit(
|
||||
"hpg-validation",
|
||||
{
|
||||
hpgMissionType: mission?.hpgMissionString,
|
||||
lat: mission?.addressLat,
|
||||
lng: mission?.addressLng,
|
||||
},
|
||||
async (result: {
|
||||
state: HpgValidationState;
|
||||
lat: number;
|
||||
lng: number;
|
||||
}) => {
|
||||
async (result: { state: HpgValidationState; lat: number; lng: number }) => {
|
||||
console.log("response from user:", result);
|
||||
|
||||
const newMission = await prisma.mission.update({
|
||||
where: { id: Number(id) },
|
||||
data: {
|
||||
// save position of new mission
|
||||
addressLat:
|
||||
result.state === "POSITION_AMANDED"
|
||||
? result.lat
|
||||
: mission.addressLat,
|
||||
addressLng:
|
||||
result.state === "POSITION_AMANDED"
|
||||
? result.lng
|
||||
: mission.addressLng,
|
||||
addressLat: result.state === "POSITION_AMANDED" ? result.lat : mission.addressLat,
|
||||
addressLng: result.state === "POSITION_AMANDED" ? result.lng : mission.addressLng,
|
||||
hpgLocationLat: result.lat,
|
||||
hpgLocationLng: result.lng,
|
||||
hpgValidationState: result.state,
|
||||
@@ -234,7 +275,7 @@ router.post("/:id/validate-hpg", async (req, res) => {
|
||||
} as NotificationPayload);
|
||||
}
|
||||
},
|
||||
); */
|
||||
);
|
||||
// TODO: remove this after testing
|
||||
setTimeout(() => {
|
||||
io.to(`user:${req.user?.id}`).emit("notification", {
|
||||
|
||||
Reference in New Issue
Block a user