fetch req conflict resolved
This commit is contained in:
1
.env
1
.env
@@ -23,6 +23,5 @@ REFRESH_JWT_SECRET="RefreshDwinzoProject"
|
||||
|
||||
|
||||
REDIS_ENV= true
|
||||
|
||||
REDIS_DOCKER =185.100.212.76
|
||||
REDIS_PORT=6666
|
||||
@@ -245,7 +245,7 @@ const router = express.Router();
|
||||
* type: string
|
||||
* example: "Internal server error"
|
||||
*/
|
||||
router.post("/zone/save", ZoneService.addandUpdateZone);
|
||||
router.post("/zone/save", ZoneService.addandUpdateZone);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
||||
@@ -11,16 +11,8 @@ import {
|
||||
|
||||
const v1Zone = express.Router();
|
||||
|
||||
v1Zone.post(
|
||||
"/zones",
|
||||
tokenValidator,
|
||||
CreateZoneController
|
||||
);
|
||||
v1Zone.patch(
|
||||
"/zones/delete",
|
||||
tokenValidator,
|
||||
DeleteZoneController
|
||||
);
|
||||
v1Zone.post("/zones", tokenValidator, CreateZoneController);
|
||||
v1Zone.patch("/zones/delete", tokenValidator, DeleteZoneController);
|
||||
|
||||
v1Zone.get(
|
||||
"/zones/visualization/:projectId",
|
||||
@@ -38,9 +30,5 @@ v1Zone.get(
|
||||
tokenValidator,
|
||||
SingleZonePanelController
|
||||
);
|
||||
v1Zone.get(
|
||||
"/zones/:projectId",
|
||||
tokenValidator,
|
||||
GetZoneController
|
||||
);
|
||||
v1Zone.get("/zones/:projectId", tokenValidator, GetZoneController);
|
||||
export default v1Zone;
|
||||
|
||||
@@ -238,25 +238,6 @@ export class ZoneService {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
static async getZones(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization } = req.params;
|
||||
|
||||
const findZoneId = await zoneSchema(organization)
|
||||
.find({isArchive:false})
|
||||
.select(
|
||||
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
||||
);
|
||||
|
||||
if (!findZoneId) {
|
||||
res.status(500).json({ message: "Invalid zone" });
|
||||
}
|
||||
res.status(201).json({ data: findZoneId, organization: organization });
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({ message: "Zone not found", error });
|
||||
}
|
||||
}
|
||||
static async lockedPanel(req: Request, res: Response): Promise<any> {
|
||||
console.log(req.body);
|
||||
const organization = req.body.organization;
|
||||
@@ -290,4 +271,24 @@ export class ZoneService {
|
||||
return res.status(500).send(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
static async getZones(req: Request, res: Response) {
|
||||
try {
|
||||
const { organization } = req.params;
|
||||
|
||||
const findZoneId = await zoneSchema(organization)
|
||||
.find({ isArchive: false })
|
||||
.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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import MainModel from "../../../connect/mongoose.ts";
|
||||
export interface Zone extends Document {
|
||||
zoneName: string;
|
||||
zoneId: string;
|
||||
zonePoints: [];
|
||||
points: [];
|
||||
viewPortCenter: [];
|
||||
viewPortposition: [];
|
||||
isArchive: boolean;
|
||||
|
||||
@@ -6,7 +6,7 @@ import templateModel from "../../../shared/model/vizualization/templatemodel.ts"
|
||||
import widgetModel from "../../../shared/model/vizualization/widgemodel.ts";
|
||||
export const setZone = async (data: any) => {
|
||||
const { organization, userId, zoneData } = data;
|
||||
console.log('data:zone ', data);
|
||||
console.log("data service: ", data);
|
||||
try {
|
||||
const zoneId = zoneData.zoneId;
|
||||
const points = zoneData.points;
|
||||
@@ -16,6 +16,7 @@ export const setZone = async (data: any) => {
|
||||
const viewPortposition = zoneData.viewPortposition;
|
||||
const findZoneId = await zoneModel(organization).findOne({
|
||||
zoneId: zoneId,
|
||||
isArchive: false,
|
||||
});
|
||||
if (findZoneId) {
|
||||
const updateZone = await zoneModel(organization)
|
||||
|
||||
@@ -251,7 +251,7 @@ const lineHandleEvent = async (
|
||||
data: any,
|
||||
io: any
|
||||
) => {
|
||||
if (!data?.organization|| typeof data.organization !== 'string') {
|
||||
if (!data?.organization || typeof data.organization !== "string") {
|
||||
console.warn(`Missing organization for event: ${event}`);
|
||||
return;
|
||||
}
|
||||
@@ -420,6 +420,7 @@ const zoneHandleEvent = async (
|
||||
let result;
|
||||
switch (event) {
|
||||
case EVENTS.setZone: {
|
||||
// console.log("create zonedata: ", data);
|
||||
result = await setZone(data);
|
||||
|
||||
if (result) {
|
||||
@@ -951,13 +952,11 @@ const emitEventResponse = (
|
||||
interface UserSocketInfo {
|
||||
socketId: string;
|
||||
userId: string;
|
||||
role: string;
|
||||
role: string;
|
||||
}
|
||||
|
||||
|
||||
export const initSocketServer = (io: Server) => {
|
||||
|
||||
|
||||
const namespaces = {
|
||||
Builder: io.of("/Builder"),
|
||||
visualization: io.of("/Visualization"),
|
||||
@@ -976,12 +975,12 @@ export const initSocketServer = (io: Server) => {
|
||||
namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
||||
const token = socket.handshake.auth.token;
|
||||
|
||||
if (!token) {
|
||||
console.log("No token provided");
|
||||
}
|
||||
if (!token) {
|
||||
console.log("No token provided");
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
next();
|
||||
});
|
||||
|
||||
namespace.on("connection", async (socket: Socket) => {
|
||||
|
||||
@@ -1071,5 +1070,4 @@ namespace.use((socket: Socket, next: (err?: Error) => void) => {
|
||||
);
|
||||
|
||||
return io;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user