Browse Source

Merge pull request #250 from Hunter275/issue-249-cors

add ability to enable/disable HTTPS connections
pull/435/head
Dan Ditomaso 1 year ago
committed by GitHub
parent
commit
98edd30360
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      src/components/PageComponents/Connect/HTTP.tsx

14
src/components/PageComponents/Connect/HTTP.tsx

@ -28,13 +28,9 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
},
});
const tlsEnabled = useWatch({
control,
name: "tls",
defaultValue: location.protocol === "https:",
});
const [connectionInProgress, setConnectionInProgress] = useState(false);
const [https, setHTTPS] = useState(false);
const onSubmit = handleSubmit(async (data) => {
setConnectionInProgress(true);
@ -46,7 +42,7 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
await connection.connect({
address: data.ip,
fetchInterval: 2000,
tls: data.tls,
tls: https,
});
setSelectedDevice(id);
@ -60,8 +56,7 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
<div className="flex h-48 flex-col gap-2">
<Label>IP Address/Hostname</Label>
<Input
// label="IP Address/Hostname"
prefix={tlsEnabled ? "https://" : "http://"}
prefix={https ? "https://" : "http://"}
placeholder="000.000.000.000 / meshtastic.local"
disabled={connectionInProgress}
{...register("ip")}
@ -71,8 +66,9 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
control={control}
render={({ field: { value, ...rest } }) => (
<>
<Label>Use TLS</Label>
<Label>Use HTTPS</Label>
<Switch
onCheckedChange={(checked) => {checked ? setHTTPS(true) : setHTTPS(false) }}
// label="Use TLS"
// description="Description"
disabled={

Loading…
Cancel
Save