Full Visualization Page API completed
This commit is contained in:
15
.env
15
.env
@@ -3,24 +3,9 @@
|
|||||||
# MONGO_PASSWORD=mongodb@hexr2002
|
# MONGO_PASSWORD=mongodb@hexr2002
|
||||||
# MONGO_AUTH_DB=admin
|
# MONGO_AUTH_DB=admin
|
||||||
|
|
||||||
|
|
||||||
MONGO_USER=admin
|
MONGO_USER=admin
|
||||||
MONGO_PASSWORD=admin321
|
MONGO_PASSWORD=admin321
|
||||||
MONGO_AUTH_DB=admin
|
MONGO_AUTH_DB=admin
|
||||||
# MONGO_USER=admin
|
|
||||||
# MONGO_PASSWORD=admin321
|
|
||||||
# MONGO_AUTH_DB=admin
|
|
||||||
MONGO_URI=mongodb://mongo/
|
MONGO_URI=mongodb://mongo/
|
||||||
API_PORT=5000
|
API_PORT=5000
|
||||||
=======
|
|
||||||
MONGO_URI=mongodb://192.168.0.111/
|
|
||||||
MONGO_USER=mydata
|
|
||||||
MONGO_PASSWORD=mongodb@hexr2002
|
|
||||||
MONGO_AUTH_DB=admin
|
|
||||||
# MONGO_USER=admin
|
|
||||||
# MONGO_PASSWORD=admin321
|
|
||||||
# MONGO_AUTH_DB=admin
|
|
||||||
# MONGO_URI=mongodb://mongo/
|
|
||||||
API_PORT=5000
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
SOCKET_PORT=8000
|
SOCKET_PORT=8000
|
||||||
@@ -2,8 +2,10 @@ import * as express from "express";
|
|||||||
import { floatWidgetService } from "../controller/visualization/floatWidgetService.ts";
|
import { floatWidgetService } from "../controller/visualization/floatWidgetService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/floatwidget/save", floatWidgetService.addfloatWidget);
|
router.post("/floatwidget/save", floatWidgetService.addfloatWidget);
|
||||||
|
router.patch("/floatwidget/delete", floatWidgetService.deletefloatWidget);
|
||||||
router.get(
|
router.get(
|
||||||
"/floadData/:zoneId/:organization",
|
"/floadData/:zoneId/:organization",
|
||||||
floatWidgetService.getfloatWidget
|
floatWidgetService.getfloatWidget
|
||||||
);
|
);
|
||||||
|
router.get("/A_floatWidget/:floatWidgetID/:organization",floatWidgetService.getsinglefloatWidget)
|
||||||
export default router;
|
export default router;
|
||||||
@@ -2,5 +2,11 @@ import * as express from "express";
|
|||||||
import { templateService } from "../controller/visualization/templateService.ts";
|
import { templateService } from "../controller/visualization/templateService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/template/save", templateService.AddTemplate);
|
router.post("/template/save", templateService.AddTemplate);
|
||||||
router.get("/templateData/:organization", templateService.GetTemplate);
|
router.get("/templateData/:organization", templateService.GetAllTemplates);
|
||||||
|
router.post("/TemplatetoZone", templateService.AddToZone);
|
||||||
|
router.patch(
|
||||||
|
"/TemplateDelete/:templateID/:organization",
|
||||||
|
templateService.Deletezone
|
||||||
|
); //delete zone
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
6
src/api-server/Routes/widget3dRoutes.ts
Normal file
6
src/api-server/Routes/widget3dRoutes.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import * as express from "express";
|
||||||
|
import { widget3dService } from "../controller/visualization/3dWidgetService.ts";
|
||||||
|
const router = express.Router();
|
||||||
|
router.post("/3dwidget/save", widget3dService.add3Dwidget);
|
||||||
|
router.get("/3dwidgetData/:zoneId/:organization", widget3dService.get3Dwiget);
|
||||||
|
export default router;
|
||||||
@@ -17,6 +17,8 @@ import assetpointRouter from "./Routes/assetpointRoutes.ts";
|
|||||||
import assetfloorRoutes from "./Routes/assetfloorRoutes.ts";
|
import assetfloorRoutes from "./Routes/assetfloorRoutes.ts";
|
||||||
import floadWidgetRoutes from "./Routes/floadWidgetRoute.ts";
|
import floadWidgetRoutes from "./Routes/floadWidgetRoute.ts";
|
||||||
import templateRoutes from "./Routes/templateRoutes.ts";
|
import templateRoutes from "./Routes/templateRoutes.ts";
|
||||||
|
import widget3dRoutes from "./Routes/widget3dRoutes.ts";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
@@ -44,4 +46,5 @@ app.use("/api/v2", assetpointRouter);
|
|||||||
app.use("/api/v2", assetfloorRoutes);
|
app.use("/api/v2", assetfloorRoutes);
|
||||||
app.use("/api/v2", floadWidgetRoutes);
|
app.use("/api/v2", floadWidgetRoutes);
|
||||||
app.use("/api/v2", templateRoutes);
|
app.use("/api/v2", templateRoutes);
|
||||||
|
app.use("/api/v2", widget3dRoutes);
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -158,7 +158,21 @@ export class pointService {
|
|||||||
modelfileID: modelfileID,
|
modelfileID: modelfileID,
|
||||||
})
|
})
|
||||||
.select("-_id -__v -createdAt -updatedAt");
|
.select("-_id -__v -createdAt -updatedAt");
|
||||||
res.send(getData);
|
if (!getData) {
|
||||||
|
return res.json({ message: "Data not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const formattedData = {
|
||||||
|
modelfileID: getData?.modelfileID,
|
||||||
|
type: getData?.type,
|
||||||
|
points: Array.isArray(getData?.points)
|
||||||
|
? getData.points.map((point: any) => ({
|
||||||
|
position: point.position,
|
||||||
|
rotation: point.rotation,
|
||||||
|
}))
|
||||||
|
: [],
|
||||||
|
};
|
||||||
|
return res.status(200).json(formattedData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Server error", error });
|
res.status(500).json({ message: "Server error", error });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,49 +2,71 @@ import { Request, Response } from "express";
|
|||||||
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
||||||
|
|
||||||
export class environment {
|
export class environment {
|
||||||
static async setEnvironment(req: Request, res: Response) {
|
static async setEnvironment(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { userId,roofVisibility,wallVisibility,shadowVisibility, organization } = req.body
|
const {
|
||||||
|
userId,
|
||||||
|
roofVisibility,
|
||||||
|
wallVisibility,
|
||||||
|
shadowVisibility,
|
||||||
|
organization,
|
||||||
|
renderDistance,
|
||||||
|
limitDistance,
|
||||||
|
} = req.body;
|
||||||
|
|
||||||
const findvalue = await environmentModel(organization).findOne({ userId: userId })
|
const findvalue = await environmentModel(organization).findOne({
|
||||||
|
userId: userId,
|
||||||
if (findvalue) {
|
});
|
||||||
|
|
||||||
const updatevalue = await environmentModel(organization).findOneAndUpdate(
|
|
||||||
{ userId: userId }, { roofVisibility:roofVisibility,wallVisibility:wallVisibility,shadowVisibility:shadowVisibility}, { new: true });
|
|
||||||
res.status(201).json(updatevalue);
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
if (findvalue) {
|
||||||
const newValue = await environmentModel(organization).create({ userId, roofVisibility, wallVisibility, });
|
const updatevalue = await environmentModel(
|
||||||
|
organization
|
||||||
|
).findOneAndUpdate(
|
||||||
res.status(201).json(newValue);
|
{ userId: userId },
|
||||||
|
{
|
||||||
|
roofVisibility: roofVisibility,
|
||||||
|
renderDistance: renderDistance,
|
||||||
|
wallVisibility: wallVisibility,
|
||||||
|
shadowVisibility: shadowVisibility,
|
||||||
|
limitDistance: limitDistance,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
res.status(201).json(updatevalue);
|
||||||
|
} else {
|
||||||
|
const newValue = await environmentModel(organization).create({
|
||||||
|
userId,
|
||||||
|
roofVisibility,
|
||||||
|
wallVisibility,
|
||||||
|
renderDistance,
|
||||||
|
shadowVisibility,
|
||||||
|
limitDistance,
|
||||||
|
});
|
||||||
|
|
||||||
}
|
res.status(201).json(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
// Send response with the created document
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating environments:', error);
|
console.error("Error creating environments:", error);
|
||||||
res.status(500).json({message:"Failed to create environments"});
|
res.status(500).json({ message: "Failed to create environments" });
|
||||||
}
|
|
||||||
}
|
}
|
||||||
static async getEnvironment(req: Request, res: Response) {
|
}
|
||||||
try {
|
static async getEnvironment(req: Request, res: Response) {
|
||||||
const { userId, organization } = req.params;
|
try {
|
||||||
|
const { userId, organization } = req.params;
|
||||||
|
|
||||||
const findValue = await environmentModel(organization).findOne({ userId: userId })
|
const findValue = await environmentModel(organization).findOne({
|
||||||
if (!findValue) {
|
userId: userId,
|
||||||
res.status(200).json("user not found");
|
});
|
||||||
} else {
|
if (!findValue) {
|
||||||
|
res.status(200).json("user not found");
|
||||||
res.status(201).json(findValue);
|
} else {
|
||||||
}
|
res.status(201).json(findValue);
|
||||||
} catch (error) {
|
}
|
||||||
console.error('Error get environments:', error);
|
} catch (error) {
|
||||||
res.status(500).json({ error: "Failed to get environments" });
|
console.error("Error get environments:", error);
|
||||||
}
|
res.status(500).json({ error: "Failed to get environments" });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,102 +5,108 @@ import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
|||||||
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
||||||
|
|
||||||
export class assetsFloorservice {
|
export class assetsFloorservice {
|
||||||
static async setFloorassets(req: Request, res: Response) {
|
static async setFloorassets(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
|
console.log("req.body: ", req.body);
|
||||||
const {
|
const {
|
||||||
modeluuid,
|
modeluuid,
|
||||||
modelname,
|
modelname,
|
||||||
speed,
|
|
||||||
assetPosition,
|
assetPosition,
|
||||||
modelfileID,
|
modelfileID,
|
||||||
assetRotation,
|
assetRotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
organization,
|
organization,
|
||||||
points,
|
eventData, // Optional
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
|
||||||
const findvalue = await assetModel(organization).findOne({
|
const findvalue = await assetModel(organization).findOne({
|
||||||
modeluuid: modeluuid,
|
modeluuid,
|
||||||
modelname: modelname,
|
modelname,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (findvalue) {
|
if (findvalue) {
|
||||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modeluuid: modeluuid, modelname: modelname },
|
{ modeluuid, modelname },
|
||||||
{
|
{
|
||||||
assetPosition: assetPosition,
|
assetPosition,
|
||||||
assetRotation: assetRotation,
|
assetRotation,
|
||||||
isVisible: isVisible,
|
isVisible,
|
||||||
isLocked: isLocked,
|
isLocked,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
res.status(201).json(updatevalue);
|
return res.status(201).json(updatevalue);
|
||||||
} else {
|
} else {
|
||||||
let pointRefs = [];
|
let assetData: any = {
|
||||||
|
|
||||||
for (const point of points) {
|
|
||||||
let actionRefs = [];
|
|
||||||
let triggerRefs = [];
|
|
||||||
|
|
||||||
if (point.actions && point.actions.length > 0) {
|
|
||||||
for (const action of point.actions) {
|
|
||||||
const actionDoc = await actionModel(organization).create({
|
|
||||||
pointsUUID: point.uuid,
|
|
||||||
isArchive: false,
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (point.triggers && point.triggers.length > 0) {
|
|
||||||
for (const trigger of point.triggers) {
|
|
||||||
const triggerDoc = await triggerModel(organization).create({
|
|
||||||
pointsUUID: point.uuid,
|
|
||||||
isArchive: false,
|
|
||||||
uuid: trigger.uuid,
|
|
||||||
name: trigger.name,
|
|
||||||
type: trigger.type,
|
|
||||||
bufferTime: trigger.bufferTime,
|
|
||||||
// triggerData: [trigger],
|
|
||||||
});
|
|
||||||
await triggerDoc.save();
|
|
||||||
triggerRefs.push(triggerDoc._id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pointRefs.push({
|
|
||||||
uuid: point.uuid,
|
|
||||||
position: point.position,
|
|
||||||
rotation: point.rotation,
|
|
||||||
actions: actionRefs,
|
|
||||||
triggers: triggerRefs,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const assetDoc = await assetModel(organization).create({
|
|
||||||
modeluuid,
|
modeluuid,
|
||||||
speed,
|
|
||||||
modelname,
|
modelname,
|
||||||
assetPosition,
|
assetPosition,
|
||||||
modelfileID,
|
modelfileID,
|
||||||
assetRotation,
|
assetRotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
points: pointRefs,
|
};
|
||||||
});
|
|
||||||
|
|
||||||
|
if (eventData) {
|
||||||
|
let pointRefs: any[] = [];
|
||||||
|
|
||||||
|
if (Array.isArray(eventData.points)) {
|
||||||
|
for (const point of eventData.points) {
|
||||||
|
let actionRefs: any[] = [];
|
||||||
|
let triggerRefs: any[] = [];
|
||||||
|
|
||||||
|
if (Array.isArray(point.actions)) {
|
||||||
|
for (const action of point.actions) {
|
||||||
|
const actionDoc = await actionModel(organization).create({
|
||||||
|
pointsUUID: point.uuid,
|
||||||
|
isArchive: false,
|
||||||
|
uuid: action.uuid,
|
||||||
|
name: action.name,
|
||||||
|
type: action.type,
|
||||||
|
material: action.material,
|
||||||
|
delay: action.delay,
|
||||||
|
spawn_Interval: action.spawn_Interval,
|
||||||
|
});
|
||||||
|
await actionDoc.save();
|
||||||
|
actionRefs.push(actionDoc._id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(point.triggers)) {
|
||||||
|
for (const trigger of point.triggers) {
|
||||||
|
const triggerDoc = await triggerModel(organization).create({
|
||||||
|
pointsUUID: point.uuid,
|
||||||
|
isArchive: false,
|
||||||
|
uuid: trigger.uuid,
|
||||||
|
name: trigger.name,
|
||||||
|
type: trigger.type,
|
||||||
|
bufferTime: trigger.bufferTime,
|
||||||
|
});
|
||||||
|
await triggerDoc.save();
|
||||||
|
triggerRefs.push(triggerDoc._id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pointRefs.push({
|
||||||
|
uuid: point.uuid,
|
||||||
|
position: point.position || [],
|
||||||
|
rotation: point.rotation || [],
|
||||||
|
actions: actionRefs,
|
||||||
|
triggers: triggerRefs,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assetData.speed = eventData.speed;
|
||||||
|
assetData.type = eventData.type;
|
||||||
|
assetData.points = pointRefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const assetDoc = await assetModel(organization).create(assetData);
|
||||||
await assetDoc.save();
|
await assetDoc.save();
|
||||||
res.status(201).json({
|
|
||||||
|
return res.status(201).json({
|
||||||
message: "Model stored successfully",
|
message: "Model stored successfully",
|
||||||
modelId: assetDoc._id,
|
modelId: assetDoc._id,
|
||||||
});
|
});
|
||||||
@@ -110,39 +116,52 @@ export class assetsFloorservice {
|
|||||||
res.status(500).json({ message: "Failed to create flooritems" });
|
res.status(500).json({ message: "Failed to create flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async getFloorItems(req: Request, res: Response) {
|
static async getFloorItems(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
const findValue = await assetModel(organization)
|
const findValues = await assetModel(organization)
|
||||||
.find()
|
.find()
|
||||||
.select("-_id")
|
.select("-_id")
|
||||||
.populate({
|
.populate({
|
||||||
path: "points",
|
path: "points",
|
||||||
// model: assetModel(organization),
|
|
||||||
select: "-_id",
|
select: "-_id",
|
||||||
})
|
})
|
||||||
.populate({
|
.populate({
|
||||||
path: "points.actions",
|
path: "points.actions",
|
||||||
model: actionModel(organization),
|
model: actionModel(organization),
|
||||||
// select: "-_id",
|
|
||||||
// populate: {
|
|
||||||
// path: "eventData",
|
|
||||||
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||||
// },
|
|
||||||
})
|
})
|
||||||
.populate({
|
.populate({
|
||||||
path: "points.triggers",
|
path: "points.triggers",
|
||||||
model: triggerModel(organization),
|
model: triggerModel(organization),
|
||||||
// select: "-_id",
|
|
||||||
// populate: {
|
|
||||||
// path: "triggerData",
|
|
||||||
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
if (!findValue) {
|
if (!findValues) {
|
||||||
res.status(200).json("floorItems not found");
|
res.status(200).json("floorItems not found");
|
||||||
} else {
|
} else {
|
||||||
res.status(201).json(findValue);
|
return res.status(200).json(
|
||||||
|
findValues.map((item) => {
|
||||||
|
let responseItem: any = {
|
||||||
|
modeluuid: item.modeluuid,
|
||||||
|
modelname: item.modelname,
|
||||||
|
assetPosition: item.assetPosition,
|
||||||
|
modelfileID: item.modelfileID,
|
||||||
|
assetRotation: item.assetRotation,
|
||||||
|
isLocked: item.isLocked,
|
||||||
|
isVisible: item.isVisible,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (item.points.length > 1) {
|
||||||
|
responseItem.eventData = {
|
||||||
|
speed: item.speed,
|
||||||
|
points: item.points,
|
||||||
|
type: item.type,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseItem;
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get flooritems:", error);
|
console.error("Error get flooritems:", error);
|
||||||
@@ -167,4 +186,6 @@ export class assetsFloorservice {
|
|||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async updateActionsDatas(req: Request, res: Response) {}
|
||||||
}
|
}
|
||||||
|
|||||||
106
src/api-server/controller/visualization/3dWidgetService.ts
Normal file
106
src/api-server/controller/visualization/3dWidgetService.ts
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
|
import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts";
|
||||||
|
export class widget3dService {
|
||||||
|
static async add3Dwidget(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
const { organization, widget, zoneId } = req.body;
|
||||||
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingZone)
|
||||||
|
return res.status(404).json({ message: "Zone not found" });
|
||||||
|
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
|
widgetID: widget.id,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existing3Dwidget) {
|
||||||
|
const update3dwidget = await widget3dModel(
|
||||||
|
organization
|
||||||
|
).findOneAndUpdate(
|
||||||
|
{
|
||||||
|
widgetID: widget.id,
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
},
|
||||||
|
{ position: widget.position },
|
||||||
|
{ upsert: true, new: true }
|
||||||
|
);
|
||||||
|
if (update3dwidget)
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ message: "widget update successfully" });
|
||||||
|
else return res.send("Widget not updated");
|
||||||
|
}
|
||||||
|
const newWidget3d = await widget3dModel(organization).create({
|
||||||
|
widgetName: widget.type,
|
||||||
|
widgetID: widget.id,
|
||||||
|
position: widget.position,
|
||||||
|
zoneId,
|
||||||
|
});
|
||||||
|
if (newWidget3d)
|
||||||
|
return res.status(201).json({ message: "Widget created successfully" });
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async get3Dwiget(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
const { organization, zoneId } = req.params;
|
||||||
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingZone) return res.send("Zone not found");
|
||||||
|
const widgetData = await widget3dModel(organization).find({
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!widgetData || widgetData.length === 0) {
|
||||||
|
return res.json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const zonebasedWidget = widgetData.map((widget) => ({
|
||||||
|
Data: {
|
||||||
|
measurements: widget.Data?.measurements || {},
|
||||||
|
duration: widget.Data?.duration || "1h",
|
||||||
|
},
|
||||||
|
type: widget.widgetName,
|
||||||
|
id: widget.widgetID,
|
||||||
|
position: widget.position,
|
||||||
|
}));
|
||||||
|
return res.status(200).json(zonebasedWidget);
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// static async update3Dposition(req: Request, res: Response): Promise<any> {
|
||||||
|
// try {
|
||||||
|
// const { organization, id, position, zoneId } = req.body;
|
||||||
|
// const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
|
// widgetID: id,
|
||||||
|
// isArchive: false,
|
||||||
|
// });
|
||||||
|
// if (existing3Dwidget) {
|
||||||
|
// const update3dwidget = await widget3dModel(
|
||||||
|
// organization
|
||||||
|
// ).findOneAndUpdate(
|
||||||
|
// {
|
||||||
|
// widgetID: id,
|
||||||
|
// zoneId: zoneId,
|
||||||
|
// isArchive: false,
|
||||||
|
// },
|
||||||
|
// { position: position },
|
||||||
|
// { upsert: true, new: true }
|
||||||
|
// );
|
||||||
|
// if (update3dwidget)
|
||||||
|
// return res.status(200).send("widget update successfully");
|
||||||
|
// } else {
|
||||||
|
// return res.status(404).send("widget not found");
|
||||||
|
// }
|
||||||
|
// } catch (error: any) {
|
||||||
|
// return res.status(500).send(error.message);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import floatWidgetModel from "../../../shared/model/vizualization/3dwidget.ts";
|
import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts";
|
||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
export class floatWidgetService {
|
export class floatWidgetService {
|
||||||
static async addfloatWidget(req: Request, res: Response): Promise<any> {
|
static async addfloatWidget(req: Request, res: Response): Promise<any> {
|
||||||
@@ -16,6 +16,7 @@ export class floatWidgetService {
|
|||||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) {
|
if (existingFloatWidget) {
|
||||||
const updateFloatWidget = await floatWidgetModel(
|
const updateFloatWidget = await floatWidgetModel(
|
||||||
@@ -27,11 +28,12 @@ export class floatWidgetService {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
// Data: {
|
Data: {
|
||||||
// // measurements: widget.Data.measurements || {},
|
measurements: widget?.Data.measurements,
|
||||||
// duration: widget.Data.duration || "1h",
|
duration: widget?.Data.duration,
|
||||||
// },
|
},
|
||||||
position: widget.position,
|
header: widget?.header,
|
||||||
|
position: widget?.position,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -94,49 +96,48 @@ export class floatWidgetService {
|
|||||||
return res.status(200).json(formattedWidgets);
|
return res.status(200).json(formattedWidgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static async deleteWidget(req: Request, res: Response): Promise<any> {
|
static async deletefloatWidget(req: Request, res: Response): Promise<any> {
|
||||||
// try {
|
try {
|
||||||
// const { widgetID, organization } = req.body;
|
const { floatWidgetID, organization } = req.body;
|
||||||
// const findWidget = await widgetSchema(organization).findOne({
|
const findfloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
// widgetID: widgetID,
|
floatWidgetID: floatWidgetID,
|
||||||
// isArchive: false,
|
isArchive: false,
|
||||||
// });
|
});
|
||||||
// if (!findWidget)
|
if (!findfloatWidget)
|
||||||
// return res.status(409).json({ message: "Widget not found" });
|
return res.status(409).json({ message: "Widget not found" });
|
||||||
// const widgetData = await widgetSchema(organization).updateOne(
|
const widgetData = await floatWidgetModel(organization).updateOne(
|
||||||
// { _id: findWidget._id, isArchive: false },
|
{ _id: findfloatWidget._id, isArchive: false },
|
||||||
// { $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
// );
|
);
|
||||||
|
return res
|
||||||
// if (widgetData) {
|
.status(200)
|
||||||
// // Find all widgets in the same panel and sort them by widgetOrder
|
.json({ message: "FloatingWidget deleted successfully" });
|
||||||
// const widgets = await widgetSchema(organization).find({
|
} catch (error: any) {
|
||||||
// panelID: findWidget.panelID,
|
return res.status(500).send(error.message);
|
||||||
// isArchive: false,
|
}
|
||||||
// });
|
}
|
||||||
// // .sort({ widgetOrder: 1 });
|
static async getsinglefloatWidget(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
// // Reassign widgetOrder values
|
const { organization, floatWidgetID } = req.params;
|
||||||
// // for (let i = 0; i < widgets.length; i++) {
|
const widgetData = await floatWidgetModel(organization)
|
||||||
// // widgets[i].widgetOrder = (i + 1).toString(); // Convert to string
|
.findOne({
|
||||||
// // await widgets[i].save();
|
floatWidgetID: floatWidgetID,
|
||||||
// // }
|
isArchive: false,
|
||||||
// const panelData = await panelSchema(organization).findOne({
|
})
|
||||||
// _id: findWidget.panelID,
|
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
||||||
// isArchive: false,
|
if (!widgetData || widgetData.length === 0) {
|
||||||
// });
|
return res.send([]);
|
||||||
// if (panelData.widgets.includes(findWidget._id)) {
|
}
|
||||||
// const index1 = panelData.widgets.indexOf(findWidget._id);
|
const Datastructure = {
|
||||||
// panelData.widgets.splice(index1, 1);
|
measurements: widgetData?.Data.measurements || {},
|
||||||
// }
|
duration: widgetData?.Data.duration || "1h",
|
||||||
// await panelData.save();
|
};
|
||||||
// }
|
const header = widgetData?.header;
|
||||||
// return res.status(200).json({ message: "Widget deleted successfully" });
|
return res.status(200).json({ Data: Datastructure, header });
|
||||||
// } catch (error: any) {
|
} catch (error: any) {
|
||||||
// return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// static async updatewidget(req: Request, res: Response): Promise<any> {
|
// static async updatewidget(req: Request, res: Response): Promise<any> {
|
||||||
// try {
|
// try {
|
||||||
// const { organization, widgetID, values } = req.body;
|
// const { organization, widgetID, values } = req.body;
|
||||||
|
|||||||
@@ -1,24 +1,38 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
||||||
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
|
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
||||||
|
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
|
import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts";
|
||||||
|
|
||||||
export class templateService {
|
export class templateService {
|
||||||
static async AddTemplate(req: Request, res: Response): Promise<any> {
|
static async AddTemplate(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
console.log("req.body: ", req.body);
|
const {
|
||||||
const { organization, templateID, name, panelOrder, widgets, snapshot } =
|
organization,
|
||||||
req.body;
|
template,
|
||||||
|
// id,
|
||||||
|
// name,
|
||||||
|
// panelOrder,
|
||||||
|
// widgets,
|
||||||
|
// snapshot,
|
||||||
|
// floatWidgets,
|
||||||
|
} = req.body;
|
||||||
|
// console.log("req.body: ", req.body);
|
||||||
const existingTemplate = await templateModel(organization).findOne({
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
templateID: templateID,
|
templateID: template.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (existingTemplate)
|
if (existingTemplate)
|
||||||
return res.status(409).json({ message: "TemplateID alreay exists" });
|
return res.json({ message: "TemplateID alreay exists" });
|
||||||
const newTemplate = await templateModel(organization).create({
|
const newTemplate = await templateModel(organization).create({
|
||||||
templateID,
|
templateID: template.id,
|
||||||
name,
|
templateName: template.name,
|
||||||
panelOrder,
|
panelOrder: template.panelOrder,
|
||||||
widgets,
|
widgets: template.widgets,
|
||||||
snapshot,
|
snapshot: template.snapshot,
|
||||||
|
floatWidgets: template.floatingWidget,
|
||||||
|
Widgets3D: template.Widgets3D,
|
||||||
});
|
});
|
||||||
if (newTemplate)
|
if (newTemplate)
|
||||||
return res.status(200).json({ message: "Template saved successfully" });
|
return res.status(200).json({ message: "Template saved successfully" });
|
||||||
@@ -26,16 +40,162 @@ export class templateService {
|
|||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async GetTemplate(req: Request, res: Response): Promise<any> {
|
static async GetAllTemplates(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
const existingTemplate = await templateModel(organization)
|
const templateDatas = await templateModel(organization)
|
||||||
.find({
|
.find({
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("-_id -__v -isArchive -createdAt -updatedAt");
|
.select("-_id -__v -isArchive -createdAt -updatedAt");
|
||||||
if (!existingTemplate) return res.status(409).send([]);
|
if (!templateDatas) return res.status(200).send([]);
|
||||||
return res.status(200).json(existingTemplate);
|
|
||||||
|
const formattedTemplates = templateDatas.map((data) => ({
|
||||||
|
id: data.templateID,
|
||||||
|
name: data.templateName,
|
||||||
|
panelOrder: data.panelOrder,
|
||||||
|
widgets: data.widgets,
|
||||||
|
floatingWidget: data.floatWidgets,
|
||||||
|
widgets3D: data.Widgets3D,
|
||||||
|
snapshot: data.snapshot,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return res.status(200).json(formattedTemplates);
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async AddToZone(req: Request, res: Response): Promise<any> {
|
||||||
|
const { zoneId, templateID, organization } = req.body;
|
||||||
|
try {
|
||||||
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingZone)
|
||||||
|
return res.status(404).json({ message: "Zone not found" });
|
||||||
|
|
||||||
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
|
templateID: templateID,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingTemplate)
|
||||||
|
return res.status(409).json({ message: "TemplateID not found" });
|
||||||
|
if (existingZone.panelOrder.length > 0) {
|
||||||
|
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||||
|
await existingZone.save();
|
||||||
|
// Clear existing data before adding new data
|
||||||
|
const archivePanelDatas = await panelSchema(organization).find({
|
||||||
|
zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
for (const panelData of archivePanelDatas) {
|
||||||
|
await widgetSchema(organization).deleteMany({
|
||||||
|
panelID: panelData._id,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await panelSchema(organization).deleteMany({
|
||||||
|
zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
await floatWidgetModel(organization).deleteMany({
|
||||||
|
zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||||
|
await existingZone.save();
|
||||||
|
const existingPanels = await panelSchema(organization).find({
|
||||||
|
zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
const existingPanelNames = existingPanels.map(
|
||||||
|
(panel: any) => panel.panelName
|
||||||
|
);
|
||||||
|
|
||||||
|
const missingPanels = existingTemplate.panelOrder.filter(
|
||||||
|
(panelName: string) => !existingPanelNames.includes(panelName)
|
||||||
|
);
|
||||||
|
const createdPanels = await Promise.all(
|
||||||
|
missingPanels.map((panelName: any) =>
|
||||||
|
panelSchema(organization).create({
|
||||||
|
zoneId,
|
||||||
|
panelName,
|
||||||
|
widgets: [],
|
||||||
|
isArchive: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const widgetData of existingTemplate.widgets) {
|
||||||
|
const addedExistingPanel = await panelSchema(organization).findOne({
|
||||||
|
panelName: widgetData.panel,
|
||||||
|
zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!addedExistingPanel) continue;
|
||||||
|
|
||||||
|
const existingWidget = await widgetSchema(organization).findOne({
|
||||||
|
panelID: addedExistingPanel._id,
|
||||||
|
widgetID: widgetData.id,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existingWidget) continue;
|
||||||
|
|
||||||
|
const newWidget = await widgetSchema(organization).create({
|
||||||
|
widgetID: widgetData.id,
|
||||||
|
elementType: widgetData.type,
|
||||||
|
widgetName: widgetData.widgetName || "Widget",
|
||||||
|
panelID: addedExistingPanel._id,
|
||||||
|
widgetside: widgetData.panel,
|
||||||
|
});
|
||||||
|
addedExistingPanel.widgets.push(newWidget._id);
|
||||||
|
await addedExistingPanel.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const floatData of existingTemplate.floatWidgets) {
|
||||||
|
const existingFloatWidget = await floatWidgetModel(
|
||||||
|
organization
|
||||||
|
).findOne({ floatWidgetID: floatData.id, isArchive: false, zoneId });
|
||||||
|
if (existingFloatWidget) continue;
|
||||||
|
|
||||||
|
await floatWidgetModel(organization).create({
|
||||||
|
className: floatData.className,
|
||||||
|
header: floatData.header,
|
||||||
|
floatWidgetID: floatData.id,
|
||||||
|
position: floatData.position,
|
||||||
|
per: floatData.per,
|
||||||
|
value: floatData.value,
|
||||||
|
zoneId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
.status(201)
|
||||||
|
.json({ message: "Template placed in Zone", createdPanels });
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async Deletezone(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
console.log("req.params: ", req.params);
|
||||||
|
const { organization, templateID } = req.params;
|
||||||
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
|
templateID: templateID,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existingTemplate) {
|
||||||
|
const newTemplate = await templateModel(organization).updateOne(
|
||||||
|
{ templateID: templateID, isArchive: false },
|
||||||
|
{ $set: { isArchive: true } }
|
||||||
|
);
|
||||||
|
if (newTemplate)
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ message: "Template deleted successfully" });
|
||||||
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
|||||||
export class widgetService {
|
export class widgetService {
|
||||||
static async addWidget(req: Request, res: Response): Promise<any> {
|
static async addWidget(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
console.log("req.body: ", req.body);
|
// console.log("req.body: ", req.body);
|
||||||
const {
|
const {
|
||||||
organization,
|
organization,
|
||||||
// panel,
|
// panel,
|
||||||
@@ -47,15 +47,17 @@ export class widgetService {
|
|||||||
$set: {
|
$set: {
|
||||||
// panelID: existingPanel._id,
|
// panelID: existingPanel._id,
|
||||||
// widgetID: widget.id,
|
// widgetID: widget.id,
|
||||||
|
widgetName: widget.widgetName,
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget.Data.measurements,
|
measurements: widget.Data?.measurements || {},
|
||||||
duration: widget.Data.duration,
|
duration: widget.Data?.duration || "1h",
|
||||||
},
|
},
|
||||||
// isArchive: false,
|
// isArchive: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
||||||
);
|
);
|
||||||
|
console.log("updateWidget: ", updateWidget);
|
||||||
return res
|
return res
|
||||||
.status(200)
|
.status(200)
|
||||||
.json({ message: "Widget updated successfully" });
|
.json({ message: "Widget updated successfully" });
|
||||||
@@ -183,13 +185,16 @@ export class widgetService {
|
|||||||
widgetID: widgetID,
|
widgetID: widgetID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("Data -_id");
|
.select("Data widgetName -_id");
|
||||||
|
if (!existingWidget)
|
||||||
|
return res.json({ message: "Widget not found for the widgetID" });
|
||||||
const Datastructure = {
|
const Datastructure = {
|
||||||
measurements: existingWidget.Data.measurements || {},
|
measurements: existingWidget.Data.measurements || {},
|
||||||
duration: existingWidget.Data.duration || "1h",
|
duration: existingWidget.Data.duration || "1h",
|
||||||
};
|
};
|
||||||
|
const widgetName = existingWidget.widgetName || "Widget";
|
||||||
if (existingWidget) return res.status(200).json({ Data: Datastructure });
|
if (existingWidget)
|
||||||
|
return res.status(200).json({ Data: Datastructure, widgetName });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export interface assetData extends Document {
|
|||||||
}[];
|
}[];
|
||||||
assetPosition: number[];
|
assetPosition: number[];
|
||||||
assetRotation: number[];
|
assetRotation: number[];
|
||||||
speed: number;
|
speed: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
// Define the Mongoose Schema
|
||||||
@@ -68,7 +68,7 @@ const assetDataSchema: Schema = new Schema({
|
|||||||
],
|
],
|
||||||
assetPosition: { type: [Number] },
|
assetPosition: { type: [Number] },
|
||||||
assetRotation: { type: [Number] },
|
assetRotation: { type: [Number] },
|
||||||
speed: { type: Number },
|
speed: { type: Schema.Types.Mixed },
|
||||||
isLocked: { type: Boolean },
|
isLocked: { type: Boolean },
|
||||||
isVisible: { type: Boolean },
|
isVisible: { type: Boolean },
|
||||||
// rotation: {
|
// rotation: {
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
import mongoose, { Document, Schema } from 'mongoose';
|
import mongoose, { Document, Schema } from "mongoose";
|
||||||
import MainModel from '../../connect/mongoose.ts';
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
// Interface for TypeScript with PascalCase
|
// Interface for TypeScript with PascalCase
|
||||||
export interface environment extends Document {
|
export interface environment extends Document {
|
||||||
userId: string;
|
userId: string;
|
||||||
roofVisibility:boolean
|
roofVisibility: boolean;
|
||||||
wallVisibility:boolean
|
wallVisibility: boolean;
|
||||||
|
renderDistance: number;
|
||||||
|
shadowVisibility: boolean;
|
||||||
|
limitDistance: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
// Define the Mongoose Schema
|
||||||
const environmentSchema: Schema = new Schema({
|
const environmentSchema: Schema = new Schema({
|
||||||
userId: { type: String, unique: true },
|
userId: { type: String, unique: true },
|
||||||
roofVisibility: { type: Boolean ,default:false},
|
roofVisibility: { type: Boolean, default: false },
|
||||||
wallVisibility: { type: Boolean ,default:false},
|
wallVisibility: { type: Boolean, default: false },
|
||||||
shadowVisibility: { type: Boolean ,default:false},
|
shadowVisibility: { type: Boolean, default: false },
|
||||||
|
renderDistance: { type: Number, default: false },
|
||||||
|
limitDistance: { type: Boolean, default: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Model for MongoDB collection
|
// Model for MongoDB collection
|
||||||
@@ -33,7 +38,7 @@ const environmentSchema: Schema = new Schema({
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// export default environmentModel;
|
// export default environmentModel;
|
||||||
const environmentModel = (db:string) => {
|
const environmentModel = (db: string) => {
|
||||||
return MainModel(db, "environments", environmentSchema, "environments")
|
return MainModel(db, "environments", environmentSchema, "environments");
|
||||||
};
|
};
|
||||||
export default environmentModel;
|
export default environmentModel;
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import mongoose, { Schema, Document, model } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface floatingWidget extends Document {
|
export interface Widget3d extends Document {
|
||||||
className: string;
|
widgetName: string;
|
||||||
header: string;
|
widgetID: string;
|
||||||
floatWidgetID: string;
|
position: [];
|
||||||
position: {};
|
|
||||||
per: string;
|
|
||||||
value: string;
|
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
zoneId: string;
|
zoneId: string;
|
||||||
Data: {
|
Data: {
|
||||||
@@ -15,14 +12,11 @@ export interface floatingWidget extends Document {
|
|||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const floatingWidgetSchema: Schema = new Schema(
|
const Widget3dSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
className: { type: String },
|
widgetName: { type: String },
|
||||||
header: { type: String },
|
widgetID: { type: String },
|
||||||
floatWidgetID: { type: String },
|
position: { type: Array },
|
||||||
position: { type: Object },
|
|
||||||
per: { type: String },
|
|
||||||
value: { type: String },
|
|
||||||
zoneId: { type: String },
|
zoneId: { type: String },
|
||||||
Data: {
|
Data: {
|
||||||
measurements: { type: Object, default: {} },
|
measurements: { type: Object, default: {} },
|
||||||
@@ -33,12 +27,7 @@ const floatingWidgetSchema: Schema = new Schema(
|
|||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const floatWidgetModel = (db: any) => {
|
const widget3dModel = (db: any) => {
|
||||||
return MainModel(
|
return MainModel(db, "3dWidget", Widget3dSchema, "3dWidget");
|
||||||
db,
|
|
||||||
"FloatingWidget",
|
|
||||||
floatingWidgetSchema,
|
|
||||||
"FloatingWidget"
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
export default floatWidgetModel;
|
export default widget3dModel;
|
||||||
|
|||||||
44
src/shared/model/vizualization/floatWidget.ts
Normal file
44
src/shared/model/vizualization/floatWidget.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import mongoose, { Schema, Document, model } from "mongoose";
|
||||||
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
|
export interface floatingWidget extends Document {
|
||||||
|
className: string;
|
||||||
|
header: string;
|
||||||
|
floatWidgetID: string;
|
||||||
|
position: {};
|
||||||
|
per: string;
|
||||||
|
value: string;
|
||||||
|
isArchive: boolean;
|
||||||
|
zoneId: string;
|
||||||
|
Data: {
|
||||||
|
measurements: {};
|
||||||
|
duration: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const floatingWidgetSchema: Schema = new Schema(
|
||||||
|
{
|
||||||
|
className: { type: String },
|
||||||
|
header: { type: String },
|
||||||
|
floatWidgetID: { type: String },
|
||||||
|
position: { type: Object },
|
||||||
|
per: { type: String },
|
||||||
|
value: { type: String },
|
||||||
|
zoneId: { type: String },
|
||||||
|
Data: {
|
||||||
|
measurements: { type: Object, default: {} },
|
||||||
|
duration: { type: String, default: "1h" },
|
||||||
|
},
|
||||||
|
isArchive: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
const floatWidgetModel = (db: any) => {
|
||||||
|
return MainModel(
|
||||||
|
db,
|
||||||
|
"FloatingWidget",
|
||||||
|
floatingWidgetSchema,
|
||||||
|
"FloatingWidget"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default floatWidgetModel;
|
||||||
@@ -7,6 +7,8 @@ export interface Template extends Document {
|
|||||||
snapshot: string;
|
snapshot: string;
|
||||||
panelOrder: [];
|
panelOrder: [];
|
||||||
widgets: [];
|
widgets: [];
|
||||||
|
floatWidgets: [];
|
||||||
|
Widgets3D: [];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
}
|
}
|
||||||
const templateSchema: Schema = new Schema(
|
const templateSchema: Schema = new Schema(
|
||||||
@@ -16,6 +18,8 @@ const templateSchema: Schema = new Schema(
|
|||||||
snapshot: { type: String },
|
snapshot: { type: String },
|
||||||
panelOrder: { type: Array },
|
panelOrder: { type: Array },
|
||||||
widgets: { type: Array },
|
widgets: { type: Array },
|
||||||
|
floatWidgets: { type: Array },
|
||||||
|
Widgets3D: { type: Array },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export interface widget extends Document {
|
|||||||
}
|
}
|
||||||
const widgetSchema: Schema = new Schema(
|
const widgetSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
widgetName: { type: String },
|
widgetName: { type: String, default: "Widget" },
|
||||||
widgetside: { type: String },
|
widgetside: { type: String },
|
||||||
widgetID: { type: String },
|
widgetID: { type: String },
|
||||||
widgetOrder: { type: String },
|
widgetOrder: { type: String },
|
||||||
|
|||||||
Reference in New Issue
Block a user