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