Browse Source

Error & formating fixes

pull/275/head
Tilen Komel 2 years ago
parent
commit
cf423620c4
  1. 2
      src/components/Form/DynamicForm.tsx
  2. 40
      src/components/PageComponents/Config/Security.tsx
  3. 2
      src/components/Sidebar.tsx
  4. 8
      src/pages/Map.tsx
  5. 6
      src/validation/config/bluetooth.ts
  6. 3
      src/validation/config/lora.ts
  7. 3
      src/validation/config/power.ts
  8. 8
      src/validation/config/security.ts
  9. 5
      src/validation/moduleConfig/storeForward.ts

2
src/components/Form/DynamicForm.tsx

@ -66,7 +66,7 @@ export function DynamicForm<T extends FieldValues>({
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;

40
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<string>(
fromByteArray(config.security?.adminKey ?? new Uint8Array(0))
fromByteArray(config.security?.adminKey ?? new Uint8Array(0)),
);
const [privateKey, setPrivateKey] = useState<string>(
fromByteArray(config.security?.privateKey ?? new Uint8Array(0))
fromByteArray(config.security?.privateKey ?? new Uint8Array(0)),
);
const [publicKey, setPublicKey] = useState<string>(
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 (
<DynamicForm<SecurityValidation>
@ -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",
},
],
},
]}
/>
)
/>
);
};

2
src/components/Sidebar.tsx

@ -85,7 +85,7 @@ export const Sidebar = ({ children }: SidebarProps): JSX.Element => {
<div className="flex items-center">
<ZapIcon size={24} viewBox={"0 0 36 24"} />
<Subtle>
{myNode?.deviceMetrics?.voltage.toPrecision(3) ?? "UNK"} volts
{myNode?.deviceMetrics?.voltage?.toPrecision(3) ?? "UNK"} volts
</Subtle>
</div>
<div className="flex items-center">

8
src/pages/Map.tsx

@ -144,8 +144,8 @@ export const MapPage = (): JSX.Element => {
{waypoints.map((wp) => (
<Marker
key={wp.id}
longitude={wp.longitudeI / 1e7}
latitude={wp.latitudeI / 1e7}
longitude={(wp.longitudeI ?? 0) / 1e7}
latitude={(wp.latitudeI ?? 0) / 1e7}
anchor="bottom"
>
<div>
@ -163,8 +163,8 @@ export const MapPage = (): JSX.Element => {
return (
<Marker
key={node.num}
longitude={node.position.longitudeI / 1e7}
latitude={node.position.latitudeI / 1e7}
longitude={(node.position.longitudeI ?? 0) / 1e7}
latitude={(node.position.latitudeI ?? 0) / 1e7}
style={{ filter: darkMode ? "invert(1)" : "" }}
anchor="bottom"
onClick={() => {

6
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<Protobuf.Config.Config_BluetoothConfig, keyof Message>
implements
Omit<
Protobuf.Config.Config_BluetoothConfig,
keyof Message | "deviceLoggingEnabled"
>
{
@IsBoolean()
enabled: boolean;

3
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<Protobuf.Config.Config_LoRaConfig, keyof Message>
implements
Omit<Protobuf.Config.Config_LoRaConfig, keyof Message | "paFanDisabled">
{
@IsBoolean()
usePreset: boolean;

3
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<Protobuf.Config.Config_PowerConfig, keyof Message>
implements
Omit<Protobuf.Config.Config_PowerConfig, keyof Message | "powermonEnables">
{
@IsBoolean()
isPowerSaving: boolean;

8
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<Protobuf.Config.Config_SecurityConfig, keyof Message | "adminKey" | "privateKey" | "publicKey">
implements
Omit<
Protobuf.Config.Config_SecurityConfig,
keyof Message | "adminKey" | "privateKey" | "publicKey"
>
{
@IsBoolean()
adminChannelEnabled: boolean;
@ -28,4 +32,4 @@ export class SecurityValidation
@IsBoolean()
serialEnabled: boolean;
}
}

5
src/validation/moduleConfig/storeForward.ts

@ -4,7 +4,10 @@ import { IsBoolean, IsInt } from "class-validator";
export class StoreForwardValidation
implements
Omit<Protobuf.ModuleConfig.ModuleConfig_StoreForwardConfig, keyof Message>
Omit<
Protobuf.ModuleConfig.ModuleConfig_StoreForwardConfig,
keyof Message | "isServer"
>
{
@IsBoolean()
enabled: boolean;

Loading…
Cancel
Save