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. (#474)
deno-round-2
Dan Ditomaso
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
16 additions and
6 deletions
-
src/components/Form/DynamicForm.tsx
-
src/components/PageComponents/Config/Bluetooth.tsx
-
src/components/PageComponents/Config/Network.tsx
-
src/components/PageComponents/Connect/Serial.tsx
|
|
|
@ -27,6 +27,7 @@ export interface BaseFormBuilderProps<T> { |
|
|
|
disabledBy?: DisabledBy<T>[]; |
|
|
|
label: string; |
|
|
|
description?: string; |
|
|
|
notes?: string; |
|
|
|
validationText?: string; |
|
|
|
properties?: Record<string, unknown>; |
|
|
|
} |
|
|
|
@ -45,6 +46,7 @@ export interface DynamicFormProps<T extends FieldValues> { |
|
|
|
fieldGroups: { |
|
|
|
label: string; |
|
|
|
description: string; |
|
|
|
notes?: string; |
|
|
|
valid?: boolean; |
|
|
|
validationText?: string; |
|
|
|
fields: FieldProps<T>[]; |
|
|
|
@ -96,6 +98,7 @@ export function DynamicForm<T extends FieldValues>({ |
|
|
|
<div> |
|
|
|
<H4 className="font-medium">{fieldGroup.label}</H4> |
|
|
|
<Subtle>{fieldGroup.description}</Subtle> |
|
|
|
<Subtle className="font-semibold">{fieldGroup?.notes}</Subtle> |
|
|
|
</div> |
|
|
|
|
|
|
|
{fieldGroup.fields.map((field) => { |
|
|
|
|
|
|
|
@ -70,7 +70,9 @@ export const Bluetooth = () => { |
|
|
|
fieldGroups={[ |
|
|
|
{ |
|
|
|
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: [ |
|
|
|
{ |
|
|
|
type: "toggle", |
|
|
|
|
|
|
|
@ -8,7 +8,7 @@ import { |
|
|
|
} from "@core/utils/ip.ts"; |
|
|
|
import { Protobuf } from "@meshtastic/core"; |
|
|
|
|
|
|
|
export const Network = (): JSX.Element => { |
|
|
|
export const Network = () => { |
|
|
|
const { config, setWorkingConfig } = useDevice(); |
|
|
|
|
|
|
|
const onSubmit = (data: NetworkValidation) => { |
|
|
|
@ -53,6 +53,8 @@ export const Network = (): JSX.Element => { |
|
|
|
{ |
|
|
|
label: "WiFi Config", |
|
|
|
description: "WiFi radio configuration", |
|
|
|
notes: |
|
|
|
"Note: Some devices (ESP32) cannot use both Bluetooth and WiFi at the same time.", |
|
|
|
fields: [ |
|
|
|
{ |
|
|
|
type: "toggle", |
|
|
|
|
|
|
|
@ -18,7 +18,9 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => { |
|
|
|
setSerialPorts(await navigator?.serial.getPorts()); |
|
|
|
}, []); |
|
|
|
|
|
|
|
navigator?.serial?.addEventListener("connect", () => { |
|
|
|
navigator?.serial?.addEventListener("connect", (event) => { |
|
|
|
console.log(event); |
|
|
|
|
|
|
|
updateSerialPortList(); |
|
|
|
}); |
|
|
|
navigator?.serial?.addEventListener("disconnect", () => { |
|
|
|
@ -45,6 +47,8 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => { |
|
|
|
<div className="flex w-full flex-col gap-2 p-4"> |
|
|
|
<div className="flex h-48 flex-col gap-2 overflow-y-auto"> |
|
|
|
{serialPorts.map((port, index) => { |
|
|
|
console.log(port); |
|
|
|
|
|
|
|
const { usbProductId, usbVendorId } = port.getInfo(); |
|
|
|
return ( |
|
|
|
<Button |
|
|
|
@ -55,9 +59,8 @@ export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => { |
|
|
|
await onConnect(port); |
|
|
|
}} |
|
|
|
> |
|
|
|
{`# ${index} - ${usbVendorId ?? "UNK"} - ${ |
|
|
|
usbProductId ?? "UNK" |
|
|
|
}`}
|
|
|
|
{`# ${index} - ${usbVendorId ?? "UNK"} - ${usbProductId ?? "UNK" |
|
|
|
}`}
|
|
|
|
</Button> |
|
|
|
); |
|
|
|
})} |
|
|
|
|