V1 for the builder processing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as express from "express";
|
||||
import { ZoneService } from "../controller/lines/zoneService.ts";
|
||||
import { zone } from "../controller/lines/zone-Services.ts";
|
||||
|
||||
const router = express.Router();
|
||||
/**
|
||||
@@ -539,4 +540,6 @@ router.get("/A_zone/:zoneId/:organization", ZoneService.ZoneData);
|
||||
*/
|
||||
router.patch("/zone/:zoneId", ZoneService.deleteAZone); //delete Zone
|
||||
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
||||
|
||||
router.get("/findZones/:organization", zone.getZones);
|
||||
export default router;
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Request, 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
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { userId, organization } = req.user || {};
|
||||
const {
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
// versionId
|
||||
projectId,
|
||||
} = req.body;
|
||||
if (
|
||||
!modelUuid ||
|
||||
!modelName ||
|
||||
!position ||
|
||||
!type ||
|
||||
!projectId ||
|
||||
!csgscale ||
|
||||
!csgposition ||
|
||||
// !versionId ||
|
||||
!quaternion ||
|
||||
!scale ||
|
||||
!organization
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required!",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await WallItems.setWallItems({
|
||||
projectId,
|
||||
modelUuid,
|
||||
// versionId,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
organization,
|
||||
});
|
||||
switch (result.state) {
|
||||
case "Updated successfully":
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
case "wall Item created successfully":
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json(error);
|
||||
break;
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
res.status(500).json({ message: "Unknown error" });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
import { Request, Response } from "express";
|
||||
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
GetCamers,
|
||||
SetCamera,
|
||||
} from "../../../../shared/services/builder/cameraService.ts";
|
||||
|
||||
export const SetNewCamera = 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
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
position,
|
||||
target,
|
||||
rotation,
|
||||
projectId,
|
||||
versionId,
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
};
|
||||
const result = await SetCamera(data);
|
||||
|
||||
switch (result.status) {
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
TrashDatas: [],
|
||||
});
|
||||
break;
|
||||
|
||||
case "Update Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: 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 CameraList = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
if (!organization || !role || !userId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await GetCamers({
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
TrashDatas: [],
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -50,21 +50,20 @@ export const recentDataController = async (
|
||||
}
|
||||
};
|
||||
export const searchProjectController = async (
|
||||
req: Request,
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { searchName, organization, userId } = req.query as {
|
||||
organization: string;
|
||||
searchName: string;
|
||||
userId: string;
|
||||
};
|
||||
if (!userId || !organization || !searchName) {
|
||||
const { userId, organization, role } = req.user || {};
|
||||
if (!userId || !organization || !role) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { searchName } = req.query as {
|
||||
searchName: string;
|
||||
};
|
||||
const result = await searchProject({
|
||||
searchName,
|
||||
organization,
|
||||
@@ -100,21 +99,21 @@ export const searchProjectController = async (
|
||||
}
|
||||
};
|
||||
export const searchTrashProjectController = async (
|
||||
req: Request,
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { searchName, organization, userId } = req.query as {
|
||||
organization: string;
|
||||
searchName: string;
|
||||
userId: string;
|
||||
};
|
||||
if (!userId || !organization || !searchName) {
|
||||
const { userId, organization, role } = req.user || {};
|
||||
if (!userId || !organization || !role) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { searchName } = req.query as {
|
||||
searchName: string;
|
||||
};
|
||||
|
||||
const result = await searchTrashProject({
|
||||
searchName,
|
||||
organization,
|
||||
|
||||
@@ -14,7 +14,6 @@ export const createProjectController = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { userId, organization } = req.user || {};
|
||||
console.log("req.user: ", req.user);
|
||||
const { projectUuid, thumbnail } = req.body;
|
||||
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||
res.status(401).json({ message: "Unauthorized" });
|
||||
@@ -82,7 +81,7 @@ export const GetProjects = async (
|
||||
break;
|
||||
|
||||
case "Success":
|
||||
res.status(201).json({
|
||||
res.status(200).json({
|
||||
Projects: result?.Datas,
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import express from "express";
|
||||
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
||||
import { recentDataController } from "../../V1/v1Controllers/homeController/v1homeController.ts";
|
||||
import {
|
||||
recentDataController,
|
||||
searchProjectController,
|
||||
searchTrashProjectController,
|
||||
} from "../../V1/v1Controllers/homeController/v1homeController.ts";
|
||||
|
||||
const v1homeRoutes = express.Router();
|
||||
|
||||
@@ -9,8 +13,20 @@ const v1homeRoutes = express.Router();
|
||||
v1homeRoutes.get(
|
||||
"/RecentlyViewed",
|
||||
tokenValidator,
|
||||
authorizedRoles("Admin", "User"),
|
||||
// authorizedRoles("Admin", "User"),
|
||||
recentDataController
|
||||
);
|
||||
v1homeRoutes.get(
|
||||
"/searchProjects",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
searchProjectController
|
||||
);
|
||||
v1homeRoutes.get(
|
||||
"/searchTrashProjects",
|
||||
tokenValidator,
|
||||
// authorizedRoles("Admin", "User"),
|
||||
searchTrashProjectController
|
||||
);
|
||||
|
||||
export default v1homeRoutes;
|
||||
|
||||
@@ -16,26 +16,26 @@ v1projectRouter.post("/upsertProject", tokenValidator, createProjectController);
|
||||
v1projectRouter.get(
|
||||
"/Projects",
|
||||
tokenValidator,
|
||||
authorizedRoles("Admin", "User"),
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetProjects
|
||||
);
|
||||
v1projectRouter.patch(
|
||||
"/Project/archive/:projectId",
|
||||
tokenValidator,
|
||||
authorizedRoles("Admin", "User"),
|
||||
// authorizedRoles("Admin", "User"),
|
||||
RemoveProject
|
||||
);
|
||||
|
||||
v1projectRouter.patch(
|
||||
"/Project/:projectId",
|
||||
tokenValidator,
|
||||
authorizedRoles("Admin", "User"),
|
||||
// authorizedRoles("Admin", "User"),
|
||||
updateProjectController
|
||||
);
|
||||
v1projectRouter.get(
|
||||
"/Project/:projectId",
|
||||
tokenValidator,
|
||||
authorizedRoles("Admin", "User"),
|
||||
// authorizedRoles("Admin", "User"),
|
||||
ViewData
|
||||
);
|
||||
|
||||
|
||||
@@ -7,19 +7,18 @@ import {
|
||||
} from "../../V1/v1Controllers/trashController/v1trashController.ts";
|
||||
|
||||
const v1TrashRoutes = express.Router();
|
||||
|
||||
//trash
|
||||
v1TrashRoutes.get(
|
||||
"/TrashItems ",
|
||||
"/TrashItems",
|
||||
tokenValidator,
|
||||
authorizedRoles("Admin", "User"),
|
||||
// authorizedRoles("Admin", "User"),
|
||||
GetTrashList
|
||||
);
|
||||
|
||||
v1TrashRoutes.patch(
|
||||
"/Trash/restore",
|
||||
tokenValidator,
|
||||
authorizedRoles("Admin", "User"),
|
||||
// authorizedRoles("Admin", "User"),
|
||||
RestoreTrash
|
||||
);
|
||||
export default v1TrashRoutes;
|
||||
|
||||
@@ -11,7 +11,7 @@ export class Environment {
|
||||
shadowVisibility,
|
||||
organization,
|
||||
renderDistance,
|
||||
limitDistance,
|
||||
limitDistance,
|
||||
} = req.body;
|
||||
|
||||
const findvalue = await environmentModel(organization).findOne({
|
||||
|
||||
117
src/api-server/controller/lines/zone-Services.ts
Normal file
117
src/api-server/controller/lines/zone-Services.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
import { Request, Response } from "express";
|
||||
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
|
||||
export class zone {
|
||||
static async setZone(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization, userId, zoneData } = req.body;
|
||||
// console.log('req.body: ', req.body);
|
||||
const zoneId = zoneData.zoneId;
|
||||
const points = zoneData.points;
|
||||
const zoneName = zoneData.zoneName;
|
||||
const layer = zoneData.layer;
|
||||
const viewPortCenter = zoneData.viewPortCenter;
|
||||
const viewPortposition = zoneData.viewPortposition;
|
||||
const findZoneId = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
});
|
||||
if (findZoneId) {
|
||||
const updateZone = await zoneModel(organization)
|
||||
.findOneAndUpdate(
|
||||
{ zoneId: zoneId },
|
||||
{
|
||||
points: points,
|
||||
viewPortposition: viewPortposition,
|
||||
viewPortCenter: viewPortCenter,
|
||||
},
|
||||
{ new: true }
|
||||
)
|
||||
.select("-_id -__v");
|
||||
res.status(201).json({
|
||||
message: "zone updated",
|
||||
data: updateZone,
|
||||
organization: organization,
|
||||
});
|
||||
} else {
|
||||
const zoneCreate = await zoneModel(organization).create({
|
||||
zoneId,
|
||||
createBy: userId,
|
||||
zoneName: zoneName,
|
||||
points,
|
||||
layer,
|
||||
viewPortCenter,
|
||||
viewPortposition,
|
||||
});
|
||||
const createdZone = await zoneModel(organization)
|
||||
.findById(zoneCreate._id)
|
||||
.select("-_id -__v")
|
||||
.lean();
|
||||
res.status(201).json({
|
||||
message: "zone created",
|
||||
data: createdZone,
|
||||
organization: organization,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({ message: "Zone not found", error });
|
||||
}
|
||||
}
|
||||
static async deleteZone(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization, userId, zoneId } = req.body;
|
||||
|
||||
const findZoneId = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
});
|
||||
if (findZoneId) {
|
||||
const deleteZone = await zoneModel(organization)
|
||||
.findOneAndDelete({ zoneId: zoneId, createBy: userId })
|
||||
.select("-_id -__v");
|
||||
res.status(201).json({
|
||||
message: "zone deleted",
|
||||
data: deleteZone,
|
||||
organization: organization,
|
||||
});
|
||||
} else {
|
||||
res.status(500).json({ message: "Invalid zone ID" });
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({ message: "Zone not found", error });
|
||||
}
|
||||
}
|
||||
static async getZones(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization, userId } = req.params;
|
||||
|
||||
const findZoneId = await zoneModel(organization)
|
||||
.find()
|
||||
.select(
|
||||
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
||||
);
|
||||
|
||||
if (!findZoneId) {
|
||||
res.status(500).json({ message: "Invalid zone" });
|
||||
}
|
||||
res.status(200).json({ data: findZoneId, organization: organization });
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({ message: "Zone not found", error });
|
||||
}
|
||||
}
|
||||
|
||||
static async ZoneData(req: Request, res: Response): Promise<any> {
|
||||
try {
|
||||
const organization = req.params.organization;
|
||||
const zoneId = req.params.zoneId;
|
||||
const findZone = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
});
|
||||
// .select("zoneName");
|
||||
console.log("findZone: ", findZone);
|
||||
if (findZone) return res.status(200).json(findZone);
|
||||
} catch (error: any) {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Document, Schema } from "mongoose";
|
||||
import { Document, Schema } from "mongoose";
|
||||
import MainModel from "../connect/mongoose.ts";
|
||||
export interface User extends Document {
|
||||
userName: String;
|
||||
@@ -49,7 +49,8 @@ const signupschema: Schema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
const userModel = (db:string) => {
|
||||
const userModel = (db: string) => {
|
||||
return MainModel(db, "Users", signupschema, "Users")
|
||||
// return MainModel(db, "UserAuth", signupschema, "UserAuth");
|
||||
};
|
||||
export default userModel;
|
||||
|
||||
0
src/shared/services/builder/assetService.ts
Normal file
0
src/shared/services/builder/assetService.ts
Normal file
0
src/shared/services/builder/lineService.ts
Normal file
0
src/shared/services/builder/lineService.ts
Normal file
117
src/shared/services/builder/wallService.ts
Normal file
117
src/shared/services/builder/wallService.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
import { Request, Response } from "express";
|
||||
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
|
||||
interface IWallSetupData {
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
type: string;
|
||||
csgposition: [];
|
||||
csgscale: [];
|
||||
position: [];
|
||||
quaternion: [];
|
||||
scale: [];
|
||||
organization: string;
|
||||
projectId: string;
|
||||
}
|
||||
interface IWallItemResult {
|
||||
data: {};
|
||||
state: string;
|
||||
}
|
||||
export class WallItems {
|
||||
static async setWallItems(data: IWallSetupData): Promise<IWallItemResult> {
|
||||
try {
|
||||
const {
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
projectId,
|
||||
organization,
|
||||
} = data;
|
||||
const findvalue = await wallItemModel(organization).findOne({
|
||||
modelUuid: modelUuid,
|
||||
});
|
||||
|
||||
if (findvalue) {
|
||||
const updatevalue = await wallItemModel(organization).findOneAndUpdate(
|
||||
{ modelUuid: modelUuid, projectId: projectId },
|
||||
{
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
},
|
||||
{ new: true } // Return the updated document
|
||||
);
|
||||
return {
|
||||
state: "Updated successfully",
|
||||
data: updatevalue,
|
||||
};
|
||||
// res.status(201).json(updatevalue);
|
||||
} else {
|
||||
const newValue = await wallItemModel(organization).create({
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
projectId,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
});
|
||||
return {
|
||||
state: "wall Item created successfully",
|
||||
data: newValue,
|
||||
};
|
||||
// res.status(201).json(newValue);
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
const err = error as Error;
|
||||
console.error("Error creating wallitems:", error);
|
||||
return {
|
||||
state: "Failed to create wallitems",
|
||||
data: { message: err.message },
|
||||
};
|
||||
}
|
||||
}
|
||||
static async getWallItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization } = req.params;
|
||||
|
||||
const findValue = await wallItemModel(organization).find();
|
||||
if (!findValue) {
|
||||
res.status(200).json("wallitems not found");
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get wallitems:", error);
|
||||
res.status(500).json({ error: "Failed to get wallitems" });
|
||||
}
|
||||
}
|
||||
static async deleteWallItems(req: Request, res: Response) {
|
||||
try {
|
||||
const { modelUuid, modelName, organization } = req.body;
|
||||
|
||||
const findValue = await wallItemModel(organization).findOneAndDelete({
|
||||
modelUuid: modelUuid,
|
||||
modelName: modelName,
|
||||
});
|
||||
if (!findValue) {
|
||||
res.status(200).json("user not found");
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get wallitems:", error);
|
||||
res.status(500).json({ error: "Failed to get wallitems" });
|
||||
}
|
||||
}
|
||||
}
|
||||
0
src/shared/services/builder/zoneService.ts
Normal file
0
src/shared/services/builder/zoneService.ts
Normal file
@@ -103,9 +103,9 @@ export const GetAllProjects = async (data: GetProjectsInterface) => {
|
||||
await existingUser(userId, organization);
|
||||
if (!existingUser) return { status: "User not found" };
|
||||
let filter = { isArchive: false } as RoleFilter;
|
||||
if (role === "User") {
|
||||
filter.createdBy = userId;
|
||||
}
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const projectDatas = await projectModel(organization)
|
||||
.find(filter)
|
||||
.select("_id projectName createdBy thumbnail createdAt projectUuid");
|
||||
@@ -121,9 +121,9 @@ export const DeleteProject = async (data: ProjectInterface) => {
|
||||
const ExistingUser = await existingUser(userId, organization);
|
||||
if (!ExistingUser) return { status: "User not found" };
|
||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||
if (role === "User") {
|
||||
filter.createdBy = userId;
|
||||
}
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const existingProject = await projectModel(organization).findOne(filter);
|
||||
if (!existingProject) return { status: "Project not found" };
|
||||
const updateProject = await projectModel(organization).findOneAndUpdate(
|
||||
@@ -143,9 +143,9 @@ export const updateProject = async (data: updateProjectInput) => {
|
||||
const ExistingUser = await existingUser(userId, organization);
|
||||
if (!ExistingUser) return { status: "User not found" };
|
||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||
if (role === "User") {
|
||||
filter.createdBy = userId;
|
||||
}
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const existingProject = await projectModel(organization).findOne(filter);
|
||||
if (!existingProject) return { status: "Project not found" };
|
||||
if (projectName !== undefined) projectName;
|
||||
@@ -173,9 +173,9 @@ export const viewProject = async (data: ProjectInterface) => {
|
||||
isArchive: false,
|
||||
});
|
||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||
if (role === "User") {
|
||||
filter.createdBy = userId;
|
||||
}
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const existingProject = await projectModel(organization).findOne(filter);
|
||||
if (!existingProject) return { status: "Project not found" };
|
||||
const newArr = RecentUserDoc?.recentlyViewed || [];
|
||||
|
||||
@@ -38,9 +38,9 @@ export const RecentlyAdded = async (data: IRecentData) => {
|
||||
select: "_id",
|
||||
});
|
||||
let filter = { isArchive: false } as RoleFilter;
|
||||
if (role === "User") {
|
||||
filter.createdBy = userId;
|
||||
}
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const populatedProjects = userRecentData.recentlyViewed as IProject[];
|
||||
const RecentDatas = await Promise.all(
|
||||
populatedProjects.map(async (project) => {
|
||||
|
||||
@@ -18,9 +18,9 @@ export const TrashDatas = async (data: IOrg) => {
|
||||
try {
|
||||
const { organization, role, userId } = data;
|
||||
let filter = { isArchive: true, isDeleted: false } as RoleFilter;
|
||||
if (role === "User") {
|
||||
filter.createdBy = userId;
|
||||
}
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const TrashLists = await projectModel(organization).find(filter);
|
||||
if (!TrashLists) return { staus: "Trash is Empty" };
|
||||
const TrashDocs: any[] = [];
|
||||
@@ -57,9 +57,9 @@ export const RestoreTrashData = async (data: IRestore) => {
|
||||
try {
|
||||
const { projectId, organization, role, userId } = data;
|
||||
let filter = { isArchive: true, _id: projectId } as RoleFilter;
|
||||
if (role === "User") {
|
||||
filter.createdBy = userId;
|
||||
}
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const findProject = await projectModel(organization).findOne(filter);
|
||||
if (!findProject) return { status: "Project not found" };
|
||||
const restoreData = await projectModel(organization).findOneAndUpdate(
|
||||
|
||||
@@ -22,7 +22,7 @@ const tokenGenerator = (
|
||||
organization: string
|
||||
) => {
|
||||
const token = Jwt.sign(
|
||||
{ Email: Email, role: role, userId, organization: organization },
|
||||
{ Email: Email, role: role, userId: userId, organization: organization },
|
||||
jwt_secret,
|
||||
{
|
||||
expiresIn: "3h",
|
||||
@@ -37,7 +37,7 @@ const tokenRefreshGenerator = (
|
||||
organization: string
|
||||
) => {
|
||||
const token = Jwt.sign(
|
||||
{ Email: Email, role: role, userId, organization: organization },
|
||||
{ Email: Email, role: role, userId: userId, organization: organization },
|
||||
refresh_jwt_secret,
|
||||
{
|
||||
expiresIn: "30d",
|
||||
@@ -95,6 +95,7 @@ const tokenValidator = async (
|
||||
userId: string;
|
||||
organization: string;
|
||||
};
|
||||
console.log("refresh token");
|
||||
if (!decodedRefresh) {
|
||||
res.status(403).json({
|
||||
success: false,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user