Controller and routing for the Vizualtion and builder
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Request, Response } from "express";
|
||||
import { Response } from "express";
|
||||
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
GetCamers,
|
||||
onlineActiveDatas,
|
||||
SetCamera,
|
||||
} from "../../../../shared/services/builder/cameraService.ts";
|
||||
|
||||
@@ -75,6 +76,7 @@ export const CameraList = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !userId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
@@ -84,6 +86,7 @@ export const CameraList = async (
|
||||
const result = await GetCamers({
|
||||
organization,
|
||||
userId,
|
||||
projectId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
@@ -110,3 +113,41 @@ export const CameraList = async (
|
||||
});
|
||||
}
|
||||
};
|
||||
export const ActiveOnlineController = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, userId } = req.user || {};
|
||||
if (!organization || !userId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await onlineActiveDatas({
|
||||
organization,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({
|
||||
message: "User not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user