Zone rename, model rename, clear panel and locked panel API and socket completed

This commit is contained in:
2025-04-09 18:22:12 +05:30
parent c4d8fc14c8
commit 40eb9d8fb9
12 changed files with 450 additions and 124 deletions

View File

@@ -136,5 +136,7 @@ router.post("/panel/save", panelService.AddPanel);
* description: Server error
*/
router.patch("/panel/delete", panelService.deletePanel);
router.patch("/clearpanel", panelService.clearPanel);
// router.get("/zone/:sceneID", Zoneservice.allZones);
export default router;

View File

@@ -538,4 +538,5 @@ router.get("/A_zone/:zoneId/:organization", Zoneservice.ZoneData);
*/
router.patch("/zone/:zoneId", Zoneservice.deleteAZone); //delete Zone
// router.get("/zone/:sceneID", Zoneservice.allZones);
router.patch("/zones/lockedPanels", Zoneservice.lockedPanel);
export default router;

View File

@@ -1,68 +1,91 @@
import { Request, Response } from "express";
import floorItemsModel from "../../../shared/model/assets/flooritems-Model.ts";
export class floorItems {
static async setFloorItems(req: Request, res: Response) {
try {
const { modeluuid, modelname, position, modelfileID,rotation,isLocked,isVisible,organization } = req.body
static async setFloorItems(req: Request, res: Response) {
try {
const {
modeluuid,
modelname,
position,
modelfileID,
rotation,
isLocked,
isVisible,
organization,
} = req.body;
const findvalue = await floorItemsModel(organization).findOne({ modeluuid: modeluuid,modelname:modelname })
if (findvalue) {
const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
{ modeluuid: modeluuid,modelname:modelname }, { position: position, rotation: rotation,isVisible:isVisible,isLocked:isLocked }, { new: true });
res.status(201).json(updatevalue);
const findvalue = await floorItemsModel(organization).findOne({
modeluuid: modeluuid,
modelname: modelname,
});
} else {
if (findvalue) {
const updatevalue = await floorItemsModel(
organization
).findOneAndUpdate(
{ modeluuid: modeluuid, modelname: modelname },
{
position: position,
rotation: rotation,
isVisible: isVisible,
isLocked: isLocked,
},
{ new: true }
);
res.status(201).json(updatevalue);
} else {
const newValue = await floorItemsModel(organization).create({
modeluuid,
modelfileID,
modelname,
position,
rotation,
isLocked,
isVisible,
});
const newValue = await floorItemsModel(organization).create({ modeluuid, modelfileID,modelname, position, rotation,isLocked,isVisible, });
res.status(201).json(newValue);
}
res.status(201).json(newValue);
}
// Send response with the created document
} catch (error) {
console.error('Error creating flooritems:', error);
res.status(500).json({ message: "Failed to create flooritems" });
}
// Send response with the created document
} 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;
// console.log('req.params: ', req.params);
}
static async getFloorItems(req: Request, res: Response) {
try {
const { organization } = req.params;
// console.log('req.params: ', req.params);
const findValue = await floorItemsModel(organization).find()
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" });
}
const findValue = await floorItemsModel(organization).find();
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 floorItemsModel(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname})
if (!findValue) {
res.status(200).json("user not found");
} else {
}
static async deleteFloorItems(req: Request, res: Response) {
try {
const { modeluuid, modelname, organization } = req.body;
res.status(201).json(findValue);
}
} catch (error) {
console.error('Error get flooritems:', error);
res.status(500).json({ error: "Failed to get flooritems" });
}
const findValue = await floorItemsModel(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" });
}
}
}

View File

@@ -30,6 +30,7 @@ interface IPointConveyor extends IPointBase {
}
interface IPointVehicle extends IPointBase {
rotation: number[];
actions: {
uuid: string;
name: string;
@@ -51,33 +52,34 @@ interface IPointArmbot extends IPointBase {
uuid: string;
name: string;
speed: number;
processes: { triggerId: string; startPoint: string; endPoint: string }[]
processes: { triggerId: string; startPoint: string; endPoint: string }[];
};
triggers: { uuid: string; name: string; type: string };
connections: {
source: { modelUUID: string; pointUUID: string };
targets: { modelUUID: string; pointUUID: string }[]
targets: { modelUUID: string; pointUUID: string }[];
};
}
interface IPointStaticMachine extends IPointBase{
interface IPointStaticMachine extends IPointBase {
rotation: number[];
actions: {
uuid: string;
name: string;
buffer: number | string;
material: string;
},
};
triggers: { uuid: string; name: string; type: string };
connections: {
source: { modelUUID: string; pointUUID: string };
targets: { modelUUID: string; pointUUID: string }[] };
connections: {
source: { modelUUID: string; pointUUID: string };
targets: { modelUUID: string; pointUUID: string }[];
};
}
export class pointService {
static async addPoints(req: Request, res: Response): Promise<any> {
const { type, modelfileID, organization } = req.body;
// Validate type
if (!["Conveyor", "Vehicle","ArmBot","StaticMachine"].includes(type)) {
if (!["Conveyor", "Vehicle", "ArmBot", "StaticMachine"].includes(type)) {
return res.status(400).json({ message: "Invalid type requested" });
}
@@ -189,8 +191,7 @@ export class pointService {
...baseData,
points: conveyorPoints,
});
}
if (type === "Vehicle") {
} else if (type === "Vehicle") {
console.log("vehcile data");
const baseData = {
modelfileID: "67e3da19c2e8f37134526e6a",
@@ -198,6 +199,7 @@ export class pointService {
};
const vehiclePoint: IPointVehicle = {
uuid: "point1UUID",
rotation: [0, 0, 0],
position: [0, 1.3, 0],
actions: {
uuid: "randomUUID",
@@ -214,11 +216,6 @@ export class pointService {
},
speed: 2,
};
if ("rotation" in vehiclePoint) {
return res
.status(400)
.json({ error: "Rotation not allowed for Vehicle points" });
}
if ("triggers" in vehiclePoint) {
return res
.status(400)
@@ -229,8 +226,7 @@ export class pointService {
...baseData,
points: vehiclePoint,
});
}
if (type === "ArmBot") {
} else if (type === "ArmBot") {
console.log("ArmBot data");
const baseData = {
modelfileID: "67eb7904c2e8f37134527eae",
@@ -239,27 +235,35 @@ export class pointService {
const ArmBotPoint: IPointArmbot = {
uuid: "point1UUID",
position: [0, 2.75, -0.5],
rotation:[0,0,0],
rotation: [0, 0, 0],
actions: {
uuid: "randomUUID",
name: "Action 1",
speed:1,
processes:[{triggerId:"triggerId",startPoint:"startPoint",endPoint:"endPoint"}]
speed: 1,
processes: [
{
triggerId: "triggerId",
startPoint: "startPoint",
endPoint: "endPoint",
},
],
},
triggers: {
uuid: "randomUUID",
name: "trigger 1",
type: "OnComplete",
},
triggers: { uuid: "randomUUID", name: "trigger 1", type: "OnComplete" },
connections: {
source: { modelUUID: "modelUUID", pointUUID: "point1UUID" },
targets: [{ modelUUID: "modelUUID", pointUUID: "point1UUID" }],
},
};
await pointModel(organization).create({
...baseData,
points: ArmBotPoint,
});
}
if (type === "StaticMachine") {
} else if (type === "StaticMachine") {
console.log("StaticMachine data");
const baseData = {
modelfileID: "67e3db5ac2e8f37134526f40",
@@ -268,26 +272,31 @@ export class pointService {
const StaticMachinePoint: IPointStaticMachine = {
uuid: "point1UUID",
position: [0, 1.5, -0.5],
rotation:[0,0,0],
rotation: [0, 0, 0],
actions: {
uuid: "randomUUID",
name: "Action 1",
buffer: 0, material: "Inherit",
buffer: 0,
material: "Inherit",
},
triggers: {
uuid: "randomUUID",
name: "trigger 1",
type: "OnComplete",
},
triggers: { uuid: "randomUUID", name: "trigger 1", type: "OnComplete" },
connections: {
source: { modelUUID: "modelUUID", pointUUID: "point1UUID" },
targets: [{ modelUUID: "modelUUID", pointUUID: "point1UUID" }],
},
};
await pointModel(organization).create({
...baseData,
points: StaticMachinePoint,
});
} else {
return res.json({ message: "Requested type mismatch" });
}
return res.status(201).json({ message: "Points created successfully" });
} catch (error) {
return res.status(500).json({

View File

@@ -4,7 +4,6 @@ import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
export class Zoneservice {
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
// console.log("req.body: ", req.body);
try {
const organization = req.body.organization;
const zoneDatas = req.body.zonesdata;
@@ -14,7 +13,7 @@ export class Zoneservice {
});
if (!existingZone) {
const newZone = await zoneSchema(organization).create({
zoneName: zoneDatas.zonename,
zoneName: zoneDatas.zoneName,
zoneId: zoneDatas.zoneId,
zonePoints: zoneDatas.points,
viewPortposition: zoneDatas.viewportPosition,
@@ -34,16 +33,23 @@ export class Zoneservice {
},
});
} else {
// const existingZoneName = await zoneSchema(organization).find({
// zoneName: zoneDatas.zoneName,
// isArchive: false,
// });
// if (existingZoneName.length > 0) {
// return res.json({ message: "Zone name already exists" });
// }
const replaceZone = await zoneSchema(organization).findOneAndUpdate(
{ zoneId: zoneDatas.zoneId, isArchive: false },
{
zoneName: zoneDatas.zoneName,
zonePoints: zoneDatas.points,
viewPortposition: zoneDatas.viewPortposition,
viewPortCenter: zoneDatas.viewPortCenter,
},
{ new: true }
);
console.log("replaceZone: ", replaceZone);
if (!replaceZone)
return res.status(404).json({ message: "Zone not updated" });
else
@@ -245,6 +251,40 @@ export class Zoneservice {
}
}
static async lockedPanel(req: Request, res: Response): Promise<any> {
console.log(req.body);
const organization = req.body.organization;
const zoneId = req.body.zoneId;
const lockedPanel = req.body.lockedPanel;
try {
const existingZone = await zoneSchema(organization).findOne({
zoneId: zoneId,
isArchive: false,
});
if (!existingZone) {
return res.status(404).json({ message: "Zone not found for the UUID" });
} else {
const updateLockedPanel = await zoneSchema(
organization
).findOneAndUpdate(
{ zoneId: zoneId, isArchive: false },
{
lockedPanel: lockedPanel,
},
{ new: true }
);
if (updateLockedPanel) {
return res
.status(200)
.json({ message: "locked panel updated successfully" });
}
}
} catch (error: any) {
return res.status(500).send(error.message);
}
}
// static async zoneIdgenerate(req: Request, res: Response): Promise<any> {
// const organization = req.query.organization;
// const sceneID = req.params.sceneID;

View File

@@ -18,10 +18,11 @@ export class assetsFloorservice {
organization,
eventData,
} = req.body;
console.log("req.body: ", req.body);
const findvalue = await assetModel(organization).findOne({
modeluuid,
modelname,
// modelname,
isArchive: false,
});
const checkpointType = await pointModel(organization).findOne({
@@ -31,8 +32,9 @@ export class assetsFloorservice {
if (findvalue) {
const updatevalue = await assetModel(organization).findOneAndUpdate(
{ modeluuid, modelname, isArchive: false },
{ modeluuid, isArchive: false },
{
modelname: modelname,
position,
rotation,
isVisible,
@@ -63,18 +65,18 @@ export class assetsFloorservice {
.status(400)
.json({ message: "Vehicle points must be a single object" });
}
if (eventData.points.rotation) {
return res.status(400).json({
message: "Rotation is not allowed for Vehicle points",
});
}
// if (eventData.points.rotation) {
// return res.status(400).json({
// message: "Rotation is not allowed for Vehicle points",
// });
// }
if (eventData.points.triggers) {
return res.status(400).json({
message: "triggers is not allowed for Vehicle points",
});
}
}
}
// else if(eventData.type === "ArmBot"){
// assetData.speed = eventData.position;
// }else if(eventData.type === "StaticMachine"){

View File

@@ -109,4 +109,47 @@ export class panelService {
return res.status(500).send(error.message);
}
}
static async clearPanel(req: Request, res: Response): Promise<any> {
try {
console.log("req.body;: ", req.body);
const { organization, panelName, zoneId } = req.body;
const existingZone = await zoneSchema(organization).findOne({
zoneId: zoneId,
panelOrder: { $in: [panelName] },
isArchive: false,
});
if (!existingZone) return res.json({ message: "Zone not found" });
const existingPanel = await panelSchema(organization).findOne({
zoneId: zoneId,
panelName: panelName,
isArchive: false,
});
if (!existingPanel)
return res.json({ message: "Requested Panel not found" });
const existingWidgets = await widgetSchema(organization).find({
panelID: existingPanel._id,
isArchive: false,
});
if (existingWidgets.length === 0)
return res.json({ message: "No widgets to clear" });
const clearWidgetsofPanel = await widgetSchema(organization).updateMany(
{ panelID: existingPanel._id, isArchive: false },
{ isArchive: true }
);
const removeWidgetsInPanel = await panelSchema(
organization
).findOneAndUpdate(
{ _id: existingPanel._id, isArchive: false },
{ $set: { widgets: [] } },
{ new: true }
);
if (!clearWidgetsofPanel && !removeWidgetsInPanel)
return res.json({ message: "Failed to clear widgets in panel" });
return res
.status(200)
.json({ message: "PanelWidgets cleared successfully" });
} catch (error: any) {
return res.status(500).send(error.message);
}
}
}

View File

@@ -56,6 +56,7 @@ interface IPointConveyor extends IPointBase {
}
interface IPointVehicle extends IPointBase {
rotation: number[];
actions: {
uuid: string;
name: string;
@@ -78,44 +79,48 @@ interface IPointArmbot extends IPointBase {
uuid: string;
name: string;
speed: number;
processes: { triggerId: string; startPoint: string; endPoint: string }[]
processes: { triggerId: string; startPoint: string; endPoint: string }[];
};
triggers: { uuid: string; name: string; type: string };
connections: {
source: { modelUUID: string; pointUUID: string };
targets: { modelUUID: string; pointUUID: string }[]
targets: { modelUUID: string; pointUUID: string }[];
};
}
interface IPointStaticMachine extends IPointBase{
interface IPointStaticMachine extends IPointBase {
rotation: number[];
actions: {
uuid: string;
name: string;
buffer: number ;
buffer: number;
material: string;
},
isUsed: boolean;
};
triggers: { uuid: string; name: string; type: string };
connections: {
source: { modelUUID: string; pointUUID: string };
targets: { modelUUID: string; pointUUID: string }[] };
connections: {
source: { modelUUID: string; pointUUID: string };
targets: { modelUUID: string; pointUUID: string }[];
};
}
// Main Document Interface
interface IPointModel extends Document {
modelfileID: string;
type: "Conveyor" | "Vehicle" |"ArmBot" |"StaticMachine",
points: IPointConveyor[] | IPointVehicle |IPointArmbot |IPointStaticMachine;
type: "Conveyor" | "Vehicle" | "ArmBot" | "StaticMachine";
points: IPointConveyor[] | IPointVehicle | IPointArmbot | IPointStaticMachine;
isArchive: boolean;
}
// Single Schema for both types
const PointSchema = new Schema<IPointModel>(
{
modelfileID: { type: String },
type: { type: String, enum: ["Conveyor", "Vehicle","ArmBot","StaticMachine"], required: true },
type: {
type: String,
enum: ["Conveyor", "Vehicle", "ArmBot", "StaticMachine"],
required: true,
},
isArchive: { type: Boolean, default: false },
points: {
type: Schema.Types.Mixed, // Flexible structure based on type
type: Schema.Types.Mixed,
required: true,
},
},
@@ -124,7 +129,7 @@ const PointSchema = new Schema<IPointModel>(
// Model Creation
const pointModel = (db: string) => {
return MainModel(db, "Points", PointSchema, "Points"); // Single collection
return MainModel(db, "Points", PointSchema, "Points");
};
export default pointModel;

View File

@@ -2,8 +2,6 @@ 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 const setAssetModel = async (data: any) => {
const {
modeluuid,
@@ -19,14 +17,15 @@ export const setAssetModel = async (data: any) => {
try {
const findvalue = await assetModel(organization).findOne({
modeluuid: modeluuid,
modelname: modelname,
// modelname: modelname,
isArchive: false,
});
if (findvalue) {
const updatevalue = await assetModel(organization).findOneAndUpdate(
{ modeluuid: modeluuid, modelname: modelname, isArchive: false },
{ modeluuid: modeluuid, isArchive: false },
{
modelname: modelname,
position: position,
rotation: rotation,
isVisible: isVisible,
@@ -63,13 +62,13 @@ export const setAssetModel = async (data: any) => {
organization: organization,
};
}
if (eventData.points.rotation) {
return {
success: false,
message: "Rotation is not allowed for Vehicle points",
organization: organization,
};
}
// if (eventData.points.rotation) {
// return {
// success: false,
// message: "Rotation is not allowed for Vehicle points",
// organization: organization,
// };
// }
if (eventData.points.triggers) {
return {
success: false,
@@ -99,8 +98,7 @@ export const setAssetModel = async (data: any) => {
speed: assetDoc.speed,
},
};
}
if (assetDoc.type === "Vehicle") {
} else if (assetDoc.type === "Vehicle") {
assetDatas = {
modeluuid: assetDoc.modeluuid,
modelname: assetDoc.modelname,
@@ -114,6 +112,44 @@ export const setAssetModel = async (data: any) => {
type: assetDoc.type,
},
};
} else if (assetDoc.type === "ArmBot") {
assetDatas = {
modeluuid: assetDoc.modeluuid,
modelname: assetDoc.modelname,
modelfileID: assetDoc.modelfileID,
position: assetDoc.position,
rotation: assetDoc.rotation,
isLocked: assetDoc.isLocked,
isVisible: assetDoc.isVisible,
eventData: {
points: assetDoc.points,
type: assetDoc.type,
},
};
} else if (assetDoc.type === "StaticMachine") {
assetDatas = {
modeluuid: assetDoc.modeluuid,
modelname: assetDoc.modelname,
modelfileID: assetDoc.modelfileID,
position: assetDoc.position,
rotation: assetDoc.rotation,
isLocked: assetDoc.isLocked,
isVisible: assetDoc.isVisible,
eventData: {
points: assetDoc.points,
type: assetDoc.type,
},
};
} else {
assetDatas = {
modeluuid: assetDoc.modeluuid,
modelname: assetDoc.modelname,
modelfileID: assetDoc.modelfileID,
position: assetDoc.position,
rotation: assetDoc.rotation,
isLocked: assetDoc.isLocked,
isVisible: assetDoc.isVisible,
};
}
return {
success: true,

View File

@@ -144,7 +144,124 @@ export const panelDelete = async (data: any) => {
};
}
};
export const panelClear = async (data: any) => {
const { organization, panelName, zoneId } = data;
console.log("data: ", data);
try {
const existingZone = await zoneSchema(organization).findOne({
zoneId: zoneId,
panelOrder: { $in: [panelName] },
isArchive: false,
});
if (!existingZone)
return {
success: false,
message: "Zone not found",
organization: organization,
};
const existingPanel = await panelSchema(organization).findOne({
zoneId: zoneId,
panelName: panelName,
isArchive: false,
});
if (!existingPanel)
return {
success: false,
message: "Requested Panel not found",
organization: organization,
};
const existingWidgets = await widgetSchema(organization).find({
panelID: existingPanel._id,
isArchive: false,
});
if (existingWidgets.length === 0)
return {
success: false,
message: "No widgets to clear",
organization: organization,
};
const clearWidgetsofPanel = await widgetSchema(organization).updateMany(
{ panelID: existingPanel._id, isArchive: false },
{ isArchive: true }
);
const removeWidgetsInPanel = await panelSchema(
organization
).findOneAndUpdate(
{ _id: existingPanel._id, isArchive: false },
{ $set: { widgets: [] } },
{ new: true }
);
if (!clearWidgetsofPanel && !removeWidgetsInPanel)
return {
success: false,
message: "Failed to clear widgets in panel",
organization: organization,
};
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
if (!zoneAndPanelData) {
return zoneAndPanelData; // If the zone and panel data retrieval fails, return the error.
}
return {
success: true,
data: zoneAndPanelData,
message: "PanelWidgets cleared successfully",
organization: organization,
};
} catch (error: any) {
return {
success: false,
message: error?.message || "Error occurred while panel",
error,
organization: organization,
};
}
};
export const panelLocked = async (data: any) => {
const { organization, lockedPanel, zoneId } = data;
console.log("data: ", data);
try {
const existingZone = await zoneSchema(organization).findOne({
zoneId: zoneId,
isArchive: false,
});
if (!existingZone) {
return {
success: false,
message: "Zone not found",
organization: organization,
};
} else {
const updateLockedPanel = await zoneSchema(organization).findOneAndUpdate(
{ zoneId: zoneId, isArchive: false },
{
lockedPanel: lockedPanel,
},
{ new: true }
);
const zoneAndPanelData = await getZoneAndPanelData(organization, zoneId);
if (!zoneAndPanelData) {
return zoneAndPanelData; // If the zone and panel data retrieval fails, return the error.
}
if (updateLockedPanel) {
return {
success: true,
message: "locked panel updated successfully",
data: zoneAndPanelData,
organization: organization,
};
}
}
} catch (error: any) {
return {
success: false,
message: error?.message || "Error occurred while panel",
error,
organization: organization,
};
}
};
const getZoneAndPanelData = async (organization: string, zoneId: string) => {
// const { organization, zoneId, } = data
// console.log('data: ', data);

View File

@@ -49,10 +49,15 @@ export const EVENTS = {
ZoneDeleteResponse:"zone:response:delete",
//visualization
//panel
addPanel:"v2:viz-panel:add",
panelUpdateResponse:"viz-panel:response:updates",
deletePanel:"v2:viz-panel:delete",
PanelDeleteResponse:"viz-panel:response:delete",
clearPanel:"v2:viz-panel:clear",
PanelClearResponse:"viz-panel:response:clear",
lockedPanel:"v2:viz-panel:locked",
PanelLockedResponse:"viz-panel:response:locked",
//widget
addWidget:"v2:viz-widget:add",

View File

@@ -7,7 +7,7 @@ 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, panelDelete } from '../services/visualization/panel-Services.ts';
import { addPanel, panelClear, panelDelete, panelLocked } from '../services/visualization/panel-Services.ts';
import { addWidget, Widgetdelete } from '../services/visualization/widget-Services.ts';
import { addfloat, deletefloat, duplicatefloat } from '../services/visualization/floatWidget-Service.ts';
import { addTemplate, addTemplateZone, TemplateZoneDelete } from '../services/visualization/templateServices.ts';
@@ -547,7 +547,50 @@ const panelHandleEvent = async (event: string, socket: Socket, data: any, namesp
}
break
}
case EVENTS.clearPanel: {
const result = await panelClear(data)
if (result) {
// console.log('result?.success: ', result.organization);
const responseEvent = EVENTS.PanelClearResponse
// console.log('responseEvent: ', responseEvent);
const organization = result?.organization
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.lockedPanel: {
const result = await panelLocked(data)
if (result) {
// console.log('result?.success: ', result.organization);
const responseEvent = EVENTS.PanelLockedResponse
// console.log('responseEvent: ', responseEvent);
const organization = result?.organization
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
}
default:
return;