AssetPoints based on type fixed, Asset Get,Create, 3d widget type updated in socket

This commit is contained in:
2025-04-03 19:51:51 +05:30
parent bc97dfa1ed
commit 7b8636c43b
14 changed files with 1648 additions and 460 deletions

View File

@@ -1,7 +1,7 @@
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts";
export const add3Dwidget = async (data: any) => {
const { organization, widget, zoneId } = data
const { organization, widget, zoneId } = data;
try {
const existingZone = await zoneSchema(organization).findOne({
@@ -9,15 +9,17 @@ export const add3Dwidget = async (data: any) => {
isArchive: false,
});
if (!existingZone)
return { success: false, message: "Zone not found for the zoneId", organization: organization }
return {
success: false,
message: "Zone not found for the zoneId",
organization: organization,
};
const existing3Dwidget = await widget3dModel(organization).findOne({
widgetID: widget.id,
isArchive: false,
});
if (existing3Dwidget) {
const update3dwidget = await widget3dModel(
organization
).findOneAndUpdate(
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
{
widgetID: widget.id,
zoneId: zoneId,
@@ -27,29 +29,47 @@ export const add3Dwidget = async (data: any) => {
{ upsert: true, new: true }
);
if (update3dwidget)
return { success: true, message: "widget update successfully", organization: organization }
else return { success: false, message: "Widget not updated", organization: organization }
return {
success: true,
message: "widget update successfully",
organization: organization,
};
else
return {
success: false,
message: "Widget not updated",
organization: organization,
};
}
const newWidget3d = await widget3dModel(organization).create({
widgetName: widget.type,
type: widget.type,
widgetID: widget.id,
position: widget.position,
zoneId,
});
if (newWidget3d) {
const widgemodel3D_Datas = {
widget: { id: newWidget3d.widgetID, type: newWidget3d.widgetName, position: newWidget3d.position, },
Data: newWidget3d.Data, zoneId: zoneId,
}
return { success: true, message: "Widget created successfully", data: widgemodel3D_Datas, organization: organization }
widget: {
id: newWidget3d.widgetID,
type: newWidget3d.type,
position: newWidget3d.position,
},
Data: newWidget3d.Data,
zoneId: zoneId,
};
return {
success: true,
message: "Widget created successfully",
data: widgemodel3D_Datas,
organization: organization,
};
}
} catch (error: any) {
return { success: false, message: error?.message || "Error occurred while 3Dwidget", error, organization: organization }
return {
success: false,
message: error?.message || "Error occurred while 3Dwidget",
error,
organization: organization,
};
}
}
};