Error & formating fixes

This commit is contained in:
Tilen Komel
2024-08-21 17:41:24 +02:00
parent 8bb0a96744
commit cf423620c4
9 changed files with 47 additions and 30 deletions
+1 -1
View File
@@ -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;
@@ -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",
},
],
},
]}
/>
)
/>
);
};
+1 -1
View File
@@ -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">