Visualization Part 2d and floating API Completed. Template Save and Get API completed
This commit is contained in:
2
.env
2
.env
@@ -2,6 +2,8 @@
|
|||||||
# MONGO_USER=mydata
|
# MONGO_USER=mydata
|
||||||
# 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
|
||||||
|
|||||||
9
src/api-server/Routes/floadWidgetRoute.ts
Normal file
9
src/api-server/Routes/floadWidgetRoute.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import * as express from "express";
|
||||||
|
import { floatWidgetService } from "../controller/visualization/floatWidgetService.ts";
|
||||||
|
const router = express.Router();
|
||||||
|
router.post("/floatwidget/save", floatWidgetService.addfloatWidget);
|
||||||
|
router.get(
|
||||||
|
"/floadData/:zoneId/:organization",
|
||||||
|
floatWidgetService.getfloatWidget
|
||||||
|
);
|
||||||
|
export default router;
|
||||||
6
src/api-server/Routes/templateRoutes.ts
Normal file
6
src/api-server/Routes/templateRoutes.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import * as express from "express";
|
||||||
|
import { templateService } from "../controller/visualization/templateService.ts";
|
||||||
|
const router = express.Router();
|
||||||
|
router.post("/template/save", templateService.AddTemplate);
|
||||||
|
router.get("/templateData/:organization", templateService.GetTemplate);
|
||||||
|
export default router;
|
||||||
@@ -136,7 +136,7 @@ const router = express.Router();
|
|||||||
*/
|
*/
|
||||||
router.post("/widget/save", widgetService.addWidget);
|
router.post("/widget/save", widgetService.addWidget);
|
||||||
router.patch("/widget/:widgetID", widgetService.updatewidget);
|
router.patch("/widget/:widgetID", widgetService.updatewidget);
|
||||||
router.patch("/widget/delete", widgetService.deleteWidget);
|
router.patch("/delete/widget", widgetService.deleteWidget);
|
||||||
router.get(
|
router.get(
|
||||||
"/WidgetData/:widgetID/:organization",
|
"/WidgetData/:widgetID/:organization",
|
||||||
widgetService.getDatafromWidget
|
widgetService.getDatafromWidget
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const router = express.Router();
|
|||||||
router.post('/setZone',zone.setZone)
|
router.post('/setZone',zone.setZone)
|
||||||
router.delete('/deleteZone',zone.deleteZone)
|
router.delete('/deleteZone',zone.deleteZone)
|
||||||
router.get('/findZones/:organization',zone.getZones)
|
router.get('/findZones/:organization',zone.getZones)
|
||||||
router.get('/A_zone/:zoneId/:organization',zone.ZoneData)
|
// router.get('/A_zone/:zoneId/:organization',zone.ZoneData)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ router.get("/ZoneVisualization/:zoneId", Zoneservice.singleZonePanelDatas);
|
|||||||
* value:
|
* value:
|
||||||
* message: "Zone not found"
|
* message: "Zone not found"
|
||||||
*/
|
*/
|
||||||
router.get("/A_zone/:zoneId", Zoneservice.ZoneData);
|
router.get("/A_zone/:zoneId/:organization", Zoneservice.ZoneData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import panelRouter from "./Routes/panelRoutes.ts";
|
|||||||
import widgetRouter from "./Routes/widgetRoute.ts";
|
import widgetRouter from "./Routes/widgetRoute.ts";
|
||||||
import assetpointRouter from "./Routes/assetpointRoutes.ts";
|
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 templateRoutes from "./Routes/templateRoutes.ts";
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
@@ -34,11 +35,13 @@ app.use("/api/v1", flooritemRoutes);
|
|||||||
app.use("/api/v1", WallitemRoutes);
|
app.use("/api/v1", WallitemRoutes);
|
||||||
app.use("/api/v1", userRoutes);
|
app.use("/api/v1", userRoutes);
|
||||||
app.use("/api/v1", shareRoutes);
|
app.use("/api/v1", shareRoutes);
|
||||||
app.use('/api/v2', zoneRoutes);
|
app.use("/api/v2", zoneRoutes);
|
||||||
//update
|
//update
|
||||||
app.use("/api/v2", zoneRoutes2); //updates
|
app.use("/api/v2", zoneRoutes2); //updates
|
||||||
app.use("/api/v2", panelRouter);
|
app.use("/api/v2", panelRouter);
|
||||||
app.use("/api/v2", widgetRouter);
|
app.use("/api/v2", widgetRouter);
|
||||||
app.use("/api/v2", assetpointRouter);
|
app.use("/api/v2", assetpointRouter);
|
||||||
app.use("/api/v2", assetfloorRoutes);
|
app.use("/api/v2", assetfloorRoutes);
|
||||||
|
app.use("/api/v2", floadWidgetRoutes);
|
||||||
|
app.use("/api/v2", templateRoutes);
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -35,14 +35,24 @@ export class pointService {
|
|||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
triggers: [],
|
triggers: [
|
||||||
|
{
|
||||||
|
uuid: "randomUUID",
|
||||||
|
name: "trigger 1",
|
||||||
|
type: "Inherit",
|
||||||
|
bufferTime: 0,
|
||||||
|
// delay: "Inherit",
|
||||||
|
// spawnInterval: "Inherit",
|
||||||
|
isUsed: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
// connections: {
|
// connections: {
|
||||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
// targets: [],
|
// targets: [],
|
||||||
// },
|
// },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uuid: "point1UUID",
|
uuid: "point2UUID",
|
||||||
position: [0, 0.85, 0],
|
position: [0, 0.85, 0],
|
||||||
rotation: [0, 0, 0],
|
rotation: [0, 0, 0],
|
||||||
actions: [
|
actions: [
|
||||||
@@ -56,14 +66,24 @@ export class pointService {
|
|||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
triggers: [],
|
triggers: [
|
||||||
|
{
|
||||||
|
uuid: "randomUUID",
|
||||||
|
name: "trigger 1",
|
||||||
|
type: "Inherit",
|
||||||
|
bufferTime: 0,
|
||||||
|
// delay: "Inherit",
|
||||||
|
// spawnInterval: "Inherit",
|
||||||
|
isUsed: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
// connections: {
|
// connections: {
|
||||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
// targets: [],
|
// targets: [],
|
||||||
// },
|
// },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uuid: "point1UUID",
|
uuid: "point3UUID",
|
||||||
position: [0, 0.85, -2.2],
|
position: [0, 0.85, -2.2],
|
||||||
rotation: [0, 0, 0],
|
rotation: [0, 0, 0],
|
||||||
actions: [
|
actions: [
|
||||||
@@ -77,14 +97,23 @@ export class pointService {
|
|||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
triggers: [],
|
triggers: [
|
||||||
|
{
|
||||||
|
uuid: "randomUUID",
|
||||||
|
name: "trigger 1",
|
||||||
|
type: "Inherit",
|
||||||
|
bufferTime: 0,
|
||||||
|
// delay: "Inherit",
|
||||||
|
// spawnInterval: "Inherit",
|
||||||
|
isUsed: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
// connections: {
|
// connections: {
|
||||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
// targets: [],
|
// targets: [],
|
||||||
// },
|
// },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
speed: 1,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// else if (type === "Vehicle") {
|
// else if (type === "Vehicle") {
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
|||||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
export class Zoneservice {
|
export class Zoneservice {
|
||||||
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
||||||
const organization = req.body.organization;
|
console.log("req.body: ", req.body);
|
||||||
const zoneDatas = req.body.zonesdata;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const organization = req.body.organization;
|
||||||
|
const zoneDatas = req.body.zonesdata;
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneDatas.zoneId,
|
zoneId: zoneDatas.zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
@@ -43,6 +43,7 @@ export class Zoneservice {
|
|||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
console.log("replaceZone: ", replaceZone);
|
||||||
if (!replaceZone)
|
if (!replaceZone)
|
||||||
return res.status(404).json({ message: "Zone not updated" });
|
return res.status(404).json({ message: "Zone not updated" });
|
||||||
else
|
else
|
||||||
@@ -231,7 +232,8 @@ export class Zoneservice {
|
|||||||
|
|
||||||
static async ZoneData(req: Request, res: Response): Promise<any> {
|
static async ZoneData(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const organization = req.query.organization;
|
console.log("req.params: ", req.params);
|
||||||
|
const organization = req.params.organization;
|
||||||
const zoneId = req.params.zoneId;
|
const zoneId = req.params.zoneId;
|
||||||
const findZone = await zoneSchema(organization).findOne({
|
const findZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ export class assetsFloorservice {
|
|||||||
const {
|
const {
|
||||||
modeluuid,
|
modeluuid,
|
||||||
modelname,
|
modelname,
|
||||||
position,
|
speed,
|
||||||
|
assetPosition,
|
||||||
modelfileID,
|
modelfileID,
|
||||||
rotation,
|
assetRotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
organization,
|
organization,
|
||||||
@@ -28,8 +29,8 @@ export class assetsFloorservice {
|
|||||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modeluuid: modeluuid, modelname: modelname },
|
{ modeluuid: modeluuid, modelname: modelname },
|
||||||
{
|
{
|
||||||
position: position,
|
assetPosition: assetPosition,
|
||||||
rotation: rotation,
|
assetRotation: assetRotation,
|
||||||
isVisible: isVisible,
|
isVisible: isVisible,
|
||||||
isLocked: isLocked,
|
isLocked: isLocked,
|
||||||
},
|
},
|
||||||
@@ -37,95 +38,46 @@ export class assetsFloorservice {
|
|||||||
);
|
);
|
||||||
res.status(201).json(updatevalue);
|
res.status(201).json(updatevalue);
|
||||||
} else {
|
} 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 = [];
|
let pointRefs = [];
|
||||||
|
|
||||||
for (const point of points) {
|
for (const point of points) {
|
||||||
let actionRefs = [];
|
let actionRefs = [];
|
||||||
let triggerRefs = [];
|
let triggerRefs = [];
|
||||||
|
|
||||||
// Store Actions (Events)
|
|
||||||
if (point.actions && point.actions.length > 0) {
|
if (point.actions && point.actions.length > 0) {
|
||||||
for (const action of point.actions) {
|
for (const action of point.actions) {
|
||||||
const actionDoc = await actionModel(organization).create({
|
const actionDoc = await actionModel(organization).create({
|
||||||
pointsUUID: point.uuid,
|
pointsUUID: point.uuid,
|
||||||
actionUUID: action.uuid,
|
|
||||||
isArchive: false,
|
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();
|
await actionDoc.save();
|
||||||
actionRefs.push(actionDoc._id); // Store reference
|
actionRefs.push(actionDoc._id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store Triggers
|
|
||||||
if (point.triggers && point.triggers.length > 0) {
|
if (point.triggers && point.triggers.length > 0) {
|
||||||
for (const trigger of point.triggers) {
|
for (const trigger of point.triggers) {
|
||||||
const triggerDoc = await triggerModel(organization).create({
|
const triggerDoc = await triggerModel(organization).create({
|
||||||
pointsUUID: point.uuid,
|
pointsUUID: point.uuid,
|
||||||
actionUUID: trigger.uuid,
|
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
triggerData: [trigger], // Store trigger data
|
uuid: trigger.uuid,
|
||||||
|
name: trigger.name,
|
||||||
|
type: trigger.type,
|
||||||
|
bufferTime: trigger.bufferTime,
|
||||||
|
// triggerData: [trigger],
|
||||||
});
|
});
|
||||||
await triggerDoc.save();
|
await triggerDoc.save();
|
||||||
triggerRefs.push(triggerDoc._id); // Store reference
|
triggerRefs.push(triggerDoc._id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the Point document
|
|
||||||
pointRefs.push({
|
pointRefs.push({
|
||||||
uuid: point.uuid,
|
uuid: point.uuid,
|
||||||
position: point.position,
|
position: point.position,
|
||||||
@@ -135,13 +87,13 @@ export class assetsFloorservice {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the main asset document
|
|
||||||
const assetDoc = await assetModel(organization).create({
|
const assetDoc = await assetModel(organization).create({
|
||||||
modeluuid,
|
modeluuid,
|
||||||
|
speed,
|
||||||
modelname,
|
modelname,
|
||||||
position,
|
assetPosition,
|
||||||
modelfileID,
|
modelfileID,
|
||||||
rotation,
|
assetRotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
points: pointRefs,
|
points: pointRefs,
|
||||||
@@ -163,22 +115,29 @@ export class assetsFloorservice {
|
|||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
const findValue = await assetModel(organization)
|
const findValue = await assetModel(organization)
|
||||||
.find()
|
.find()
|
||||||
.select("-_id -__v")
|
.select("-_id")
|
||||||
|
.populate({
|
||||||
|
path: "points",
|
||||||
|
// model: assetModel(organization),
|
||||||
|
select: "-_id",
|
||||||
|
})
|
||||||
.populate({
|
.populate({
|
||||||
path: "points.actions",
|
path: "points.actions",
|
||||||
select: "-_id",
|
model: actionModel(organization),
|
||||||
populate: {
|
// select: "-_id",
|
||||||
path: "eventData",
|
// populate: {
|
||||||
select: "uuid type -_id",
|
// path: "eventData",
|
||||||
},
|
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||||
|
// },
|
||||||
})
|
})
|
||||||
.populate({
|
.populate({
|
||||||
path: "points.triggers",
|
path: "points.triggers",
|
||||||
select: "-_id",
|
model: triggerModel(organization),
|
||||||
populate: {
|
// select: "-_id",
|
||||||
path: "triggerData",
|
// populate: {
|
||||||
select: "uuid type -_id",
|
// path: "triggerData",
|
||||||
},
|
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||||
|
// },
|
||||||
});
|
});
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(200).json("floorItems not found");
|
res.status(200).json("floorItems not found");
|
||||||
|
|||||||
201
src/api-server/controller/visualization/floatWidgetService.ts
Normal file
201
src/api-server/controller/visualization/floatWidgetService.ts
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import floatWidgetModel from "../../../shared/model/vizualization/3dwidget.ts";
|
||||||
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
|
export class floatWidgetService {
|
||||||
|
static async addfloatWidget(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 for the zoneId" });
|
||||||
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
|
floatWidgetID: widget.id,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existingFloatWidget) {
|
||||||
|
const updateFloatWidget = await floatWidgetModel(
|
||||||
|
organization
|
||||||
|
).findOneAndUpdate(
|
||||||
|
{
|
||||||
|
floatWidgetID: widget.id,
|
||||||
|
isArchive: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
// Data: {
|
||||||
|
// // measurements: widget.Data.measurements || {},
|
||||||
|
// duration: widget.Data.duration || "1h",
|
||||||
|
// },
|
||||||
|
position: widget.position,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
upsert: true,
|
||||||
|
new: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json({ message: "Widget updated successfully" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const newFloadWidget = await floatWidgetModel(organization).create({
|
||||||
|
className: widget.className,
|
||||||
|
header: widget.header,
|
||||||
|
floatWidgetID: widget.id,
|
||||||
|
position: widget.position,
|
||||||
|
per: widget.per,
|
||||||
|
value: widget.value,
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
if (newFloadWidget) {
|
||||||
|
return res
|
||||||
|
.status(201)
|
||||||
|
.json({ message: "FloatWidget created successfully" });
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async getfloatWidget(req: Request, res: Response): Promise<any> {
|
||||||
|
const { organization, zoneId } = req.params;
|
||||||
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingZone)
|
||||||
|
return res.status(404).json({ message: "Zone not found" });
|
||||||
|
const widgetData = await floatWidgetModel(organization)
|
||||||
|
.find({
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
})
|
||||||
|
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
||||||
|
if (!widgetData || widgetData.length === 0) {
|
||||||
|
return res.send([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const formattedWidgets = widgetData.map((widget) => ({
|
||||||
|
Data: {
|
||||||
|
measurements: widget.Data?.measurements || {},
|
||||||
|
duration: widget.Data?.duration || "1h",
|
||||||
|
},
|
||||||
|
className: widget.className,
|
||||||
|
header: widget.header,
|
||||||
|
id: widget.floatWidgetID,
|
||||||
|
position: widget.position,
|
||||||
|
per: widget.per,
|
||||||
|
value: widget.value,
|
||||||
|
}));
|
||||||
|
return res.status(200).json(formattedWidgets);
|
||||||
|
}
|
||||||
|
|
||||||
|
// static async deleteWidget(req: Request, res: Response): Promise<any> {
|
||||||
|
// try {
|
||||||
|
// const { widgetID, organization } = req.body;
|
||||||
|
// const findWidget = await widgetSchema(organization).findOne({
|
||||||
|
// widgetID: widgetID,
|
||||||
|
// isArchive: false,
|
||||||
|
// });
|
||||||
|
// if (!findWidget)
|
||||||
|
// return res.status(409).json({ message: "Widget not found" });
|
||||||
|
// const widgetData = await widgetSchema(organization).updateOne(
|
||||||
|
// { _id: findWidget._id, isArchive: false },
|
||||||
|
// { $set: { isArchive: true } }
|
||||||
|
// );
|
||||||
|
|
||||||
|
// if (widgetData) {
|
||||||
|
// // Find all widgets in the same panel and sort them by widgetOrder
|
||||||
|
// const widgets = await widgetSchema(organization).find({
|
||||||
|
// panelID: findWidget.panelID,
|
||||||
|
// isArchive: false,
|
||||||
|
// });
|
||||||
|
// // .sort({ widgetOrder: 1 });
|
||||||
|
|
||||||
|
// // Reassign widgetOrder values
|
||||||
|
// // for (let i = 0; i < widgets.length; i++) {
|
||||||
|
// // widgets[i].widgetOrder = (i + 1).toString(); // Convert to string
|
||||||
|
// // await widgets[i].save();
|
||||||
|
// // }
|
||||||
|
// const panelData = await panelSchema(organization).findOne({
|
||||||
|
// _id: findWidget.panelID,
|
||||||
|
// isArchive: false,
|
||||||
|
// });
|
||||||
|
// if (panelData.widgets.includes(findWidget._id)) {
|
||||||
|
// const index1 = panelData.widgets.indexOf(findWidget._id);
|
||||||
|
// panelData.widgets.splice(index1, 1);
|
||||||
|
// }
|
||||||
|
// await panelData.save();
|
||||||
|
// }
|
||||||
|
// return res.status(200).json({ message: "Widget deleted successfully" });
|
||||||
|
// } catch (error: any) {
|
||||||
|
// return res.status(500).send(error.message);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static async updatewidget(req: Request, res: Response): Promise<any> {
|
||||||
|
// try {
|
||||||
|
// const { organization, widgetID, values } = req.body;
|
||||||
|
// const findwidget = await widgetSchema(organization).findOne({
|
||||||
|
// widgetID: widgetID,
|
||||||
|
// isArchive: false,
|
||||||
|
// });
|
||||||
|
// if (!findwidget)
|
||||||
|
// return res.status(404).send({ message: "Data not found" });
|
||||||
|
// const updateData = {
|
||||||
|
// widgetName: values.widgetName,
|
||||||
|
// widgetSide: values.widgetSide, // Fixed typo from widgetside to widgetSide
|
||||||
|
// elementType: values.type,
|
||||||
|
// Data: {
|
||||||
|
// measurement: values.Data.measurement,
|
||||||
|
// duration: values.Data.duration,
|
||||||
|
// },
|
||||||
|
// elementColor: values.color,
|
||||||
|
// fontFamily: values.fontFamily,
|
||||||
|
// fontStyle: values.fontStyle,
|
||||||
|
// fontWeight: values.fontWeight,
|
||||||
|
// isArchive: false,
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const changedWidget = await widgetSchema(organization).findOneAndUpdate(
|
||||||
|
// { widgetID: widgetID, isArchive: false },
|
||||||
|
// updateData,
|
||||||
|
// {
|
||||||
|
// new: true,
|
||||||
|
// upsert: true,
|
||||||
|
// setDefaultsOnInsert: true,
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
// return res.status(200).json({
|
||||||
|
// message: "Widget updated successfully",
|
||||||
|
// });
|
||||||
|
// } catch (error: any) {
|
||||||
|
// return res.status(500).send(error.message);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static async getDatafromWidget(req: Request, res: Response): Promise<any> {
|
||||||
|
// const { organization, widgetID } = req.params;
|
||||||
|
// try {
|
||||||
|
// const existingWidget = await widgetSchema(organization)
|
||||||
|
// .findOne({
|
||||||
|
// widgetID: widgetID,
|
||||||
|
// isArchive: false,
|
||||||
|
// })
|
||||||
|
// .select("Data -_id");
|
||||||
|
// const Datastructure = {
|
||||||
|
// measurements: existingWidget.Data.measurements || {},
|
||||||
|
// duration: existingWidget.Data.duration || "1h",
|
||||||
|
// };
|
||||||
|
|
||||||
|
// if (existingWidget) return res.status(200).json({ Data: Datastructure });
|
||||||
|
// } catch (error: any) {
|
||||||
|
// return res.status(500).send(error.message);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -95,12 +95,10 @@ export class panelService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
||||||
existingZone.panelOrder = existingZone.panelOrder.filter(
|
const index1 = existingZone.panelOrder.indexOf(existingPanel.panelName);
|
||||||
(panel: any) => panel !== existingPanel.panelName
|
existingZone.panelOrder.splice(index1, 1);
|
||||||
);
|
|
||||||
|
|
||||||
await existingZone.save();
|
|
||||||
}
|
}
|
||||||
|
await existingZone.save();
|
||||||
|
|
||||||
return res.status(200).json({ message: "Panel deleted successfully" });
|
return res.status(200).json({ message: "Panel deleted successfully" });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
43
src/api-server/controller/visualization/templateService.ts
Normal file
43
src/api-server/controller/visualization/templateService.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
||||||
|
|
||||||
|
export class templateService {
|
||||||
|
static async AddTemplate(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
console.log("req.body: ", req.body);
|
||||||
|
const { organization, templateID, name, panelOrder, widgets, snapshot } =
|
||||||
|
req.body;
|
||||||
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
|
templateID: templateID,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existingTemplate)
|
||||||
|
return res.status(409).json({ message: "TemplateID alreay exists" });
|
||||||
|
const newTemplate = await templateModel(organization).create({
|
||||||
|
templateID,
|
||||||
|
name,
|
||||||
|
panelOrder,
|
||||||
|
widgets,
|
||||||
|
snapshot,
|
||||||
|
});
|
||||||
|
if (newTemplate)
|
||||||
|
return res.status(200).json({ message: "Template saved successfully" });
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async GetTemplate(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
const { organization } = req.params;
|
||||||
|
const existingTemplate = await templateModel(organization)
|
||||||
|
.find({
|
||||||
|
isArchive: false,
|
||||||
|
})
|
||||||
|
.select("-_id -__v -isArchive -createdAt -updatedAt");
|
||||||
|
if (!existingTemplate) return res.status(409).send([]);
|
||||||
|
return res.status(200).json(existingTemplate);
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,23 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
||||||
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
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);
|
||||||
const {
|
const {
|
||||||
organization,
|
organization,
|
||||||
// panel,
|
// panel,
|
||||||
zoneId,
|
zoneId,
|
||||||
widget,
|
widget,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingZone)
|
||||||
|
return res.status(404).json({ message: "Zone not found" });
|
||||||
const existingPanel = await panelSchema(organization).findOne({
|
const existingPanel = await panelSchema(organization).findOne({
|
||||||
panelName: widget.panel,
|
panelName: widget.panel,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -25,10 +33,35 @@ export class widgetService {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
// widgetOrder: widget.widgetOrder,
|
// widgetOrder: widget.widgetOrder,
|
||||||
});
|
});
|
||||||
|
// console.log('existingWidget: ', widget.data.measurements);
|
||||||
if (existingWidget) {
|
if (existingWidget) {
|
||||||
|
const updateWidget = await widgetSchema(
|
||||||
|
organization
|
||||||
|
).findOneAndUpdate(
|
||||||
|
{
|
||||||
|
panelID: existingPanel._id,
|
||||||
|
widgetID: widget.id,
|
||||||
|
isArchive: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
// panelID: existingPanel._id,
|
||||||
|
// widgetID: widget.id,
|
||||||
|
Data: {
|
||||||
|
measurements: widget.Data.measurements,
|
||||||
|
duration: widget.Data.duration,
|
||||||
|
},
|
||||||
|
// isArchive: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
||||||
|
);
|
||||||
return res
|
return res
|
||||||
.status(409)
|
.status(200)
|
||||||
.json({ message: "Widget already exist for the widgetID" });
|
.json({ message: "Widget updated successfully" });
|
||||||
|
// return res
|
||||||
|
// .status(409)
|
||||||
|
// .json({ message: "Widget already exist for the widgetID" });
|
||||||
}
|
}
|
||||||
const newWidget = await widgetSchema(organization).create({
|
const newWidget = await widgetSchema(organization).create({
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
@@ -39,7 +72,7 @@ export class widgetService {
|
|||||||
widgetside: widget.panel,
|
widgetside: widget.panel,
|
||||||
// Data: {
|
// Data: {
|
||||||
// measurements: widget.Data.measurements || {},
|
// measurements: widget.Data.measurements || {},
|
||||||
// duration: widget.Data.duration || "1hr",
|
// duration: widget.Data.duration || "1h",
|
||||||
// },
|
// },
|
||||||
});
|
});
|
||||||
if (newWidget) {
|
if (newWidget) {
|
||||||
@@ -65,7 +98,7 @@ export class widgetService {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findWidget)
|
if (!findWidget)
|
||||||
return res.status(409).json({ message: "Widget already deleted" });
|
return res.status(409).json({ message: "Widget not found" });
|
||||||
const widgetData = await widgetSchema(organization).updateOne(
|
const widgetData = await widgetSchema(organization).updateOne(
|
||||||
{ _id: findWidget._id, isArchive: false },
|
{ _id: findWidget._id, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
@@ -73,27 +106,24 @@ export class widgetService {
|
|||||||
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
// Find all widgets in the same panel and sort them by widgetOrder
|
// Find all widgets in the same panel and sort them by widgetOrder
|
||||||
const widgets = await widgetSchema(organization)
|
const widgets = await widgetSchema(organization).find({
|
||||||
.find({
|
panelID: findWidget.panelID,
|
||||||
panelID: findWidget.panelID,
|
isArchive: false,
|
||||||
isArchive: false,
|
});
|
||||||
})
|
// .sort({ widgetOrder: 1 });
|
||||||
.sort({ widgetOrder: 1 });
|
|
||||||
|
|
||||||
// Reassign widgetOrder values
|
// Reassign widgetOrder values
|
||||||
for (let i = 0; i < widgets.length; i++) {
|
// for (let i = 0; i < widgets.length; i++) {
|
||||||
widgets[i].widgetOrder = (i + 1).toString(); // Convert to string
|
// widgets[i].widgetOrder = (i + 1).toString(); // Convert to string
|
||||||
await widgets[i].save();
|
// await widgets[i].save();
|
||||||
}
|
// }
|
||||||
const panelData = await panelSchema(organization).findOne({
|
const panelData = await panelSchema(organization).findOne({
|
||||||
_id: findWidget.panelID,
|
_id: findWidget.panelID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (panelData.widgets.includes(findWidget._id)) {
|
if (panelData.widgets.includes(findWidget._id)) {
|
||||||
panelData.widgets = panelData.widgets.filter(
|
const index1 = panelData.widgets.indexOf(findWidget._id);
|
||||||
(widget: any) => widget !== findWidget._id
|
panelData.widgets.splice(index1, 1);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
await panelData.save();
|
await panelData.save();
|
||||||
}
|
}
|
||||||
@@ -150,13 +180,13 @@ export class widgetService {
|
|||||||
try {
|
try {
|
||||||
const existingWidget = await widgetSchema(organization)
|
const existingWidget = await widgetSchema(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
_id: widgetID,
|
widgetID: widgetID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("Data -_id");
|
.select("Data -_id");
|
||||||
const Datastructure = {
|
const Datastructure = {
|
||||||
measurements: existingWidget.Data.measurements || {},
|
measurements: existingWidget.Data.measurements || {},
|
||||||
duration: existingWidget.Data.duration || "1hr",
|
duration: existingWidget.Data.duration || "1h",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (existingWidget) return res.status(200).json({ Data: Datastructure });
|
if (existingWidget) return res.status(200).json({ Data: Datastructure });
|
||||||
|
|||||||
@@ -1,44 +1,41 @@
|
|||||||
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 IAction {
|
|
||||||
uuid: string;
|
|
||||||
name: string;
|
|
||||||
type: string;
|
|
||||||
material: string;
|
|
||||||
delay: string;
|
|
||||||
spawnInterval: string;
|
|
||||||
isUsed: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interface for TypeScript with PascalCase
|
|
||||||
export interface assetData extends Document {
|
export interface assetData extends Document {
|
||||||
modeluuid: string;
|
modeluuid: string;
|
||||||
modelfileID: string;
|
modelfileID: string;
|
||||||
modelname: string;
|
modelname: string;
|
||||||
isLocked: boolean;
|
isLocked: boolean;
|
||||||
|
type: string;
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
position: [];
|
// position: [];
|
||||||
rotation: {
|
// rotation: {
|
||||||
x: number;
|
// x: number;
|
||||||
y: number;
|
// y: number;
|
||||||
z: number;
|
// z: number;
|
||||||
};
|
// };
|
||||||
points: [
|
points: {
|
||||||
{
|
uuid: string;
|
||||||
uuid: string;
|
position: [];
|
||||||
position: [];
|
rotation: [];
|
||||||
rotation: [];
|
actions: [mongoose.Types.ObjectId];
|
||||||
actions: [mongoose.Types.ObjectId];
|
triggers: [mongoose.Types.ObjectId];
|
||||||
triggers: [mongoose.Types.ObjectId];
|
connections: {
|
||||||
// connections:{
|
source: {
|
||||||
// source:{
|
pathUUID: string;
|
||||||
// pathuuid:string,pointuuid:string
|
pointUUID: string;
|
||||||
// },
|
};
|
||||||
// target:[]
|
targets: [
|
||||||
// }
|
{
|
||||||
}
|
pathUUID: string;
|
||||||
];
|
pointUUID: string;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}[];
|
||||||
|
}[];
|
||||||
|
assetPosition: number[];
|
||||||
|
assetRotation: number[];
|
||||||
|
speed: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the Mongoose Schema
|
// Define the Mongoose Schema
|
||||||
@@ -46,7 +43,8 @@ const assetDataSchema: Schema = new Schema({
|
|||||||
modeluuid: { type: String },
|
modeluuid: { type: String },
|
||||||
modelfileID: { type: String },
|
modelfileID: { type: String },
|
||||||
modelname: { type: String },
|
modelname: { type: String },
|
||||||
position: { type: Array },
|
type: { type: String },
|
||||||
|
// assetPosition: { type: Array },
|
||||||
points: [
|
points: [
|
||||||
{
|
{
|
||||||
uuid: { type: String },
|
uuid: { type: String },
|
||||||
@@ -54,15 +52,30 @@ const assetDataSchema: Schema = new Schema({
|
|||||||
rotation: { type: Array },
|
rotation: { type: Array },
|
||||||
actions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Actions" }],
|
actions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Actions" }],
|
||||||
triggers: [{ type: mongoose.Schema.Types.ObjectId, ref: "Triggers" }],
|
triggers: [{ type: mongoose.Schema.Types.ObjectId, ref: "Triggers" }],
|
||||||
|
connections: {
|
||||||
|
source: {
|
||||||
|
pathUUID: { type: String },
|
||||||
|
pointUUID: { type: String },
|
||||||
|
},
|
||||||
|
targets: [
|
||||||
|
{
|
||||||
|
pathUUID: { type: String },
|
||||||
|
pointUUID: { type: String },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
assetPosition: { type: [Number] },
|
||||||
|
assetRotation: { type: [Number] },
|
||||||
|
speed: { type: Number },
|
||||||
isLocked: { type: Boolean },
|
isLocked: { type: Boolean },
|
||||||
isVisible: { type: Boolean },
|
isVisible: { type: Boolean },
|
||||||
rotation: {
|
// rotation: {
|
||||||
x: { type: Number },
|
// x: { type: Number },
|
||||||
y: { type: Number },
|
// y: { type: Number },
|
||||||
z: { type: Number },
|
// z: { type: Number },
|
||||||
},
|
// },
|
||||||
});
|
});
|
||||||
|
|
||||||
// export default floorItemsModel;
|
// export default floorItemsModel;
|
||||||
|
|||||||
@@ -9,53 +9,81 @@ interface IAction {
|
|||||||
delay: string;
|
delay: string;
|
||||||
spawnInterval: string;
|
spawnInterval: string;
|
||||||
isUsed: boolean;
|
isUsed: boolean;
|
||||||
|
hitCount: number;
|
||||||
|
start: string;
|
||||||
|
end: string;
|
||||||
|
buffer: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// interface IConnection {
|
interface ITriggers {
|
||||||
// source: { pathUUID: string; pointUUID: string };
|
uuid: string;
|
||||||
// targets: string[];
|
name: string;
|
||||||
// }
|
type: string;
|
||||||
|
isUsed: boolean;
|
||||||
|
bufferTime: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IConnection {
|
||||||
|
source: { pathUUID: string; pointUUID: string };
|
||||||
|
targets: { pathUUID: string; pointUUID: string }[];
|
||||||
|
}
|
||||||
|
|
||||||
interface IPoint {
|
interface IPoint {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: number[];
|
position: number[];
|
||||||
rotation: number[];
|
rotation: number[];
|
||||||
actions: IAction[];
|
actions: IAction[];
|
||||||
triggers: string[];
|
triggers: ITriggers[];
|
||||||
// connections: IConnection;
|
connections: IConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IBaseModel extends Document {
|
interface IBaseModel extends Document {
|
||||||
modelfileID: string;
|
modelfileID: string;
|
||||||
type: "Conveyor" | "Vehicle";
|
type: "Conveyor" | "Vehicle";
|
||||||
points: IPoint[] | IPoint;
|
points: IPoint[] | IPoint;
|
||||||
speed: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base Schema
|
// Base Schema
|
||||||
const PointSchema = new Schema<IPoint>({
|
const PointSchema = new Schema<IPoint>({
|
||||||
uuid: { type: String, required: true },
|
uuid: { type: String, required: true },
|
||||||
position: { type: [Number], required: true },
|
position: { type: [Number] },
|
||||||
rotation: { type: [Number], required: true },
|
rotation: { type: [Number] },
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
uuid: { type: String, default: "" },
|
uuid: { type: String, default: "" },
|
||||||
name: { type: String, required: true },
|
name: { type: String },
|
||||||
type: { type: String, required: true },
|
type: { type: String },
|
||||||
material: { type: String, required: true },
|
material: { type: String },
|
||||||
delay: { type: String, required: true },
|
delay: { type: String },
|
||||||
spawnInterval: { type: String, required: true },
|
spawnInterval: { type: String },
|
||||||
isUsed: { type: Boolean, required: true },
|
isUsed: { type: Boolean },
|
||||||
|
hitCount: { type: String },
|
||||||
|
start: { type: String },
|
||||||
|
end: { type: String },
|
||||||
|
buffer: { type: String },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
triggers: { type: [String], default: [] },
|
triggers: [
|
||||||
// connections: {
|
{
|
||||||
// source: {
|
uuid: { type: String, default: "" },
|
||||||
// pathUUID: { type: String, required: true },
|
name: { type: String },
|
||||||
// pointUUID: { type: String, required: true },
|
type: { type: String },
|
||||||
// },
|
bufferTime: { type: Number },
|
||||||
// targets: { type: [String], default: [] },
|
isUsed: { type: Boolean },
|
||||||
// },
|
},
|
||||||
|
],
|
||||||
|
connections: {
|
||||||
|
source: {
|
||||||
|
pathUUID: { type: String },
|
||||||
|
pointUUID: { type: String },
|
||||||
|
},
|
||||||
|
targets: [
|
||||||
|
{
|
||||||
|
pathUUID: { type: String },
|
||||||
|
pointUUID: { type: String },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const BaseSchema = new Schema<IBaseModel>(
|
const BaseSchema = new Schema<IBaseModel>(
|
||||||
@@ -66,7 +94,6 @@ const BaseSchema = new Schema<IBaseModel>(
|
|||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
speed: { type: Number },
|
|
||||||
},
|
},
|
||||||
{ discriminatorKey: "type", timestamps: true }
|
{ discriminatorKey: "type", timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,38 +1,46 @@
|
|||||||
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 Event extends Document {
|
export interface Action extends Document {
|
||||||
pointsUUID: string;
|
pointsUUID: string;
|
||||||
actionUUID: string;
|
// actionUUID: string;
|
||||||
isArchive: string;
|
isArchive: string;
|
||||||
sceneID: string;
|
// sceneID: string;
|
||||||
eventData: {
|
// eventData: {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
type: string;
|
name: string;
|
||||||
material: string;
|
type: string;
|
||||||
delay: number;
|
material: string;
|
||||||
spawn_Interval: number;
|
delay: string;
|
||||||
};
|
spawnInterval: string;
|
||||||
|
isUsed: boolean;
|
||||||
|
hitCount: number;
|
||||||
|
start: string;
|
||||||
|
end: string;
|
||||||
|
buffer: number;
|
||||||
|
// };
|
||||||
}
|
}
|
||||||
const eventSchema: Schema = new Schema(
|
const actionSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
pointsUUID: { type: String },
|
pointsUUID: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
actionUUID: { type: String },
|
// actionUUID: { type: String },
|
||||||
eventData: [
|
uuid: { type: String, default: "" },
|
||||||
{
|
name: { type: String },
|
||||||
uuid: { type: String },
|
type: { type: String },
|
||||||
type: { type: String },
|
material: { type: String },
|
||||||
material: { type: String },
|
delay: { type: String },
|
||||||
delay: { type: Number },
|
spawnInterval: { type: String },
|
||||||
spawn_Interval: { type: Number },
|
isUsed: { type: Boolean },
|
||||||
},
|
hitCount: { type: String },
|
||||||
],
|
start: { type: String },
|
||||||
|
end: { type: String },
|
||||||
|
buffer: { type: String },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const actionModel = (db: any) => {
|
const actionModel = (db: any) => {
|
||||||
return MainModel(db, "Actions", eventSchema, "Actions");
|
return MainModel(db, "Actions", actionSchema, "Actions");
|
||||||
};
|
};
|
||||||
export default actionModel;
|
export default actionModel;
|
||||||
|
|||||||
@@ -3,32 +3,26 @@ import MainModel from "../../connect/mongoose.ts";
|
|||||||
|
|
||||||
export interface Trigger extends Document {
|
export interface Trigger extends Document {
|
||||||
pointsUUID: string;
|
pointsUUID: string;
|
||||||
actionUUID: string;
|
// triggerUUID: string;
|
||||||
isArchive: string;
|
isArchive: string;
|
||||||
sceneID: string;
|
// sceneID: string;
|
||||||
triggerData: {
|
uuid: string;
|
||||||
uuid: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
// material: string;
|
isUsed: boolean;
|
||||||
// delay: number;
|
bufferTime: number;
|
||||||
// spawn_Interval: number;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
const triggerSchema: Schema = new Schema(
|
const triggerSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
pointsUUID: { type: String },
|
pointsUUID: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
actionUUID: { type: String },
|
// triggerUUID: { type: String },
|
||||||
sceneID: { type: String },
|
uuid: { type: String, default: "" },
|
||||||
triggerData: [
|
name: { type: String },
|
||||||
{
|
type: { type: String },
|
||||||
uuid: { type: String },
|
material: { type: String },
|
||||||
type: { type: String },
|
delay: { type: String },
|
||||||
// material: { type: String },
|
isUsed: { type: Boolean },
|
||||||
// delay: { type: Number },
|
|
||||||
// spawn_Interval: { type: Number },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
44
src/shared/model/vizualization/3dwidget.ts
Normal file
44
src/shared/model/vizualization/3dwidget.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;
|
||||||
@@ -3,11 +3,19 @@ import MainModel from "../../connect/mongoose.ts";
|
|||||||
|
|
||||||
export interface Template extends Document {
|
export interface Template extends Document {
|
||||||
templateName: string;
|
templateName: string;
|
||||||
|
templateID: string;
|
||||||
|
snapshot: string;
|
||||||
|
panelOrder: [];
|
||||||
|
widgets: [];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
}
|
}
|
||||||
const templateSchema: Schema = new Schema(
|
const templateSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
templateName: { type: String },
|
templateName: { type: String },
|
||||||
|
templateID: { type: String },
|
||||||
|
snapshot: { type: String },
|
||||||
|
panelOrder: { type: Array },
|
||||||
|
widgets: { type: Array },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export interface widget extends Document {
|
|||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
panelID: mongoose.Types.ObjectId;
|
panelID: mongoose.Types.ObjectId;
|
||||||
Data: {
|
Data: {
|
||||||
measurement: [any];
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -29,8 +29,8 @@ const widgetSchema: Schema = new Schema(
|
|||||||
fontFamily: { type: String },
|
fontFamily: { type: String },
|
||||||
fontStyle: { type: String },
|
fontStyle: { type: String },
|
||||||
Data: {
|
Data: {
|
||||||
measurements: { type: Array, default: [] },
|
measurements: { type: Object, default: {} },
|
||||||
duration: { type: String, default: "1hr" },
|
duration: { type: String, default: "1h" },
|
||||||
},
|
},
|
||||||
fontWeight: { type: String },
|
fontWeight: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
|
|||||||
Reference in New Issue
Block a user