diff --git a/package.json b/package.json index c0848fcc..de402734 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.24.2", + "version": "0.24.3", "private": true, "scripts": { "dev": "react-scripts start", diff --git a/src/components/VersionViewer/VersionViewer.tsx b/src/components/VersionViewer/VersionViewer.tsx index b2736924..fdd05ece 100644 --- a/src/components/VersionViewer/VersionViewer.tsx +++ b/src/components/VersionViewer/VersionViewer.tsx @@ -5,10 +5,10 @@ import { ReactElement } from "react"; export default function VersionViewer(): ReactElement { return (
-

- {isProduction ? "P" : "D"} - {packageJSON?.version} - {envApplication ? "A" : "R"} +

+ {isProduction ? "P" : "D"} + {envApplication ? "A" : "R"} + {" - "}v{packageJSON?.version}

); diff --git a/src/contexts/RobotContext.tsx b/src/contexts/RobotContext.tsx index b7bb6a70..f0cb9303 100644 --- a/src/contexts/RobotContext.tsx +++ b/src/contexts/RobotContext.tsx @@ -44,6 +44,8 @@ export default ({ children }: any) => { const [topicList, setTopicList] = useState([]); const [isRosConnected, setIsRosConnected] = useState(null); + const [isVDIConnected, setIsVDIConnected] = useState(null); + // Main Functions useEffect(() => { if ( @@ -248,6 +250,44 @@ export default ({ children }: any) => { } // ROS Topic Setter + // VDI Test Connection + useEffect(() => { + const vdiClient = + responseRobot?.vdiIngressEndpoint && + isRobotReady && + isSettedCookie && + isVDIConnected === null + ? new WebSocket( + responseRobot?.vdiIngressEndpoint + "ws?password=admin" || "", + ) + : null; + + vdiClient?.addEventListener("open", () => { + setIsVDIConnected(true); + }); + + vdiClient?.addEventListener("error", () => { + setIsVDIConnected(false); + }); + + vdiClient?.addEventListener("close", () => { + setIsVDIConnected(false); + }); + + function closeConnection() { + typeof isVDIConnected === "boolean" && vdiClient?.close(); + } + + closeConnection(); + + return closeConnection(); + }, [isRobotReady, isSettedCookie, isVDIConnected, responseRobot]); + + useEffect(() => { + console.log("isVDIConnected", isVDIConnected); + }, [isVDIConnected]); + // VDI Test Connection + function handleGetOrganization() { getOrganization( {