Add node bounding box controll to map

This commit is contained in:
Sacha Weatherstone
2022-12-28 13:37:44 +11:00
parent b1f86466f0
commit f61d006a7a
5 changed files with 1255 additions and 67 deletions

View File

@@ -25,13 +25,13 @@ export interface ImportDialogProps {
export const ImportDialog = ({
isOpen,
close,
close
}: ImportDialogProps): JSX.Element => {
const [QRCodeURL, setQRCodeURL] = useState<string>("");
const [channelSet, setChannelSet] = useState<Protobuf.ChannelSet>();
const [validURL, setValidURL] = useState<boolean>(false);
const {connection} = useDevice()
const { connection } = useDevice();
useEffect(() => {
const base64String = QRCodeURL.split("e/#")[1]
@@ -48,29 +48,30 @@ export const ImportDialog = ({
}, [QRCodeURL]);
const apply = () => {
channelSet?.settings.map(((ch, index) => {
channelSet?.settings.map((ch, index) => {
connection?.setChannel({
channel: {
index,
role: index === 0 ? Protobuf.Channel_Role.PRIMARY: Protobuf.Channel_Role.SECONDARY,
role:
index === 0
? Protobuf.Channel_Role.PRIMARY
: Protobuf.Channel_Role.SECONDARY,
settings: ch
}
})
}))
});
});
if (channelSet?.loraConfig) {
connection?.setConfig({
config: {
payloadVariant: {
oneofKind: 'lora',
oneofKind: "lora",
lora: channelSet.loraConfig
}
}
})
});
}
}
};
return (
<Dialog
@@ -87,48 +88,55 @@ export const ImportDialog = ({
onChange={(e) => {
setQRCodeURL(e.target.value);
}}
/>{validURL && (
<div className="flex flex-col gap-3">
<div className="flex w-full gap-2">
<div className="w-36">
<Toggle
className="flex-col gap-2"
label="Use Preset?"
/>
{validURL && (
<div className="flex flex-col gap-3">
<div className="flex w-full gap-2">
<div className="w-36">
<Toggle
className="flex-col gap-2"
label="Use Preset?"
disabled
checked={channelSet?.loraConfig?.usePreset ?? true}
/>
</div>
<Select
label="Modem Preset"
disabled
value={channelSet?.loraConfig?.modemPreset}
>
{renderOptions(Protobuf.Config_LoRaConfig_ModemPreset)}
</Select>
</div>
<Select
label="Region"
disabled
checked={channelSet?.loraConfig?.usePreset ?? true}
/>
value={channelSet?.loraConfig?.region}
>
{renderOptions(Protobuf.Config_LoRaConfig_RegionCode)}
</Select>
<span className="text-md block font-medium text-gray-700">
Channels:
</span>
<div className="flex w-40 flex-col gap-1">
{channelSet?.settings.map((channel, index) => (
<Checkbox
key={index}
label={
channel.name.length
? channel.name
: `Channel: ${channel.id}`
}
/>
))}
</div>
</div>
<Select
label="Modem Preset"
disabled
value={channelSet?.loraConfig?.modemPreset}
>
{renderOptions(Protobuf.Config_LoRaConfig_ModemPreset)}
</Select>
</div>
<Select
label="Region"
disabled
value={channelSet?.loraConfig?.region}
>
{renderOptions(Protobuf.Config_LoRaConfig_RegionCode)}
</Select>
<span className="block text-md font-medium text-gray-700">Channels:</span>
<div className="flex w-40 flex-col gap-1">
{channelSet?.settings.map((channel, index) => (
<Checkbox
key={index}
label={
channel.name.length ? channel.name : `Channel: ${channel.id}`
}
/>
))}
</div>
</div>)}
<Button onClick={() => apply()} disabled={!validURL}>Apply</Button></div>
)}
<Button onClick={() => apply()} disabled={!validURL}>
Apply
</Button>
</div>
</Dialog>
);
};