Asset point updated for the vehicle and conveyor widget 3D update delete routing completed
This commit is contained in:
@@ -1,28 +1,10 @@
|
||||
import { Request, Response } from "express";
|
||||
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
||||
interface ITriggerConveyor {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}
|
||||
interface ITriggerVehicle {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
}
|
||||
interface IConnection {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: { pathUUID: string; pointUUID: string }[];
|
||||
}
|
||||
|
||||
interface IPointBase {
|
||||
uuid: string;
|
||||
position: number[];
|
||||
connections: IConnection;
|
||||
}
|
||||
|
||||
interface IPointConveyor extends IPointBase {
|
||||
rotation: number[];
|
||||
actions: Array<{
|
||||
@@ -41,25 +23,27 @@ interface IPointConveyor extends IPointBase {
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}>;
|
||||
connections: {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: Array<{ pathUUID: string; pointUUID: string }>;
|
||||
};
|
||||
}
|
||||
|
||||
interface IPointVehicle extends IPointBase {
|
||||
actions: Array<{
|
||||
actions: {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
hitCount: number;
|
||||
start: string;
|
||||
end: string;
|
||||
start: { x: number; y: number } | {};
|
||||
end: { x: number; y: number } | {};
|
||||
buffer: number;
|
||||
}>;
|
||||
triggers: Array<{
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
}>;
|
||||
};
|
||||
connections: {
|
||||
source: { modelUUID: string; pointUUID: string };
|
||||
targets: Array<{ pathUUID: string; pointUUID: string }>;
|
||||
};
|
||||
speed: number;
|
||||
}
|
||||
export class pointService {
|
||||
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||
@@ -188,31 +172,31 @@ export class pointService {
|
||||
const vehiclePoint: IPointVehicle = {
|
||||
uuid: "point1UUID",
|
||||
position: [0, 1.3, 0],
|
||||
actions: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "string",
|
||||
hitCount: 1,
|
||||
isUsed: false,
|
||||
start: "start",
|
||||
end: "end",
|
||||
buffer: 0,
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{ uuid: "string", name: "string", type: "string", isUsed: false },
|
||||
],
|
||||
actions: {
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "string",
|
||||
hitCount: 1,
|
||||
start: { x: 0, y: 0 },
|
||||
end: { x: 0, y: 0 },
|
||||
buffer: 0,
|
||||
},
|
||||
connections: {
|
||||
source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
source: { modelUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
targets: [{ pathUUID: "modelUUID", pointUUID: "point1UUID" }],
|
||||
},
|
||||
speed: 2,
|
||||
};
|
||||
if ("rotation" in vehiclePoint) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Rotation not allowed for Vehicle points" });
|
||||
}
|
||||
if ("triggers" in vehiclePoint) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Triggers not allowed for Vehicle points" });
|
||||
}
|
||||
|
||||
await pointModel(organization).create({
|
||||
...baseData,
|
||||
@@ -248,56 +232,3 @@ export class pointService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function to remove `_id` recursively
|
||||
// const removeIdRecursively = (obj: any): any => {
|
||||
// if (Array.isArray(obj)) {
|
||||
// return obj.map(removeIdRecursively);
|
||||
// } else if (obj !== null && typeof obj === "object") {
|
||||
// const { _id, ...rest } = obj; // Remove `_id`
|
||||
// return Object.keys(rest).reduce((acc, key) => {
|
||||
// acc[key] = removeIdRecursively(rest[key]); // Recursively clean nested objects
|
||||
// return acc;
|
||||
// }, {} as any);
|
||||
// }
|
||||
// return obj;
|
||||
// };
|
||||
// static async gettypePoints(req: Request, res: Response): Promise<any> {
|
||||
// const { modelfileID, organization } = req.params;
|
||||
// try {
|
||||
// const { ConveyorModel, VehicleModel } = pointModel(organization);
|
||||
|
||||
// const conveyorData = await ConveyorModel.findOne({ modelfileID })
|
||||
// .select("-_id -createdAt -updatedAt")
|
||||
// .lean();
|
||||
|
||||
// const vehicleData = await VehicleModel.findOne({ modelfileID })
|
||||
// .select("-_id -createdAt -updatedAt")
|
||||
// .lean();
|
||||
|
||||
// if (!conveyorData && !vehicleData) {
|
||||
// return res.status(404).json({ message: "Data not found" });
|
||||
// }
|
||||
|
||||
// const combinedData = [conveyorData, vehicleData].filter(Boolean);
|
||||
|
||||
// const formattedData = combinedData.map((data) => {
|
||||
// const typedData = data as any;
|
||||
|
||||
// return {
|
||||
// modelfileID: typedData.modelfileID,
|
||||
// type: typedData.type,
|
||||
// points: Array.isArray(typedData.points)
|
||||
// ? typedData.points.map((point: any) => ({
|
||||
// position: point.position,
|
||||
// rotation: point.rotation,
|
||||
// }))
|
||||
// : [],
|
||||
// };
|
||||
// });
|
||||
|
||||
// return res.status(200).json(formattedData);
|
||||
// } catch (error) {
|
||||
// res.status(500).json({ message: "Server error", error });
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user