Made Aircrafts fetch from Server. Added OSM Objects to mission
This commit is contained in:
@@ -1,112 +0,0 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
export interface Aircraft {
|
||||
id: string;
|
||||
bosName: string;
|
||||
bosNameShort: string;
|
||||
bosNutzung: string;
|
||||
fmsStatus: string;
|
||||
fmsLog: {
|
||||
status: string;
|
||||
timestamp: string;
|
||||
user: string;
|
||||
}[];
|
||||
location: {
|
||||
lat: number;
|
||||
lng: number;
|
||||
altitude: number;
|
||||
speed: number;
|
||||
};
|
||||
locationHistory: {
|
||||
lat: number;
|
||||
lon: number;
|
||||
altitude: number;
|
||||
speed: number;
|
||||
timestamp: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
interface AircraftStore {
|
||||
aircrafts: Aircraft[];
|
||||
setAircrafts: (aircrafts: Aircraft[]) => void;
|
||||
setAircraft: (aircraft: Aircraft) => void;
|
||||
}
|
||||
|
||||
export const useAircraftsStore = create<AircraftStore>((set) => ({
|
||||
aircrafts: [
|
||||
{
|
||||
id: "1",
|
||||
bosName: "Christoph 31",
|
||||
bosNameShort: "CHX31",
|
||||
bosNutzung: "RTH",
|
||||
fmsStatus: "1",
|
||||
fmsLog: [],
|
||||
location: {
|
||||
lat: 52.546781040592776,
|
||||
lng: 13.369535209542219,
|
||||
altitude: 0,
|
||||
speed: 0,
|
||||
},
|
||||
locationHistory: [],
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
bosName: "Christoph Berlin",
|
||||
bosNameShort: "CHX83",
|
||||
bosNutzung: "ITH",
|
||||
fmsStatus: "2",
|
||||
fmsLog: [],
|
||||
location: {
|
||||
lat: 52.54588546048977,
|
||||
lng: 13.46470691054384,
|
||||
altitude: 0,
|
||||
speed: 0,
|
||||
},
|
||||
locationHistory: [],
|
||||
},
|
||||
{
|
||||
id: "3",
|
||||
bosName: "Christoph 100",
|
||||
bosNameShort: "CHX100",
|
||||
bosNutzung: "RTH",
|
||||
fmsStatus: "7",
|
||||
fmsLog: [],
|
||||
location: {
|
||||
lat: 52.497519717230155,
|
||||
lng: 13.342040806552554,
|
||||
altitude: 0,
|
||||
speed: 0,
|
||||
},
|
||||
locationHistory: [],
|
||||
},
|
||||
{
|
||||
id: "4",
|
||||
bosName: "Christophorus 1",
|
||||
bosNameShort: "A4",
|
||||
bosNutzung: "RTH",
|
||||
fmsStatus: "6",
|
||||
fmsLog: [],
|
||||
location: {
|
||||
lat: 52.50175041192073,
|
||||
lng: 13.478628701227349,
|
||||
altitude: 0,
|
||||
speed: 0,
|
||||
},
|
||||
locationHistory: [],
|
||||
},
|
||||
],
|
||||
setAircrafts: (aircrafts) => set({ aircrafts }),
|
||||
setAircraft: (aircraft) =>
|
||||
set((state) => {
|
||||
const existingAircraftIndex = state.aircrafts.findIndex(
|
||||
(a) => a.id === aircraft.id,
|
||||
);
|
||||
if (existingAircraftIndex !== -1) {
|
||||
const updatedAircrafts = [...state.aircrafts];
|
||||
updatedAircrafts[existingAircraftIndex] = aircraft;
|
||||
return { aircrafts: updatedAircrafts };
|
||||
} else {
|
||||
return { aircrafts: [...state.aircrafts, aircraft] };
|
||||
}
|
||||
}),
|
||||
}));
|
||||
@@ -1,3 +1,4 @@
|
||||
import { OSMWay } from "@repo/db";
|
||||
import { create } from "zustand";
|
||||
|
||||
interface MapStore {
|
||||
@@ -18,30 +19,14 @@ interface MapStore {
|
||||
close: number[];
|
||||
}) => void;
|
||||
openAircraftMarker: {
|
||||
id: string;
|
||||
id: number;
|
||||
tab: "home" | "fms" | "aircraft" | "mission" | "chat";
|
||||
}[];
|
||||
setOpenAircraftMarker: (aircraft: {
|
||||
open: MapStore["openAircraftMarker"];
|
||||
close: string[];
|
||||
close: number[];
|
||||
}) => void;
|
||||
searchElements: {
|
||||
id: number;
|
||||
nodes: {
|
||||
lat: number;
|
||||
lon: number;
|
||||
}[];
|
||||
tags?: {
|
||||
"addr:country"?: string;
|
||||
"addr:city"?: string;
|
||||
"addr:housenumber"?: string;
|
||||
"addr:postcode"?: string;
|
||||
"addr:street"?: string;
|
||||
"addr:suburb"?: string;
|
||||
building?: string;
|
||||
};
|
||||
type: string;
|
||||
}[];
|
||||
searchElements: OSMWay[];
|
||||
setSearchElements: (elements: MapStore["searchElements"]) => void;
|
||||
setContextMenu: (popup: MapStore["contextMenu"]) => void;
|
||||
searchPopup: {
|
||||
@@ -54,8 +39,8 @@ interface MapStore {
|
||||
[aircraftId: string]: "home" | "fms" | "aircraft" | "mission" | "chat";
|
||||
};
|
||||
setAircraftTab: (
|
||||
aircraftId: string,
|
||||
tab: MapStore["aircraftTabs"][string],
|
||||
aircraftId: number,
|
||||
tab: MapStore["aircraftTabs"][number],
|
||||
) => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ interface ConnectionStore {
|
||||
disconnect: () => void;
|
||||
}
|
||||
|
||||
export const useDispatchConnectionStore = create<ConnectionStore>((set) => ({
|
||||
export const usePilotConnectionStore = create<ConnectionStore>((set) => ({
|
||||
status: "disconnected",
|
||||
message: "",
|
||||
selectedStation: null,
|
||||
@@ -40,23 +40,23 @@ export const useDispatchConnectionStore = create<ConnectionStore>((set) => ({
|
||||
|
||||
dispatchSocket.on("connect", () => {
|
||||
pilotSocket.disconnect();
|
||||
useDispatchConnectionStore.setState({ status: "connected", message: "" });
|
||||
usePilotConnectionStore.setState({ status: "connected", message: "" });
|
||||
});
|
||||
|
||||
dispatchSocket.on("connect_error", (err) => {
|
||||
useDispatchConnectionStore.setState({
|
||||
usePilotConnectionStore.setState({
|
||||
status: "error",
|
||||
message: err.message,
|
||||
});
|
||||
});
|
||||
|
||||
dispatchSocket.on("disconnect", () => {
|
||||
useDispatchConnectionStore.setState({ status: "disconnected", message: "" });
|
||||
usePilotConnectionStore.setState({ status: "disconnected", message: "" });
|
||||
});
|
||||
|
||||
dispatchSocket.on("force-disconnect", (reason: string) => {
|
||||
console.log("force-disconnect", reason);
|
||||
useDispatchConnectionStore.setState({
|
||||
usePilotConnectionStore.setState({
|
||||
status: "disconnected",
|
||||
message: reason,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user