Merge branch 'meshtastic:master' into enable-map-control
This commit is contained in:
@@ -16,7 +16,19 @@ import {
|
|||||||
import { Link } from "@components/UI/Typography/Link.js";
|
import { Link } from "@components/UI/Typography/Link.js";
|
||||||
import { Subtle } from "@components/UI/Typography/Subtle.js";
|
import { Subtle } from "@components/UI/Typography/Subtle.js";
|
||||||
|
|
||||||
const tabs = [
|
export interface TabElementProps {
|
||||||
|
closeDialog: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TabManifest {
|
||||||
|
label: string;
|
||||||
|
element: React.FC<TabElementProps>;
|
||||||
|
disabled: boolean;
|
||||||
|
disabledMessage: string;
|
||||||
|
disabledLink?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tabs: TabManifest[] = [
|
||||||
{
|
{
|
||||||
label: "HTTP",
|
label: "HTTP",
|
||||||
element: HTTP,
|
element: HTTP,
|
||||||
@@ -74,7 +86,7 @@ export const NewDeviceDialog = ({
|
|||||||
{tab.disabledMessage}
|
{tab.disabledMessage}
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<tab.element />
|
<tab.element closeDialog={() => onOpenChange(false)} />
|
||||||
)}
|
)}
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface InputFieldProps<T> extends BaseFormBuilderProps<T> {
|
|||||||
properties?: {
|
properties?: {
|
||||||
prefix?: string;
|
prefix?: string;
|
||||||
suffix?: string;
|
suffix?: string;
|
||||||
|
step?: number;
|
||||||
action?: {
|
action?: {
|
||||||
icon: LucideIcon;
|
icon: LucideIcon;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
@@ -30,11 +31,12 @@ export function GenericInput<T extends FieldValues>({
|
|||||||
render={({ field: { value, onChange, ...rest } }) => (
|
render={({ field: { value, onChange, ...rest } }) => (
|
||||||
<Input
|
<Input
|
||||||
type={field.type}
|
type={field.type}
|
||||||
value={field.type === "number" ? parseInt(value) : value}
|
step={field.properties?.step}
|
||||||
|
value={field.type === "number" ? Number.parseInt(value) : value}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
onChange(
|
onChange(
|
||||||
field.type === "number"
|
field.type === "number"
|
||||||
? parseInt(e.target.value)
|
? Number.parseInt(e.target.value)
|
||||||
: e.target.value,
|
: e.target.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ export const Power = (): JSX.Element => {
|
|||||||
name: "adcMultiplierOverride",
|
name: "adcMultiplierOverride",
|
||||||
label: "ADC Multiplier Override ratio",
|
label: "ADC Multiplier Override ratio",
|
||||||
description: "Used for tweaking battery voltage reading",
|
description: "Used for tweaking battery voltage reading",
|
||||||
|
properties: {
|
||||||
|
step: 0.01,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "number",
|
type: "number",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { TabElementProps } from "@app/components/Dialog/NewDeviceDialog";
|
||||||
import { Button } from "@components/UI/Button.js";
|
import { Button } from "@components/UI/Button.js";
|
||||||
import { Mono } from "@components/generic/Mono.js";
|
import { Mono } from "@components/generic/Mono.js";
|
||||||
import { useAppStore } from "@core/stores/appStore.js";
|
import { useAppStore } from "@core/stores/appStore.js";
|
||||||
@@ -7,7 +8,7 @@ import { randId } from "@core/utils/randId.js";
|
|||||||
import { BleConnection, Constants } from "@meshtastic/js";
|
import { BleConnection, Constants } from "@meshtastic/js";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
|
||||||
export const BLE = (): JSX.Element => {
|
export const BLE = ({ closeDialog }: TabElementProps): JSX.Element => {
|
||||||
const [bleDevices, setBleDevices] = useState<BluetoothDevice[]>([]);
|
const [bleDevices, setBleDevices] = useState<BluetoothDevice[]>([]);
|
||||||
const { addDevice } = useDeviceStore();
|
const { addDevice } = useDeviceStore();
|
||||||
const { setSelectedDevice } = useAppStore();
|
const { setSelectedDevice } = useAppStore();
|
||||||
@@ -30,6 +31,8 @@ export const BLE = (): JSX.Element => {
|
|||||||
});
|
});
|
||||||
device.addConnection(connection);
|
device.addConnection(connection);
|
||||||
subscribeAll(device, connection);
|
subscribeAll(device, connection);
|
||||||
|
|
||||||
|
closeDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { TabElementProps } from "@app/components/Dialog/NewDeviceDialog";
|
||||||
import { Button } from "@components/UI/Button.js";
|
import { Button } from "@components/UI/Button.js";
|
||||||
import { Input } from "@components/UI/Input.js";
|
import { Input } from "@components/UI/Input.js";
|
||||||
import { Label } from "@components/UI/Label.js";
|
import { Label } from "@components/UI/Label.js";
|
||||||
@@ -9,7 +10,7 @@ import { randId } from "@core/utils/randId.js";
|
|||||||
import { HttpConnection } from "@meshtastic/js";
|
import { HttpConnection } from "@meshtastic/js";
|
||||||
import { Controller, useForm, useWatch } from "react-hook-form";
|
import { Controller, useForm, useWatch } from "react-hook-form";
|
||||||
|
|
||||||
export const HTTP = (): JSX.Element => {
|
export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
|
||||||
const { addDevice } = useDeviceStore();
|
const { addDevice } = useDeviceStore();
|
||||||
const { setSelectedDevice } = useAppStore();
|
const { setSelectedDevice } = useAppStore();
|
||||||
const { register, handleSubmit, control } = useForm<{
|
const { register, handleSubmit, control } = useForm<{
|
||||||
@@ -18,7 +19,7 @@ export const HTTP = (): JSX.Element => {
|
|||||||
}>({
|
}>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
ip: ["client.meshtastic.org", "localhost"].includes(
|
ip: ["client.meshtastic.org", "localhost"].includes(
|
||||||
window.location.hostname,
|
window.location.hostname
|
||||||
)
|
)
|
||||||
? "meshtastic.local"
|
? "meshtastic.local"
|
||||||
: window.location.hostname,
|
: window.location.hostname,
|
||||||
@@ -45,6 +46,8 @@ export const HTTP = (): JSX.Element => {
|
|||||||
});
|
});
|
||||||
device.addConnection(connection);
|
device.addConnection(connection);
|
||||||
subscribeAll(device, connection);
|
subscribeAll(device, connection);
|
||||||
|
|
||||||
|
closeDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { TabElementProps } from "@app/components/Dialog/NewDeviceDialog";
|
||||||
import { Button } from "@components/UI/Button.js";
|
import { Button } from "@components/UI/Button.js";
|
||||||
import { Mono } from "@components/generic/Mono.js";
|
import { Mono } from "@components/generic/Mono.js";
|
||||||
import { useAppStore } from "@core/stores/appStore.js";
|
import { useAppStore } from "@core/stores/appStore.js";
|
||||||
@@ -7,7 +8,7 @@ import { randId } from "@core/utils/randId.js";
|
|||||||
import { SerialConnection } from "@meshtastic/js";
|
import { SerialConnection } from "@meshtastic/js";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
|
||||||
export const Serial = (): JSX.Element => {
|
export const Serial = ({ closeDialog }: TabElementProps): JSX.Element => {
|
||||||
const [serialPorts, setSerialPorts] = useState<SerialPort[]>([]);
|
const [serialPorts, setSerialPorts] = useState<SerialPort[]>([]);
|
||||||
const { addDevice } = useDeviceStore();
|
const { addDevice } = useDeviceStore();
|
||||||
const { setSelectedDevice } = useAppStore();
|
const { setSelectedDevice } = useAppStore();
|
||||||
@@ -40,6 +41,8 @@ export const Serial = (): JSX.Element => {
|
|||||||
.catch((e: Error) => console.log(`Unable to Connect: ${e.message}`));
|
.catch((e: Error) => console.log(`Unable to Connect: ${e.message}`));
|
||||||
device.addConnection(connection);
|
device.addConnection(connection);
|
||||||
subscribeAll(device, connection);
|
subscribeAll(device, connection);
|
||||||
|
|
||||||
|
closeDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ export const MQTT = (): JSX.Element => {
|
|||||||
name: "proxyToClientEnabled",
|
name: "proxyToClientEnabled",
|
||||||
label: "Proxy to Client Enabled",
|
label: "Proxy to Client Enabled",
|
||||||
description:
|
description:
|
||||||
"Whether to proxy MQTT packets to the client (for example to Home Assistant)",
|
"Use the client's internet connection for MQTT (feature only active in mobile apps)",
|
||||||
disabledBy: [
|
disabledBy: [
|
||||||
{
|
{
|
||||||
fieldName: "enabled",
|
fieldName: "enabled",
|
||||||
|
|||||||
Reference in New Issue
Block a user