Skip to content

Commit

Permalink
fix layout of webrtc
Browse files Browse the repository at this point in the history
  • Loading branch information
Sir-Thom committed Dec 13, 2023
1 parent fd3b7dd commit 2ed5ef8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
15 changes: 9 additions & 6 deletions src/views/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Notification from "../components/notification/notification";
import useServerData from "../utils/hooks/ServerData";

export default function Setting() {
const [saveButtonPressed, setSaveButtonPressed] = useState(false);
const { configData, serverError, apiIp } = useServerData();
const [error, setError] = useState<string | null>(null);
const [successMessage, setSuccessMessage] = useState("");
Expand Down Expand Up @@ -152,8 +153,6 @@ export default function Setting() {

console.log("API Setting from useEffect: " + apiIpValue);

console.log("API Setting from useEffect: " + apiIpValue);

const serverUrl = `http://${apiIpValue}/v3/config/global/get`;
console.log("serverUrl: " + serverUrl);
invoke("get_server_request", { url: serverUrl })
Expand Down Expand Up @@ -423,7 +422,7 @@ export default function Setting() {
recordSegmentDuration: parsedResponse.recordSegmentDuration || "1h",
recordDeleteAfter: parsedResponse.recordDeleteAfter || "24h"
});
setSuccessMessage("Settings saved successfully");


const apiIpValue = apiIp;
invoke("save_api_ip", { apiIp: apiIpValue }).then((res) => {
Expand Down Expand Up @@ -452,16 +451,19 @@ export default function Setting() {
console.log("patch setting: " + JSON.stringify(PatchData));
// Handle common actions
await updateStateAndHandleActions(PatchData);
setSaveButtonPressed(true);
setSuccessMessage("Settings saved successfully");
} catch (error) {
console.log("error: " + error.error);
if (error && error.error) {
// Display the specific error message
setError(error.error);
} else {
// Display a generic error message
setError("Unable to connect to the server." + error.toString());
setError("An error occurred: " + error.toString());
}
}


console.log("configData: " + JSON.stringify(configData));
}

Expand All @@ -482,6 +484,7 @@ export default function Setting() {
}

function handleCloseAlert(): void {
setSaveButtonPressed(false);
setSuccessMessage("");
}

Expand All @@ -501,7 +504,7 @@ export default function Setting() {

<div className="my-8 py-3.5 row-start-1 row-end-2 w-full col-start-4 col-span-9 h-full ">
<div className="mx-auto z-auto my-auto ">
{successMessage && (
{saveButtonPressed && successMessage && (
<SuccessAlert
message={successMessage}
OnClose={handleCloseAlert}
Expand Down
56 changes: 30 additions & 26 deletions src/views/serverSetting/webrtcSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ export default function WebrtcSetting({ settings, onSave, patchSetting }) {
const handleWebrtcICEServers = (event) => {
setWebrtcICEServers(event.target.value);
};

const handleWebrtcICEServers2 = (event) => {
setWebrtcICEServers2(event.target.value);
const { name, value } = event.target;

setWebrtcICEServers2((prevICEServers2) => ({
...prevICEServers2,
[name]: value,
}));
};

const handleWebrtcICEHostNAT1To1IPs = (event) => {
setWebrtcICEHostNAT1To1IPs(event.target.value);
};
Expand Down Expand Up @@ -230,22 +233,22 @@ export default function WebrtcSetting({ settings, onSave, patchSetting }) {
</h2>
</div>
<div className="col-span-1 grid grid-rows-5 gap-y-2">
<label className="mt-16 mb-16">Webrtc ICE Servers:</label>
<label className="mt-16 mb-32">Webrtc ICE Servers2:</label>
<label className="mt-28 mb-38">
<label className="mt-16 ">Webrtc ICE Servers:</label>
<label className="mt-16">Webrtc ICE Servers2:</label>
<label className="mt-24 w-full">
Webrtc ICE Host NAT 1 To 1 IPs:
</label>
<label className="mt-2">Webrtc ICE UDP Mux Address:</label>
<label className="mt-2 w-full">Webrtc ICE UDP Mux Address:</label>
<label className="mt-2">Webrtc ICE TCP Mux Address:</label>
</div>
<div className="col-span-2 grid grid-cols-2 gap-x-4">
<div className="col-span-2 grid grid-cols-2 grid-rows-5 gap-x-4">
<textarea
name="webrtcICEServers"
className="resize-none my-2 h-40 col-span-2 border border-gray-300 rounded-md focus:outline-none focus:border-blue-500 mx-2"
value={webrtcICEServers}
onChange={handleWebrtcICEServers}
/>
<div className="grid grid-cols-1 gap-x-4">
<div className="grid grid-cols-1 grid-rows-3 gap-x-4">
<div className="flex flex-col my-2">
<label className="my-2">URL:</label>
<input
Expand Down Expand Up @@ -278,23 +281,24 @@ export default function WebrtcSetting({ settings, onSave, patchSetting }) {
</div>
</div>
<textarea
name="webrtcICEHostNAT1To1IPs"
className="resize-none my-2 h-16 col-span-2 border border-gray-300 rounded-md focus:outline-none focus:border-blue-500 mx-2"
value={webrtcICEHostNAT1To1IPs}
onChange={handleWebrtcICEHostNAT1To1IPs}
/>
<input
type="text"
className="my-2 h-8 border border-gray-300 rounded-md focus:outline-none focus:border-blue-500 mx-2"
value={webrtcICEUDPMuxAddress}
onChange={handleWebrtcICEUDPMuxAddress}
/>
<input
type="text"
className="my-3 h-8 border border-gray-300 rounded-md focus:outline-none focus:border-blue-500 mx-2"
value={webrtcICETCPMuxAddress}
onChange={handleWebrtcICETCPMuxAddress}
/>
name="webrtcICEHostNAT1To1IPs"
className="resize-none my-20 h-16 col-span-2 border border-gray-300 rounded-md focus:outline-none focus:border-blue-500 mx-2"
value={webrtcICEHostNAT1To1IPs}
onChange={handleWebrtcICEHostNAT1To1IPs}
/>
<input
type="text"
className="my-2 h-8 border col-span-2 border-gray-300 rounded-md focus:outline-none focus:border-blue-500 mx-2"
value={webrtcICEUDPMuxAddress}
onChange={handleWebrtcICEUDPMuxAddress}
/>
<input
type="text"
className="my-2 h-8 border col-span-2 border-gray-300 rounded-md focus:outline-none focus:border-blue-500 mx-2"
value={webrtcICETCPMuxAddress}
onChange={handleWebrtcICETCPMuxAddress}
/>

</div>
</div>
);
Expand Down

0 comments on commit 2ed5ef8

Please sign in to comment.