Zone rename, model rename, clear panel and locked panel API and socket completed
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user