bugs cleared for the testing purpose
This commit is contained in:
12
.env
12
.env
@@ -1,10 +1,14 @@
|
||||
|
||||
MONGO_URI=mongodb://mongo/
|
||||
MONGO_USER=admin
|
||||
MONGO_PASSWORD=admin321
|
||||
# MONGO_URI=mongodb://mongo/
|
||||
# MONGO_USER=admin
|
||||
# MONGO_PASSWORD=admin321
|
||||
# MONGO_AUTH_DB=admin
|
||||
|
||||
MONGO_URI=mongodb://192.168.0.110/
|
||||
MONGO_USER=mydata
|
||||
MONGO_PASSWORD=mongodb@hexr2002
|
||||
MONGO_AUTH_DB=admin
|
||||
|
||||
|
||||
API_PORT=5000
|
||||
SOCKET_PORT=8000
|
||||
NODE_ENV=development
|
||||
|
||||
@@ -3,7 +3,7 @@ ARG NODE_VERSION=lts
|
||||
FROM node:${NODE_VERSION}-alpine AS development
|
||||
# Use production node environment by default.
|
||||
|
||||
ENV NODE_ENV = development
|
||||
ENV NODE_ENV=development
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export const SignupController = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
console.log("req.body: ", req.body);
|
||||
const { userName, Email, Password, profilePicture } = req.body;
|
||||
const { userName, Email, Password } = req.body;
|
||||
if (!userName || !Email || !Password) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
|
||||
@@ -13,15 +13,14 @@ export const SetNewCamera = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { position, target, rotation, projectId, versionId } = req.body;
|
||||
const { position, target, rotation, projectId} = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!userId ||
|
||||
!position ||
|
||||
!target ||
|
||||
!rotation ||
|
||||
!projectId ||
|
||||
!versionId
|
||||
!projectId
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
@@ -33,7 +32,6 @@ export const SetNewCamera = async (
|
||||
target,
|
||||
rotation,
|
||||
projectId,
|
||||
versionId,
|
||||
organization,
|
||||
userId,
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export const createProjectController = async (
|
||||
const { userId, organization } = req.user || {};
|
||||
const { projectUuid, thumbnail } = req.body;
|
||||
|
||||
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||
if (!req.user?.userId || !req.user?.organization) {
|
||||
res.status(401).json({ message: "Unauthorized" });
|
||||
return;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ export const RemoveProject = async (
|
||||
try {
|
||||
const { projectId } = req.params;
|
||||
const { organization, userId } = req.user || {};
|
||||
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||
if (!req.user?.userId || !req.user?.organization) {
|
||||
res.status(401).json({ message: "Unauthorized" });
|
||||
return;
|
||||
}
|
||||
@@ -208,12 +208,7 @@ export const ViewData = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId, role } = req.user || {};
|
||||
if (
|
||||
!req.user ||
|
||||
!req.user.userId ||
|
||||
!req.user.organization ||
|
||||
!req.user.role
|
||||
) {
|
||||
if (!req.user?.userId || !req.user?.organization) {
|
||||
res.status(401).json({ message: "Unauthorized" });
|
||||
return;
|
||||
}
|
||||
@@ -269,7 +264,7 @@ export const ProjectDuplicateController = async (
|
||||
const { userId, organization } = req.user || {};
|
||||
const { projectUuid, thumbnail, projectName } = req.body;
|
||||
|
||||
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||
if (!req.user?.userId || !req.user?.organization) {
|
||||
res.status(401).json({ message: "Unauthorized" });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ export const AddWidgetController = async (
|
||||
res.status(404).json({
|
||||
message: "Zone not found",
|
||||
});
|
||||
break;
|
||||
case "panelName not found":
|
||||
res.status(404).json({
|
||||
message: "panelName not found",
|
||||
@@ -179,11 +180,6 @@ export const WidgetUpdateController = async (
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "Zone not found for the zoneId":
|
||||
res.status(404).json({
|
||||
message: "Zone not found for the zoneId",
|
||||
@@ -247,11 +243,6 @@ export const GetWidgetController = async (
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
});
|
||||
break;
|
||||
case "Zone not found for the zoneId":
|
||||
res.status(404).json({
|
||||
message: "Zone not found for the zoneId",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import express from "express";
|
||||
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
||||
import {
|
||||
recentDataController,
|
||||
searchProjectController,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import express from "express";
|
||||
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
||||
import {
|
||||
DeleteTrashData,
|
||||
GetTrashList,
|
||||
|
||||
@@ -35,7 +35,7 @@ import v1PanelRoutes from "./V1/v1Routes/vizRoutes.ts/v1-panelRoutes.ts";
|
||||
import v1Template from "./V1/v1Routes/vizRoutes.ts/v1-TemplateRoutes.ts";
|
||||
import v1Widget from "./V1/v1Routes/vizRoutes.ts/v1-widgetRoutes.ts";
|
||||
import v1Widget3d from "./V1/v1Routes/vizRoutes.ts/v1-widget3dRoutes.ts";
|
||||
redis;
|
||||
redis
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import MainModel from "../../connect/mongoose.ts";
|
||||
import { User } from "./userAuthModel.ts";
|
||||
export interface Token extends Document {
|
||||
userId: User["_id"];
|
||||
isArchive: Boolean;
|
||||
isArchive: boolean;
|
||||
refreshToken: string;
|
||||
resetTokenExpiry?: Date;
|
||||
resetToken: string;
|
||||
|
||||
@@ -13,14 +13,14 @@ export interface Camera extends Document {
|
||||
z: number;
|
||||
};
|
||||
target: {
|
||||
x: { type: Number; required: true };
|
||||
y: { type: Number; required: true };
|
||||
z: { type: Number; required: true };
|
||||
x: { type: number; required: true };
|
||||
y: { type: number; required: true };
|
||||
z: { type: number; required: true };
|
||||
};
|
||||
rotation: {
|
||||
x: { type: Number; required: true };
|
||||
y: { type: Number; required: true };
|
||||
z: { type: Number; required: true };
|
||||
x: { type: number; required: true };
|
||||
y: { type: number; required: true };
|
||||
z: { type: number; required: true };
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -125,12 +125,12 @@ interface StorageEventSchema extends AssetEventSchema {
|
||||
point: StoragePointSchema;
|
||||
}
|
||||
interface IPointModel extends Document {
|
||||
modelUuid: String;
|
||||
modelName: String;
|
||||
position: String;
|
||||
rotation: String;
|
||||
state: String;
|
||||
productId: String;
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
position: [number];
|
||||
rotation: [number];
|
||||
state: string;
|
||||
productId: string;
|
||||
isArchive: boolean;
|
||||
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
||||
speed: number;
|
||||
|
||||
@@ -6,7 +6,7 @@ import MainModel from "../../connect/mongoose.ts";
|
||||
interface IComment {
|
||||
userId: User["_id"];
|
||||
comment: string;
|
||||
timestamp:Number
|
||||
timestamp:number
|
||||
}
|
||||
export interface IThread extends Document {
|
||||
projectId: Project["_id"];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Schema, Document, model } from "mongoose";
|
||||
import { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Zone } from "../Builder/zoneModel.ts";
|
||||
export interface Widget3d extends Document {
|
||||
@@ -8,7 +8,7 @@ export interface Widget3d extends Document {
|
||||
position: [];
|
||||
rotation: [];
|
||||
isArchive: boolean;
|
||||
zoneId: string;
|
||||
zoneId: Zone["_id"];
|
||||
Data: {
|
||||
measurements: {};
|
||||
duration: string;
|
||||
@@ -21,7 +21,7 @@ const Widget3dSchema: Schema = new Schema(
|
||||
widgetName: { type: String, default: "Widget3D" },
|
||||
position: { type: Array },
|
||||
rotation: { type: Array },
|
||||
zoneId: { type: String },
|
||||
zoneId:{ type: Schema.Types.ObjectId, ref: "Zone" },
|
||||
Data: {
|
||||
measurements: { type: Object, default: {} },
|
||||
duration: { type: String, default: "1h" },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Schema, Document, model } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Zone } from "../Builder/zoneModel.ts";
|
||||
export interface FloatingWidget extends Document {
|
||||
className: string;
|
||||
@@ -10,7 +10,7 @@ export interface FloatingWidget extends Document {
|
||||
per: string;
|
||||
value: string;
|
||||
isArchive: boolean;
|
||||
zoneId: string;
|
||||
zoneId: Zone["_id"];
|
||||
Data: {
|
||||
measurements: {};
|
||||
duration: string;
|
||||
@@ -25,7 +25,7 @@ const floatingWidgetSchema: Schema = new Schema(
|
||||
position: { type: Object },
|
||||
per: { type: String },
|
||||
value: { type: String },
|
||||
zoneId: { type: String },
|
||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
||||
Data: {
|
||||
measurements: { type: Object, default: {} },
|
||||
duration: { type: String, default: "1h" },
|
||||
|
||||
@@ -2,14 +2,14 @@ import mongoose, { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Zone } from "../Builder/zoneModel.ts";
|
||||
export interface Panel extends Document {
|
||||
zoneId: string;
|
||||
zoneId: Zone["_id"];
|
||||
panelName: string;
|
||||
widgets: [mongoose.Types.ObjectId];
|
||||
isArchive: boolean;
|
||||
}
|
||||
const panelSchema: Schema = new Schema(
|
||||
{
|
||||
zoneId: { type: String },
|
||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
||||
panelName: { type: String },
|
||||
widgets: [{ type: mongoose.Schema.Types.ObjectId, ref: "Widget" }],
|
||||
isArchive: { type: Boolean, default: false },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import mongoose, { Schema, Document } from "mongoose";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
import { Zone } from "../Builder/zoneModel.ts";
|
||||
export interface widget extends Document {
|
||||
export interface Widget extends Document {
|
||||
widgetName: string;
|
||||
widgetside: string;
|
||||
widgetID: string;
|
||||
@@ -17,7 +17,7 @@ export interface widget extends Document {
|
||||
measurements: {};
|
||||
duration: string;
|
||||
};
|
||||
zoneId: string;
|
||||
zoneId: Zone["_id"];
|
||||
}
|
||||
const widgetSchema: Schema = new Schema(
|
||||
{
|
||||
@@ -36,7 +36,7 @@ const widgetSchema: Schema = new Schema(
|
||||
fontWeight: { type: String },
|
||||
isArchive: { type: Boolean, default: false },
|
||||
panelID: { type: mongoose.Schema.Types.ObjectId, ref: "Panel" },
|
||||
zoneId: { type: String },
|
||||
zoneId: { type: Schema.Types.ObjectId, ref: "Zone" },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import mongoose, { Schema, Connection, Model } from "mongoose";
|
||||
import { Client } from "minio";
|
||||
interface ConnectionCache {
|
||||
[key: string]: Connection;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Response, Request, NextFunction } from "express";
|
||||
import { Response, NextFunction } from "express";
|
||||
import { AuthenticatedRequest } from "../../shared/utils/token.ts";
|
||||
type Role = "Admin" | "User";
|
||||
const authorizedRoles = (...allowedRoles: Role[]) => {
|
||||
|
||||
@@ -20,7 +20,7 @@ interface IThread {
|
||||
}
|
||||
export const createThread = async (data: IThread) => {
|
||||
try {
|
||||
const { projectId, versionId, state, userId, position, rotation, comments, organization, threadId } = data
|
||||
const { projectId, state, userId, position, rotation, comments, organization } = data
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
if (!userExisting) {
|
||||
return {
|
||||
@@ -38,7 +38,6 @@ export const createThread = async (data: IThread) => {
|
||||
}
|
||||
const newThread = await ThreadModel(organization).create({
|
||||
projectId,
|
||||
versionId,
|
||||
state,
|
||||
createdBy: userId,
|
||||
position,
|
||||
@@ -58,7 +57,7 @@ export const createThread = async (data: IThread) => {
|
||||
}
|
||||
export const deleteThread = async (data: IThread) => {
|
||||
try {
|
||||
const { projectId, versionId, state, userId, organization, threadId } = data
|
||||
const { projectId, userId, organization, threadId } = data
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
if (!userExisting) {
|
||||
return {
|
||||
@@ -92,7 +91,7 @@ export const deleteThread = async (data: IThread) => {
|
||||
}
|
||||
export const addComments = async (data: IThread) => {
|
||||
try {
|
||||
const { projectId, versionId, userId, comments, organization, threadId } = data
|
||||
const { projectId, userId, comments, organization, threadId } = data
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
if (!userExisting) {
|
||||
return {
|
||||
@@ -125,7 +124,7 @@ export const addComments = async (data: IThread) => {
|
||||
}
|
||||
export const deleteComments = async (data: IThread) => {
|
||||
try {
|
||||
const { projectId, versionId, userId, commentId, organization, threadId } = data
|
||||
const { projectId, userId, commentId, organization, threadId } = data
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
if (!userExisting) {
|
||||
return {
|
||||
|
||||
@@ -64,7 +64,7 @@ export const AuthSignup = async (
|
||||
Email: caseChange,
|
||||
Password: hashPassword,
|
||||
});
|
||||
const UserDatas = await UsersDataModel(organization).create({
|
||||
await UsersDataModel(organization).create({
|
||||
userId: newuser._id,
|
||||
role: role,
|
||||
isShare: isShare,
|
||||
@@ -449,7 +449,7 @@ async function handleTokenCache(
|
||||
isArchive: false,
|
||||
});
|
||||
if (!tokenDoc) {
|
||||
tokenDoc = await tokenType(organization).create({ userId, refreshToken });
|
||||
await tokenType(organization).create({ userId, refreshToken });
|
||||
} else {
|
||||
await tokenType(organization).findByIdAndUpdate(
|
||||
tokenDoc._id,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
existingUser,
|
||||
} from "../helpers/v1projecthelperFns.ts";
|
||||
|
||||
interface setAssetInput {
|
||||
interface SetAssetInput {
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
position: [];
|
||||
@@ -50,7 +50,7 @@ interface ReplaceEventInput {
|
||||
modelUuid: string;
|
||||
}
|
||||
export const setAssetModel = async (
|
||||
data: setAssetInput
|
||||
data: SetAssetInput
|
||||
): Promise<{ status: string; data?: Object }> => {
|
||||
try {
|
||||
const {
|
||||
@@ -286,7 +286,7 @@ export const deleteAssetModel = async (
|
||||
status: "Failed to archive asset",
|
||||
};
|
||||
}
|
||||
const updatedEvents = await EventsDataModel(organization).updateMany(
|
||||
await EventsDataModel(organization).updateMany(
|
||||
{ modelUuid, productId: projectId },
|
||||
{ $set: { isArchive: true } }
|
||||
);
|
||||
@@ -342,7 +342,7 @@ export const replaceEventDatas = async (
|
||||
{ modelUuid, projectId, isArchive: false },
|
||||
{
|
||||
points: typedEventData?.points,
|
||||
type: typedEventData?.type || existingModel?.type,
|
||||
type: typedEventData?.type ?? existingModel?.type,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
@@ -11,7 +11,6 @@ interface IcameraData {
|
||||
rotation: Object;
|
||||
organization: string;
|
||||
projectId: string;
|
||||
versionId: string;
|
||||
}
|
||||
interface IgetCameras {
|
||||
organization: string;
|
||||
@@ -32,8 +31,7 @@ export const SetCamera = async (
|
||||
target,
|
||||
rotation,
|
||||
organization,
|
||||
projectId,
|
||||
versionId,
|
||||
projectId
|
||||
} = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
@@ -52,7 +50,6 @@ export const SetCamera = async (
|
||||
{
|
||||
userId: userId,
|
||||
projectId: projectId,
|
||||
versionId: versionId,
|
||||
isArchive: false,
|
||||
},
|
||||
{ position: position, target: target, rotation: rotation },
|
||||
@@ -66,7 +63,6 @@ export const SetCamera = async (
|
||||
const newCamera = await cameraModel(organization).create({
|
||||
userId,
|
||||
projectId,
|
||||
versionId,
|
||||
position,
|
||||
target,
|
||||
rotation,
|
||||
|
||||
@@ -14,7 +14,7 @@ interface IProject {
|
||||
createdAt: Date;
|
||||
isViewed?: number;
|
||||
}
|
||||
interface searchProjectInterface {
|
||||
interface SearchProjectInterface {
|
||||
searchName: string;
|
||||
userId: string;
|
||||
organization: string;
|
||||
@@ -50,7 +50,7 @@ export const RecentlyAdded = async (data: IRecentData) => {
|
||||
return { status: error };
|
||||
}
|
||||
};
|
||||
export const searchProject = async (data: searchProjectInterface) => {
|
||||
export const searchProject = async (data: SearchProjectInterface) => {
|
||||
try {
|
||||
const { userId, organization, searchName } = data;
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
@@ -66,7 +66,7 @@ export const searchProject = async (data: searchProjectInterface) => {
|
||||
return { status: error };
|
||||
}
|
||||
};
|
||||
export const searchTrashProject = async (data: searchProjectInterface) => {
|
||||
export const searchTrashProject = async (data: SearchProjectInterface) => {
|
||||
try {
|
||||
const { userId, organization, searchName } = data;
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
|
||||
@@ -4,7 +4,6 @@ import versionModel from "../../model/version/versionModel.ts";
|
||||
import {
|
||||
existingProject,
|
||||
existingUser,
|
||||
archiveProject,
|
||||
previousVersion,
|
||||
generateUntitledProjectName,
|
||||
} from "../helpers/ProjecthelperFn.ts";
|
||||
@@ -16,7 +15,7 @@ interface CreateProjectInput {
|
||||
sharedUsers?: string[];
|
||||
organization: string;
|
||||
}
|
||||
interface updateProjectInput {
|
||||
interface UpdateProjectInput {
|
||||
projectName: string;
|
||||
projectId: string;
|
||||
userId: string;
|
||||
@@ -130,7 +129,7 @@ export const DeleteProject = async (data: ProjectInterface) => {
|
||||
return { status: error };
|
||||
}
|
||||
};
|
||||
export const updateProject = async (data: updateProjectInput) => {
|
||||
export const updateProject = async (data: UpdateProjectInput) => {
|
||||
try {
|
||||
const { projectId, organization, userId, projectName, thumbnail } = data;
|
||||
const ExistingUser = await existingUser(userId, organization);
|
||||
@@ -141,8 +140,8 @@ export const updateProject = async (data: updateProjectInput) => {
|
||||
isArchive: false,
|
||||
});
|
||||
if (!existingProject) return { status: "Project not found" };
|
||||
if (projectName !== undefined) projectName;
|
||||
if (thumbnail !== undefined) thumbnail;
|
||||
if (projectName !== undefined) existingProject.projectName=projectName;
|
||||
if (thumbnail !== undefined) existingProject.thumbnail=thumbnail;
|
||||
const updateProject = await projectModel(organization)
|
||||
.findOneAndUpdate(
|
||||
{ _id: projectId, isArchive: false },
|
||||
|
||||
@@ -12,8 +12,8 @@ interface Iproduct {
|
||||
eventDatas: {
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
position: [Number];
|
||||
rotation: [Number];
|
||||
position: [number];
|
||||
rotation: [number];
|
||||
type: string;
|
||||
speed: string;
|
||||
point: Mixed;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import projectModel from "../../model/project/project-model.ts";
|
||||
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
interface IOrg {
|
||||
organization: string;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import versionModel from "../../V1Models/Version/versionModel.ts";
|
||||
import {
|
||||
existingProject,
|
||||
existingUser,
|
||||
archiveProject,
|
||||
previousVersion,
|
||||
generateUntitledProjectName,
|
||||
} from "../helpers/v1projecthelperFns.ts";
|
||||
@@ -11,7 +10,7 @@ import UsersDataModel from "../../V1Models/Auth/user.ts";
|
||||
interface CreateProjectInput {
|
||||
projectName: string;
|
||||
projectUuid: string;
|
||||
userId: string;
|
||||
userId: string;
|
||||
thumbnail?: string;
|
||||
sharedUsers?: string[];
|
||||
organization: string;
|
||||
@@ -19,15 +18,15 @@ interface CreateProjectInput {
|
||||
interface IProjectDuplicate {
|
||||
projectName: string;
|
||||
projectUuid: string;
|
||||
userId: string;
|
||||
userId: string;
|
||||
thumbnail?: string;
|
||||
sharedUsers?: string[];
|
||||
organization: string;
|
||||
}
|
||||
interface updateProjectInput {
|
||||
interface UpdateProjectInput {
|
||||
projectName: string;
|
||||
projectId: string;
|
||||
userId: string;
|
||||
userId: string;
|
||||
thumbnail?: string;
|
||||
sharedUsers?: string[];
|
||||
organization: string;
|
||||
@@ -112,7 +111,7 @@ export const createProject = async (data: CreateProjectInput) => {
|
||||
|
||||
export const GetAllProjects = async (data: GetProjectsInterface) => {
|
||||
try {
|
||||
const { userId, organization, role } = data;
|
||||
const { userId, organization } = data;
|
||||
await existingUser(userId, organization);
|
||||
if (!existingUser) return { status: "User not found" };
|
||||
let filter = { isArchive: false } as RoleFilter;
|
||||
@@ -147,9 +146,9 @@ export const DeleteProject = async (data: ProjectDelInterface) => {
|
||||
return { status: error };
|
||||
}
|
||||
};
|
||||
export const updateProject = async (data: updateProjectInput) => {
|
||||
export const updateProject = async (data: UpdateProjectInput) => {
|
||||
try {
|
||||
const { projectId, organization, userId, projectName, thumbnail, role } =
|
||||
const { projectId, organization, userId, projectName, thumbnail } =
|
||||
data;
|
||||
const ExistingUser = await existingUser(userId, organization);
|
||||
if (!ExistingUser) return { status: "User not found" };
|
||||
@@ -157,8 +156,8 @@ export const updateProject = async (data: updateProjectInput) => {
|
||||
|
||||
const existingProject = await projectModel(organization).findOne(filter);
|
||||
if (!existingProject) return { status: "Project not found" };
|
||||
if (projectName !== undefined) projectName;
|
||||
if (thumbnail !== undefined) thumbnail;
|
||||
if (projectName !== undefined) existingProject.projectName = projectName;
|
||||
if (thumbnail !== undefined) existingProject.thumbnail = thumbnail;
|
||||
const updateProject = await projectModel(organization)
|
||||
.findOneAndUpdate(
|
||||
filter,
|
||||
@@ -231,7 +230,7 @@ export const DuplicateProject = async (data: IProjectDuplicate) => {
|
||||
const maxLength: number = 6;
|
||||
export const viewProject = async (data: ProjectInterface) => {
|
||||
try {
|
||||
const { projectId, organization, userId, role } = data;
|
||||
const { projectId, organization, userId } = data;
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
if (!userExisting) return { status: "User not found" };
|
||||
const RecentUserDoc = await UsersDataModel(organization).findOne({
|
||||
@@ -257,7 +256,7 @@ export const viewProject = async (data: ProjectInterface) => {
|
||||
newArr.pop();
|
||||
}
|
||||
}
|
||||
const datas = await UsersDataModel(organization).findOneAndUpdate(
|
||||
await UsersDataModel(organization).findOneAndUpdate(
|
||||
{ userId: userId, isArchive: false },
|
||||
{ recentlyViewed: newArr },
|
||||
{ new: true }
|
||||
|
||||
@@ -15,18 +15,14 @@ interface IProject {
|
||||
createdAt: Date;
|
||||
isViewed?: number;
|
||||
}
|
||||
interface searchProjectInterface {
|
||||
interface SearchProjectInterface {
|
||||
searchName: string;
|
||||
userId: string;
|
||||
organization: string;
|
||||
}
|
||||
interface RoleFilter {
|
||||
isArchive: boolean;
|
||||
createdBy?: string;
|
||||
}
|
||||
export const RecentlyAdded = async (data: IRecentData) => {
|
||||
try {
|
||||
const { userId, organization, role } = data;
|
||||
const { userId, organization } = data;
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
if (!userExisting) return { status: "User not found" };
|
||||
const userRecentData = await UsersDataModel(organization)
|
||||
@@ -54,7 +50,7 @@ export const RecentlyAdded = async (data: IRecentData) => {
|
||||
return { status: error };
|
||||
}
|
||||
};
|
||||
export const searchProject = async (data: searchProjectInterface) => {
|
||||
export const searchProject = async (data: SearchProjectInterface) => {
|
||||
try {
|
||||
const { userId, organization, searchName } = data;
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
@@ -70,7 +66,7 @@ export const searchProject = async (data: searchProjectInterface) => {
|
||||
return { status: error };
|
||||
}
|
||||
};
|
||||
export const searchTrashProject = async (data: searchProjectInterface) => {
|
||||
export const searchTrashProject = async (data: SearchProjectInterface) => {
|
||||
try {
|
||||
const { userId, organization, searchName } = data;
|
||||
const userExisting = await existingUser(userId, organization);
|
||||
|
||||
@@ -17,7 +17,7 @@ interface RoleFilter {
|
||||
}
|
||||
export const TrashDatas = async (data: IOrg) => {
|
||||
try {
|
||||
const { organization, role, userId } = data;
|
||||
const { organization, userId } = data;
|
||||
let filter = { isArchive: true, isDeleted: false } as RoleFilter;
|
||||
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
@@ -56,7 +56,7 @@ export const TrashDatas = async (data: IOrg) => {
|
||||
};
|
||||
export const RestoreTrashData = async (data: IRestore) => {
|
||||
try {
|
||||
const { projectId, organization, role, userId } = data;
|
||||
const { projectId, organization, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
let filter = { isArchive: true, _id: projectId } as RoleFilter;
|
||||
|
||||
@@ -171,13 +171,13 @@ export const DelFloat = async (data: IDelFloat): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, floatWidgetID, zoneId, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
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({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -224,13 +224,13 @@ export const DuplicateFloat = async (
|
||||
try {
|
||||
const { organization, widget, zoneId, index, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
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({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -332,13 +332,13 @@ export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, zoneId, projectId, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const LivingProject = await existingProjectById(
|
||||
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({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
@@ -388,7 +388,7 @@ export const SingleFloatWidget = async (
|
||||
const { organization, floatWidgetID, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
|
||||
|
||||
const widgetData = await floatWidgetModel(organization)
|
||||
.findOne({
|
||||
floatWidgetID: floatWidgetID,
|
||||
|
||||
@@ -88,7 +88,7 @@ export const AddPanel = async (data: IAddPanel): Promise<IResult> => {
|
||||
if (!zoneAndPanelData) {
|
||||
return zoneAndPanelData;
|
||||
}
|
||||
return { status: "Success", data: zoneAndPanelData };
|
||||
return { status: "Success", data: createdPanels };
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
|
||||
@@ -47,13 +47,13 @@ export const AddTemplate = async (data: IAddTemplate): Promise<IResult> => {
|
||||
try {
|
||||
const { organization, template, 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 existingTemplate = await templateModel(organization).findOne({
|
||||
templateID: template.id,
|
||||
isArchive: false,
|
||||
|
||||
@@ -16,7 +16,6 @@ export default async function mongoAdminCreation() {
|
||||
.findOne({ user: user.user });
|
||||
|
||||
if (userExists) {
|
||||
console.log(`User ${user} already exists`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Socket, Server } from "socket.io";
|
||||
import { EVENTS } from "../../socket/events.ts";
|
||||
import { emitToSenderAndAdmins } from "../../utils/emitEventResponse.ts";
|
||||
import { SetCamera } from "../../../shared/services/builder/cameraService.ts";
|
||||
import { setEnvironment } from "../../../shared/services/builder/EnvironmentService.ts";
|
||||
export const setEnvironmentHandleEvent = async (
|
||||
event: string,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Socket, Server } from "socket.io";
|
||||
import { Socket } from "socket.io";
|
||||
import { EVENTS } from "../../socket/events.ts";
|
||||
import { emitEventResponse } from "../../utils/emitEventResponse.ts";
|
||||
import { addComments, createThread, deleteComments, deleteThread } from "../../../shared/services/Thread/ThreadService.ts";
|
||||
|
||||
@@ -2,8 +2,6 @@ import { Socket, Server } from "socket.io";
|
||||
import { EVENTS } from "../../socket/events.ts";
|
||||
import { emitEventResponse, emitToSenderAndAdmins, } from "../../utils/emitEventResponse.ts";
|
||||
import {
|
||||
TrashDatas,
|
||||
RestoreTrashData,
|
||||
TrashDelete,
|
||||
} from "../../../shared/services/v1trash/v1trashservice.ts";
|
||||
export const TrashDeleteHandleEvent = async (
|
||||
|
||||
@@ -103,15 +103,7 @@ export const update3DHandleEvent = async (
|
||||
status === "Success" && result?.data
|
||||
|
||||
? {
|
||||
// const updateDatas = {
|
||||
// widget: {
|
||||
// id: update3dwidget.widgetID,
|
||||
// type: update3dwidget.type,
|
||||
// position: update3dwidget.position,
|
||||
// rotation: update3dwidget.rotation,
|
||||
// },
|
||||
// zoneId: zoneId,
|
||||
// };
|
||||
|
||||
}
|
||||
: undefined;
|
||||
|
||||
@@ -165,10 +157,7 @@ export const Delete3DwidgetHandleEvent = async (
|
||||
status === "Success" && result?.data
|
||||
|
||||
? {
|
||||
// const delete_Datas = {
|
||||
// zoneId: zoneId,
|
||||
// id: existing3Dwidget.widgetID,
|
||||
// };
|
||||
|
||||
}
|
||||
: undefined;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import express, { Response, Request } from "express";
|
||||
import http from "http";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
import { Server } from "socket.io";
|
||||
dotenv.config();
|
||||
|
||||
import { SocketServer } from "./manager/manager.ts";
|
||||
@@ -13,10 +13,15 @@ const server = http.createServer(app);
|
||||
app.get("/", (req: Request, res: Response) => {
|
||||
res.send("Hello, I am Major-Dwinzo RealTime!");
|
||||
});
|
||||
initSocketServer(server);
|
||||
const io = new Server(server, {
|
||||
cors: {
|
||||
origin: "*",
|
||||
methods: ["GET", "POST"]
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
SocketServer(server);
|
||||
initSocketServer(io);
|
||||
SocketServer(io);
|
||||
|
||||
server.listen(PORT, () => {
|
||||
console.log(`socket-Server is running on http://localhost:${PORT}`);
|
||||
|
||||
@@ -27,22 +27,16 @@ interface UserSocketInfo {
|
||||
}
|
||||
|
||||
const connectedUsersByOrg: { [organization: string]: UserSocketInfo[] } = {};
|
||||
export const SocketServer = (httpServer: any) => {
|
||||
const io = new Server(httpServer, {
|
||||
cors: {
|
||||
origin: '*',
|
||||
methods: ['GET', 'POST'],
|
||||
},
|
||||
});
|
||||
|
||||
export const SocketServer = (io: Server) => {
|
||||
|
||||
|
||||
|
||||
const namespaces = {
|
||||
dashboard: io.of('/dashboard'),
|
||||
project: io.of('/project'),
|
||||
thread: io.of('/thread'),
|
||||
Builder: io.of("/Builder"),
|
||||
visualization: io.of("/Visualization"),
|
||||
Builder: io.of("/BuilderToken"),
|
||||
visualization: io.of("/VisualizationToken"),
|
||||
};
|
||||
|
||||
|
||||
@@ -126,6 +120,7 @@ export const SocketServer = (httpServer: any) => {
|
||||
}
|
||||
|
||||
socket.onAny((event: string, data: any, callback: any) => {
|
||||
console.log('data: dahbord', data);
|
||||
eventHandlers.forEach(handler =>
|
||||
handler(event, socket, io, data, connectedUsersByOrg, callback)
|
||||
);
|
||||
|
||||
@@ -971,18 +971,13 @@ interface UserSocketInfo {
|
||||
|
||||
const connectedUsersByOrg: { [organization: string]: UserSocketInfo[] } = {};
|
||||
|
||||
export const initSocketServer = (httpServer: any) => {
|
||||
const io = new Server(httpServer, {
|
||||
cors: {
|
||||
origin: "*",
|
||||
methods: ["GET", "POST"],
|
||||
},
|
||||
});
|
||||
export const initSocketServer = (io: Server) => {
|
||||
|
||||
|
||||
const namespaces = {
|
||||
Builder: io.of("/Builder"),
|
||||
visualization: io.of("/Visualization"),
|
||||
project: io.of("/project"),
|
||||
project: io.of("/projectPublic"),
|
||||
};
|
||||
|
||||
const onlineUsers: { [organization: string]: Set<string> } = {};
|
||||
@@ -999,7 +994,7 @@ namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
||||
console.log("No token provided");
|
||||
}
|
||||
|
||||
next();
|
||||
next();
|
||||
});
|
||||
|
||||
namespace.on("connection", async (socket: Socket) => {
|
||||
@@ -1019,6 +1014,7 @@ namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
||||
userStatus(EVENTS.connection, socket, socket.handshake.auth, socket);
|
||||
|
||||
socket.onAny((event: string, data: any, callback: any) => {
|
||||
console.log('data: socketmanager', data);
|
||||
eventHandlers.forEach((handler) =>
|
||||
handler(event, socket, data, namespace, io, callback)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user