panelDelete and AssetsGet API created
This commit is contained in:
@@ -7,5 +7,8 @@ router.get(
|
|||||||
"/floadData/:zoneId/:organization",
|
"/floadData/:zoneId/:organization",
|
||||||
floatWidgetService.getfloatWidget
|
floatWidgetService.getfloatWidget
|
||||||
);
|
);
|
||||||
router.get("/A_floatWidget/:floatWidgetID/:organization",floatWidgetService.getsinglefloatWidget)
|
router.get(
|
||||||
|
"/A_floatWidget/:floatWidgetID/:organization",
|
||||||
|
floatWidgetService.getsinglefloatWidget
|
||||||
|
);
|
||||||
export default router;
|
export default router;
|
||||||
@@ -4,7 +4,7 @@ export class zone {
|
|||||||
static async setZone(req: Request, res: Response) {
|
static async setZone(req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
const { organization, userId, zoneData } = req.body
|
const { organization, userId, zoneData } = req.body
|
||||||
console.log('req.body: ', req.body);
|
// console.log('req.body: ', req.body);
|
||||||
const zoneId = zoneData.zoneId
|
const zoneId = zoneData.zoneId
|
||||||
const points = zoneData.points
|
const points = zoneData.points
|
||||||
const zoneName = zoneData.zoneName
|
const zoneName = zoneData.zoneName
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import panelSchema from "../../../shared/model/vizualization/panelmodel.ts";
|
|||||||
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||||
export class Zoneservice {
|
export class Zoneservice {
|
||||||
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
static async addandUpdateZone(req: Request, res: Response): Promise<any> {
|
||||||
console.log("req.body: ", req.body);
|
// console.log("req.body: ", req.body);
|
||||||
try {
|
try {
|
||||||
const organization = req.body.organization;
|
const organization = req.body.organization;
|
||||||
const zoneDatas = req.body.zonesdata;
|
const zoneDatas = req.body.zonesdata;
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ export class assetsFloorservice {
|
|||||||
const {
|
const {
|
||||||
modeluuid,
|
modeluuid,
|
||||||
modelname,
|
modelname,
|
||||||
assetPosition,
|
position,
|
||||||
modelfileID,
|
modelfileID,
|
||||||
assetRotation,
|
rotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
organization,
|
organization,
|
||||||
@@ -29,8 +29,8 @@ export class assetsFloorservice {
|
|||||||
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||||
{ modeluuid, modelname },
|
{ modeluuid, modelname },
|
||||||
{
|
{
|
||||||
assetPosition,
|
position,
|
||||||
assetRotation,
|
rotation,
|
||||||
isVisible,
|
isVisible,
|
||||||
isLocked,
|
isLocked,
|
||||||
},
|
},
|
||||||
@@ -41,9 +41,9 @@ export class assetsFloorservice {
|
|||||||
let assetData: any = {
|
let assetData: any = {
|
||||||
modeluuid,
|
modeluuid,
|
||||||
modelname,
|
modelname,
|
||||||
assetPosition,
|
position,
|
||||||
modelfileID,
|
modelfileID,
|
||||||
assetRotation,
|
rotation,
|
||||||
isLocked,
|
isLocked,
|
||||||
isVisible,
|
isVisible,
|
||||||
};
|
};
|
||||||
@@ -144,9 +144,9 @@ export class assetsFloorservice {
|
|||||||
let responseItem: any = {
|
let responseItem: any = {
|
||||||
modeluuid: item.modeluuid,
|
modeluuid: item.modeluuid,
|
||||||
modelname: item.modelname,
|
modelname: item.modelname,
|
||||||
assetPosition: item.assetPosition,
|
position: item.position,
|
||||||
modelfileID: item.modelfileID,
|
modelfileID: item.modelfileID,
|
||||||
assetRotation: item.assetRotation,
|
rotation: item.rotation,
|
||||||
isLocked: item.isLocked,
|
isLocked: item.isLocked,
|
||||||
isVisible: item.isVisible,
|
isVisible: item.isVisible,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,17 +98,18 @@ export class floatWidgetService {
|
|||||||
|
|
||||||
static async deletefloatWidget(req: Request, res: Response): Promise<any> {
|
static async deletefloatWidget(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
|
console.log("req.body: ", req.body);
|
||||||
const { floatWidgetID, organization } = req.body;
|
const { floatWidgetID, organization } = req.body;
|
||||||
const findfloatWidget = await floatWidgetModel(organization).findOne({
|
const findfloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: floatWidgetID,
|
floatWidgetID: floatWidgetID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findfloatWidget)
|
if (!findfloatWidget) return res.json({ message: "Widget not found" });
|
||||||
return res.status(409).json({ message: "Widget not found" });
|
|
||||||
const widgetData = await floatWidgetModel(organization).updateOne(
|
const widgetData = await floatWidgetModel(organization).updateOne(
|
||||||
{ _id: findfloatWidget._id, isArchive: false },
|
{ _id: findfloatWidget._id, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
|
console.log("widgetData: ", widgetData);
|
||||||
return res
|
return res
|
||||||
.status(200)
|
.status(200)
|
||||||
.json({ message: "FloatingWidget deleted successfully" });
|
.json({ message: "FloatingWidget deleted successfully" });
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ export class panelService {
|
|||||||
}
|
}
|
||||||
static async deletePanel(req: Request, res: Response): Promise<any> {
|
static async deletePanel(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
|
console.log("req.body: ", req.body);
|
||||||
const { organization, panelName, zoneId } = req.body;
|
const { organization, panelName, zoneId } = req.body;
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
@@ -80,15 +81,15 @@ export class panelService {
|
|||||||
});
|
});
|
||||||
if (!existingPanel)
|
if (!existingPanel)
|
||||||
return res.status(409).json({ message: "Panel Already Deleted" });
|
return res.status(409).json({ message: "Panel Already Deleted" });
|
||||||
const updatePanel = await panelSchema(organization).updateOne(
|
const updatePanel = await panelSchema(organization).findOneAndUpdate(
|
||||||
{ _id: existingPanel._id, isArchive: false },
|
{ _id: existingPanel._id, isArchive: false },
|
||||||
{ $set: { isArchive: true } }
|
{ isArchive: true },
|
||||||
|
{ new: true }
|
||||||
);
|
);
|
||||||
const existingWidgets = await widgetSchema(organization).find({
|
const existingWidgets = await widgetSchema(organization).find({
|
||||||
panelID: existingPanel._id,
|
panelID: existingPanel._id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const widgetData of existingWidgets) {
|
for (const widgetData of existingWidgets) {
|
||||||
widgetData.isArchive = true;
|
widgetData.isArchive = true;
|
||||||
await widgetData.save();
|
await widgetData.save();
|
||||||
@@ -96,9 +97,15 @@ export class panelService {
|
|||||||
|
|
||||||
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
if (existingZone.panelOrder.includes(existingPanel.panelName)) {
|
||||||
const index1 = existingZone.panelOrder.indexOf(existingPanel.panelName);
|
const index1 = existingZone.panelOrder.indexOf(existingPanel.panelName);
|
||||||
existingZone.panelOrder.splice(index1, 1);
|
const zonepanelname = await zoneSchema(organization).updateOne(
|
||||||
|
{ _id: existingZone._id },
|
||||||
|
{ $pull: { panelOrder: existingPanel.panelName } }
|
||||||
|
);
|
||||||
|
console.log("zonepanelname: ", zonepanelname);
|
||||||
|
// existingZone.panelOrder.splice(index1, 1);
|
||||||
|
// existingZone.markModified("panelOrder"); // Mark modified
|
||||||
|
// await existingZone.save();
|
||||||
}
|
}
|
||||||
await existingZone.save();
|
|
||||||
|
|
||||||
return res.status(200).json({ message: "Panel deleted successfully" });
|
return res.status(200).json({ message: "Panel deleted successfully" });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
@@ -33,8 +33,13 @@ export interface assetData extends Document {
|
|||||||
];
|
];
|
||||||
}[];
|
}[];
|
||||||
}[];
|
}[];
|
||||||
assetPosition: number[];
|
position: [];
|
||||||
assetRotation: number[];
|
// rotation: [];
|
||||||
|
rotation: {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
z: number;
|
||||||
|
};
|
||||||
speed: number | string;
|
speed: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,16 +71,16 @@ const assetDataSchema: Schema = new Schema({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
assetPosition: { type: [Number] },
|
position: { type: Array},
|
||||||
assetRotation: { type: [Number] },
|
// rotation: { type: Array },
|
||||||
|
rotation: {
|
||||||
|
x: { type: Number },
|
||||||
|
y: { type: Number },
|
||||||
|
z: { type: Number },
|
||||||
|
},
|
||||||
speed: { type: Schema.Types.Mixed },
|
speed: { type: Schema.Types.Mixed },
|
||||||
isLocked: { type: Boolean },
|
isLocked: { type: Boolean },
|
||||||
isVisible: { type: Boolean },
|
isVisible: { type: Boolean },
|
||||||
// rotation: {
|
|
||||||
// x: { type: Number },
|
|
||||||
// y: { type: Number },
|
|
||||||
// z: { type: Number },
|
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// export default floorItemsModel;
|
// export default floorItemsModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user