25 Commits

Author SHA1 Message Date
d2f030f221 added save and load endpoints 2025-11-17 10:19:44 +00:00
5ce70ffa06 Merge pull request 'develop' (#12) from develop into main
Reviewed-on: #12
2025-11-17 09:08:32 +00:00
b1cd2cef8a Merge branch 'main' into develop 2025-11-17 09:08:19 +00:00
8db9d7ff51 minor tweaks to spelling and wording 2025-11-17 09:07:13 +00:00
0b1f0b72a8 Merge pull request 'feature/mobile-menu' (#11) from feature/mobile-menu into develop
Reviewed-on: #11
2025-11-14 15:41:31 +00:00
0945097abb Merge branch 'develop' into feature/mobile-menu 2025-11-14 15:25:57 +00:00
1b46ecc3d1 Merge pull request '- added nped category options for alert popups' (#10) from bugfix/NPEDconfig into develop
Reviewed-on: #10
2025-11-14 15:10:57 +00:00
dd1cd342c1 - added nped category options for alert popups
- minor fix on modal for 'DISABLED' MCC
2025-11-14 15:01:01 +00:00
0a1ac97c57 - removed console.log 2025-11-14 11:55:01 +00:00
ac53a8fd7f Merge branch 'develop' into feature/mobile-menu 2025-11-12 10:17:49 +00:00
96a880a4df Merge pull request 'develop' (#9) from develop into main
Reviewed-on: #9
2025-11-12 09:50:18 +00:00
3ceca96276 Merge branch 'main' into develop 2025-11-12 09:50:09 +00:00
e7b741af78 Merge pull request 'updated and improved ip address validation' (#8) from bugfix/ipaddress into develop
Reviewed-on: #8
2025-11-12 09:49:03 +00:00
ed271964d8 updated and improved ip address validation 2025-11-12 09:46:59 +00:00
9b996430d0 Merge pull request '- added additional modem settings and ip validation' (#6) from bugfix/modem into develop
Reviewed-on: #6
2025-11-11 16:24:02 +00:00
2ccc26ebdc - added additional modem settings and ip validation 2025-11-11 16:22:30 +00:00
b86830a3c3 updated styling for small mobile screens 2025-11-11 15:44:06 +00:00
3d1cc09a5b Merge pull request '- removed dist and updated readme' (#5) from develop into main
Reviewed-on: #5
2025-11-11 14:27:59 +00:00
f571ab80a2 Merge branch 'main' into develop 2025-11-11 14:27:50 +00:00
b2335d2d4d - removed dist and updated readme 2025-11-11 14:26:52 +00:00
a873da8ef5 Merge pull request 'develop' (#4) from develop into main
Reviewed-on: #4
2025-11-11 13:58:46 +00:00
5014c97b4d updated readme 2025-11-11 13:57:05 +00:00
e374456588 updated readme 2025-11-11 13:52:58 +00:00
c057ce5084 Merge pull request 'develop' (#2) from develop into main
Reviewed-on: #2
2025-11-11 12:52:29 +00:00
be0a047d30 - commiting changes for now will revert back 2025-11-11 12:01:28 +00:00
26 changed files with 416 additions and 87 deletions

View File

@@ -1,77 +1,116 @@
# Mav Mobile Ui # Mav Mobile UI
This is a React-based web application built with Vite (react and typescript). This is a React-based web application built with Vite (react and typescript).
## Getting started ## Getting started
### Prerequisites ### Prerequisites
- Node.js (v18 or higher recommended) - Node.js (v18 or higher recommended)
- Yarn (v1.22+) (https://yarnpkg.com/) - Yarn (v1.22+) (https://yarnpkg.com/)
### Installation ### Installation
```bash ```bash
git clone https://mavportal.com/TobaOjo/Mav-Mobile-UI.git git clone https://mavportal.com/TobaOjo/Mav-Mobile-UI.git
cd Mav-Mobile-UI cd Mav-Mobile-UI
yarn install yarn install
``` ```
### Running Locally ### Running Locally
```bash ```bash
yarn dev yarn dev
``` ```
The app will be available at `http://localhost:5173`. The app will be available at `http://localhost:5173`.
To run on locally on other devices To run on locally on other devices
```bash ```bash
yarn dev --host yarn dev --host
``` ```
The app will be available at the exposed addresses to access e.g. http://192.168.0.123:5173/Mobile
The app will be available at the exposed addresses to access e.g. http://1xx.xxx.x.xxx:<PORT>/Mobile
## Tech Stack ## Tech Stack
- **React** UI library - **React** UI library
- **Vite** Build tool - **Vite** Build tool
- **Yarn** Package manager - **Yarn** Package manager
## Configuration ## Configuration
Create a `.env` file to access the Mav Mobile box in unit 5 for or for any environment-specific settings: Create a `.env` file to access the Mav Mobile box in unit 5 for or for any environment-specific settings:
```env ```env
VITE_AGX_BOX_URL=http://100.118.196.113:8080 VITE_AGX_BOX_URL=http://1xx.xxx.xxx.xxx:<PORT>
``` ```
## 🧪 Development ## Development
### Linting & Formatting ### Linting & Formatting
```bash ```bash
yarn lint yarn lint
yarn format yarn format
``` ```
### Testing ### Testing
(Currently not implemented consider adding Jest or Vitest) (Currently not implemented consider adding Jest or Vitest)
## 🚢 Deployment ## Deployment
To build for production: 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 ```bash
yarn build yarn build
``` ```
Navigate to your Mav-Mobile-UI folder - Navigate to your Mav-Mobile-UI folder
Select the Dist folder - Select the Dist folder
Compress to (ZIP) - Compress to (ZIP)
Log into box on Moba using Session > SSH and putting IP in Remote Host. - Log into box on Moba using Session > SSH and putting IP in Remote Host.
Creds are mav:mav - Creds are mav:mav
Drag and drop dist.zip into file explorer menu on left hand side (has to be named dist.zip exactly). - Drag and drop dist.zip into file explorer menu on left hand side (has to be named dist.zip exactly).
Run command - Run command
```bash ```bash
sudo ./integrate-web-ui.sh sudo ./integrate-web-ui.sh
``` ```
Run Run
```bash ```bash
sudo nano web-static/index.html sudo nano web-static/index.html
``` ```
- add the following between the lines </body> & </html>
```js
<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

View File

@@ -0,0 +1,73 @@
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}>
<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;

View File

@@ -62,7 +62,11 @@ const SessionCard = () => {
path: "sessionStats", path: "sessionStats",
value: dedupedSightings, value: dedupedSightings,
}); });
await mutation.mutateAsync({
operation: "SAVE",
path: "",
value: null,
});
if (result.reason === "OK") toast.success("Session saved"); if (result.reason === "OK") toast.success("Session saved");
}; };

View File

@@ -234,7 +234,7 @@ const ChannelFields = ({ touched, isSubmitting, format }: ChannelFieldsProps) =>
<button <button
type="submit" 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 ? "Saving..." : "Save Changes"} {isSubmitting ? "Saving..." : "Save Changes"}
</button> </button>

View File

@@ -6,7 +6,7 @@ import NPEDIcon from "/NPED.svg";
const NPEDCard = () => { const NPEDCard = () => {
return ( return (
<Card className="p-4"> <Card className="p-4">
<CardHeader title={"NPED Config"} img={NPEDIcon} /> <CardHeader title={"NPED"} img={NPEDIcon} />
<NPEDFields /> <NPEDFields />
</Card> </Card>
); );

View 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;

View File

@@ -13,20 +13,18 @@ const NPEDFields = () => {
const [showPwd, setShowPwd] = useState(false); const [showPwd, setShowPwd] = useState(false);
const { signIn, signOut } = useNPEDAuth(); const { signIn, signOut } = useNPEDAuth();
const initialValues = state.npedUser const username = state.npedUser?.propUsername?.value;
? { const password = state.npedUser?.propPassword?.value;
username: state.npedUser?.propUsername?.value, const clientId = state.npedUser?.propClientID?.value;
password: state.npedUser?.propPassword?.value, const frontId = "NPED";
clientId: state.npedUser?.propClientID?.value, const rearId = "NPED";
frontId: "NPED",
rearId: "NPED", const initialValues = {
} username: username ?? "",
: { password: password ?? "",
username: "", clientId: clientId ?? "",
password: "", frontId: frontId,
clientId: "", rearId: rearId,
frontId: "NPED",
rearId: "NPED",
}; };
const handleSubmit = async (values: NPEDFieldType) => { const handleSubmit = async (values: NPEDFieldType) => {
@@ -100,17 +98,18 @@ const NPEDFields = () => {
className="p-1.5 border border-gray-400 rounded-lg" className="p-1.5 border border-gray-400 rounded-lg"
/> />
</FormGroup> </FormGroup>
{!state.npedUser?.propClientID?.value ? ( {!state.npedUser?.propClientID?.value ? (
<button <button
type="submit" 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"} {isSubmitting ? "Logging in..." : "Login"}
</button> </button>
) : ( ) : (
<button <button
type="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} onClick={handleLogoutClick}
> >
Logout Logout

View File

@@ -47,7 +47,7 @@ const NPEDHotlist = () => {
/> />
<button <button
type="submit" 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} // disabled={errors ? true : false}
> >
Upload Upload

View File

@@ -39,6 +39,11 @@ const SoundSettingsFields = () => {
path: "soundSettings", path: "soundSettings",
value: updatedValues, value: updatedValues,
}); });
await mutation.mutateAsync({
operation: "SAVE",
path: "",
value: null,
});
if (result.reason !== "OK") { if (result.reason !== "OK") {
toast.error("Cannot update sound settings"); toast.error("Cannot update sound settings");
} else { } else {
@@ -139,7 +144,7 @@ const SoundSettingsFields = () => {
</div> </div>
<button <button
type="submit" 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 Save Settings
</button> </button>

View File

@@ -46,7 +46,11 @@ const SoundUpload = () => {
if (result.reason !== "OK") { if (result.reason !== "OK") {
toast.error("Cannot update sound settings"); toast.error("Cannot update sound settings");
} }
await mutation.mutateAsync({
operation: "SAVE",
path: "",
value: null,
});
dispatch({ type: "ADD", payload: values }); dispatch({ type: "ADD", payload: values });
}; };
@@ -96,7 +100,7 @@ const SoundUpload = () => {
{errors.soundFile && <p className="text-red-500 text-sm mt-1">Not an mp3 file</p>} {errors.soundFile && <p className="text-red-500 text-sm mt-1">Not an mp3 file</p>}
<button <button
type="submit" 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} disabled={errors.soundFile ? true : false}
> >
Upload Upload

View File

@@ -5,6 +5,8 @@ import { timezones } from "./timezones";
import SystemFileUpload from "./SystemFileUpload"; import SystemFileUpload from "./SystemFileUpload";
import type { SystemValues, SystemValuesErrors } from "../../../types/types"; import type { SystemValues, SystemValuesErrors } from "../../../types/types";
import { useDNSSettings, useSystemConfig } from "../../../hooks/useSystemConfig"; import { useDNSSettings, useSystemConfig } from "../../../hooks/useSystemConfig";
import { ValidateIPaddress } from "../../../utils/utils";
import { toast } from "sonner";
const SystemConfigFields = () => { const SystemConfigFields = () => {
const { saveSystemSettings, systemSettingsData, saveSystemSettingsLoading } = useSystemConfig(); const { saveSystemSettings, systemSettingsData, saveSystemSettingsLoading } = useSystemConfig();
@@ -35,6 +37,14 @@ const SystemConfigFields = () => {
if (!values.timeZone) errors.timeZone = "Required"; if (!values.timeZone) errors.timeZone = "Required";
if (isNaN(interval) || interval <= 0) errors.sntpInterval = "Cannot be less than 0"; if (isNaN(interval) || interval <= 0) errors.sntpInterval = "Cannot be less than 0";
if (!values.sntpServer) errors.sntpServer = "Required"; 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; return errors;
}; };
@@ -52,7 +62,7 @@ const SystemConfigFields = () => {
onSubmit={handleSubmit} onSubmit={handleSubmit}
validate={validateValues} validate={validateValues}
enableReinitialize enableReinitialize
validateOnChange validateOnChange={false}
validateOnBlur validateOnBlur
> >
{({ values, errors, touched, isSubmitting }) => ( {({ values, errors, touched, isSubmitting }) => (
@@ -157,7 +167,7 @@ const SystemConfigFields = () => {
</FormGroup> </FormGroup>
<button <button
type="submit" 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} disabled={isSubmitting}
> >
{saveSystemSettingsLoading ? "Saving..." : "Save System Settings"} {saveSystemSettingsLoading ? "Saving..." : "Save System Settings"}

View File

@@ -52,7 +52,7 @@ const SystemFileUpload = ({ name, selectedFile }: SystemFileUploadProps) => {
</FormGroup> </FormGroup>
<button <button
type="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} disabled={!selectedFile}
onClick={handleFileUploadClick} onClick={handleFileUploadClick}
> >

View File

@@ -6,7 +6,6 @@ const ModemCard = () => {
return ( return (
<Card className="p-4"> <Card className="p-4">
<CardHeader title={"Modem"} /> <CardHeader title={"Modem"} />
<ModemSettings /> <ModemSettings />
</Card> </Card>
); );

View File

@@ -6,6 +6,8 @@ import { useEffect, useState } from "react";
import ModemToggle from "./ModemToggle"; import ModemToggle from "./ModemToggle";
import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons"; import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { ValidateIPaddress } from "../../../utils/utils";
import { toast, Toaster } from "sonner";
const ModemSettings = () => { const ModemSettings = () => {
const [showSettings, setShowSettings] = useState(false); const [showSettings, setShowSettings] = useState(false);
@@ -16,6 +18,8 @@ const ModemSettings = () => {
const username = modemQuery?.data?.propUsername.value; const username = modemQuery?.data?.propUsername.value;
const password = modemQuery?.data?.propPassword?.value; const password = modemQuery?.data?.propPassword?.value;
const mode = modemQuery?.data?.propMode?.value; const mode = modemQuery?.data?.propMode?.value;
const serverPrimary = modemQuery?.data?.propNameServerPrimary?.value;
const serverSecondary = modemQuery?.data?.propNameServerSecondary?.value;
useEffect(() => { useEffect(() => {
setShowSettings(mode === "AUTO"); setShowSettings(mode === "AUTO");
@@ -26,9 +30,19 @@ const ModemSettings = () => {
username: username ?? "", username: username ?? "",
password: password ?? "", password: password ?? "",
authenticationType: "PAP", authenticationType: "PAP",
serverPrimary: serverPrimary ?? "",
serverSecondary: serverSecondary ?? "",
}; };
const handleSubmit = async (values: ModemSettingsType) => { 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 modemConfig = { const modemConfig = {
id: "ModemAndWifiManager-modem", id: "ModemAndWifiManager-modem",
fields: [ fields: [
@@ -49,9 +63,24 @@ const ModemSettings = () => {
property: "propMode", property: "propMode",
value: showSettings ? "AUTO" : "MANUAL", value: showSettings ? "AUTO" : "MANUAL",
}, },
{
property: "propNameServerPrimary",
value: values.serverPrimary,
},
{
property: "propNameServerSecondary",
value: values.serverSecondary,
},
], ],
}; };
await modemMutation.mutateAsync(modemConfig);
const response = await modemMutation.mutateAsync(modemConfig);
if (!response?.id) {
toast.success("Modem settings updated successfully", {
id: "modemSettings",
});
}
}; };
return ( return (
@@ -107,9 +136,33 @@ const ModemSettings = () => {
/> />
</div> </div>
</FormGroup> </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> <FormGroup>
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3"> <label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
Password Authentication Type
</label> </label>
<Field <Field
name="authenticationType" name="authenticationType"
@@ -125,13 +178,14 @@ const ModemSettings = () => {
)} )}
<button <button
type="submit" 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 || modemMutation.isPending ? "Saving..." : "Save Modem settings"} {isSubmitting || modemMutation.isPending ? "Saving..." : "Save Modem settings"}
</button> </button>
</Form> </Form>
)} )}
</Formik> </Formik>
<Toaster />
</> </>
); );
}; };

View File

@@ -21,10 +21,11 @@ type SightingModalProps = {
const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }: SightingModalProps) => { const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }: SightingModalProps) => {
const { dispatch } = useAlertHitContext(); const { dispatch } = useAlertHitContext();
const { query, mutation } = useCameraBlackboard(); const { query, mutation } = useCameraBlackboard();
const hotlistNames = getHotlistName(sighting?.metadata?.hotlistMatches); const hotlistNames = getHotlistName(sighting?.metadata?.hotlistMatches);
const handleAcknowledgeButton = () => { const handleAcknowledgeButton = async () => {
try { try {
if (!sighting) { if (!sighting) {
toast.error("Cannot add sighting to alert list"); toast.error("Cannot add sighting to alert list");
@@ -32,17 +33,27 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }:
return; return;
} }
if (!query.data.alertHistory) { if (!query.data.alertHistory) {
mutation.mutate({ await mutation.mutateAsync({
operation: "INSERT", operation: "INSERT",
path: "alertHistory", path: "alertHistory",
value: [sighting], value: [sighting],
}); });
await mutation.mutateAsync({
operation: "SAVE",
path: "",
value: null,
});
} else { } else {
mutation.mutate({ await mutation.mutateAsync({
operation: "APPEND", operation: "APPEND",
path: "alertHistory", path: "alertHistory",
value: sighting, value: sighting,
}); });
await mutation.mutateAsync({
operation: "SAVE",
path: "",
value: null,
});
toast.success("Sighting Successfully added to alert list"); toast.success("Sighting Successfully added to alert list");
} }
@@ -160,23 +171,24 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }:
<dd className="font-medium text-2xl">{sighting?.seenCount ?? "-"}</dd> <dd className="font-medium text-2xl">{sighting?.seenCount ?? "-"}</dd>
</div> </div>
{sighting?.make && ( {sighting?.make && sighting.make.trim() && sighting.make.toLowerCase() !== "disabled" && (
<div> <div>
<dt className="text-gray-300">Make</dt> <dt className="text-gray-300">Make</dt>
<dd className="font-medium text-2xl">{sighting?.make ?? "-"}</dd> <dd className="font-medium text-2xl">{sighting.make}</dd>
</div> </div>
)} )}
{sighting?.model ||
(!sighting?.model.trim() && ( {sighting?.model && sighting.model.trim() && sighting.model.toLowerCase() !== "disabled" && (
<div> <div>
<dt className="text-gray-300">Model</dt> <dt className="text-gray-300">Model</dt>
<dd className="font-medium text-2xl">{sighting?.model ?? "-"}</dd> <dd className="font-medium text-2xl">{sighting.model}</dd>
</div> </div>
))} )}
{sighting?.color && (
{sighting?.color && sighting.color.trim() && sighting.color.toLowerCase() !== "disabled" && (
<div className="sm:col-span-2"> <div className="sm:col-span-2">
<dt className="text-gray-300">Colour</dt> <dt className="text-gray-300">Colour</dt>
<dd className="font-medium text-2xl">{sighting?.color ?? "-"}</dd> <dd className="font-medium text-2xl">{sighting.color}</dd>
</div> </div>
)} )}

View File

@@ -68,6 +68,11 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
const hasAutoOpenedRef = useRef(false); const hasAutoOpenedRef = useRef(false);
const npedRef = 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) => { const enqueue = useCallback((sighting: SightingType, kind: HitKind) => {
const id = sighting.vrm ?? sighting.ref; const id = sighting.vrm ?? sighting.ref;
if (processedRefs.current.has(id)) return; if (processedRefs.current.has(id)) return;
@@ -118,7 +123,11 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
if (processedRefs.current.has(id)) continue; if (processedRefs.current.has(id)) continue;
const isHotlistHit = checkIsHotListHit(sighting); const isHotlistHit = checkIsHotListHit(sighting);
const npedcategory = sighting?.metadata?.npedJSON?.["NPED CATEGORY"]; const npedcategory = sighting?.metadata?.npedJSON?.["NPED CATEGORY"];
const isNPED = npedcategory === "A" || npedcategory === "B" || npedcategory === "C"; const isNPED =
(npedcategory === "A" && isCatAEnabled) ||
(npedcategory === "B" && isCatBEnabled) ||
(npedcategory === "C" && isCatCEnabled) ||
(npedcategory === "D" && isCatDEnabled);
if (isNPED || isHotlistHit) { if (isNPED || isHotlistHit) {
enqueue(sighting, isNPED ? "NPED" : "HOTLIST"); // enqueue ONLY enqueue(sighting, isNPED ? "NPED" : "HOTLIST"); // enqueue ONLY
@@ -148,7 +157,8 @@ export default function SightingHistoryWidget({ className, title }: SightingHist
const isNPEDHitA = cat === "A"; const isNPEDHitA = cat === "A";
const isNPEDHitB = cat === "B"; const isNPEDHitB = cat === "B";
const isNPEDHitC = cat === "C"; const isNPEDHitC = cat === "C";
return isNPEDHitA || isNPEDHitB || isNPEDHitC; const isNPEDHitD = cat === "D";
return isNPEDHitA || isNPEDHitB || isNPEDHitC || isNPEDHitD;
}); });
const firstHot = rows?.find((r) => { const firstHot = rows?.find((r) => {
const isHotListHit = checkIsHotListHit(r); const isHotListHit = checkIsHotListHit(r);

View File

@@ -1,15 +1,26 @@
import { Link } from "react-router"; import { Link } from "react-router";
import Logo from "/MAV.svg"; import Logo from "/MAV.svg";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faGear, faHome, faListCheck, faMaximize, faMinimize, faRotate } from "@fortawesome/free-solid-svg-icons"; import {
faBars,
faGear,
faHome,
faListCheck,
faMaximize,
faMinimize,
faRotate,
} from "@fortawesome/free-solid-svg-icons";
import { useState } from "react"; import { useState } from "react";
import SoundBtn from "./SoundBtn"; import SoundBtn from "./SoundBtn";
import { useIntegrationsContext } from "../../context/IntegrationsContext"; import { useIntegrationsContext } from "../../context/IntegrationsContext";
export default function Header() { export default function Header() {
const [isFullscreen, setIsFullscreen] = useState(false); const [isFullscreen, setIsFullscreen] = useState(false);
const [isMenuOpen, setIsMenuOpen] = useState(false);
const { state } = useIntegrationsContext(); const { state } = useIntegrationsContext();
const toggleMenu = () => setIsMenuOpen(!isMenuOpen);
const sessionStarted = state.sessionStarted; const sessionStarted = state.sessionStarted;
const sessionPaused = state.sessionPaused; const sessionPaused = state.sessionPaused;
@@ -36,7 +47,7 @@ export default function Header() {
</Link> </Link>
</div> </div>
<div className="flex flex-col lg:flex-row items-center space-x-24 justify-items-center"> <div className="flex flex-col lg:flex-row items-center space-x-24 justify-items-center">
<div className="flex flex-row lg:flex-row space-x-2"> <div className="flex flex-row lg:flex-row space-x-2 mx-10 p-2 md:p-0 items-center">
{sessionStarted && sessionPaused ? ( {sessionStarted && sessionPaused ? (
<p className="text-gray-400 font-bold">Session Paused</p> <p className="text-gray-400 font-bold">Session Paused</p>
) : ( ) : (
@@ -44,7 +55,7 @@ export default function Header() {
)} )}
</div> </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={"/"}> <Link to={"/"}>
<FontAwesomeIcon className="text-white" icon={faHome} size="2x" /> <FontAwesomeIcon className="text-white" icon={faHome} size="2x" />
</Link> </Link>
@@ -59,15 +70,35 @@ export default function Header() {
<FontAwesomeIcon icon={faRotate} size="2x" /> <FontAwesomeIcon icon={faRotate} size="2x" />
</div> </div>
<SoundBtn /> <SoundBtn />
<Link to={"/session-settings"}> <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" /> <FontAwesomeIcon className="text-white" icon={faListCheck} size="2x" />
</Link> </Link>
<Link to={"/system-settings"}> <Link className="hidden md:flex" to={"/system-settings"}>
<FontAwesomeIcon className="text-white" icon={faGear} size="2x" /> <FontAwesomeIcon className="text-white" icon={faGear} size="2x" />
</Link> </Link>
</div> </div>
</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> </div>
); );
} }

View File

@@ -16,6 +16,11 @@ const SoundBtn = () => {
path: "soundEnabled", path: "soundEnabled",
value: { enabled: newEnabled }, value: { enabled: newEnabled },
}); });
await mutation.mutateAsync({
operation: "SAVE",
path: "",
value: null,
});
}; };
useEffect(() => { useEffect(() => {
setEnabled(query?.data?.soundEnabled?.enabled); setEnabled(query?.data?.soundEnabled?.enabled);
@@ -23,10 +28,7 @@ const SoundBtn = () => {
return ( return (
<button onClick={handleClick}> <button onClick={handleClick}>
<FontAwesomeIcon <FontAwesomeIcon icon={enabled ? faVolumeHigh : faVolumeXmark} size="2x" />
icon={enabled ? faVolumeHigh : faVolumeXmark}
size="2x"
/>
</button> </button>
); );
}; };

View File

@@ -12,17 +12,44 @@ export const IntegrationsProvider = ({ children }: IntegrationsProviderType) =>
const { mutation } = useCameraBlackboard(); const { mutation } = useCameraBlackboard();
useEffect(() => { useEffect(() => {
let isMounted = true;
const fetchData = async () => { const fetchData = async () => {
try {
await mutation.mutateAsync({
operation: "Load",
path: "",
value: null,
});
const result = await mutation.mutateAsync({ const result = await mutation.mutateAsync({
operation: "VIEW", operation: "VIEW",
path: "sessionStats", path: "sessionStats",
}); });
if (!result.result || typeof result.result === "string") return;
dispatch({ type: "UPDATE", payload: result?.result }); if (!isMounted) return;
const catResult = await mutation.mutateAsync({
operation: "VIEW",
path: "CategoryPopup",
});
if (!isMounted) return;
if (!result?.result || typeof result.result === "string") return;
dispatch({ type: "UPDATE", payload: result.result });
dispatch({ type: "NPEDCATENABLED", payload: catResult.result });
} catch (error) {
console.error("Error in fetchData:", error);
}
}; };
fetchData(); fetchData();
return () => {
isMounted = false;
};
}, []); }, []);
return ( return (
<IntegrationsContext.Provider <IntegrationsContext.Provider
value={{ value={{

View File

@@ -20,6 +20,11 @@ const SoundContextProvider = ({ children }: SoundContextProviderProps) => {
operation: "VIEW", operation: "VIEW",
path: "soundSettings", path: "soundSettings",
}); });
await mutation.mutateAsync({
operation: "LOAD",
path: "",
value: null,
});
if (!result.result || typeof result.result !== "object") { if (!result.result || typeof result.result !== "object") {
dispatch({ type: "UPDATE", payload: state }); dispatch({ type: "UPDATE", payload: state });

View File

@@ -6,6 +6,12 @@ export const initialState = {
sessionPaused: false, sessionPaused: false,
savedSightings: [], savedSightings: [],
npedUser: null, npedUser: null,
iscatEnabled: {
catA: true,
catB: true,
catC: true,
catD: false,
},
}; };
export function reducer(state: NPEDSTATE, action: NPEDACTION) { export function reducer(state: NPEDSTATE, action: NPEDACTION) {
@@ -40,6 +46,11 @@ export function reducer(state: NPEDSTATE, action: NPEDACTION) {
...state, ...state,
sessionList: action.payload, sessionList: action.payload,
}; };
case "NPEDCATENABLED":
return {
...state,
iscatEnabled: action.payload,
};
default: default:
return { ...state }; return { ...state };
} }

View File

@@ -11,7 +11,6 @@ const getCameraMode = async (options: { camera: string }) => {
}; };
const updateCameraMode = async (options: { camera: string; mode: string }) => { const updateCameraMode = async (options: { camera: string; mode: string }) => {
console.log(options);
const dayNightPayload = { const dayNightPayload = {
id: options.camera, id: options.camera,
fields: [ fields: [

View File

@@ -33,7 +33,7 @@ body {
} }
.arrow-outline path { .arrow-outline path {
stroke: black; /* outline color */ stroke: black;
stroke-width: 20px; /* thickness of outline (tweak this) */ stroke-width: 20px;
stroke-linejoin: round; stroke-linejoin: round;
} }

View File

@@ -10,6 +10,7 @@ import { Toaster } from "sonner";
import { useNPEDAuth } from "../hooks/useNPEDAuth"; import { useNPEDAuth } from "../hooks/useNPEDAuth";
import SoundSettingsCard from "../components/SettingForms/Sound/SoundSettingsCard"; import SoundSettingsCard from "../components/SettingForms/Sound/SoundSettingsCard";
import SoundUploadCard from "../components/SettingForms/Sound/SoundUploadCard"; import SoundUploadCard from "../components/SettingForms/Sound/SoundUploadCard";
import NPEDCategoryPopup from "../components/PopupSettings/NPEDCategoryPopup";
const SystemSettings = () => { const SystemSettings = () => {
useNPEDAuth(); useNPEDAuth();
@@ -21,7 +22,7 @@ const SystemSettings = () => {
<Tab>System</Tab> <Tab>System</Tab>
<Tab>Output</Tab> <Tab>Output</Tab>
<Tab>Integrations</Tab> <Tab>Integrations</Tab>
<Tab>WiFi and Modem</Tab> <Tab>WiFi & Modem</Tab>
<Tab>Sound</Tab> <Tab>Sound</Tab>
</TabList> </TabList>
<TabPanel> <TabPanel>
@@ -38,6 +39,7 @@ 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"> <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 /> <NPEDCard />
<NPEDHotlistCard /> <NPEDHotlistCard />
<NPEDCategoryPopup />
</div> </div>
</TabPanel> </TabPanel>
<TabPanel> <TabPanel>

View File

@@ -282,7 +282,7 @@ export type CameraConfig = {
export type CameraBlackBoardOptions = { export type CameraBlackBoardOptions = {
operation?: string; operation?: string;
path?: string; path?: string;
value?: object | string | number | (string | number)[]; value?: object | string | number | (string | number)[] | null;
}; };
export type CameraBlackboardResponse = { export type CameraBlackboardResponse = {
@@ -403,6 +403,8 @@ export type ModemSettingsType = {
username: string; username: string;
password: string; password: string;
authenticationType: string; authenticationType: string;
serverPrimary: string;
serverSecondary: string;
}; };
export type HitKind = "NPED" | "HOTLIST"; export type HitKind = "NPED" | "HOTLIST";
@@ -421,6 +423,7 @@ export type NPEDSTATE = {
sessionPaused: boolean; sessionPaused: boolean;
savedSightings: DedupedSightings; savedSightings: DedupedSightings;
npedUser: NPEDUser; npedUser: NPEDUser;
iscatEnabled: CategoryPopups;
}; };
export type NPEDACTION = { export type NPEDACTION = {
@@ -428,3 +431,10 @@ export type NPEDACTION = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
payload: any; payload: any;
}; };
export type CategoryPopups = {
catA: boolean;
catB: boolean;
catC: boolean;
catD: boolean;
};

View File

@@ -184,3 +184,14 @@ export const reverseZoomMapping = (magnification: string) => {
break; 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";
}
};