Controller and routing for the Vizualtion and builder
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
import { Response } from "express";
|
||||
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
getEnvironment,
|
||||
setEnvironment,
|
||||
} from "../../../../shared/services/builder/EnvironmentService.ts";
|
||||
|
||||
export const SetEnvironmentController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const {
|
||||
roofVisibility,
|
||||
renderDistance,
|
||||
limitDistance,
|
||||
wallVisibility,
|
||||
shadowVisibility,
|
||||
projectId,
|
||||
} = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!userId ||
|
||||
!roofVisibility ||
|
||||
!wallVisibility ||
|
||||
!renderDistance ||
|
||||
!limitDistance ||
|
||||
!shadowVisibility ||
|
||||
!projectId
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
roofVisibility,
|
||||
wallVisibility,
|
||||
shadowVisibility,
|
||||
organization,
|
||||
projectId,
|
||||
userId,
|
||||
renderDistance,
|
||||
limitDistance,
|
||||
};
|
||||
const result = await setEnvironment(data);
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "environments updated":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
case "Success":
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const GetEnvironmentController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !userId || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
organization,
|
||||
projectId,
|
||||
userId,
|
||||
};
|
||||
const result = await getEnvironment(data);
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "Environment Not found for the User":
|
||||
res.status(404).json({
|
||||
message: "Environment Not found for the User",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,277 @@
|
||||
import { Response } from "express";
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
CreateLineItems,
|
||||
DeleteLayer,
|
||||
DeleteLineItems,
|
||||
DeleteLinePoints,
|
||||
GetLinesService,
|
||||
UpdateLineItems,
|
||||
} from "../../../../shared/services/builder/lineService.ts";
|
||||
|
||||
export const NewLineController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { line, type, layer, projectId } = req.body;
|
||||
if (!organization || !userId || !line || !type || !layer || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
line,
|
||||
type,
|
||||
layer,
|
||||
projectId,
|
||||
organization,
|
||||
userId,
|
||||
};
|
||||
const result = await CreateLineItems(data);
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const UpdateLineController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { uuid, position, projectId } = req.body;
|
||||
if (!organization || !userId || !uuid || !position || projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await UpdateLineItems({
|
||||
organization,
|
||||
projectId,
|
||||
uuid,
|
||||
position,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const DeleteLineController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId, line } = req.body;
|
||||
if (!organization || !userId || !projectId || !line) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await DeleteLineItems({
|
||||
organization,
|
||||
projectId,
|
||||
line,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "line not found":
|
||||
res.status(404).json({
|
||||
message: "data not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const DeleteLayerController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId, layer } = req.body;
|
||||
if (!organization || !userId || !projectId || !layer) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await DeleteLayer({
|
||||
organization,
|
||||
projectId,
|
||||
layer,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "layer not found":
|
||||
res.status(404).json({
|
||||
message: "data not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const DeleteLinePointsController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId, uuid } = req.body;
|
||||
if (!organization || !userId || !projectId || !uuid) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await DeleteLinePoints({
|
||||
organization,
|
||||
projectId,
|
||||
uuid,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Line not found":
|
||||
res.status(404).json({
|
||||
message: "data not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const GetLinesController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !userId || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await GetLinesService({
|
||||
organization,
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
import { Response } from "express";
|
||||
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
deleteAssetModel,
|
||||
getFloorItems,
|
||||
replaceEventDatas,
|
||||
setAssetModel,
|
||||
updateAssetPositionRotation,
|
||||
} from "../../../../shared/services/builder/assetService.ts";
|
||||
|
||||
export const CreateAssetController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const {
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
rotation,
|
||||
eventData,
|
||||
modelfileID,
|
||||
isLocked,
|
||||
isVisible,
|
||||
projectId,
|
||||
} = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!userId ||
|
||||
!isLocked ||
|
||||
!isVisible ||
|
||||
!position ||
|
||||
!rotation ||
|
||||
!modelfileID ||
|
||||
!modelName ||
|
||||
!projectId ||
|
||||
!modelUuid
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
organization,
|
||||
userId,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
rotation,
|
||||
eventData,
|
||||
modelfileID,
|
||||
isLocked,
|
||||
isVisible,
|
||||
projectId,
|
||||
};
|
||||
const result = await setAssetModel(data);
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(200).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(200).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "Updated successfully":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
message: "Model stored successfully",
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const DeleteAssetController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { modelUuid, modelName, projectId } = req.body;
|
||||
if (!organization || !userId || !modelUuid || !projectId || !modelName) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await deleteAssetModel({
|
||||
organization,
|
||||
modelName,
|
||||
modelUuid,
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "model not found":
|
||||
res.status(404).json({
|
||||
message: "Model not found",
|
||||
});
|
||||
break;
|
||||
case "Failed to archive asset":
|
||||
res.status(200).json({
|
||||
message: "Failed to archive asset",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
message: "Asset Deleted successfully",
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const GetAssetController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !userId || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await getFloorItems({
|
||||
organization,
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "floorItems not found":
|
||||
res.status(404).json({
|
||||
message: "floorItems not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const ReplaceEventDataController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { modelUuid, eventData, projectId } = req.body;
|
||||
if (!organization || !userId || !projectId || !modelUuid || !eventData) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await replaceEventDatas({
|
||||
modelUuid,
|
||||
organization,
|
||||
eventData,
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "Model not for this UUID":
|
||||
res.status(404).json({
|
||||
message: "Model not for this UUID",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({ message: "Data updated successfully" });
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const AssetUpdatePosRotController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const {
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
rotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
projectId,
|
||||
} = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!userId ||
|
||||
!isLocked ||
|
||||
!isVisible ||
|
||||
!position ||
|
||||
!rotation ||
|
||||
!modelName ||
|
||||
!projectId ||
|
||||
!modelUuid
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await updateAssetPositionRotation({
|
||||
organization,
|
||||
userId,
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
rotation,
|
||||
isLocked,
|
||||
isVisible,
|
||||
projectId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "Asset not found":
|
||||
res.status(404).json({
|
||||
message: "Asset not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({ message: "Asset updated successfully" });
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Request, Response } from "express";
|
||||
import { Response } from "express";
|
||||
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
GetCamers,
|
||||
onlineActiveDatas,
|
||||
SetCamera,
|
||||
} from "../../../../shared/services/builder/cameraService.ts";
|
||||
|
||||
@@ -75,6 +76,7 @@ export const CameraList = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !userId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
@@ -84,6 +86,7 @@ export const CameraList = async (
|
||||
const result = await GetCamers({
|
||||
organization,
|
||||
userId,
|
||||
projectId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
@@ -110,3 +113,41 @@ export const CameraList = async (
|
||||
});
|
||||
}
|
||||
};
|
||||
export const ActiveOnlineController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
if (!organization || !userId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await onlineActiveDatas({
|
||||
organization,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Request, Response } from "express";
|
||||
import { Response } from "express";
|
||||
import { WallItems } from "../../../../shared/services/builder/wallService.ts";
|
||||
import { error } from "console";
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
|
||||
export const WallSetup = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
@@ -18,7 +17,6 @@ export const WallSetup = async (
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
// versionId
|
||||
projectId,
|
||||
} = req.body;
|
||||
if (
|
||||
@@ -29,10 +27,10 @@ export const WallSetup = async (
|
||||
!projectId ||
|
||||
!csgscale ||
|
||||
!csgposition ||
|
||||
// !versionId ||
|
||||
!quaternion ||
|
||||
!scale ||
|
||||
!organization
|
||||
!organization ||
|
||||
!userId
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required!",
|
||||
@@ -42,7 +40,6 @@ export const WallSetup = async (
|
||||
const result = await WallItems.setWallItems({
|
||||
projectId,
|
||||
modelUuid,
|
||||
// versionId,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
@@ -51,13 +48,17 @@ export const WallSetup = async (
|
||||
quaternion,
|
||||
scale,
|
||||
organization,
|
||||
userId,
|
||||
});
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({ message: "User not found" });
|
||||
break;
|
||||
case "Updated successfully":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
case "wall Item created successfully":
|
||||
res.status(200).json(result.data);
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json(error);
|
||||
@@ -75,9 +76,9 @@ export const WallGet = async (
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !role || !userId || !projectId) {
|
||||
if (!organization || !userId || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
@@ -85,21 +86,21 @@ export const WallGet = async (
|
||||
}
|
||||
const result = await WallItems.getWallItems({
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
projectId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({ message: "User not found" });
|
||||
break;
|
||||
case "wallitems not found":
|
||||
res.status(404).json({
|
||||
message: "wallitems not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
WallItems: result.data,
|
||||
});
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
@@ -118,16 +119,9 @@ export const WallDelete = async (
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId, modelName, modelUuid } = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!role ||
|
||||
!userId ||
|
||||
!projectId ||
|
||||
!modelName ||
|
||||
!modelUuid
|
||||
) {
|
||||
if (!organization || !userId || !projectId || !modelName || !modelUuid) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
@@ -135,7 +129,6 @@ export const WallDelete = async (
|
||||
}
|
||||
const result = await WallItems.deleteWallItems({
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
projectId,
|
||||
modelName,
|
||||
@@ -143,15 +136,16 @@ export const WallDelete = async (
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({ message: "User not found" });
|
||||
break;
|
||||
case "model not found":
|
||||
res.status(404).json({
|
||||
message: "model not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
message: "WallItem deleted",
|
||||
});
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
|
||||
@@ -1,61 +1,51 @@
|
||||
import { Request, Response } from "express";
|
||||
|
||||
import { Response } from "express";
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
GetCamers,
|
||||
SetCamera,
|
||||
} from "../../../../shared/services/builder/cameraService.ts";
|
||||
DelZone,
|
||||
GetZones,
|
||||
SetZone,
|
||||
SingleZonePanelData,
|
||||
VizZoneDatas,
|
||||
ZoneData,
|
||||
} from "../../../../shared/services/builder/zoneService.ts";
|
||||
|
||||
export const SetNewCamera = async (
|
||||
export const CreateZoneController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
const { position, target, rotation, projectId, versionId } = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!role ||
|
||||
!userId ||
|
||||
!position ||
|
||||
!target ||
|
||||
!rotation ||
|
||||
!projectId ||
|
||||
!versionId
|
||||
) {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { zoneData, projectId } = req.body;
|
||||
if (!organization || !userId || !zoneData || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
position,
|
||||
target,
|
||||
rotation,
|
||||
zoneData,
|
||||
projectId,
|
||||
versionId,
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
};
|
||||
const result = await SetCamera(data);
|
||||
const result = await SetZone(data);
|
||||
|
||||
switch (result.status) {
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
TrashDatas: [],
|
||||
case "User not found":
|
||||
res.status(200).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
|
||||
case "Update Success":
|
||||
case "zone updated":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
message: "zone updated",
|
||||
ZoneData: result.data,
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
message: "zone created",
|
||||
ZoneData: result.data,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
@@ -71,29 +61,35 @@ export const SetNewCamera = async (
|
||||
});
|
||||
}
|
||||
};
|
||||
export const CameraList = async (
|
||||
export const DeleteZoneController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
if (!organization || !role || !userId) {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { zoneId, projectId } = req.body;
|
||||
if (!organization || !userId || !zoneId || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await GetCamers({
|
||||
const result = await DelZone({
|
||||
organization,
|
||||
role,
|
||||
zoneId,
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "Project not found":
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
TrashDatas: [],
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Invalid zone ID":
|
||||
res.status(404).json({
|
||||
message: "Zone not found for the UUID",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
@@ -113,3 +109,186 @@ export const CameraList = async (
|
||||
});
|
||||
}
|
||||
};
|
||||
export const GetZoneController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !userId || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await GetZones({
|
||||
organization,
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Invalid zone":
|
||||
res.status(404).json({
|
||||
message: "Zone not found for the UUID",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const VizZoneController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !userId || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await VizZoneDatas({
|
||||
organization,
|
||||
projectId,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Zone not found for the UUID":
|
||||
res.status(404).json({
|
||||
message: "Zone not found for the UUID",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const ZoneDataController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId, zoneId } = req.params;
|
||||
if (!organization || !userId || !projectId || !zoneId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await ZoneData({
|
||||
organization,
|
||||
projectId,
|
||||
userId,
|
||||
zoneId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Zone not found":
|
||||
res.status(404).json({
|
||||
message: "Zone not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const SingleZonePanelController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId, zoneId } = req.params;
|
||||
if (!organization || !userId || !projectId || !zoneId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await SingleZonePanelData({
|
||||
organization,
|
||||
projectId,
|
||||
userId,
|
||||
zoneId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Zone not found for the UUID":
|
||||
res.status(404).json({
|
||||
message: "Zone not found for the UUID",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user