Collaboration completed for builder,dashboard, visualization for API and socket

This commit is contained in:
2025-06-04 17:25:46 +05:30
parent 591d86c274
commit 5216ee190a
40 changed files with 1045 additions and 674 deletions

View File

@@ -0,0 +1,62 @@
import UsersDataModel from "../../V1Models/Auth/user.ts";
import AuthModel from "../../V1Models/Auth/userAuthModel.ts";
import {
existingProjectById,
existingUser,
} from "../helpers/v1projecthelperFns.ts";
interface ISearchUser {
searchName: string;
userId: string;
organization: string;
projectId: string;
}
interface ShareUserResult {
userName: string;
Email: string;
profilePicture?: string;
}
export const ShareUserSearch = async (
data: ISearchUser
): Promise<{
status: string;
data?: object;
}> => {
const { userId, organization, searchName, projectId } = data;
try {
if (!(await existingUser(userId, organization)))
return { status: "User not found" };
if (!(await existingProjectById(projectId, organization, userId)))
return { status: "Project not found" };
const UsersData = await AuthModel(organization).find({
Email: { $regex: `${searchName}`, $options: "i" },
isArchive: false,
});
if (!UsersData || UsersData.length === 0)
return { status: "Project not found" };
const results = await Promise.all(
UsersData.map(async (user) => {
const profile = await UsersDataModel(organization)
.findOne({ userId: user._id, isArchive: false })
.select("profilePicture");
return {
userName: user.userName,
Email: user.Email,
profilePicture: profile?.profilePicture,
};
})
);
return { status: "Success", data: results };
} catch (error: unknown) {
if (error instanceof Error) {
return {
status: error.message,
};
} else {
return {
status: "An unexpected error occurred",
};
}
}
};

View File

@@ -11,7 +11,7 @@ interface Iserviceuser {
userName: string;
Email: string;
Password: string;
profilePicture: string;
profilePicture?: string;
}
interface IloginUser {
Email: string;
@@ -64,7 +64,7 @@ export const AuthSignup = async (
Email: caseChange,
Password: hashPassword,
});
await UsersDataModel(organization).create({
await UsersDataModel(organization).create({
userId: newuser._id,
role: role,
isShare: isShare,

View File

@@ -5,11 +5,11 @@ import {
} from "../helpers/v1projecthelperFns.ts";
interface EnvironmentInput {
roofVisibility: boolean;
wallVisibility: boolean;
shadowVisibility: boolean;
renderDistance: number;
limitDistance: boolean;
roofVisibility?: boolean;
wallVisibility?: boolean;
shadowVisibility?: boolean;
renderDistance?: number;
limitDistance?: boolean;
organization: string;
projectId: string;
userId: string;
@@ -43,6 +43,7 @@ export const setEnvironment = async (
if (!LivingProject) return { status: "Project not found" };
const findvalue = await environmentModel(organization).findOne({
userId: userId,
projectId: projectId,
isArchive: false,
});
if (findvalue) {
@@ -95,13 +96,21 @@ export const getEnvironment = async (
);
if (!LivingProject) return { status: "Project not found" };
const findValue = await environmentModel(organization).findOne({
userId: userId,
projectId: projectId,
isArchive: false,
});
const findValue = await environmentModel(organization)
.findOne({
userId: userId,
projectId: projectId,
isArchive: false,
})
.select(
"limitDistance projectId renderDistance roofVisibility shadowVisibility wallVisibility _id"
);
if (!findValue) {
return { status: "Environment Not found for the User" };
const newValue = await environmentModel(organization).create({
userId,
projectId,
});
return { status: "Environment Not found for the User", data: newValue };
} else {
return { status: "Success", data: findValue };
}

View File

@@ -80,6 +80,7 @@ export const setAssetModel = async (
userId: userId,
isArchive: false,
});
console.log("findvalue: ", findvalue);
if (findvalue) {
const updatevalue = await assetModel(organization).findOneAndUpdate(
{
@@ -439,11 +440,11 @@ export const getFloorItems = async (
);
if (!LivingProject) return { status: "Project not found" };
const findValues = await assetModel(organization)
.find({ isArchive: false })
.find({ isArchive: false, projectId: projectId })
.select("-_id -isArchive");
if (!findValues || findValues.length === 0) {
return { status: "floorItems not found" };
return { status: "floorItems not found", data: [] };
}
const response = findValues.map((item) => {

View File

@@ -25,14 +25,8 @@ export const SetCamera = async (
data: IcameraData
): Promise<{ status: string; data?: Object }> => {
try {
const {
userId,
position,
target,
rotation,
organization,
projectId
} = data;
const { userId, position, target, rotation, organization, projectId } =
data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const LivingProject = await existingProjectById(
@@ -43,6 +37,7 @@ export const SetCamera = async (
if (!LivingProject) return { status: "Project not found" };
const existingCamera = await cameraModel(organization).findOne({
userId: userId,
projectId: projectId,
isArchive: false,
});
if (existingCamera) {
@@ -98,7 +93,7 @@ export const GetCamers = async (
isArchive: false,
});
if (!findCamera) {
return { status: "Camera not found" };
return { status: "Camera not found", data: [] };
} else {
return { status: "Success", data: findCamera };
}

View File

@@ -1,5 +1,8 @@
import lineModel from "../../V1Models/Builder/linesModel.ts";
import { existingProjectById, existingUser } from "../helpers/v1projecthelperFns.ts";
import {
existingProjectById,
existingUser,
} from "../helpers/v1projecthelperFns.ts";
interface ILineItems {
organization: string;
layer: number;
@@ -83,7 +86,7 @@ export const UpdateLineItems = async (
userId
);
if (!LivingProject) return { status: "Project not found" };
const updateResult= await lineModel(organization).updateMany(
const updateResult = await lineModel(organization).updateMany(
{ "line.uuid": uuid, projectId: projectId },
{ $set: { "line.$.position": position } }
);
@@ -117,14 +120,15 @@ export const DeleteLineItems = async (
userId
);
if (!LivingProject) return { status: "Project not found" };
const inputUuids = line.map((item: any) => item.uuid);
const inputUuids = line.map((item: any) => {
return item.uuid;
});
const findValue = await lineModel(organization).findOneAndDelete(
{ projectId: projectId, isArchive: false },
{
"line.uuid": { $all: inputUuids },
}
);
const findValue = await lineModel(organization).findOneAndDelete({
projectId,
isArchive: false,
"line.uuid": { $all: inputUuids },
});
if (!findValue) {
return {
@@ -153,6 +157,7 @@ export const DeleteLayer = async (
): Promise<{ status: string; data?: object }> => {
try {
const { organization, projectId, layer, userId } = data;
console.log("data: ", data);
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const LivingProject = await existingProjectById(
@@ -171,7 +176,7 @@ export const DeleteLayer = async (
return { status: "layer not found" };
} else {
await lineModel(organization).deleteMany(
{ projectId: projectId },
{ projectId: projectId, layer: layer, isArchive: false },
{ layer: layer }
);
@@ -209,7 +214,7 @@ export const GetLinesService = async (
isArchive: false,
});
if (!findValue) {
return { status: "user not found" };
return { status: "Line not found", data: [] };
} else {
return { status: "Success", data: findValue };
}
@@ -227,7 +232,7 @@ export const GetLinesService = async (
};
export const DeleteLinePoints = async (
data: ILinePointsDelete
): Promise<{ status: string; data?: object }> => {
): Promise<{ status: string; data?: object | string }> => {
try {
const { organization, projectId, uuid, userId } = data;
const UserExists = await existingUser(userId, organization);
@@ -239,7 +244,7 @@ export const DeleteLinePoints = async (
);
if (!LivingProject) return { status: "Project not found" };
const findValue = await lineModel(organization).deleteMany(
{ projectId: projectId, isArchive: false },
{ projectId: projectId, isArchive: false, "line.uuid": uuid },
{
"line.uuid": uuid,
}
@@ -248,7 +253,7 @@ export const DeleteLinePoints = async (
if (!findValue) {
return { status: "Line not found" };
} else {
return { status: "Success" };
return { status: "Success", data: uuid };
}
} catch (error: unknown) {
if (error instanceof Error) {

View File

@@ -1,5 +1,8 @@
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
import { existingProjectById, existingUser } from "../helpers/v1projecthelperFns.ts";
import {
existingProjectById,
existingUser,
} from "../helpers/v1projecthelperFns.ts";
interface IWallSetupData {
modelUuid: string;
modelName: string;
@@ -29,7 +32,9 @@ interface IWallItemResult {
data?: Object;
status: string;
}
export const setWallItems = async (data: IWallSetupData): Promise<IWallItemResult> => {
export const setWallItems = async (
data: IWallSetupData
): Promise<IWallItemResult> => {
try {
const {
userId,
@@ -86,6 +91,7 @@ export const setWallItems = async (data: IWallSetupData): Promise<IWallItemResul
quaternion,
scale,
});
console.log("newValue: ", newValue);
return {
status: "wall Item created successfully",
data: newValue,
@@ -102,7 +108,7 @@ export const setWallItems = async (data: IWallSetupData): Promise<IWallItemResul
};
}
}
}
};
export const getWallItems = async (data: IWallGet) => {
try {
const { organization, userId, projectId } = data;
@@ -120,6 +126,7 @@ export const getWallItems = async (data: IWallGet) => {
if (!findValue) {
return {
status: "wallitems not found",
data: [],
};
} else {
return {
@@ -138,8 +145,10 @@ export const getWallItems = async (data: IWallGet) => {
};
}
}
}
export const deleteWallItems = async (data: IWallDelete): Promise<IWallItemResult> => {
};
export const deleteWallItems = async (
data: IWallDelete
): Promise<IWallItemResult> => {
try {
const { modelUuid, modelName, organization, userId, projectId } = data;
const UserExists = await existingUser(userId, organization);
@@ -176,4 +185,4 @@ export const deleteWallItems = async (data: IWallDelete): Promise<IWallItemResul
};
}
}
}
};

View File

@@ -4,7 +4,10 @@ import floatWidgetModel from "../../V1Models/Vizualization/floatWidget.ts";
import panelModel from "../../V1Models/Vizualization/panelmodel.ts";
import templateModel from "../../V1Models/Vizualization/templatemodel.ts";
import widgetModel from "../../V1Models/Vizualization/widgemodel.ts";
import { existingProjectById, existingUser } from "../helpers/v1projecthelperFns.ts";
import {
existingProjectById,
existingUser,
} from "../helpers/v1projecthelperFns.ts";
interface ISetZone {
organization: string;
projectId: string;
@@ -119,12 +122,16 @@ export const DelZone = async (data: IZone): Promise<IResult> => {
if (!LivingProject) return { status: "Project not found" };
if (findZoneId) {
const deleteZone = await zoneModel(organization)
.findOneAndUpdate({
zoneUuid: zoneUuid,
createdBy: userId,
projectId: projectId,
isArchive: false,
},{isArchive:true},{new:true})
.findOneAndUpdate(
{
zoneUuid: zoneUuid,
createdBy: userId,
projectId: projectId,
isArchive: false,
},
{ isArchive: true },
{ new: true }
)
.select("-_id -__v");
if (deleteZone) {
const panels = await panelModel(organization).find({

View File

@@ -84,7 +84,6 @@ export const existingProjectById = async (
) => {
const projectData = await projectModel(organization).findOne({
_id: projectId,
createdBy: userId,
isArchive: false,
});
return projectData;

View File

@@ -114,7 +114,7 @@ export const GetAllProjects = async (data: GetProjectsInterface) => {
const { userId, organization } = data;
await existingUser(userId, organization);
if (!existingUser) return { status: "User not found" };
let filter = { isArchive: false } as RoleFilter;
let filter = { isArchive: false, createdBy: userId } as RoleFilter;
const projectDatas = await projectModel(organization)
.find(filter)

View File

@@ -44,7 +44,6 @@ export const RecentlyAdded = async (data: IRecentData) => {
);
const filteredProjects = RecentDatas.filter(Boolean);
console.log("filteredProjects: ", filteredProjects);
return { status: "Success", data: filteredProjects };
} catch (error) {
return { status: error };

View File

@@ -171,13 +171,17 @@ export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
try {
const { organization, floatWidgetID, zoneUuid, projectId, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) { return { status: "User not found" } }
if (!UserExists) {
return { status: "User not found" };
}
const LivingProject = await existingProjectById(
projectId,
organization,
userId
);
if (!LivingProject) { return { status: "Project not found" } }
if (!LivingProject) {
return { status: "Project not found" };
}
const existingZone = await zoneModel(organization).findOne({
zoneUuid: zoneUuid,
isArchive: false,
@@ -224,13 +228,17 @@ export const DuplicateFloat = async (
try {
const { organization, widget, zoneUuid, index, projectId, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) {return { status: "User not found" }};
if (!UserExists) {
return { status: "User not found" };
}
const LivingProject = await existingProjectById(
projectId,
organization,
userId
);
if (!LivingProject) {return { status: "Project not found" }};
if (!LivingProject) {
return { status: "Project not found" };
}
const existingZone = await zoneModel(organization).findOne({
zoneUuid: zoneUuid,
isArchive: false,
@@ -332,13 +340,17 @@ export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
try {
const { organization, zoneUuid, projectId, userId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) {return { status: "User not found" }}
if (!UserExists) {
return { status: "User not found" };
}
const LivingProject = await existingProjectById(
projectId,
organization,
userId
);
if (!LivingProject) {return { status: "Project not found" }};
if (!LivingProject) {
return { status: "Project not found" };
}
const existingZone = await zoneModel(organization).findOne({
zoneUuid: zoneUuid,
isArchive: false,