builder,vizualization socket functionality completed
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import lineModel from "../../V1Models/Builder/linesModel.ts";
|
||||
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
import { existingProjectById, existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
interface ILineItems {
|
||||
organization: string;
|
||||
layer: number;
|
||||
@@ -45,6 +45,12 @@ export const CreateLineItems = async (
|
||||
const { organization, line, type, layer, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const newLine = await lineModel(organization).create({
|
||||
layer,
|
||||
line,
|
||||
@@ -71,7 +77,13 @@ export const UpdateLineItems = async (
|
||||
const { organization, projectId, uuid, position, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const updateResult = await lineModel(organization).updateMany(
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const updateResult= await lineModel(organization).updateMany(
|
||||
{ "line.uuid": uuid, projectId: projectId },
|
||||
{ $set: { "line.$.position": position } }
|
||||
);
|
||||
@@ -99,6 +111,12 @@ export const DeleteLineItems = async (
|
||||
const { organization, projectId, line, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const inputUuids = line.map((item: any) => item.uuid);
|
||||
|
||||
const findValue = await lineModel(organization).findOneAndDelete(
|
||||
@@ -137,6 +155,12 @@ export const DeleteLayer = async (
|
||||
const { organization, projectId, layer, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findValue = await lineModel(organization).find({
|
||||
layer: layer,
|
||||
projectId: projectId,
|
||||
@@ -208,6 +232,12 @@ export const DeleteLinePoints = async (
|
||||
const { organization, projectId, uuid, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findValue = await lineModel(organization).deleteMany(
|
||||
{ projectId: projectId, isArchive: false },
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
|
||||
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
import { existingProjectById, existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
interface IWallSetupData {
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
@@ -29,138 +29,153 @@ interface IWallItemResult {
|
||||
data?: Object;
|
||||
status: string;
|
||||
}
|
||||
export class WallItems {
|
||||
static async setWallItems(data: IWallSetupData): Promise<IWallItemResult> {
|
||||
try {
|
||||
const {
|
||||
userId,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
projectId,
|
||||
organization,
|
||||
} = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const findvalue = await wallItemModel(organization).findOne({
|
||||
modelUuid: modelUuid,
|
||||
isArchive: false,
|
||||
});
|
||||
export const setWallItems = async (data: IWallSetupData): Promise<IWallItemResult> => {
|
||||
try {
|
||||
const {
|
||||
userId,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
projectId,
|
||||
organization,
|
||||
} = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findvalue = await wallItemModel(organization).findOne({
|
||||
modelUuid: modelUuid,
|
||||
});
|
||||
|
||||
if (findvalue) {
|
||||
const updatevalue = await wallItemModel(organization).findOneAndUpdate(
|
||||
{ modelUuid: modelUuid, projectId: projectId, isArchive: false },
|
||||
{
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
return {
|
||||
status: "Updated successfully",
|
||||
data: updatevalue,
|
||||
};
|
||||
} else {
|
||||
const newValue = await wallItemModel(organization).create({
|
||||
modelUuid,
|
||||
if (findvalue) {
|
||||
const updatevalue = await wallItemModel(organization).findOneAndUpdate(
|
||||
{ modelUuid: modelUuid, projectId: projectId },
|
||||
{
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
projectId,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
});
|
||||
return {
|
||||
status: "wall Item created successfully",
|
||||
data: newValue,
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
static async getWallItems(data: IWallGet) {
|
||||
try {
|
||||
const { organization, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const findValue = await wallItemModel(organization).find({
|
||||
projectId: projectId,
|
||||
isArchive: false,
|
||||
},
|
||||
{ new: true } // Return the updated document
|
||||
);
|
||||
return {
|
||||
status: "Updated successfully",
|
||||
data: updatevalue,
|
||||
};
|
||||
// res.status(201).json(updatevalue);
|
||||
} else {
|
||||
const newValue = await wallItemModel(organization).create({
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
projectId,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
});
|
||||
if (!findValue) {
|
||||
return {
|
||||
status: "wallitems not found",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "Success",
|
||||
data: findValue,
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: "wall Item created successfully",
|
||||
data: newValue,
|
||||
};
|
||||
// res.status(201).json(newValue);
|
||||
}
|
||||
}
|
||||
static async deleteWallItems(data: IWallDelete): Promise<IWallItemResult> {
|
||||
try {
|
||||
const { modelUuid, modelName, organization, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const findValue = await wallItemModel(organization).findOneAndDelete({
|
||||
modelUuid: modelUuid,
|
||||
modelName: modelName,
|
||||
projectId: projectId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (!findValue) {
|
||||
return {
|
||||
status: "model not found",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "Success",
|
||||
data: findValue,
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
export const getWallItems = async (data: IWallGet) => {
|
||||
try {
|
||||
const { organization, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findValue = await wallItemModel(organization).find({
|
||||
projectId: projectId,
|
||||
});
|
||||
if (!findValue) {
|
||||
return {
|
||||
status: "wallitems not found",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "Success",
|
||||
data: findValue,
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
export const deleteWallItems = async (data: IWallDelete): Promise<IWallItemResult> => {
|
||||
try {
|
||||
const { modelUuid, modelName, organization, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findValue = await wallItemModel(organization).findOneAndDelete({
|
||||
modelUuid: modelUuid,
|
||||
modelName: modelName,
|
||||
projectId: projectId,
|
||||
});
|
||||
if (!findValue) {
|
||||
return {
|
||||
status: "model not found",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "Success",
|
||||
data: findValue,
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ 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 { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
import { existingProjectById, existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
interface ISetZone {
|
||||
organization: string;
|
||||
projectId: string;
|
||||
@@ -50,6 +50,12 @@ export const SetZone = async (data: ISetZone): Promise<IResult> => {
|
||||
const viewPortposition = zoneData.viewPortposition;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findZoneId = await zoneModel(organization).findOne({
|
||||
projectId: projectId,
|
||||
zoneId: zoneId,
|
||||
@@ -105,6 +111,12 @@ export const DelZone = async (data: IZone): Promise<IResult> => {
|
||||
});
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
if (findZoneId) {
|
||||
const deleteZone = await zoneModel(organization)
|
||||
.findOneAndDelete({
|
||||
@@ -203,6 +215,12 @@ export const ZoneData = async (data: IZone): Promise<IResult> => {
|
||||
const { organization, userId, projectId, zoneId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const findZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
projectId: projectId,
|
||||
@@ -233,6 +251,12 @@ export const SingleZonePanelData = async (data: IZone): Promise<IResult> => {
|
||||
const { organization, userId, projectId, zoneId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZone = await zoneModel(organization)
|
||||
.findOne({
|
||||
projectId: projectId,
|
||||
@@ -301,6 +325,12 @@ export const VizZoneDatas = async (data: IVizZone): Promise<IResult> => {
|
||||
const { organization, userId, projectId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
projectId,
|
||||
organization,
|
||||
userId
|
||||
);
|
||||
if (!LivingProject) return { status: "Project not found" };
|
||||
const existingZones = await zoneModel(organization)
|
||||
.find({
|
||||
projectId: projectId,
|
||||
|
||||
Reference in New Issue
Block a user