From cf423620c4e7a8da32d1b1484f8122fc07593172 Mon Sep 17 00:00:00 2001 From: Tilen Komel Date: Wed, 21 Aug 2024 17:41:24 +0200 Subject: [PATCH] Error & formating fixes --- src/components/Form/DynamicForm.tsx | 2 +- .../PageComponents/Config/Security.tsx | 40 ++++++++++--------- src/components/Sidebar.tsx | 2 +- src/pages/Map.tsx | 8 ++-- src/validation/config/bluetooth.ts | 6 ++- src/validation/config/lora.ts | 3 +- src/validation/config/power.ts | 3 +- src/validation/config/security.ts | 8 +++- src/validation/moduleConfig/storeForward.ts | 5 ++- 9 files changed, 47 insertions(+), 30 deletions(-) diff --git a/src/components/Form/DynamicForm.tsx b/src/components/Form/DynamicForm.tsx index 9affc0c7..58bf241e 100644 --- a/src/components/Form/DynamicForm.tsx +++ b/src/components/Form/DynamicForm.tsx @@ -66,7 +66,7 @@ export function DynamicForm({ if (!disabledBy) return false; return disabledBy.some((field) => { - if (field.fieldName === "always") return true + if (field.fieldName === "always") return true; const value = getValues(field.fieldName); if (value === "always") return true; if (typeof value === "boolean") return field.invert ? value : !value; diff --git a/src/components/PageComponents/Config/Security.tsx b/src/components/PageComponents/Config/Security.tsx index ea3b2f17..2834574c 100644 --- a/src/components/PageComponents/Config/Security.tsx +++ b/src/components/PageComponents/Config/Security.tsx @@ -1,5 +1,5 @@ -import type { SecurityValidation } from "@app/validation/config/security.js" import { DynamicForm } from "@app/components/Form/DynamicForm.js"; +import type { SecurityValidation } from "@app/validation/config/security.js"; import { useDevice } from "@core/stores/deviceStore.js"; import { Protobuf } from "@meshtastic/js"; import { fromByteArray, toByteArray } from "base64-js"; @@ -9,13 +9,13 @@ export const Security = (): JSX.Element => { const { config, nodes, hardware, setWorkingConfig } = useDevice(); const [adminKey, setAdminKey] = useState( - fromByteArray(config.security?.adminKey ?? new Uint8Array(0)) + fromByteArray(config.security?.adminKey ?? new Uint8Array(0)), ); const [privateKey, setPrivateKey] = useState( - fromByteArray(config.security?.privateKey ?? new Uint8Array(0)) + fromByteArray(config.security?.privateKey ?? new Uint8Array(0)), ); const [publicKey, setPublicKey] = useState( - fromByteArray(config.security?.publicKey ?? new Uint8Array(0)) + fromByteArray(config.security?.publicKey ?? new Uint8Array(0)), ); const onSubmit = (data: SecurityValidation) => { @@ -28,10 +28,10 @@ export const Security = (): JSX.Element => { adminKey: toByteArray(adminKey), privateKey: toByteArray(privateKey), publicKey: toByteArray(publicKey), - } + }, }, - }) - ) + }), + ); }; return ( @@ -40,7 +40,7 @@ export const Security = (): JSX.Element => { ...config.security, adminKey: adminKey, privateKey: privateKey, - publicKey: publicKey + publicKey: publicKey, }} fieldGroups={[ { @@ -57,8 +57,9 @@ export const Security = (): JSX.Element => { type: "text", name: "publicKey", label: "Public Key", - description: "Sent out to other nodes on the mesh to allow them to compute a shared secret key", - disabledBy: [ { fieldName: "always" } ] + description: + "Sent out to other nodes on the mesh to allow them to compute a shared secret key", + disabledBy: [{ fieldName: "always" }], }, ], }, @@ -70,20 +71,23 @@ export const Security = (): JSX.Element => { type: "toggle", name: "adminChannelEnabled", label: "Admin Channel", - description: "Allow incoming device control over the insecure legacy admin channel", + description: + "Allow incoming device control over the insecure legacy admin channel", }, { type: "toggle", name: "isManaged", label: "Is Managed", - description: 'If true, device is considered to be "managed" by a mesh administrator via admin messages', + description: + 'If true, device is considered to be "managed" by a mesh administrator via admin messages', }, { type: "text", name: "adminKey", label: "Admin Key", - description: "The public key authorized to send admin messages to this node", - } + description: + "The public key authorized to send admin messages to this node", + }, ], }, { @@ -106,11 +110,11 @@ export const Security = (): JSX.Element => { type: "toggle", name: "serialEnabled", label: "Serial", - description: "Serial Console over the Stream API" - } + description: "Serial Console over the Stream API", + }, ], }, ]} - /> - ) + /> + ); }; diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 96d820bb..116b6647 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -85,7 +85,7 @@ export const Sidebar = ({ children }: SidebarProps): JSX.Element => {
- {myNode?.deviceMetrics?.voltage.toPrecision(3) ?? "UNK"} volts + {myNode?.deviceMetrics?.voltage?.toPrecision(3) ?? "UNK"} volts
diff --git a/src/pages/Map.tsx b/src/pages/Map.tsx index 8c86480e..53df0cd4 100644 --- a/src/pages/Map.tsx +++ b/src/pages/Map.tsx @@ -144,8 +144,8 @@ export const MapPage = (): JSX.Element => { {waypoints.map((wp) => (
@@ -163,8 +163,8 @@ export const MapPage = (): JSX.Element => { return ( { diff --git a/src/validation/config/bluetooth.ts b/src/validation/config/bluetooth.ts index 65a0d0be..efaca6e9 100644 --- a/src/validation/config/bluetooth.ts +++ b/src/validation/config/bluetooth.ts @@ -3,7 +3,11 @@ import { Protobuf } from "@meshtastic/js"; import { IsBoolean, IsEnum, IsInt } from "class-validator"; export class BluetoothValidation - implements Omit + implements + Omit< + Protobuf.Config.Config_BluetoothConfig, + keyof Message | "deviceLoggingEnabled" + > { @IsBoolean() enabled: boolean; diff --git a/src/validation/config/lora.ts b/src/validation/config/lora.ts index 291a42d0..f5ef49d6 100644 --- a/src/validation/config/lora.ts +++ b/src/validation/config/lora.ts @@ -3,7 +3,8 @@ import { Protobuf } from "@meshtastic/js"; import { IsArray, IsBoolean, IsEnum, IsInt, Max, Min } from "class-validator"; export class LoRaValidation - implements Omit + implements + Omit { @IsBoolean() usePreset: boolean; diff --git a/src/validation/config/power.ts b/src/validation/config/power.ts index 3f3d097a..67bd1cd0 100644 --- a/src/validation/config/power.ts +++ b/src/validation/config/power.ts @@ -3,7 +3,8 @@ import type { Protobuf } from "@meshtastic/js"; import { IsBoolean, IsInt, IsNumber, Max, Min } from "class-validator"; export class PowerValidation - implements Omit + implements + Omit { @IsBoolean() isPowerSaving: boolean; diff --git a/src/validation/config/security.ts b/src/validation/config/security.ts index 4d501537..d1a35808 100644 --- a/src/validation/config/security.ts +++ b/src/validation/config/security.ts @@ -3,7 +3,11 @@ import type { Protobuf } from "@meshtastic/js"; import { IsBoolean, IsString } from "class-validator"; export class SecurityValidation - implements Omit + implements + Omit< + Protobuf.Config.Config_SecurityConfig, + keyof Message | "adminKey" | "privateKey" | "publicKey" + > { @IsBoolean() adminChannelEnabled: boolean; @@ -28,4 +32,4 @@ export class SecurityValidation @IsBoolean() serialEnabled: boolean; -} \ No newline at end of file +} diff --git a/src/validation/moduleConfig/storeForward.ts b/src/validation/moduleConfig/storeForward.ts index 82d9f4c2..773a2539 100644 --- a/src/validation/moduleConfig/storeForward.ts +++ b/src/validation/moduleConfig/storeForward.ts @@ -4,7 +4,10 @@ import { IsBoolean, IsInt } from "class-validator"; export class StoreForwardValidation implements - Omit + Omit< + Protobuf.ModuleConfig.ModuleConfig_StoreForwardConfig, + keyof Message | "isServer" + > { @IsBoolean() enabled: boolean;