Skip to content

Commit

Permalink
feat(version): release 0.25.9 version
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Dec 21, 2023
1 parent 81d58de commit f3b9b7c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 53 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<img src="https://img.shields.io/badge/nodejs-18.18.2-dgreen" alt="node">
</a>
<a href="https://github.com/robolaunch/ui/releases">
<img src="https://img.shields.io/badge/release-v0.24.8-red" alt="release">
<img src="https://img.shields.io/badge/release-v0.24.9-red" alt="release">
</a>
<a href="#">
<img src="https://img.shields.io/badge/language-typescript-blue" alt="language">
Expand Down
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.25.8",
"version": "0.25.9",
"private": true,
"scripts": {
"dev": "react-scripts start",
Expand Down
51 changes: 34 additions & 17 deletions src/components/RosTopicListWidget/RosTopicListWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement, useEffect, useState } from "react";
import { ReactElement, useEffect, useState } from "react";
import ROSLIB from "roslib";
import { AiOutlineUnorderedList } from "react-icons/ai";
import RosWidgetLayout from "../../layouts/RosWidgetLayout";
Expand All @@ -14,24 +14,41 @@ export default function RosTopicListWidget({
id,
handleRemoveWidget,
}: IRosTopicListWidget): ReactElement {
const [topicList, setTopicList] = useState<string[]>([]);
const [topicList, setTopicList] = useState<any>([]);

useEffect(() => {
const getTopics = new ROSLIB.Service({
ros: ros,
name: "/rosapi/topics",
serviceType: "rosapi/Topics",
});
// @ts-ignore
const request = new ROSLIB.ServiceRequest();
getTopics.callService(request, function (result) {
result.topics.map((topic: string, key: number) =>
setTopicList((prev: any) => [
...prev,
{ name: topic, type: result.types[key] },
]),
);
});
function getTopics() {
if (ros) {
const getTopics = new ROSLIB.Service({
ros: ros,
name: "/rosapi/topics",
serviceType: "rosapi/Topics",
});

const request = new ROSLIB.ServiceRequest({});
getTopics.callService(request, async function (result) {
const resultTopicsList = await result?.topics?.map(
(topic: string, key: number) => {
return {
name: topic,
type: result?.types[key],
};
},
);

if (resultTopicsList?.length !== topicList?.length) {
setTopicList(resultTopicsList);
}
});
}
}

getTopics();
const timer = setInterval(() => getTopics(), 10000);
return () => {
clearInterval(timer);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ros]);

return (
Expand Down
67 changes: 34 additions & 33 deletions src/contexts/RobotContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useFunctions from "../hooks/useFunctions";
import { useParams } from "react-router-dom";
import useMain from "../hooks/useMain";
import ROSLIB from "roslib";
import { useAppSelector } from "../hooks/redux";

export const RobotContext: any = createContext<any>(null);

Expand Down Expand Up @@ -53,6 +54,8 @@ export default ({ children }: any) => {
vdi: null,
});

const { urls } = useAppSelector((state) => state.robot);

function handleReducer(state: any, action: any) {
switch (action.type) {
case "ros":
Expand Down Expand Up @@ -221,11 +224,11 @@ export default ({ children }: any) => {
isSettedCookie &&
responseRobot?.bridgeIngressEndpoint?.split("://")[0] === "wss"
? new ROSLIB.Ros({
url: responseRobot?.bridgeIngressEndpoint,
url: urls?.ros || responseRobot?.bridgeIngressEndpoint,
})
: null;

setRos(ros);
setRos(rosClient);

rosClient?.on("connection", function () {
connectionsReducer?.ros === null &&
Expand All @@ -249,43 +252,41 @@ export default ({ children }: any) => {

// ROS Topic Setter
useEffect(() => {
!envApplication && getTopics();
function getTopics() {
if (ros && isSettedCookie && !envApplication) {
const getTopics = new ROSLIB.Service({
ros: ros,
name: "/rosapi/topics",
serviceType: "rosapi/Topics",
});

const timer = setInterval(() => {
!envApplication && getTopics();
}, 10000);
const request = new ROSLIB.ServiceRequest({});
getTopics.callService(request, async function (result) {
const resultTopicsList = await result?.topics?.map(
(topic: string, key: number) => {
return {
name: topic,
type: result?.types[key],
};
},
);

if (resultTopicsList?.length !== topicList?.length) {
setTopicList(resultTopicsList);
}
});
}
}

getTopics();

const timer = setInterval(() => getTopics(), 10000);

return () => {
clearInterval(timer);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ros]);

function getTopics() {
if (ros && isSettedCookie && !envApplication) {
const getTopics = new ROSLIB.Service({
ros: ros,
name: "/rosapi/topics",
serviceType: "rosapi/Topics",
});
// @ts-ignore
const request = new ROSLIB.ServiceRequest();
getTopics.callService(request, async function (result) {
const resultTopicsList = await result?.topics?.map(
(topic: string, key: number) => {
return {
name: topic,
type: result?.types[key],
};
},
);

if (resultTopicsList?.length !== topicList?.length) {
setTopicList(resultTopicsList);
}
});
}
}
}, [ros, isSettedCookie]);
// ROS Topic Setter

// VDI - vIDE Test Connection
Expand Down
2 changes: 1 addition & 1 deletion src/toolkit/RobotSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export const RobotSlice = createSlice({
urls: {
vdi: isProduction ? "" : "ws://localhost:8080/",
ide: isProduction ? "" : "",
ros: isProduction ? "" : "",
ros: isProduction ? "" : "ws://172.16.44.189:9090",
},
},
reducers: {},
Expand Down

0 comments on commit f3b9b7c

Please sign in to comment.