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