WIP config update
This commit is contained in:
@@ -49,17 +49,7 @@ export const Map = (): JSX.Element => {
|
||||
// }, [reset, rasterSources]);
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Map Config"
|
||||
breadcrumbs={["App Config", "Map"]}
|
||||
reset={() =>
|
||||
reset({
|
||||
rasterSources
|
||||
})
|
||||
}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<InfoWrapper label="WMS Sources">
|
||||
<div className="flex flex-col gap-2">
|
||||
{fields.map((field, index) => (
|
||||
|
||||
@@ -105,31 +105,7 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Channel Editor"
|
||||
breadcrumbs={[
|
||||
"Channels",
|
||||
channel.settings?.name.length
|
||||
? channel.settings.name
|
||||
: channel.role === Protobuf.Channel_Role.PRIMARY
|
||||
? "Primary"
|
||||
: `Channel: ${channel.index}`
|
||||
]}
|
||||
reset={() =>
|
||||
reset({
|
||||
enabled: [
|
||||
Protobuf.Channel_Role.SECONDARY,
|
||||
Protobuf.Channel_Role.PRIMARY
|
||||
].find((role) => role === channel?.role)
|
||||
? true
|
||||
: false,
|
||||
...channel?.settings,
|
||||
psk: fromByteArray(channel?.settings?.psk ?? new Uint8Array(0))
|
||||
})
|
||||
}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
{channel?.index !== 0 && (
|
||||
<>
|
||||
<Controller
|
||||
|
||||
@@ -71,10 +71,6 @@ export const Bluetooth = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Bluetooth Config"
|
||||
breadcrumbs={["Config", "Bluetooth"]}
|
||||
reset={() => reset(config.bluetooth)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Controller
|
||||
|
||||
@@ -64,10 +64,6 @@ export const Device = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Device Config"
|
||||
breadcrumbs={["Config", "Device"]}
|
||||
reset={() => reset(config.device)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Select
|
||||
|
||||
@@ -7,7 +7,7 @@ import { toast } from "react-hot-toast";
|
||||
import { Input } from "@app/components/form/Input.js";
|
||||
import { Select } from "@app/components/form/Select.js";
|
||||
import { Toggle } from "@app/components/form/Toggle.js";
|
||||
import { DisplayValidation } from "@app/validation/config/display.js";
|
||||
import type { DisplayValidation } from "@app/validation/config/display.js";
|
||||
import { Form } from "@components/form/Form";
|
||||
import { useDevice } from "@core/providers/useDevice.js";
|
||||
import { renderOptions } from "@core/utils/selectEnumOptions.js";
|
||||
@@ -22,54 +22,48 @@ export const Display = (): JSX.Element => {
|
||||
formState: { errors, isDirty },
|
||||
reset,
|
||||
control
|
||||
} = useForm<Protobuf.Config_DisplayConfig>({
|
||||
defaultValues: config.display,
|
||||
resolver: classValidatorResolver(DisplayValidation)
|
||||
} = useForm<DisplayValidation>({
|
||||
defaultValues: config.display
|
||||
// resolver: classValidatorResolver(DisplayValidation)
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
reset(config.display);
|
||||
}, [reset, config.display]);
|
||||
// useEffect(() => {
|
||||
// reset(config.display);
|
||||
// }, [reset, config.display]);
|
||||
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection
|
||||
.setConfig(
|
||||
new Protobuf.Config({
|
||||
payloadVariant: {
|
||||
case: "display",
|
||||
value: data
|
||||
}
|
||||
})
|
||||
)
|
||||
.then(() =>
|
||||
setConfig(
|
||||
new Protobuf.Config({
|
||||
payloadVariant: {
|
||||
case: "display",
|
||||
value: data
|
||||
}
|
||||
})
|
||||
)
|
||||
),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Display Config, Restarting Node",
|
||||
error: "No response received"
|
||||
}
|
||||
);
|
||||
}
|
||||
// if (connection) {
|
||||
// void toast.promise(
|
||||
// connection
|
||||
// .setConfig(
|
||||
// new Protobuf.Config({
|
||||
// payloadVariant: {
|
||||
// case: "display",
|
||||
// value: data
|
||||
// }
|
||||
// })
|
||||
// )
|
||||
// .then(() =>
|
||||
// setConfig(
|
||||
// new Protobuf.Config({
|
||||
// payloadVariant: {
|
||||
// case: "display",
|
||||
// value: data
|
||||
// }
|
||||
// })
|
||||
// )
|
||||
// ),
|
||||
// {
|
||||
// loading: "Saving...",
|
||||
// success: "Saved Display Config, Restarting Node",
|
||||
// error: "No response received"
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Display Config"
|
||||
breadcrumbs={["Config", "Display"]}
|
||||
reset={() => reset(config.display)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Input
|
||||
label="Screen Timeout"
|
||||
description="Turn off the display after this long"
|
||||
|
||||
@@ -72,10 +72,6 @@ export const LoRa = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="LoRa Config"
|
||||
breadcrumbs={["Config", "LoRa"]}
|
||||
reset={() => reset(config.lora)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<FormSection title="Modem Settings">
|
||||
|
||||
@@ -85,10 +85,6 @@ export const Network = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Network Config"
|
||||
breadcrumbs={["Config", "Network"]}
|
||||
reset={() => reset(config.network)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<ErrorMessage errors={errors} name="wifiEnabled" />
|
||||
|
||||
@@ -108,10 +108,6 @@ export const Position = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Position Config"
|
||||
breadcrumbs={["Config", "Position"]}
|
||||
reset={() => reset(config.position)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Controller
|
||||
|
||||
@@ -63,10 +63,6 @@ export const Power = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Power Config"
|
||||
breadcrumbs={["Config", "Power"]}
|
||||
reset={() => reset(config.power)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Input
|
||||
|
||||
@@ -62,16 +62,6 @@ export const User = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="User Config"
|
||||
breadcrumbs={["Config", "User"]}
|
||||
reset={() => {
|
||||
reset({
|
||||
longName: myNode?.data.user?.longName,
|
||||
shortName: myNode?.data.user?.shortName,
|
||||
isLicensed: myNode?.data.user?.isLicensed
|
||||
});
|
||||
}}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<ErrorMessage errors={errors} name="longName" />
|
||||
|
||||
@@ -63,13 +63,7 @@ export const Audio = (): JSX.Element => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Audio Config"
|
||||
breadcrumbs={["Module Config", "Audio"]}
|
||||
reset={() => reset(moduleConfig.audio)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Controller
|
||||
name="codec2Enabled"
|
||||
control={control}
|
||||
|
||||
@@ -69,13 +69,7 @@ export const CannedMessage = (): JSX.Element => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Canned Message Config"
|
||||
breadcrumbs={["Module Config", "Canned Message"]}
|
||||
reset={() => reset(moduleConfig.cannedMessage)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Controller
|
||||
name="enabled"
|
||||
control={control}
|
||||
|
||||
@@ -66,13 +66,7 @@ export const ExternalNotification = (): JSX.Element => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="External Notification Config"
|
||||
breadcrumbs={["Module Config", "External Notification"]}
|
||||
reset={() => reset(moduleConfig.externalNotification)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Controller
|
||||
name="enabled"
|
||||
control={control}
|
||||
|
||||
@@ -67,13 +67,7 @@ export const MQTT = (): JSX.Element => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="MQTT Config"
|
||||
breadcrumbs={["Module Config", "MQTT"]}
|
||||
reset={() => reset(moduleConfig.mqtt)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Controller
|
||||
name="enabled"
|
||||
control={control}
|
||||
|
||||
@@ -68,10 +68,6 @@ export const RangeTest = (): JSX.Element => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Range Test Config"
|
||||
breadcrumbs={["Module Config", "Range Test"]}
|
||||
reset={() => reset(moduleConfig.rangeTest)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Controller
|
||||
|
||||
@@ -69,13 +69,7 @@ export const Serial = (): JSX.Element => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Serial Config"
|
||||
breadcrumbs={["Module Config", "Serial"]}
|
||||
reset={() => reset(moduleConfig.serial)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Controller
|
||||
name="enabled"
|
||||
control={control}
|
||||
|
||||
@@ -67,13 +67,7 @@ export const StoreForward = (): JSX.Element => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Store & Forward Config"
|
||||
breadcrumbs={["Module Config", "Store & Forward"]}
|
||||
reset={() => reset(moduleConfig.storeForward)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Controller
|
||||
name="enabled"
|
||||
control={control}
|
||||
|
||||
@@ -61,13 +61,7 @@ export const Telemetry = (): JSX.Element => {
|
||||
});
|
||||
|
||||
return (
|
||||
<Form
|
||||
title="Telemetry Config"
|
||||
breadcrumbs={["Module Config", "Telemetry"]}
|
||||
reset={() => reset(moduleConfig.telemetry)}
|
||||
dirty={isDirty}
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Controller
|
||||
name="environmentMeasurementEnabled"
|
||||
control={control}
|
||||
|
||||
Reference in New Issue
Block a user