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_URI=mongodb://192.168.0.111/
|
||||||
# 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
|
||||||
MONGO_URI=mongodb://mongo/
|
# MONGO_USER=admin
|
||||||
API_PORT=5000
|
# MONGO_PASSWORD=admin321
|
||||||
|
# MONGO_AUTH_DB=admin
|
||||||
|
MONGO_URI=mongodb://mongo/
|
||||||
|
API_PORT=5000
|
||||||
SOCKET_PORT=8000
|
SOCKET_PORT=8000
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { assetsFloorservice } from "../controller/simulation/assetsFloorservice.ts";
|
import { assetsFloorservice } from "../controller/simulation/assetsFloorservice.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/setasset", assetsFloorservice.setFloorassets);
|
router.post("/setasset", assetsFloorservice.setFloorassets);
|
||||||
router.get("/floorAssets/:organization", assetsFloorservice.getFloorItems);
|
router.get("/floorAssets/:organization", assetsFloorservice.getFloorItems);
|
||||||
// router.get("/pointData/:modelfileID/:organization", assetsFloorservice.gettypePoints);
|
// router.get("/pointData/:modelfileID/:organization", assetsFloorservice.gettypePoints);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { pointService } from "../controller/assets/pointService.ts";
|
import { pointService } from "../controller/assets/pointService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/pointSchema", pointService.addPoints);
|
router.post("/pointSchema", pointService.addPoints);
|
||||||
router.get("/pointData/:modelfileID/:organization", pointService.gettypePoints);
|
router.get("/pointData/:modelfileID/:organization", pointService.gettypePoints);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { floatWidgetService } from "../controller/visualization/floatWidgetService.ts";
|
import { floatWidgetService } from "../controller/visualization/floatWidgetService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/floatwidget/save", floatWidgetService.addfloatWidget);
|
router.post("/floatwidget/save", floatWidgetService.addfloatWidget);
|
||||||
router.get(
|
router.get(
|
||||||
"/floadData/:zoneId/:organization",
|
"/floadData/:zoneId/:organization",
|
||||||
floatWidgetService.getfloatWidget
|
floatWidgetService.getfloatWidget
|
||||||
);
|
);
|
||||||
export default router;
|
export default router;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { templateService } from "../controller/visualization/templateService.ts";
|
import { templateService } from "../controller/visualization/templateService.ts";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
router.post("/template/save", templateService.AddTemplate);
|
router.post("/template/save", templateService.AddTemplate);
|
||||||
router.get("/templateData/:organization", templateService.GetTemplate);
|
router.get("/templateData/:organization", templateService.GetTemplate);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -1,166 +1,166 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
import pointModel from "../../../shared/model/builder/assets/assetPoint-Model.ts";
|
||||||
|
|
||||||
export class pointService {
|
export class pointService {
|
||||||
static async addPoints(req: Request, res: Response): Promise<any> {
|
static async addPoints(req: Request, res: Response): Promise<any> {
|
||||||
const { type, modelfileID, organization } = req.body;
|
const { type, modelfileID, organization } = req.body;
|
||||||
|
|
||||||
if (!["Conveyor", "Vehicle"].includes(type)) {
|
if (!["Conveyor", "Vehicle"].includes(type)) {
|
||||||
return res.status(400).json({ message: "Invalid type requested" });
|
return res.status(400).json({ message: "Invalid type requested" });
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (type === "Conveyor") {
|
if (type === "Conveyor") {
|
||||||
const pointsData = await pointModel(organization).findOne({
|
const pointsData = await pointModel(organization).findOne({
|
||||||
modelfileID: modelfileID,
|
modelfileID: modelfileID,
|
||||||
type: type,
|
type: type,
|
||||||
});
|
});
|
||||||
if (pointsData) return res.send("Data already exists");
|
if (pointsData) return res.send("Data already exists");
|
||||||
const createData = await pointModel(organization).create({
|
const createData = await pointModel(organization).create({
|
||||||
type: "Conveyor",
|
type: "Conveyor",
|
||||||
modelfileID: "672a090f80d91ac979f4d0bd",
|
modelfileID: "672a090f80d91ac979f4d0bd",
|
||||||
points: [
|
points: [
|
||||||
{
|
{
|
||||||
uuid: "point1UUID",
|
uuid: "point1UUID",
|
||||||
position: [0, 0.85, 2.2],
|
position: [0, 0.85, 2.2],
|
||||||
rotation: [0, 0, 0],
|
rotation: [0, 0, 0],
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
uuid: "randomUUID",
|
uuid: "randomUUID",
|
||||||
name: "Action 1",
|
name: "Action 1",
|
||||||
type: "Inherit",
|
type: "Inherit",
|
||||||
material: "Inherit",
|
material: "Inherit",
|
||||||
delay: "Inherit",
|
delay: "Inherit",
|
||||||
spawnInterval: "Inherit",
|
spawnInterval: "Inherit",
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
triggers: [
|
triggers: [
|
||||||
{
|
{
|
||||||
uuid: "randomUUID",
|
uuid: "randomUUID",
|
||||||
name: "trigger 1",
|
name: "trigger 1",
|
||||||
type: "Inherit",
|
type: "Inherit",
|
||||||
bufferTime: 0,
|
bufferTime: 0,
|
||||||
// delay: "Inherit",
|
// delay: "Inherit",
|
||||||
// spawnInterval: "Inherit",
|
// spawnInterval: "Inherit",
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// connections: {
|
// connections: {
|
||||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
// targets: [],
|
// targets: [],
|
||||||
// },
|
// },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uuid: "point2UUID",
|
uuid: "point2UUID",
|
||||||
position: [0, 0.85, 0],
|
position: [0, 0.85, 0],
|
||||||
rotation: [0, 0, 0],
|
rotation: [0, 0, 0],
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
uuid: "randomUUID",
|
uuid: "randomUUID",
|
||||||
name: "Action 1",
|
name: "Action 1",
|
||||||
type: "Inherit",
|
type: "Inherit",
|
||||||
material: "Inherit",
|
material: "Inherit",
|
||||||
delay: "Inherit",
|
delay: "Inherit",
|
||||||
spawnInterval: "Inherit",
|
spawnInterval: "Inherit",
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
triggers: [
|
triggers: [
|
||||||
{
|
{
|
||||||
uuid: "randomUUID",
|
uuid: "randomUUID",
|
||||||
name: "trigger 1",
|
name: "trigger 1",
|
||||||
type: "Inherit",
|
type: "Inherit",
|
||||||
bufferTime: 0,
|
bufferTime: 0,
|
||||||
// delay: "Inherit",
|
// delay: "Inherit",
|
||||||
// spawnInterval: "Inherit",
|
// spawnInterval: "Inherit",
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// connections: {
|
// connections: {
|
||||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
// targets: [],
|
// targets: [],
|
||||||
// },
|
// },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uuid: "point3UUID",
|
uuid: "point3UUID",
|
||||||
position: [0, 0.85, -2.2],
|
position: [0, 0.85, -2.2],
|
||||||
rotation: [0, 0, 0],
|
rotation: [0, 0, 0],
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
uuid: "randomUUID",
|
uuid: "randomUUID",
|
||||||
name: "Action 1",
|
name: "Action 1",
|
||||||
type: "Inherit",
|
type: "Inherit",
|
||||||
material: "Inherit",
|
material: "Inherit",
|
||||||
delay: "Inherit",
|
delay: "Inherit",
|
||||||
spawnInterval: "Inherit",
|
spawnInterval: "Inherit",
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
triggers: [
|
triggers: [
|
||||||
{
|
{
|
||||||
uuid: "randomUUID",
|
uuid: "randomUUID",
|
||||||
name: "trigger 1",
|
name: "trigger 1",
|
||||||
type: "Inherit",
|
type: "Inherit",
|
||||||
bufferTime: 0,
|
bufferTime: 0,
|
||||||
// delay: "Inherit",
|
// delay: "Inherit",
|
||||||
// spawnInterval: "Inherit",
|
// spawnInterval: "Inherit",
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// connections: {
|
// connections: {
|
||||||
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
// source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
// targets: [],
|
// targets: [],
|
||||||
// },
|
// },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// else if (type === "Vehicle") {
|
// else if (type === "Vehicle") {
|
||||||
// // responseData = {
|
// // responseData = {
|
||||||
// // type: "Vehicle",
|
// // type: "Vehicle",
|
||||||
// // points: {
|
// // points: {
|
||||||
// // uuid: "point1UUID",
|
// // uuid: "point1UUID",
|
||||||
// // position: [10, 20, 30],
|
// // position: [10, 20, 30],
|
||||||
// // rotation: [0, 0, 0],
|
// // rotation: [0, 0, 0],
|
||||||
// // actions: [
|
// // actions: [
|
||||||
// // {
|
// // {
|
||||||
// // uuid: "randomUUID",
|
// // uuid: "randomUUID",
|
||||||
// // name: "Action 1",
|
// // name: "Action 1",
|
||||||
// // type: "Inherit",
|
// // type: "Inherit",
|
||||||
// // material: "Inherit",
|
// // material: "Inherit",
|
||||||
// // delay: "Inherit",
|
// // delay: "Inherit",
|
||||||
// // spawnInterval: "Inherit",
|
// // spawnInterval: "Inherit",
|
||||||
// // isUsed: false,
|
// // isUsed: false,
|
||||||
// // },
|
// // },
|
||||||
// // ],
|
// // ],
|
||||||
// // triggers: [],
|
// // triggers: [],
|
||||||
// // connections: {
|
// // connections: {
|
||||||
// // source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
// // source: { pathUUID: "modelUUID", pointUUID: "point1UUID" },
|
||||||
// // targets: [],
|
// // targets: [],
|
||||||
// // },
|
// // },
|
||||||
// // },
|
// // },
|
||||||
// // speed: 1,
|
// // speed: 1,
|
||||||
// // };
|
// // };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
res.status(200).json({ message: "point created successfully" });
|
res.status(200).json({ message: "point created successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Server error", error });
|
res.status(500).json({ message: "Server error", error });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async gettypePoints(req: Request, res: Response): Promise<any> {
|
static async gettypePoints(req: Request, res: Response): Promise<any> {
|
||||||
const { modelfileID, organization } = req.params;
|
const { modelfileID, organization } = req.params;
|
||||||
try {
|
try {
|
||||||
const getData = await pointModel(organization)
|
const getData = await pointModel(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
modelfileID: modelfileID,
|
modelfileID: modelfileID,
|
||||||
})
|
})
|
||||||
.select("-_id -__v -createdAt -updatedAt");
|
.select("-_id -__v -createdAt -updatedAt");
|
||||||
res.send(getData);
|
res.send(getData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Server error", error });
|
res.status(500).json({ message: "Server error", error });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,170 +1,170 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
// import assetModel from "../../../shared/model/assets/flooritems-Model.ts";
|
// import assetModel from "../../../shared/model/assets/flooritems-Model.ts";
|
||||||
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
||||||
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
||||||
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
||||||
|
|
||||||
export class assetsFloorservice {
|
export class assetsFloorservice {
|
||||||
static async setFloorassets(req: Request, res: Response) {
|
static async setFloorassets(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
modeluuid,
|
modeluuid,
|
||||||
modelname,
|
modelname,
|
||||||
speed,
|
speed,
|
||||||
assetPosition,
|
assetPosition,
|
||||||
modelfileID,
|
modelfileID,
|
||||||
assetRotation,
|
assetRotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
organization,
|
organization,
|
||||||
points,
|
points,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
|
||||||
const findvalue = await assetModel(organization).findOne({
|
const findvalue = await assetModel(organization).findOne({
|
||||||
modeluuid: modeluuid,
|
modeluuid: modeluuid,
|
||||||
modelname: modelname,
|
modelname: modelname,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (findvalue) {
|
if (findvalue) {
|
||||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modeluuid: modeluuid, modelname: modelname },
|
{ modeluuid: modeluuid, modelname: modelname },
|
||||||
{
|
{
|
||||||
assetPosition: assetPosition,
|
assetPosition: assetPosition,
|
||||||
assetRotation: assetRotation,
|
assetRotation: assetRotation,
|
||||||
isVisible: isVisible,
|
isVisible: isVisible,
|
||||||
isLocked: isLocked,
|
isLocked: isLocked,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
res.status(201).json(updatevalue);
|
res.status(201).json(updatevalue);
|
||||||
} else {
|
} else {
|
||||||
let pointRefs = [];
|
let pointRefs = [];
|
||||||
|
|
||||||
for (const point of points) {
|
for (const point of points) {
|
||||||
let actionRefs = [];
|
let actionRefs = [];
|
||||||
let triggerRefs = [];
|
let triggerRefs = [];
|
||||||
|
|
||||||
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,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
uuid: action.uuid,
|
uuid: action.uuid,
|
||||||
name: action.name,
|
name: action.name,
|
||||||
type: action.type,
|
type: action.type,
|
||||||
material: action.material,
|
material: action.material,
|
||||||
delay: action.delay,
|
delay: action.delay,
|
||||||
spawn_Interval: action.spawn_Interval,
|
spawn_Interval: action.spawn_Interval,
|
||||||
// eventData: [action],
|
// eventData: [action],
|
||||||
});
|
});
|
||||||
await actionDoc.save();
|
await actionDoc.save();
|
||||||
actionRefs.push(actionDoc._id);
|
actionRefs.push(actionDoc._id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
uuid: trigger.uuid,
|
uuid: trigger.uuid,
|
||||||
name: trigger.name,
|
name: trigger.name,
|
||||||
type: trigger.type,
|
type: trigger.type,
|
||||||
bufferTime: trigger.bufferTime,
|
bufferTime: trigger.bufferTime,
|
||||||
// triggerData: [trigger],
|
// triggerData: [trigger],
|
||||||
});
|
});
|
||||||
await triggerDoc.save();
|
await triggerDoc.save();
|
||||||
triggerRefs.push(triggerDoc._id);
|
triggerRefs.push(triggerDoc._id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pointRefs.push({
|
pointRefs.push({
|
||||||
uuid: point.uuid,
|
uuid: point.uuid,
|
||||||
position: point.position,
|
position: point.position,
|
||||||
rotation: point.rotation,
|
rotation: point.rotation,
|
||||||
actions: actionRefs,
|
actions: actionRefs,
|
||||||
triggers: triggerRefs,
|
triggers: triggerRefs,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetDoc = await assetModel(organization).create({
|
const assetDoc = await assetModel(organization).create({
|
||||||
modeluuid,
|
modeluuid,
|
||||||
speed,
|
speed,
|
||||||
modelname,
|
modelname,
|
||||||
assetPosition,
|
assetPosition,
|
||||||
modelfileID,
|
modelfileID,
|
||||||
assetRotation,
|
assetRotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
points: pointRefs,
|
points: pointRefs,
|
||||||
});
|
});
|
||||||
|
|
||||||
await assetDoc.save();
|
await assetDoc.save();
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
message: "Model stored successfully",
|
message: "Model stored successfully",
|
||||||
modelId: assetDoc._id,
|
modelId: assetDoc._id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error creating flooritems:", error);
|
console.error("Error creating flooritems:", error);
|
||||||
res.status(500).json({ message: "Failed to create flooritems" });
|
res.status(500).json({ message: "Failed to create flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async getFloorItems(req: Request, res: Response) {
|
static async getFloorItems(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
const findValue = await assetModel(organization)
|
const findValue = await assetModel(organization)
|
||||||
.find()
|
.find()
|
||||||
.select("-_id")
|
.select("-_id")
|
||||||
.populate({
|
.populate({
|
||||||
path: "points",
|
path: "points",
|
||||||
// model: assetModel(organization),
|
// model: assetModel(organization),
|
||||||
select: "-_id",
|
select: "-_id",
|
||||||
})
|
})
|
||||||
.populate({
|
.populate({
|
||||||
path: "points.actions",
|
path: "points.actions",
|
||||||
model: actionModel(organization),
|
model: actionModel(organization),
|
||||||
// select: "-_id",
|
// select: "-_id",
|
||||||
// populate: {
|
// populate: {
|
||||||
// path: "eventData",
|
// path: "eventData",
|
||||||
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
||||||
// },
|
// },
|
||||||
})
|
})
|
||||||
.populate({
|
.populate({
|
||||||
path: "points.triggers",
|
path: "points.triggers",
|
||||||
model: triggerModel(organization),
|
model: triggerModel(organization),
|
||||||
// select: "-_id",
|
// select: "-_id",
|
||||||
// populate: {
|
// populate: {
|
||||||
// path: "triggerData",
|
// path: "triggerData",
|
||||||
select: "-__v -_id -isArchive -pointsUUID -createdAt -updatedAt",
|
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");
|
||||||
} else {
|
} else {
|
||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get flooritems:", error);
|
console.error("Error get flooritems:", error);
|
||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async deleteFloorItems(req: Request, res: Response) {
|
static async deleteFloorItems(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { modeluuid, modelname, organization } = req.body;
|
const { modeluuid, modelname, organization } = req.body;
|
||||||
|
|
||||||
const findValue = await assetModel(organization).findOneAndDelete({
|
const findValue = await assetModel(organization).findOneAndDelete({
|
||||||
modeluuid: modeluuid,
|
modeluuid: modeluuid,
|
||||||
modelname: modelname,
|
modelname: modelname,
|
||||||
});
|
});
|
||||||
if (!findValue) {
|
if (!findValue) {
|
||||||
res.status(200).json("user not found");
|
res.status(200).json("user not found");
|
||||||
} else {
|
} else {
|
||||||
res.status(201).json(findValue);
|
res.status(201).json(findValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get flooritems:", error);
|
console.error("Error get flooritems:", error);
|
||||||
res.status(500).json({ error: "Failed to get flooritems" });
|
res.status(500).json({ error: "Failed to get flooritems" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,201 +1,201 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import floatWidgetModel from "../../../shared/model/vizualization/3dwidget.ts";
|
import floatWidgetModel from "../../../shared/model/vizualization/3dwidget.ts";
|
||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
export class floatWidgetService {
|
export class floatWidgetService {
|
||||||
static async addfloatWidget(req: Request, res: Response): Promise<any> {
|
static async addfloatWidget(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization, widget, zoneId } = req.body;
|
const { organization, widget, zoneId } = req.body;
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingZone)
|
if (!existingZone)
|
||||||
return res
|
return res
|
||||||
.status(404)
|
.status(404)
|
||||||
.json({ message: "Zone not found for the zoneId" });
|
.json({ message: "Zone not found for the zoneId" });
|
||||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) {
|
if (existingFloatWidget) {
|
||||||
const updateFloatWidget = await floatWidgetModel(
|
const updateFloatWidget = await floatWidgetModel(
|
||||||
organization
|
organization
|
||||||
).findOneAndUpdate(
|
).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
// Data: {
|
// Data: {
|
||||||
// // measurements: widget.Data.measurements || {},
|
// // measurements: widget.Data.measurements || {},
|
||||||
// duration: widget.Data.duration || "1h",
|
// duration: widget.Data.duration || "1h",
|
||||||
// },
|
// },
|
||||||
position: widget.position,
|
position: widget.position,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
upsert: true,
|
upsert: true,
|
||||||
new: true,
|
new: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return res.status(200).json({ message: "Widget updated successfully" });
|
return res.status(200).json({ message: "Widget updated successfully" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const newFloadWidget = await floatWidgetModel(organization).create({
|
const newFloadWidget = await floatWidgetModel(organization).create({
|
||||||
className: widget.className,
|
className: widget.className,
|
||||||
header: widget.header,
|
header: widget.header,
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
position: widget.position,
|
position: widget.position,
|
||||||
per: widget.per,
|
per: widget.per,
|
||||||
value: widget.value,
|
value: widget.value,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
if (newFloadWidget) {
|
if (newFloadWidget) {
|
||||||
return res
|
return res
|
||||||
.status(201)
|
.status(201)
|
||||||
.json({ message: "FloatWidget created successfully" });
|
.json({ message: "FloatWidget created successfully" });
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async getfloatWidget(req: Request, res: Response): Promise<any> {
|
static async getfloatWidget(req: Request, res: Response): Promise<any> {
|
||||||
const { organization, zoneId } = req.params;
|
const { organization, zoneId } = req.params;
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingZone)
|
if (!existingZone)
|
||||||
return res.status(404).json({ message: "Zone not found" });
|
return res.status(404).json({ message: "Zone not found" });
|
||||||
const widgetData = await floatWidgetModel(organization)
|
const widgetData = await floatWidgetModel(organization)
|
||||||
.find({
|
.find({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
.select("-_id -zoneId -createdAt -updatedAt -__v");
|
||||||
if (!widgetData || widgetData.length === 0) {
|
if (!widgetData || widgetData.length === 0) {
|
||||||
return res.send([]);
|
return res.send([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const formattedWidgets = widgetData.map((widget) => ({
|
const formattedWidgets = widgetData.map((widget) => ({
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget.Data?.measurements || {},
|
measurements: widget.Data?.measurements || {},
|
||||||
duration: widget.Data?.duration || "1h",
|
duration: widget.Data?.duration || "1h",
|
||||||
},
|
},
|
||||||
className: widget.className,
|
className: widget.className,
|
||||||
header: widget.header,
|
header: widget.header,
|
||||||
id: widget.floatWidgetID,
|
id: widget.floatWidgetID,
|
||||||
position: widget.position,
|
position: widget.position,
|
||||||
per: widget.per,
|
per: widget.per,
|
||||||
value: widget.value,
|
value: widget.value,
|
||||||
}));
|
}));
|
||||||
return res.status(200).json(formattedWidgets);
|
return res.status(200).json(formattedWidgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static async deleteWidget(req: Request, res: Response): Promise<any> {
|
// static async deleteWidget(req: Request, res: Response): Promise<any> {
|
||||||
// try {
|
// try {
|
||||||
// const { widgetID, organization } = req.body;
|
// const { widgetID, organization } = req.body;
|
||||||
// const findWidget = await widgetSchema(organization).findOne({
|
// const findWidget = await widgetSchema(organization).findOne({
|
||||||
// widgetID: widgetID,
|
// widgetID: widgetID,
|
||||||
// isArchive: false,
|
// isArchive: false,
|
||||||
// });
|
// });
|
||||||
// if (!findWidget)
|
// if (!findWidget)
|
||||||
// return res.status(409).json({ message: "Widget not found" });
|
// return res.status(409).json({ message: "Widget not found" });
|
||||||
// const widgetData = await widgetSchema(organization).updateOne(
|
// const widgetData = await widgetSchema(organization).updateOne(
|
||||||
// { _id: findWidget._id, isArchive: false },
|
// { _id: findWidget._id, isArchive: false },
|
||||||
// { $set: { isArchive: true } }
|
// { $set: { isArchive: true } }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// 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).find({
|
// const widgets = await widgetSchema(organization).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)) {
|
||||||
// const index1 = panelData.widgets.indexOf(findWidget._id);
|
// const index1 = panelData.widgets.indexOf(findWidget._id);
|
||||||
// panelData.widgets.splice(index1, 1);
|
// panelData.widgets.splice(index1, 1);
|
||||||
// }
|
// }
|
||||||
// await panelData.save();
|
// await panelData.save();
|
||||||
// }
|
// }
|
||||||
// return res.status(200).json({ message: "Widget deleted successfully" });
|
// return res.status(200).json({ message: "Widget deleted successfully" });
|
||||||
// } catch (error: any) {
|
// } catch (error: any) {
|
||||||
// return res.status(500).send(error.message);
|
// return res.status(500).send(error.message);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static async updatewidget(req: Request, res: Response): Promise<any> {
|
// static async updatewidget(req: Request, res: Response): Promise<any> {
|
||||||
// try {
|
// try {
|
||||||
// const { organization, widgetID, values } = req.body;
|
// const { organization, widgetID, values } = req.body;
|
||||||
// const findwidget = await widgetSchema(organization).findOne({
|
// const findwidget = await widgetSchema(organization).findOne({
|
||||||
// widgetID: widgetID,
|
// widgetID: widgetID,
|
||||||
// isArchive: false,
|
// isArchive: false,
|
||||||
// });
|
// });
|
||||||
// if (!findwidget)
|
// if (!findwidget)
|
||||||
// return res.status(404).send({ message: "Data not found" });
|
// return res.status(404).send({ message: "Data not found" });
|
||||||
// const updateData = {
|
// const updateData = {
|
||||||
// widgetName: values.widgetName,
|
// widgetName: values.widgetName,
|
||||||
// widgetSide: values.widgetSide, // Fixed typo from widgetside to widgetSide
|
// widgetSide: values.widgetSide, // Fixed typo from widgetside to widgetSide
|
||||||
// elementType: values.type,
|
// elementType: values.type,
|
||||||
// Data: {
|
// Data: {
|
||||||
// measurement: values.Data.measurement,
|
// measurement: values.Data.measurement,
|
||||||
// duration: values.Data.duration,
|
// duration: values.Data.duration,
|
||||||
// },
|
// },
|
||||||
// elementColor: values.color,
|
// elementColor: values.color,
|
||||||
// fontFamily: values.fontFamily,
|
// fontFamily: values.fontFamily,
|
||||||
// fontStyle: values.fontStyle,
|
// fontStyle: values.fontStyle,
|
||||||
// fontWeight: values.fontWeight,
|
// fontWeight: values.fontWeight,
|
||||||
// isArchive: false,
|
// isArchive: false,
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const changedWidget = await widgetSchema(organization).findOneAndUpdate(
|
// const changedWidget = await widgetSchema(organization).findOneAndUpdate(
|
||||||
// { widgetID: widgetID, isArchive: false },
|
// { widgetID: widgetID, isArchive: false },
|
||||||
// updateData,
|
// updateData,
|
||||||
// {
|
// {
|
||||||
// new: true,
|
// new: true,
|
||||||
// upsert: true,
|
// upsert: true,
|
||||||
// setDefaultsOnInsert: true,
|
// setDefaultsOnInsert: true,
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// return res.status(200).json({
|
// return res.status(200).json({
|
||||||
// message: "Widget updated successfully",
|
// message: "Widget updated successfully",
|
||||||
// });
|
// });
|
||||||
// } catch (error: any) {
|
// } catch (error: any) {
|
||||||
// return res.status(500).send(error.message);
|
// return res.status(500).send(error.message);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static async getDatafromWidget(req: Request, res: Response): Promise<any> {
|
// static async getDatafromWidget(req: Request, res: Response): Promise<any> {
|
||||||
// const { organization, widgetID } = req.params;
|
// const { organization, widgetID } = req.params;
|
||||||
// try {
|
// try {
|
||||||
// const existingWidget = await widgetSchema(organization)
|
// const existingWidget = await widgetSchema(organization)
|
||||||
// .findOne({
|
// .findOne({
|
||||||
// widgetID: 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 || "1h",
|
// duration: existingWidget.Data.duration || "1h",
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// if (existingWidget) return res.status(200).json({ Data: Datastructure });
|
// if (existingWidget) return res.status(200).json({ Data: Datastructure });
|
||||||
// } catch (error: any) {
|
// } catch (error: any) {
|
||||||
// return res.status(500).send(error.message);
|
// return res.status(500).send(error.message);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,43 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
||||||
|
|
||||||
export class templateService {
|
export class templateService {
|
||||||
static async AddTemplate(req: Request, res: Response): Promise<any> {
|
static async AddTemplate(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
console.log("req.body: ", req.body);
|
console.log("req.body: ", req.body);
|
||||||
const { organization, templateID, name, panelOrder, widgets, snapshot } =
|
const { organization, templateID, name, panelOrder, widgets, snapshot } =
|
||||||
req.body;
|
req.body;
|
||||||
const existingTemplate = await templateModel(organization).findOne({
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
templateID: templateID,
|
templateID: templateID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (existingTemplate)
|
if (existingTemplate)
|
||||||
return res.status(409).json({ message: "TemplateID alreay exists" });
|
return res.status(409).json({ message: "TemplateID alreay exists" });
|
||||||
const newTemplate = await templateModel(organization).create({
|
const newTemplate = await templateModel(organization).create({
|
||||||
templateID,
|
templateID,
|
||||||
name,
|
name,
|
||||||
panelOrder,
|
panelOrder,
|
||||||
widgets,
|
widgets,
|
||||||
snapshot,
|
snapshot,
|
||||||
});
|
});
|
||||||
if (newTemplate)
|
if (newTemplate)
|
||||||
return res.status(200).json({ message: "Template saved successfully" });
|
return res.status(200).json({ message: "Template saved successfully" });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async GetTemplate(req: Request, res: Response): Promise<any> {
|
static async GetTemplate(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
const existingTemplate = await templateModel(organization)
|
const existingTemplate = await templateModel(organization)
|
||||||
.find({
|
.find({
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("-_id -__v -isArchive -createdAt -updatedAt");
|
.select("-_id -__v -isArchive -createdAt -updatedAt");
|
||||||
if (!existingTemplate) return res.status(409).send([]);
|
if (!existingTemplate) return res.status(409).send([]);
|
||||||
return res.status(200).json(existingTemplate);
|
return res.status(200).json(existingTemplate);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return res.status(500).send(error.message);
|
return res.status(500).send(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,107 +1,107 @@
|
|||||||
import mongoose, { Schema, Document } from "mongoose";
|
import mongoose, { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../../connect/mongoose.ts";
|
import MainModel from "../../../connect/mongoose.ts";
|
||||||
|
|
||||||
interface IAction {
|
interface IAction {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
material: string;
|
material: string;
|
||||||
delay: string;
|
delay: string;
|
||||||
spawnInterval: string;
|
spawnInterval: string;
|
||||||
isUsed: boolean;
|
isUsed: boolean;
|
||||||
hitCount: number;
|
hitCount: number;
|
||||||
start: string;
|
start: string;
|
||||||
end: string;
|
end: string;
|
||||||
buffer: number;
|
buffer: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ITriggers {
|
interface ITriggers {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
isUsed: boolean;
|
isUsed: boolean;
|
||||||
bufferTime: number;
|
bufferTime: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IConnection {
|
interface IConnection {
|
||||||
source: { pathUUID: string; pointUUID: string };
|
source: { pathUUID: string; pointUUID: string };
|
||||||
targets: { 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: ITriggers[];
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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] },
|
position: { type: [Number] },
|
||||||
rotation: { type: [Number] },
|
rotation: { type: [Number] },
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
uuid: { type: String, default: "" },
|
uuid: { type: String, default: "" },
|
||||||
name: { type: String },
|
name: { type: String },
|
||||||
type: { type: String },
|
type: { type: String },
|
||||||
material: { type: String },
|
material: { type: String },
|
||||||
delay: { type: String },
|
delay: { type: String },
|
||||||
spawnInterval: { type: String },
|
spawnInterval: { type: String },
|
||||||
isUsed: { type: Boolean },
|
isUsed: { type: Boolean },
|
||||||
hitCount: { type: String },
|
hitCount: { type: String },
|
||||||
start: { type: String },
|
start: { type: String },
|
||||||
end: { type: String },
|
end: { type: String },
|
||||||
buffer: { type: String },
|
buffer: { type: String },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
triggers: [
|
triggers: [
|
||||||
{
|
{
|
||||||
uuid: { type: String, default: "" },
|
uuid: { type: String, default: "" },
|
||||||
name: { type: String },
|
name: { type: String },
|
||||||
type: { type: String },
|
type: { type: String },
|
||||||
bufferTime: { type: Number },
|
bufferTime: { type: Number },
|
||||||
isUsed: { type: Boolean },
|
isUsed: { type: Boolean },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
connections: {
|
connections: {
|
||||||
source: {
|
source: {
|
||||||
pathUUID: { type: String },
|
pathUUID: { type: String },
|
||||||
pointUUID: { type: String },
|
pointUUID: { type: String },
|
||||||
},
|
},
|
||||||
targets: [
|
targets: [
|
||||||
{
|
{
|
||||||
pathUUID: { type: String },
|
pathUUID: { type: String },
|
||||||
pointUUID: { type: String },
|
pointUUID: { type: String },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const BaseSchema = new Schema<IBaseModel>(
|
const BaseSchema = new Schema<IBaseModel>(
|
||||||
{
|
{
|
||||||
modelfileID: { type: String },
|
modelfileID: { type: String },
|
||||||
type: { type: String, enum: ["Conveyor", "Vehicle"] },
|
type: { type: String, enum: ["Conveyor", "Vehicle"] },
|
||||||
points: {
|
points: {
|
||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ discriminatorKey: "type", timestamps: true }
|
{ discriminatorKey: "type", timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const pointModel = (db: string) => {
|
const pointModel = (db: string) => {
|
||||||
return MainModel(db, "Points", BaseSchema, "Points");
|
return MainModel(db, "Points", BaseSchema, "Points");
|
||||||
};
|
};
|
||||||
export default pointModel;
|
export default pointModel;
|
||||||
|
|
||||||
// const pointModel = mongoose.model<IBaseModel>("Points", BaseSchema, "Points");
|
// const pointModel = mongoose.model<IBaseModel>("Points", BaseSchema, "Points");
|
||||||
// export default pointModel;
|
// export default pointModel;
|
||||||
|
|||||||
@@ -1,44 +1,44 @@
|
|||||||
import mongoose, { Schema, Document, model } from "mongoose";
|
import mongoose, { Schema, Document, model } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
export interface floatingWidget extends Document {
|
export interface floatingWidget extends Document {
|
||||||
className: string;
|
className: string;
|
||||||
header: string;
|
header: string;
|
||||||
floatWidgetID: string;
|
floatWidgetID: string;
|
||||||
position: {};
|
position: {};
|
||||||
per: string;
|
per: string;
|
||||||
value: string;
|
value: string;
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
zoneId: string;
|
zoneId: string;
|
||||||
Data: {
|
Data: {
|
||||||
measurements: {};
|
measurements: {};
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const floatingWidgetSchema: Schema = new Schema(
|
const floatingWidgetSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
className: { type: String },
|
className: { type: String },
|
||||||
header: { type: String },
|
header: { type: String },
|
||||||
floatWidgetID: { type: String },
|
floatWidgetID: { type: String },
|
||||||
position: { type: Object },
|
position: { type: Object },
|
||||||
per: { type: String },
|
per: { type: String },
|
||||||
value: { type: String },
|
value: { type: String },
|
||||||
zoneId: { type: String },
|
zoneId: { type: String },
|
||||||
Data: {
|
Data: {
|
||||||
measurements: { type: Object, default: {} },
|
measurements: { type: Object, default: {} },
|
||||||
duration: { type: String, default: "1h" },
|
duration: { type: String, default: "1h" },
|
||||||
},
|
},
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const floatWidgetModel = (db: any) => {
|
const floatWidgetModel = (db: any) => {
|
||||||
return MainModel(
|
return MainModel(
|
||||||
db,
|
db,
|
||||||
"FloatingWidget",
|
"FloatingWidget",
|
||||||
floatingWidgetSchema,
|
floatingWidgetSchema,
|
||||||
"FloatingWidget"
|
"FloatingWidget"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default floatWidgetModel;
|
export default floatWidgetModel;
|
||||||
|
|||||||
@@ -59,8 +59,9 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
export const deletePanel = async (data: any) => {
|
export const panelDelete = async (data: any) => {
|
||||||
const { organization, panelID, zoneId } = data;
|
const { organization, panelName, zoneId } = data;
|
||||||
|
console.log('data: ', data);
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -71,17 +72,17 @@ export const deletePanel = async (data: any) => {
|
|||||||
|
|
||||||
const existingPanel = await panelSchema(organization).findOne({
|
const existingPanel = await panelSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
_id: panelID,
|
panelName: panelName,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingPanel)
|
if (!existingPanel)
|
||||||
return { success: false, message: 'Panel Already Deleted',organization: organization}
|
return { success: false, message: 'Panel Already Deleted',organization: organization}
|
||||||
const updatePanel = await panelSchema(organization).updateOne(
|
const updatePanel = await panelSchema(organization).updateOne(
|
||||||
{ _id: panelID, isArchive: false },
|
{ _id: existingPanel._id, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
const existingWidgets = await widgetSchema(organization).find({
|
const existingWidgets = await widgetSchema(organization).find({
|
||||||
panelID: panelID,
|
panelID:existingPanel._id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -90,14 +91,13 @@ export const deletePanel = async (data: any) => {
|
|||||||
await widgetData.save();
|
await widgetData.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
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) {
|
} catch (error) {
|
||||||
return { success: false, message: 'Panel not found', error,organization: organization } }
|
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",
|
panelUpdateRespones:"viz-panel:response:updates",
|
||||||
deletePanel:"v2:viz-panel:delete",
|
deletePanel:"v2:viz-panel:delete",
|
||||||
PanelDeleteRespones:"viz-panel:response: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 { deleteLineItems, deleteLinPoiteItems, updateLineItems ,createLineItems, deleteLayer} from '../services/lines/line-Controller.ts';
|
||||||
import { activeUserOffline, activeUsers } from '../services/users/user-controller.ts';
|
import { activeUserOffline, activeUsers } from '../services/users/user-controller.ts';
|
||||||
import { deleteZone, setZone } from '../services/lines/zone-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;
|
let result;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVENTS.addPanel:
|
case EVENTS.addPanel:{
|
||||||
result = await addPanel(data);
|
result = await addPanel(data);
|
||||||
console.log('result: ', result);
|
console.log('result: ', result);
|
||||||
|
|
||||||
@@ -443,7 +444,7 @@ const panelHandleEvent=async(event: string, socket: Socket, data: any,namespace:
|
|||||||
const organization=result?.organization
|
const organization=result?.organization
|
||||||
console.log('organization: ', organization);
|
console.log('organization: ', organization);
|
||||||
// const emitTarget = notifySender ? socket.in(organization) : socket.to(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);
|
// console.log('emitTarget: ', emitTarget);
|
||||||
|
|
||||||
socket.to(organization).emit(responseEvent, {
|
socket.to(organization).emit(responseEvent, {
|
||||||
@@ -455,7 +456,34 @@ const panelHandleEvent=async(event: string, socket: Socket, data: any,namespace:
|
|||||||
organization: result.organization,
|
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:
|
default:
|
||||||
return;
|
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) => {
|
export const initSocketServer = (httpServer: any) => {
|
||||||
const io = new Server(httpServer, {
|
const io = new Server(httpServer, {
|
||||||
cors: {
|
cors: {
|
||||||
@@ -497,40 +596,42 @@ userStatus(EVENTS.connection, socket, socket.handshake.auth,io);
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 🔹 Create different namespaces
|
// 🔹 Create different namespaces
|
||||||
const namespaces = {
|
const namespaces = {
|
||||||
camera: io.of("/camera"),
|
camera: io.of("/camera"),
|
||||||
environment: io.of("/environment"),
|
environment: io.of("/environment"),
|
||||||
floorItems: io.of("/floorItems"),
|
floorItems: io.of("/floorItems"),
|
||||||
wallItems: io.of("/wallItems"),
|
wallItems: io.of("/wallItems"),
|
||||||
line: io.of("/line"),
|
line: io.of("/line"),
|
||||||
zone: io.of("/zone"),
|
zone: io.of("/zone"),
|
||||||
panel:io.of('/panel')
|
visualization: io.of('/visualization'),
|
||||||
};
|
// widget:io.of('/widget')
|
||||||
|
};
|
||||||
// 🔹 Function to handle connections in a namespace
|
// 🔹 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) => {
|
namespace.on("connection", (socket: Socket) => {
|
||||||
console.log(`✅ Client connected to ${namespaceName}: ${socket.id}`);
|
console.log(`✅ Client connected to ${namespaceName}: ${socket.id}`);
|
||||||
|
|
||||||
// Extract organization from query parameters
|
// Extract organization from query parameters
|
||||||
const organization = socket.handshake.query.organization as string;
|
const organization = socket.handshake.query.organization as string;
|
||||||
console.log(`🔍 Received organization: ${organization}`);
|
// console.log(`🔍 Received organization: ${organization}`);
|
||||||
|
|
||||||
if (organization) {
|
if (organization) {
|
||||||
socket.join(organization);
|
socket.join(organization);
|
||||||
console.log(`🔹 Socket ${socket.id} joined room: ${organization}`);
|
// console.log(`🔹 Socket ${socket.id} joined room: ${organization}`);
|
||||||
|
|
||||||
// Debug: Check rooms
|
// Debug: Check rooms
|
||||||
console.log(`🛠️ Current rooms for ${socket.id}:`, socket.rooms);
|
// console.log(`🛠️ Current rooms for ${socket.id}:`, socket.rooms);
|
||||||
} else {
|
} else {
|
||||||
console.warn(`⚠️ Warning: Socket ${socket.id} did not provide an organization`);
|
console.warn(`⚠️ Warning: Socket ${socket.id} did not provide an organization`);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.onAny((event: string, data: any) => {
|
socket.onAny((event: string, data: any) => {
|
||||||
console.log(`📩 Event received: ${event}, Data: ${JSON.stringify(data)}`);
|
// console.log(`📩 Event received: ${event}, Data: ${JSON.stringify(data)}`);
|
||||||
eventHandler(event, socket, data, namespace); // Pass `namespace` instead of `io`
|
eventHandlers.forEach(handler => handler(event, socket, data, namespace));
|
||||||
|
// eventHandler(event, socket, data, namespace); // Pass `namespace` instead of `io`
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("disconnect", (reason: string) => {
|
socket.on("disconnect", (reason: string) => {
|
||||||
console.log(`❌ Client disconnected from ${namespaceName}: ${socket.id}, Reason: ${reason}`);
|
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("wallItems", namespaces.wallItems, wallItemsHandleEvent);
|
||||||
handleNamespace("line", namespaces.line, lineHandleEvent);
|
handleNamespace("line", namespaces.line, lineHandleEvent);
|
||||||
handleNamespace("zone", namespaces.zone, zoneHandleEvent);
|
handleNamespace("zone", namespaces.zone, zoneHandleEvent);
|
||||||
handleNamespace("panel", namespaces.panel, panelHandleEvent);
|
// handleNamespace("visualization", namespaces.panel, panelHandleEvent);
|
||||||
// 📌 **Create a separate namespace for panels**
|
// handleNamespace("widget", namespaces.visualization, widgetHandleEvent);
|
||||||
// const panelNamespace = io.of('/panel');
|
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;
|
return io;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user