Update deps, add ethernet config

This commit is contained in:
Sacha Weatherstone
2022-10-23 12:39:43 +10:00
parent 79e8ba70a6
commit aa01bb206f
7 changed files with 257 additions and 19 deletions
@@ -33,6 +33,12 @@ export const Network = (): JSX.Element => {
defaultValue: false,
});
const ethEnabled = useWatch({
control,
name: "ethEnabled",
defaultValue: false,
});
useEffect(() => {
reset(config.network);
}, [reset, config.network]);
@@ -108,8 +114,57 @@ export const Network = (): JSX.Element => {
label="NTP Server"
description="NTP server for time synchronization"
error={errors.ntpServer?.message}
disabled={!wifiEnabled && !ethEnabled}
{...register("ntpServer")}
/>
<Controller
name="ethEnabled"
control={control}
render={({ field: { value, ...rest } }) => (
<Toggle
label="Ethernet Enabled"
description="Enable or disbale the Ethernet port"
checked={value}
{...rest}
/>
)}
/>
<Select
label="Ethernet Mode"
description="Address assignment selection"
disabled={!ethEnabled}
{...register("ethMode", { valueAsNumber: true })}
>
{renderOptions(Protobuf.Config_NetworkConfig_WiFiMode)}
</Select>
<Input
label="Ethernet IP"
description="IP Address"
error={errors.wifiSsid?.message}
disabled={!ethEnabled}
{...register("ethConfig.ip")}
/>
<Input
label="Ethernet Gateway"
description="Default Gatewat"
error={errors.wifiSsid?.message}
disabled={!ethEnabled}
{...register("ethConfig.gateway")}
/>
<Input
label="Ethernet Subnet"
description="Subnet Mask"
error={errors.wifiSsid?.message}
disabled={!ethEnabled}
{...register("ethConfig.subnet")}
/>
<Input
label="Ethernet DNS"
description="DNS Server"
error={errors.wifiSsid?.message}
disabled={!ethEnabled}
{...register("ethConfig.dns")}
/>
</Form>
);
};
+1 -1
View File
@@ -34,7 +34,7 @@ export const Sidebar = (): JSX.Element => {
removeDevice(selectedDevice ?? 0);
}}
reconnect={() => {
console.log("");
void connection?.disconnect();
}}
/>
+14 -2
View File
@@ -16,7 +16,16 @@ export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
}
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
{ label, description, prefix, suffix, action, error, ...rest }: InputProps,
{
label,
description,
prefix,
suffix,
action,
error,
disabled,
...rest
}: InputProps,
ref
) {
return (
@@ -34,7 +43,10 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
ref={ref}
className={`flex h-10 w-full rounded-md border-transparent bg-orange-100 px-3 text-sm focus:border-transparent focus:outline-none focus:ring-2 focus:ring-orange-500 ${
prefix ? "rounded-l-none" : ""
} ${action ? "rounded-r-none" : ""}`}
} ${action ? "rounded-r-none" : ""} ${
disabled ? "cursor-not-allowed bg-orange-50 text-orange-200" : ""
}`}
disabled={disabled}
{...rest}
/>
{suffix && (
+1 -1
View File
@@ -43,7 +43,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(function Input(
className={`flex h-10 w-full rounded-md border-transparent bg-orange-100 px-3 text-sm focus:border-transparent focus:outline-none focus:ring-2 focus:ring-orange-500 ${
prefix ? "rounded-l-none" : ""
} ${action ? "rounded-r-none" : ""} ${
disabled ? "cursor-not-allowed" : ""
disabled ? "cursor-not-allowed bg-orange-50 text-orange-200" : ""
}`}
disabled={disabled}
{...rest}
+25 -1
View File
@@ -1,4 +1,4 @@
import { IsBoolean, IsEnum, Length } from "class-validator";
import { IsBoolean, IsEnum, IsIP, Length } from "class-validator";
import { Protobuf } from "@meshtastic/meshtasticjs";
@@ -17,4 +17,28 @@ export class NetworkValidation implements Protobuf.Config_NetworkConfig {
@Length(2, 30)
ntpServer: string;
@IsBoolean()
ethEnabled: boolean;
@IsEnum(Protobuf.Config_NetworkConfig_EthMode)
ethMode: Protobuf.Config_NetworkConfig_EthMode;
ethConfig: NetworkValidation_ethConfig;
}
export class NetworkValidation_ethConfig
implements Protobuf.Config_NetworkConfig_NetworkConfig
{
@IsIP()
ip: number;
@IsIP()
gateway: number;
@IsIP()
subnet: number;
@IsIP()
dns: number;
}