Skip to content

Commit

Permalink
refactor(hidden-frame): 🎉 update hidden frame logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Aug 9, 2023
1 parent b0c900e commit 92ddf5c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui",
"version": "0.10.3",
"version": "0.10.4",
"private": true,
"dependencies": {
"@emotion/css": "^11.10.6",
Expand Down
33 changes: 14 additions & 19 deletions src/components/HiddenFrame/HiddenFrame.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
import React, { ReactElement, useEffect, useState } from "react";
import React, { Fragment, ReactElement, useEffect, useState } from "react";

interface IHiddenFrame {
url: string;
}

export default function HiddenFrame({ url }: IHiddenFrame): ReactElement {
const [connection, setConnection] = useState<boolean>(true);
const [active, setActive] = useState<boolean>(true);

useEffect(() => {
setInterval(() => {
setConnection(false);
console.log("frame active");

setTimeout(() => {
setConnection(true);
console.log("frame deactive");
}, 5000);
}, 100000);
}, []);
url && setActive((prev) => !prev);
}, 30000);
}, [active, url]);

return (
<iframe
title="iframe"
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-top-navigation allow-downloads"
allow="microphone; camera; usb; midi; encrypted-media; autoplay; clipboard-write; clipboard-read"
className="absolute -top-[9999px] grid-cols-1 gap-6"
src={connection ? url || "" : ""}
onLoad={() => console.log("iframe loaded")}
/>
<Fragment>
<iframe
title="iframe"
allow="clipboard-read"
className="absolute grid-cols-1 gap-6"
src={url ? url.replace("wss://", "https://") + "health" : ""}
onLoad={() => console.log("iframe loaded")}
/>
</Fragment>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function RobotConnectionsViewer({
<div className="flex gap-6">
{!envOnPremise && (
<div className="flex gap-1">
<span>ROS: </span>
<span className="text-xs font-semibold">ROS: </span>
<StateCell
state={
isRosConnected === true
Expand All @@ -60,15 +60,15 @@ export default function RobotConnectionsViewer({
</div>
)}
<div className="flex gap-1">
<span>IDE: </span>
<span className="text-xs font-semibold">IDE: </span>
<StateCell
state={
ide === true ? "Connected" : ide === false ? "Warning" : "Waiting"
}
/>
</div>
<div className="flex gap-1">
<span>VDI: </span>
<span className="text-xs font-semibold">VDI: </span>
<StateCell
state={
isVDIConnected === true
Expand Down
2 changes: 2 additions & 0 deletions src/pages/RobotPage/RobotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useAppSelector } from "../../hooks/redux";
import { useParams } from "react-router-dom";
import Overview from "./Overview/Overview";
import useMain from "../../hooks/useMain";
import HiddenFrame from "../../components/HiddenFrame/HiddenFrame";

export default function RobotPage(): ReactElement {
const [responseRobot, setResponseRobot] = useState<any>(undefined);
Expand Down Expand Up @@ -353,6 +354,7 @@ export default function RobotPage(): ReactElement {
topicList={topicList}
setTopicList={setTopicList}
/>
<HiddenFrame url={responseRobot?.vdiIngressEndpoint} />
</div>
);
}

0 comments on commit 92ddf5c

Please sign in to comment.