diff --git a/src/components/SettingForms/BearerType/BearerTypeCard.tsx b/src/components/SettingForms/BearerType/BearerTypeCard.tsx index 2e42a60..b5eaa02 100644 --- a/src/components/SettingForms/BearerType/BearerTypeCard.tsx +++ b/src/components/SettingForms/BearerType/BearerTypeCard.tsx @@ -4,7 +4,7 @@ import BearerTypeFields from "./BearerTypeFields"; const BearerTypeCard = () => { return ( - + diff --git a/src/components/SettingForms/Channel1-JSON/ChannelCard.tsx b/src/components/SettingForms/Channel1-JSON/ChannelCard.tsx index 86f8879..3d2e1a1 100644 --- a/src/components/SettingForms/Channel1-JSON/ChannelCard.tsx +++ b/src/components/SettingForms/Channel1-JSON/ChannelCard.tsx @@ -37,7 +37,7 @@ const ChannelCard = ({ touched, isSubmitting, isBof2ConstantsLoading, isDispatch }, [backOfficeQuery.isSuccess, mapped, setFieldValue]); return ( - + {!isBof2ConstantsLoading && !isDispatcherLoading && !isBackOfficeQueryLoading ? ( {format?.toLowerCase() === "bof2" && ( <> -
-

{values.format} Constants

+
+
+

{values.format} Constants

+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+

{values.format} Lane ID Config

+
+ + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - - - )}
diff --git a/src/components/SettingForms/SettingForms/SettingForms.tsx b/src/components/SettingForms/SettingForms/SettingForms.tsx index f3cd9be..e3db87c 100644 --- a/src/components/SettingForms/SettingForms/SettingForms.tsx +++ b/src/components/SettingForms/SettingForms/SettingForms.tsx @@ -7,6 +7,7 @@ import type { InitialValuesForm, InitialValuesFormErrors, OptionalBOF2Constants, + OptionalBOF2LaneIDs, } from "../../../types/types"; import { useQueryClient } from "@tanstack/react-query"; import { useUpdateBackOfficeConfig } from "../../../hooks/useBackOfficeConfig"; @@ -14,7 +15,8 @@ import { useFormVaidate } from "../../../hooks/useFormValidate"; const SettingForms = () => { const qc = useQueryClient(); - const { dispatcherQuery, dispatcherMutation, backOfficeDispatcherMutation } = useCameraOutput(); + const { dispatcherQuery, dispatcherMutation, backOfficeDispatcherMutation, bof2LandMutation, laneIdQuery } = + useCameraOutput(); const { backOfficeMutation } = useUpdateBackOfficeConfig(); const { bof2ConstantsQuery } = useGetDispatcherConfig(); const { validateMutation } = useFormVaidate(); @@ -22,6 +24,9 @@ const SettingForms = () => { const format = dispatcherQuery?.data?.propFormat?.value; const enabled = dispatcherQuery?.data?.propEnabled?.value; + 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; @@ -30,7 +35,7 @@ const SettingForms = () => { const isDispatcherLoading = dispatcherQuery?.isFetching; const isBof2ConstantsLoading = bof2ConstantsQuery?.isFetching; - const initialValues: BearerTypeFieldType & InitialValuesForm & OptionalBOF2Constants = { + const initialValues: BearerTypeFieldType & InitialValuesForm & OptionalBOF2Constants & OptionalBOF2LaneIDs = { format: format ?? "JSON", enabled: enabled === "true", backOfficeURL: "", @@ -44,6 +49,10 @@ const SettingForms = () => { SCID: SCID ?? "", timestampSource: timestampSource ?? "", GPSFormat: GPSFormat ?? "", + + //BOF2 - optional Lane IDs + LID1: LID1 ?? "", + LID2: LID2 ?? "", }; const validateValues = (values: InitialValuesForm): InitialValuesFormErrors => { @@ -65,7 +74,9 @@ const SettingForms = () => { return errors; }; - const handleSubmit = async (values: BearerTypeFieldType & InitialValuesForm & OptionalBOF2Constants) => { + const handleSubmit = async ( + values: BearerTypeFieldType & InitialValuesForm & OptionalBOF2Constants & OptionalBOF2LaneIDs + ) => { const validResponse = await validateMutation.mutateAsync(values); const dispatcherData = { @@ -88,6 +99,13 @@ const SettingForms = () => { timestampSource: values.timestampSource, GPSFormat: values.GPSFormat, }; + + const bof2LaneData: OptionalBOF2LaneIDs = { + LID1: values.LID1, + LID2: values.LID2, + LID3: values.LID3, + }; + await bof2LandMutation.mutateAsync(bof2LaneData); await backOfficeDispatcherMutation.mutateAsync(bof2ConstantsData); } } else { diff --git a/src/components/SettingForms/System/SettingSaveRecall.tsx b/src/components/SettingForms/System/SettingSaveRecall.tsx index 8d9b3e7..b2a3de4 100644 --- a/src/components/SettingForms/System/SettingSaveRecall.tsx +++ b/src/components/SettingForms/System/SettingSaveRecall.tsx @@ -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,7 +45,7 @@ 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); @@ -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; diff --git a/src/components/SettingForms/System/SystemConfigFields.tsx b/src/components/SettingForms/System/SystemConfigFields.tsx index 21a280e..93627e5 100644 --- a/src/components/SettingForms/System/SystemConfigFields.tsx +++ b/src/components/SettingForms/System/SystemConfigFields.tsx @@ -4,21 +4,30 @@ 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"; const SystemConfigFields = () => { const { saveSystemSettings, systemSettingsData, saveSystemSettingsLoading } = useSystemConfig(); const { softRebootMutation, hardRebootMutation } = useReboots(); + const { dnsQuery, dnsMutation } = useDNSSettings(); + console.log(dnsQuery?.data); + 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, + 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 = {}; @@ -102,6 +111,34 @@ const SystemConfigFields = () => { autoComplete="off" /> + + + + + + + + + +