Use new js lib version
This commit is contained in:
@@ -214,7 +214,7 @@ export const CommandPalette = (): JSX.Element => {
|
||||
icon: TrashIcon,
|
||||
action() {
|
||||
if (connection) {
|
||||
void toast.promise(connection.resetPeers({}), {
|
||||
void toast.promise(connection.resetPeers(), {
|
||||
loading: "Resetting...",
|
||||
success: "Succesfully reset peers",
|
||||
error: "No response received"
|
||||
|
||||
@@ -36,13 +36,11 @@ export const RebootDialog = ({
|
||||
action={{
|
||||
icon: <ClockIcon className="w-4" />,
|
||||
action() {
|
||||
connection?.reboot({
|
||||
time: time * 60,
|
||||
callback: async () => {
|
||||
setRebootDialogOpen(false);
|
||||
await Promise.resolve();
|
||||
}
|
||||
});
|
||||
connection
|
||||
?.reboot({
|
||||
time: time * 60
|
||||
})
|
||||
.then(() => setRebootDialogOpen(false));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
@@ -50,13 +48,11 @@ export const RebootDialog = ({
|
||||
className="w-24"
|
||||
iconBefore={<ArrowPathIcon className="w-4" />}
|
||||
onClick={() => {
|
||||
connection?.reboot({
|
||||
time: 0,
|
||||
callback: async () => {
|
||||
setRebootDialogOpen(false);
|
||||
await Promise.resolve();
|
||||
}
|
||||
});
|
||||
connection
|
||||
?.reboot({
|
||||
time: 0
|
||||
})
|
||||
.then(() => setRebootDialogOpen(false));
|
||||
}}
|
||||
>
|
||||
Now
|
||||
|
||||
@@ -36,13 +36,11 @@ export const ShutdownDialog = ({
|
||||
action={{
|
||||
icon: <ClockIcon className="w-4" />,
|
||||
action() {
|
||||
connection?.shutdown({
|
||||
time: time * 60,
|
||||
callback: async () => {
|
||||
setShutdownDialogOpen(false);
|
||||
await Promise.resolve();
|
||||
}
|
||||
});
|
||||
connection
|
||||
?.shutdown({
|
||||
time: time * 60
|
||||
})
|
||||
.then(() => setShutdownDialogOpen(false));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
@@ -50,13 +48,11 @@ export const ShutdownDialog = ({
|
||||
className="w-24"
|
||||
iconBefore={<PowerIcon className="w-4" />}
|
||||
onClick={() => {
|
||||
connection?.shutdown({
|
||||
time: 0,
|
||||
callback: async () => {
|
||||
setShutdownDialogOpen(false);
|
||||
await Promise.resolve();
|
||||
}
|
||||
});
|
||||
connection
|
||||
?.shutdown({
|
||||
time: 0
|
||||
})
|
||||
.then(() => setShutdownDialogOpen(false));
|
||||
}}
|
||||
>
|
||||
Now
|
||||
|
||||
@@ -65,25 +65,23 @@ export const Channel = ({ channel }: SettingsPanelProps): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setChannel({
|
||||
channel: {
|
||||
role:
|
||||
channel?.role === Protobuf.Channel_Role.PRIMARY
|
||||
? Protobuf.Channel_Role.PRIMARY
|
||||
: data.enabled
|
||||
? Protobuf.Channel_Role.SECONDARY
|
||||
: Protobuf.Channel_Role.DISABLED,
|
||||
index: channel?.index,
|
||||
settings: {
|
||||
...data,
|
||||
psk: toByteArray(data.psk ?? "")
|
||||
connection
|
||||
.setChannel({
|
||||
channel: {
|
||||
role:
|
||||
channel?.role === Protobuf.Channel_Role.PRIMARY
|
||||
? Protobuf.Channel_Role.PRIMARY
|
||||
: data.enabled
|
||||
? Protobuf.Channel_Role.SECONDARY
|
||||
: Protobuf.Channel_Role.DISABLED,
|
||||
index: channel?.index,
|
||||
settings: {
|
||||
...data,
|
||||
psk: toByteArray(data.psk ?? "")
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: (): Promise<void> => {
|
||||
reset({ ...data });
|
||||
return Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Channel",
|
||||
|
||||
@@ -35,18 +35,16 @@ export const Bluetooth = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "bluetooth",
|
||||
bluetooth: data
|
||||
connection
|
||||
.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "bluetooth",
|
||||
bluetooth: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Bluetooth Config, Restarting Node",
|
||||
|
||||
@@ -34,18 +34,16 @@ export const Device = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "device",
|
||||
device: data
|
||||
connection
|
||||
.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "device",
|
||||
device: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Device Config, Restarting Node",
|
||||
|
||||
@@ -34,18 +34,16 @@ export const Display = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "display",
|
||||
display: data
|
||||
connection
|
||||
.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "display",
|
||||
display: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Display Config, Restarting Node",
|
||||
|
||||
@@ -42,18 +42,16 @@ export const LoRa = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "lora",
|
||||
lora: data
|
||||
connection
|
||||
.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "lora",
|
||||
lora: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved LoRa Config, Restarting Node",
|
||||
|
||||
@@ -63,13 +63,9 @@ export const Network = (): JSX.Element => {
|
||||
oneofKind: "network",
|
||||
network: Protobuf.Config_NetworkConfig.create(data)
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
})
|
||||
.catch((e) => console.log(e)),
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Network Config, Restarting Node",
|
||||
|
||||
@@ -60,17 +60,15 @@ export const Position = (): JSX.Element => {
|
||||
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setPosition({
|
||||
position: Protobuf.Position.create({
|
||||
altitude: fixedAlt,
|
||||
latitudeI: fixedLat * 1e7,
|
||||
longitudeI: fixedLng * 1e7
|
||||
}),
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
connection
|
||||
.setPosition({
|
||||
position: Protobuf.Position.create({
|
||||
altitude: fixedAlt,
|
||||
latitudeI: fixedLat * 1e7,
|
||||
longitudeI: fixedLng * 1e7
|
||||
})
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Position Config, Restarting Node",
|
||||
@@ -79,18 +77,16 @@ export const Position = (): JSX.Element => {
|
||||
);
|
||||
if (configHasChanged) {
|
||||
void toast.promise(
|
||||
connection.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "position",
|
||||
position: rest
|
||||
connection
|
||||
.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "position",
|
||||
position: rest
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Position Config, Restarting Node",
|
||||
|
||||
@@ -32,18 +32,16 @@ export const Power = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "power",
|
||||
power: data
|
||||
connection
|
||||
.setConfig({
|
||||
config: {
|
||||
payloadVariant: {
|
||||
oneofKind: "power",
|
||||
power: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Power Config, Restarting Node",
|
||||
|
||||
@@ -42,13 +42,11 @@ export const User = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection && myNode?.data.user) {
|
||||
void toast.promise(
|
||||
connection.setOwner({
|
||||
owner: { ...myNode.data.user, ...data },
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
connection
|
||||
.setOwner({
|
||||
owner: { ...myNode.data.user, ...data }
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved User, Restarting Node",
|
||||
|
||||
@@ -31,17 +31,19 @@ export const Message = ({
|
||||
|
||||
return lastMsgSameUser ? (
|
||||
<div className="ml-4 flex">
|
||||
{message.ack ? (
|
||||
{message.state === "ack" ? (
|
||||
<CheckCircleIcon className="my-auto h-4 text-textSecondary" />
|
||||
) : (
|
||||
) : message.state === "waiting" ? (
|
||||
<EllipsisHorizontalCircleIcon className="my-auto h-4 text-textSecondary" />
|
||||
) : (
|
||||
<ExclamationCircleIcon className="my-auto h-4 text-textSecondary" />
|
||||
)}
|
||||
{"waypointID" in message ? (
|
||||
<WaypointMessage waypointID={message.waypointID} />
|
||||
) : (
|
||||
<span
|
||||
className={`ml-4 border-l-2 border-l-backgroundPrimary pl-2 ${
|
||||
message.ack ? "text-textPrimary" : "text-textSecondary"
|
||||
message.state === "ack" ? "text-textPrimary" : "text-textSecondary"
|
||||
}`}
|
||||
>
|
||||
{message.text}
|
||||
@@ -69,17 +71,21 @@ export const Message = ({
|
||||
</div>
|
||||
<div className="flex">
|
||||
{/* <ExclamationCircleIcon /> */}
|
||||
{message.ack ? (
|
||||
{message.state === "ack" ? (
|
||||
<CheckCircleIcon className="my-auto h-4 text-textSecondary" />
|
||||
) : (
|
||||
) : message.state === "waiting" ? (
|
||||
<EllipsisHorizontalCircleIcon className="my-auto h-4 text-textSecondary" />
|
||||
) : (
|
||||
<ExclamationCircleIcon className="my-auto h-4 text-textSecondary" />
|
||||
)}
|
||||
{"waypointID" in message ? (
|
||||
<WaypointMessage waypointID={message.waypointID} />
|
||||
) : (
|
||||
<span
|
||||
className={`ml-4 border-l-2 border-l-backgroundPrimary pl-2 ${
|
||||
message.ack ? "text-textPrimary" : "text-textSecondary"
|
||||
message.state === "ack"
|
||||
? "text-textPrimary"
|
||||
: "text-textSecondary"
|
||||
}`}
|
||||
>
|
||||
{message.text}
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface MessageInputProps {
|
||||
}
|
||||
|
||||
export const MessageInput = ({ channel }: MessageInputProps): JSX.Element => {
|
||||
const { connection, ackMessage } = useDevice();
|
||||
const { connection, setMessageState } = useDevice();
|
||||
|
||||
const { register, handleSubmit } = useForm<{
|
||||
message: string;
|
||||
@@ -24,16 +24,17 @@ export const MessageInput = ({ channel }: MessageInputProps): JSX.Element => {
|
||||
}
|
||||
});
|
||||
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
void connection?.sendText({
|
||||
text: data.message,
|
||||
wantAck: true,
|
||||
channel: channel.config.index as Types.ChannelNumber,
|
||||
callback: (id) => {
|
||||
ackMessage(channel.config.index, id);
|
||||
return Promise.resolve();
|
||||
}
|
||||
});
|
||||
const onSubmit = handleSubmit(async (data) => {
|
||||
await connection
|
||||
?.sendText({
|
||||
text: data.message,
|
||||
wantAck: true,
|
||||
channel: channel.config.index as Types.ChannelNumber
|
||||
})
|
||||
.then((id) => setMessageState(channel.config.index, id, "ack"))
|
||||
.catch((e: Types.PacketError) =>
|
||||
setMessageState(channel.config.index, e.id, e.error)
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@@ -40,18 +40,16 @@ export const CannedMessage = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "cannedMessage",
|
||||
cannedMessage: data
|
||||
connection
|
||||
.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "cannedMessage",
|
||||
cannedMessage: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Canned Message Config, Restarting Node",
|
||||
|
||||
@@ -30,18 +30,16 @@ export const ExternalNotification = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "externalNotification",
|
||||
externalNotification: data
|
||||
connection
|
||||
.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "externalNotification",
|
||||
externalNotification: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved External Notification Config, Restarting Node",
|
||||
|
||||
@@ -37,18 +37,16 @@ export const MQTT = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "mqtt",
|
||||
mqtt: data
|
||||
connection
|
||||
.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "mqtt",
|
||||
mqtt: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved MQTT Config, Restarting Node",
|
||||
|
||||
@@ -31,18 +31,16 @@ export const RangeTest = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "rangeTest",
|
||||
rangeTest: data
|
||||
connection
|
||||
.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "rangeTest",
|
||||
rangeTest: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Range Test Config, Restarting Node",
|
||||
|
||||
@@ -31,18 +31,16 @@ export const Serial = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "serial",
|
||||
serial: data
|
||||
connection
|
||||
.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "serial",
|
||||
serial: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Serial Config, Restarting Node",
|
||||
|
||||
@@ -31,18 +31,16 @@ export const StoreForward = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "storeForward",
|
||||
storeForward: data
|
||||
connection
|
||||
.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "storeForward",
|
||||
storeForward: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
})
|
||||
.then(() => reset({ ...data })),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Store & Forward Config, Restarting Node",
|
||||
|
||||
@@ -31,18 +31,19 @@ export const Telemetry = (): JSX.Element => {
|
||||
const onSubmit = handleSubmit((data) => {
|
||||
if (connection) {
|
||||
void toast.promise(
|
||||
connection.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "telemetry",
|
||||
telemetry: data
|
||||
connection
|
||||
.setModuleConfig({
|
||||
moduleConfig: {
|
||||
payloadVariant: {
|
||||
oneofKind: "telemetry",
|
||||
telemetry: data
|
||||
}
|
||||
}
|
||||
},
|
||||
callback: async () => {
|
||||
})
|
||||
.then(async () => {
|
||||
reset({ ...data });
|
||||
await Promise.resolve();
|
||||
}
|
||||
}),
|
||||
}),
|
||||
{
|
||||
loading: "Saving...",
|
||||
success: "Saved Telemetry Config, Restarting Node",
|
||||
|
||||
Reference in New Issue
Block a user