-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into glydric
- Loading branch information
Showing
52 changed files
with
770 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const cameraIds = [0, 1, 2, 3, 4, 5, 6, 7]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Use the official Node.js image as the base image | ||
FROM node:14-alpine | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json to the working directory | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy the entire app to the working directory | ||
COPY . . | ||
|
||
# Build the Next.js app | ||
RUN npm run build | ||
|
||
# Expose the port that your Next.js app will run on | ||
EXPOSE 3000 | ||
|
||
# Start the Next.js app | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Activity, AnyObject, Camera } from "@/types"; | ||
import { axiosClient } from "./axios-client"; | ||
import { endpoints } from "./endpoints"; | ||
|
||
type CamerasResponseDTO = Camera[]; | ||
type CameraSettingUpdateResponseDTO = any; | ||
|
||
export const getCameras = () => { | ||
return () => | ||
axiosClient | ||
.get<CamerasResponseDTO>(`${endpoints.getCameras}`, {}) | ||
.then((result) => result.data); | ||
}; | ||
|
||
export const updateCamera = async (configuration: AnyObject) => { | ||
for (const key in configuration) { | ||
try { | ||
await axiosClient | ||
.post<CamerasResponseDTO>(`${key}/${configuration[key]}`, {}); | ||
} catch (error: any) { | ||
console.log(error); | ||
} | ||
|
||
} | ||
return "Success" | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
export const endpoints = { | ||
/* authentication endpoints */ | ||
// authentication endpoints | ||
login: "login", | ||
|
||
// ِRecent activites endpoints | ||
recentActivities: "intrusionDetection", | ||
getIntrusionCount: "intrusionDetection/aggregate", | ||
|
||
// Camera endpoints | ||
getCameras: "cameras", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export { ReactQueryProvider } from "./react-query-provider"; | ||
export { ReactQueryProvider, queryClient } from "./react-query-provider"; | ||
export { axiosClient } from "./axios-client"; | ||
|
||
/* authentication methods */ | ||
|
||
export { login } from "./authentication/login"; | ||
export { getRecentActivities, getRecentActivitiesCount,getActivityImage } from "./recent-activities"; | ||
export { getCameras, updateCamera } from "./cameras"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Activity } from "@/types"; | ||
import { axiosClient } from "./axios-client"; | ||
import { endpoints } from "./endpoints"; | ||
|
||
type RecentActivitiesResponseDTO = { | ||
data: Activity[]; | ||
}; | ||
|
||
type RecentActivitiesCountResponseDTO = { | ||
_id: string; | ||
count: number; | ||
}[]; | ||
|
||
type RecentActivityImageResponseDTO = { | ||
data: any; | ||
}; | ||
|
||
export const getRecentActivities = (top: number, skip: number) => { | ||
return () => | ||
axiosClient | ||
.get<RecentActivitiesResponseDTO>( | ||
`${endpoints.recentActivities}/${top}/${skip}`, | ||
{} | ||
) | ||
.then((result) => result.data); | ||
}; | ||
|
||
export const getRecentActivitiesCount = () => { | ||
return () => | ||
axiosClient | ||
.get<RecentActivitiesCountResponseDTO>( | ||
`${endpoints.getIntrusionCount}`, | ||
{} | ||
) | ||
.then((result) => { | ||
let totalCount = 0; | ||
|
||
result.data.forEach((item) => { | ||
totalCount += item.count; | ||
}); | ||
|
||
return totalCount; | ||
}); | ||
}; | ||
|
||
export const getActivityImage = (id: string, timestamp: string) => { | ||
return () => | ||
axiosClient | ||
.get<RecentActivityImageResponseDTO>( | ||
`${id}/${timestamp}`, | ||
{} | ||
) | ||
.then((result) => result.data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
"use client"; | ||
import { Table } from "@/components"; | ||
import { recentActivitiesData, recentActivitiesColumns } from "@/data"; | ||
import { RecentActivitiesContainer } from "@/containers"; | ||
|
||
export default function RecentActivities() { | ||
return ( | ||
<div> | ||
<Table | ||
columns={recentActivitiesColumns} | ||
data={recentActivitiesData} | ||
pagination={{ total: recentActivitiesData.length }} | ||
rowKey={"id"} | ||
/> | ||
<RecentActivitiesContainer /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use client"; | ||
import { SettingsContainer } from "@/containers"; | ||
|
||
export default function Settings() { | ||
return ( | ||
<div> | ||
<SettingsContainer /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Button } from "./button"; | ||
import { CameraOutlined } from "@ant-design/icons"; | ||
import { useModalSlice, useNotificationSlice } from "@/hooks"; | ||
import { useQuery } from "react-query"; | ||
import { getActivityImage } from "@/api"; | ||
import { Spin } from "antd"; | ||
import { useEffect } from "react"; | ||
|
||
type PropsType = { | ||
cameraId: string; | ||
timestamp: string; | ||
}; | ||
|
||
/** This component renders screenshot button */ | ||
export const ViewScreenshotButton: React.FC<PropsType> = ({ | ||
cameraId, | ||
timestamp, | ||
}) => { | ||
const { openModal, closeModal } = useModalSlice(); | ||
const { openNotification } = useNotificationSlice(); | ||
|
||
// Get total number of recent activities | ||
const { | ||
isLoading: isLoadingImage, | ||
error: isErrorImage, | ||
data: imageData, | ||
refetch: fetchImage, | ||
} = useQuery( | ||
["recentActivitiesCount", cameraId], | ||
getActivityImage(cameraId, timestamp), | ||
{ enabled: false } | ||
); | ||
|
||
const onButtonClick = () => { | ||
fetchImage(); | ||
}; | ||
|
||
useEffect(() => { | ||
if (imageData) { | ||
openModal({ | ||
title: timestamp, | ||
modalContent: imageData.data, | ||
isLoading: true, | ||
}); | ||
} | ||
}, [imageData]); | ||
|
||
useEffect(() => { | ||
if (isLoadingImage) { | ||
openModal({ | ||
title: timestamp, | ||
modalContent: "", | ||
isLoading: true, | ||
}); | ||
} | ||
}, [isLoadingImage]); | ||
|
||
useEffect(() => { | ||
if (isErrorImage) { | ||
openNotification({ | ||
type: "error", | ||
message: "Could not fetch image.", | ||
}); | ||
closeModal(); | ||
} | ||
}, [isErrorImage]); | ||
|
||
return ( | ||
<Button | ||
toolTipText="View screenshot" | ||
icon={<CameraOutlined />} | ||
onClick={onButtonClick} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export { VideoRecordingScreen } from "./video-recording-screen/video-recording-screen"; | ||
export { Table } from "./table/table"; | ||
export { Button } from "./button/button"; | ||
export { ViewScreenshotButton } from "./button/view-screenshot"; | ||
export { Card } from "./card/card"; | ||
export { Input } from "./input/input"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.