mirror of
https://github.com/meshtastic/web.git
synced 2026-04-23 23:38:04 -04:00
wip
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"imports": {
|
||||
"@meshtastic/core": "jsr:@meshtastic/core@^2.6.2",
|
||||
"@meshtastic/js": "jsr:@meshtastic/js@^2.3.4",
|
||||
"@meshtastic/transport-http": "jsr:@meshtastic/transport-http@^0.2.1",
|
||||
"@meshtastic/transport-web-bluetooth": "jsr:@meshtastic/transport-web-bluetooth@^0.1.1",
|
||||
"@meshtastic/transport-web-serial": "jsr:@meshtastic/transport-web-serial@^0.2.1",
|
||||
"@app/": "./src/",
|
||||
"@pages/": "./src/pages/",
|
||||
"@components/": "./src/components/",
|
||||
|
||||
@@ -35,10 +35,6 @@
|
||||
"homepage": "https://meshtastic.org",
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.2.3",
|
||||
"@meshtastic/core": "npm:@jsr/meshtastic__core@2.6.0-0",
|
||||
"@meshtastic/js": "npm:@jsr/meshtastic__js@2.6.0-0",
|
||||
"@meshtastic/transport-http": "npm:@jsr/meshtastic__transport-http",
|
||||
"@meshtastic/transport-web-serial": "npm:@jsr/meshtastic__transport-web-serial",
|
||||
"@noble/curves": "^1.8.1",
|
||||
"@radix-ui/react-accordion": "^1.2.3",
|
||||
"@radix-ui/react-checkbox": "^1.1.4",
|
||||
@@ -74,6 +70,7 @@
|
||||
"react-qrcode-logo": "^3.0.0",
|
||||
"rfc4648": "^1.5.4",
|
||||
"vite-plugin-node-polyfills": "^0.23.0",
|
||||
"zod": "^3.24.2",
|
||||
"zustand": "5.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -10,13 +10,14 @@ import {
|
||||
SelectValue,
|
||||
} from "@components/UI/Select.tsx";
|
||||
import { useController, type FieldValues } from "react-hook-form";
|
||||
import { computeHeadingLevel } from "@core/utils/test.tsx";
|
||||
|
||||
export interface SelectFieldProps<T> extends BaseFormBuilderProps<T> {
|
||||
type: "select";
|
||||
selectChange?: (e: string, name: string) => void;
|
||||
validate?: (newValue: string) => Promise<boolean>;
|
||||
defaultValue?: string;
|
||||
properties: BaseFormBuilderProps<T>["properties"] & {
|
||||
defaultValue?: T;
|
||||
enumValue: {
|
||||
[s: string]: string | number;
|
||||
};
|
||||
@@ -38,11 +39,15 @@ export function SelectInput<T extends FieldValues>({
|
||||
disabled,
|
||||
field,
|
||||
}: GenericFormElementProps<T, SelectFieldProps<T>>) {
|
||||
// Get default value and set it
|
||||
const defaultValue = field.properties.defaultValue ?? field.defaultValue;
|
||||
|
||||
const {
|
||||
field: { value, onChange, ...rest },
|
||||
} = useController({
|
||||
name: field.name,
|
||||
control,
|
||||
defaultValue: defaultValue ? defaultValue.toString() : undefined,
|
||||
});
|
||||
|
||||
const { enumValue, formatEnumName, ...remainingProperties } = field.properties;
|
||||
@@ -70,12 +75,12 @@ export function SelectInput<T extends FieldValues>({
|
||||
onChange(Number.parseInt(newValue));
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Select
|
||||
onValueChange={handleValueChange}
|
||||
disabled={disabled}
|
||||
value={value?.toString()}
|
||||
defaultValue={defaultValue?.toString()}
|
||||
{...remainingProperties}
|
||||
{...rest}
|
||||
>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { NetworkValidation } from "@app/validation/config/network.tsx";
|
||||
import type { NetworkValidation } from "@app/validation/config/network.ts";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import { DynamicForm } from "@components/Form/DynamicForm.tsx";
|
||||
import { useDevice } from "@core/stores/deviceStore.ts";
|
||||
@@ -12,6 +12,9 @@ export const Network = () => {
|
||||
const { config, setWorkingConfig } = useDevice();
|
||||
|
||||
const onSubmit = (data: NetworkValidation) => {
|
||||
|
||||
console.log("Network data", data);
|
||||
|
||||
setWorkingConfig(
|
||||
create(Protobuf.Config.ConfigSchema, {
|
||||
payloadVariant: {
|
||||
@@ -21,7 +24,7 @@ export const Network = () => {
|
||||
ipv4Config: create(
|
||||
Protobuf.Config.Config_NetworkConfig_IpV4ConfigSchema,
|
||||
{
|
||||
ip: convertIpAddressToInt(data.ipv4Config.ip) ?? 0,
|
||||
ip: convertIpAddressToInt(data?.ipv4Config?.ip) ?? 0,
|
||||
gateway: convertIpAddressToInt(data.ipv4Config.gateway) ?? 0,
|
||||
subnet: convertIpAddressToInt(data.ipv4Config.subnet) ?? 0,
|
||||
dns: convertIpAddressToInt(data.ipv4Config.dns) ?? 0,
|
||||
@@ -165,6 +168,22 @@ export const Network = () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "UDP Config",
|
||||
description: "UDP over Mesh configuration",
|
||||
fields: [
|
||||
{
|
||||
type: "select",
|
||||
name: "enabledProtocols",
|
||||
label: "Mesh via UDP enabled",
|
||||
properties: {
|
||||
enumValue:
|
||||
Protobuf.Config.Config_NetworkConfig_ProtocolFlags,
|
||||
formatEnumName: true,
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "NTP Config",
|
||||
description: "NTP configuration",
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
export function convertIntToIpAddress(int: number): string {
|
||||
return `${int & 0xff}.${(int >> 8) & 0xff}.${(int >> 16) & 0xff}.${
|
||||
(int >> 24) & 0xff
|
||||
}`;
|
||||
return `${int & 0xff}.${(int >> 8) & 0xff}.${(int >> 16) & 0xff}.${(int >> 24) & 0xff
|
||||
}`;
|
||||
}
|
||||
|
||||
export function convertIpAddressToInt(ip: string): number | null {
|
||||
export function convertIpAddressToInt(ip: string): number | undefined {
|
||||
if (!ip) {
|
||||
return undefined;
|
||||
}
|
||||
return (
|
||||
ip
|
||||
.split(".")
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
|
||||
export class NetworkValidation
|
||||
implements
|
||||
Omit<Protobuf.Config.Config_NetworkConfig, keyof Message | "ipv4Config"> {
|
||||
Omit<Protobuf.Config.Config_NetworkConfig, keyof Message | "ipv4Config"> {
|
||||
@IsBoolean()
|
||||
wifiEnabled: boolean;
|
||||
|
||||
@@ -34,6 +34,9 @@ export class NetworkValidation
|
||||
|
||||
ipv4Config: NetworkValidationIpV4Config;
|
||||
|
||||
@IsEnum(Protobuf.Config.Config_NetworkConfig_EnabledProtocols)
|
||||
enabledProtocols: Protobuf.Config.Config_NetworkConfig_ProtocolFlags;
|
||||
|
||||
@IsString()
|
||||
rsyslogServer: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user