Merge branch 'main' into branch-v2
This commit is contained in:
127
src/socket-server/services/assets/asset-Controller.ts
Normal file
127
src/socket-server/services/assets/asset-Controller.ts
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
import assetModel from "../../../shared/model/builder/assets/asset-Model.ts";
|
||||||
|
import actionModel from "../../../shared/model/simulation/actionmodel.ts";
|
||||||
|
import triggerModel from "../../../shared/model/simulation/triggersmodel.ts";
|
||||||
|
|
||||||
|
export const setAssetModel = async (data: any) => {
|
||||||
|
const {modeluuid, modelname,position,rotation, eventData,modelfileID,isLocked,isVisible,organization, }= data
|
||||||
|
console.log('data: ', data);
|
||||||
|
// const position=data.position
|
||||||
|
// const rotation=data.rotation
|
||||||
|
try {
|
||||||
|
const findvalue = await assetModel(organization).findOne({
|
||||||
|
modeluuid: modeluuid,
|
||||||
|
modelname: modelname,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (findvalue) {
|
||||||
|
console.log('findvalue: ', findvalue);
|
||||||
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
||||||
|
{ modeluuid: modeluuid, modelname: modelname },
|
||||||
|
{
|
||||||
|
position: position,
|
||||||
|
rotation: rotation,
|
||||||
|
isVisible: isVisible,
|
||||||
|
isLocked: isLocked,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
);
|
||||||
|
console.log('updatevalue: ', updatevalue);
|
||||||
|
return { success: true, message: 'Model updated successfully', data: updatevalue, organization: organization }
|
||||||
|
} else {
|
||||||
|
let assetData: any = {
|
||||||
|
modeluuid,
|
||||||
|
modelname,
|
||||||
|
position,
|
||||||
|
modelfileID,
|
||||||
|
rotation,
|
||||||
|
isLocked,
|
||||||
|
isVisible,
|
||||||
|
};
|
||||||
|
if (eventData) {
|
||||||
|
let pointRefs: any[] = [];
|
||||||
|
|
||||||
|
if (Array.isArray(eventData.points)) {
|
||||||
|
for (const point of eventData.points) {
|
||||||
|
let actionRefs: any[] = [];
|
||||||
|
let triggerRefs: any[] = [];
|
||||||
|
|
||||||
|
if (Array.isArray(point.actions)) {
|
||||||
|
for (const action of point.actions) {
|
||||||
|
const actionDoc = await actionModel(organization).create({
|
||||||
|
pointsUUID: point.uuid,
|
||||||
|
isArchive: false,
|
||||||
|
uuid: action.uuid,
|
||||||
|
name: action.name,
|
||||||
|
type: action.type,
|
||||||
|
material: action.material,
|
||||||
|
delay: action.delay,
|
||||||
|
spawn_Interval: action.spawn_Interval,
|
||||||
|
});
|
||||||
|
await actionDoc.save();
|
||||||
|
actionRefs.push(actionDoc._id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(point.triggers)) {
|
||||||
|
for (const trigger of point.triggers) {
|
||||||
|
const triggerDoc = await triggerModel(organization).create({
|
||||||
|
pointsUUID: point.uuid,
|
||||||
|
isArchive: false,
|
||||||
|
uuid: trigger.uuid,
|
||||||
|
name: trigger.name,
|
||||||
|
type: trigger.type,
|
||||||
|
bufferTime: trigger.bufferTime,
|
||||||
|
});
|
||||||
|
await triggerDoc.save();
|
||||||
|
triggerRefs.push(triggerDoc._id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pointRefs.push({
|
||||||
|
uuid: point.uuid,
|
||||||
|
position: point.position || [],
|
||||||
|
rotation: point.rotation || [],
|
||||||
|
actions: actionRefs,
|
||||||
|
triggers: triggerRefs,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assetData.speed = eventData.speed;
|
||||||
|
assetData.type = eventData.type;
|
||||||
|
assetData.points = pointRefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const assetDoc = await assetModel(organization).create(assetData);
|
||||||
|
await assetDoc.save();
|
||||||
|
// await assetDoc.save();
|
||||||
|
// if(assetDoc.)
|
||||||
|
const assetDatas={
|
||||||
|
modeluuid:assetDoc.modeluuid,modelname:assetDoc.modelname,modelfileID:assetDoc.modelfileID,position:assetDoc.position,rotation:assetDoc.rotation,isLocked:assetDoc.isLocked,isVisible:assetDoc.isVisible
|
||||||
|
,eventData:{points:assetDoc.points,type:assetDoc.type,speed:assetDoc.speed}
|
||||||
|
}
|
||||||
|
return { success: true, message:"Model created successfully", data: assetDatas, organization: organization }
|
||||||
|
}
|
||||||
|
} catch (error:any) {
|
||||||
|
// console.error("Error creating flooritems:", error);
|
||||||
|
return { success: false, message: error?.message || "Error occurred while ModelAsset", error, organization: organization }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const deleteAssetModel = async (data: any)=>{
|
||||||
|
const { modeluuid,modelname,organization } = data;
|
||||||
|
try {
|
||||||
|
|
||||||
|
const findValue = await assetModel(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname})
|
||||||
|
if (!findValue) {
|
||||||
|
return { success: false, message: 'model not found',organization:organization }
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
return { success: true, message: 'Model deleted successfully', data: findValue,organization:organization }
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// console.error('Error get flooritems:', error);
|
||||||
|
return { success: false, message: 'Failed to delete asset', error,organization:organization }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,9 @@ import { Socket } from "socket.io";
|
|||||||
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
|
import cameraModel from "../../../shared/model/camera/camera-Model.ts";
|
||||||
|
|
||||||
export const createCamera = async (data: any,) => {
|
export const createCamera = async (data: any,) => {
|
||||||
|
const { userId, position, target, organization,rotation } = data
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const { userId, position, target, organization,rotation } = data
|
|
||||||
|
|
||||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
||||||
if (findCamera) {
|
if (findCamera) {
|
||||||
@@ -18,14 +18,14 @@ export const createCamera = async (data: any,) => {
|
|||||||
else {
|
else {
|
||||||
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation })
|
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation })
|
||||||
|
|
||||||
return { success: false, message: 'Camera created' ,data:newCamera,organization:organization}
|
return { success: true, message: 'Camera created' ,data:newCamera,organization:organization}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response with the created document
|
// Send response with the created document
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating camera:', error);
|
console.error('Error creating camera:', error);
|
||||||
return { success: false, message: 'Error creating or updating camera', error, }
|
return { success: false, message: 'Error creating or updating camera', error, organization:organization}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import environmentModel from "../../../shared/model/environments/environments-Mo
|
|||||||
|
|
||||||
|
|
||||||
export const setEnvironment = async (data: any,) => {
|
export const setEnvironment = async (data: any,) => {
|
||||||
try {
|
|
||||||
const { userId,roofVisibility,wallVisibility,shadowVisibility, organization } = data
|
const { userId,roofVisibility,wallVisibility,shadowVisibility, organization } = data
|
||||||
|
try {
|
||||||
|
|
||||||
const findvalue = await environmentModel(organization).findOne({ userId: userId })
|
const findvalue = await environmentModel(organization).findOne({ userId: userId })
|
||||||
if (findvalue) {
|
if (findvalue) {
|
||||||
@@ -27,7 +27,7 @@ export const setEnvironment = async (data: any,) => {
|
|||||||
// Send response with the created document
|
// Send response with the created document
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating evironments:', error);
|
console.error('Error creating evironments:', error);
|
||||||
return { success: false, message: 'Error creating or updating evironments', error }
|
return { success: false, message: 'Error creating or updating evironments', error ,organization:organization}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,21 +3,21 @@ import lineModel from "../../../shared/model/lines/lines-Model.ts";
|
|||||||
|
|
||||||
|
|
||||||
export const createLineItems = async (data: any)=>{
|
export const createLineItems = async (data: any)=>{
|
||||||
try {
|
|
||||||
const {organization,layer,line,type}=data
|
const {organization,layer,line,type}=data
|
||||||
|
try {
|
||||||
const newLine = await lineModel(organization).create({ layer,line,type });
|
const newLine = await lineModel(organization).create({ layer,line,type });
|
||||||
return { success: true, message: 'line create', data: newLine,organization:organization }
|
return { success: true, message: 'line create', data: newLine,organization:organization }
|
||||||
|
|
||||||
// Send response with the created document
|
// Send response with the created document
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
return { success: false, message: 'Error create line', error }
|
return { success: false, message: 'Error create line', error,organization:organization }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const updateLineItems = async (data: any)=>{
|
export const updateLineItems = async (data: any)=>{
|
||||||
try {
|
|
||||||
const {organization,uuid,position,}=data
|
const {organization,uuid,position,}=data
|
||||||
|
try {
|
||||||
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
|
// const findLine = await lineModel(organization).find({ 'line.uuid': uuid });
|
||||||
// Update the position of the line matching the uuid
|
// Update the position of the line matching the uuid
|
||||||
const updateResult = await lineModel(organization).updateMany(
|
const updateResult = await lineModel(organization).updateMany(
|
||||||
@@ -29,13 +29,13 @@ export const updateLineItems = async (data: any)=>{
|
|||||||
// Send response with the created document
|
// Send response with the created document
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating Lines:', error);
|
console.error('Error creating Lines:', error);
|
||||||
return { success: false, message: 'Error updating line', error }
|
return { success: false, message: 'Error updating line', error,organization:organization }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteLineItems = async (data: any)=>{
|
export const deleteLineItems = async (data: any)=>{
|
||||||
try {
|
|
||||||
const {organization,line}=data
|
const {organization,line}=data
|
||||||
|
try {
|
||||||
|
|
||||||
const inputUuids = line.map((item: any) => item.uuid);
|
const inputUuids = line.map((item: any) => item.uuid);
|
||||||
|
|
||||||
@@ -54,12 +54,12 @@ export const updateLineItems = async (data: any)=>{
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error delete Lines:', error);
|
console.error('Error delete Lines:', error);
|
||||||
return { success: false, message: 'Failed to delete line', error }
|
return { success: false, message: 'Failed to delete line', error ,organization:organization}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const deleteLayer = async (data: any)=>{
|
export const deleteLayer = async (data: any)=>{
|
||||||
try {
|
|
||||||
const {organization,layer}=data
|
const {organization,layer}=data
|
||||||
|
try {
|
||||||
|
|
||||||
const findValue = await lineModel(organization).find({ layer: layer });
|
const findValue = await lineModel(organization).find({ layer: layer });
|
||||||
|
|
||||||
@@ -77,12 +77,12 @@ export const updateLineItems = async (data: any)=>{
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error delete layer:', error);
|
console.error('Error delete layer:', error);
|
||||||
return { success: false, message: 'Failed to delete layer', error }
|
return { success: false, message: 'Failed to delete layer', error ,organization:organization}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const deleteLinPoiteItems = async (data: any)=>{
|
export const deleteLinPoiteItems = async (data: any)=>{
|
||||||
try {
|
|
||||||
const {organization,uuid}=data
|
const {organization,uuid}=data
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid })
|
const findValue = await lineModel(organization).deleteMany({ 'line.uuid': uuid })
|
||||||
@@ -95,6 +95,6 @@ export const updateLineItems = async (data: any)=>{
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error delete Lines:', error);
|
console.error('Error delete Lines:', error);
|
||||||
return { success: false, message: 'Failed to delete point', error }
|
return { success: false, message: 'Failed to delete point', error ,organization:organization}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
|
import zoneModel from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
|
|
||||||
export const setZone = async (data: any) => {
|
export const setZone = async (data: any) => {
|
||||||
try {
|
|
||||||
const { organization, userId, zoneData } = data
|
const { organization, userId, zoneData } = data
|
||||||
console.log('data: ', data);
|
try {
|
||||||
const zoneId = zoneData.zoneId
|
const zoneId = zoneData.zoneId
|
||||||
const points = zoneData.points
|
const points = zoneData.points
|
||||||
const zoneName = zoneData.zoneName
|
const zoneName = zoneData.zoneName
|
||||||
@@ -18,7 +16,7 @@ export const setZone = async (data: any) => {
|
|||||||
return { success: true, message: 'zone updated', data: updateZone, organization: organization }
|
return { success: true, message: 'zone updated', data: updateZone, organization: organization }
|
||||||
} else {
|
} else {
|
||||||
const zoneCreate = await zoneModel(organization).create({
|
const zoneCreate = await zoneModel(organization).create({
|
||||||
zoneId, createBy: userId, zoneName: zoneName, points, layer, viewPortCenter, viewPortposition
|
zoneId, createdBy: userId, zoneName: zoneName, points, layer, viewPortCenter, viewPortposition
|
||||||
})
|
})
|
||||||
const createdZone = await zoneModel(organization)
|
const createdZone = await zoneModel(organization)
|
||||||
.findById(zoneCreate._id)
|
.findById(zoneCreate._id)
|
||||||
@@ -28,18 +26,18 @@ export const setZone = async (data: any) => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('error: ', error);
|
console.log('error: ', error);
|
||||||
return { success: false, message: 'Zone not found', error }
|
return { success: false, message: 'Zone not found', error , organization: organization}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteZone = async (data: any) => {
|
export const deleteZone = async (data: any) => {
|
||||||
try {
|
|
||||||
const { organization, userId, zoneId } = data
|
const { organization, userId, zoneId } = data
|
||||||
|
try {
|
||||||
|
|
||||||
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
const findZoneId = await zoneModel(organization).findOne({ zoneId: zoneId })
|
||||||
if (findZoneId) {
|
if (findZoneId) {
|
||||||
const deleteZone = await zoneModel(organization).findOneAndDelete(
|
const deleteZone = await zoneModel(organization).findOneAndDelete(
|
||||||
{ zoneId: zoneId, createBy: userId }
|
{ zoneId: zoneId, createdBy: userId }
|
||||||
).select("-_id -__v")
|
).select("-_id -__v")
|
||||||
return { success: true, message: 'zone deleted', data: deleteZone, organization: organization }
|
return { success: true, message: 'zone deleted', data: deleteZone, organization: organization }
|
||||||
} else {
|
} else {
|
||||||
@@ -48,6 +46,6 @@ export const deleteZone = async (data: any) => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('error: ', error);
|
console.log('error: ', error);
|
||||||
return { success: false, message: 'Zone not found', error }
|
return { success: false, message: 'Zone not found', error, organization: organization }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@ import cameraModel from "../../../shared/model/camera/camera-Model.ts"
|
|||||||
import userModel from "../../../shared/model/user-Model.ts"
|
import userModel from "../../../shared/model/user-Model.ts"
|
||||||
|
|
||||||
export const activeUsers = async (data: any) => {
|
export const activeUsers = async (data: any) => {
|
||||||
|
const {organization}=data
|
||||||
|
// console.log('data: ', data);
|
||||||
try {
|
try {
|
||||||
if (data && data.email) {
|
if (data && data.email) {
|
||||||
|
|
||||||
@@ -42,23 +44,25 @@ export const activeUsers = async (data: any) => {
|
|||||||
// Handle the error or return a default value
|
// Handle the error or return a default value
|
||||||
// Example: Return an error response if the email is invalid
|
// Example: Return an error response if the email is invalid
|
||||||
|
|
||||||
return { success: false, message: 'Email is missing or invalid', }
|
return { success: false, message: 'Email is missing or invalid', organization:organization }
|
||||||
// return res.status(400).send({ message: 'Email is missing or invalid' });
|
// return res.status(400).send({ message: 'Email is missing or invalid' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // return [];
|
// // return [];
|
||||||
} catch (error) {
|
} catch (error:any) {
|
||||||
|
return { success: false, message: error?.message || "Error occurred while activeUser", error, organization: organization }
|
||||||
|
|
||||||
return { success: false, message:error}
|
// return { success: false, message:error}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const activeUserOffline = async (data: any) => {
|
export const activeUserOffline = async (data: any) => {
|
||||||
try {
|
|
||||||
|
|
||||||
const email = data.email
|
const email = data.email
|
||||||
const organization = email.split("@")[1].split(".")[0]
|
const organization = email.split("@")[1].split(".")[0]
|
||||||
|
try {
|
||||||
|
|
||||||
const findUsers = await userModel(organization).findOne({email})
|
const findUsers = await userModel(organization).findOne({email})
|
||||||
// console.log('findUsers: ', findUsers);
|
// console.log('findUsers: ', findUsers);
|
||||||
@@ -90,8 +94,44 @@ export const activeUserOffline = async (data: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // return [];
|
// // return [];
|
||||||
} catch (error) {
|
} catch (error:any) {
|
||||||
|
return { success: false, message: error?.message || "Error occurred while activeUser", error, organization: organization }
|
||||||
|
|
||||||
return { success: false, message: error}
|
// return { success: false, message: error}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
type OnlineUsersMap = Map<string, Set<string>>;
|
||||||
|
|
||||||
|
// export const addUserToOnlineList = async (
|
||||||
|
// organization: string,
|
||||||
|
// email: string,
|
||||||
|
// onlineUsers: OnlineUsersMap,
|
||||||
|
// socket: any,
|
||||||
|
// namespace: string
|
||||||
|
// ) => {
|
||||||
|
// if (!organization || !email) return;
|
||||||
|
// console.log('organization: ', organization);
|
||||||
|
|
||||||
|
// // Ensure the organization entry exists
|
||||||
|
// if (!onlineUsers.has(organization)) {
|
||||||
|
// onlineUsers.set(organization, new Set());
|
||||||
|
// }
|
||||||
|
// const findUser = await userModel(organization).findOne({email})
|
||||||
|
// if (!findUser) {
|
||||||
|
// return { success: false, message: "User not found", organization };
|
||||||
|
// }
|
||||||
|
// const userId = findUser._id;
|
||||||
|
// console.log(`🔍 Found user with ID: ${userId}`);
|
||||||
|
// // Add user to the online set
|
||||||
|
// onlineUsers.get(organization)!.add(userId);
|
||||||
|
|
||||||
|
// console.log(`✅ User ${userId} is online (Org: ${organization})`);
|
||||||
|
|
||||||
|
// // Emit updated online users list
|
||||||
|
// socket.emit("users:online", {
|
||||||
|
// organization,
|
||||||
|
// users: [...onlineUsers.get(organization)!],
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import floatWidgetModel from "../../../shared/model/vizualization/3dwidget.ts";
|
||||||
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
|
|
||||||
|
export const addfloat = async (data: any) => {
|
||||||
|
const { organization, widget, zoneId } = data;
|
||||||
|
console.log('data: ', data);
|
||||||
|
try {
|
||||||
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (!existingZone)
|
||||||
|
return { success: false, message: "Zone not found for the zoneId", organization: organization }
|
||||||
|
|
||||||
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
|
floatWidgetID: widget.id,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existingFloatWidget) {
|
||||||
|
const updateFloatWidget = await floatWidgetModel(organization).findOneAndUpdate(
|
||||||
|
{
|
||||||
|
floatWidgetID: widget.id,
|
||||||
|
isArchive: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
// Data: {
|
||||||
|
// // measurements: widget.Data.measurements || {},
|
||||||
|
// duration: widget.Data.duration || "1h",
|
||||||
|
// },
|
||||||
|
position: widget.position,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
upsert: true,
|
||||||
|
new: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return { success: true, message: "Widget updated successfully", data: updateFloatWidget, organization: organization }
|
||||||
|
}
|
||||||
|
|
||||||
|
const newFloadWidget = await floatWidgetModel(organization).create({
|
||||||
|
className: widget.className,
|
||||||
|
header: widget.header,
|
||||||
|
floatWidgetID: widget.id,
|
||||||
|
position: widget.position,
|
||||||
|
per: widget.per,
|
||||||
|
value: widget.value,
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
if (newFloadWidget) {
|
||||||
|
return { success: true, message: "FloatWidget created successfully", data: newFloadWidget, organization: organization }
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
return { success: false, message: error?.message || "Error occurred while float", error, organization: organization }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
src/socket-server/services/visualization/templateServices.ts
Normal file
26
src/socket-server/services/visualization/templateServices.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import templateModel from "../../../shared/model/vizualization/templatemodel.ts";
|
||||||
|
export const addTemplate = async (data: any) => {
|
||||||
|
const { organization, templateID, name, panelOrder, widgets, snapshot } =data;
|
||||||
|
console.log('data: ', data);
|
||||||
|
try {
|
||||||
|
|
||||||
|
const existingTemplate = await templateModel(organization).findOne({
|
||||||
|
templateID: templateID,
|
||||||
|
isArchive: false,
|
||||||
|
});
|
||||||
|
if (existingTemplate)
|
||||||
|
return { success: false, message: "TemplateID alreay exists", organization: organization }
|
||||||
|
const newTemplate = await templateModel(organization).create({
|
||||||
|
templateID,
|
||||||
|
name,
|
||||||
|
panelOrder,
|
||||||
|
widgets,
|
||||||
|
snapshot,
|
||||||
|
});
|
||||||
|
if (newTemplate)
|
||||||
|
return { success: false, message: "Template saved successfully", data: newTemplate, organization: organization }
|
||||||
|
} catch (error: any) {
|
||||||
|
return { success: false, message: error?.message || "Error occurred while template", error, organization: organization }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,8 +2,8 @@ export const EVENTS = {
|
|||||||
connection: "connection",
|
connection: "connection",
|
||||||
disconnect:"disconnect",
|
disconnect:"disconnect",
|
||||||
//userActiveStatus
|
//userActiveStatus
|
||||||
userConnect:"userConnectRespones",
|
userConnect:"userConnectResponse",
|
||||||
userDisConnect:"userDisConnectRespones",
|
userDisConnect:"userDisConnectResponse",
|
||||||
// Room management events
|
// Room management events
|
||||||
joinRoom: 'joinRoom',
|
joinRoom: 'joinRoom',
|
||||||
createroom: "createRoom", // When a client joins a room
|
createroom: "createRoom", // When a client joins a room
|
||||||
@@ -59,4 +59,22 @@ export const EVENTS = {
|
|||||||
widgetUpdateRespones:"viz-widget:response:updates",
|
widgetUpdateRespones:"viz-widget:response:updates",
|
||||||
deleteWidget:"v2:viz-widget:delete",
|
deleteWidget:"v2:viz-widget:delete",
|
||||||
widgetDeleteRespones:"viz-widget:response:delete",
|
widgetDeleteRespones:"viz-widget:response:delete",
|
||||||
|
|
||||||
|
//float
|
||||||
|
addFloat: "v2:viz-float:add",
|
||||||
|
floatUpdateRespones: "viz-float:response:updates",
|
||||||
|
deleteFloat: "v2:viz-float:delete",
|
||||||
|
floatDeleteRespones: "viz-float:response:delete",
|
||||||
|
|
||||||
|
//template
|
||||||
|
addTemplate:"v2:viz-template:add",
|
||||||
|
templateUpdateRespones:"viz-template:response:updates",
|
||||||
|
|
||||||
|
//model-asset
|
||||||
|
setAssetModel: "v2:model-asset:add",
|
||||||
|
assetUpdateRespones: "model-asset:response:updates",
|
||||||
|
deleteAssetModel:"v2:model-asset:delete",
|
||||||
|
assetDeleteRespones: "model-asset:response:updates",
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user