RT-Vis 2d and floating widget API collaboration completed, template Save and get API completed. SOCKET 2d panel and widgets events completed
This commit is contained in:
25
.env
25
.env
@@ -1,12 +1,15 @@
|
||||
# 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
|
||||
# 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_USER=admin
|
||||
# MONGO_PASSWORD=admin321
|
||||
# MONGO_AUTH_DB=admin
|
||||
MONGO_URI=mongodb://mongo/
|
||||
API_PORT=5000
|
||||
SOCKET_PORT=8000
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as express from "express";
|
||||
import { assetsFloorservice } from "../controller/simulation/assetsFloorservice.ts";
|
||||
const router = express.Router();
|
||||
router.post("/setasset", assetsFloorservice.setFloorassets);
|
||||
router.get("/floorAssets/:organization", assetsFloorservice.getFloorItems);
|
||||
// router.get("/pointData/:modelfileID/:organization", assetsFloorservice.gettypePoints);
|
||||
export default router;
|
||||
import * as express from "express";
|
||||
import { assetsFloorservice } from "../controller/simulation/assetsFloorservice.ts";
|
||||
const router = express.Router();
|
||||
router.post("/setasset", assetsFloorservice.setFloorassets);
|
||||
router.get("/floorAssets/:organization", assetsFloorservice.getFloorItems);
|
||||
// router.get("/pointData/:modelfileID/:organization", assetsFloorservice.gettypePoints);
|
||||
export default router;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as express from "express";
|
||||
import { pointService } from "../controller/assets/pointService.ts";
|
||||
const router = express.Router();
|
||||
router.post("/pointSchema", pointService.addPoints);
|
||||
router.get("/pointData/:modelfileID/:organization", pointService.gettypePoints);
|
||||
export default router;
|
||||
import * as express from "express";
|
||||
import { pointService } from "../controller/assets/pointService.ts";
|
||||
const router = express.Router();
|
||||
router.post("/pointSchema", pointService.addPoints);
|
||||
router.get("/pointData/:modelfileID/:organization", pointService.gettypePoints);
|
||||
export default router;
|
||||
|
||||
@@ -1,9 +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
|
||||
);
|
||||
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;
|
||||
@@ -1,6 +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;
|
||||
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;
|
||||
|
||||
@@ -1,166 +1,166 @@
|
||||
import { Request, Response } from "express";
|
||||
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
||||
|
||||
export class pointService {
|
||||
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||
const { type, modelfileID, organization } = req.body;
|
||||
|
||||
if (!["Conveyor", "Vehicle"].includes(type)) {
|
||||
return res.status(400).json({ message: "Invalid type requested" });
|
||||
}
|
||||
|
||||
try {
|
||||
if (type === "Conveyor") {
|
||||
const pointsData = await pointModel(organization).findOne({
|
||||
modelfileID: modelfileID,
|
||||
type: type,
|
||||
});
|
||||
if (pointsData) return res.send("Data already exists");
|
||||
const createData = await pointModel(organization).create({
|
||||
type: "Conveyor",
|
||||
modelfileID: "672a090f80d91ac979f4d0bd",
|
||||
points: [
|
||||
{
|
||||
uuid: "point1UUID",
|
||||
position: [0, 0.85, 2.2],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "Inherit",
|
||||
material: "Inherit",
|
||||
delay: "Inherit",
|
||||
spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "trigger 1",
|
||||
type: "Inherit",
|
||||
bufferTime: 0,
|
||||
// delay: "Inherit",
|
||||
// spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
// connections: {
|
||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
// targets: [],
|
||||
// },
|
||||
},
|
||||
{
|
||||
uuid: "point2UUID",
|
||||
position: [0, 0.85, 0],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "Inherit",
|
||||
material: "Inherit",
|
||||
delay: "Inherit",
|
||||
spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "trigger 1",
|
||||
type: "Inherit",
|
||||
bufferTime: 0,
|
||||
// delay: "Inherit",
|
||||
// spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
// connections: {
|
||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
// targets: [],
|
||||
// },
|
||||
},
|
||||
{
|
||||
uuid: "point3UUID",
|
||||
position: [0, 0.85, -2.2],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "Inherit",
|
||||
material: "Inherit",
|
||||
delay: "Inherit",
|
||||
spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "trigger 1",
|
||||
type: "Inherit",
|
||||
bufferTime: 0,
|
||||
// delay: "Inherit",
|
||||
// spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
// connections: {
|
||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
// targets: [],
|
||||
// },
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
// else if (type === "Vehicle") {
|
||||
// // responseData = {
|
||||
// // type: "Vehicle",
|
||||
// // points: {
|
||||
// // uuid: "point1UUID",
|
||||
// // position: [10, 20, 30],
|
||||
// // rotation: [0, 0, 0],
|
||||
// // actions: [
|
||||
// // {
|
||||
// // uuid: "randomUUID",
|
||||
// // name: "Action 1",
|
||||
// // type: "Inherit",
|
||||
// // material: "Inherit",
|
||||
// // delay: "Inherit",
|
||||
// // spawnInterval: "Inherit",
|
||||
// // isUsed: false,
|
||||
// // },
|
||||
// // ],
|
||||
// // triggers: [],
|
||||
// // connections: {
|
||||
// // source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
// // targets: [],
|
||||
// // },
|
||||
// // },
|
||||
// // speed: 1,
|
||||
// // };
|
||||
// }
|
||||
|
||||
res.status(200).json({ message: "point created successfully" });
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Server error", error });
|
||||
}
|
||||
}
|
||||
|
||||
static async gettypePoints(req: Request, res: Response): Promise<any> {
|
||||
const { modelfileID, organization } = req.params;
|
||||
try {
|
||||
const getData = await pointModel(organization)
|
||||
.findOne({
|
||||
modelfileID: modelfileID,
|
||||
})
|
||||
.select("-_id -__v -createdAt -updatedAt");
|
||||
res.send(getData);
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Server error", error });
|
||||
}
|
||||
}
|
||||
}
|
||||
import { Request, Response } from "express";
|
||||
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
||||
|
||||
export class pointService {
|
||||
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||
const { type, modelfileID, organization } = req.body;
|
||||
|
||||
if (!["Conveyor", "Vehicle"].includes(type)) {
|
||||
return res.status(400).json({ message: "Invalid type requested" });
|
||||
}
|
||||
|
||||
try {
|
||||
if (type === "Conveyor") {
|
||||
const pointsData = await pointModel(organization).findOne({
|
||||
modelfileID: modelfileID,
|
||||
type: type,
|
||||
});
|
||||
if (pointsData) return res.send("Data already exists");
|
||||
const createData = await pointModel(organization).create({
|
||||
type: "Conveyor",
|
||||
modelfileID: "672a090f80d91ac979f4d0bd",
|
||||
points: [
|
||||
{
|
||||
uuid: "point1UUID",
|
||||
position: [0, 0.85, 2.2],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "Inherit",
|
||||
material: "Inherit",
|
||||
delay: "Inherit",
|
||||
spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "trigger 1",
|
||||
type: "Inherit",
|
||||
bufferTime: 0,
|
||||
// delay: "Inherit",
|
||||
// spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
// connections: {
|
||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
// targets: [],
|
||||
// },
|
||||
},
|
||||
{
|
||||
uuid: "point2UUID",
|
||||
position: [0, 0.85, 0],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "Inherit",
|
||||
material: "Inherit",
|
||||
delay: "Inherit",
|
||||
spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "trigger 1",
|
||||
type: "Inherit",
|
||||
bufferTime: 0,
|
||||
// delay: "Inherit",
|
||||
// spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
// connections: {
|
||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
// targets: [],
|
||||
// },
|
||||
},
|
||||
{
|
||||
uuid: "point3UUID",
|
||||
position: [0, 0.85, -2.2],
|
||||
rotation: [0, 0, 0],
|
||||
actions: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "Action 1",
|
||||
type: "Inherit",
|
||||
material: "Inherit",
|
||||
delay: "Inherit",
|
||||
spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{
|
||||
uuid: "randomUUID",
|
||||
name: "trigger 1",
|
||||
type: "Inherit",
|
||||
bufferTime: 0,
|
||||
// delay: "Inherit",
|
||||
// spawnInterval: "Inherit",
|
||||
isUsed: false,
|
||||
},
|
||||
],
|
||||
// connections: {
|
||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
// targets: [],
|
||||
// },
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
// else if (type === "Vehicle") {
|
||||
// // responseData = {
|
||||
// // type: "Vehicle",
|
||||
// // points: {
|
||||
// // uuid: "point1UUID",
|
||||
// // position: [10, 20, 30],
|
||||
// // rotation: [0, 0, 0],
|
||||
// // actions: [
|
||||
// // {
|
||||
// // uuid: "randomUUID",
|
||||
// // name: "Action 1",
|
||||
// // type: "Inherit",
|
||||
// // material: "Inherit",
|
||||
// // delay: "Inherit",
|
||||
// // spawnInterval: "Inherit",
|
||||
// // isUsed: false,
|
||||
// // },
|
||||
// // ],
|
||||
// // triggers: [],
|
||||
// // connections: {
|
||||
// // source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||
// // targets: [],
|
||||
// // },
|
||||
// // },
|
||||
// // speed: 1,
|
||||
// // };
|
||||
// }
|
||||
|
||||
res.status(200).json({ message: "point created successfully" });
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Server error", error });
|
||||
}
|
||||
}
|
||||
|
||||
static async gettypePoints(req: Request, res: Response): Promise<any> {
|
||||
const { modelfileID, organization } = req.params;
|
||||
try {
|
||||
const getData = await pointModel(organization)
|
||||
.findOne({
|
||||
modelfileID: modelfileID,
|
||||
})
|
||||
.select("-_id -__v -createdAt -updatedAt");
|
||||
res.send(getData);
|
||||
} catch (error) {
|
||||
res.status(500).json({ message: "Server error", error });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,170 +1,170 @@
|
||||
import { Request, Response } from "express";
|
||||
// import assetModel from "../../../shared/model/assets/flooritems-Model.ts";
|
||||
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
||||
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
||||
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
||||
|
||||
export class assetsFloorservice {
|
||||
static async setFloorassets(req: Request, res: Response) {
|
||||
try {
|
||||
const {
|
||||
modeluuid,
|
||||
modelname,
|
||||
speed,
|
||||
assetPosition,
|
||||
modelfileID,
|
||||
assetRotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
organization,
|
||||
points,
|
||||
} = req.body;
|
||||
|
||||
const findvalue = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
modelname: modelname,
|
||||
});
|
||||
|
||||
if (findvalue) {
|
||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid, modelname: modelname },
|
||||
{
|
||||
assetPosition: assetPosition,
|
||||
assetRotation: assetRotation,
|
||||
isVisible: isVisible,
|
||||
isLocked: isLocked,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
res.status(201).json(updatevalue);
|
||||
} else {
|
||||
let pointRefs = [];
|
||||
|
||||
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,
|
||||
speed,
|
||||
modelname,
|
||||
assetPosition,
|
||||
modelfileID,
|
||||
assetRotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
points: pointRefs,
|
||||
});
|
||||
|
||||
await assetDoc.save();
|
||||
res.status(201).json({
|
||||
message: "Model stored successfully",
|
||||
modelId: assetDoc._id,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error creating flooritems:", error);
|
||||
res.status(500).json({ message: "Failed to create flooritems" });
|
||||
}
|
||||
}
|
||||
static async getFloorItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization } = req.params;
|
||||
const findValue = await assetModel(organization)
|
||||
.find()
|
||||
.select("-_id")
|
||||
.populate({
|
||||
path: "points",
|
||||
// model: assetModel(organization),
|
||||
select: "-_id",
|
||||
})
|
||||
.populate({
|
||||
path: "points.actions",
|
||||
model: actionModel(organization),
|
||||
// select: "-_id",
|
||||
// populate: {
|
||||
// path: "eventData",
|
||||
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||
// },
|
||||
})
|
||||
.populate({
|
||||
path: "points.triggers",
|
||||
model: triggerModel(organization),
|
||||
// select: "-_id",
|
||||
// populate: {
|
||||
// path: "triggerData",
|
||||
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||
// },
|
||||
});
|
||||
if (!findValue) {
|
||||
res.status(200).json("floorItems not found");
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get flooritems:", error);
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
static async deleteFloorItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { modeluuid, modelname, organization } = req.body;
|
||||
|
||||
const findValue = await assetModel(organization).findOneAndDelete({
|
||||
modeluuid: modeluuid,
|
||||
modelname: modelname,
|
||||
});
|
||||
if (!findValue) {
|
||||
res.status(200).json("user not found");
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get flooritems:", error);
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
}
|
||||
import { Request, Response } from "express";
|
||||
// import assetModel from "../../../shared/model/assets/flooritems-Model.ts";
|
||||
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
||||
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
||||
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
||||
|
||||
export class assetsFloorservice {
|
||||
static async setFloorassets(req: Request, res: Response) {
|
||||
try {
|
||||
const {
|
||||
modeluuid,
|
||||
modelname,
|
||||
speed,
|
||||
assetPosition,
|
||||
modelfileID,
|
||||
assetRotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
organization,
|
||||
points,
|
||||
} = req.body;
|
||||
|
||||
const findvalue = await assetModel(organization).findOne({
|
||||
modeluuid: modeluuid,
|
||||
modelname: modelname,
|
||||
});
|
||||
|
||||
if (findvalue) {
|
||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid, modelname: modelname },
|
||||
{
|
||||
assetPosition: assetPosition,
|
||||
assetRotation: assetRotation,
|
||||
isVisible: isVisible,
|
||||
isLocked: isLocked,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
res.status(201).json(updatevalue);
|
||||
} else {
|
||||
let pointRefs = [];
|
||||
|
||||
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,
|
||||
speed,
|
||||
modelname,
|
||||
assetPosition,
|
||||
modelfileID,
|
||||
assetRotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
points: pointRefs,
|
||||
});
|
||||
|
||||
await assetDoc.save();
|
||||
res.status(201).json({
|
||||
message: "Model stored successfully",
|
||||
modelId: assetDoc._id,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error creating flooritems:", error);
|
||||
res.status(500).json({ message: "Failed to create flooritems" });
|
||||
}
|
||||
}
|
||||
static async getFloorItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization } = req.params;
|
||||
const findValue = await assetModel(organization)
|
||||
.find()
|
||||
.select("-_id")
|
||||
.populate({
|
||||
path: "points",
|
||||
// model: assetModel(organization),
|
||||
select: "-_id",
|
||||
})
|
||||
.populate({
|
||||
path: "points.actions",
|
||||
model: actionModel(organization),
|
||||
// select: "-_id",
|
||||
// populate: {
|
||||
// path: "eventData",
|
||||
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||
// },
|
||||
})
|
||||
.populate({
|
||||
path: "points.triggers",
|
||||
model: triggerModel(organization),
|
||||
// select: "-_id",
|
||||
// populate: {
|
||||
// path: "triggerData",
|
||||
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||
// },
|
||||
});
|
||||
if (!findValue) {
|
||||
res.status(200).json("floorItems not found");
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get flooritems:", error);
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
static async deleteFloorItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { modeluuid, modelname, organization } = req.body;
|
||||
|
||||
const findValue = await assetModel(organization).findOneAndDelete({
|
||||
modeluuid: modeluuid,
|
||||
modelname: modelname,
|
||||
});
|
||||
if (!findValue) {
|
||||
res.status(200).json("user not found");
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get flooritems:", error);
|
||||
res.status(500).json({ error: "Failed to get flooritems" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,201 +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);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
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);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,43 +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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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,107 +1,107 @@
|
||||
import mongoose, { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
interface IAction {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
material: string;
|
||||
delay: string;
|
||||
spawnInterval: string;
|
||||
isUsed: boolean;
|
||||
hitCount: number;
|
||||
start: string;
|
||||
end: string;
|
||||
buffer: number;
|
||||
}
|
||||
|
||||
interface ITriggers {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}
|
||||
|
||||
interface IConnection {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: { pathUUID: string; pointUUID: string }[];
|
||||
}
|
||||
|
||||
interface IPoint {
|
||||
uuid: string;
|
||||
position: number[];
|
||||
rotation: number[];
|
||||
actions: IAction[];
|
||||
triggers: ITriggers[];
|
||||
connections: IConnection;
|
||||
}
|
||||
|
||||
interface IBaseModel extends Document {
|
||||
modelfileID: string;
|
||||
type: "Conveyor" | "Vehicle";
|
||||
points: IPoint[] | IPoint;
|
||||
}
|
||||
|
||||
// Base Schema
|
||||
const PointSchema = new Schema<IPoint>({
|
||||
uuid: { type: String, required: true },
|
||||
position: { type: [Number] },
|
||||
rotation: { type: [Number] },
|
||||
actions: [
|
||||
{
|
||||
uuid: { type: String, default: "" },
|
||||
name: { type: String },
|
||||
type: { type: String },
|
||||
material: { type: String },
|
||||
delay: { type: String },
|
||||
spawnInterval: { type: String },
|
||||
isUsed: { type: Boolean },
|
||||
hitCount: { type: String },
|
||||
start: { type: String },
|
||||
end: { type: String },
|
||||
buffer: { type: String },
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{
|
||||
uuid: { type: String, default: "" },
|
||||
name: { type: String },
|
||||
type: { type: String },
|
||||
bufferTime: { type: Number },
|
||||
isUsed: { type: Boolean },
|
||||
},
|
||||
],
|
||||
connections: {
|
||||
source: {
|
||||
pathUUID: { type: String },
|
||||
pointUUID: { type: String },
|
||||
},
|
||||
targets: [
|
||||
{
|
||||
pathUUID: { type: String },
|
||||
pointUUID: { type: String },
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const BaseSchema = new Schema<IBaseModel>(
|
||||
{
|
||||
modelfileID: { type: String },
|
||||
type: { type: String, enum: ["Conveyor", "Vehicle"] },
|
||||
points: {
|
||||
type: Schema.Types.Mixed,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{ discriminatorKey: "type", timestamps: true }
|
||||
);
|
||||
|
||||
const pointModel = (db: string) => {
|
||||
return MainModel(db, "Points", BaseSchema, "Points");
|
||||
};
|
||||
export default pointModel;
|
||||
|
||||
// const pointModel = mongoose.model<IBaseModel>("Points", BaseSchema, "Points");
|
||||
// export default pointModel;
|
||||
import mongoose, { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../../connect/mongoose.ts";
|
||||
|
||||
interface IAction {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
material: string;
|
||||
delay: string;
|
||||
spawnInterval: string;
|
||||
isUsed: boolean;
|
||||
hitCount: number;
|
||||
start: string;
|
||||
end: string;
|
||||
buffer: number;
|
||||
}
|
||||
|
||||
interface ITriggers {
|
||||
uuid: string;
|
||||
name: string;
|
||||
type: string;
|
||||
isUsed: boolean;
|
||||
bufferTime: number;
|
||||
}
|
||||
|
||||
interface IConnection {
|
||||
source: { pathUUID: string; pointUUID: string };
|
||||
targets: { pathUUID: string; pointUUID: string }[];
|
||||
}
|
||||
|
||||
interface IPoint {
|
||||
uuid: string;
|
||||
position: number[];
|
||||
rotation: number[];
|
||||
actions: IAction[];
|
||||
triggers: ITriggers[];
|
||||
connections: IConnection;
|
||||
}
|
||||
|
||||
interface IBaseModel extends Document {
|
||||
modelfileID: string;
|
||||
type: "Conveyor" | "Vehicle";
|
||||
points: IPoint[] | IPoint;
|
||||
}
|
||||
|
||||
// Base Schema
|
||||
const PointSchema = new Schema<IPoint>({
|
||||
uuid: { type: String, required: true },
|
||||
position: { type: [Number] },
|
||||
rotation: { type: [Number] },
|
||||
actions: [
|
||||
{
|
||||
uuid: { type: String, default: "" },
|
||||
name: { type: String },
|
||||
type: { type: String },
|
||||
material: { type: String },
|
||||
delay: { type: String },
|
||||
spawnInterval: { type: String },
|
||||
isUsed: { type: Boolean },
|
||||
hitCount: { type: String },
|
||||
start: { type: String },
|
||||
end: { type: String },
|
||||
buffer: { type: String },
|
||||
},
|
||||
],
|
||||
triggers: [
|
||||
{
|
||||
uuid: { type: String, default: "" },
|
||||
name: { type: String },
|
||||
type: { type: String },
|
||||
bufferTime: { type: Number },
|
||||
isUsed: { type: Boolean },
|
||||
},
|
||||
],
|
||||
connections: {
|
||||
source: {
|
||||
pathUUID: { type: String },
|
||||
pointUUID: { type: String },
|
||||
},
|
||||
targets: [
|
||||
{
|
||||
pathUUID: { type: String },
|
||||
pointUUID: { type: String },
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const BaseSchema = new Schema<IBaseModel>(
|
||||
{
|
||||
modelfileID: { type: String },
|
||||
type: { type: String, enum: ["Conveyor", "Vehicle"] },
|
||||
points: {
|
||||
type: Schema.Types.Mixed,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{ discriminatorKey: "type", timestamps: true }
|
||||
);
|
||||
|
||||
const pointModel = (db: string) => {
|
||||
return MainModel(db, "Points", BaseSchema, "Points");
|
||||
};
|
||||
export default pointModel;
|
||||
|
||||
// const pointModel = mongoose.model<IBaseModel>("Points", BaseSchema, "Points");
|
||||
// export default pointModel;
|
||||
|
||||
@@ -1,44 +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;
|
||||
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;
|
||||
|
||||
@@ -59,8 +59,9 @@ try {
|
||||
}
|
||||
|
||||
}
|
||||
export const deletePanel = async (data: any) => {
|
||||
const { organization, panelID, zoneId } = data;
|
||||
export const panelDelete = async (data: any) => {
|
||||
const { organization, panelName, zoneId } = data;
|
||||
console.log('data: ', data);
|
||||
try {
|
||||
const existingZone = await zoneSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
@@ -71,17 +72,17 @@ export const deletePanel = async (data: any) => {
|
||||
|
||||
const existingPanel = await panelSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
_id: panelID,
|
||||
panelName: panelName,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingPanel)
|
||||
return { success: false, message: 'Panel Already Deleted',organization: organization}
|
||||
const updatePanel = await panelSchema(organization).updateOne(
|
||||
{ _id: panelID, isArchive: false },
|
||||
{ _id: existingPanel._id, isArchive: false },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
const existingWidgets = await widgetSchema(organization).find({
|
||||
panelID: panelID,
|
||||
panelID:existingPanel._id,
|
||||
isArchive: false,
|
||||
});
|
||||
|
||||
@@ -90,14 +91,13 @@ export const deletePanel = async (data: any) => {
|
||||
await widgetData.save();
|
||||
}
|
||||
|
||||
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
||||
existingZone.panelOrder = existingZone.panelOrder.filter(
|
||||
(panel: any) => panel !== existingPanel.panelName
|
||||
);
|
||||
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
||||
const index1 = existingZone.panelOrder.indexOf(existingPanel.panelName);
|
||||
existingZone.panelOrder.splice(index1, 1);
|
||||
|
||||
await existingZone.save();
|
||||
const panelDeleteDatas= await existingZone.save();
|
||||
return { success: true, message: 'Panel deleted successfully',data:panelDeleteDatas,organization: organization}
|
||||
}
|
||||
return { success: true, message: 'Panel deleted successfully',organization: organization}
|
||||
|
||||
} catch (error) {
|
||||
return { success: false, message: 'Panel not found', error,organization: organization } }
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||
export const addPanel = async (data: any) => {
|
||||
|
||||
}
|
||||
119
src/socket-server/services/visualization/widget-Services.ts
Normal file
119
src/socket-server/services/visualization/widget-Services.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||
export const addWidget = async (data: any) => {
|
||||
const { organization,panel,zoneId,widget,} = data
|
||||
console.log('data: ', data);
|
||||
try {
|
||||
const existingPanel = await panelSchema(organization).findOne({
|
||||
panelName: widget.panel,
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingPanel)
|
||||
|
||||
return { success: false, message: "panelName not found",organization: organization}
|
||||
|
||||
|
||||
if (existingPanel.panelName === widget.panel) {
|
||||
const existingWidget = await widgetSchema(organization).findOne({
|
||||
panelID: existingPanel._id,
|
||||
widgetID: widget.id,
|
||||
isArchive: false,
|
||||
// widgetOrder: widget.widgetOrder,
|
||||
});
|
||||
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 { success: false, message: "Widget updated successfully",data:updateWidget,organization: organization}
|
||||
|
||||
}
|
||||
const newWidget = await widgetSchema(organization).create({
|
||||
widgetID: widget.id,
|
||||
elementType: widget.type,
|
||||
// widgetOrder: widgetOrder,
|
||||
widgetName: widget.widgetName,
|
||||
panelID: existingPanel._id,
|
||||
widgetside: widget.panel,
|
||||
// Data: {
|
||||
// measurements: widget.Data.measurements || {},
|
||||
// duration: widget.Data.duration || "1hr",
|
||||
// },
|
||||
});
|
||||
if (newWidget) {
|
||||
existingPanel.widgets.push(newWidget._id);
|
||||
await existingPanel.save();
|
||||
return { success: true, message: "Widget already exist for the widgetID",data:existingPanel,organization: organization}
|
||||
}
|
||||
}
|
||||
return { success: false, message: "Type mismatch",organization: organization}
|
||||
|
||||
} catch (error: any) {
|
||||
return { success: false, message: 'widge not found', error,organization: organization }
|
||||
}
|
||||
}
|
||||
export const Widgetdelete = async (data: any) => {
|
||||
const { widgetID, organization } = data
|
||||
console.log('data: ', data);
|
||||
try {
|
||||
const findWidget = await widgetSchema(organization).findOne({
|
||||
widgetID: widgetID,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!findWidget)
|
||||
return { success: false, message: "Widget not found",organization: organization}
|
||||
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);
|
||||
}
|
||||
const panelDeletedata = await panelData.save();
|
||||
console.log('Widget deleted successfully: ');
|
||||
return { success: false, message: "Widget deleted successfully",data:panelDeletedata,organization: organization}
|
||||
|
||||
}
|
||||
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error?.message || "An unknown error occurred.", error ,organization: organization}
|
||||
}
|
||||
}
|
||||
@@ -53,4 +53,10 @@ export const EVENTS = {
|
||||
panelUpdateRespones:"viz-panel:response:updates",
|
||||
deletePanel:"v2:viz-panel:delete",
|
||||
PanelDeleteRespones:"viz-panel:response:delete",
|
||||
|
||||
//widget
|
||||
addWidget:"v2:viz-widget:add",
|
||||
widgetUpdateRespones:"viz-widget:response:updates",
|
||||
deleteWidget:"v2:viz-widget:delete",
|
||||
widgetDeleteRespones:"viz-widget:response:delete",
|
||||
}
|
||||
@@ -7,7 +7,8 @@ import { deleteWallItems, setWallItems } from '../services/assets/wallitem-Contr
|
||||
import { deleteLineItems, deleteLinPoiteItems, updateLineItems ,createLineItems, deleteLayer} from '../services/lines/line-Controller.ts';
|
||||
import { activeUserOffline, activeUsers } from '../services/users/user-controller.ts';
|
||||
import { deleteZone, setZone } from '../services/lines/zone-controller.ts';
|
||||
import { addPanel } from '../services/visualization/panel-Services.ts';
|
||||
import { addPanel, panelDelete } from '../services/visualization/panel-Services.ts';
|
||||
import { addWidget, Widgetdelete } from '../services/visualization/widget-Services.ts';
|
||||
|
||||
|
||||
|
||||
@@ -432,7 +433,7 @@ const panelHandleEvent=async(event: string, socket: Socket, data: any,namespace:
|
||||
|
||||
let result;
|
||||
switch (event) {
|
||||
case EVENTS.addPanel:
|
||||
case EVENTS.addPanel:{
|
||||
result = await addPanel(data);
|
||||
console.log('result: ', result);
|
||||
|
||||
@@ -443,7 +444,7 @@ const panelHandleEvent=async(event: string, socket: Socket, data: any,namespace:
|
||||
const organization=result?.organization
|
||||
console.log('organization: ', organization);
|
||||
// const emitTarget = notifySender ? socket.in(organization) : socket.to(organization);
|
||||
console.log(`👀 Active sockets in room:`, namespace.adapter.rooms.get(organization));
|
||||
// console.log(`👀 Active sockets in room:`, namespace.adapter.rooms.get(organization));
|
||||
// console.log('emitTarget: ', emitTarget);
|
||||
|
||||
socket.to(organization).emit(responseEvent, {
|
||||
@@ -455,7 +456,34 @@ const panelHandleEvent=async(event: string, socket: Socket, data: any,namespace:
|
||||
organization: result.organization,
|
||||
});
|
||||
}
|
||||
break;
|
||||
break;}
|
||||
case EVENTS.deletePanel: {
|
||||
const result = await panelDelete(data)
|
||||
if (result) {
|
||||
// console.log('result?.success: ', result.organization);
|
||||
const responseEvent = EVENTS.PanelDeleteRespones
|
||||
// console.log('responseEvent: ', responseEvent);
|
||||
const organization = result?.organization
|
||||
// console.log('organization: ', organization);
|
||||
// const emitTarget = notifySender ? socket.in(organization) : socket.to(organization);
|
||||
// console.log(`👀 Active sockets in room:`, namespace.adapter.rooms.get(organization));
|
||||
// console.log('emitTarget: ', emitTarget);
|
||||
if (organization) {
|
||||
socket.emit(responseEvent, {
|
||||
success: result.success,
|
||||
message: result.message,
|
||||
data: result.data,
|
||||
error: result.error || null,
|
||||
socketId: socket.id,
|
||||
organization,
|
||||
});
|
||||
} else {
|
||||
console.warn(`Organization missing in response for event: ${event}`);
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
return;
|
||||
@@ -463,6 +491,77 @@ const panelHandleEvent=async(event: string, socket: Socket, data: any,namespace:
|
||||
|
||||
|
||||
}
|
||||
const widgetHandleEvent = async (event: string, socket: Socket, data: any, namespace: any, notifySender: boolean = false) => {
|
||||
// console.log('data: ', data);
|
||||
if (!data?.organization) {
|
||||
console.warn(`Missing organization for event: ${event}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let result;
|
||||
switch (event) {
|
||||
case EVENTS.addWidget: {
|
||||
result = await addWidget(data);
|
||||
// console.log('result: ', result);
|
||||
|
||||
if (result) {
|
||||
// console.log('result?.success: ', result.organization);
|
||||
const responseEvent = EVENTS.widgetUpdateRespones
|
||||
// console.log('responseEvent: ', responseEvent);
|
||||
const organization = result?.organization
|
||||
// console.log('organization: ', organization);
|
||||
// const emitTarget = notifySender ? socket.in(organization) : socket.to(organization);
|
||||
// console.log(`👀 Active sockets in room:`, namespace.adapter.rooms.get(organization));
|
||||
// console.log('emitTarget: ', emitTarget);
|
||||
if (organization) {
|
||||
socket.to(organization).emit(responseEvent, {
|
||||
success: result.success,
|
||||
message: result.message,
|
||||
data: result.data,
|
||||
error: result.error || null,
|
||||
socketId: socket.id,
|
||||
organization,
|
||||
});
|
||||
} else {
|
||||
console.warn(`Organization missing in response for event: ${event}`);
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
case EVENTS.deleteWidget: {
|
||||
const result = await Widgetdelete(data)
|
||||
if (result) {
|
||||
// console.log('result?.success: ', result.organization);
|
||||
const responseEvent = EVENTS.widgetDeleteRespones
|
||||
// console.log('responseEvent: ', responseEvent);
|
||||
const organization = result?.organization
|
||||
// console.log('organization: ', organization);
|
||||
// const emitTarget = notifySender ? socket.in(organization) : socket.to(organization);
|
||||
// console.log(`👀 Active sockets in room:`, namespace.adapter.rooms.get(organization));
|
||||
// console.log('emitTarget: ', emitTarget);
|
||||
if (organization) {
|
||||
socket.emit(responseEvent, {
|
||||
success: result.success,
|
||||
message: result.message,
|
||||
data: result.data,
|
||||
error: result.error || null,
|
||||
socketId: socket.id,
|
||||
organization,
|
||||
});
|
||||
} else {
|
||||
console.warn(`Organization missing in response for event: ${event}`);
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export const initSocketServer = (httpServer: any) => {
|
||||
const io = new Server(httpServer, {
|
||||
cors: {
|
||||
@@ -497,40 +596,42 @@ userStatus(EVENTS.connection, socket, socket.handshake.auth,io);
|
||||
});
|
||||
});
|
||||
|
||||
// 🔹 Create different namespaces
|
||||
const namespaces = {
|
||||
camera: io.of("/camera"),
|
||||
environment: io.of("/environment"),
|
||||
floorItems: io.of("/floorItems"),
|
||||
wallItems: io.of("/wallItems"),
|
||||
line: io.of("/line"),
|
||||
zone: io.of("/zone"),
|
||||
panel:io.of('/panel')
|
||||
};
|
||||
// 🔹 Create different namespaces
|
||||
const namespaces = {
|
||||
camera: io.of("/camera"),
|
||||
environment: io.of("/environment"),
|
||||
floorItems: io.of("/floorItems"),
|
||||
wallItems: io.of("/wallItems"),
|
||||
line: io.of("/line"),
|
||||
zone: io.of("/zone"),
|
||||
visualization: io.of('/visualization'),
|
||||
// widget:io.of('/widget')
|
||||
};
|
||||
// 🔹 Function to handle connections in a namespace
|
||||
const handleNamespace = (namespaceName: string, namespace: any, eventHandler: Function) => {
|
||||
const handleNamespace = (namespaceName: string, namespace: any, ...eventHandlers: Function[]) => {
|
||||
namespace.on("connection", (socket: Socket) => {
|
||||
console.log(`✅ Client connected to ${namespaceName}: ${socket.id}`);
|
||||
|
||||
|
||||
// Extract organization from query parameters
|
||||
const organization = socket.handshake.query.organization as string;
|
||||
console.log(`🔍 Received organization: ${organization}`);
|
||||
|
||||
// console.log(`🔍 Received organization: ${organization}`);
|
||||
|
||||
if (organization) {
|
||||
socket.join(organization);
|
||||
console.log(`🔹 Socket ${socket.id} joined room: ${organization}`);
|
||||
|
||||
// console.log(`🔹 Socket ${socket.id} joined room: ${organization}`);
|
||||
|
||||
// Debug: Check rooms
|
||||
console.log(`🛠️ Current rooms for ${socket.id}:`, socket.rooms);
|
||||
// console.log(`🛠️ Current rooms for ${socket.id}:`, socket.rooms);
|
||||
} else {
|
||||
console.warn(`⚠️ Warning: Socket ${socket.id} did not provide an organization`);
|
||||
}
|
||||
|
||||
|
||||
socket.onAny((event: string, data: any) => {
|
||||
console.log(`📩 Event received: ${event}, Data: ${JSON.stringify(data)}`);
|
||||
eventHandler(event, socket, data, namespace); // Pass `namespace` instead of `io`
|
||||
// console.log(`📩 Event received: ${event}, Data: ${JSON.stringify(data)}`);
|
||||
eventHandlers.forEach(handler => handler(event, socket, data, namespace));
|
||||
// eventHandler(event, socket, data, namespace); // Pass `namespace` instead of `io`
|
||||
});
|
||||
|
||||
|
||||
socket.on("disconnect", (reason: string) => {
|
||||
console.log(`❌ Client disconnected from ${namespaceName}: ${socket.id}, Reason: ${reason}`);
|
||||
});
|
||||
@@ -544,21 +645,10 @@ userStatus(EVENTS.connection, socket, socket.handshake.auth,io);
|
||||
handleNamespace("wallItems", namespaces.wallItems, wallItemsHandleEvent);
|
||||
handleNamespace("line", namespaces.line, lineHandleEvent);
|
||||
handleNamespace("zone", namespaces.zone, zoneHandleEvent);
|
||||
handleNamespace("panel", namespaces.panel, panelHandleEvent);
|
||||
// 📌 **Create a separate namespace for panels**
|
||||
// const panelNamespace = io.of('/panel');
|
||||
// handleNamespace("visualization", namespaces.panel, panelHandleEvent);
|
||||
// handleNamespace("widget", namespaces.visualization, widgetHandleEvent);
|
||||
handleNamespace("visualization", namespaces.visualization, panelHandleEvent, widgetHandleEvent);
|
||||
|
||||
// panelNamespace.on(EVENTS.connection, (socket: Socket) => {
|
||||
// console.log(`New client connected to /panel namespace: ${socket.id}`);
|
||||
|
||||
// socket.onAny((event: string, data: any) => {
|
||||
// panelHandleEvent(event, socket, data);
|
||||
// });
|
||||
|
||||
// socket.on(EVENTS.disconnect, (reason: string) => {
|
||||
// console.log(`Client disconnected from /panel namespace: ${socket.id}, Reason: ${reason}`);
|
||||
// });
|
||||
// })
|
||||
|
||||
return io;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user