zone response zone-points added
This commit is contained in:
@@ -108,7 +108,7 @@ export class Zoneservice {
|
||||
isArchive: false,
|
||||
})
|
||||
.select(
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition"
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition points"
|
||||
);
|
||||
if (!existingZone) {
|
||||
return res.send({ message: "Zone not found for the UUID" });
|
||||
@@ -146,7 +146,7 @@ export class Zoneservice {
|
||||
activeSides: existingZone.panelOrder || [],
|
||||
panelOrder: existingZone.panelOrder || [],
|
||||
lockedPanels: existingZone.lockedPanel || [],
|
||||
points: existingZone.zonePoints || [],
|
||||
points: existingZone.points || [],
|
||||
widgets: flattenedWidgets,
|
||||
};
|
||||
|
||||
@@ -166,7 +166,7 @@ export class Zoneservice {
|
||||
isArchive: false,
|
||||
})
|
||||
.select(
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition"
|
||||
"panelOrder zoneName zonePoints lockedPanel zoneId viewPortCenter viewPortposition points"
|
||||
);
|
||||
if (!existingZones) {
|
||||
return res.send({ message: "Zone not found for the UUID" });
|
||||
@@ -205,7 +205,7 @@ export class Zoneservice {
|
||||
activeSides: zone.panelOrder || [],
|
||||
panelOrder: zone.panelOrder || [],
|
||||
lockedPanels: zone.lockedPanel || [],
|
||||
points: zone.zonePoints || [],
|
||||
points: zone.points || [],
|
||||
widgets: widgets.flat(),
|
||||
};
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ export class widgetService {
|
||||
static async addWidget(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
// console.log("req.body: ", req.body);
|
||||
console.log("req.body: ", req.body);
|
||||
const {
|
||||
organization,
|
||||
// panel,
|
||||
@@ -57,7 +58,6 @@ export class widgetService {
|
||||
},
|
||||
{ upsert: true, new: true } // Upsert: create if not exists, new: return updated document
|
||||
);
|
||||
console.log("updateWidget: ", updateWidget);
|
||||
return res
|
||||
.status(200)
|
||||
.json({ message: "Widget updated successfully" });
|
||||
@@ -95,8 +95,8 @@ export class widgetService {
|
||||
|
||||
static async deleteWidget(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const { widgetID, organization,zoneId} = req.body;
|
||||
console.log(' req.body: ', req.body);
|
||||
const { widgetID, organization, zoneId } = req.body;
|
||||
console.log(" req.body: ", req.body);
|
||||
const findWidget = await widgetSchema(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
widgetID: widgetID,
|
||||
@@ -105,7 +105,7 @@ export class widgetService {
|
||||
if (!findWidget)
|
||||
return res.status(409).json({ message: "Widget not found" });
|
||||
const widgetData = await widgetSchema(organization).updateOne(
|
||||
{ _id: findWidget._id, isArchive: false,zoneId: zoneId },
|
||||
{ _id: findWidget._id, isArchive: false, zoneId: zoneId },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
|
||||
@@ -142,6 +142,7 @@ export class widgetService {
|
||||
|
||||
static async updatewidget(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
console.log("req.body: ", req.body);
|
||||
const { organization, widgetID, values } = req.body;
|
||||
const findwidget = await widgetSchema(organization).findOne({
|
||||
widgetID: widgetID,
|
||||
|
||||
@@ -5,7 +5,7 @@ import widgetSchema from "../../../shared/model/vizualization/widgemodel.ts";
|
||||
import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts";
|
||||
export const addTemplate = async (data: any) => {
|
||||
const { organization, template, name, panelOrder, widgets, snapshot } = data;
|
||||
console.log('data: ', data);
|
||||
console.log("data: ", data);
|
||||
try {
|
||||
// console.log("req.body: ", req.body);
|
||||
const existingTemplate = await templateModel(organization).findOne({
|
||||
@@ -14,7 +14,11 @@ export const addTemplate = async (data: any) => {
|
||||
});
|
||||
|
||||
if (existingTemplate)
|
||||
return { success: false, message: "TemplateID alreay exists", organization: organization }
|
||||
return {
|
||||
success: false,
|
||||
message: "TemplateID alreay exists",
|
||||
organization: organization,
|
||||
};
|
||||
const newTemplate = await templateModel(organization).create({
|
||||
templateID: template.id,
|
||||
templateName: template.name,
|
||||
@@ -46,14 +50,15 @@ export const addTemplate = async (data: any) => {
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error?.message || "Error occurred while template", error, organization: organization }
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: error?.message || "Error occurred while template",
|
||||
error,
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export const addTemplateZone = async (data: any) => {
|
||||
const { zoneId, templateID, organization } = data;
|
||||
@@ -63,14 +68,22 @@ export const addTemplateZone = async (data: any) => {
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingZone)
|
||||
return { success: false, message: "Zone not found ", organization: organization }
|
||||
return {
|
||||
success: false,
|
||||
message: "Zone not found ",
|
||||
organization: organization,
|
||||
};
|
||||
|
||||
const existingTemplate = await templateModel(organization).findOne({
|
||||
templateID: templateID,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingTemplate)
|
||||
return { success: false, message: "TemplateID not found", organization: organization }
|
||||
return {
|
||||
success: false,
|
||||
message: "TemplateID not found",
|
||||
organization: organization,
|
||||
};
|
||||
|
||||
if (existingZone.panelOrder.length > 0) {
|
||||
existingZone.panelOrder = existingTemplate.panelOrder;
|
||||
@@ -147,9 +160,11 @@ export const addTemplateZone = async (data: any) => {
|
||||
}
|
||||
|
||||
for (const floatData of existingTemplate.floatWidgets) {
|
||||
const existingFloatWidget = await floatWidgetModel(
|
||||
organization
|
||||
).findOne({ floatWidgetID: floatData.id, isArchive: false, zoneId });
|
||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||
floatWidgetID: floatData.id,
|
||||
isArchive: false,
|
||||
zoneId,
|
||||
});
|
||||
if (existingFloatWidget) continue;
|
||||
|
||||
await floatWidgetModel(organization).create({
|
||||
@@ -163,19 +178,33 @@ export const addTemplateZone = async (data: any) => {
|
||||
});
|
||||
}
|
||||
const templateZoneDatas = {
|
||||
template: { id: existingTemplate.templateID, name: existingTemplate.templateName, panelOrder: existingTemplate.panelOrder, widgets: existingTemplate.widgets, snapshot: existingTemplate.snapshot, floatingWidget: existingTemplate.floatWidgets },
|
||||
zoneId: existingZone.zoneId, zoneName: existingZone.zoneName
|
||||
}
|
||||
|
||||
|
||||
return { success: true, message: "Template placed in Zone", data: templateZoneDatas, organization: organization }
|
||||
template: {
|
||||
id: existingTemplate.templateID,
|
||||
name: existingTemplate.templateName,
|
||||
panelOrder: existingTemplate.panelOrder,
|
||||
widgets: existingTemplate.widgets,
|
||||
snapshot: existingTemplate.snapshot,
|
||||
floatingWidget: existingTemplate.floatWidgets,
|
||||
},
|
||||
zoneId: existingZone.zoneId,
|
||||
zoneName: existingZone.zoneName,
|
||||
};
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Template placed in Zone",
|
||||
data: templateZoneDatas,
|
||||
organization: organization,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error?.message || "Error occurred while template", error, organization: organization }
|
||||
return {
|
||||
success: false,
|
||||
message: error?.message || "Error occurred while template",
|
||||
error,
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
export const TemplateZoneDelete = async (data: any) => {
|
||||
const { zoneId, templateID, organization } = data;
|
||||
try {
|
||||
@@ -189,16 +218,21 @@ export const TemplateZoneDelete = async (data: any) => {
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
if (newTemplate) {
|
||||
|
||||
const TemplateDeleteData = existingTemplate.templateID
|
||||
return { success: true, message: "Template deleted successfully", data: TemplateDeleteData, organization: organization }
|
||||
const TemplateDeleteData = existingTemplate.templateID;
|
||||
return {
|
||||
success: true,
|
||||
message: "Template deleted successfully",
|
||||
data: TemplateDeleteData,
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error?.message || "Error occurred while template", error, organization: organization }
|
||||
return {
|
||||
success: false,
|
||||
message: error?.message || "Error occurred while template",
|
||||
error,
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user