Visualization Part 2d and floating API Completed. Template Save and Get API completed

This commit is contained in:
2025-03-29 17:31:08 +05:30
parent bb3ece0ff6
commit 7c0e59edad
21 changed files with 604 additions and 228 deletions

View File

@@ -10,9 +10,10 @@ export class assetsFloorservice {
const {
modeluuid,
modelname,
position,
speed,
assetPosition,
modelfileID,
rotation,
assetRotation,
isLocked,
isVisible,
organization,
@@ -28,8 +29,8 @@ export class assetsFloorservice {
const updatevalue = await assetModel(organization).findOneAndUpdate(
{ modeluuid: modeluuid, modelname: modelname },
{
position: position,
rotation: rotation,
assetPosition: assetPosition,
assetRotation: assetRotation,
isVisible: isVisible,
isLocked: isLocked,
},
@@ -37,95 +38,46 @@ export class assetsFloorservice {
);
res.status(201).json(updatevalue);
} else {
// const newValue = await assetModel(organization).create({
// modeluuid,
// modelfileID,
// modelname,
// position,
// rotation,
// isLocked,
// isVisible,
// points,
// });
// for (const point of points) {
// // Create actions if they exist
// for (const action of point.actions || []) {
// const actionData = await actionModel(organization).create({
// pointsUUID: point.uuid,
// actionUUID: action.uuid,
// eventData: {
// uuid: action.uuid,
// type: action.type,
// material: action.material,
// delay: action.delay,
// spawn_Interval: action.spawnInterval,
// },
// });
// // Push action ID to point
// newValue.points
// .find((p: any) => p.uuid === point.uuid)
// ?.actions.push(actionData._id);
// }
// // Create triggers if they exist
// for (const trigger of point.triggers || []) {
// const triggerData = await triggerModel(organization).create({
// pointsUUID: point.uuid,
// actionUUID: trigger.uuid,
// triggerData: {
// type: trigger.type,
// },
// });
// // Push trigger ID to point
// newValue.points
// .find((p: any) => p.uuid === point.uuid)
// ?.triggers.push(triggerData._id);
// }
// }
// // Save the updated document
// await newValue.save();
// res.status(201).json(newValue);
let pointRefs = [];
for (const point of points) {
let actionRefs = [];
let triggerRefs = [];
// Store Actions (Events)
if (point.actions && point.actions.length > 0) {
for (const action of point.actions) {
const actionDoc = await actionModel(organization).create({
pointsUUID: point.uuid,
actionUUID: action.uuid,
isArchive: false,
eventData: [action], // Store the action data
uuid: action.uuid,
name: action.name,
type: action.type,
material: action.material,
delay: action.delay,
spawn_Interval: action.spawn_Interval,
// eventData: [action],
});
await actionDoc.save();
actionRefs.push(actionDoc._id); // Store reference
actionRefs.push(actionDoc._id);
}
}
// Store Triggers
if (point.triggers && point.triggers.length > 0) {
for (const trigger of point.triggers) {
const triggerDoc = await triggerModel(organization).create({
pointsUUID: point.uuid,
actionUUID: trigger.uuid,
isArchive: false,
triggerData: [trigger], // Store trigger data
uuid: trigger.uuid,
name: trigger.name,
type: trigger.type,
bufferTime: trigger.bufferTime,
// triggerData: [trigger],
});
await triggerDoc.save();
triggerRefs.push(triggerDoc._id); // Store reference
triggerRefs.push(triggerDoc._id);
}
}
// Store the Point document
pointRefs.push({
uuid: point.uuid,
position: point.position,
@@ -135,13 +87,13 @@ export class assetsFloorservice {
});
}
// Store the main asset document
const assetDoc = await assetModel(organization).create({
modeluuid,
speed,
modelname,
position,
assetPosition,
modelfileID,
rotation,
assetRotation,
isLocked,
isVisible,
points: pointRefs,
@@ -163,22 +115,29 @@ export class assetsFloorservice {
const { organization } = req.params;
const findValue = await assetModel(organization)
.find()
.select("-_id -__v")
.select("-_id")
.populate({
path: "points",
// model: assetModel(organization),
select: "-_id",
})
.populate({
path: "points.actions",
select: "-_id",
populate: {
path: "eventData",
select: "uuid type -_id",
},
model: actionModel(organization),
// select: "-_id",
// populate: {
// path: "eventData",
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
// },
})
.populate({
path: "points.triggers",
select: "-_id",
populate: {
path: "triggerData",
select: "uuid type -_id",
},
model: triggerModel(organization),
// select: "-_id",
// populate: {
// path: "triggerData",
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
// },
});
if (!findValue) {
res.status(200).json("floorItems not found");