2 Commits

Author SHA1 Message Date
1b788271a8 Merge pull request 'bugfix/saveandload' (#13) from bugfix/saveandload into develop
Reviewed-on: #13
2025-11-17 10:22:36 +00:00
d2f030f221 added save and load endpoints 2025-11-17 10:19:44 +00:00
10 changed files with 52 additions and 11 deletions

View File

@@ -30,6 +30,12 @@ const NPEDCategoryPopup = () => {
value: values, value: values,
path: "CategoryPopup", path: "CategoryPopup",
}); });
await mutation.mutateAsync({
operation: "SAVE",
path: "",
value: null
})
if (result?.reason === "OK") toast.success("Pop up settings saved"); if (result?.reason === "OK") toast.success("Pop up settings saved");
dispatch({ type: "NPEDCATENABLED", payload: values }); dispatch({ type: "NPEDCATENABLED", payload: values });
}; };

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

@@ -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 {

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 });
}; };

View File

@@ -25,7 +25,7 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }:
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");
@@ -33,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");
} }

View File

@@ -47,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 mx-auto p-2 md:p-0 items-center"> <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>
) : ( ) : (

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

@@ -16,6 +16,11 @@ export const IntegrationsProvider = ({ children }: IntegrationsProviderType) =>
const fetchData = async () => { const fetchData = async () => {
try { 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",

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

@@ -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 = {