Compare commits
115 Commits
bugfix/Ala
...
feature/la
| Author | SHA1 | Date | |
|---|---|---|---|
| 24ea41205f | |||
| 5b188747a5 | |||
| 1c760cb2a8 | |||
| 26e9238518 | |||
| 29e9086d5a | |||
| 555330991d | |||
| cae652477e | |||
| 8b635101de | |||
| 696a36ba92 | |||
| 5dc1d13e25 | |||
| 430d134037 | |||
| 1ebd8aaa6f | |||
| 266def727b | |||
| dcc58d527a | |||
| dbaeffe246 | |||
| 12cd0f9f37 | |||
| 0b3dcbb265 | |||
| ea93053dd3 | |||
| 516b43a2f8 | |||
| 1b788271a8 | |||
| d2f030f221 | |||
| 5ce70ffa06 | |||
| b1cd2cef8a | |||
| 8db9d7ff51 | |||
| 0b1f0b72a8 | |||
| 0945097abb | |||
| 1b46ecc3d1 | |||
| dd1cd342c1 | |||
| 0a1ac97c57 | |||
| ac53a8fd7f | |||
| 96a880a4df | |||
| 3ceca96276 | |||
| e7b741af78 | |||
| ed271964d8 | |||
| 9b996430d0 | |||
| 2ccc26ebdc | |||
| b86830a3c3 | |||
| 3d1cc09a5b | |||
| f571ab80a2 | |||
| b2335d2d4d | |||
| a873da8ef5 | |||
| 5014c97b4d | |||
| e374456588 | |||
| ee3e111e9b | |||
| a8178269c2 | |||
| c057ce5084 | |||
| 0c7d99f7ea | |||
| f2e10f958d | |||
| 903b856303 | |||
| be0a047d30 | |||
| 672ff1d2f1 | |||
| 08a07b7ffb | |||
| d60c546db1 | |||
| f35e2f9fb5 | |||
| cac9a2167d | |||
| feddaa1eb0 | |||
| ddeedd2d72 | |||
| a734de6261 | |||
| d57ad1003a | |||
| 861f2dd31d | |||
| 647fd201a3 | |||
| c127ce8a8c | |||
| 61894c0c42 | |||
| 76643cc84c | |||
| f6c1ea2b1c | |||
| 18e4d1dcff | |||
| 010a9fb59d | |||
| b1953dd965 | |||
| 630261ac21 | |||
| c948192f10 | |||
| f47459d116 | |||
| 705d7c7040 | |||
| ca625673e9 | |||
| 538b623ac6 | |||
| 933c101cbc | |||
| af1dabc8fc | |||
| a839502421 | |||
| 39629897d4 | |||
| cd26b3b68f | |||
| a8abed2246 | |||
| cf72a1e1d3 | |||
| c8eed55801 | |||
| 907555cb0d | |||
| d6c39843c8 | |||
| a64fa76ecb | |||
| 93dcde4459 | |||
| a5b07333da | |||
| ae0a6f9249 | |||
| 350d7cf41c | |||
| 78e5da45ca | |||
| e46460f41d | |||
| 6c441a0a4b | |||
| 2d5b264041 | |||
| 251a2f5e7b | |||
| 18534ceb2c | |||
| 9975e6a6ca | |||
| c83122cd52 | |||
| abc8007fc6 | |||
| 7903633809 | |||
| 359f3781f2 | |||
| f264f4e808 | |||
| 0c6e4b57be | |||
| a958901bed | |||
| 4519700561 | |||
| b58181e551 | |||
| df6bf75184 | |||
| c5cea81532 | |||
| 78905b09e0 | |||
| 1ffad51503 | |||
| d16f55413c | |||
| 3598f8d069 | |||
| 0a3a543d6f | |||
| 0867b3b743 | |||
| a152c15ec7 | |||
| 617ea60f26 |
163
README.md
163
README.md
@@ -1,69 +1,116 @@
|
||||
# React + TypeScript + Vite
|
||||
# Mav Mobile UI
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
This is a React-based web application built with Vite (react and typescript).
|
||||
|
||||
Currently, two official plugins are available:
|
||||
## Getting started
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
### Prerequisites
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
- Node.js (v18 or higher recommended)
|
||||
- Yarn (v1.22+) (https://yarnpkg.com/)
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
### Installation
|
||||
|
||||
```js
|
||||
export default tseslint.config([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
...tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```bash
|
||||
git clone https://mavportal.com/TobaOjo/Mav-Mobile-UI.git
|
||||
cd Mav-Mobile-UI
|
||||
yarn install
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
### Running Locally
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
The app will be available at `http://localhost:5173`.
|
||||
|
||||
To run on locally on other devices
|
||||
|
||||
```bash
|
||||
yarn dev --host
|
||||
```
|
||||
|
||||
The app will be available at the exposed addresses to access e.g. http://1xx.xxx.x.xxx:<PORT>/Mobile
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- **React** – UI library
|
||||
- **Vite** – Build tool
|
||||
- **Yarn** – Package manager
|
||||
|
||||
## Configuration
|
||||
|
||||
Create a `.env` file to access the Mav Mobile box in unit 5 for or for any environment-specific settings:
|
||||
|
||||
```env
|
||||
VITE_AGX_BOX_URL=http://1xx.xxx.xxx.xxx:<PORT>
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Linting & Formatting
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
yarn format
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
(Currently not implemented – consider adding Jest or Vitest)
|
||||
|
||||
## Deployment
|
||||
|
||||
To build for production:
|
||||
Navigate to the Mav-Mobile-UI folder
|
||||
|
||||
```bash
|
||||
cd Mav-Mobile-UI
|
||||
```
|
||||
|
||||
**Delete** the local .env (Production will use its own domain)
|
||||
|
||||
run
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
- Navigate to your Mav-Mobile-UI folder
|
||||
- Select the Dist folder
|
||||
- Compress to (ZIP)
|
||||
- Log into box on Moba using Session > SSH and putting IP in Remote Host.
|
||||
- Creds are mav:mav
|
||||
- Drag and drop dist.zip into file explorer menu on left hand side (has to be named dist.zip exactly).
|
||||
- Run command
|
||||
|
||||
```bash
|
||||
sudo ./integrate-web-ui.sh
|
||||
```
|
||||
|
||||
Run
|
||||
|
||||
```bash
|
||||
sudo nano web-static/index.html
|
||||
```
|
||||
|
||||
- add the following between the lines </body> & </html>
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default tseslint.config([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
<foot>
|
||||
<script>
|
||||
if (window.location.pathname !== "/Mobile") {
|
||||
window.location.replace(window.location.origin + "/Mobile");
|
||||
}
|
||||
</script>
|
||||
</foot>
|
||||
```
|
||||
|
||||
- Run
|
||||
|
||||
```bash
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
It should come back up all working
|
||||
|
||||
3623
package-lock.json
generated
Normal file
3623
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "in-car-system-fe",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.20",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -31,11 +31,14 @@
|
||||
"react-swipeable": "^7.0.2",
|
||||
"react-tabs": "^6.1.0",
|
||||
"react-use": "^17.6.0",
|
||||
"react-use-websocket": "^4.13.0",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwindcss": "^4.1.11"
|
||||
"tailwindcss": "^4.1.11",
|
||||
"use-debounce": "^10.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.32.0",
|
||||
"@types/node": "^25.0.1",
|
||||
"@types/react": "^19.1.9",
|
||||
"@types/react-dom": "^19.1.7",
|
||||
"@types/react-modal": "^3.16.3",
|
||||
|
||||
11
public/NPED_Cat_D.svg
Normal file
11
public/NPED_Cat_D.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 29 KiB |
33
src/App.tsx
33
src/App.tsx
@@ -5,29 +5,32 @@ import FrontCamera from "./pages/FrontCamera";
|
||||
import RearCamera from "./pages/RearCamera";
|
||||
import SystemSettings from "./pages/SystemSettings";
|
||||
import Session from "./pages/Session";
|
||||
import { NPEDUserProvider } from "./context/providers/NPEDUserContextProvider";
|
||||
import { IntegrationsProvider } from "./context/providers/IntegrationsContextProvider";
|
||||
import { AlertHitProvider } from "./context/providers/AlertHitProvider";
|
||||
import { SoundProvider } from "react-sounds";
|
||||
import SoundContextProvider from "./context/providers/SoundContextProvider";
|
||||
import WebSocketProvider from "./context/providers/WebSocketProvider";
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<SoundContextProvider>
|
||||
<SoundProvider initialEnabled={true}>
|
||||
<NPEDUserProvider>
|
||||
<AlertHitProvider>
|
||||
<Routes>
|
||||
<Route path="/" element={<Container />}>
|
||||
<Route index element={<Dashboard />} />
|
||||
<Route path="camera-settings" element={<FrontCamera />} />
|
||||
<Route path="rear-camera-settings" element={<RearCamera />} />
|
||||
<Route path="system-settings" element={<SystemSettings />} />
|
||||
<Route path="session-settings" element={<Session />} />
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</AlertHitProvider>
|
||||
</NPEDUserProvider>
|
||||
<WebSocketProvider>
|
||||
<IntegrationsProvider>
|
||||
<AlertHitProvider>
|
||||
<Routes>
|
||||
<Route path="/" element={<Container />}>
|
||||
<Route index element={<Dashboard />} />
|
||||
<Route path="a-camera-settings" element={<FrontCamera />} />
|
||||
<Route path="b-camera-settings" element={<RearCamera />} />
|
||||
<Route path="system-settings" element={<SystemSettings />} />
|
||||
<Route path="session-settings" element={<Session />} />
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</AlertHitProvider>
|
||||
</IntegrationsProvider>
|
||||
</WebSocketProvider>
|
||||
</SoundProvider>
|
||||
</SoundContextProvider>
|
||||
);
|
||||
|
||||
BIN
src/assets/sounds/ui/Attention.wav
Normal file
BIN
src/assets/sounds/ui/Attention.wav
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,11 +1,8 @@
|
||||
import { useGetOverviewSnapshot } from "../../hooks/useGetOverviewSnapshot";
|
||||
import type { ZoomInOptions } from "../../types/types";
|
||||
import NavigationArrow from "../UI/NavigationArrow";
|
||||
import { useCameraZoom } from "../../hooks/useCameraZoom";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import Loading from "../UI/Loading";
|
||||
import ErrorState from "../UI/ErrorState";
|
||||
|
||||
type SnapshotContainerProps = {
|
||||
side: string;
|
||||
settingsPage?: boolean;
|
||||
@@ -13,52 +10,20 @@ type SnapshotContainerProps = {
|
||||
onZoomLevelChange?: (level: number) => void;
|
||||
};
|
||||
|
||||
export const SnapshotContainer = ({
|
||||
side,
|
||||
settingsPage,
|
||||
zoomLevel,
|
||||
onZoomLevelChange,
|
||||
}: SnapshotContainerProps) => {
|
||||
export const SnapshotContainer = ({ side, settingsPage }: SnapshotContainerProps) => {
|
||||
const { canvasRef, isError, isPending } = useGetOverviewSnapshot(side);
|
||||
const cameraControllerSide =
|
||||
side === "CameraA" ? "CameraControllerA" : "CameraControllerB";
|
||||
const { mutation } = useCameraZoom({ camera: cameraControllerSide });
|
||||
|
||||
const handleZoomClick = () => {
|
||||
const baseLevel = zoomLevel ?? 1;
|
||||
const newLevel = baseLevel >= 8 ? 1 : baseLevel * 2;
|
||||
|
||||
if (onZoomLevelChange) onZoomLevelChange(newLevel);
|
||||
|
||||
if (!zoomLevel) return;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (zoomLevel) {
|
||||
const zoomInOptions: ZoomInOptions = {
|
||||
camera: cameraControllerSide,
|
||||
multiplier: zoomLevel,
|
||||
};
|
||||
mutation.mutate(zoomInOptions);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [zoomLevel]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col md:flex-row">
|
||||
<NavigationArrow side={side} settingsPage={settingsPage} />
|
||||
<div className="w-full">
|
||||
<div className="w-full bg-[#253445] rounded-md overflow-hidden md:h-[500px] lg:h-[70vh]">
|
||||
{isError && <ErrorState />}
|
||||
{isPending && (
|
||||
<div className="my-50 h-[50%]">
|
||||
<div className="absolute inset-0 grid place-items-center">
|
||||
<Loading message="Camera Preview" />
|
||||
</div>
|
||||
)}
|
||||
<canvas
|
||||
onClick={handleZoomClick}
|
||||
ref={canvasRef}
|
||||
className="absolute inset-0 object-contain min-h-[100%] z-20"
|
||||
/>
|
||||
<canvas ref={canvasRef} className="absolute w-full h-full z-20" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -4,14 +4,14 @@ import { useEffect, useMemo, useState } from "react";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faEye, faEyeSlash } from "@fortawesome/free-regular-svg-icons";
|
||||
import CardHeader from "../UI/CardHeader";
|
||||
import { useCameraZoom } from "../../hooks/useCameraZoom";
|
||||
import { parseRTSPUrl } from "../../utils/utils";
|
||||
import { useCameraMode, useCameraZoom } from "../../hooks/useCameraZoom";
|
||||
import { capitalize, parseRTSPUrl, reverseZoomMapping, zoomMapping } from "../../utils/utils";
|
||||
|
||||
type CameraSettingsProps = {
|
||||
initialData: CameraConfig;
|
||||
updateCameraConfig: (values: CameraSettingValues) => Promise<void> | void;
|
||||
zoomLevel?: number;
|
||||
onZoomLevelChange?: (level: number) => void;
|
||||
onZoomLevelChange?: (level: number | undefined) => void;
|
||||
updateCameraConfigError: null | Error;
|
||||
};
|
||||
|
||||
@@ -20,38 +20,21 @@ const CameraSettingFields = ({
|
||||
updateCameraConfig,
|
||||
zoomLevel,
|
||||
onZoomLevelChange,
|
||||
updateCameraConfigError,
|
||||
}: CameraSettingsProps) => {
|
||||
const [showPwd, setShowPwd] = useState(false);
|
||||
const cameraControllerSide = initialData?.id === "CameraA" ? "CameraControllerA" : "CameraControllerB";
|
||||
const { mutation, query } = useCameraZoom({ camera: cameraControllerSide });
|
||||
const zoomOptions = [1, 2, 4, 8];
|
||||
|
||||
const { cameraModeQuery, cameraModeMutation } = useCameraMode({ camera: cameraControllerSide });
|
||||
const zoomOptions = [1, 2, 4];
|
||||
const magnification = query?.data?.propMagnification?.value;
|
||||
const apiZoom = reverseZoomMapping(magnification);
|
||||
const parsed = parseRTSPUrl(initialData?.propURI?.value);
|
||||
const cameraMode = cameraModeQuery?.data?.propDayNightMode?.value;
|
||||
|
||||
useEffect(() => {
|
||||
if (!query?.data) return;
|
||||
const apiZoom = getZoomLevel(query.data);
|
||||
onZoomLevelChange?.(apiZoom);
|
||||
}, [query?.data, onZoomLevelChange]);
|
||||
|
||||
const getZoomLevel = (levelstring: string | undefined) => {
|
||||
switch (levelstring) {
|
||||
case "1x":
|
||||
return 1;
|
||||
|
||||
case "2x":
|
||||
return 2;
|
||||
|
||||
case "4x":
|
||||
return 4;
|
||||
|
||||
case "8x":
|
||||
return 8;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
}, [query?.data, onZoomLevelChange, apiZoom]);
|
||||
|
||||
const initialValues = useMemo<CameraSettingValues>(
|
||||
() => ({
|
||||
@@ -60,11 +43,11 @@ const CameraSettingFields = ({
|
||||
userName: parsed?.username ?? "",
|
||||
password: parsed?.password ?? "",
|
||||
id: initialData?.id,
|
||||
|
||||
zoom: zoomLevel,
|
||||
mode: cameraMode ?? "",
|
||||
zoom: apiZoom,
|
||||
}),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[initialData?.id, initialData?.propURI?.value, zoomLevel]
|
||||
|
||||
[initialData?.id, initialData?.propURI?.value, parsed?.username, parsed?.password, cameraMode, apiZoom]
|
||||
);
|
||||
|
||||
const validateValues = (values: CameraSettingValues) => {
|
||||
@@ -80,15 +63,18 @@ const CameraSettingFields = ({
|
||||
|
||||
const handleRadioButtonChange = async (levelNumber: number) => {
|
||||
if (!onZoomLevelChange || !zoomLevel) return;
|
||||
const text = zoomMapping(levelNumber);
|
||||
onZoomLevelChange(levelNumber);
|
||||
|
||||
const zoomInOptions: ZoomInOptions = {
|
||||
camera: cameraControllerSide,
|
||||
multiplier: levelNumber,
|
||||
multiplierText: text,
|
||||
};
|
||||
|
||||
mutation.mutate(zoomInOptions);
|
||||
};
|
||||
|
||||
const selectedZoom = zoomLevel ?? 1;
|
||||
return (
|
||||
<Formik
|
||||
@@ -98,8 +84,8 @@ const CameraSettingFields = ({
|
||||
validateOnChange={false}
|
||||
enableReinitialize
|
||||
>
|
||||
{({ errors, touched }) => (
|
||||
<Form className="flex flex-col space-y-6 p-2">
|
||||
{({ errors, touched, values, setFieldValue, isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-6 p-2 overflow-x-hidden">
|
||||
<div className="flex flex-col space-y-2 relative">
|
||||
<label htmlFor="friendlyName">Name</label>
|
||||
{touched.friendlyName && errors.friendlyName && (
|
||||
@@ -111,7 +97,6 @@ const CameraSettingFields = ({
|
||||
type="text"
|
||||
className="p-2 border border-gray-400 rounded-lg"
|
||||
placeholder="Enter camera name"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -126,7 +111,6 @@ const CameraSettingFields = ({
|
||||
type="text"
|
||||
className="p-2 border border-gray-400 rounded-lg"
|
||||
placeholder="RTSP://..."
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -142,7 +126,6 @@ const CameraSettingFields = ({
|
||||
className="p-2 border border-gray-400 rounded-lg"
|
||||
placeholder="Enter user name"
|
||||
autoComplete="username"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -158,7 +141,6 @@ const CameraSettingFields = ({
|
||||
type={showPwd ? "text" : "password"}
|
||||
className="p-2 border border-gray-400 rounded-lg w-full "
|
||||
placeholder="Enter password"
|
||||
disabled
|
||||
/>
|
||||
<FontAwesomeIcon
|
||||
type="button"
|
||||
@@ -169,7 +151,7 @@ const CameraSettingFields = ({
|
||||
</div>
|
||||
<div className="my-3">
|
||||
<CardHeader title="Zoom settings" />
|
||||
<div className="mx-auto grid grid-cols-4 items-center">
|
||||
<div className="mx-auto grid grid-cols-3 place-items-center">
|
||||
{zoomOptions.map((zoom) => (
|
||||
<div key={zoom} className="my-3">
|
||||
<Field
|
||||
@@ -187,27 +169,53 @@ const CameraSettingFields = ({
|
||||
peer-checked:border-2 peer-checked:border-blue-900
|
||||
peer-checked:text-blue-600 peer-checked:bg-gray-100"
|
||||
>
|
||||
x{zoom}
|
||||
{zoomMapping(zoom)}
|
||||
</label>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<CardHeader title="Mode" />
|
||||
<div
|
||||
role="radiogroup"
|
||||
aria-label="Camera mode"
|
||||
className="mx-auto grid grid-cols-3 place-items-center gap-3"
|
||||
>
|
||||
{["day", "night", "auto"].map((el) => (
|
||||
<div key={el} className="my-3">
|
||||
<Field
|
||||
type="radio"
|
||||
name="mode"
|
||||
value={el}
|
||||
checked={values.mode === el}
|
||||
id={`mode-${el}`}
|
||||
className="peer hidden"
|
||||
disabled={cameraModeMutation.isPending}
|
||||
onChange={async () => {
|
||||
setFieldValue("mode", el);
|
||||
await cameraModeMutation.mutateAsync({ camera: cameraControllerSide, mode: el });
|
||||
}}
|
||||
/>
|
||||
<label
|
||||
htmlFor={`mode-${el}`}
|
||||
className={`px-8 py-2 rounded-md border border-gray-300
|
||||
peer-checked:border-2 peer-checked:border-blue-900
|
||||
peer-checked:text-blue-600 peer-checked:bg-gray-100
|
||||
${cameraModeMutation.isPending ? "opacity-60 cursor-not-allowed" : "cursor-pointer"}`}
|
||||
>
|
||||
{capitalize(el)}
|
||||
</label>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3">
|
||||
{updateCameraConfigError ? (
|
||||
<button className="bg-red-500 text-white rounded-lg p-2 mx-auto h-[100%] w-full" disabled>
|
||||
Retry
|
||||
{
|
||||
<button type="submit" className="bg-green-700 text-white rounded-lg p-2 mx-auto w-full">
|
||||
{isSubmitting ? "Saving" : "Save settings"}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
type="submit"
|
||||
className="bg-blue-700 text-white rounded-lg p-2 mx-auto h-[100%] w-full"
|
||||
disabled
|
||||
>
|
||||
{/* {isSubmitting ? "Saving" : "Save settings"} bg-[#26B170] */}
|
||||
{"Disabled: Coming soon"}
|
||||
</button>
|
||||
)}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
|
||||
@@ -13,15 +13,14 @@ const CameraSettings = ({
|
||||
title: string;
|
||||
side: string;
|
||||
zoomLevel?: number;
|
||||
onZoomLevelChange?: (level: number) => void;
|
||||
onZoomLevelChange?: (level: number | undefined) => void;
|
||||
}) => {
|
||||
const { data, updateCameraConfig, updateCameraConfigError } = useFetchCameraConfig(side);
|
||||
|
||||
return (
|
||||
<Card className="overflow-hidden min-h-[40vh] md:min-h-[60vh] max-h-[80vh] lg:w-[40%] p-4">
|
||||
<Card className="overflow-x-visible min-h-[40vh] md:min-h-[60vh] lg:w-[40%] p-4">
|
||||
<div className="relative flex flex-col space-y-3">
|
||||
<CardHeader title={title} icon={faWrench} />
|
||||
|
||||
{
|
||||
<CameraSettingFields
|
||||
initialData={data}
|
||||
|
||||
@@ -8,8 +8,8 @@ import SightingOverview from "../SightingOverview/SightingOverview";
|
||||
const FrontCameraOverviewCard = () => {
|
||||
const navigate = useNavigate();
|
||||
const handlers = useSwipeable({
|
||||
onSwipedRight: () => navigate("/camera-settings"),
|
||||
onSwipedLeft: () => navigate("/rear-camera-settings"),
|
||||
onSwipedRight: () => navigate("/a-camera-settings"),
|
||||
onSwipedLeft: () => navigate("/b-camera-settings"),
|
||||
trackMouse: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -20,17 +20,17 @@ const OverviewVideoContainer = ({
|
||||
const location = useLocation();
|
||||
const handlers = useSwipeable({
|
||||
onSwipedLeft: () => {
|
||||
if (location.pathname === "/rear-camera-settings") return;
|
||||
if (location.pathname === "/b-camera-settings") return;
|
||||
navigate("/");
|
||||
},
|
||||
onSwipedRight: () => {
|
||||
if (location.pathname === "/camera-settings") return;
|
||||
if (location.pathname === "/a-camera-settings") return;
|
||||
navigate("/");
|
||||
},
|
||||
trackMouse: true,
|
||||
});
|
||||
return (
|
||||
<Card className={clsx("relative min-h-[40vh] md:min-h-[60vh] max-h-[80vh] lg:w-[70%] overflow-y-hidden")}>
|
||||
<Card className={clsx("relative min-h-[40vh] md:min-h-[40vh] max-h-[70vh] lg:w-[70%] overflow-y-hidden")}>
|
||||
<div className="w-full" {...handlers}>
|
||||
<SnapshotContainer
|
||||
side={side}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useCameraBlackboard } from "../../hooks/useCameraBlackboard";
|
||||
import NPED_CAT_A from "/NPED_Cat_A.svg";
|
||||
import NPED_CAT_B from "/NPED_Cat_B.svg";
|
||||
import NPED_CAT_C from "/NPED_Cat_C.svg";
|
||||
import NPED_CAT_D from "/NPED_Cat_D.svg";
|
||||
import { checkIsHotListHit, formatAge, getNPEDCategory } from "../../utils/utils";
|
||||
import { faX } from "@fortawesome/free-solid-svg-icons";
|
||||
import { faClock } from "@fortawesome/free-regular-svg-icons";
|
||||
@@ -30,6 +31,7 @@ const AlertItem = ({ item }: AlertItemProps) => {
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
const isNPEDHitD = cat === "D";
|
||||
|
||||
const handleClick = () => {
|
||||
setIsModalOpen(true);
|
||||
@@ -69,6 +71,7 @@ const AlertItem = ({ item }: AlertItemProps) => {
|
||||
{isNPEDHitA && <img src={NPED_CAT_A} alt="NPEDHITicon" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitB && <img src={NPED_CAT_B} alt="NPEDHITicon" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitC && <img src={NPED_CAT_C} alt="NPEDHITicon" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitD && <img src={NPED_CAT_D} alt="NPEDHITicon" className="h-20 object-contain rounded-md" />}
|
||||
<div className={`border p-1 hidden md:block`}>
|
||||
<img src={item?.plateUrlColour} height={48} width={200} alt="colour patch" />
|
||||
</div>
|
||||
|
||||
@@ -31,9 +31,7 @@ const HistoryList = () => {
|
||||
<div className="flex flex-col gap-1 px-2">
|
||||
{state?.alertList?.length > 0 ? (
|
||||
<div className="mt-3 grid grid-cols-1 gap-3">
|
||||
{state?.alertList?.map((alertItem) => (
|
||||
<AlertItem item={alertItem} key={alertItem.vrm} />
|
||||
))}
|
||||
{state?.alertList?.map((alertItem) => <AlertItem item={alertItem} key={alertItem.vrm} />).reverse()}
|
||||
</div>
|
||||
) : (
|
||||
<div className="mt-4 flex flex-col items-center justify-center rounded-2xl border border-slate-800 bg-slate-900/40 p-10 text-center">
|
||||
|
||||
67
src/components/HotlistList/HotlistList.tsx
Normal file
67
src/components/HotlistList/HotlistList.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
import { useHotlistData } from "../../hooks/useHotListData";
|
||||
import { useIntegrationsContext } from "../../context/IntegrationsContext";
|
||||
import Card from "../UI/Card";
|
||||
import CardHeader from "../UI/CardHeader";
|
||||
import { toast } from "sonner";
|
||||
import { faTrash } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
|
||||
const HotlistList = () => {
|
||||
const { state, dispatch } = useIntegrationsContext();
|
||||
const { mutation } = useHotlistData();
|
||||
|
||||
const hotlists = state?.hotlistFiles;
|
||||
|
||||
const handleDeleteClick = async (filename: string) => {
|
||||
await mutation.mutateAsync(filename);
|
||||
dispatch({ type: "DELETEHOTLIST", payload: filename });
|
||||
toast.success(`${filename} successfully deleted`);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="p-4">
|
||||
<CardHeader title="Uploaded hotlists" />
|
||||
{hotlists?.length > 0 ? (
|
||||
<ul className="px-2">
|
||||
{hotlists?.map((hotlist) => (
|
||||
<li
|
||||
key={hotlist.filename}
|
||||
className="flex flex-row justify-between my-3 items-center border-b border-gray-700"
|
||||
>
|
||||
<div>
|
||||
<p className="text-xl">{hotlist.filename}</p>
|
||||
<div className="flex flex-row gap-3">
|
||||
<div>
|
||||
<p className="text-gray-400">
|
||||
Number of records: <span>{hotlist.rowCount}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-gray-400">
|
||||
File Size (bytes): <span>{hotlist.fileSizeBytes}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button onClick={() => handleDeleteClick(hotlist.filename)}>
|
||||
<FontAwesomeIcon icon={faTrash} />
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<div className="mt-4 flex flex-col items-center justify-center rounded-2xl border border-slate-800 bg-slate-900/40 p-10 text-center">
|
||||
<div className="mb-3 rounded-xl bg-slate-800 px-3 py-1 text-xs uppercase tracking-wider text-slate-400">
|
||||
No Uploaded Hotlists
|
||||
</div>
|
||||
<p className="max-w-md text-slate-300">
|
||||
<span className="text-emerald-400">Hotlists</span> will appear here once there are uploaded.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default HotlistList;
|
||||
@@ -40,9 +40,7 @@ const NumberPlate = ({ motion, vrm, size }: NumberPlateProps) => {
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`relative ${options.plateWidth} ${
|
||||
options.borderWidth
|
||||
} border-black rounded-xl text-nowrap
|
||||
className={`relative ${options.plateWidth} ${options.borderWidth} border-black rounded-xl text-nowrap
|
||||
text-black px-6 py-2
|
||||
${motion ? "bg-yellow-400" : "bg-white"}`}
|
||||
>
|
||||
@@ -50,9 +48,7 @@ const NumberPlate = ({ motion, vrm, size }: NumberPlateProps) => {
|
||||
<div className="absolute inset-y-0 left-0 bg-blue-600 w-8 flex flex-col">
|
||||
<GB />
|
||||
</div>
|
||||
<p className={`pl-4 font-extrabold ${options.textSize} text-right`}>
|
||||
{vrm && formatNumberPlate(vrm)}
|
||||
</p>
|
||||
<p className={`pl-4 font-extrabold ${options.textSize} text-right`}>{vrm && formatNumberPlate(vrm)}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
74
src/components/PopupSettings/NPEDCategoryPopup.tsx
Normal file
74
src/components/PopupSettings/NPEDCategoryPopup.tsx
Normal file
@@ -0,0 +1,74 @@
|
||||
import Card from "../UI/Card";
|
||||
import CardHeader from "../UI/CardHeader";
|
||||
import NPEDCatToggle from "../SettingForms/NPED/NPEDCatToggle";
|
||||
import FormGroup from "../SettingForms/components/FormGroup";
|
||||
import { Form, Formik } from "formik";
|
||||
import { useIntegrationsContext } from "../../context/IntegrationsContext";
|
||||
import { useCameraBlackboard } from "../../hooks/useCameraBlackboard";
|
||||
import type { CategoryPopups } from "../../types/types";
|
||||
import { toast } from "sonner";
|
||||
|
||||
const NPEDCategoryPopup = () => {
|
||||
const { state, dispatch } = useIntegrationsContext();
|
||||
|
||||
const { mutation } = useCameraBlackboard();
|
||||
|
||||
const isCatAEnabled = state?.iscatEnabled?.catA;
|
||||
const isCatBEnabled = state?.iscatEnabled?.catB;
|
||||
const isCatCEnabled = state?.iscatEnabled?.catC;
|
||||
const isCatDEnabled = state?.iscatEnabled?.catD;
|
||||
|
||||
const initialValues = {
|
||||
catA: isCatAEnabled ?? true,
|
||||
catB: isCatBEnabled ?? true,
|
||||
catC: isCatCEnabled ?? true,
|
||||
catD: isCatDEnabled ?? false,
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: CategoryPopups) => {
|
||||
const result = await mutation.mutateAsync({
|
||||
operation: "INSERT",
|
||||
value: values,
|
||||
path: "CategoryPopup",
|
||||
});
|
||||
|
||||
await mutation.mutateAsync({
|
||||
operation: "SAVE",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
if (result?.reason === "OK") toast.success("Pop up settings saved");
|
||||
dispatch({ type: "NPEDCATENABLED", payload: values });
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="p-4">
|
||||
<CardHeader title={"Alert Pop ups"} />
|
||||
<p className="italic my-2">Allows alerts to pop up to user.</p>
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
<FormGroup>
|
||||
<NPEDCatToggle name={"catA"} label="NPED Category A" />
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<NPEDCatToggle name={"catB"} label="NPED Category B" />
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<NPEDCatToggle name={"catC"} label="NPED Category C" />
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<NPEDCatToggle name={"catD"} label="NPED Category D" />
|
||||
</FormGroup>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</Form>
|
||||
</Formik>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default NPEDCategoryPopup;
|
||||
@@ -13,7 +13,7 @@ type CardProps = React.HTMLAttributes<HTMLDivElement>;
|
||||
const RearCameraOverviewCard = ({ className }: CardProps) => {
|
||||
const navigate = useNavigate();
|
||||
const handlers = useSwipeable({
|
||||
onSwipedLeft: () => navigate("/rear-camera-settings"),
|
||||
onSwipedLeft: () => navigate("/b-camera-settings"),
|
||||
trackMouse: true,
|
||||
});
|
||||
const { mostRecent } = useSightingFeedContext();
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
import Card from "../UI/Card";
|
||||
import CardHeader from "../UI/CardHeader";
|
||||
import { useNPEDContext } from "../../context/NPEDUserContext";
|
||||
import { useIntegrationsContext } from "../../context/IntegrationsContext";
|
||||
import type { ReducedSightingType } from "../../types/types";
|
||||
import { toast } from "sonner";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faFloppyDisk, faPause, faPlay, faStop, faArrowRotateRight } from "@fortawesome/free-solid-svg-icons";
|
||||
import VehicleSessionItem from "../UI/VehicleSessionItem";
|
||||
import { useCameraBlackboard } from "../../hooks/useCameraBlackboard";
|
||||
|
||||
const SessionCard = () => {
|
||||
const { sessionStarted, setSessionStarted, sessionList } = useNPEDContext();
|
||||
const { state, dispatch } = useIntegrationsContext();
|
||||
const { mutation } = useCameraBlackboard();
|
||||
|
||||
const handleStartClick = () => {
|
||||
setSessionStarted(!sessionStarted);
|
||||
toast(`${sessionStarted ? "Vehicle tracking session Ended" : "Vehicle tracking session Started"}`);
|
||||
};
|
||||
const sessionStarted = state.sessionStarted;
|
||||
const sessionPaused = state.sessionPaused;
|
||||
const sessionList = state.sessionList;
|
||||
|
||||
const sightings = [...new Map(sessionList.map((vehicle) => [vehicle.vrm, vehicle]))];
|
||||
const sightings = [...new Map(sessionList?.map((vehicle) => [vehicle.vrm, vehicle]))];
|
||||
|
||||
const dedupedSightings = sightings.map((sighting) => sighting[1]);
|
||||
|
||||
const vehicles = dedupedSightings.reduce<Record<string, ReducedSightingType[]>>(
|
||||
(acc, item) => {
|
||||
const hotlisthit = Object.values(item.metadata?.hotlistMatches ?? {}).includes(true);
|
||||
if (item.metadata?.npedJSON["NPED CATEGORY"] === "A") acc.npedCatA.push(item);
|
||||
if (item.metadata?.npedJSON["NPED CATEGORY"] === "B") acc.npedCatB.push(item);
|
||||
if (item.metadata?.npedJSON["NPED CATEGORY"] === "C") acc.npedCatC.push(item);
|
||||
if (item.metadata?.npedJSON["NPED CATEGORY"] === "D") acc.npedCatD.push(item);
|
||||
if (item.metadata?.npedJSON["TAX STATUS"] === false) acc.notTaxed.push(item);
|
||||
if (item.metadata?.npedJSON["MOT STATUS"] === false) acc.notMOT.push(item);
|
||||
|
||||
if (hotlisthit) acc.hotlistHit.push(item);
|
||||
acc.vehicles.push(item);
|
||||
return acc;
|
||||
},
|
||||
{
|
||||
@@ -34,9 +40,51 @@ const SessionCard = () => {
|
||||
npedCatD: [],
|
||||
notTaxed: [],
|
||||
notMOT: [],
|
||||
hotlistHit: [],
|
||||
vehicles: [],
|
||||
}
|
||||
);
|
||||
|
||||
const handleStartClick = () => {
|
||||
dispatch({ type: "SESSIONSTART", payload: !sessionStarted });
|
||||
dispatch({ type: "SESSIONPAUSE", payload: false });
|
||||
toast(`${sessionStarted ? "Vehicle tracking session ended" : "Vehicle tracking session started"}`);
|
||||
};
|
||||
|
||||
const handlepauseClick = () => {
|
||||
dispatch({ type: "SESSIONPAUSE", payload: !sessionPaused });
|
||||
toast(`${sessionStarted ? "Vehicle tracking session paused" : "Vehicle tracking session resumed"}`);
|
||||
};
|
||||
|
||||
const handleSaveCick = async () => {
|
||||
const result = await mutation.mutateAsync({
|
||||
operation: "INSERT",
|
||||
path: "sessionStats",
|
||||
value: dedupedSightings,
|
||||
});
|
||||
await mutation.mutateAsync({
|
||||
operation: "SAVE",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
if (result.reason === "OK") toast.success("Session saved");
|
||||
};
|
||||
|
||||
const handleRestartClick = async () => {
|
||||
const result = await mutation.mutateAsync({
|
||||
operation: "INSERT",
|
||||
path: "sessionStats",
|
||||
value: [],
|
||||
});
|
||||
await mutation.mutateAsync({
|
||||
operation: "SAVE",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
if (result.reason === "OK") toast.success("Session restarted");
|
||||
dispatch({ type: "SESSIONRESTART", payload: [] });
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="p-4 col-span-3">
|
||||
<CardHeader title="Session" />
|
||||
@@ -47,34 +95,88 @@ const SessionCard = () => {
|
||||
} transition w-full`}
|
||||
onClick={handleStartClick}
|
||||
>
|
||||
{sessionStarted ? "End Session" : "Start Session"}
|
||||
<div className="flex flex-row gap-3 items-center justify-self-center">
|
||||
<FontAwesomeIcon icon={sessionStarted ? faStop : faPlay} />
|
||||
<p>{sessionStarted ? "End Session" : "Start Session"}</p>
|
||||
</div>
|
||||
</button>
|
||||
{sessionStarted && (
|
||||
<button
|
||||
className={`bg-none text-white px-4 py-2 rounded transition w-full border border-gray-500 hover:bg-gray-500 hover:text-gray-900`}
|
||||
onClick={handleRestartClick}
|
||||
>
|
||||
<div className="flex flex-row gap-3 items-center justify-self-center">
|
||||
<FontAwesomeIcon icon={faArrowRotateRight} />
|
||||
<p>Restart Session</p>
|
||||
</div>
|
||||
</button>
|
||||
)}
|
||||
<div className="flex flex-col lg:flex-row gap-5">
|
||||
{sessionStarted && (
|
||||
<button
|
||||
className={`bg-blue-600 text-white px-4 py-2 rounded transition w-full lg:w-[50%]`}
|
||||
onClick={handleSaveCick}
|
||||
>
|
||||
<div className="flex flex-row gap-3 items-center justify-self-center">
|
||||
<FontAwesomeIcon icon={faFloppyDisk} />
|
||||
<p>Save session</p>
|
||||
</div>
|
||||
</button>
|
||||
)}
|
||||
{sessionStarted && (
|
||||
<button
|
||||
className={`bg-gray-300 text-gray-800 px-4 py-2 rounded transition w-full lg:w-[50%]`}
|
||||
onClick={handlepauseClick}
|
||||
>
|
||||
<div className="flex flex-row gap-3 items-center justify-self-center">
|
||||
<FontAwesomeIcon icon={sessionPaused ? faPlay : faPause} />
|
||||
<p>{sessionPaused ? "Resume session" : "Pause session"}</p>
|
||||
</div>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ul className="text-white space-y-2">
|
||||
<li className="rounded-xl border border-slate-800 bg-slate-800/60 p-3 shadow-sm flex flex-row justify-between">
|
||||
<p>Number of Vehicles:</p>
|
||||
<span className="font-bold text-green-600 text-xl">{dedupedSightings.length}</span>
|
||||
</li>
|
||||
<li className="rounded-xl border border-slate-800 bg-slate-800/60 p-3 shadow-sm flex flex-row justify-between">
|
||||
<p>Vehicles without Tax:</p>
|
||||
<span className="font-bold text-amber-600 text-xl">{vehicles.notTaxed.length}</span>
|
||||
</li>
|
||||
<li className="rounded-xl border border-slate-800 bg-slate-800/60 p-3 shadow-sm flex flex-row justify-between">
|
||||
<p>Vehicles without MOT:</p>{" "}
|
||||
<span className="font-bold text-red-500 text-xl">{vehicles.notMOT.length}</span>
|
||||
</li>
|
||||
<li className="rounded-xl border border-slate-800 bg-slate-800/60 p-3 shadow-sm flex flex-row justify-between">
|
||||
<p>Vehicles with NPED Cat A:</p>
|
||||
<span className="font-bold text-gray-300 text-xl">{vehicles.npedCatA.length}</span>
|
||||
</li>
|
||||
<li className="rounded-xl border border-slate-800 bg-slate-800/60 p-3 shadow-sm flex flex-row justify-between">
|
||||
<p>Vehicles with NPED Cat B:</p>{" "}
|
||||
<span className="font-bold text-gray-300text-xl">{vehicles.npedCatB.length}</span>
|
||||
</li>
|
||||
<li className="rounded-xl border border-slate-800 bg-slate-800/60 p-3 shadow-sm flex flex-row justify-between">
|
||||
Vehicles with NPED Cat C:{" "}
|
||||
<span className="font-bold text-gray-300 text-xl">{vehicles.npedCatC.length}</span>
|
||||
</li>
|
||||
<VehicleSessionItem
|
||||
sessionNumber={vehicles.vehicles.length}
|
||||
textColour="text-green-400"
|
||||
vehicleTag={"Number of Vehicles sightings:"}
|
||||
/>
|
||||
<VehicleSessionItem
|
||||
sessionNumber={vehicles.notTaxed.length}
|
||||
textColour="text-amber-400"
|
||||
vehicleTag={"Vehicles without Tax:"}
|
||||
/>
|
||||
<VehicleSessionItem
|
||||
sessionNumber={vehicles.notMOT.length}
|
||||
textColour="text-red-500"
|
||||
vehicleTag={"Vehicles without MOT:"}
|
||||
/>
|
||||
<VehicleSessionItem
|
||||
sessionNumber={vehicles.hotlistHit.length}
|
||||
textColour="text-blue-400"
|
||||
vehicleTag={"Vehicles on Hotlists:"}
|
||||
/>
|
||||
<VehicleSessionItem
|
||||
sessionNumber={vehicles.npedCatA.length}
|
||||
textColour="text-gray-300"
|
||||
vehicleTag={"Vehicles with NPED Cat A:"}
|
||||
/>
|
||||
<VehicleSessionItem
|
||||
sessionNumber={vehicles.npedCatB.length}
|
||||
textColour="text-gray-300"
|
||||
vehicleTag={"Vehicles with NPED Cat B:"}
|
||||
/>
|
||||
<VehicleSessionItem
|
||||
sessionNumber={vehicles.npedCatC.length}
|
||||
textColour="text-gray-300"
|
||||
vehicleTag={"Vehicles with NPED Cat C:"}
|
||||
/>
|
||||
<VehicleSessionItem
|
||||
sessionNumber={vehicles.npedCatD.length}
|
||||
textColour="text-gray-300"
|
||||
vehicleTag={"Vehicles with NPED Cat D:"}
|
||||
/>
|
||||
</ul>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -4,7 +4,7 @@ import BearerTypeFields from "./BearerTypeFields";
|
||||
|
||||
const BearerTypeCard = () => {
|
||||
return (
|
||||
<Card className="p-4">
|
||||
<Card className="p-4 h-60">
|
||||
<CardHeader title="Bearer Type" />
|
||||
<BearerTypeFields />
|
||||
</Card>
|
||||
|
||||
@@ -1,69 +1,35 @@
|
||||
import { Field, Form, Formik } from "formik";
|
||||
import { Field, useFormikContext } from "formik";
|
||||
import FormToggle from "../components/FormToggle";
|
||||
import { useCameraOutput } from "../../../hooks/useCameraOutput";
|
||||
import { cleanArray } from "../../../utils/utils";
|
||||
import FormGroup from "../components/FormGroup";
|
||||
import type { BearerTypeFieldType } from "../../../types/types";
|
||||
|
||||
export const ValuesComponent = () => {
|
||||
return null;
|
||||
};
|
||||
import type { BearerTypeFieldType, InitialValuesForm } from "../../../types/types";
|
||||
|
||||
const BearerTypeFields = () => {
|
||||
const { dispatcherQuery, dispatcherMutation } = useCameraOutput();
|
||||
|
||||
const format = dispatcherQuery?.data?.propFormat?.value;
|
||||
const rawOptions = dispatcherQuery?.data?.propFormat?.accepted;
|
||||
const enabled = dispatcherQuery?.data?.propEnabled?.value;
|
||||
const verbose = dispatcherQuery?.data?.propVerbose?.value;
|
||||
const options = cleanArray(rawOptions);
|
||||
|
||||
const initialValues: BearerTypeFieldType = {
|
||||
format: format ?? "JSON",
|
||||
enabled: enabled === "true",
|
||||
verbose: verbose === "true",
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: BearerTypeFieldType) => {
|
||||
await dispatcherMutation.mutateAsync(values);
|
||||
};
|
||||
useFormikContext<BearerTypeFieldType & InitialValuesForm>();
|
||||
|
||||
return (
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
{({ isSubmitting }) => (
|
||||
<Form>
|
||||
<div className="flex flex-col space-y-4 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="format">Format</label>
|
||||
<Field
|
||||
as="select"
|
||||
name="format"
|
||||
id="format"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
{options?.map((option: string) => (
|
||||
<option key={option} value={option}>
|
||||
{option}
|
||||
</option>
|
||||
))}
|
||||
</Field>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<div className="flex flex-col space-y-4">
|
||||
<FormToggle name="enabled" label="Enabled" />
|
||||
<FormToggle name="verbose" label="Verbose" />
|
||||
</div>
|
||||
</FormGroup>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
{isSubmitting || dispatcherMutation.isPending ? "Saving..." : "Save Changes"}
|
||||
</button>
|
||||
</div>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
<div className="flex flex-col space-y-4 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="format">Format</label>
|
||||
<Field
|
||||
as="select"
|
||||
name="format"
|
||||
id="format"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
<option key={"JSON"} value={"JSON"}>
|
||||
JSON
|
||||
</option>
|
||||
<option key={"BOF2"} value={"BOF2"}>
|
||||
BOF2
|
||||
</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<div className="flex flex-col space-y-4">
|
||||
<FormToggle name="enabled" label="Enabled" />
|
||||
</div>
|
||||
</FormGroup>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +1,54 @@
|
||||
import { useFormikContext, type FormikTouched } from "formik";
|
||||
import Card from "../../UI/Card";
|
||||
import CardHeader from "../../UI/CardHeader";
|
||||
import ChannelFields from "./ChannelFields";
|
||||
import type { BearerTypeFieldType, InitialValuesForm } from "../../../types/types";
|
||||
import { useCameraBackOfficeOutput } from "../../../hooks/useBackOfficeConfig";
|
||||
import { useEffect, useMemo } from "react";
|
||||
|
||||
type ChannelCardProps = {
|
||||
touched: FormikTouched<BearerTypeFieldType & InitialValuesForm>;
|
||||
isSubmitting: boolean;
|
||||
isBof2ConstantsLoading: boolean;
|
||||
isDispatcherLoading: boolean;
|
||||
};
|
||||
|
||||
const ChannelCard = ({ touched, isSubmitting, isBof2ConstantsLoading, isDispatcherLoading }: ChannelCardProps) => {
|
||||
const { values, setFieldValue } = useFormikContext<BearerTypeFieldType & InitialValuesForm>();
|
||||
const { backOfficeQuery } = useCameraBackOfficeOutput(values?.format);
|
||||
const isBackOfficeQueryLoading = backOfficeQuery?.isFetching;
|
||||
|
||||
const mapped = useMemo(() => {
|
||||
const d = backOfficeQuery?.data;
|
||||
return {
|
||||
backOfficeURL: d?.propBackofficeURL?.value ?? "",
|
||||
username: d?.propUsername?.value ?? "",
|
||||
password: d?.propPassword?.value ?? "",
|
||||
connectTimeoutSeconds: Number(d?.propConnectTimeoutSeconds?.value),
|
||||
readTimeoutSeconds: Number(d?.propReadTimeoutSeconds?.value),
|
||||
};
|
||||
}, [backOfficeQuery?.data]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!backOfficeQuery?.isSuccess) return;
|
||||
for (const [key, value] of Object.entries(mapped)) {
|
||||
setFieldValue(key, value);
|
||||
}
|
||||
}, [backOfficeQuery.isSuccess, mapped, setFieldValue]);
|
||||
|
||||
const ChannelCard = () => {
|
||||
return (
|
||||
<Card className="p-4">
|
||||
<CardHeader title="Channel 1 (JSON)" />
|
||||
<ChannelFields />
|
||||
<Card className="p-4 overflow-y-auto ">
|
||||
<CardHeader title={`Channel (${values?.format})`} />
|
||||
{!isBof2ConstantsLoading && !isDispatcherLoading && !isBackOfficeQueryLoading ? (
|
||||
<ChannelFields
|
||||
touched={touched}
|
||||
isSubmitting={isSubmitting}
|
||||
backOfficeData={backOfficeQuery}
|
||||
format={values?.format}
|
||||
/>
|
||||
) : (
|
||||
<>Loading...</>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,79 +1,52 @@
|
||||
import { Field, Form, Formik, useFormikContext } from "formik";
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { Field, useFormikContext, type FormikTouched } from "formik";
|
||||
import FormGroup from "../components/FormGroup";
|
||||
import { useEffect, useState } from "react";
|
||||
import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { useCameraOutput } from "../../../hooks/useCameraOutput";
|
||||
import type { InitialValuesForm, InitialValuesFormErrors } from "../../../types/types";
|
||||
import type { BearerTypeFieldType, InitialValuesForm } from "../../../types/types";
|
||||
import { toast } from "sonner";
|
||||
import type { UseQueryResult } from "@tanstack/react-query";
|
||||
|
||||
const ChannelFields = () => {
|
||||
type ChannelFieldsProps = {
|
||||
touched: FormikTouched<BearerTypeFieldType & InitialValuesForm>;
|
||||
isSubmitting: boolean;
|
||||
|
||||
backOfficeData: UseQueryResult<any, Error>;
|
||||
format?: string;
|
||||
};
|
||||
|
||||
const ChannelFields = ({ touched, isSubmitting, format }: ChannelFieldsProps) => {
|
||||
const [showPwd, setShowPwd] = useState(false);
|
||||
const { backOfficeQuery, backOfficeMutation } = useCameraOutput();
|
||||
|
||||
const backOfficeURL = backOfficeQuery?.data?.propBackofficeURL?.value;
|
||||
const username = backOfficeQuery?.data?.propUsername?.value;
|
||||
const password = backOfficeQuery?.data?.propPassword?.value;
|
||||
const connectTimeoutSeconds = backOfficeQuery?.data?.propConnectTimeoutSeconds?.value;
|
||||
const readTimeoutSeconds = backOfficeQuery?.data?.propReadTimeoutSeconds?.value;
|
||||
|
||||
const initialValues: InitialValuesForm = {
|
||||
backOfficeURL: backOfficeURL ?? "",
|
||||
username: username ?? "",
|
||||
password: password ?? "",
|
||||
connectTimeoutSeconds: Number(connectTimeoutSeconds),
|
||||
readTimeoutSeconds: Number(readTimeoutSeconds),
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: InitialValuesForm) => {
|
||||
await backOfficeMutation.mutateAsync(values);
|
||||
};
|
||||
const { submitCount, isValid, values, errors } = useFormikContext<BearerTypeFieldType & InitialValuesForm>();
|
||||
|
||||
const ValidationToastOnce = () => {
|
||||
const { submitCount, isValid } = useFormikContext();
|
||||
useEffect(() => {
|
||||
if (submitCount > 0 && !isValid) {
|
||||
toast.error("Check fields are filled in");
|
||||
}
|
||||
}, [submitCount, isValid]);
|
||||
}, []);
|
||||
return null;
|
||||
};
|
||||
|
||||
const validateValues = (values: InitialValuesForm): InitialValuesFormErrors => {
|
||||
const errors: InitialValuesFormErrors = {};
|
||||
|
||||
const url = values.backOfficeURL?.trim();
|
||||
const username = values.username?.trim();
|
||||
const password = values.password?.trim();
|
||||
|
||||
if (!url) {
|
||||
errors.backOfficeURL = "Required";
|
||||
}
|
||||
|
||||
if (!username) errors.username = "Required";
|
||||
if (!password) errors.password = "Required";
|
||||
|
||||
const read = Number(values.readTimeoutSeconds);
|
||||
if (!Number.isFinite(read)) {
|
||||
errors.readTimeoutSeconds = "Must be a number";
|
||||
} else if (read < 0) {
|
||||
errors.readTimeoutSeconds = "Must be ≥ 0";
|
||||
}
|
||||
|
||||
const connect = Number(values.connectTimeoutSeconds);
|
||||
if (!Number.isFinite(connect)) {
|
||||
errors.connectTimeoutSeconds = "Must be a number";
|
||||
} else if (connect < 0) {
|
||||
errors.connectTimeoutSeconds = "Must be ≥ 0";
|
||||
}
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
return (
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize validate={validateValues}>
|
||||
{({ errors, touched, isSubmitting }) => (
|
||||
<Form>
|
||||
<>
|
||||
{format?.toLowerCase() !== "bof2" && format?.toLowerCase() !== "json" ? (
|
||||
<>
|
||||
<div className="mt-4 flex flex-col items-center justify-center rounded-2xl border border-slate-800 bg-slate-900/40 p-10 text-center">
|
||||
<div className="mb-3 rounded-xl bg-slate-800 px-3 py-1 text-xs uppercase tracking-wider text-slate-400">
|
||||
Format coming soon
|
||||
</div>
|
||||
|
||||
<p className="max-w-md text-slate-300">
|
||||
Output configuration currently supports <span className="font-bold text-blue-400">JSON</span> or{" "}
|
||||
<span className="font-bold text-emerald-400">BOF2</span>. <br /> More formats will be added in future
|
||||
updates.
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div className="flex flex-col space-y-2 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="backoffice" className="m-0">
|
||||
@@ -85,9 +58,7 @@ const ChannelFields = () => {
|
||||
type="text"
|
||||
id="backoffice"
|
||||
placeholder="https://www.backoffice.com"
|
||||
className={`p-1.5 border ${
|
||||
errors.backOfficeURL && touched.backOfficeURL ? "border-red-500" : "border-gray-400 "
|
||||
} rounded-lg w-full md:w-60`}
|
||||
className={`p-1.5 border border-gray-400 rounded-lg w-full md:w-60`}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
@@ -97,9 +68,7 @@ const ChannelFields = () => {
|
||||
type="text"
|
||||
id="username"
|
||||
placeholder="Back office username"
|
||||
className={`p-1.5 border ${
|
||||
errors.username && touched.username ? "border-red-500" : "border-gray-400 "
|
||||
} rounded-lg w-full md:w-60`}
|
||||
className={`p-1.5 border border-gray-400 rounded-lg w-full md:w-60`}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
@@ -146,17 +115,133 @@ const ChannelFields = () => {
|
||||
} rounded-lg w-full md:w-60`}
|
||||
/>
|
||||
</FormGroup>
|
||||
{/* Overview quality and scale */}
|
||||
<FormGroup>
|
||||
<label htmlFor="overviewQuality">Overview quality and scale</label>
|
||||
<Field
|
||||
name={"overviewQuality"}
|
||||
as="select"
|
||||
id="overviewQuality"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
<option value={"HIGH"}>High</option>
|
||||
<option value={"MEDIUM"}>Medium</option>
|
||||
<option value={"LOW"}>Low</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
{/* propOverviewImageScaleFactor cropSizeFactor */}
|
||||
<FormGroup>
|
||||
<label htmlFor="cropSizeFactor">Crop Size Factor</label>
|
||||
<Field
|
||||
name={"cropSizeFactor"}
|
||||
as="select"
|
||||
id="cropSizeFactor"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
<option value={"FULL"}>Full</option>
|
||||
<option value={"3/4"}>3/4</option>
|
||||
<option value={"1/2"}>1/2</option>
|
||||
<option value={"1/4"}>1/4</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
{format?.toLowerCase() === "bof2" && (
|
||||
<>
|
||||
<div className="space-y-3">
|
||||
<div className="border-b border-gray-500 my-3">
|
||||
<h2 className="font-bold">{values.format} Constants</h2>
|
||||
</div>
|
||||
<FormGroup>
|
||||
<label htmlFor="FFID">Feed ID / Force ID</label>
|
||||
<Field
|
||||
name={"FFID"}
|
||||
type="text"
|
||||
id="FFID"
|
||||
placeholder="ABC123"
|
||||
className={`p-1.5 border ${
|
||||
errors.readTimeoutSeconds && touched.readTimeoutSeconds ? "border-red-500" : "border-gray-400 "
|
||||
} rounded-lg w-full md:w-60`}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="SCID">Source ID / Camera ID</label>
|
||||
<Field
|
||||
name={"SCID"}
|
||||
type="text"
|
||||
id="SCID"
|
||||
placeholder="DEF345"
|
||||
className={`p-1.5 border ${
|
||||
errors.readTimeoutSeconds && touched.readTimeoutSeconds ? "border-red-500" : "border-gray-400 "
|
||||
} rounded-lg w-full md:w-60`}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="timestampSource">Timestamp Source</label>
|
||||
<Field
|
||||
name={"timestampSource"}
|
||||
as="select"
|
||||
id="timestampSource"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
<option value={"UTC"}>UTC</option>
|
||||
<option value={"LOCAL"}>Local</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="GPSFormat">GPS Format</label>
|
||||
<Field
|
||||
name={"GPSFormat"}
|
||||
as="select"
|
||||
id="GPSFormat"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
<option value={"Minutes"}>Minutes</option>
|
||||
<option value={"Decimal Degrees"}>Decimal degrees</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<div className="border-b border-gray-500 my-3">
|
||||
<h2 className="font-bold">{values.format} Lane ID Config</h2>
|
||||
</div>
|
||||
<FormGroup>
|
||||
<label htmlFor="LID1">Lane ID 1 (Camera A)</label>
|
||||
<Field
|
||||
name={"LID1"}
|
||||
type="text"
|
||||
id="LID1"
|
||||
placeholder="10"
|
||||
className={`p-1.5 border ${
|
||||
errors.readTimeoutSeconds && touched.readTimeoutSeconds ? "border-red-500" : "border-gray-400 "
|
||||
} rounded-lg w-full md:w-60`}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="LID2">Lane ID 2 (Camera B)</label>
|
||||
<Field
|
||||
name={"LID2"}
|
||||
type="text"
|
||||
id="LID2"
|
||||
placeholder="20"
|
||||
className={`p-1.5 border ${
|
||||
errors.readTimeoutSeconds && touched.readTimeoutSeconds ? "border-red-500" : "border-gray-400 "
|
||||
} rounded-lg w-full md:w-60`}
|
||||
/>
|
||||
</FormGroup>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
className="w-full md:w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
{isSubmitting || backOfficeMutation.isPending ? "Saving..." : "Save Changes"}
|
||||
{isSubmitting ? "Saving..." : "Save Changes"}
|
||||
</button>
|
||||
<ValidationToastOnce />
|
||||
</Form>
|
||||
</>
|
||||
)}
|
||||
</Formik>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import NPEDIcon from "/NPED.svg";
|
||||
const NPEDCard = () => {
|
||||
return (
|
||||
<Card className="p-4">
|
||||
<CardHeader title={"NPED Config"} img={NPEDIcon} />
|
||||
<CardHeader title={"NPED"} img={NPEDIcon} />
|
||||
<NPEDFields />
|
||||
</Card>
|
||||
);
|
||||
|
||||
22
src/components/SettingForms/NPED/NPEDCatToggle.tsx
Normal file
22
src/components/SettingForms/NPED/NPEDCatToggle.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Field } from "formik";
|
||||
|
||||
type NPEDToggleProps = {
|
||||
name: string;
|
||||
label: string;
|
||||
};
|
||||
|
||||
const NPEDCatToggle = ({ name, label }: NPEDToggleProps) => {
|
||||
return (
|
||||
<label className="flex items-center gap-3 cursor-pointer select-none w-full justify-between">
|
||||
<span className="text-lg">{label}</span>
|
||||
<Field id={name} type="checkbox" name={name} className="sr-only peer" />
|
||||
<div
|
||||
className="relative w-10 h-5 rounded-full bg-gray-300 transition peer-checked:bg-blue-500 after:content-['']
|
||||
after:absolute after:top-0.5 after:left-0.5 after:w-4 after:h-4 after:rounded-full after:bg-white after:shadow after:transition
|
||||
after:duration-300 peer-checked:after:translate-x-5"
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
};
|
||||
|
||||
export default NPEDCatToggle;
|
||||
@@ -6,26 +6,26 @@ import { toast } from "sonner";
|
||||
import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { useState } from "react";
|
||||
import { useIntegrationsContext } from "../../../context/IntegrationsContext";
|
||||
|
||||
const NPEDFields = () => {
|
||||
const { state } = useIntegrationsContext();
|
||||
const [showPwd, setShowPwd] = useState(false);
|
||||
const { signIn, user, signOut } = useNPEDAuth();
|
||||
const { signIn, signOut } = useNPEDAuth();
|
||||
|
||||
const initialValues = user
|
||||
? {
|
||||
username: user?.propUsername?.value,
|
||||
password: user?.propPassword?.value,
|
||||
clientId: user?.propClientID?.value,
|
||||
frontId: "NPED",
|
||||
rearId: "NPED",
|
||||
}
|
||||
: {
|
||||
username: "",
|
||||
password: "",
|
||||
clientId: "",
|
||||
frontId: "NPED",
|
||||
rearId: "NPED",
|
||||
};
|
||||
const username = state.npedUser?.propUsername?.value;
|
||||
const password = state.npedUser?.propPassword?.value;
|
||||
const clientId = state.npedUser?.propClientID?.value;
|
||||
const frontId = "NPED";
|
||||
const rearId = "NPED";
|
||||
|
||||
const initialValues = {
|
||||
username: username ?? "",
|
||||
password: password ?? "",
|
||||
clientId: clientId ?? "",
|
||||
frontId: frontId,
|
||||
rearId: rearId,
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: NPEDFieldType) => {
|
||||
const valuesToSend = {
|
||||
@@ -48,20 +48,13 @@ const NPEDFields = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Formik
|
||||
initialValues={initialValues}
|
||||
onSubmit={handleSubmit}
|
||||
validate={validateValues}
|
||||
enableReinitialize
|
||||
>
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} validate={validateValues} enableReinitialize>
|
||||
{({ errors, touched, isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="username">Username</label>
|
||||
{touched.username && errors.username && (
|
||||
<small className="absolute right-0 -top-5 text-red-500">
|
||||
{errors.username}
|
||||
</small>
|
||||
<small className="absolute right-0 -top-5 text-red-500">{errors.username}</small>
|
||||
)}
|
||||
<Field
|
||||
name="username"
|
||||
@@ -82,9 +75,7 @@ const NPEDFields = () => {
|
||||
className="p-2 border border-gray-400 rounded-lg w-full"
|
||||
/>
|
||||
{touched.password && errors.password && (
|
||||
<small className="absolute right-0 -top-5 text-red-500">
|
||||
{errors.password}
|
||||
</small>
|
||||
<small className="absolute right-0 -top-5 text-red-500">{errors.password}</small>
|
||||
)}
|
||||
<FontAwesomeIcon
|
||||
type="button"
|
||||
@@ -97,9 +88,7 @@ const NPEDFields = () => {
|
||||
<FormGroup>
|
||||
<label htmlFor="clientId">Client ID</label>
|
||||
{touched.clientId && errors.clientId && (
|
||||
<small className="absolute right-0 -top-5 text-red-500">
|
||||
{errors.clientId}
|
||||
</small>
|
||||
<small className="absolute right-0 -top-5 text-red-500">{errors.clientId}</small>
|
||||
)}
|
||||
<Field
|
||||
name="clientId"
|
||||
@@ -109,17 +98,18 @@ const NPEDFields = () => {
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
/>
|
||||
</FormGroup>
|
||||
{!user?.propClientID?.value ? (
|
||||
|
||||
{!state.npedUser?.propClientID?.value ? (
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5 hover:cursor-pointer"
|
||||
className="w-full md:w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5 hover:cursor-pointer"
|
||||
>
|
||||
{isSubmitting ? "Logging in..." : "Login"}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="w-1/4 border-red-700 bg-red-800 text-white font-small rounded-lg text-sm px-2 py-2.5 hover:cursor-pointer"
|
||||
className="w-full md:w-1/4 border-red-700 bg-red-800 text-white font-small rounded-lg text-sm px-2 py-2.5 hover:cursor-pointer"
|
||||
onClick={handleLogoutClick}
|
||||
>
|
||||
Logout
|
||||
|
||||
@@ -5,6 +5,7 @@ import { CAM_BASE } from "../../../utils/config";
|
||||
|
||||
const NPEDHotlist = () => {
|
||||
const { uploadSettings } = useSystemConfig();
|
||||
|
||||
const initialValue = {
|
||||
file: null,
|
||||
};
|
||||
@@ -47,7 +48,7 @@ const NPEDHotlist = () => {
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
className="w-full md:w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
// disabled={errors ? true : false}
|
||||
>
|
||||
Upload
|
||||
|
||||
@@ -1,12 +1,151 @@
|
||||
import { Form, Formik } from "formik";
|
||||
import BearerTypeCard from "../BearerType/BearerTypeCard";
|
||||
import ChannelCard from "../Channel1-JSON/ChannelCard";
|
||||
import { useCameraOutput, useGetDispatcherConfig } from "../../../hooks/useCameraOutput";
|
||||
import type {
|
||||
BearerTypeFieldType,
|
||||
InitialValuesForm,
|
||||
InitialValuesFormErrors,
|
||||
OptionalBOF2Constants,
|
||||
OptionalBOF2LaneIDs,
|
||||
} from "../../../types/types";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useUpdateBackOfficeConfig } from "../../../hooks/useBackOfficeConfig";
|
||||
import { useFormVaidate } from "../../../hooks/useFormValidate";
|
||||
import { useSightingAmend } from "../../../hooks/useSightingAmend";
|
||||
import StoreCard from "../Store/StoreCard";
|
||||
|
||||
const SettingForms = () => {
|
||||
const qc = useQueryClient();
|
||||
const { dispatcherQuery, dispatcherMutation, backOfficeDispatcherMutation, bof2LandMutation, laneIdQuery } =
|
||||
useCameraOutput();
|
||||
const { backOfficeMutation } = useUpdateBackOfficeConfig();
|
||||
const { bof2ConstantsQuery } = useGetDispatcherConfig();
|
||||
const { validateMutation } = useFormVaidate();
|
||||
const { sightingAmendQuery, sightingAmendMutation } = useSightingAmend();
|
||||
|
||||
const format = dispatcherQuery?.data?.propFormat?.value;
|
||||
const enabled = dispatcherQuery?.data?.propEnabled?.value;
|
||||
|
||||
const sightingQuality = sightingAmendQuery?.data?.propOverviewQuality?.value;
|
||||
const cropSizeFactor = sightingAmendQuery?.data?.propOverviewImageScaleFactor?.value;
|
||||
|
||||
const laneID = laneIdQuery?.data?.id;
|
||||
const LID1 = laneIdQuery?.data?.propLaneID1?.value;
|
||||
const LID2 = laneIdQuery?.data?.propLaneID2?.value;
|
||||
|
||||
const FFID = bof2ConstantsQuery?.data?.propFeedIdentifier?.value;
|
||||
const SCID = bof2ConstantsQuery?.data?.propSourceIdentifier?.value;
|
||||
const GPSFormat = bof2ConstantsQuery?.data?.propGpsFormat?.value;
|
||||
const timestampSource = bof2ConstantsQuery?.data?.propTimeZoneType?.value;
|
||||
|
||||
const isDispatcherLoading = dispatcherQuery?.isFetching;
|
||||
const isBof2ConstantsLoading = bof2ConstantsQuery?.isFetching;
|
||||
|
||||
const initialValues: BearerTypeFieldType & InitialValuesForm & OptionalBOF2Constants & OptionalBOF2LaneIDs = {
|
||||
format: format ?? "JSON",
|
||||
enabled: enabled === "true",
|
||||
backOfficeURL: "",
|
||||
username: "",
|
||||
password: "",
|
||||
connectTimeoutSeconds: Number(5),
|
||||
readTimeoutSeconds: Number(15),
|
||||
overviewQuality: sightingQuality ?? "HIGH",
|
||||
cropSizeFactor: cropSizeFactor ?? "3/4",
|
||||
|
||||
// Bof2 - optional constants
|
||||
FFID: FFID ?? "",
|
||||
SCID: SCID ?? "",
|
||||
timestampSource: timestampSource ?? "",
|
||||
GPSFormat: GPSFormat ?? "",
|
||||
|
||||
//BOF2 - optional Lane IDs
|
||||
laneId: laneID ?? "",
|
||||
LID1: LID1 ?? "",
|
||||
LID2: LID2 ?? "",
|
||||
};
|
||||
|
||||
const validateValues = (values: InitialValuesForm): InitialValuesFormErrors => {
|
||||
const errors: InitialValuesFormErrors = {};
|
||||
|
||||
const read = Number(values.readTimeoutSeconds);
|
||||
if (!Number.isFinite(read)) {
|
||||
errors.readTimeoutSeconds = "Must be a number";
|
||||
} else if (read < 0) {
|
||||
errors.readTimeoutSeconds = "Must be ≥ 0";
|
||||
}
|
||||
|
||||
const connect = Number(values.connectTimeoutSeconds);
|
||||
if (!Number.isFinite(connect)) {
|
||||
errors.connectTimeoutSeconds = "Must be a number";
|
||||
} else if (connect < 0) {
|
||||
errors.connectTimeoutSeconds = "Must be ≥ 0";
|
||||
}
|
||||
return errors;
|
||||
};
|
||||
|
||||
const handleSubmit = async (
|
||||
values: BearerTypeFieldType & InitialValuesForm & OptionalBOF2Constants & OptionalBOF2LaneIDs
|
||||
) => {
|
||||
const validResponse = await validateMutation.mutateAsync(values);
|
||||
|
||||
const dispatcherData = {
|
||||
format: values.format,
|
||||
enabled: values.enabled,
|
||||
};
|
||||
const result = await dispatcherMutation.mutateAsync(dispatcherData);
|
||||
|
||||
if (result?.id) {
|
||||
qc.invalidateQueries({ queryKey: ["dispatcher"] });
|
||||
qc.invalidateQueries({ queryKey: ["backoffice", values.format] });
|
||||
|
||||
if (validResponse?.reason === "OK") {
|
||||
await backOfficeMutation.mutateAsync(values);
|
||||
await sightingAmendMutation.mutateAsync(values);
|
||||
|
||||
if (values.format.toLowerCase() === "bof2") {
|
||||
const bof2ConstantsData: OptionalBOF2Constants = {
|
||||
FFID: values.FFID,
|
||||
SCID: values.SCID,
|
||||
timestampSource: values.timestampSource,
|
||||
GPSFormat: values.GPSFormat,
|
||||
};
|
||||
|
||||
const bof2LaneData: OptionalBOF2LaneIDs = {
|
||||
laneId: laneIdQuery?.data?.id,
|
||||
LID1: values.LID1,
|
||||
LID2: values.LID2,
|
||||
};
|
||||
await bof2LandMutation.mutateAsync(bof2LaneData);
|
||||
await backOfficeDispatcherMutation.mutateAsync(bof2ConstantsData);
|
||||
}
|
||||
} else {
|
||||
console.log("error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mx-auto grid grid-cols-1 sm:grid-cols-1 lg:grid-cols-2 gap-2 px-2 sm:px-4 lg:px-0 w-full">
|
||||
<BearerTypeCard />
|
||||
<ChannelCard />
|
||||
</div>
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} validate={validateValues} enableReinitialize>
|
||||
{({ isSubmitting, touched }) => (
|
||||
<Form>
|
||||
<div className="mx-auto grid grid-cols-1 sm:grid-cols-1 lg:grid-cols-2 gap-2 px-2 sm:px-4 lg:px-0 w-full">
|
||||
<div>
|
||||
<BearerTypeCard />
|
||||
<StoreCard />
|
||||
</div>
|
||||
|
||||
<ChannelCard
|
||||
touched={touched}
|
||||
isSubmitting={isSubmitting}
|
||||
isDispatcherLoading={isDispatcherLoading}
|
||||
isBof2ConstantsLoading={isBof2ConstantsLoading}
|
||||
/>
|
||||
</div>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Field, FieldArray, Form, Formik } from "formik";
|
||||
import { Field, Form, Formik } from "formik";
|
||||
import FormGroup from "../components/FormGroup";
|
||||
import type { FormValues, Hotlist } from "../../../types/types";
|
||||
import { useSoundContext } from "../../../context/SoundContext";
|
||||
@@ -13,13 +13,14 @@ const SoundSettingsFields = () => {
|
||||
const hotlists: Hotlist[] = state.hotlists;
|
||||
|
||||
const soundOptions = state?.soundOptions?.map((soundOption) => ({
|
||||
value: soundOption?.soundFile,
|
||||
value: soundOption?.soundFileName,
|
||||
label: soundOption?.name,
|
||||
}));
|
||||
|
||||
const initialValues: FormValues = {
|
||||
sightingSound: state.sightingSound ?? "switch",
|
||||
NPEDsound: state.NPEDsound ?? "popup",
|
||||
hotlistSound: state.hotlistSound ?? "notification",
|
||||
hotlists,
|
||||
};
|
||||
|
||||
@@ -28,14 +29,21 @@ const SoundSettingsFields = () => {
|
||||
...values,
|
||||
sightingVolume: state.sightingVolume,
|
||||
NPEDsoundVolume: state.NPEDsoundVolume,
|
||||
hotlistSoundVolume: state.hotlistSoundVolume,
|
||||
soundOptions: [...(state.soundOptions ?? [])],
|
||||
};
|
||||
|
||||
dispatch({ type: "UPDATE", payload: updatedValues });
|
||||
|
||||
const result = await mutation.mutateAsync({
|
||||
operation: "INSERT",
|
||||
path: "soundSettings",
|
||||
value: updatedValues,
|
||||
});
|
||||
await mutation.mutateAsync({
|
||||
operation: "SAVE",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
if (result.reason !== "OK") {
|
||||
toast.error("Cannot update sound settings");
|
||||
} else {
|
||||
@@ -44,7 +52,7 @@ const SoundSettingsFields = () => {
|
||||
};
|
||||
return (
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit}>
|
||||
{({ values }) => (
|
||||
{() => (
|
||||
<Form className="flex flex-col space-y-3">
|
||||
<FormGroup>
|
||||
<div className="flex flex-col md:flex-row space-y-2 w-full justify-between gap-3">
|
||||
@@ -85,6 +93,23 @@ const SoundSettingsFields = () => {
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-2">Hotlist Sounds</h3>
|
||||
<FormGroup>
|
||||
<div className="flex flex-col md:flex-row space-y-2 w-full justify-between gap-3">
|
||||
<label htmlFor="hotlistSound">All hotlist Sounds</label>
|
||||
<Field
|
||||
as="select"
|
||||
name="hotlistSound"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
{soundOptions?.map(({ value, label }) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</Field>
|
||||
<SliderComponent soundCategory="HOTLISTVOLUME" />
|
||||
</div>
|
||||
</FormGroup>
|
||||
{/* <FormGroup>
|
||||
<FieldArray
|
||||
name="hotlists"
|
||||
render={() => (
|
||||
@@ -115,11 +140,11 @@ const SoundSettingsFields = () => {
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormGroup> */}
|
||||
</div>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
className="w-full md:w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
Save Settings
|
||||
</button>
|
||||
|
||||
@@ -3,26 +3,72 @@ import FormGroup from "../components/FormGroup";
|
||||
import type { SoundUploadValue } from "../../../types/types";
|
||||
import { useSoundContext } from "../../../context/SoundContext";
|
||||
import { toast } from "sonner";
|
||||
import { useCameraBlackboard } from "../../../hooks/useCameraBlackboard";
|
||||
import { useFileUpload } from "../../../hooks/useFileUpload";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
const SoundUpload = () => {
|
||||
const { dispatch } = useSoundContext();
|
||||
const { state, dispatch } = useSoundContext();
|
||||
const { mutation } = useCameraBlackboard();
|
||||
const currentUrlRef = useRef<string | null>(null);
|
||||
const { mutation: fileMutation } = useFileUpload();
|
||||
|
||||
const initialValues: SoundUploadValue = {
|
||||
name: "",
|
||||
soundFile: null,
|
||||
soundFileName: "",
|
||||
soundUrl: "",
|
||||
uploadedAt: Date.now(),
|
||||
};
|
||||
|
||||
const handleSubmit = (values: SoundUploadValue) => {
|
||||
const handleSubmit = async (values: SoundUploadValue) => {
|
||||
if (!values.soundFile) {
|
||||
toast.warning("Please select an audio file");
|
||||
} else {
|
||||
dispatch({ type: "ADD", payload: values });
|
||||
toast.success("Sound file upload successfully");
|
||||
return;
|
||||
}
|
||||
const alreadyExists = state?.soundOptions?.some((soundOption) => soundOption.name === values.name);
|
||||
if (state.soundOptions?.includes(values) || alreadyExists) {
|
||||
toast.warning("Sound already in list");
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedValues = {
|
||||
...state,
|
||||
soundOptions: [...(state.soundOptions ?? []), values],
|
||||
};
|
||||
|
||||
const result = await mutation.mutateAsync({
|
||||
operation: "INSERT",
|
||||
path: "soundSettings",
|
||||
value: updatedValues,
|
||||
});
|
||||
await fileMutation.mutateAsync(values.soundFile);
|
||||
if (currentUrlRef.current) {
|
||||
URL.revokeObjectURL(currentUrlRef.current);
|
||||
currentUrlRef.current = null;
|
||||
}
|
||||
if (result.reason !== "OK") {
|
||||
toast.error("Cannot update sound settings");
|
||||
}
|
||||
await mutation.mutateAsync({
|
||||
operation: "SAVE",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
dispatch({ type: "ADD", payload: values });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (currentUrlRef.current) {
|
||||
URL.revokeObjectURL(currentUrlRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
{({ setFieldValue, errors, setFieldError, values }) => (
|
||||
{({ setFieldValue, errors, setFieldError }) => (
|
||||
<Form>
|
||||
<label htmlFor="soundFile" className="">
|
||||
Sound File
|
||||
@@ -35,9 +81,22 @@ const SoundUpload = () => {
|
||||
accept="audio/mpeg"
|
||||
className="mt-4 w-full flex flex-col items-center justify-center rounded-2xl border border-slate-800 bg-slate-900/40 p-10 text-center file:px-3 file:border file:border-gray-500 file:rounded-lg file:bg-blue-800 file:mr-5"
|
||||
onChange={(e) => {
|
||||
if (currentUrlRef.current) {
|
||||
URL.revokeObjectURL(currentUrlRef.current);
|
||||
}
|
||||
if (e.target?.files && e.target?.files[0]?.type === "audio/mpeg") {
|
||||
currentUrlRef.current = URL.createObjectURL(e.target.files[0]);
|
||||
const url = currentUrlRef.current;
|
||||
setFieldValue("soundUrl", url);
|
||||
setFieldValue("name", e.target.files[0].name);
|
||||
setFieldValue("soundFileName", e.target.files[0].name);
|
||||
setFieldValue("soundFile", e.target.files[0]);
|
||||
setFieldValue("uploadedAt", Date.now());
|
||||
if (e?.target?.files[0]?.size >= 1 * 1024 * 1024) {
|
||||
setFieldError("soundFile", "larger than 1mb");
|
||||
toast.error("File larger than 1MB");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
setFieldError("soundFile", "Not an mp3 file");
|
||||
toast.error("Not an mp3 file");
|
||||
@@ -47,11 +106,6 @@ const SoundUpload = () => {
|
||||
</FormGroup>
|
||||
|
||||
<div className="mt-4 flex flex-col items-center justify-center rounded-2xl border border-slate-800 bg-slate-900/40 p-10 text-center">
|
||||
{!values.soundFile && (
|
||||
<div className="mb-3 rounded-xl bg-slate-800 px-3 py-1 text-xs uppercase tracking-wider text-slate-400">
|
||||
No uploaded sound files
|
||||
</div>
|
||||
)}
|
||||
<p className="max-w-md text-slate-300">
|
||||
Uploaded Sound files will appear in the <span className="font-bold">drop downs</span> once they are
|
||||
uploaded. They can be used for any <span className="text-blue-400">Sighting,</span>{" "}
|
||||
@@ -62,7 +116,7 @@ const SoundUpload = () => {
|
||||
{errors.soundFile && <p className="text-red-500 text-sm mt-1">Not an mp3 file</p>}
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5 mt-[5%]"
|
||||
className="w-full md:w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5 mt-[5%]"
|
||||
disabled={errors.soundFile ? true : false}
|
||||
>
|
||||
Upload
|
||||
|
||||
@@ -4,7 +4,7 @@ import SoundUpload from "./SoundUpload";
|
||||
|
||||
const SoundUploadCard = () => {
|
||||
return (
|
||||
<Card className="p-4 col-span-3 w-full">
|
||||
<Card className="p-4 col-span-5 lg:col-span-3 w-full">
|
||||
<CardHeader title={"Sound upload"} />
|
||||
<SoundUpload />
|
||||
</Card>
|
||||
|
||||
14
src/components/SettingForms/Store/StoreCard.tsx
Normal file
14
src/components/SettingForms/Store/StoreCard.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import Card from "../../UI/Card";
|
||||
import CardHeader from "../../UI/CardHeader";
|
||||
import StoreFields from "./StoreFields";
|
||||
|
||||
const StoreCard = () => {
|
||||
return (
|
||||
<Card className="p-4">
|
||||
<CardHeader title="Store" />
|
||||
<StoreFields />
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default StoreCard;
|
||||
29
src/components/SettingForms/Store/StoreFields.tsx
Normal file
29
src/components/SettingForms/Store/StoreFields.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { useStoreDispatch } from "../../../hooks/useStoreDispatch";
|
||||
import VehicleSessionItem from "../../UI/VehicleSessionItem";
|
||||
|
||||
const StoreFields = () => {
|
||||
const { storeQuery } = useStoreDispatch();
|
||||
|
||||
const totalPending = storeQuery?.data?.totalPending;
|
||||
const totalActive = storeQuery?.data?.totalActive;
|
||||
const totalSent = storeQuery?.data?.totalSent;
|
||||
const totalReceived = storeQuery?.data?.totalReceived;
|
||||
const totalLost = storeQuery?.data?.totalLost;
|
||||
|
||||
if (storeQuery.isLoading) return <div className="p-4">Loading store data...</div>;
|
||||
if (storeQuery.error) return <div className="p-4">Error: {storeQuery.error.message}</div>;
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<ul className="text-white space-y-3">
|
||||
<VehicleSessionItem sessionNumber={totalActive} textColour="text-gray-400" vehicleTag={"Total Active:"} />
|
||||
<VehicleSessionItem sessionNumber={totalSent} textColour="text-blue-400" vehicleTag={"Total Sent:"} />
|
||||
<VehicleSessionItem sessionNumber={totalReceived} textColour="text-green-400" vehicleTag={"Total Received:"} />
|
||||
<VehicleSessionItem sessionNumber={totalPending} textColour="text-amber-400" vehicleTag={"Total Pending:"} />
|
||||
<VehicleSessionItem sessionNumber={totalLost} textColour="text-red-400" vehicleTag={"Total Lost:"} />
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default StoreFields;
|
||||
@@ -2,6 +2,8 @@ import { toast } from "sonner";
|
||||
import type { SystemValues } from "../../../types/types";
|
||||
import { CAM_BASE } from "../../../utils/config";
|
||||
|
||||
const camBase = import.meta.env.MODE !== "development" ? CAM_BASE : "";
|
||||
|
||||
export async function handleSystemSave(values: SystemValues) {
|
||||
const payload = {
|
||||
// Build JSON
|
||||
@@ -18,7 +20,7 @@ export async function handleSystemSave(values: SystemValues) {
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config`, {
|
||||
const response = await fetch(`${camBase}/api/update-config`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -29,11 +31,7 @@ export async function handleSystemSave(values: SystemValues) {
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text().catch(() => "");
|
||||
throw new Error(
|
||||
`HTTP ${response.status} ${response.statusText}${
|
||||
text ? ` - ${text}` : ""
|
||||
}`
|
||||
);
|
||||
throw new Error(`HTTP ${response.status} ${response.statusText}${text ? ` - ${text}` : ""}`);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
@@ -47,10 +45,10 @@ export async function handleSystemSave(values: SystemValues) {
|
||||
}
|
||||
|
||||
export async function handleSystemRecall() {
|
||||
const url = `${CAM_BASE}/api/fetch-config?id=GLOBAL--Device`;
|
||||
const url = `${camBase}/api/fetch-config?id=GLOBAL--Device`;
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), 7000);
|
||||
const timeoutId = setTimeout(() => controller.abort(), 70000);
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
@@ -61,11 +59,7 @@ export async function handleSystemRecall() {
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text().catch(() => "");
|
||||
throw new Error(
|
||||
`HTTP ${response.status} ${response.statusText}${
|
||||
text ? ` - ${text}` : ""
|
||||
}`
|
||||
);
|
||||
throw new Error(`HTTP ${response.status} ${response.statusText}${text ? ` - ${text}` : ""}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
@@ -76,9 +70,7 @@ export async function handleSystemRecall() {
|
||||
|
||||
const sntpIntervalRaw = data?.propSNTPIntervalMinutes?.value;
|
||||
let sntpInterval =
|
||||
typeof sntpIntervalRaw === "number"
|
||||
? sntpIntervalRaw
|
||||
: Number.parseInt(String(sntpIntervalRaw).trim(), 10);
|
||||
typeof sntpIntervalRaw === "number" ? sntpIntervalRaw : Number.parseInt(String(sntpIntervalRaw).trim(), 10);
|
||||
|
||||
if (!Number.isFinite(sntpInterval)) {
|
||||
sntpInterval = 60;
|
||||
|
||||
@@ -4,21 +4,35 @@ import { useReboots } from "../../../hooks/useReboots";
|
||||
import { timezones } from "./timezones";
|
||||
import SystemFileUpload from "./SystemFileUpload";
|
||||
import type { SystemValues, SystemValuesErrors } from "../../../types/types";
|
||||
import { useSystemConfig } from "../../../hooks/useSystemConfig";
|
||||
import { useDNSSettings, useSystemConfig } from "../../../hooks/useSystemConfig";
|
||||
import { ValidateIPaddress } from "../../../utils/utils";
|
||||
import { toast } from "sonner";
|
||||
// import { useSystemStatus } from "../../../hooks/useSystemStatus";
|
||||
|
||||
const SystemConfigFields = () => {
|
||||
const { saveSystemSettings, systemSettingsData, saveSystemSettingsLoading } = useSystemConfig();
|
||||
const { softRebootMutation, hardRebootMutation } = useReboots();
|
||||
// const { systemStatusQuery } = useSystemStatus();
|
||||
const { hardRebootMutation } = useReboots();
|
||||
const { dnsQuery, dnsMutation } = useDNSSettings();
|
||||
|
||||
const sntpInterval = systemSettingsData?.sntpInterval;
|
||||
const dnsPrimary = dnsQuery?.data?.propNameServerPrimary?.value;
|
||||
const dnsSecondary = dnsQuery?.data?.propNameServerSecondary?.value;
|
||||
|
||||
const initialvalues: SystemValues = {
|
||||
deviceName: systemSettingsData?.deviceName ?? "",
|
||||
timeZone: systemSettingsData?.timeZone ?? "",
|
||||
sntpServer: systemSettingsData?.sntpServer ?? "",
|
||||
sntpInterval: systemSettingsData?.sntpInterval ?? 60,
|
||||
sntpInterval: sntpInterval ?? 60,
|
||||
serverPrimary: dnsPrimary ?? "",
|
||||
serverSecondary: dnsSecondary ?? "",
|
||||
softwareUpdate: null,
|
||||
};
|
||||
|
||||
const handleSubmit = (values: SystemValues) => saveSystemSettings(values);
|
||||
const handleSubmit = async (values: SystemValues) => {
|
||||
saveSystemSettings(values);
|
||||
await dnsMutation.mutateAsync(values);
|
||||
};
|
||||
|
||||
const validateValues = (values: SystemValues) => {
|
||||
const errors: SystemValuesErrors = {};
|
||||
@@ -27,12 +41,20 @@ const SystemConfigFields = () => {
|
||||
if (!values.timeZone) errors.timeZone = "Required";
|
||||
if (isNaN(interval) || interval <= 0) errors.sntpInterval = "Cannot be less than 0";
|
||||
if (!values.sntpServer) errors.sntpServer = "Required";
|
||||
const invalidPrimary = ValidateIPaddress(values.serverPrimary);
|
||||
const invalidSecondary = ValidateIPaddress(values.serverSecondary);
|
||||
|
||||
if (invalidPrimary || invalidSecondary) {
|
||||
toast.error(invalidPrimary || invalidSecondary, {
|
||||
id: "invalid-ip",
|
||||
});
|
||||
}
|
||||
return errors;
|
||||
};
|
||||
|
||||
const handleSoftReboot = async () => {
|
||||
await softRebootMutation.mutate();
|
||||
};
|
||||
// const handleSoftReboot = async () => {
|
||||
// await softRebootMutation.mutate();
|
||||
// };
|
||||
|
||||
const handleHardReboot = async () => {
|
||||
await hardRebootMutation.mutate();
|
||||
@@ -44,7 +66,7 @@ const SystemConfigFields = () => {
|
||||
onSubmit={handleSubmit}
|
||||
validate={validateValues}
|
||||
enableReinitialize
|
||||
validateOnChange
|
||||
validateOnChange={false}
|
||||
validateOnBlur
|
||||
>
|
||||
{({ values, errors, touched, isSubmitting }) => (
|
||||
@@ -102,6 +124,7 @@ const SystemConfigFields = () => {
|
||||
autoComplete="off"
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<label htmlFor="sntpInterval" className="font-medium whitespace-nowrap md:w-1/2 text-left">
|
||||
SNTP Interval minutes
|
||||
@@ -118,9 +141,37 @@ const SystemConfigFields = () => {
|
||||
className="p-2 border border-gray-400 rounded-lg w-full max-w-xs"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="serverPrimary" className="font-medium whitespace-nowrap md:w-1/2 text-left">
|
||||
Primary DNS Server
|
||||
</label>
|
||||
|
||||
<Field
|
||||
id="serverPrimary"
|
||||
name="serverPrimary"
|
||||
type="text"
|
||||
className="p-2 border border-gray-400 rounded-lg w-full max-w-xs"
|
||||
placeholder="Enter DNS primary address"
|
||||
autoComplete="off"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="serverSecondary" className="font-medium whitespace-nowrap md:w-1/2 text-left">
|
||||
Secondary DNS Server
|
||||
</label>
|
||||
|
||||
<Field
|
||||
id="serverSecondary"
|
||||
name="serverSecondary"
|
||||
type="text"
|
||||
className="p-2 border border-gray-400 rounded-lg w-full max-w-xs"
|
||||
placeholder="Enter DNS secondary address"
|
||||
autoComplete="off"
|
||||
/>
|
||||
</FormGroup>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
className="w-full md:w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{saveSystemSettingsLoading ? "Saving..." : "Save System Settings"}
|
||||
@@ -130,13 +181,13 @@ const SystemConfigFields = () => {
|
||||
<p>Reboot</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
{/* <button
|
||||
type="button"
|
||||
className="bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 transition w-full md:w-[50%]"
|
||||
onClick={handleSoftReboot}
|
||||
>
|
||||
{softRebootMutation.isPending || isSubmitting ? "Rebooting..." : "Software Reboot"}
|
||||
</button>
|
||||
</button> */}
|
||||
<button
|
||||
type="button"
|
||||
className="bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 transition w-full md:w-[50%]"
|
||||
|
||||
@@ -19,7 +19,7 @@ const SystemFileUpload = ({ name, selectedFile }: SystemFileUploadProps) => {
|
||||
opts: {
|
||||
timeoutMs: 30000,
|
||||
fieldName: "upload",
|
||||
uploadUrl: "http://192.168.75.11/upload/software-update/2",
|
||||
uploadUrl: "http://192.168.75.11/upload/software-update/4",
|
||||
},
|
||||
};
|
||||
uploadSettings(settings);
|
||||
@@ -52,7 +52,7 @@ const SystemFileUpload = ({ name, selectedFile }: SystemFileUploadProps) => {
|
||||
</FormGroup>
|
||||
<button
|
||||
type="button"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
className="w-full md:w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
disabled={!selectedFile}
|
||||
onClick={handleFileUploadClick}
|
||||
>
|
||||
|
||||
@@ -10,16 +10,10 @@ type BlobFileUpload = {
|
||||
};
|
||||
};
|
||||
|
||||
export async function sendBlobFileUpload({
|
||||
file,
|
||||
opts,
|
||||
}: BlobFileUpload): Promise<string> {
|
||||
export async function sendBlobFileUpload({ file, opts }: BlobFileUpload): Promise<string> {
|
||||
if (!file) throw new Error("No file supplied");
|
||||
if (!opts?.uploadUrl) throw new Error("No URL supplied");
|
||||
|
||||
if (file?.type !== "text/csv") {
|
||||
throw new Error("This file is not supported, please upload a CSV file.");
|
||||
}
|
||||
const timeoutMs = opts?.timeoutMs ?? 30000;
|
||||
const fieldName = opts?.fieldName ?? "upload";
|
||||
const fileName = opts?.overrideFileName ?? file?.name;
|
||||
@@ -42,9 +36,7 @@ export async function sendBlobFileUpload({
|
||||
const bodyText = await resp.text();
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error(
|
||||
`Upload failed (${resp.status} ${resp.statusText}) from ${opts.uploadUrl} — ${bodyText}`
|
||||
);
|
||||
throw new Error(`Upload failed (${resp.status} ${resp.statusText}) from ${opts.uploadUrl} — ${bodyText}`);
|
||||
}
|
||||
|
||||
return bodyText;
|
||||
@@ -54,9 +46,7 @@ export async function sendBlobFileUpload({
|
||||
}
|
||||
// In browsers, fetch throws TypeError on network-level failures
|
||||
if (err instanceof TypeError) {
|
||||
throw new Error(
|
||||
`HTTP error uploading to ${opts.uploadUrl}: ${err.message}`
|
||||
);
|
||||
throw new Error(`HTTP error uploading to ${opts.uploadUrl}: ${err.message}`);
|
||||
}
|
||||
// Todo: fix error message response
|
||||
return `Hotlist Load OK`;
|
||||
|
||||
@@ -6,7 +6,6 @@ const ModemCard = () => {
|
||||
return (
|
||||
<Card className="p-4">
|
||||
<CardHeader title={"Modem"} />
|
||||
|
||||
<ModemSettings />
|
||||
</Card>
|
||||
);
|
||||
|
||||
@@ -6,6 +6,8 @@ import { useEffect, useState } from "react";
|
||||
import ModemToggle from "./ModemToggle";
|
||||
import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { ValidateIPaddress } from "../../../utils/utils";
|
||||
import { toast, Toaster } from "sonner";
|
||||
|
||||
const ModemSettings = () => {
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
@@ -16,6 +18,8 @@ const ModemSettings = () => {
|
||||
const username = modemQuery?.data?.propUsername.value;
|
||||
const password = modemQuery?.data?.propPassword?.value;
|
||||
const mode = modemQuery?.data?.propMode?.value;
|
||||
const serverPrimary = modemQuery?.data?.propNameServerPrimary?.value;
|
||||
const serverSecondary = modemQuery?.data?.propNameServerSecondary?.value;
|
||||
|
||||
useEffect(() => {
|
||||
setShowSettings(mode === "AUTO");
|
||||
@@ -26,109 +30,153 @@ const ModemSettings = () => {
|
||||
username: username ?? "",
|
||||
password: password ?? "",
|
||||
authenticationType: "PAP",
|
||||
serverPrimary: serverPrimary ?? "",
|
||||
serverSecondary: serverSecondary ?? "",
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: ModemSettingsType) => {
|
||||
const invalidPrimary = ValidateIPaddress(values.serverPrimary);
|
||||
const invalidSecondary = ValidateIPaddress(values.serverSecondary);
|
||||
|
||||
if (invalidPrimary || invalidSecondary) {
|
||||
toast.error(invalidPrimary || invalidSecondary, {
|
||||
id: "invalid-ip",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const fields = [
|
||||
{ property: "propAPN", value: values.apn },
|
||||
{ property: "propPassword", value: values.password },
|
||||
{ property: "propUsername", value: values.username },
|
||||
{ property: "propMode", value: showSettings ? "AUTO" : "MANUAL" },
|
||||
{ property: "propNameServerPrimary", value: values.serverPrimary },
|
||||
];
|
||||
|
||||
if (values.serverSecondary?.trim()) {
|
||||
fields.push({
|
||||
property: "propNameServerSecondary",
|
||||
value: values.serverSecondary.trim(),
|
||||
});
|
||||
}
|
||||
|
||||
const modemConfig = {
|
||||
id: "ModemAndWifiManager-modem",
|
||||
fields: [
|
||||
{
|
||||
property: "propAPN",
|
||||
value: values.apn,
|
||||
},
|
||||
{
|
||||
property: "propPassword",
|
||||
value: values.password,
|
||||
},
|
||||
{
|
||||
property: "propUsername",
|
||||
value: values.username,
|
||||
},
|
||||
|
||||
{
|
||||
property: "propMode",
|
||||
value: showSettings ? "AUTO" : "MANUAL",
|
||||
},
|
||||
],
|
||||
fields,
|
||||
};
|
||||
await modemMutation.mutateAsync(modemConfig);
|
||||
|
||||
const response = await modemMutation.mutateAsync(modemConfig);
|
||||
|
||||
if (!response?.id) {
|
||||
toast.success("Modem settings updated successfully", {
|
||||
id: "modemSettings",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ModemToggle showSettings={showSettings} onShowSettings={setShowSettings} />
|
||||
{!showSettings && (
|
||||
<Formik initialValues={inititalValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
{({ isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="apn" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
APN
|
||||
</label>
|
||||
<Field
|
||||
placeholder="Enter APN"
|
||||
name="apn"
|
||||
id="apn"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="username" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Username
|
||||
</label>
|
||||
<Field
|
||||
placeholder="Enter Username"
|
||||
name="username"
|
||||
id="username"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Password
|
||||
</label>
|
||||
<div className="flex gap-2 items-center relative mb-4">
|
||||
|
||||
<Formik initialValues={inititalValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
{({ isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
{!showSettings && (
|
||||
<>
|
||||
<FormGroup>
|
||||
<label htmlFor="apn" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
APN
|
||||
</label>
|
||||
<Field
|
||||
id="password"
|
||||
name="password"
|
||||
type={showPwd ? "text" : "password"}
|
||||
className="p-2 border border-gray-400 rounded-lg w-full"
|
||||
placeholder="Enter Password"
|
||||
placeholder="Enter APN"
|
||||
name="apn"
|
||||
id="apn"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
/>
|
||||
<FontAwesomeIcon
|
||||
type="button"
|
||||
className="absolute right-5 end-0"
|
||||
onClick={() => setShowPwd((s) => !s)}
|
||||
icon={showPwd ? faEyeSlash : faEye}
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="username" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Username
|
||||
</label>
|
||||
<Field
|
||||
placeholder="Enter Username"
|
||||
name="username"
|
||||
id="username"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
/>
|
||||
</div>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Password
|
||||
</label>
|
||||
<Field
|
||||
name="authenticationType"
|
||||
as="select"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] flex-1 w-2/3"
|
||||
>
|
||||
<option value="PAP">PAP</option>
|
||||
<option value="CHAP">CHAP</option>
|
||||
<option value="none">None</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
{isSubmitting || modemMutation.isPending ? "Saving..." : "Save Modem settings"}
|
||||
</button>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
)}
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Password
|
||||
</label>
|
||||
<div className="flex gap-2 items-center relative mb-4">
|
||||
<Field
|
||||
id="password"
|
||||
name="password"
|
||||
type={showPwd ? "text" : "password"}
|
||||
className="p-2 border border-gray-400 rounded-lg w-full"
|
||||
placeholder="Enter Password"
|
||||
/>
|
||||
<FontAwesomeIcon
|
||||
type="button"
|
||||
className="absolute right-5 end-0"
|
||||
onClick={() => setShowPwd((s) => !s)}
|
||||
icon={showPwd ? faEyeSlash : faEye}
|
||||
/>
|
||||
</div>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="serverPrimary" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Name server primary
|
||||
</label>
|
||||
<Field
|
||||
placeholder="Enter Server primary"
|
||||
name="serverPrimary"
|
||||
id="serverPrimary"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="serverSecondary" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Name server secondary
|
||||
</label>
|
||||
<Field
|
||||
placeholder="Enter Server secondary"
|
||||
name="serverSecondary"
|
||||
id="serverSecondary"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Authentication Type
|
||||
</label>
|
||||
<Field
|
||||
name="authenticationType"
|
||||
as="select"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] flex-1 w-2/3"
|
||||
>
|
||||
<option value="PAP">PAP</option>
|
||||
<option value="CHAP">CHAP</option>
|
||||
<option value="none">None</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
</>
|
||||
)}
|
||||
<button
|
||||
type="submit"
|
||||
className="w-full md:w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
{isSubmitting || modemMutation.isPending ? "Saving..." : "Save Modem settings"}
|
||||
</button>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
<Toaster />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useWifiAndModem } from "../../../hooks/useCameraWifiandModem";
|
||||
import { useState } from "react";
|
||||
import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { toast, Toaster } from "sonner";
|
||||
|
||||
const WiFiSettingsForm = () => {
|
||||
const [showPwd, setShowPwd] = useState(false);
|
||||
@@ -16,7 +17,13 @@ const WiFiSettingsForm = () => {
|
||||
const initialValues = {
|
||||
ssid: wifiSSID ?? "",
|
||||
password: wifiPassword ?? "",
|
||||
encryption: "WPA2",
|
||||
};
|
||||
|
||||
const validatePassword = (password: string) => {
|
||||
if (password.length < 8) {
|
||||
toast.error("Password must be at least 8 characters long", { id: "password" });
|
||||
return "Password must be at least 8 characters long";
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: WifiSettingValues) => {
|
||||
@@ -37,66 +44,56 @@ const WiFiSettingsForm = () => {
|
||||
await wifiMutation.mutateAsync(wifiConfig);
|
||||
};
|
||||
return (
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
{({ isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="ssid" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
SSID
|
||||
</label>
|
||||
<Field
|
||||
id="ssid"
|
||||
name="ssid"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
placeholder="Enter SSID"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Password
|
||||
</label>
|
||||
<div className="flex gap-2 items-center relative mb-4">
|
||||
<>
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
{({ isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="ssid" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
SSID
|
||||
</label>
|
||||
<Field
|
||||
id="password"
|
||||
name="password"
|
||||
type={showPwd ? "text" : "password"}
|
||||
className="p-2 border border-gray-400 rounded-lg w-full"
|
||||
placeholder="Enter Password"
|
||||
id="ssid"
|
||||
name="ssid"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
placeholder="Enter SSID"
|
||||
/>
|
||||
<FontAwesomeIcon
|
||||
type="button"
|
||||
className="absolute right-5 end-0"
|
||||
onClick={() => setShowPwd((s) => !s)}
|
||||
icon={showPwd ? faEyeSlash : faEye}
|
||||
/>
|
||||
</div>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="encryption" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
WPA/Encryption Type
|
||||
</label>
|
||||
<Field
|
||||
id="encryption"
|
||||
name="encryption"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] flex-1 w-2/3"
|
||||
as="select"
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Password
|
||||
</label>
|
||||
<div className="flex gap-2 items-center relative mb-4">
|
||||
<Field
|
||||
id="password"
|
||||
name="password"
|
||||
type={showPwd ? "text" : "password"}
|
||||
className="p-2 border border-gray-400 rounded-lg w-full"
|
||||
placeholder="Enter Password"
|
||||
validate={validatePassword}
|
||||
/>
|
||||
|
||||
<FontAwesomeIcon
|
||||
type="button"
|
||||
className="absolute right-5 end-0"
|
||||
onClick={() => setShowPwd((s) => !s)}
|
||||
icon={showPwd ? faEyeSlash : faEye}
|
||||
/>
|
||||
</div>
|
||||
</FormGroup>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
<option value="WPA2">WPA2</option>
|
||||
<option value="WPA3">WPA3</option>
|
||||
<option value="WEP">WEP</option>
|
||||
<option value="None">None</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
{isSubmitting || wifiMutation.isPending ? "Saving..." : " Save WiFi settings"}
|
||||
</button>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
{isSubmitting || wifiMutation.isPending ? "Saving..." : " Save WiFi settings"}
|
||||
</button>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
<Toaster />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ import HotListImg from "/Hotlist_Hit.svg";
|
||||
import NPED_CAT_A from "/NPED_Cat_A.svg";
|
||||
import NPED_CAT_B from "/NPED_Cat_B.svg";
|
||||
import NPED_CAT_C from "/NPED_Cat_C.svg";
|
||||
import { checkIsHotListHit, getHotlistName, getNPEDCategory } from "../../utils/utils";
|
||||
import NPED_CAT_D from "/NPED_Cat_D.svg";
|
||||
import { checkIsHotListHit, getHotlistName, getNPEDCategory, getNPEDReason } from "../../utils/utils";
|
||||
|
||||
type SightingModalProps = {
|
||||
isSightingModalOpen: boolean;
|
||||
@@ -21,11 +22,11 @@ type SightingModalProps = {
|
||||
|
||||
const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }: SightingModalProps) => {
|
||||
const { dispatch } = useAlertHitContext();
|
||||
|
||||
const { query, mutation } = useCameraBlackboard();
|
||||
|
||||
const hotlistName = getHotlistName(sighting?.metadata?.hotlistMatches);
|
||||
|
||||
const handleAcknowledgeButton = () => {
|
||||
const hotlistNames = getHotlistName(sighting?.metadata?.hotlistMatches);
|
||||
const handleAcknowledgeButton = async () => {
|
||||
try {
|
||||
if (!sighting) {
|
||||
toast.error("Cannot add sighting to alert list");
|
||||
@@ -33,17 +34,27 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }:
|
||||
return;
|
||||
}
|
||||
if (!query.data.alertHistory) {
|
||||
mutation.mutate({
|
||||
await mutation.mutateAsync({
|
||||
operation: "INSERT",
|
||||
path: "alertHistory",
|
||||
value: [sighting],
|
||||
});
|
||||
await mutation.mutateAsync({
|
||||
operation: "SAVE",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
} else {
|
||||
mutation.mutate({
|
||||
await mutation.mutateAsync({
|
||||
operation: "APPEND",
|
||||
path: "alertHistory",
|
||||
value: sighting,
|
||||
});
|
||||
await mutation.mutateAsync({
|
||||
operation: "SAVE",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
toast.success("Sighting Successfully added to alert list");
|
||||
}
|
||||
|
||||
@@ -64,16 +75,24 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }:
|
||||
};
|
||||
|
||||
const motionAway = (sighting?.motion ?? "").toUpperCase() === "AWAY";
|
||||
|
||||
const isHotListHit = checkIsHotListHit(sighting);
|
||||
const cat = getNPEDCategory(sighting);
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
const isNPEDHitD = cat === "D";
|
||||
|
||||
const reason = getNPEDReason(sighting);
|
||||
|
||||
const insuranceStatus = reason ? reason["INSURANCE STATUS"] : null;
|
||||
const motStatus = reason ? reason["MOT STATUS"] : null;
|
||||
const taxStatus = reason ? reason["TAX STATUS"] : null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<ModalComponent isModalOpen={isSightingModalOpen} close={handleClose}>
|
||||
<div className="max-w-screen-lg mx-auto py-4 px-2">
|
||||
<div className="mx-auto py-4 px-6 overflow-y-scroll">
|
||||
<div className="border-b border-gray-600 mb-4">
|
||||
<h2 className="text-lg md:text-xl font-semibold">Sighting Details</h2>
|
||||
</div>
|
||||
@@ -117,70 +136,129 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }:
|
||||
<div className="flex flex-col md:flex-row gap-3 items-center">
|
||||
<NumberPlate vrm={sighting?.vrm} motion={motionAway} />
|
||||
<img src={sighting?.plateUrlColour} alt="plate patch" className="h-16 object-contain rounded-md" />
|
||||
{hotlistName && (
|
||||
<div>
|
||||
<p className="text-gray-300">Hotlist</p>
|
||||
<div className="items-center px-2.5 py-0.5 rounded-sm me-2 bg-amber-500">
|
||||
<p className="font-medium text-2xl break-all text-amber-800">
|
||||
{hotlistName ? hotlistName[0].replace(/\.csv$/i, "") : "-"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{isHotListHit && <img src={HotListImg} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitA && <img src={NPED_CAT_A} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitB && <img src={NPED_CAT_B} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitC && <img src={NPED_CAT_C} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitD && <img src={NPED_CAT_D} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
</div>
|
||||
<div className="flex flex-col lg:flex-row items-center gap-3">
|
||||
{hotlistNames && hotlistNames.length > 0 && (
|
||||
<div className="flex flex-col border-b border-gray-600 mb-4">
|
||||
<p className="text-gray-300">Hotlists</p>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 md:gap-x-[20%] w-[50%]">
|
||||
{hotlistNames.map((hotlistName, index) => (
|
||||
<span className="items-center px-2.5 py-0.5 rounded-sm me-2 bg-amber-500 w-50 m-2" key={index}>
|
||||
<p className="font-medium text-2xl break-all text-amber-800">
|
||||
{hotlistName ? hotlistName?.replace(/\.csv$/i, "") : "-"}
|
||||
</p>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex flex-col lg:flex-row items-center gap-3 ">
|
||||
<img
|
||||
src={sighting?.overviewUrl}
|
||||
alt="overview patch"
|
||||
className="w-full h-56 sm:h-72 md:h-96 rounded-lg object-cover border border-gray-700"
|
||||
className="w-full h-56 sm:h-72 md:h-72 rounded-lg object-cover border border-gray-700"
|
||||
/>
|
||||
<aside className="w-full lg:w-80 bg-gray-800/70 text-white rounded-xl py-4 px-2 border h-[70%] border-gray-700">
|
||||
<h3 className="text-base md:text-lg font-semibold pb-2 border-b border-gray-700">Vehicle Info</h3>
|
||||
<dl className="mt-3 gap-x-4 gap-y-2 text-sm">
|
||||
<div>
|
||||
<dt className="text-gray-300">VRM</dt>
|
||||
<dd className="font-medium text-2xl break-all">{sighting?.vrm ?? "-"}</dd>
|
||||
<dd className="font-medium text-2xl break-all font-mono tracking-wide">{sighting?.vrm ?? "-"}</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt className="text-gray-300">Motion</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.motion ?? "-"}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-gray-300">Seen Count</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.seenCount ?? "-"}</dd>
|
||||
</div>
|
||||
|
||||
{sighting?.make && (
|
||||
<div>
|
||||
<dt className="text-gray-300">Make</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.make ?? "-"}</dd>
|
||||
</div>
|
||||
)}
|
||||
{sighting?.model ||
|
||||
(!sighting?.model.trim() && (
|
||||
<div>
|
||||
<dt className="text-gray-300">Model</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.model ?? "-"}</dd>
|
||||
{isNPEDHitA || isNPEDHitB || isNPEDHitC || isNPEDHitD ? (
|
||||
<>
|
||||
<div className="">
|
||||
<dt className="text-gray-300 text-xl">Insurance</dt>
|
||||
<dd className="font-medium text-2xl flex">
|
||||
{insuranceStatus ? (
|
||||
<span
|
||||
className={`text-green-600 bg-green-300 w-[30%] px-2 rounded-lg border border-green-900`}
|
||||
>
|
||||
YES
|
||||
</span>
|
||||
) : (
|
||||
<span className={`text-red-300 bg-red-600 w-[30%] px-2 rounded-lg border border-red-900`}>
|
||||
NO
|
||||
</span>
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-gray-300 text-3xl">MOT</dt>
|
||||
<dd className="font-medium text-2xl">
|
||||
{motStatus ? (
|
||||
<span
|
||||
className={`text-green-700 bg-green-400 w-[30%] px-2 rounded-lg border border-green-900`}
|
||||
>
|
||||
VALID
|
||||
</span>
|
||||
) : (
|
||||
<span className={`text-red-600 bg-red-300 w-[30%] px-2 rounded-lg border border-red-900`}>
|
||||
EXPIRED
|
||||
</span>
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-gray-300 text-3xl">Tax</dt>
|
||||
<dd className="font-medium text-2xl">
|
||||
{taxStatus ? (
|
||||
<span
|
||||
className={`text-green-700 bg-green-400 w-[30%] px-2 rounded-lg border border-green-900`}
|
||||
>
|
||||
VALID
|
||||
</span>
|
||||
) : (
|
||||
<span className={`text-red-600 bg-red-300 w-[30%] px-2 rounded-lg border border-red-900`}>
|
||||
EXPIRED
|
||||
</span>
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
<dt className="text-gray-300">Motion</dt>
|
||||
<dd className="font-medium text-2xl ">{sighting?.motion ?? "-"}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-gray-300">Seen Count</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.seenCount ?? "-"}</dd>
|
||||
</div>
|
||||
))}
|
||||
{sighting?.color && (
|
||||
<div className="sm:col-span-2">
|
||||
<dt className="text-gray-300">Colour</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.color ?? "-"}</dd>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<dt className="text-gray-300">Time</dt>
|
||||
<dd className="font-medium text-xl">{sighting?.timeStamp ?? "-"}</dd>
|
||||
</div>
|
||||
{sighting?.make && sighting.make.trim() && sighting.make.toLowerCase() !== "disabled" && (
|
||||
<div>
|
||||
<dt className="text-gray-300">Make</dt>
|
||||
<dd className="font-medium text-2xl">{sighting.make}</dd>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{sighting?.model && sighting.model.trim() && sighting.model.toLowerCase() !== "disabled" && (
|
||||
<div>
|
||||
<dt className="text-gray-300">Model</dt>
|
||||
<dd className="font-medium text-2xl">{sighting.model}</dd>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{sighting?.color && sighting.color.trim() && sighting.color.toLowerCase() !== "disabled" && (
|
||||
<div className="sm:col-span-2">
|
||||
<dt className="text-gray-300">Colour</dt>
|
||||
<dd className="font-medium text-2xl">{sighting.color}</dd>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<dt className="text-gray-300">Time</dt>
|
||||
<dd className="font-medium text-xl">{sighting?.timeStamp ?? "-"}</dd>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</dl>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import type { ReducedSightingType, SightingType } from "../../types/types";
|
||||
import { BLANK_IMG, getSoundFileURL } from "../../utils/utils";
|
||||
import type { HitKind, QueuedHit, ReducedSightingType, SightingType } from "../../types/types";
|
||||
import { BLANK_IMG } from "../../utils/utils";
|
||||
import NumberPlate from "../PlateStack/NumberPlate";
|
||||
import Card from "../UI/Card";
|
||||
import CardHeader from "../UI/CardHeader";
|
||||
@@ -12,11 +12,8 @@ import HotListImg from "/Hotlist_Hit.svg";
|
||||
import NPED_CAT_A from "/NPED_Cat_A.svg";
|
||||
import NPED_CAT_B from "/NPED_Cat_B.svg";
|
||||
import NPED_CAT_C from "/NPED_Cat_C.svg";
|
||||
import popup from "../../assets/sounds/ui/popup_open.mp3";
|
||||
import notification from "../../assets/sounds/ui/notification.mp3";
|
||||
import { useSound } from "react-sounds";
|
||||
import { useNPEDContext } from "../../context/NPEDUserContext";
|
||||
import { useSoundContext } from "../../context/SoundContext";
|
||||
import NPED_CAT_D from "/NPED_Cat_D.svg";
|
||||
import { useIntegrationsContext } from "../../context/IntegrationsContext";
|
||||
import Loading from "../UI/Loading";
|
||||
import { checkIsHotListHit, getNPEDCategory } from "../../utils/utils";
|
||||
|
||||
@@ -39,19 +36,10 @@ type SightingHistoryProps = {
|
||||
};
|
||||
|
||||
export default function SightingHistoryWidget({ className, title }: SightingHistoryProps) {
|
||||
const [modalQueue, setModalQueue] = useState<QueuedHit[]>([]);
|
||||
|
||||
useNow(1000);
|
||||
const { state } = useSoundContext();
|
||||
|
||||
const soundSrcNped = useMemo(() => {
|
||||
return getSoundFileURL(state.NPEDsound) ?? popup;
|
||||
}, [state.NPEDsound]);
|
||||
|
||||
const soundSrcHotlist = useMemo(() => {
|
||||
return getSoundFileURL(state?.hotlists?.[0]?.sound) ?? notification;
|
||||
}, [state.hotlists]);
|
||||
|
||||
const { play: npedSound } = useSound(soundSrcNped, { volume: state.NPEDsoundVolume });
|
||||
const { play: hotlistsound } = useSound(soundSrcHotlist);
|
||||
const {
|
||||
sightings,
|
||||
setSelectedSighting,
|
||||
@@ -62,14 +50,39 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
|
||||
isLoading,
|
||||
} = useSightingFeedContext();
|
||||
|
||||
const { dispatch } = useAlertHitContext();
|
||||
const { sessionStarted, setSessionList, sessionList } = useNPEDContext();
|
||||
|
||||
const { dispatch, state: alertState } = useAlertHitContext();
|
||||
const { state: integrationState, dispatch: integrationDispatch } = useIntegrationsContext();
|
||||
const sessionStarted = integrationState.sessionStarted;
|
||||
const sessionPaused = integrationState.sessionPaused;
|
||||
const processedRefs = useRef<Set<number | string>>(new Set());
|
||||
|
||||
const hasAutoOpenedRef = useRef(false);
|
||||
const npedRef = useRef(false);
|
||||
|
||||
const isCatAEnabled = integrationState?.iscatEnabled?.catA;
|
||||
const isCatBEnabled = integrationState?.iscatEnabled?.catB;
|
||||
const isCatCEnabled = integrationState?.iscatEnabled?.catC;
|
||||
const isCatDEnabled = integrationState?.iscatEnabled?.catD;
|
||||
|
||||
const enqueue = useCallback(
|
||||
(sighting: SightingType, kind: HitKind) => {
|
||||
if (!sighting) return;
|
||||
|
||||
const id = sighting.vrm ?? sighting.ref;
|
||||
if (processedRefs.current.has(id)) return;
|
||||
|
||||
const inList = alertState?.alertList?.find((sighting) => sighting.vrm === id);
|
||||
if (inList) {
|
||||
return;
|
||||
}
|
||||
|
||||
processedRefs.current.add(id);
|
||||
|
||||
setModalQueue((q) => [...q, { id, sighting, kind }]);
|
||||
},
|
||||
[alertState?.alertList]
|
||||
);
|
||||
|
||||
const reduceObject = (obj: SightingType): ReducedSightingType => {
|
||||
return {
|
||||
vrm: obj.vrm,
|
||||
@@ -80,11 +93,12 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
|
||||
useEffect(() => {
|
||||
if (sessionStarted) {
|
||||
if (!mostRecent) return;
|
||||
if (sessionPaused) return;
|
||||
const reducedMostRecent = reduceObject(mostRecent);
|
||||
setSessionList([...sessionList, reducedMostRecent]);
|
||||
integrationDispatch({ type: "ADD", payload: reducedMostRecent });
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [mostRecent, sessionStarted, setSessionList]);
|
||||
}, [mostRecent, sessionStarted]);
|
||||
|
||||
const onRowClick = useCallback(
|
||||
(sighting: SightingType) => {
|
||||
@@ -104,50 +118,29 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
|
||||
const id = sighting.vrm;
|
||||
|
||||
if (processedRefs.current.has(id)) continue;
|
||||
const isHot = checkIsHotListHit(sighting);
|
||||
const cat = sighting?.metadata?.npedJSON?.["NPED CATEGORY"];
|
||||
const isHotlistHit = checkIsHotListHit(sighting);
|
||||
const npedcategory = sighting?.metadata?.npedJSON?.["NPED CATEGORY"];
|
||||
const isNPED =
|
||||
(npedcategory === "A" && isCatAEnabled) ||
|
||||
(npedcategory === "B" && isCatBEnabled) ||
|
||||
(npedcategory === "C" && isCatCEnabled) ||
|
||||
(npedcategory === "D" && isCatDEnabled);
|
||||
|
||||
if (cat === "A" || cat === "B" || cat === "C") {
|
||||
npedSound();
|
||||
setSelectedSighting(sighting);
|
||||
setSightingModalOpen(true);
|
||||
processedRefs.current.add(id);
|
||||
break; // stop after one new open per render cycle
|
||||
}
|
||||
|
||||
if (isHot) {
|
||||
hotlistsound();
|
||||
setSelectedSighting(sighting);
|
||||
setSightingModalOpen(true);
|
||||
processedRefs.current.add(id);
|
||||
break;
|
||||
if (isNPED || isHotlistHit) {
|
||||
enqueue(sighting, isNPED ? "NPED" : "HOTLIST"); // enqueue ONLY
|
||||
}
|
||||
}
|
||||
}, [rows, hotlistsound, npedSound, setSightingModalOpen, setSelectedSighting]);
|
||||
|
||||
useEffect(() => {
|
||||
rows?.forEach((obj) => {
|
||||
const cat = getNPEDCategory(obj);
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
if (isNPEDHitA || isNPEDHitB || isNPEDHitC) {
|
||||
dispatch({
|
||||
type: "ADD",
|
||||
payload: obj,
|
||||
});
|
||||
}
|
||||
});
|
||||
}, [dispatch]);
|
||||
}, [rows, enqueue, isCatAEnabled, isCatBEnabled, isCatCEnabled, isCatDEnabled]);
|
||||
|
||||
useEffect(() => {
|
||||
if (hasAutoOpenedRef.current || npedRef.current) return;
|
||||
const firstNPED = rows.find((r) => {
|
||||
const cat = getNPEDCategory(r);
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
return isNPEDHitA || isNPEDHitB || isNPEDHitC;
|
||||
const isNPEDHitA = cat === "A" && isCatAEnabled;
|
||||
const isNPEDHitB = cat === "B" && isCatBEnabled;
|
||||
const isNPEDHitC = cat === "C" && isCatCEnabled;
|
||||
const isNPEDHitD = cat === "D" && isCatDEnabled;
|
||||
return isNPEDHitA || isNPEDHitB || isNPEDHitC || isNPEDHitD;
|
||||
});
|
||||
const firstHot = rows?.find((r) => {
|
||||
const isHotListHit = checkIsHotListHit(r);
|
||||
@@ -156,22 +149,54 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
|
||||
});
|
||||
|
||||
if (firstNPED) {
|
||||
setSelectedSighting(firstNPED);
|
||||
npedSound();
|
||||
setSightingModalOpen(true);
|
||||
enqueue(firstNPED, "NPED");
|
||||
npedRef.current = true;
|
||||
}
|
||||
|
||||
if (firstHot) {
|
||||
setSelectedSighting(firstHot);
|
||||
hotlistsound();
|
||||
setSightingModalOpen(true);
|
||||
enqueue(firstHot, "HOTLIST");
|
||||
|
||||
hasAutoOpenedRef.current = true;
|
||||
}
|
||||
}, [hotlistsound, npedSound, setSelectedSighting]);
|
||||
}, [
|
||||
enqueue,
|
||||
rows,
|
||||
setSelectedSighting,
|
||||
setSightingModalOpen,
|
||||
isCatAEnabled,
|
||||
isCatBEnabled,
|
||||
isCatCEnabled,
|
||||
isCatDEnabled,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isSightingModalOpen && modalQueue.length > 0) {
|
||||
const next = modalQueue[0];
|
||||
setSelectedSighting(next.sighting);
|
||||
|
||||
setSightingModalOpen(true);
|
||||
}
|
||||
}, [isSightingModalOpen, setSelectedSighting, setSightingModalOpen, modalQueue]);
|
||||
|
||||
useEffect(() => {
|
||||
rows?.forEach((obj) => {
|
||||
const cat = getNPEDCategory(obj);
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
const isNPEDHitD = cat === "D";
|
||||
if (isNPEDHitA || isNPEDHitB || isNPEDHitC || isNPEDHitD) {
|
||||
dispatch({
|
||||
type: "ADD",
|
||||
payload: obj,
|
||||
});
|
||||
}
|
||||
});
|
||||
}, [dispatch, rows]);
|
||||
|
||||
const handleClose = () => {
|
||||
setSightingModalOpen(false);
|
||||
setModalQueue((q) => q.slice(1));
|
||||
};
|
||||
return (
|
||||
<>
|
||||
@@ -190,6 +215,7 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
const isNPEDHitD = cat === "D";
|
||||
const motionAway = (obj?.motion ?? "").toUpperCase() === "AWAY";
|
||||
const isHotListHit = checkIsHotListHit(obj);
|
||||
return (
|
||||
@@ -208,6 +234,7 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
|
||||
{isNPEDHitA && <img src={NPED_CAT_A} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitB && <img src={NPED_CAT_B} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitC && <img src={NPED_CAT_C} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
{isNPEDHitD && <img src={NPED_CAT_D} alt="hotlistHit" className="h-20 object-contain rounded-md" />}
|
||||
<NumberPlate motion={motionAway} vrm={obj?.vrm} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,25 +11,18 @@ type CameraOverviewHeaderProps = {
|
||||
sighting?: SightingType | null;
|
||||
};
|
||||
|
||||
const CardHeader = ({
|
||||
title,
|
||||
icon,
|
||||
img,
|
||||
sighting,
|
||||
}: CameraOverviewHeaderProps) => {
|
||||
const CardHeader = ({ title, icon, img, sighting }: CameraOverviewHeaderProps) => {
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
"w-full border-b border-gray-600 flex flex-row items-center space-x-2 md:mb-6 relative justify-between"
|
||||
"w-full border-b border-gray-600 flex flex-row items-center space-x-2 mb-6 relative justify-between"
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
{icon && <FontAwesomeIcon icon={icon} className="size-4" />}
|
||||
<h2 className="text-xl">{title}</h2>
|
||||
</div>
|
||||
{img && (
|
||||
<img src={img} alt="Logo" width={100} height={50} className="ml-auto" />
|
||||
)}
|
||||
{img && <img src={img} alt="Logo" width={100} height={50} className="ml-auto" />}
|
||||
{sighting?.vrm && <NumberPlate vrm={sighting.vrm} motion={false} />}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
import { useState } from "react";
|
||||
import { useGetVersions } from "../../hooks/useGetVersions";
|
||||
import Logo from "/MAV.svg";
|
||||
import VersionsModal from "./VersionsModal";
|
||||
|
||||
const Footer = () => {
|
||||
const { versionsQuery } = useGetVersions();
|
||||
const [isDevModalOpen, setDevModalOpen] = useState(false);
|
||||
|
||||
const versionsData = versionsQuery?.data;
|
||||
|
||||
const handleClick = () => {
|
||||
setDevModalOpen(true);
|
||||
};
|
||||
return (
|
||||
<footer className="bg-gray-900 border-t border-gray-700 text-white py-5 text-left p-8 h-30 mt-5 flex flex-col space-y-4 ">
|
||||
<img src={Logo} alt="Logo" width={100} height={100} />
|
||||
<p className="text-sm">
|
||||
{new Date().getFullYear()} MAV Systems © All rights reserved.
|
||||
</p>
|
||||
</footer>
|
||||
<>
|
||||
<footer className="bg-gray-900 border-t border-gray-700 text-white py-5 text-left p-8 h-30 mt-5 flex flex-col space-y-4 ">
|
||||
<img src={Logo} alt="Logo" width={100} height={100} onClick={handleClick} />
|
||||
<p className="text-sm">{new Date().getFullYear()} MAV Systems © All rights reserved.</p>
|
||||
</footer>
|
||||
<VersionsModal isDevModalOpen={isDevModalOpen} handleClose={() => setDevModalOpen(false)} data={versionsData} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Link } from "react-router";
|
||||
import Logo from "/MAV.svg";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import {
|
||||
faBars,
|
||||
faGear,
|
||||
faHome,
|
||||
faListCheck,
|
||||
@@ -11,11 +12,18 @@ import {
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { useState } from "react";
|
||||
import SoundBtn from "./SoundBtn";
|
||||
import { useNPEDContext } from "../../context/NPEDUserContext";
|
||||
import { useIntegrationsContext } from "../../context/IntegrationsContext";
|
||||
|
||||
export default function Header() {
|
||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||
const { sessionStarted } = useNPEDContext();
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
const { state } = useIntegrationsContext();
|
||||
|
||||
const toggleMenu = () => setIsMenuOpen(!isMenuOpen);
|
||||
|
||||
const sessionStarted = state.sessionStarted;
|
||||
|
||||
const sessionPaused = state.sessionPaused;
|
||||
|
||||
const toggleFullscreen = () => {
|
||||
if (!document.fullscreenElement) {
|
||||
@@ -39,11 +47,15 @@ export default function Header() {
|
||||
</Link>
|
||||
</div>
|
||||
<div className="flex flex-col lg:flex-row items-center space-x-24 justify-items-center">
|
||||
{sessionStarted && (
|
||||
<div className="text-green-400 font-bold">Session Active</div>
|
||||
)}
|
||||
<div className="flex flex-row lg:flex-row space-x-2 mx-10 p-2 md:p-0 items-center">
|
||||
{sessionStarted && sessionPaused ? (
|
||||
<p className="text-gray-400 font-bold">Session Paused</p>
|
||||
) : (
|
||||
sessionStarted && <p className="text-green-400 font-bold">Session Active</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row space-x-8">
|
||||
<div className="flex flex-row space-x-6 md:space-x-8 items-center">
|
||||
<Link to={"/"}>
|
||||
<FontAwesomeIcon className="text-white" icon={faHome} size="2x" />
|
||||
</Link>
|
||||
@@ -58,19 +70,35 @@ export default function Header() {
|
||||
<FontAwesomeIcon icon={faRotate} size="2x" />
|
||||
</div>
|
||||
<SoundBtn />
|
||||
<Link to={"/session-settings"}>
|
||||
<FontAwesomeIcon
|
||||
className="text-white"
|
||||
icon={faListCheck}
|
||||
size="2x"
|
||||
/>
|
||||
<div className="md:hidden">
|
||||
<FontAwesomeIcon icon={faBars} size="2x" onClick={toggleMenu} />
|
||||
</div>
|
||||
|
||||
<Link className="hidden md:flex" to={"/session-settings"}>
|
||||
<FontAwesomeIcon className="text-white" icon={faListCheck} size="2x" />
|
||||
</Link>
|
||||
|
||||
<Link to={"/system-settings"}>
|
||||
<Link className="hidden md:flex" to={"/system-settings"}>
|
||||
<FontAwesomeIcon className="text-white" icon={faGear} size="2x" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
{isMenuOpen && (
|
||||
<div className="md:hidden">
|
||||
<ul className="flex flex-row gap-5">
|
||||
<li onClick={() => setIsMenuOpen(false)}>
|
||||
<Link to={"/session-settings"}>
|
||||
<FontAwesomeIcon className="text-white" icon={faListCheck} size="2x" />
|
||||
</Link>
|
||||
</li>
|
||||
<li onClick={() => setIsMenuOpen(false)}>
|
||||
<Link to={"/system-settings"}>
|
||||
<FontAwesomeIcon className="text-white" icon={faGear} size="2x" />
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,16 @@ const ModalComponent = ({ isModalOpen, children, close }: ModalComponentProps) =
|
||||
<Modal
|
||||
isOpen={isModalOpen}
|
||||
onRequestClose={close}
|
||||
className="bg-[#1e2a38] p-6 rounded-lg shadow-lg max-w-[80%] mx-auto mt-[1%] md:w-[70%] md:h-[95%] z-[100] overflow-y-auto max-h-screen"
|
||||
overlayClassName="fixed inset-0 bg-[#1e2a38]/70 flex justify-center items-start z-100"
|
||||
className="bg-[#1e2a38] p-3 rounded-lg shadow-lg w-[95%] mt-[2%] md:w-[60%] h-[100%] md:h-[95%] lg:h-[80%] z-[100] overflow-y-hidden border border-gray-500"
|
||||
overlayClassName="fixed inset-0 bg-[#1e2a38]/70 flex justify-center items-start z-100 "
|
||||
style={{
|
||||
overlay: {
|
||||
transition: "opacity 200ms ease-in-out",
|
||||
},
|
||||
content: {
|
||||
transition: "all 200ms ease-in-out",
|
||||
},
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</Modal>
|
||||
|
||||
@@ -17,9 +17,9 @@ const NavigationArrow = ({ side, settingsPage }: NavigationArrowProps) => {
|
||||
}
|
||||
|
||||
if (side === "Front") {
|
||||
navigate("/camera-settings");
|
||||
navigate("/a-camera-settings");
|
||||
} else if (side === "Rear") {
|
||||
navigate("/Rear-Camera-settings");
|
||||
navigate("/b-Camera-settings");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,15 +30,15 @@ const NavigationArrow = ({ side, settingsPage }: NavigationArrowProps) => {
|
||||
<FontAwesomeIcon
|
||||
size="2xl"
|
||||
icon={faArrowRight}
|
||||
className="absolute top-[50%] right-[2%] backdrop-blur-lg hover:cursor-pointer animate-bounce z-30"
|
||||
onClick={() => navigationDest("Front")}
|
||||
className="absolute top-[50%] right-[2%] backdrop-blur-lg hover:cursor-pointer animate-bounce z-30 rounded-md arrow-outline"
|
||||
onClick={() => navigationDest("a")}
|
||||
/>
|
||||
) : (
|
||||
<FontAwesomeIcon
|
||||
icon={faArrowLeft}
|
||||
size="2xl"
|
||||
className="absolute top-[50%] left-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-30"
|
||||
onClick={() => navigationDest(side)}
|
||||
className="absolute top-[50%] left-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-30 rounded-md arrow-outline"
|
||||
onClick={() => navigationDest("b")}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
@@ -49,14 +49,14 @@ const NavigationArrow = ({ side, settingsPage }: NavigationArrowProps) => {
|
||||
<FontAwesomeIcon
|
||||
icon={faArrowLeft}
|
||||
size="2xl"
|
||||
className="absolute top-[50%] left-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-100 "
|
||||
className="absolute top-[50%] left-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-100 arrow-outline rounded-md"
|
||||
onClick={() => navigationDest("Front")}
|
||||
/>
|
||||
|
||||
<FontAwesomeIcon
|
||||
icon={faArrowRight}
|
||||
size="2xl"
|
||||
className="absolute top-[50%] right-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-100"
|
||||
className="absolute top-[50%] right-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-100 arrow-outline rounded-md"
|
||||
onClick={() => navigationDest("Rear")}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -4,7 +4,20 @@ import { useSoundContext } from "../../context/SoundContext";
|
||||
|
||||
const SliderComponent = ({ soundCategory }: { soundCategory: "SIGHTINGVOLUME" | "NPEDVOLUME" | "HOTLISTVOLUME" }) => {
|
||||
const { dispatch, state } = useSoundContext();
|
||||
const volume = soundCategory === "SIGHTINGVOLUME" ? state.sightingVolume : state.NPEDsoundVolume;
|
||||
|
||||
const getVolumeOption = (soundCategory: string) => {
|
||||
if (soundCategory === "SIGHTINGVOLUME") {
|
||||
return state.sightingVolume;
|
||||
}
|
||||
if (soundCategory === "NPEDVOLUME") {
|
||||
return state.NPEDsoundVolume;
|
||||
}
|
||||
if (soundCategory === "HOTLISTVOLUME") {
|
||||
return state.hotlistSoundVolume;
|
||||
}
|
||||
};
|
||||
|
||||
const volume = getVolumeOption(soundCategory);
|
||||
|
||||
const handleChange = (value: number | number[]) => {
|
||||
const number = typeof value === "number" ? value : value[0];
|
||||
@@ -39,7 +52,7 @@ const SliderComponent = ({ soundCategory }: { soundCategory: "SIGHTINGVOLUME" |
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<span>{volume * 10}</span>
|
||||
<span>{volume ? volume * 10 : 1}</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,6 +16,11 @@ const SoundBtn = () => {
|
||||
path: "soundEnabled",
|
||||
value: { enabled: newEnabled },
|
||||
});
|
||||
await mutation.mutateAsync({
|
||||
operation: "SAVE",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
};
|
||||
useEffect(() => {
|
||||
setEnabled(query?.data?.soundEnabled?.enabled);
|
||||
@@ -23,10 +28,7 @@ const SoundBtn = () => {
|
||||
|
||||
return (
|
||||
<button onClick={handleClick}>
|
||||
<FontAwesomeIcon
|
||||
icon={enabled ? faVolumeHigh : faVolumeXmark}
|
||||
size="2x"
|
||||
/>
|
||||
<FontAwesomeIcon icon={enabled ? faVolumeHigh : faVolumeXmark} size="2x" />
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
18
src/components/UI/VehicleSessionItem.tsx
Normal file
18
src/components/UI/VehicleSessionItem.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import clsx from "clsx";
|
||||
|
||||
type VehicleSessionItemProps = {
|
||||
sessionNumber: number;
|
||||
textColour: string;
|
||||
vehicleTag: string;
|
||||
};
|
||||
|
||||
const VehicleSessionItem = ({ sessionNumber, textColour, vehicleTag }: VehicleSessionItemProps) => {
|
||||
return (
|
||||
<li className="rounded-xl border border-slate-800 bg-slate-800/60 p-3 shadow-sm flex flex-row justify-between items-center">
|
||||
<p>{vehicleTag}</p>
|
||||
<span className={`font-bold text-xl bg-slate-700 px-2 rounded-md ${clsx(textColour)}`}>{sessionNumber}</span>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
|
||||
export default VehicleSessionItem;
|
||||
84
src/components/UI/VersionsModal.tsx
Normal file
84
src/components/UI/VersionsModal.tsx
Normal file
@@ -0,0 +1,84 @@
|
||||
import type { versionInfo } from "../../types/types";
|
||||
import ModalComponent from "./ModalComponent";
|
||||
|
||||
type VersionsModalProps = {
|
||||
isDevModalOpen: boolean;
|
||||
handleClose: () => void;
|
||||
data: versionInfo;
|
||||
};
|
||||
|
||||
const VersionsModal = ({ isDevModalOpen, handleClose, data }: VersionsModalProps) => {
|
||||
const uiName = __APP_NAME__;
|
||||
const uiVersion = __APP_VERSION__;
|
||||
const commitID = __GIT_COMMIT__;
|
||||
const commitTimeStamp = __GIT_TIMESTAMP__;
|
||||
|
||||
return (
|
||||
<ModalComponent isModalOpen={isDevModalOpen} close={handleClose}>
|
||||
<div className="flex justify-end overflow-auto">
|
||||
<button
|
||||
onClick={handleClose}
|
||||
className="p-2 border border-gray-600 rounded-md text-gray-200 hover:bg-gray-700 transition"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
<div className="space-y-6 p-5">
|
||||
<div className="border-b border-gray-600 pb-3">
|
||||
<h2 className="text-2xl font-bold text-gray-100">System Information</h2>
|
||||
<p className="text-sm text-gray-400 mt-1">Application version details</p>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-sm font-semibold text-gray-400 uppercase tracking-wide">Frontend (UI)</h3>
|
||||
<div className="bg-gray-800/50 rounded-lg p-4 space-y-3">
|
||||
<div className="flex justify-between items-center border-b border-gray-700 pb-2">
|
||||
<span className="text-gray-400 text-sm">Name</span>
|
||||
<span className="text-gray-200 font-mono font-semibold">{uiName}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-gray-400 text-sm">Version</span>
|
||||
<span className="text-gray-200 font-mono font-semibold">{uiVersion}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-gray-400 text-sm">Revision (Commit ID)</span>
|
||||
<span className="bg-[#233241] p-2 rounded-md text-gray-200 font-mono text-sm">{commitID}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-gray-400 text-sm">Build Time</span>
|
||||
<span className="text-gray-200 font-mono text-sm">{commitTimeStamp}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-sm font-semibold text-gray-400 uppercase tracking-wide">Backend</h3>
|
||||
<div className="bg-gray-800/50 rounded-lg p-4 space-y-3">
|
||||
<div className="flex justify-between items-center border-b border-gray-700 pb-2">
|
||||
<span className="text-gray-400 text-sm"> Name</span>
|
||||
<span className="text-gray-200 font-mono font-semibold">{data?.appname || "N/A"}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center pb-2">
|
||||
<span className="text-gray-400 text-sm">Version</span>
|
||||
<span className="text-gray-200 font-mono font-semibold">{data?.version || "N/A"}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center pb-2">
|
||||
<span className="text-gray-400 text-sm">Revision (Commit ID)</span>
|
||||
<span className="bg-[#233241] p-2 rounded-md text-gray-200 font-mono text-sm">
|
||||
{data?.revision || "N/A"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center pb-2">
|
||||
<span className="text-gray-400 text-sm">Build Time</span>
|
||||
<span className="text-gray-200 font-mono text-sm">{data?.buildtime || "N/A"}</span>
|
||||
</div>
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-gray-400 text-sm">MAC Address</span>
|
||||
<span className="text-gray-200 font-mono text-sm">{data?.MAC || "N/A"}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ModalComponent>
|
||||
);
|
||||
};
|
||||
|
||||
export default VersionsModal;
|
||||
14
src/context/IntegrationsContext.ts
Normal file
14
src/context/IntegrationsContext.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createContext, useContext, type ActionDispatch } from "react";
|
||||
import type { NPEDACTION, NPEDSTATE } from "../types/types";
|
||||
|
||||
type IntegrationsValue = {
|
||||
state: NPEDSTATE;
|
||||
dispatch: ActionDispatch<[action: NPEDACTION]>;
|
||||
};
|
||||
|
||||
export const IntegrationsContext = createContext<IntegrationsValue | undefined>(undefined);
|
||||
export const useIntegrationsContext = () => {
|
||||
const ctx = useContext(IntegrationsContext);
|
||||
if (!ctx) throw new Error("useNPEDContext must be used within <IntegrationsProvider>");
|
||||
return ctx;
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
import { createContext, useContext, type SetStateAction } from "react";
|
||||
import type { NPEDUser, ReducedSightingType } from "../types/types";
|
||||
|
||||
type UserContextValue = {
|
||||
user: NPEDUser | null;
|
||||
setUser: React.Dispatch<SetStateAction<NPEDUser | null>>;
|
||||
sessionStarted: boolean;
|
||||
setSessionStarted: React.Dispatch<SetStateAction<boolean>>;
|
||||
sessionList: ReducedSightingType[];
|
||||
setSessionList: React.Dispatch<SetStateAction<ReducedSightingType[]>>;
|
||||
};
|
||||
|
||||
export const NPEDUserContext = createContext<UserContextValue | undefined>(
|
||||
undefined
|
||||
);
|
||||
export const useNPEDContext = () => {
|
||||
const ctx = useContext(NPEDUserContext);
|
||||
if (!ctx)
|
||||
throw new Error("useNPEDContext must be used within <NPEDUserProvider>");
|
||||
return ctx;
|
||||
};
|
||||
33
src/context/WebsocketContext.ts
Normal file
33
src/context/WebsocketContext.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import type { InfoBarData } from "../types/types";
|
||||
import { ReadyState } from "react-use-websocket";
|
||||
|
||||
type InfoSocketState = {
|
||||
data: InfoBarData | null;
|
||||
readyState: ReadyState;
|
||||
sendJson: (msg: unknown) => void;
|
||||
send?: (msg: string) => void;
|
||||
};
|
||||
|
||||
type heatmapSocketState = {
|
||||
data: null;
|
||||
readyState: ReadyState;
|
||||
sendJson: (msg: unknown) => void;
|
||||
send?: (msg: string) => void;
|
||||
};
|
||||
|
||||
export type WebsocketContextValue = {
|
||||
info: InfoSocketState;
|
||||
heatmap?: heatmapSocketState;
|
||||
};
|
||||
|
||||
export const WebsocketContext = createContext<WebsocketContextValue | null>(null);
|
||||
|
||||
const useWebSocketContext = () => {
|
||||
const ctx = useContext(WebsocketContext);
|
||||
if (!ctx) throw new Error("useWebSocketContext must be used inside <WebSocketConext.Provider>");
|
||||
return ctx;
|
||||
};
|
||||
|
||||
export const useInfoBarSocket = () => useWebSocketContext().info;
|
||||
export const useHeatmapSocket = () => useWebSocketContext().heatmap;
|
||||
81
src/context/providers/IntegrationsContextProvider.tsx
Normal file
81
src/context/providers/IntegrationsContextProvider.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
import { useEffect, useReducer, type ReactNode } from "react";
|
||||
import { IntegrationsContext } from "../IntegrationsContext";
|
||||
import { useCameraBlackboard } from "../../hooks/useCameraBlackboard";
|
||||
import { initialState, reducer } from "../reducers/IntegrationsContextReducer";
|
||||
import { useHotlistData } from "../../hooks/useHotListData";
|
||||
|
||||
type IntegrationsProviderType = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export const IntegrationsProvider = ({ children }: IntegrationsProviderType) => {
|
||||
const [state, dispatch] = useReducer(reducer, initialState);
|
||||
const { mutation } = useCameraBlackboard();
|
||||
const { query } = useHotlistData();
|
||||
|
||||
useEffect(() => {
|
||||
let isMounted = true;
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
await mutation.mutateAsync({
|
||||
operation: "Load",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
const result = await mutation.mutateAsync({
|
||||
operation: "VIEW",
|
||||
path: "sessionStats",
|
||||
});
|
||||
|
||||
if (!isMounted) return;
|
||||
|
||||
const catResult = await mutation.mutateAsync({
|
||||
operation: "VIEW",
|
||||
path: "CategoryPopup",
|
||||
});
|
||||
|
||||
if (!isMounted) return;
|
||||
|
||||
if (result?.result && typeof result.result !== "string") {
|
||||
dispatch({ type: "UPDATE", payload: result.result });
|
||||
}
|
||||
|
||||
if (catResult?.result) {
|
||||
dispatch({ type: "NPEDCATENABLED", payload: catResult.result });
|
||||
} else {
|
||||
dispatch({
|
||||
type: "NPEDCATENABLED",
|
||||
payload: { catA: true, catB: true, catC: true, catD: true },
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error in fetchData:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchHotlistData = async () => {
|
||||
dispatch({ type: "SETHOTLISTS", payload: query?.data?.hotlists });
|
||||
};
|
||||
fetchHotlistData();
|
||||
}, [query?.data]);
|
||||
|
||||
return (
|
||||
<IntegrationsContext.Provider
|
||||
value={{
|
||||
state,
|
||||
dispatch,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</IntegrationsContext.Provider>
|
||||
);
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
import { useState, type ReactNode } from "react";
|
||||
import type { NPEDUser, ReducedSightingType } from "../../types/types";
|
||||
import { NPEDUserContext } from "../NPEDUserContext";
|
||||
|
||||
type NPEDUserProviderType = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export const NPEDUserProvider = ({ children }: NPEDUserProviderType) => {
|
||||
const [user, setUser] = useState<NPEDUser | null>(null);
|
||||
const [sessionStarted, setSessionStarted] = useState(false);
|
||||
const [sessionList, setSessionList] = useState<ReducedSightingType[]>([]);
|
||||
|
||||
return (
|
||||
<NPEDUserContext.Provider
|
||||
value={{
|
||||
user,
|
||||
setUser,
|
||||
setSessionStarted,
|
||||
sessionStarted,
|
||||
sessionList,
|
||||
setSessionList,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</NPEDUserContext.Provider>
|
||||
);
|
||||
};
|
||||
@@ -20,8 +20,17 @@ const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
|
||||
operation: "VIEW",
|
||||
path: "soundSettings",
|
||||
});
|
||||
console.log(result.result);
|
||||
dispatch({ type: "UPDATE", payload: result.result });
|
||||
await mutation.mutateAsync({
|
||||
operation: "LOAD",
|
||||
path: "",
|
||||
value: null,
|
||||
});
|
||||
|
||||
if (!result.result || typeof result.result !== "object") {
|
||||
dispatch({ type: "UPDATE", payload: state });
|
||||
} else {
|
||||
dispatch({ type: "UPDATE", payload: result.result });
|
||||
}
|
||||
};
|
||||
fetchSound();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
||||
40
src/context/providers/WebSocketProvider.tsx
Normal file
40
src/context/providers/WebSocketProvider.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
||||
import type { InfoBarData } from "../../types/types";
|
||||
import useWebSocket from "react-use-websocket";
|
||||
import { ws_config } from "../../utils/ws_config";
|
||||
import { WebsocketContext, type WebsocketContextValue } from "../WebsocketContext";
|
||||
|
||||
type WebSocketProviderProps = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
const WebSocketProvider = ({ children }: WebSocketProviderProps) => {
|
||||
const [systemData, setSystemData] = useState<InfoBarData | null>(null);
|
||||
|
||||
const infoSocket = useWebSocket(ws_config.infoBar, { share: true, shouldReconnect: () => true });
|
||||
|
||||
useEffect(() => {
|
||||
async function parseData() {
|
||||
if (infoSocket.lastMessage) {
|
||||
const text = await infoSocket.lastMessage.data.text();
|
||||
const data = JSON.parse(text);
|
||||
setSystemData(data);
|
||||
}
|
||||
}
|
||||
parseData();
|
||||
}, [infoSocket.lastMessage]);
|
||||
|
||||
const value = useMemo<WebsocketContextValue>(
|
||||
() => ({
|
||||
info: {
|
||||
data: systemData,
|
||||
readyState: infoSocket.readyState,
|
||||
sendJson: infoSocket.sendJsonMessage,
|
||||
},
|
||||
}),
|
||||
[systemData, infoSocket.readyState, infoSocket.sendJsonMessage]
|
||||
);
|
||||
return <WebsocketContext.Provider value={value}>{children}</WebsocketContext.Provider>;
|
||||
};
|
||||
|
||||
export default WebSocketProvider;
|
||||
74
src/context/reducers/IntegrationsContextReducer.ts
Normal file
74
src/context/reducers/IntegrationsContextReducer.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import type { NPEDACTION, NPEDSTATE } from "../../types/types";
|
||||
|
||||
export const initialState = {
|
||||
sessionStarted: true,
|
||||
sessionList: [],
|
||||
sessionPaused: false,
|
||||
savedSightings: [],
|
||||
npedUser: null,
|
||||
iscatEnabled: {
|
||||
catA: true,
|
||||
catB: true,
|
||||
catC: true,
|
||||
catD: false,
|
||||
},
|
||||
hotlistFiles: [],
|
||||
};
|
||||
|
||||
export function reducer(state: NPEDSTATE, action: NPEDACTION) {
|
||||
switch (action.type) {
|
||||
case "SESSIONSTART":
|
||||
return {
|
||||
...state,
|
||||
sessionStarted: action.payload,
|
||||
};
|
||||
case "LOGIN":
|
||||
return {
|
||||
...state,
|
||||
npedUser: action.payload,
|
||||
};
|
||||
case "LOGOUT":
|
||||
return {
|
||||
...state,
|
||||
npedUser: action.payload,
|
||||
};
|
||||
case "SESSIONPAUSE":
|
||||
return {
|
||||
...state,
|
||||
sessionPaused: action.payload,
|
||||
};
|
||||
case "SESSIONRESTART":
|
||||
return {
|
||||
...state,
|
||||
sessionList: action.payload,
|
||||
};
|
||||
case "ADD":
|
||||
return {
|
||||
...state,
|
||||
sessionList: [...state.sessionList, action.payload],
|
||||
};
|
||||
case "UPDATE":
|
||||
return {
|
||||
...state,
|
||||
sessionList: action.payload,
|
||||
};
|
||||
case "NPEDCATENABLED":
|
||||
return {
|
||||
...state,
|
||||
iscatEnabled: action.payload,
|
||||
};
|
||||
|
||||
case "SETHOTLISTS":
|
||||
return {
|
||||
...state,
|
||||
hotlistFiles: action.payload,
|
||||
};
|
||||
case "DELETEHOTLIST":
|
||||
return {
|
||||
...state,
|
||||
hotlistFiles: state.hotlistFiles.filter((hotlist) => hotlist.filename !== action.payload),
|
||||
};
|
||||
default:
|
||||
return { ...state };
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,22 @@ import type { SoundAction, SoundState } from "../../types/types";
|
||||
export const initialState: SoundState = {
|
||||
sightingSound: "switch",
|
||||
NPEDsound: "popup",
|
||||
hotlistSound: "warning",
|
||||
hotlists: [{ name: "hotlistName", sound: "notification" }],
|
||||
soundOptions: [
|
||||
{ name: "Switch (Default)", soundFile: "switch" },
|
||||
{ name: "Popup", soundFile: "popup" },
|
||||
{ name: "Notification", soundFile: "notification" },
|
||||
{ name: "Beep", soundFile: "beep" },
|
||||
{ name: "Ding", soundFile: "ding" },
|
||||
{ name: "Shutter", soundFile: "shutter" },
|
||||
{ name: "Warning (voice)", soundFile: "warning" },
|
||||
{ name: "Switch (Default)", soundFileName: "switch" },
|
||||
{ name: "Popup", soundFileName: "popup" },
|
||||
{ name: "Notification", soundFileName: "notification" },
|
||||
{ name: "Beep", soundFileName: "beep" },
|
||||
{ name: "Ding", soundFileName: "ding" },
|
||||
{ name: "Shutter", soundFileName: "shutter" },
|
||||
{ name: "Warning (voice)", soundFileName: "warning" },
|
||||
{ name: "Attention (voice)", soundFileName: "attention" },
|
||||
],
|
||||
sightingVolume: 1,
|
||||
NPEDsoundVolume: 1,
|
||||
hotlistSoundVolume: 1,
|
||||
uploadedSound: null,
|
||||
};
|
||||
|
||||
export function reducer(state: SoundState, action: SoundAction): SoundState {
|
||||
@@ -25,12 +28,15 @@ export function reducer(state: SoundState, action: SoundAction): SoundState {
|
||||
...state,
|
||||
sightingSound: action.payload.sightingSound,
|
||||
NPEDsound: action.payload.NPEDsound,
|
||||
hotlistSound: action.payload.hotlistSound,
|
||||
hotlists: action.payload.hotlists?.map((hotlist) => ({
|
||||
name: hotlist.name,
|
||||
sound: hotlist.sound,
|
||||
})),
|
||||
NPEDsoundVolume: action.payload.NPEDsoundVolume,
|
||||
sightingVolume: action.payload.sightingVolume,
|
||||
hotlistSoundVolume: action.payload.hotlistSoundVolume,
|
||||
soundOptions: action.payload.soundOptions,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,6 +59,16 @@ export function reducer(state: SoundState, action: SoundAction): SoundState {
|
||||
NPEDsoundVolume: action.payload,
|
||||
};
|
||||
|
||||
case "HOTLISTVOLUME":
|
||||
return {
|
||||
...state,
|
||||
hotlistSoundVolume: action.payload,
|
||||
};
|
||||
case "UPLOADEDSOUND":
|
||||
return {
|
||||
...state,
|
||||
uploadedSound: action.payload,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
75
src/hooks/useBackOfficeConfig.ts
Normal file
75
src/hooks/useBackOfficeConfig.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
import type { InitialValuesForm } from "../types/types";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const getBackOfficeConfig = async (format: string) => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=Dispatcher-${format?.toLowerCase()}`);
|
||||
if (!response.ok) throw new Error("Cannot get Back Office configuration");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const updateBackOfficeConfig = async (data: InitialValuesForm) => {
|
||||
const updateConfigPayload = {
|
||||
id: `Dispatcher-${data.format.toLowerCase()}`,
|
||||
fields: [
|
||||
{
|
||||
property: "propBackofficeURL",
|
||||
value: data.backOfficeURL,
|
||||
},
|
||||
{
|
||||
property: "propConnectTimeoutSeconds",
|
||||
value: data.connectTimeoutSeconds,
|
||||
},
|
||||
{
|
||||
property: "propPassword",
|
||||
value: data.password,
|
||||
},
|
||||
{
|
||||
property: "propReadTimeoutSeconds",
|
||||
value: data.readTimeoutSeconds,
|
||||
},
|
||||
{
|
||||
property: "propUsername",
|
||||
value: data.username,
|
||||
},
|
||||
],
|
||||
};
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(updateConfigPayload),
|
||||
});
|
||||
if (!response.ok) throw new Error("Cannot update Back Office configuration");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useCameraBackOfficeOutput = (format: string) => {
|
||||
const backOfficeQuery = useQuery({
|
||||
queryKey: ["backoffice", format],
|
||||
queryFn: () => getBackOfficeConfig(format),
|
||||
enabled: !!format,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (backOfficeQuery.isError) toast.error(backOfficeQuery.error.message);
|
||||
}, [backOfficeQuery?.error?.message, backOfficeQuery.isError]);
|
||||
|
||||
return {
|
||||
backOfficeQuery,
|
||||
};
|
||||
};
|
||||
|
||||
export const useUpdateBackOfficeConfig = () => {
|
||||
const backOfficeMutation = useMutation({
|
||||
mutationKey: ["backOfficeUpdate"],
|
||||
mutationFn: updateBackOfficeConfig,
|
||||
onError: (error) => toast.error(error.message),
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
toast.success("Settings successfully updated", { id: "dispatchSettings" });
|
||||
}
|
||||
},
|
||||
});
|
||||
return { backOfficeMutation };
|
||||
};
|
||||
@@ -8,7 +8,7 @@ const camBase = import.meta.env.MODE !== "development" ? CAM_BASE : "";
|
||||
|
||||
const getAllBlackboardData = async () => {
|
||||
const response = await fetch(`${camBase}/api/blackboard`, {
|
||||
signal: AbortSignal.timeout(500),
|
||||
signal: AbortSignal.timeout(300000),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch blackboard data");
|
||||
@@ -17,7 +17,7 @@ const getAllBlackboardData = async () => {
|
||||
};
|
||||
|
||||
const viewBlackboardData = async (options: CameraBlackBoardOptions) => {
|
||||
const response = await fetch(`/${camBase}api/blackboard`, {
|
||||
const response = await fetch(`${camBase}/api/blackboard`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(options),
|
||||
|
||||
@@ -8,7 +8,7 @@ const fetchCameraSideConfig = async ({ queryKey }: { queryKey: string[] }) => {
|
||||
const [, cameraSide] = queryKey;
|
||||
const fetchUrl = `${base_url}/fetch-config?id=${cameraSide}`;
|
||||
const response = await fetch(fetchUrl, {
|
||||
signal: AbortSignal.timeout(500),
|
||||
signal: AbortSignal.timeout(300000),
|
||||
});
|
||||
if (!response.ok) throw new Error("cannot react cameraSide ");
|
||||
return response.json();
|
||||
@@ -31,7 +31,7 @@ const updateCamerasideConfig = async (data: { id: string | number; friendlyName:
|
||||
method: "POST",
|
||||
body: JSON.stringify(updateConfigPayload),
|
||||
});
|
||||
if (!response.ok) throw new Error("Feature unavailable: Coming soon");
|
||||
if (!response.ok) throw new Error("Please make sure fields are filled in correctly");
|
||||
};
|
||||
|
||||
export const useFetchCameraConfig = (cameraSide: string) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
import { useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
import type { BearerTypeFieldType, InitialValuesForm } from "../types/types";
|
||||
import type { BearerTypeFieldType, OptionalBOF2Constants, OptionalBOF2LaneIDs } from "../types/types";
|
||||
|
||||
const getDispatcherConfig = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=Dispatcher`);
|
||||
@@ -18,14 +18,13 @@ const updateDispatcherConfig = async (data: BearerTypeFieldType) => {
|
||||
property: "propEnabled",
|
||||
value: data.enabled,
|
||||
},
|
||||
// Todo: figure out how to add verbose conditionally
|
||||
{
|
||||
property: "propFormat",
|
||||
value: data.format,
|
||||
},
|
||||
],
|
||||
};
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config?id=Dispatcher`, {
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(updateConfigPayload),
|
||||
});
|
||||
@@ -33,43 +32,68 @@ const updateDispatcherConfig = async (data: BearerTypeFieldType) => {
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const getBackOfficeConfig = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=Dispatcher-json`);
|
||||
if (!response.ok) throw new Error("Cannot get Back Office configuration");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const updateBackOfficeConfig = async (data: InitialValuesForm) => {
|
||||
const updateConfigPayload = {
|
||||
id: "Dispatcher-json",
|
||||
const updateBackOfficeDispatcher = async (data: OptionalBOF2Constants) => {
|
||||
const bof2ContantsPayload = {
|
||||
id: "Dispatcher-bof2-constants",
|
||||
fields: [
|
||||
{
|
||||
property: "propBackofficeURL",
|
||||
value: data.backOfficeURL,
|
||||
property: "propFeedIdentifier",
|
||||
value: data?.FFID,
|
||||
},
|
||||
{
|
||||
property: "propConnectTimeoutSeconds",
|
||||
value: data.connectTimeoutSeconds,
|
||||
property: "propSourceIdentifier",
|
||||
value: data?.SCID,
|
||||
},
|
||||
{
|
||||
property: "propPassword",
|
||||
value: data.password,
|
||||
property: "propTimeZoneType",
|
||||
value: data?.timestampSource,
|
||||
},
|
||||
{
|
||||
property: "propReadTimeoutSeconds",
|
||||
value: data.readTimeoutSeconds,
|
||||
},
|
||||
{
|
||||
property: "propUsername",
|
||||
value: data.username,
|
||||
property: "propGpsFormat",
|
||||
value: data?.GPSFormat,
|
||||
},
|
||||
],
|
||||
};
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config?id=Dispatcher-json`, {
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(updateConfigPayload),
|
||||
body: JSON.stringify(bof2ContantsPayload),
|
||||
});
|
||||
if (!response.ok) throw new Error("Cannot update Back Office configuration");
|
||||
if (!response.ok) throw new Error("Cannot update dispatcher configuration");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const getBof2DispatcherData = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=Dispatcher-bof2-constants`);
|
||||
if (!response.ok) throw new Error("Cannot get BOF2 dispatcher config");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const updateBOF2LaneId = async (data: OptionalBOF2LaneIDs) => {
|
||||
const bof2LaneIds = {
|
||||
id: data?.laneId,
|
||||
fields: [
|
||||
{
|
||||
property: "propLaneID1",
|
||||
value: data?.LID1,
|
||||
},
|
||||
{
|
||||
property: "propLaneID2",
|
||||
value: data?.LID2,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config`, {
|
||||
method: "post",
|
||||
body: JSON.stringify(bof2LaneIds),
|
||||
});
|
||||
if (!response.ok) throw new Error("cannot send to lane IDs");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const getBOF2LaneId = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=SightingAmmendA-lane-ids`);
|
||||
if (!response.ok) throw new Error("Canot get Lane Ids");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
@@ -79,45 +103,55 @@ export const useCameraOutput = () => {
|
||||
queryFn: getDispatcherConfig,
|
||||
});
|
||||
|
||||
const backOfficeQuery = useQuery({
|
||||
queryKey: ["backoffice"],
|
||||
queryFn: getBackOfficeConfig,
|
||||
});
|
||||
|
||||
const dispatcherMutation = useMutation({
|
||||
mutationFn: updateDispatcherConfig,
|
||||
mutationKey: ["dispatcherUpdate"],
|
||||
onError: (error) => toast.error(error.message),
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
toast.success("Settings successfully updated");
|
||||
toast.success("Settings successfully updated", { id: "dispatchSettings" });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const backOfficeMutation = useMutation({
|
||||
mutationKey: ["backOfficeUpdate"],
|
||||
mutationFn: updateBackOfficeConfig,
|
||||
onError: (error) => toast.error(error.message),
|
||||
const backOfficeDispatcherMutation = useMutation({
|
||||
mutationKey: ["backofficedDispatcher"],
|
||||
mutationFn: updateBackOfficeDispatcher,
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
toast.success("Settings successfully updated");
|
||||
toast.success("Settings successfully updated", { id: "dispatchSettings" });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const bof2LandMutation = useMutation({
|
||||
mutationKey: ["updateBOF2LaneId"],
|
||||
mutationFn: updateBOF2LaneId,
|
||||
});
|
||||
|
||||
const laneIdQuery = useQuery({
|
||||
queryKey: ["getBOF2LaneId"],
|
||||
queryFn: getBOF2LaneId,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (dispatcherQuery.isError) toast.error(dispatcherQuery.error.message);
|
||||
}, [dispatcherQuery?.error?.message, dispatcherQuery.isError]);
|
||||
|
||||
useEffect(() => {
|
||||
if (backOfficeQuery.isError) toast.error(backOfficeQuery.error.message);
|
||||
}, [backOfficeQuery?.error?.message, backOfficeQuery.isError]);
|
||||
|
||||
return {
|
||||
dispatcherQuery,
|
||||
dispatcherMutation,
|
||||
backOfficeQuery,
|
||||
backOfficeMutation,
|
||||
backOfficeDispatcherMutation,
|
||||
bof2LandMutation,
|
||||
laneIdQuery,
|
||||
};
|
||||
};
|
||||
|
||||
export const useGetDispatcherConfig = () => {
|
||||
const bof2ConstantsQuery = useQuery({
|
||||
queryKey: ["getBof2DispatcherData"],
|
||||
queryFn: getBof2DispatcherData,
|
||||
});
|
||||
|
||||
return { bof2ConstantsQuery };
|
||||
};
|
||||
|
||||
@@ -3,10 +3,11 @@ import { CAM_BASE } from "../utils/config";
|
||||
import type { ModemConfig, WifiConfig } from "../types/types";
|
||||
import { useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
const camBase = import.meta.env.MODE !== "development" ? CAM_BASE : "";
|
||||
|
||||
const getWiFiSettings = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=ModemAndWifiManager-wifi`, {
|
||||
signal: AbortSignal.timeout(500),
|
||||
const response = await fetch(`${camBase}/api/fetch-config?id=ModemAndWifiManager-wifi`, {
|
||||
signal: AbortSignal.timeout(600000),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Cannot fetch Wifi settings");
|
||||
@@ -15,7 +16,7 @@ const getWiFiSettings = async () => {
|
||||
};
|
||||
|
||||
const updateWifiSettings = async (wifiConfig: WifiConfig) => {
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config?id=ModemAndWifiManager-wifi`, {
|
||||
const response = await fetch(`${camBase}/api/update-config`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(wifiConfig),
|
||||
@@ -27,8 +28,8 @@ const updateWifiSettings = async (wifiConfig: WifiConfig) => {
|
||||
};
|
||||
|
||||
const getModemSettings = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=ModemAndWifiManager-modem`, {
|
||||
signal: AbortSignal.timeout(500),
|
||||
const response = await fetch(`${camBase}/api/fetch-config?id=ModemAndWifiManager-modem`, {
|
||||
signal: AbortSignal.timeout(600000),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Cannot fetch modem settings");
|
||||
@@ -37,7 +38,7 @@ const getModemSettings = async () => {
|
||||
};
|
||||
|
||||
const updateModemSettings = async (modemConfig: ModemConfig) => {
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config?id=ModemAndWifiManager-modem`, {
|
||||
const response = await fetch(`${camBase}/api/update-config`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(modemConfig),
|
||||
|
||||
@@ -1,18 +1,38 @@
|
||||
import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
type QueryFunctionContext,
|
||||
} from "@tanstack/react-query";
|
||||
import { useMutation, useQuery, type QueryFunctionContext } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
import type { zoomConfig, ZoomInOptions } from "../types/types";
|
||||
import { toast } from "sonner";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const getCameraMode = async (options: { camera: string }) => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=Ip${options.camera}`);
|
||||
if (!response.ok) throw new Error("Cannot get camera mode");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const updateCameraMode = async (options: { camera: string; mode: string }) => {
|
||||
const dayNightPayload = {
|
||||
id: options.camera,
|
||||
fields: [
|
||||
{
|
||||
property: "propDayNightMode",
|
||||
value: options.mode,
|
||||
},
|
||||
],
|
||||
};
|
||||
const response = await fetch(`${CAM_BASE}/Ip${options.camera}-command?dayNightMode=${options.mode}`, {
|
||||
method: "post",
|
||||
body: JSON.stringify(dayNightPayload),
|
||||
});
|
||||
if (!response.ok) throw new Error("cannot update camera mode");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
async function zoomIn(options: ZoomInOptions) {
|
||||
const response = await fetch(
|
||||
`${CAM_BASE}/Ip${options.camera}-command?magnification=${options.multiplier}x`,
|
||||
`${CAM_BASE}/Ip${options.camera}-command?magnification=${options.multiplierText?.toLowerCase()}`,
|
||||
{
|
||||
signal: AbortSignal.timeout(500),
|
||||
signal: AbortSignal.timeout(300000),
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
@@ -22,28 +42,21 @@ async function zoomIn(options: ZoomInOptions) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function fetchZoomInConfig({
|
||||
queryKey,
|
||||
}: QueryFunctionContext<[string, zoomConfig]>) {
|
||||
async function fetchZoomInConfig({ queryKey }: QueryFunctionContext<[string, zoomConfig]>) {
|
||||
const [, { camera }] = queryKey;
|
||||
const response = await fetch(`${CAM_BASE}/Ip${camera}-inspect`, {
|
||||
signal: AbortSignal.timeout(500),
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=Ip${camera}`, {
|
||||
signal: AbortSignal.timeout(300000),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Cannot get camera zoom settings");
|
||||
}
|
||||
return response.text();
|
||||
return response.json();
|
||||
}
|
||||
//change to string
|
||||
export const useCameraZoom = (options: zoomConfig) => {
|
||||
const mutation = useMutation({
|
||||
mutationKey: ["zoomIn"],
|
||||
mutationFn: (options: ZoomInOptions) => zoomIn(options),
|
||||
onError: (err) => {
|
||||
toast.error(`Failed to update zoom settings: ${err.message}`, {
|
||||
id: "zoom",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const query = useQuery({
|
||||
@@ -52,8 +65,25 @@ export const useCameraZoom = (options: zoomConfig) => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (query.isError) toast.error(query.error.message, { id: "hardReboot" });
|
||||
if (query.isError) toast.error(query.error.message, { id: "zoom" });
|
||||
}, [query?.error?.message, query.isError]);
|
||||
|
||||
return { mutation, query };
|
||||
};
|
||||
|
||||
export const useCameraMode = (option: { camera: string }) => {
|
||||
const cameraModeQuery = useQuery({
|
||||
queryKey: ["getCameraMode"],
|
||||
queryFn: () => getCameraMode(option),
|
||||
});
|
||||
|
||||
const cameraModeMutation = useMutation({
|
||||
mutationKey: ["updateCameraMode"],
|
||||
mutationFn: updateCameraMode,
|
||||
});
|
||||
|
||||
return {
|
||||
cameraModeQuery,
|
||||
cameraModeMutation,
|
||||
};
|
||||
};
|
||||
|
||||
30
src/hooks/useFileUpload.ts
Normal file
30
src/hooks/useFileUpload.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
import { toast } from "sonner";
|
||||
|
||||
const camBase = import.meta.env.MODE !== "development" ? CAM_BASE : CAM_BASE;
|
||||
console.log(camBase);
|
||||
|
||||
const uploadFile = async (file: File) => {
|
||||
const form = new FormData();
|
||||
form.append("upload", file, file.name);
|
||||
const response = await fetch(`${camBase}/upload/file-upload/3`, {
|
||||
method: "POST",
|
||||
body: form,
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Cannot reach upload file endpoint");
|
||||
}
|
||||
return response.text();
|
||||
};
|
||||
|
||||
export const useFileUpload = () => {
|
||||
const mutation = useMutation({
|
||||
mutationFn: (file: File) => uploadFile(file),
|
||||
mutationKey: ["uploadFile"],
|
||||
onError: (err) => toast.error(err ? err.message : ""),
|
||||
onSuccess: async (msg) => toast.success(msg),
|
||||
});
|
||||
|
||||
return { mutation };
|
||||
};
|
||||
46
src/hooks/useFormValidate.ts
Normal file
46
src/hooks/useFormValidate.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
import type { InitialValuesForm } from "../types/types";
|
||||
|
||||
const sendToValidate = async (data: InitialValuesForm) => {
|
||||
const updateConfigPayload = {
|
||||
id: `Dispatcher-${data.format.toLowerCase()}`,
|
||||
fields: [
|
||||
{
|
||||
property: "propBackofficeURL",
|
||||
value: data.backOfficeURL,
|
||||
},
|
||||
{
|
||||
property: "propConnectTimeoutSeconds",
|
||||
value: data.connectTimeoutSeconds,
|
||||
},
|
||||
{
|
||||
property: "propPassword",
|
||||
value: data.password,
|
||||
},
|
||||
{
|
||||
property: "propReadTimeoutSeconds",
|
||||
value: data.readTimeoutSeconds,
|
||||
},
|
||||
{
|
||||
property: "propUsername",
|
||||
value: data.username,
|
||||
},
|
||||
],
|
||||
};
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config-isvalid`, {
|
||||
method: "post",
|
||||
body: JSON.stringify(updateConfigPayload),
|
||||
});
|
||||
if (!response.ok) throw new Error("Cannot send to validate");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useFormVaidate = () => {
|
||||
const validateMutation = useMutation({
|
||||
mutationKey: ["sendToValidate"],
|
||||
mutationFn: sendToValidate,
|
||||
});
|
||||
|
||||
return { validateMutation };
|
||||
};
|
||||
153
src/hooks/useGetOverviewSnapshot copy.ts
Normal file
153
src/hooks/useGetOverviewSnapshot copy.ts
Normal file
@@ -0,0 +1,153 @@
|
||||
import { useRef, useCallback, useEffect } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const apiUrl = CAM_BASE;
|
||||
|
||||
async function fetchSnapshot(cameraSide: string): Promise<Blob> {
|
||||
const response = await fetch(`${apiUrl}/${cameraSide}-preview`, {
|
||||
signal: AbortSignal.timeout(300000),
|
||||
cache: "no-store",
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Cannot reach endpoint (${response.status})`);
|
||||
}
|
||||
return response.blob();
|
||||
}
|
||||
|
||||
/** Draw an ImageBitmap to canvas with aspect-fill (like object-fit: cover) */
|
||||
function drawBitmapToCanvas(canvas: HTMLCanvasElement, bitmap: ImageBitmap) {
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) return;
|
||||
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
const cssWidth = canvas.clientWidth;
|
||||
const cssHeight = canvas.clientHeight;
|
||||
|
||||
const width = Math.floor(cssWidth * dpr);
|
||||
const height = Math.floor(cssHeight * dpr);
|
||||
|
||||
if (canvas.width !== width || canvas.height !== height) {
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
}
|
||||
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
const srcW = bitmap.width;
|
||||
const srcH = bitmap.height;
|
||||
const srcAspect = srcW / srcH;
|
||||
const dstAspect = width / height;
|
||||
|
||||
let drawWidth = width;
|
||||
let drawHeight = height;
|
||||
|
||||
// aspect-fit calculation (no cropping)
|
||||
if (srcAspect > dstAspect) {
|
||||
// image is wider → fit to canvas width
|
||||
drawWidth = width;
|
||||
drawHeight = width / srcAspect;
|
||||
} else {
|
||||
// image is taller → fit to canvas height
|
||||
drawHeight = height;
|
||||
drawWidth = height * srcAspect;
|
||||
}
|
||||
|
||||
// center image (adds black borders if aspect ratios differ)
|
||||
const dx = (width - drawWidth) / 50;
|
||||
const dy = (height - drawHeight) / 2;
|
||||
|
||||
ctx.imageSmoothingEnabled = true;
|
||||
ctx.imageSmoothingQuality = "high";
|
||||
ctx.drawImage(bitmap, 0, 0, srcW, srcH, dx, dy, drawWidth, drawHeight);
|
||||
}
|
||||
|
||||
export function useGetOverviewSnapshot(side: string) {
|
||||
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
||||
const latestBitmapRef = useRef<ImageBitmap | null>(null);
|
||||
|
||||
// Redraw helper; always draws the current bitmap if available
|
||||
const draw = useCallback(() => {
|
||||
const canvas = canvasRef.current;
|
||||
const bmp = latestBitmapRef.current;
|
||||
if (!canvas || !bmp) return;
|
||||
drawBitmapToCanvas(canvas, bmp);
|
||||
}, []);
|
||||
|
||||
const {
|
||||
data: snapshotBlob,
|
||||
isError,
|
||||
error,
|
||||
isPending,
|
||||
} = useQuery({
|
||||
queryKey: ["overviewSnapshot", side],
|
||||
queryFn: () => fetchSnapshot(side),
|
||||
// Poll ~4 fps when visible; pause when tab hidden
|
||||
refetchInterval: () => (document.visibilityState === "visible" ? 250 : false),
|
||||
refetchOnWindowFocus: false,
|
||||
// Avoid keeping lots of blobs around in cache
|
||||
gcTime: 0, // v5 name (cacheTime in v4)
|
||||
staleTime: 0,
|
||||
retry: false, // or a small number if you prefer retries
|
||||
});
|
||||
|
||||
// Convert Blob -> ImageBitmap and draw
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
if (!snapshotBlob) return;
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const bitmap = await createImageBitmap(snapshotBlob);
|
||||
if (cancelled) {
|
||||
bitmap.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Dispose previous bitmap to free memory
|
||||
if (latestBitmapRef.current) {
|
||||
latestBitmapRef.current.close();
|
||||
}
|
||||
latestBitmapRef.current = bitmap;
|
||||
|
||||
// Draw now (and again on next resize)
|
||||
draw();
|
||||
} catch {
|
||||
// noop — fetch handler surfaces the main error path
|
||||
}
|
||||
})();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [snapshotBlob, draw]);
|
||||
|
||||
// Redraw on resize & DPR changes
|
||||
useEffect(() => {
|
||||
const onResize = () => draw();
|
||||
const onDPR = () => draw();
|
||||
window.addEventListener("resize", onResize);
|
||||
// Listen for DPR changes (some browsers support this)
|
||||
const mql = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
||||
mql.addEventListener?.("change", onDPR);
|
||||
return () => {
|
||||
window.removeEventListener("resize", onResize);
|
||||
mql.removeEventListener?.("change", onDPR);
|
||||
};
|
||||
}, [draw]);
|
||||
|
||||
// Cleanup on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (latestBitmapRef.current) {
|
||||
latestBitmapRef.current.close();
|
||||
latestBitmapRef.current = null;
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Optional: normalize error type
|
||||
const typedError = error instanceof Error ? error : undefined;
|
||||
|
||||
return { canvasRef, isError, error: typedError, isPending };
|
||||
}
|
||||
@@ -3,34 +3,69 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const apiUrl = CAM_BASE;
|
||||
// const fetch_url = `http://100.82.205.44/Colour-preview`;
|
||||
async function fetchSnapshot(cameraSide: string) {
|
||||
|
||||
async function fetchSnapshot(cameraSide: string): Promise<Blob> {
|
||||
const response = await fetch(`${apiUrl}/${cameraSide}-preview`, {
|
||||
signal: AbortSignal.timeout(500),
|
||||
signal: AbortSignal.timeout(300000),
|
||||
cache: "no-store",
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Cannot reach endpoint");
|
||||
throw new Error(`Cannot reach endpoint (${response.status})`);
|
||||
}
|
||||
return response.blob();
|
||||
}
|
||||
|
||||
function drawBitmapToCanvas(canvas: HTMLCanvasElement, bitmap: ImageBitmap) {
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) return;
|
||||
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
const cssWidth = canvas.clientWidth;
|
||||
const cssHeight = canvas.clientHeight;
|
||||
|
||||
const width = Math.floor(cssWidth * dpr);
|
||||
const height = Math.floor(cssHeight * dpr);
|
||||
|
||||
if (canvas.width !== width || canvas.height !== height) {
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
}
|
||||
|
||||
return await response.blob();
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
const srcW = bitmap.width;
|
||||
const srcH = bitmap.height;
|
||||
const srcAspect = srcW / srcH;
|
||||
const dstAspect = width / height;
|
||||
|
||||
let drawWidth = width;
|
||||
let drawHeight = height;
|
||||
|
||||
if (srcAspect > dstAspect) {
|
||||
drawWidth = width;
|
||||
drawHeight = width / srcAspect;
|
||||
} else {
|
||||
drawHeight = height;
|
||||
drawWidth = height * srcAspect;
|
||||
}
|
||||
|
||||
const dx = (width - drawWidth) / 50;
|
||||
const dy = (height - drawHeight) / 2;
|
||||
|
||||
ctx.imageSmoothingEnabled = true;
|
||||
ctx.imageSmoothingQuality = "high";
|
||||
ctx.drawImage(bitmap, 0, 0, srcW, srcH, dx, dy, drawWidth, drawHeight);
|
||||
}
|
||||
|
||||
export function useGetOverviewSnapshot(side: string) {
|
||||
const latestUrlRef = useRef<string | null>(null);
|
||||
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
||||
const imageRef = useRef<HTMLImageElement | null>(null);
|
||||
const latestBitmapRef = useRef<ImageBitmap | null>(null);
|
||||
|
||||
const drawImage = useCallback(() => {
|
||||
const draw = useCallback(() => {
|
||||
const canvas = canvasRef.current;
|
||||
const ctx = canvas?.getContext("2d");
|
||||
const img = imageRef.current;
|
||||
|
||||
if (!canvas || !ctx || !img) return;
|
||||
|
||||
canvas.width = canvas.clientWidth;
|
||||
canvas.height = canvas.clientHeight;
|
||||
|
||||
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
||||
const bmp = latestBitmapRef.current;
|
||||
if (!canvas || !bmp) return;
|
||||
drawBitmapToCanvas(canvas, bmp);
|
||||
}, []);
|
||||
|
||||
const {
|
||||
@@ -39,43 +74,76 @@ export function useGetOverviewSnapshot(side: string) {
|
||||
error,
|
||||
isPending,
|
||||
} = useQuery({
|
||||
queryKey: ["overviewSnapshot"],
|
||||
queryKey: ["overviewSnapshot", side],
|
||||
queryFn: () => fetchSnapshot(side),
|
||||
|
||||
refetchInterval: () => (document.visibilityState === "visible" ? 250 : false),
|
||||
refetchOnWindowFocus: false,
|
||||
refetchInterval: 250,
|
||||
|
||||
gcTime: 0,
|
||||
staleTime: 0,
|
||||
retry: false,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
if (!snapshotBlob) return;
|
||||
|
||||
const imgUrl = URL.createObjectURL(snapshotBlob);
|
||||
const img = new Image();
|
||||
imageRef.current = img;
|
||||
(async () => {
|
||||
try {
|
||||
const bitmap = await createImageBitmap(snapshotBlob);
|
||||
if (cancelled) {
|
||||
bitmap.close();
|
||||
return;
|
||||
}
|
||||
|
||||
img.onload = () => {
|
||||
drawImage();
|
||||
};
|
||||
img.src = imgUrl;
|
||||
if (latestBitmapRef.current) {
|
||||
latestBitmapRef.current.close();
|
||||
}
|
||||
latestBitmapRef.current = bitmap;
|
||||
|
||||
if (latestUrlRef.current) {
|
||||
URL.revokeObjectURL(latestUrlRef.current);
|
||||
}
|
||||
latestUrlRef.current = imgUrl;
|
||||
draw();
|
||||
} catch {
|
||||
// noop — fetch handler surfaces the main error path
|
||||
}
|
||||
})();
|
||||
|
||||
return () => {
|
||||
if (latestUrlRef.current) {
|
||||
URL.revokeObjectURL(latestUrlRef.current);
|
||||
latestUrlRef.current = null;
|
||||
}
|
||||
cancelled = true;
|
||||
};
|
||||
}, [snapshotBlob, drawImage]);
|
||||
}, [snapshotBlob, draw]);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("resize", drawImage);
|
||||
return () => {
|
||||
window.removeEventListener("resize", drawImage);
|
||||
};
|
||||
}, [drawImage]);
|
||||
const onResize = () => draw();
|
||||
const onDPR = () => draw();
|
||||
window.addEventListener("resize", onResize);
|
||||
|
||||
return { canvasRef, isError, error, isPending };
|
||||
const mql = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
||||
mql.addEventListener?.("change", onDPR);
|
||||
return () => {
|
||||
window.removeEventListener("resize", onResize);
|
||||
mql.removeEventListener?.("change", onDPR);
|
||||
};
|
||||
}, [draw]);
|
||||
|
||||
useEffect(() => {
|
||||
const el = canvasRef.current?.parentElement;
|
||||
if (!el) return;
|
||||
const ro = new ResizeObserver(() => draw());
|
||||
ro.observe(el);
|
||||
return () => ro.disconnect();
|
||||
}, [draw]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (latestBitmapRef.current) {
|
||||
latestBitmapRef.current.close();
|
||||
latestBitmapRef.current = null;
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const typedError = error instanceof Error ? error : undefined;
|
||||
|
||||
return { canvasRef, isError, error: typedError, isPending };
|
||||
}
|
||||
|
||||
22
src/hooks/useGetUploadedFiles.ts
Normal file
22
src/hooks/useGetUploadedFiles.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getOrCacheBlob } from "../utils/cacheSound";
|
||||
|
||||
type UseFileUploadProps = {
|
||||
queryKey?: string[];
|
||||
};
|
||||
|
||||
const getUploadFiles = async ({ queryKey }: { queryKey: string[] }) => {
|
||||
const [, fileName] = queryKey;
|
||||
const url = fileName;
|
||||
return getOrCacheBlob(url);
|
||||
};
|
||||
|
||||
export const useGetUploadedFiles = ({ queryKey }: UseFileUploadProps) => {
|
||||
const query = useQuery({
|
||||
queryKey: ["getUploadFiles", ...(queryKey ?? [])],
|
||||
queryFn: () => getUploadFiles({ queryKey: ["getUploadFiles", ...(queryKey ?? [])] }),
|
||||
enabled: !!queryKey,
|
||||
});
|
||||
|
||||
return { query: queryKey ? query : undefined };
|
||||
};
|
||||
17
src/hooks/useGetVersions.ts
Normal file
17
src/hooks/useGetVersions.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const fetchVersions = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/api/versions`);
|
||||
if (!response.ok) throw new Error("Cannot get Versions");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useGetVersions = () => {
|
||||
const versionsQuery = useQuery({
|
||||
queryKey: ["getversions"],
|
||||
queryFn: fetchVersions,
|
||||
});
|
||||
|
||||
return { versionsQuery };
|
||||
};
|
||||
28
src/hooks/useHotListData.ts
Normal file
28
src/hooks/useHotListData.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const fetchHotlists = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/Hotlist-csv-metadata`);
|
||||
if (!response.ok) throw new Error("Cannot reach hotlist endpoint");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const deleteHotlist = async (filename: string) => {
|
||||
const response = await fetch(`${CAM_BASE}/Hotlist-csv-delete?filename=${filename}`);
|
||||
if (!response.ok) throw new Error(`Cannot delte hotlist: ${filename}`);
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useHotlistData = () => {
|
||||
const query = useQuery({
|
||||
queryKey: ["fetchHotlists"],
|
||||
queryFn: fetchHotlists,
|
||||
});
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationKey: ["deleteHotlist"],
|
||||
mutationFn: (filename: string) => deleteHotlist(filename),
|
||||
});
|
||||
|
||||
return { query, mutation };
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import type { NPEDFieldType } from "../types/types";
|
||||
import { useNPEDContext } from "../context/NPEDUserContext";
|
||||
import { useIntegrationsContext } from "../context/IntegrationsContext";
|
||||
import { useEffect } from "react";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
import { toast } from "sonner";
|
||||
@@ -8,7 +8,7 @@ import { toast } from "sonner";
|
||||
async function fetchNPEDDetails() {
|
||||
const fetchUrl = `${CAM_BASE}/api/fetch-config?id=NPED`;
|
||||
const response = await fetch(fetchUrl, {
|
||||
signal: AbortSignal.timeout(500),
|
||||
signal: AbortSignal.timeout(300000),
|
||||
});
|
||||
if (!response.ok) throw new Error("Cannot reach fetch-config endpoint");
|
||||
|
||||
@@ -42,8 +42,7 @@ async function signIn(loginDetails: NPEDFieldType) {
|
||||
}),
|
||||
]);
|
||||
|
||||
if (!frontRes.ok || !rearRes.ok)
|
||||
throw new Error("Cannot reach NPED endpoint");
|
||||
if (!frontRes.ok || !rearRes.ok) throw new Error("Cannot reach NPED endpoint");
|
||||
|
||||
return {
|
||||
frontResponse: frontRes.json(),
|
||||
@@ -73,7 +72,7 @@ async function signOut() {
|
||||
}
|
||||
|
||||
export const useNPEDAuth = () => {
|
||||
const { setUser, user } = useNPEDContext();
|
||||
const { dispatch } = useIntegrationsContext();
|
||||
|
||||
const signInMutation = useMutation({
|
||||
mutationKey: ["NPEDSignin"],
|
||||
@@ -84,7 +83,8 @@ export const useNPEDAuth = () => {
|
||||
onSuccess: async (data) => {
|
||||
toast.dismiss();
|
||||
toast.success("Signed in successfully!");
|
||||
setUser(await data.frontResponse);
|
||||
|
||||
dispatch({ type: "LOGIN", payload: await data.frontResponse });
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.dismiss();
|
||||
@@ -101,7 +101,7 @@ export const useNPEDAuth = () => {
|
||||
mutationFn: signOut,
|
||||
onSuccess: () => {
|
||||
toast.success("Signed out successfully");
|
||||
setUser(null);
|
||||
dispatch({ type: "LOGOUT", payload: null });
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(`Sign-out failed: ${error.message}`);
|
||||
@@ -115,11 +115,11 @@ export const useNPEDAuth = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (fetchdataQuery.isSuccess && fetchdataQuery.data) {
|
||||
setUser(fetchdataQuery.data);
|
||||
dispatch({ type: "LOGIN", payload: fetchdataQuery.data });
|
||||
} else {
|
||||
setUser(null);
|
||||
dispatch({ type: "LOGOUT", payload: null });
|
||||
}
|
||||
}, [fetchdataQuery.data, fetchdataQuery.isSuccess, setUser]);
|
||||
}, [dispatch, fetchdataQuery.data, fetchdataQuery.isSuccess]);
|
||||
|
||||
useEffect(() => {
|
||||
if (fetchdataQuery.isError) toast.error(fetchdataQuery.error.message);
|
||||
@@ -134,8 +134,6 @@ export const useNPEDAuth = () => {
|
||||
data: signInMutation.data,
|
||||
fetchdataQueryError: fetchdataQuery.error,
|
||||
fetchdataQueryLoading: fetchdataQuery.isLoading,
|
||||
user,
|
||||
setUser,
|
||||
signOut: signOutMutation.mutate,
|
||||
};
|
||||
};
|
||||
|
||||
48
src/hooks/useSightingAmend.ts
Normal file
48
src/hooks/useSightingAmend.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
import type { InitialValuesForm } from "../types/types";
|
||||
|
||||
const getSightingAmend = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=SightingAmmendA`);
|
||||
if (!response.ok) throw new Error("Cannot reach sighting amend endpoint");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const updateSightingAmend = async (data: InitialValuesForm) => {
|
||||
const updateSightingAmendPayload = {
|
||||
id: "SightingAmmendA",
|
||||
fields: [
|
||||
{
|
||||
property: "propOverviewQuality",
|
||||
value: data.overviewQuality,
|
||||
},
|
||||
{
|
||||
property: "propOverviewImageScaleFactor",
|
||||
value: data.cropSizeFactor,
|
||||
},
|
||||
],
|
||||
};
|
||||
const response = await fetch(`${CAM_BASE}/api/update-config`, {
|
||||
method: "Post",
|
||||
body: JSON.stringify(updateSightingAmendPayload),
|
||||
});
|
||||
if (!response.ok) throw new Error("cannot update camera control");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useSightingAmend = () => {
|
||||
const sightingAmendQuery = useQuery({
|
||||
queryKey: ["getSightingAmend"],
|
||||
queryFn: getSightingAmend,
|
||||
});
|
||||
|
||||
const sightingAmendMutation = useMutation({
|
||||
mutationKey: ["updateSightingAmend"],
|
||||
mutationFn: updateSightingAmend,
|
||||
});
|
||||
|
||||
return {
|
||||
sightingAmendQuery,
|
||||
sightingAmendMutation,
|
||||
};
|
||||
};
|
||||
@@ -1,14 +1,18 @@
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useDebouncedCallback } from "use-debounce";
|
||||
import { Query, useQuery } from "@tanstack/react-query";
|
||||
import type { SightingType } from "../types/types";
|
||||
import { useSoundOnChange } from "react-sounds";
|
||||
import { useSound } from "react-sounds";
|
||||
import { useSoundContext } from "../context/SoundContext";
|
||||
import { getSoundFileURL } from "../utils/utils";
|
||||
import { checkIsHotListHit, getNPEDCategory } from "../utils/utils";
|
||||
import switchSound from "../assets/sounds/ui/switch.mp3";
|
||||
import notification from "../assets/sounds/ui/notification.mp3";
|
||||
import popup from "../assets/sounds/ui/popup_open.mp3";
|
||||
import { useCachedSoundSrc } from "./usecachedSoundSrc";
|
||||
|
||||
async function fetchSighting(url: string | undefined, ref: number): Promise<SightingType> {
|
||||
const res = await fetch(`${url}${ref}`, {
|
||||
signal: AbortSignal.timeout(5000),
|
||||
signal: AbortSignal.timeout(300000),
|
||||
});
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
return res.json();
|
||||
@@ -21,31 +25,19 @@ export function useSightingFeed(url: string | undefined) {
|
||||
const [sessionStarted, setSessionStarted] = useState(false);
|
||||
const [selectedSighting, setSelectedSighting] = useState<SightingType | null>(null);
|
||||
|
||||
const mostRecent = sightings[0] ?? null;
|
||||
const latestRef = mostRecent?.ref ?? null;
|
||||
const { src: soundSrc } = useCachedSoundSrc(state?.sightingSound, state?.soundOptions, switchSound);
|
||||
const { src: soundSrcHotlist } = useCachedSoundSrc(state?.hotlistSound, state?.soundOptions, notification);
|
||||
const { src: soundSrcNped } = useCachedSoundSrc(state?.NPEDsound, state?.soundOptions, popup);
|
||||
|
||||
const { play: hotlistsound } = useSound(soundSrcHotlist, { volume: state.hotlistSoundVolume });
|
||||
const { play: npedSound } = useSound(soundSrcNped, { volume: state.NPEDsoundVolume });
|
||||
const { play: sightingSound } = useSound(soundSrc, { volume: state.sightingVolume });
|
||||
|
||||
const mostRecent = sightings[0] ?? null;
|
||||
|
||||
const first = useRef(true);
|
||||
const lastSoundAt = useRef(0);
|
||||
const COOLDOWN_MS = 1500;
|
||||
const currentRef = useRef<number>(-1);
|
||||
const lastValidTimestamp = useRef<number>(Date.now());
|
||||
|
||||
const trigger = useMemo(() => {
|
||||
if (latestRef == null || !audioArmed) return null;
|
||||
if (first.current) {
|
||||
first.current = false;
|
||||
return Symbol("skip");
|
||||
}
|
||||
const now = Date.now();
|
||||
if (now - lastSoundAt.current < COOLDOWN_MS) return Symbol("skip");
|
||||
lastSoundAt.current = now;
|
||||
return latestRef;
|
||||
}, [audioArmed, latestRef]);
|
||||
|
||||
const soundSrc = useMemo(() => {
|
||||
return getSoundFileURL(state?.sightingSound) ?? switchSound;
|
||||
}, [state.sightingSound]);
|
||||
|
||||
function refetchInterval(query: Query<SightingType, Error, SightingType, (string | undefined)[]>) {
|
||||
if (!query) return;
|
||||
const data = query.state.data as SightingType | undefined;
|
||||
@@ -56,7 +48,7 @@ export function useSightingFeed(url: string | undefined) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
if (now - lastValidTimestamp.current > 60_000) {
|
||||
if (now - lastValidTimestamp.current > 600_000) {
|
||||
currentRef.current = -1;
|
||||
lastValidTimestamp.current = now;
|
||||
}
|
||||
@@ -74,16 +66,42 @@ export function useSightingFeed(url: string | undefined) {
|
||||
staleTime: 0,
|
||||
});
|
||||
|
||||
//use latestref instead of trigger to revert back
|
||||
const playHotlistsound = useDebouncedCallback(() => {
|
||||
hotlistsound();
|
||||
}, 500);
|
||||
|
||||
useSoundOnChange(soundSrc, trigger, {
|
||||
volume: state.sightingVolume,
|
||||
initial: false,
|
||||
});
|
||||
const playNPEDHitSound = useDebouncedCallback(() => {
|
||||
npedSound();
|
||||
}, 500);
|
||||
|
||||
const playSightingHitSound = useDebouncedCallback(() => {
|
||||
sightingSound();
|
||||
}, 500);
|
||||
|
||||
useEffect(() => {
|
||||
const data = query.data;
|
||||
|
||||
if (!data || data.ref === -1) return;
|
||||
const isHotListHit = checkIsHotListHit(data);
|
||||
const cat = getNPEDCategory(data);
|
||||
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
const isNPEDHitD = cat === "D";
|
||||
|
||||
if (
|
||||
(isNPEDHitA && audioArmed) ||
|
||||
(isNPEDHitB && audioArmed) ||
|
||||
(isNPEDHitC && audioArmed) ||
|
||||
(isNPEDHitD && audioArmed)
|
||||
) {
|
||||
playNPEDHitSound();
|
||||
} else if (isHotListHit && audioArmed) {
|
||||
playHotlistsound();
|
||||
} else if (audioArmed) {
|
||||
playSightingHitSound();
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
|
||||
19
src/hooks/useStoreDispatch.ts
Normal file
19
src/hooks/useStoreDispatch.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const getStoreData = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/Store/diagnostics-json`);
|
||||
if (!response.ok) throw new Error("Cannot get store data");
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useStoreDispatch = () => {
|
||||
const storeQuery = useQuery({
|
||||
queryKey: ["getStoreData"],
|
||||
queryFn: getStoreData,
|
||||
refetchInterval: 1000,
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
return { storeQuery };
|
||||
};
|
||||
@@ -1,11 +1,41 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { sendBlobFileUpload } from "../components/SettingForms/System/Upload";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
handleSystemSave,
|
||||
handleSystemRecall,
|
||||
} from "../components/SettingForms/System/SettingSaveRecall";
|
||||
import { handleSystemSave, handleSystemRecall } from "../components/SettingForms/System/SettingSaveRecall";
|
||||
import { useEffect } from "react";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
import type { DNSSettingsType } from "../types/types";
|
||||
|
||||
const camBase = import.meta.env.MODE !== "development" ? CAM_BASE : "";
|
||||
|
||||
const getDNSSettings = async () => {
|
||||
const response = await fetch(`${camBase}/api/fetch-config?id=GLOBAL--NetworkConfig`);
|
||||
if (!response.ok) throw new Error("Cannot get DNS Settings");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const updateDNSSettings = async (data: DNSSettingsType) => {
|
||||
const dnsSettingsPayload = {
|
||||
id: "GLOBAL--NetworkConfig",
|
||||
fields: [
|
||||
{
|
||||
property: "propNameServerPrimary",
|
||||
value: data?.serverPrimary,
|
||||
},
|
||||
{
|
||||
property: "propNameServerSecondary",
|
||||
value: data?.serverSecondary,
|
||||
},
|
||||
],
|
||||
};
|
||||
const response = await fetch(`${camBase}/api/update-config`, {
|
||||
method: "post",
|
||||
body: JSON.stringify(dnsSettingsPayload),
|
||||
});
|
||||
if (!response.ok) throw new Error("cannot send to DNS endpoint");
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useSystemConfig = () => {
|
||||
const uploadSettingsMutation = useMutation({
|
||||
@@ -51,3 +81,20 @@ export const useSystemConfig = () => {
|
||||
saveSystemSettingsLoading: saveSystemSettings.isPending,
|
||||
};
|
||||
};
|
||||
|
||||
export const useDNSSettings = () => {
|
||||
const dnsQuery = useQuery({
|
||||
queryKey: ["getDNSSettings"],
|
||||
queryFn: getDNSSettings,
|
||||
});
|
||||
|
||||
const dnsMutation = useMutation({
|
||||
mutationKey: ["updateDNSSettings"],
|
||||
mutationFn: updateDNSSettings,
|
||||
});
|
||||
|
||||
return {
|
||||
dnsQuery,
|
||||
dnsMutation,
|
||||
};
|
||||
};
|
||||
|
||||
20
src/hooks/useSystemStatus.ts
Normal file
20
src/hooks/useSystemStatus.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { CAM_BASE } from "../utils/config";
|
||||
|
||||
const fetchSystemStatus = async () => {
|
||||
const response = await fetch(`${CAM_BASE}/sysstatus?func=getstatus`);
|
||||
if (!response.ok) {
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const useSystemStatus = () => {
|
||||
const systemStatusQuery = useQuery({
|
||||
queryKey: ["get systemStatus"],
|
||||
queryFn: fetchSystemStatus,
|
||||
refetchInterval: 60000,
|
||||
});
|
||||
|
||||
return { systemStatusQuery };
|
||||
};
|
||||
56
src/hooks/usecachedSoundSrc.ts
Normal file
56
src/hooks/usecachedSoundSrc.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useFileUpload } from "./useFileUpload";
|
||||
import { getSoundFileURL } from "../utils/utils";
|
||||
import type { SoundUploadValue } from "../types/types";
|
||||
import { resolveSoundSource } from "../utils/soundResolver";
|
||||
|
||||
export function useCachedSoundSrc(
|
||||
selected: string | undefined,
|
||||
soundOptions: SoundUploadValue[] | undefined,
|
||||
fallbackUrl: string
|
||||
) {
|
||||
const isUploaded = !!selected && (selected.endsWith(".mp3") || selected.endsWith(".wav"));
|
||||
|
||||
const resolved = resolveSoundSource(selected, soundOptions);
|
||||
|
||||
const { query } = useFileUpload({
|
||||
queryKey: resolved?.type === "uploaded" ? [resolved?.url] : undefined,
|
||||
});
|
||||
|
||||
const [objectUrl, setObjectUrl] = useState<string>();
|
||||
const objRef = useRef<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const blob = query?.data;
|
||||
|
||||
if (blob instanceof Blob) {
|
||||
if (objRef.current) URL.revokeObjectURL(objRef.current);
|
||||
const url = URL.createObjectURL(blob);
|
||||
objRef.current = url;
|
||||
setObjectUrl(url);
|
||||
} else {
|
||||
if (objRef.current) URL.revokeObjectURL(objRef.current);
|
||||
objRef.current = null;
|
||||
setObjectUrl(undefined);
|
||||
}
|
||||
}, [query?.data]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (objRef.current) URL.revokeObjectURL(objRef.current);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const src = useMemo(() => {
|
||||
if (isUploaded && objectUrl) return objectUrl;
|
||||
if (!selected) return fallbackUrl;
|
||||
return getSoundFileURL(selected) ?? fallbackUrl;
|
||||
}, [isUploaded, objectUrl, selected, fallbackUrl]);
|
||||
|
||||
return {
|
||||
src,
|
||||
isUploaded,
|
||||
isLoading: !!query?.isLoading,
|
||||
error: (query?.error as Error) || undefined,
|
||||
};
|
||||
}
|
||||
@@ -31,3 +31,39 @@ body {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.arrow-outline path {
|
||||
stroke: black;
|
||||
stroke-width: 20px;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
/* Modal animations */
|
||||
.ReactModal__Overlay {
|
||||
opacity: 0;
|
||||
transition: opacity 200ms ease-in-out;
|
||||
}
|
||||
|
||||
.ReactModal__Overlay--after-open {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.ReactModal__Overlay--before-close {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.ReactModal__Content {
|
||||
transform: scale(0.9) translateY(-20px);
|
||||
opacity: 0;
|
||||
transition: all 200ms ease-in-out;
|
||||
}
|
||||
|
||||
.ReactModal__Content--after-open {
|
||||
transform: scale(1) translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.ReactModal__Content--before-close {
|
||||
transform: scale(0.9) translateY(-20px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import OverviewVideoContainer from "../components/FrontCameraSettings/OverviewVi
|
||||
import { Toaster } from "sonner";
|
||||
|
||||
const FrontCamera = () => {
|
||||
const [zoomLevel, setZoomLevel] = useState<number>(1);
|
||||
const [zoomLevel, setZoomLevel] = useState<number | undefined>(1);
|
||||
return (
|
||||
<div className="mx-auto flex flex-col lg:flex-row gap-2 px-1 sm:px-2 lg:px-0 w-full min-h-screen">
|
||||
<OverviewVideoContainer
|
||||
|
||||
@@ -4,9 +4,9 @@ import { Toaster } from "sonner";
|
||||
import { useState } from "react";
|
||||
|
||||
const RearCamera = () => {
|
||||
const [zoomLevel, setZoomLevel] = useState<number>(1);
|
||||
const [zoomLevel, setZoomLevel] = useState<number | undefined>(1);
|
||||
return (
|
||||
<div className="mx-auto flex flex-col lg:flex-row gap-2 px-1 sm:px-2 lg:px-0 w-full min-h-screen">
|
||||
<div className="mx-auto flex flex-col-reverse lg:flex-row gap-2 px-1 sm:px-2 lg:px-0 w-full min-h-screen">
|
||||
<CameraSettings
|
||||
title="Camera B Settings"
|
||||
side={"CameraB"}
|
||||
|
||||
@@ -10,6 +10,8 @@ import { Toaster } from "sonner";
|
||||
import { useNPEDAuth } from "../hooks/useNPEDAuth";
|
||||
import SoundSettingsCard from "../components/SettingForms/Sound/SoundSettingsCard";
|
||||
import SoundUploadCard from "../components/SettingForms/Sound/SoundUploadCard";
|
||||
import NPEDCategoryPopup from "../components/PopupSettings/NPEDCategoryPopup";
|
||||
import HotlistList from "../components/HotlistList/HotlistList";
|
||||
|
||||
const SystemSettings = () => {
|
||||
useNPEDAuth();
|
||||
@@ -21,7 +23,7 @@ const SystemSettings = () => {
|
||||
<Tab>System</Tab>
|
||||
<Tab>Output</Tab>
|
||||
<Tab>Integrations</Tab>
|
||||
<Tab>WiFi and Modem</Tab>
|
||||
<Tab>WiFi & Modem</Tab>
|
||||
<Tab>Sound</Tab>
|
||||
</TabList>
|
||||
<TabPanel>
|
||||
@@ -38,6 +40,8 @@ const SystemSettings = () => {
|
||||
<div className="mx-auto grid grid-cols-1 sm:grid-cols-1 lg:grid-cols-2 gap-2 px-2 sm:px-4 lg:px-0 w-full">
|
||||
<NPEDCard />
|
||||
<NPEDHotlistCard />
|
||||
<NPEDCategoryPopup />
|
||||
<HotlistList />
|
||||
</div>
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
|
||||
@@ -41,6 +41,7 @@ export type CameraSettingValues = {
|
||||
userName: string;
|
||||
password: string;
|
||||
id: number | string;
|
||||
mode: string;
|
||||
};
|
||||
|
||||
export type CameraSettingErrorValues = Partial<Record<keyof CameraSettingValues, string>>;
|
||||
@@ -48,15 +49,18 @@ export type CameraSettingErrorValues = Partial<Record<keyof CameraSettingValues,
|
||||
export type BearerTypeFieldType = {
|
||||
format: string;
|
||||
enabled: boolean;
|
||||
verbose: boolean;
|
||||
verbose?: boolean;
|
||||
};
|
||||
|
||||
export type InitialValuesForm = {
|
||||
format: string;
|
||||
backOfficeURL: string;
|
||||
username: string;
|
||||
password: string;
|
||||
connectTimeoutSeconds: number;
|
||||
readTimeoutSeconds: number;
|
||||
overviewQuality?: string;
|
||||
cropSizeFactor?: string;
|
||||
};
|
||||
|
||||
export type InitialValuesFormErrors = {
|
||||
@@ -67,6 +71,20 @@ export type InitialValuesFormErrors = {
|
||||
readTimeoutSeconds?: string;
|
||||
};
|
||||
|
||||
export type OptionalBOF2Constants = {
|
||||
FFID?: string;
|
||||
SCID?: string;
|
||||
timestampSource?: string;
|
||||
GPSFormat?: string;
|
||||
};
|
||||
|
||||
export type OptionalBOF2LaneIDs = {
|
||||
laneId?: string;
|
||||
LID1?: string;
|
||||
LID2?: string;
|
||||
LID3?: string;
|
||||
};
|
||||
|
||||
export type NPEDFieldType = {
|
||||
frontId: string;
|
||||
username: string | undefined;
|
||||
@@ -149,6 +167,13 @@ export type SystemValues = {
|
||||
sntpInterval: number;
|
||||
timeZone: string;
|
||||
softwareUpdate?: File | null;
|
||||
serverPrimary?: string;
|
||||
serverSecondary?: string;
|
||||
};
|
||||
|
||||
export type DNSSettingsType = {
|
||||
serverPrimary?: string;
|
||||
serverSecondary?: string;
|
||||
};
|
||||
|
||||
export type SystemValuesErrors = {
|
||||
@@ -257,7 +282,7 @@ export type CameraConfig = {
|
||||
export type CameraBlackBoardOptions = {
|
||||
operation?: string;
|
||||
path?: string;
|
||||
value?: object | string | number | (string | number)[];
|
||||
value?: object | string | number | (string | number)[] | null;
|
||||
};
|
||||
|
||||
export type CameraBlackboardResponse = {
|
||||
@@ -285,21 +310,28 @@ export type FormValues = {
|
||||
sightingSound: SoundValue;
|
||||
NPEDsound: SoundValue;
|
||||
hotlists: Hotlist[];
|
||||
hotlistSound: SoundValue;
|
||||
soundOptions?: SoundUploadValue[];
|
||||
};
|
||||
|
||||
export type SoundUploadValue = {
|
||||
name: string;
|
||||
soundFile: File | null;
|
||||
soundFileName?: string;
|
||||
soundFile?: File | null;
|
||||
soundUrl?: string;
|
||||
uploadedAt?: number;
|
||||
};
|
||||
|
||||
export type SoundState = {
|
||||
sightingSound: SoundValue;
|
||||
NPEDsound: SoundValue;
|
||||
hotlists: Hotlist[];
|
||||
hotlistSound: SoundValue;
|
||||
soundOptions?: SoundUploadValue[];
|
||||
sightingVolume: number;
|
||||
NPEDsoundVolume: number;
|
||||
hotlistSoundVolume: number;
|
||||
uploadedSound?: Blob | null;
|
||||
};
|
||||
|
||||
type UpdateAction = {
|
||||
@@ -310,7 +342,9 @@ type UpdateAction = {
|
||||
hotlists: Hotlist[];
|
||||
sightingVolume: number;
|
||||
NPEDsoundVolume: number;
|
||||
hotlistSoundVolume?: number;
|
||||
hotlistSoundVolume: number;
|
||||
hotlistSound: SoundValue;
|
||||
soundOptions?: SoundUploadValue[];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -324,11 +358,16 @@ type VolumeAction = {
|
||||
payload: number;
|
||||
};
|
||||
|
||||
export type SoundAction = UpdateAction | AddAction | VolumeAction;
|
||||
type UploadedState = {
|
||||
type: "UPLOADEDSOUND";
|
||||
payload: Blob | undefined;
|
||||
};
|
||||
|
||||
export type SoundAction = UpdateAction | AddAction | VolumeAction | UploadedState;
|
||||
export type WifiSettingValues = {
|
||||
ssid: string;
|
||||
password: string;
|
||||
encryption: string;
|
||||
encryption?: string;
|
||||
};
|
||||
export type ModemConfigPayload = {
|
||||
property: string;
|
||||
@@ -352,6 +391,7 @@ export type ModemConfig = {
|
||||
export type ZoomInOptions = {
|
||||
camera: string;
|
||||
multiplier: number;
|
||||
multiplierText?: string;
|
||||
};
|
||||
|
||||
export type zoomConfig = {
|
||||
@@ -363,4 +403,65 @@ export type ModemSettingsType = {
|
||||
username: string;
|
||||
password: string;
|
||||
authenticationType: string;
|
||||
serverPrimary: string;
|
||||
serverSecondary: string;
|
||||
};
|
||||
|
||||
export type HitKind = "NPED" | "HOTLIST";
|
||||
|
||||
export type QueuedHit = {
|
||||
id: number | string;
|
||||
sighting: SightingType;
|
||||
kind: HitKind;
|
||||
};
|
||||
|
||||
export type DedupedSightings = ReducedSightingType[];
|
||||
|
||||
export type HotlistFile = {
|
||||
fileSizeBytes: number;
|
||||
filename: string;
|
||||
rowCount: number;
|
||||
};
|
||||
|
||||
export type NPEDSTATE = {
|
||||
sessionStarted: boolean;
|
||||
sessionList: ReducedSightingType[];
|
||||
sessionPaused: boolean;
|
||||
savedSightings: DedupedSightings;
|
||||
npedUser: NPEDUser;
|
||||
iscatEnabled: CategoryPopups;
|
||||
hotlistFiles: HotlistFile[];
|
||||
};
|
||||
|
||||
export type NPEDACTION = {
|
||||
type: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
payload: any;
|
||||
};
|
||||
|
||||
export type CategoryPopups = {
|
||||
catA: boolean;
|
||||
catB: boolean;
|
||||
catC: boolean;
|
||||
catD: boolean;
|
||||
};
|
||||
|
||||
export type versionInfo = {
|
||||
version: string;
|
||||
revision: string;
|
||||
buildtime: string;
|
||||
appname: string;
|
||||
MAC: string;
|
||||
timeStamp: number;
|
||||
UUID: string;
|
||||
proquint: string;
|
||||
"Serial No.": string;
|
||||
"Model No.": string;
|
||||
};
|
||||
|
||||
export type InfoBarData = {
|
||||
"system-clock-utc": string;
|
||||
"system-clock-local": string;
|
||||
"memory-cpu-status": string;
|
||||
"thread-count": string;
|
||||
};
|
||||
|
||||
16
src/utils/cacheSound.ts
Normal file
16
src/utils/cacheSound.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export async function getOrCacheBlob(url: string) {
|
||||
const cache = await caches.open("app-sounds-v1");
|
||||
const hit = await cache.match(url);
|
||||
if (hit) return await hit.blob();
|
||||
|
||||
const res = await fetch(url, { cache: "no-store" });
|
||||
if (!res.ok) throw new Error(`Fetch failed: ${res.status}`);
|
||||
|
||||
await cache.put(url, res.clone());
|
||||
return await res.blob();
|
||||
}
|
||||
|
||||
export async function evictFromCache(url: string) {
|
||||
const cache = await caches.open("app-sounds-v1");
|
||||
await cache.delete(url);
|
||||
}
|
||||
24
src/utils/soundResolver.ts
Normal file
24
src/utils/soundResolver.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { getSoundFileURL } from "./utils";
|
||||
import { CAM_BASE } from "./config";
|
||||
import type { SoundUploadValue } from "../types/types";
|
||||
|
||||
export function resolveSoundSource(
|
||||
selected: string | undefined,
|
||||
soundOptions: SoundUploadValue[] | undefined
|
||||
): { type: "uploaded"; url: string } | { type: "builtin"; url: string } | undefined {
|
||||
if (!selected) return undefined;
|
||||
|
||||
const isFile = selected.endsWith(".mp3") || selected.endsWith(".wav");
|
||||
|
||||
if (isFile) {
|
||||
const match = soundOptions?.find((o) => o.soundFileName === selected);
|
||||
const version = match?.uploadedAt ?? 0;
|
||||
const url = `${CAM_BASE}/Mobile/${encodeURIComponent(selected)}?v=${version}`;
|
||||
return { type: "uploaded", url };
|
||||
}
|
||||
|
||||
const builtin = getSoundFileURL(selected);
|
||||
if (builtin) return { type: "builtin", url: builtin };
|
||||
|
||||
return undefined;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import beep from "../assets/sounds/ui/Beep.wav";
|
||||
import warning from "../assets/sounds/ui/Warning.wav";
|
||||
import ding from "../assets/sounds/ui/Ding.wav";
|
||||
import shutter from "../assets/sounds/ui/shutter.mp3";
|
||||
|
||||
import attention from "../assets/sounds/ui/Attention.wav";
|
||||
import type { HotlistMatches, SightingType } from "../types/types";
|
||||
|
||||
export function getSoundFileURL(name: string) {
|
||||
@@ -17,10 +17,15 @@ export function getSoundFileURL(name: string) {
|
||||
warning: warning,
|
||||
ding: ding,
|
||||
shutter: shutter,
|
||||
attention: attention,
|
||||
};
|
||||
return sounds[name] ?? null;
|
||||
}
|
||||
|
||||
export const showSoundURL = (url: URL | string | undefined) => {
|
||||
console.log(url);
|
||||
};
|
||||
|
||||
const randomChars = () => {
|
||||
const uppercaseAsciiStart = 65;
|
||||
const letterIndex = Math.floor(Math.random() * 26);
|
||||
@@ -143,11 +148,52 @@ export const checkIsHotListHit = (sigthing: SightingType | null) => {
|
||||
};
|
||||
|
||||
export function getHotlistName(obj: HotlistMatches | undefined) {
|
||||
if (!obj || Object.values(obj).includes(false)) return;
|
||||
if (!obj) return;
|
||||
|
||||
const keys = Object.keys(obj);
|
||||
return keys;
|
||||
const hotlistNames = Object.entries(obj)
|
||||
.filter(([, value]) => value === true)
|
||||
.map(([key]) => key);
|
||||
return hotlistNames;
|
||||
}
|
||||
|
||||
export const getNPEDCategory = (r?: SightingType | null) =>
|
||||
r?.metadata?.npedJSON?.["NPED CATEGORY"] as "A" | "B" | "C" | undefined;
|
||||
r?.metadata?.npedJSON?.["NPED CATEGORY"] as "A" | "B" | "C" | "D" | undefined;
|
||||
|
||||
export const getNPEDReason = (r?: SightingType | null) => r?.metadata?.npedJSON;
|
||||
|
||||
export const zoomMapping = (zoomLevel: number | undefined) => {
|
||||
switch (zoomLevel) {
|
||||
case 1:
|
||||
return "Near";
|
||||
case 2:
|
||||
return "Mid";
|
||||
case 4:
|
||||
return "Far";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
export const reverseZoomMapping = (magnification: string) => {
|
||||
switch (magnification) {
|
||||
case "near":
|
||||
return 1;
|
||||
case "mid":
|
||||
return 2;
|
||||
case "far":
|
||||
return 4;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
export const ValidateIPaddress = (value: string | undefined) => {
|
||||
if (!value) return;
|
||||
|
||||
const regex =
|
||||
/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
|
||||
|
||||
if (!regex.test(value)) {
|
||||
return "Invalid IP address format";
|
||||
}
|
||||
};
|
||||
|
||||
6
src/utils/ws_config.ts
Normal file
6
src/utils/ws_config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { CAM_BASE } from "./config";
|
||||
|
||||
export const ws_config = {
|
||||
infoBar: `${CAM_BASE.replace("http", "ws")}/websocket-infobar`,
|
||||
heatmap: `${CAM_BASE.replace("http", "ws")}/websocket-SystemConfig`,
|
||||
};
|
||||
5
src/vite-env.d.ts
vendored
5
src/vite-env.d.ts
vendored
@@ -1 +1,6 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare const __APP_NAME__: string;
|
||||
declare const __APP_VERSION__: string;
|
||||
declare const __GIT_COMMIT__: string;
|
||||
declare const __GIT_TIMESTAMP__: string;
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import pkg from "./package.json";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
const gitCommitHash = (() => {
|
||||
try {
|
||||
return execSync("git rev-parse --short HEAD").toString().trim();
|
||||
} catch {
|
||||
return "unknown";
|
||||
}
|
||||
})();
|
||||
|
||||
const gitCommitTimeStamp = (() => {
|
||||
try {
|
||||
return execSync("git log -1 --format=%cd --date=iso").toString().trim();
|
||||
} catch {
|
||||
return "unknown";
|
||||
}
|
||||
})();
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
@@ -15,4 +33,10 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
base: "/Mobile",
|
||||
define: {
|
||||
__APP_NAME__: JSON.stringify(pkg.name),
|
||||
__APP_VERSION__: JSON.stringify(pkg.version),
|
||||
__GIT_COMMIT__: JSON.stringify(gitCommitHash),
|
||||
__GIT_TIMESTAMP__: JSON.stringify(gitCommitTimeStamp),
|
||||
},
|
||||
});
|
||||
|
||||
106
yarn.lock
106
yarn.lock
@@ -140,7 +140,7 @@
|
||||
|
||||
"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.1", "@babel/runtime@^7.18.3":
|
||||
version "7.28.4"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.4.tgz#a70226016fabe25c5783b2f22d3e1c9bc5ca3326"
|
||||
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz"
|
||||
integrity sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==
|
||||
|
||||
"@babel/template@^7.27.2":
|
||||
@@ -174,17 +174,17 @@
|
||||
"@babel/helper-validator-identifier" "^7.27.1"
|
||||
|
||||
"@emnapi/core@^1.4.3":
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@emnapi/core/-/core-1.5.0.tgz#85cd84537ec989cebb2343606a1ee663ce4edaf0"
|
||||
integrity sha512-sbP8GzB1WDzacS8fgNPpHlp6C9VZe+SJP3F90W9rLemaQj2PzIuTEl1qDOYQf58YIpyjViI24y9aPWCjEzY2cg==
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@emnapi/core/-/core-1.7.1.tgz#3a79a02dbc84f45884a1806ebb98e5746bdfaac4"
|
||||
integrity sha512-o1uhUASyo921r2XtHYOHy7gdkGLge8ghBEQHMWmyJFoXlpU58kIrhhN3w26lpQb6dspetweapMn2CSNwQ8I4wg==
|
||||
dependencies:
|
||||
"@emnapi/wasi-threads" "1.1.0"
|
||||
tslib "^2.4.0"
|
||||
|
||||
"@emnapi/runtime@^1.4.3":
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@emnapi/runtime/-/runtime-1.5.0.tgz#9aebfcb9b17195dce3ab53c86787a6b7d058db73"
|
||||
integrity sha512-97/BJ3iXHww3djw6hYIfErCZFee7qCtrneuLa20UXFCOTCfBM2cvQHjWJ2EG0s0MtdNwInarqCTz35i4wWXHsQ==
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@emnapi/runtime/-/runtime-1.7.1.tgz#a73784e23f5d57287369c808197288b52276b791"
|
||||
integrity sha512-PVtJr5CmLwYAU9PZDMITZoR5iAOShYREoR45EyyLrbntV50mdePTgUn4AmOw90Ifcj+x2kRjdzr1HP3RrNiHGA==
|
||||
dependencies:
|
||||
tslib "^2.4.0"
|
||||
|
||||
@@ -810,7 +810,7 @@
|
||||
|
||||
"@types/js-cookie@^2.2.6":
|
||||
version "2.2.7"
|
||||
resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-2.2.7.tgz#226a9e31680835a6188e887f3988e60c04d3f6a3"
|
||||
resolved "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-2.2.7.tgz"
|
||||
integrity sha512-aLkWa0C0vO5b4Sr798E26QgOkss68Un0bLjs7u9qxzPT5CG+8DuNTffWES58YzJs3hrVAOs1wonycqEBqNJubA==
|
||||
|
||||
"@types/json-schema@^7.0.15":
|
||||
@@ -818,6 +818,13 @@
|
||||
resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz"
|
||||
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
|
||||
|
||||
"@types/node@^25.0.1":
|
||||
version "25.0.1"
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-25.0.1.tgz"
|
||||
integrity sha512-czWPzKIAXucn9PtsttxmumiQ9N0ok9FrBwgRWrwmVLlp86BrMExzvXRLFYRJ+Ex3g6yqj+KuaxfX1JTgV2lpfg==
|
||||
dependencies:
|
||||
undici-types "~7.16.0"
|
||||
|
||||
"@types/react-dom@^19.1.7":
|
||||
version "19.1.7"
|
||||
resolved "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.1.7.tgz"
|
||||
@@ -949,7 +956,7 @@
|
||||
|
||||
"@xobotyi/scrollbar-width@^1.9.5":
|
||||
version "1.9.5"
|
||||
resolved "https://registry.yarnpkg.com/@xobotyi/scrollbar-width/-/scrollbar-width-1.9.5.tgz#80224a6919272f405b87913ca13b92929bdf3c4d"
|
||||
resolved "https://registry.npmjs.org/@xobotyi/scrollbar-width/-/scrollbar-width-1.9.5.tgz"
|
||||
integrity sha512-N8tkAACJx2ww8vFMneJmaAgmjAG1tnVBZJRLRcx061tmsLRZHSEZSLuGWnwPtunsSLvSqXQ2wfp7Mgqg1I+2dQ==
|
||||
|
||||
acorn-jsx@^5.3.2:
|
||||
@@ -1046,7 +1053,7 @@ chownr@^3.0.0:
|
||||
|
||||
classnames@^2.2.5:
|
||||
version "2.5.1"
|
||||
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.5.1.tgz#ba774c614be0f016da105c858e7159eae8e7687b"
|
||||
resolved "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz"
|
||||
integrity sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==
|
||||
|
||||
clsx@^2.0.0, clsx@^2.1.1:
|
||||
@@ -1083,7 +1090,7 @@ cookie@^1.0.1:
|
||||
|
||||
copy-to-clipboard@^3.3.1:
|
||||
version "3.3.3"
|
||||
resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz#55ac43a1db8ae639a4bd99511c148cdd1b83a1b0"
|
||||
resolved "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz"
|
||||
integrity sha512-2KV8NhB5JqC3ky0r9PMCAZKbUHSwtEo4CwCs0KXgruG43gX5PMqDEBbVU4OUzw2MuAWUfsuFmWvEKG5QRfSnJA==
|
||||
dependencies:
|
||||
toggle-selection "^1.0.6"
|
||||
@@ -1104,14 +1111,14 @@ cross-spawn@^7.0.6:
|
||||
|
||||
css-in-js-utils@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/css-in-js-utils/-/css-in-js-utils-3.1.0.tgz#640ae6a33646d401fc720c54fc61c42cd76ae2bb"
|
||||
resolved "https://registry.npmjs.org/css-in-js-utils/-/css-in-js-utils-3.1.0.tgz"
|
||||
integrity sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A==
|
||||
dependencies:
|
||||
hyphenate-style-name "^1.0.3"
|
||||
|
||||
css-tree@^1.1.2:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d"
|
||||
resolved "https://registry.npmjs.org/css-tree/-/css-tree-1.1.3.tgz"
|
||||
integrity sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==
|
||||
dependencies:
|
||||
mdn-data "2.0.14"
|
||||
@@ -1159,7 +1166,7 @@ enhanced-resolve@^5.18.1:
|
||||
|
||||
error-stack-parser@^2.0.6:
|
||||
version "2.1.4"
|
||||
resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.1.4.tgz#229cb01cdbfa84440bfa91876285b94680188286"
|
||||
resolved "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz"
|
||||
integrity sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==
|
||||
dependencies:
|
||||
stackframe "^1.3.4"
|
||||
@@ -1341,12 +1348,12 @@ fast-levenshtein@^2.0.6:
|
||||
|
||||
fast-shallow-equal@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fast-shallow-equal/-/fast-shallow-equal-1.0.0.tgz#d4dcaf6472440dcefa6f88b98e3251e27f25628b"
|
||||
resolved "https://registry.npmjs.org/fast-shallow-equal/-/fast-shallow-equal-1.0.0.tgz"
|
||||
integrity sha512-HPtaa38cPgWvaCFmRNhlc6NG7pv6NUHqjPgVAkWGoB9mQMwYB27/K0CvOM5Czy+qpT3e8XJ6Q4aPAnzpNpzNaw==
|
||||
|
||||
fastest-stable-stringify@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/fastest-stable-stringify/-/fastest-stable-stringify-2.0.2.tgz#3757a6774f6ec8de40c4e86ec28ea02417214c76"
|
||||
resolved "https://registry.npmjs.org/fastest-stable-stringify/-/fastest-stable-stringify-2.0.2.tgz"
|
||||
integrity sha512-bijHueCGd0LqqNK9b5oCMHc0MluJAx0cwqASgbWMvkO01lCYgIhacVRLcaDz3QnyYIRNJRDwMb41VuT6pHJ91Q==
|
||||
|
||||
fastq@^1.6.0:
|
||||
@@ -1468,12 +1475,12 @@ hoist-non-react-statics@^3.3.0:
|
||||
|
||||
howler@^2.2.3, howler@^2.2.4:
|
||||
version "2.2.4"
|
||||
resolved "https://registry.yarnpkg.com/howler/-/howler-2.2.4.tgz#bd3df4a4f68a0118a51e4bd84a2bfc2e93e6e5a1"
|
||||
resolved "https://registry.npmjs.org/howler/-/howler-2.2.4.tgz"
|
||||
integrity sha512-iARIBPgcQrwtEr+tALF+rapJ8qSc+Set2GJQl7xT1MQzWaVkFebdJhR3alVlSiUf5U7nAANKuj3aWpwerocD5w==
|
||||
|
||||
hyphenate-style-name@^1.0.3:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.1.0.tgz#1797bf50369588b47b72ca6d5e65374607cf4436"
|
||||
resolved "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.1.0.tgz"
|
||||
integrity sha512-WDC/ui2VVRrz3jOVi+XtjqkDjiVjTtFaAGiW37k6b+ohyQ5wYDOGkvCZa8+H0nx3gyvv0+BST9xuOgIyGQ00gw==
|
||||
|
||||
ignore@^5.2.0:
|
||||
@@ -1501,7 +1508,7 @@ imurmurhash@^0.1.4:
|
||||
|
||||
inline-style-prefixer@^7.0.1:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/inline-style-prefixer/-/inline-style-prefixer-7.0.1.tgz#9310f3cfa2c6f3901d1480f373981c02691781e8"
|
||||
resolved "https://registry.npmjs.org/inline-style-prefixer/-/inline-style-prefixer-7.0.1.tgz"
|
||||
integrity sha512-lhYo5qNTQp3EvSSp3sRvXMbVQTLrvGV6DycRMJ5dm2BLMiJ30wpXKdDdgX+GmJZ5uQMucwRKHamXSst3Sj/Giw==
|
||||
dependencies:
|
||||
css-in-js-utils "^3.1.0"
|
||||
@@ -1535,7 +1542,7 @@ jiti@^2.4.2:
|
||||
|
||||
js-cookie@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
|
||||
resolved "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz"
|
||||
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
|
||||
|
||||
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
|
||||
@@ -1703,7 +1710,7 @@ magic-string@^0.30.17:
|
||||
|
||||
mdn-data@2.0.14:
|
||||
version "2.0.14"
|
||||
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50"
|
||||
resolved "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz"
|
||||
integrity sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==
|
||||
|
||||
merge2@^1.3.0:
|
||||
@@ -1757,7 +1764,7 @@ ms@^2.1.3:
|
||||
|
||||
nano-css@^5.6.2:
|
||||
version "5.6.2"
|
||||
resolved "https://registry.yarnpkg.com/nano-css/-/nano-css-5.6.2.tgz#584884ddd7547278f6d6915b6805069742679a32"
|
||||
resolved "https://registry.npmjs.org/nano-css/-/nano-css-5.6.2.tgz"
|
||||
integrity sha512-+6bHaC8dSDGALM1HJjOHVXpuastdu2xFoZlC77Jh4cg+33Zcgm+Gxd+1xsnpZK14eyHObSp82+ll5y3SX75liw==
|
||||
dependencies:
|
||||
"@jridgewell/sourcemap-codec" "^1.4.15"
|
||||
@@ -1882,7 +1889,7 @@ queue-microtask@^1.2.2:
|
||||
|
||||
rc-slider@^11.1.9:
|
||||
version "11.1.9"
|
||||
resolved "https://registry.yarnpkg.com/rc-slider/-/rc-slider-11.1.9.tgz#d872130fbf4ec51f28543d62e90451091d6f5208"
|
||||
resolved "https://registry.npmjs.org/rc-slider/-/rc-slider-11.1.9.tgz"
|
||||
integrity sha512-h8IknhzSh3FEM9u8ivkskh+Ef4Yo4JRIY2nj7MrH6GQmrwV6mcpJf5/4KgH5JaVI1H3E52yCdpOlVyGZIeph5A==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.10.1"
|
||||
@@ -1891,7 +1898,7 @@ rc-slider@^11.1.9:
|
||||
|
||||
rc-util@^5.36.0:
|
||||
version "5.44.4"
|
||||
resolved "https://registry.yarnpkg.com/rc-util/-/rc-util-5.44.4.tgz#89ee9037683cca01cd60f1a6bbda761457dd6ba5"
|
||||
resolved "https://registry.npmjs.org/rc-util/-/rc-util-5.44.4.tgz"
|
||||
integrity sha512-resueRJzmHG9Q6rI/DfK6Kdv9/Lfls05vzMs1Sk3M2P+3cJa+MakaZyWY8IPfehVuhPJFKrIY1IK4GqbiaiY5w==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.18.3"
|
||||
@@ -1916,7 +1923,7 @@ react-is@^16.13.1, react-is@^16.7.0:
|
||||
|
||||
react-is@^18.2.0:
|
||||
version "18.3.1"
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e"
|
||||
resolved "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz"
|
||||
integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==
|
||||
|
||||
react-lifecycles-compat@^3.0.0:
|
||||
@@ -1949,7 +1956,7 @@ react-router@^7.8.0:
|
||||
|
||||
react-sounds@^1.0.25:
|
||||
version "1.0.25"
|
||||
resolved "https://registry.yarnpkg.com/react-sounds/-/react-sounds-1.0.25.tgz#cc7b176d05c7b8ae8e476749246160c76d325a60"
|
||||
resolved "https://registry.npmjs.org/react-sounds/-/react-sounds-1.0.25.tgz"
|
||||
integrity sha512-szyOayVjaTomED1MSQdcNw5gBxHffClR982sl3yxeUi3hmmfJZf0Q1+hneab7z8x4khM64bvlrF4VQltzyEjUg==
|
||||
dependencies:
|
||||
howler "^2.2.3"
|
||||
@@ -1969,12 +1976,17 @@ react-tabs@^6.1.0:
|
||||
|
||||
react-universal-interface@^0.6.2:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/react-universal-interface/-/react-universal-interface-0.6.2.tgz#5e8d438a01729a4dbbcbeeceb0b86be146fe2b3b"
|
||||
resolved "https://registry.npmjs.org/react-universal-interface/-/react-universal-interface-0.6.2.tgz"
|
||||
integrity sha512-dg8yXdcQmvgR13RIlZbTRQOoUrDciFVoSBZILwjE2LFISxZZ8loVJKAkuzswl5js8BHda79bIb2b84ehU8IjXw==
|
||||
|
||||
react-use-websocket@^4.13.0:
|
||||
version "4.13.0"
|
||||
resolved "https://registry.yarnpkg.com/react-use-websocket/-/react-use-websocket-4.13.0.tgz#9db1dbac6dc8ba2fdc02a5bba06205fbf6406736"
|
||||
integrity sha512-anMuVoV//g2N76Wxqvqjjo1X48r9Np3y1/gMl7arX84tAPXdy5R7sB5lO5hvCzQRYjqXwV8XMAiEBOUbyrZFrw==
|
||||
|
||||
react-use@^17.6.0:
|
||||
version "17.6.0"
|
||||
resolved "https://registry.yarnpkg.com/react-use/-/react-use-17.6.0.tgz#2101a3a79dc965a25866b21f5d6de4b128488a14"
|
||||
resolved "https://registry.npmjs.org/react-use/-/react-use-17.6.0.tgz"
|
||||
integrity sha512-OmedEScUMKFfzn1Ir8dBxiLLSOzhKe/dPZwVxcujweSj45aNM7BEGPb9BEVIgVEqEXx6f3/TsXzwIktNgUR02g==
|
||||
dependencies:
|
||||
"@types/js-cookie" "^2.2.6"
|
||||
@@ -1999,7 +2011,7 @@ react@^19.1.1:
|
||||
|
||||
resize-observer-polyfill@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
|
||||
resolved "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz"
|
||||
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==
|
||||
|
||||
resolve-from@^4.0.0:
|
||||
@@ -2043,7 +2055,7 @@ rollup@^4.43.0:
|
||||
|
||||
rtl-css-js@^1.16.1:
|
||||
version "1.16.1"
|
||||
resolved "https://registry.yarnpkg.com/rtl-css-js/-/rtl-css-js-1.16.1.tgz#4b48b4354b0ff917a30488d95100fbf7219a3e80"
|
||||
resolved "https://registry.npmjs.org/rtl-css-js/-/rtl-css-js-1.16.1.tgz"
|
||||
integrity sha512-lRQgou1mu19e+Ya0LsTvKrVJ5TYUbqCVPAiImX3UfLTenarvPUl1QFdvu5Z3PYmHT9RCcwIfbjRQBntExyj3Zg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.1.2"
|
||||
@@ -2062,7 +2074,7 @@ scheduler@^0.26.0:
|
||||
|
||||
screenfull@^5.1.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/screenfull/-/screenfull-5.2.0.tgz#6533d524d30621fc1283b9692146f3f13a93d1ba"
|
||||
resolved "https://registry.npmjs.org/screenfull/-/screenfull-5.2.0.tgz"
|
||||
integrity sha512-9BakfsO2aUQN2K9Fdbj87RJIEZ82Q9IGim7FqM5OsebfoFC6ZHXgDq/KvniuLTPdeM8wY2o6Dj3WQ7KeQCj3cA==
|
||||
|
||||
semver@^6.3.1:
|
||||
@@ -2082,7 +2094,7 @@ set-cookie-parser@^2.6.0:
|
||||
|
||||
set-harmonic-interval@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/set-harmonic-interval/-/set-harmonic-interval-1.0.1.tgz#e1773705539cdfb80ce1c3d99e7f298bb3995249"
|
||||
resolved "https://registry.npmjs.org/set-harmonic-interval/-/set-harmonic-interval-1.0.1.tgz"
|
||||
integrity sha512-AhICkFV84tBP1aWqPwLZqFvAwqEoVA9kxNMniGEUvzOlm4vLmOFLiTT3UZ6bziJTy4bOVpzWGTfSCbmaayGx8g==
|
||||
|
||||
shebang-command@^2.0.0:
|
||||
@@ -2109,29 +2121,29 @@ source-map-js@^1.2.1:
|
||||
|
||||
source-map@0.5.6:
|
||||
version "0.5.6"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"
|
||||
resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz"
|
||||
integrity sha512-MjZkVp0NHr5+TPihLcadqnlVoGIoWo4IBHptutGh9wI3ttUYvCG26HkSuDi+K6lsZ25syXJXcctwgyVCt//xqA==
|
||||
|
||||
source-map@^0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||
resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
|
||||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||
|
||||
stack-generator@^2.0.5:
|
||||
version "2.0.10"
|
||||
resolved "https://registry.yarnpkg.com/stack-generator/-/stack-generator-2.0.10.tgz#8ae171e985ed62287d4f1ed55a1633b3fb53bb4d"
|
||||
resolved "https://registry.npmjs.org/stack-generator/-/stack-generator-2.0.10.tgz"
|
||||
integrity sha512-mwnua/hkqM6pF4k8SnmZ2zfETsRUpWXREfA/goT8SLCV4iOFa4bzOX2nDipWAZFPTjLvQB82f5yaodMVhK0yJQ==
|
||||
dependencies:
|
||||
stackframe "^1.3.4"
|
||||
|
||||
stackframe@^1.3.4:
|
||||
version "1.3.4"
|
||||
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310"
|
||||
resolved "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz"
|
||||
integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==
|
||||
|
||||
stacktrace-gps@^3.0.4:
|
||||
version "3.1.2"
|
||||
resolved "https://registry.yarnpkg.com/stacktrace-gps/-/stacktrace-gps-3.1.2.tgz#0c40b24a9b119b20da4525c398795338966a2fb0"
|
||||
resolved "https://registry.npmjs.org/stacktrace-gps/-/stacktrace-gps-3.1.2.tgz"
|
||||
integrity sha512-GcUgbO4Jsqqg6RxfyTHFiPxdPqF+3LFmQhm7MgCuYQOYuWyqxo5pwRPz5d/u6/WYJdEnWfK4r+jGbyD8TSggXQ==
|
||||
dependencies:
|
||||
source-map "0.5.6"
|
||||
@@ -2139,7 +2151,7 @@ stacktrace-gps@^3.0.4:
|
||||
|
||||
stacktrace-js@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/stacktrace-js/-/stacktrace-js-2.0.2.tgz#4ca93ea9f494752d55709a081d400fdaebee897b"
|
||||
resolved "https://registry.npmjs.org/stacktrace-js/-/stacktrace-js-2.0.2.tgz"
|
||||
integrity sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg==
|
||||
dependencies:
|
||||
error-stack-parser "^2.0.6"
|
||||
@@ -2153,7 +2165,7 @@ strip-json-comments@^3.1.1:
|
||||
|
||||
stylis@^4.3.0:
|
||||
version "4.3.6"
|
||||
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.3.6.tgz#7c7b97191cb4f195f03ecab7d52f7902ed378320"
|
||||
resolved "https://registry.npmjs.org/stylis/-/stylis-4.3.6.tgz"
|
||||
integrity sha512-yQ3rwFWRfwNUY7H5vpU0wfdkNSnvnJinhF9830Swlaxl03zsOjCfmX0ugac+3LtK0lYSgwL/KXc8oYL3mG4YFQ==
|
||||
|
||||
supports-color@^7.1.0:
|
||||
@@ -2187,7 +2199,7 @@ tar@^7.4.3:
|
||||
|
||||
throttle-debounce@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-3.0.1.tgz#32f94d84dfa894f786c9a1f290e7a645b6a19abb"
|
||||
resolved "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-3.0.1.tgz"
|
||||
integrity sha512-dTEWWNu6JmeVXY0ZYoPuH5cRIwc0MeGbJwah9KUNYSJwommQpCzTySTpEe8Gs1J23aeWEuAobe4Ag7EHVt/LOg==
|
||||
|
||||
tiny-warning@^1.0.2:
|
||||
@@ -2212,7 +2224,7 @@ to-regex-range@^5.0.1:
|
||||
|
||||
toggle-selection@^1.0.6:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"
|
||||
resolved "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz"
|
||||
integrity sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==
|
||||
|
||||
ts-api-utils@^2.1.0:
|
||||
@@ -2222,7 +2234,7 @@ ts-api-utils@^2.1.0:
|
||||
|
||||
ts-easing@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/ts-easing/-/ts-easing-0.2.0.tgz#c8a8a35025105566588d87dbda05dd7fbfa5a4ec"
|
||||
resolved "https://registry.npmjs.org/ts-easing/-/ts-easing-0.2.0.tgz"
|
||||
integrity sha512-Z86EW+fFFh/IFB1fqQ3/+7Zpf9t2ebOAxNI/V6Wo7r5gqiqtxmgTlQ1qbqQcjLKYeSHPTsEmvlJUDg/EuL0uHQ==
|
||||
|
||||
tslib@^2.0.0, tslib@^2.1.0, tslib@^2.4.0, tslib@^2.8.0:
|
||||
@@ -2252,6 +2264,11 @@ typescript@~5.8.3:
|
||||
resolved "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz"
|
||||
integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==
|
||||
|
||||
undici-types@~7.16.0:
|
||||
version "7.16.0"
|
||||
resolved "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz"
|
||||
integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==
|
||||
|
||||
update-browserslist-db@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz"
|
||||
@@ -2267,6 +2284,11 @@ uri-js@^4.2.2:
|
||||
dependencies:
|
||||
punycode "^2.1.0"
|
||||
|
||||
use-debounce@^10.0.6:
|
||||
version "10.0.6"
|
||||
resolved "https://registry.npmjs.org/use-debounce/-/use-debounce-10.0.6.tgz"
|
||||
integrity sha512-C5OtPyhAZgVoteO9heXMTdW7v/IbFI+8bSVKYCJrSmiWWCLsbUxiBSp4t9v0hNBTGY97bT72ydDIDyGSFWfwXg==
|
||||
|
||||
vite@^7.1.0:
|
||||
version "7.1.2"
|
||||
resolved "https://registry.npmjs.org/vite/-/vite-7.1.2.tgz"
|
||||
|
||||
Reference in New Issue
Block a user