Browse Source

fix: added a notes fild to Dynamic form allowing for notes to inform users about using BLE and wifi at the same time.

pull/474/head
Dan Ditomaso 1 year ago
parent
commit
791c24f500
  1. 3
      src/components/Form/DynamicForm.tsx
  2. 4
      src/components/PageComponents/Config/Bluetooth.tsx
  3. 4
      src/components/PageComponents/Config/Network.tsx
  4. 2
      src/components/PageComponents/Config/Security/Security.tsx
  5. 13
      src/components/PageComponents/Connect/Serial.tsx

3
src/components/Form/DynamicForm.tsx

@ -27,6 +27,7 @@ export interface BaseFormBuilderProps<T> {
disabledBy?: DisabledBy<T>[]; disabledBy?: DisabledBy<T>[];
label: string; label: string;
description?: string; description?: string;
notes?: string;
validationText?: string; validationText?: string;
properties?: Record<string, unknown>; properties?: Record<string, unknown>;
} }
@ -45,6 +46,7 @@ export interface DynamicFormProps<T extends FieldValues> {
fieldGroups: { fieldGroups: {
label: string; label: string;
description: string; description: string;
notes?: string;
valid?: boolean; valid?: boolean;
validationText?: string; validationText?: string;
fields: FieldProps<T>[]; fields: FieldProps<T>[];
@ -96,6 +98,7 @@ export function DynamicForm<T extends FieldValues>({
<div> <div>
<H4 className="font-medium">{fieldGroup.label}</H4> <H4 className="font-medium">{fieldGroup.label}</H4>
<Subtle>{fieldGroup.description}</Subtle> <Subtle>{fieldGroup.description}</Subtle>
<Subtle className="font-semibold">{fieldGroup?.notes}</Subtle>
</div> </div>
{fieldGroup.fields.map((field) => ( {fieldGroup.fields.map((field) => (

4
src/components/PageComponents/Config/Bluetooth.tsx

@ -69,7 +69,9 @@ export const Bluetooth = () => {
fieldGroups={[ fieldGroups={[
{ {
label: "Bluetooth Settings", label: "Bluetooth Settings",
description: "Settings for the Bluetooth module", description: "Settings for the Bluetooth module ",
notes:
"Note: Some devices (ESP32) cannot use both Bluetooth and WiFi at the same time.",
fields: [ fields: [
{ {
type: "toggle", type: "toggle",

4
src/components/PageComponents/Config/Network.tsx

@ -7,7 +7,7 @@ import {
} from "@core/utils/ip.ts"; } from "@core/utils/ip.ts";
import { Protobuf } from "@meshtastic/js"; import { Protobuf } from "@meshtastic/js";
export const Network = (): JSX.Element => { export const Network = () => {
const { config, setWorkingConfig } = useDevice(); const { config, setWorkingConfig } = useDevice();
const onSubmit = (data: NetworkValidation) => { const onSubmit = (data: NetworkValidation) => {
@ -49,6 +49,8 @@ export const Network = (): JSX.Element => {
{ {
label: "WiFi Config", label: "WiFi Config",
description: "WiFi radio configuration", description: "WiFi radio configuration",
notes:
"Note: Some devices (ESP32) cannot use both Bluetooth and WiFi at the same time.",
fields: [ fields: [
{ {
type: "toggle", type: "toggle",

2
src/components/PageComponents/Config/Security/Security.tsx

@ -241,7 +241,7 @@ export const Security = () => {
? getErrorMessage("adminKey") ? getErrorMessage("adminKey")
: "", : "",
inputChange: adminKeyInputChangeEvent, inputChange: adminKeyInputChangeEvent,
selectChange: () => { }, selectChange: () => {},
bits: [{ text: "256 bit", value: "32", key: "bit256" }], bits: [{ text: "256 bit", value: "32", key: "bit256" }],
devicePSKBitCount: state.privateKeyBitCount, devicePSKBitCount: state.privateKeyBitCount,
hide: !state.adminKeyVisible, hide: !state.adminKeyVisible,

13
src/components/PageComponents/Connect/Serial.tsx

@ -17,7 +17,9 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => {
setSerialPorts(await navigator?.serial.getPorts()); setSerialPorts(await navigator?.serial.getPorts());
}, []); }, []);
navigator?.serial?.addEventListener("connect", () => { navigator?.serial?.addEventListener("connect", (event) => {
console.log(event);
updateSerialPortList(); updateSerialPortList();
}); });
navigator?.serial?.addEventListener("disconnect", () => { navigator?.serial?.addEventListener("disconnect", () => {
@ -39,16 +41,22 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => {
concurrentLogOutput: true, concurrentLogOutput: true,
}) })
.catch((e: Error) => console.log(`Unable to Connect: ${e.message}`)); .catch((e: Error) => console.log(`Unable to Connect: ${e.message}`));
console.log(connection);
device.addConnection(connection); device.addConnection(connection);
subscribeAll(device, connection); subscribeAll(device, connection);
closeDialog(); closeDialog();
}; };
console.log(serialPorts);
return ( return (
<div className="flex w-full flex-col gap-2 p-4"> <div className="flex w-full flex-col gap-2 p-4">
<div className="flex h-48 flex-col gap-2 overflow-y-auto"> <div className="flex h-48 flex-col gap-2 overflow-y-auto">
{serialPorts.map((port, index) => { {serialPorts.map((port, index) => {
console.log(port);
const { usbProductId, usbVendorId } = port.getInfo(); const { usbProductId, usbVendorId } = port.getInfo();
return ( return (
<Button <Button
@ -59,8 +67,7 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => {
await onConnect(port); await onConnect(port);
}} }}
> >
{`# ${index} - ${usbVendorId ?? "UNK"} - ${ {`# ${index} - ${usbVendorId ?? "UNK"} - ${usbProductId ?? "UNK"
usbProductId ?? "UNK"
}`} }`}
</Button> </Button>
); );

Loading…
Cancel
Save