Skip to content

Commit

Permalink
feat(version): release 0.25.7 version
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Dec 21, 2023
1 parent ee33398 commit d1fe89a
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 37 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.25.6",
"version": "0.25.7",
"private": true,
"scripts": {
"dev": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Connections/Connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function Connections(): ReactElement {
/>
<StateCell
state={
connectionsReducer?.physicalIDE === undefined
connectionsReducer?.physicalIDE === null
? "Waiting"
: connectionsReducer?.physicalIDE
? "Connected"
Expand Down
32 changes: 32 additions & 0 deletions src/contexts/FunctionsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
IgetNamespaces,
IgetOrganization,
IgetPhysicalFleet,
IgetPhysicalInstance,
IgetPhysicalInstances,
IgetRobot,
IgetRoboticsCloud,
Expand Down Expand Up @@ -340,6 +341,36 @@ export default ({ children }: any) => {
});
}

async function getPhysicalInstance(
values: IgetPhysicalInstance,
parameters?: ImultipleGetParameters,
) {
await dispatch(
getAllPhysicalInstances({
organizationId: values?.organizationId,
roboticsCloudName: values?.roboticsCloudName,
instanceId: values?.instanceId,
region: values?.region,
}),
).then((responsePhysicalInstances: any) => {
if (
responsePhysicalInstances?.payload?.data?.[0]?.roboticsClouds?.[0]
?.cloudInstances?.[0]?.robolaunchPhysicalInstances
) {
parameters?.setResponse &&
parameters?.setResponse(
responsePhysicalInstances?.payload?.data[0]?.roboticsClouds[0]?.cloudInstances[0]?.robolaunchPhysicalInstances?.find(
(physicalInstance: any) =>
physicalInstance?.name === values?.physicalInstanceName,
) || {},
);
} else {
parameters?.ifErrorNavigateTo404 && navigateTo404();
parameters?.setResponse && parameters?.setResponse({});
}
});
}

async function getInstance(
values: IgetInstance,
parameters?: IsingleGetParameters,
Expand Down Expand Up @@ -1327,6 +1358,7 @@ export default ({ children }: any) => {
getRoboticsCloud,
getInstances,
getPhysicalInstances,
getPhysicalInstance,
getInstance,
getFleets,
getFleet,
Expand Down
87 changes: 52 additions & 35 deletions src/contexts/RobotContext.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { useEffect, createContext, useState, useReducer } from "react";
import { IrobotTab } from "../interfaces/robotInterfaces";
import { envApplication, isProduction } from "../helpers/envProvider";
import { envApplication } from "../helpers/envProvider";
import useFunctions from "../hooks/useFunctions";
import { useParams } from "react-router-dom";
import useMain from "../hooks/useMain";
import ROSLIB from "roslib";
import { AxiosResponse } from "axios";
import axiosInterceptorOpenApi from "../middlewares/axios.interceptor.openapi";

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

Expand All @@ -16,6 +14,7 @@ export default ({ children }: any) => {
getOrganization,
getRoboticsCloud,
getInstance,
getPhysicalInstance,
getFleet,
getNamespace,
getRobot,
Expand All @@ -30,6 +29,8 @@ export default ({ children }: any) => {

const [activeTab, setActiveTab] = useState<IrobotTab["name"]>("Overview");

const [responsePhysicalInstance, setResponsePhysicalInstance] =
useState<any>(undefined);
const [responseRobot, setResponseRobot] = useState<any>(undefined);
const [responseBuildManager, setResponseBuildManager] =
useState<any>(undefined);
Expand Down Expand Up @@ -98,6 +99,8 @@ export default ({ children }: any) => {
!envApplication && handleGetBuildManager();
} else if (!responseLaunchManagers) {
!envApplication && handleGetLaunchManagers();
} else if (responseRobot?.physicalInstance && !responsePhysicalInstance) {
handleGetPhysicalInstance();
}

const timerResponseRobot = setInterval(() => {
Expand Down Expand Up @@ -286,25 +289,29 @@ export default ({ children }: any) => {
}
// ROS Topic Setter

// VDI Test Connection
// VDI - vIDE Test Connection
useEffect(() => {
const vdiClient: WebSocket | null =
isSettedCookie && connectionsReducer?.vdi === null
? new WebSocket(responseRobot?.vdiIngressEndpoint + "ws?password=admin")
: null;

vdiClient?.addEventListener("open", () => {
dispatcher({
type: "vdi",
payload: true,
});
["vdi", "virtualIDE"].map((connection) =>
dispatcher({
type: connection,
payload: true,
}),
);
});

vdiClient?.addEventListener("error", () => {
dispatcher({
type: "vdi",
payload: false,
});
["vdi", "virtualIDE"].map((connection) =>
dispatcher({
type: connection,
payload: false,
}),
);
});

connectionsReducer?.vdi !== null && vdiClient && vdiClient.close();
Expand All @@ -314,37 +321,30 @@ export default ({ children }: any) => {
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isSettedCookie, connectionsReducer?.vdi]);
// VDI Test Connection
// VDI - vIDE Test Connection

// V-IDE Test Connection
// Physical IDE Test Connection
useEffect(() => {
try {
if (isSettedCookie && isProduction) {
axiosInterceptorOpenApi
.get(responseRobot?.ideIngressEndpoint + "healthz")
.then((response: AxiosResponse<any>) => {
console.log(response.data);
dispatcher({
type: "virtualIDE",
payload: true,
});
});
if (isSettedCookie && typeof connectionsReducer?.vdi === "boolean") {
if (
connectionsReducer?.vdi &&
responsePhysicalInstance?.federationPhase === "Connected" &&
responsePhysicalInstance?.multicastPhase === "Connected" &&
responsePhysicalInstance?.phase === "Connected"
) {
dispatcher({
type: "physicalIDE",
payload: true,
});
} else {
dispatcher({
type: "virtualIDE",
type: "physicalIDE",
payload: false,
});
}
} catch (error) {
dispatcher({
type: "virtualIDE",
payload: false,
});
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isSettedCookie]);
// V-IDE Test Connection
}, [responsePhysicalInstance, isSettedCookie, connectionsReducer?.vdi]);
// Physical IDE Test Connection

function handleGetOrganization() {
getOrganization(
Expand Down Expand Up @@ -390,6 +390,22 @@ export default ({ children }: any) => {
);
}

function handleGetPhysicalInstance() {
getPhysicalInstance(
{
organizationId: pagesState?.organization?.organizationId!,
roboticsCloudName: pagesState?.roboticsCloud?.name!,
instanceId: pagesState?.instance?.instanceId!,
physicalInstanceName: responseRobot?.physicalInstance,
region: pagesState?.roboticsCloud?.region!,
},
{
ifErrorNavigateTo404: false,
setResponse: setResponsePhysicalInstance,
},
);
}

function handleGetFleet() {
getFleet(
{
Expand Down Expand Up @@ -519,6 +535,7 @@ export default ({ children }: any) => {
value={{
activeTab,
setActiveTab,
responsePhysicalInstance,
responseRobot,
responseBuildManager,
responseLaunchManagers,
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useRobot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useContext } from "react";
interface IuseRobot {
activeTab: string;
setActiveTab: any;
responsePhysicalInstance: any;
responseRobot: any;
responseBuildManager: any;
responseLaunchManagers: any;
Expand Down
12 changes: 12 additions & 0 deletions src/interfaces/useFunctionsInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ export interface IgetPhysicalInstances {
region: string;
}

export interface IgetPhysicalInstance {
organizationId: string;
roboticsCloudName: string;
instanceId: string;
physicalInstanceName: string;
region: string;
}

export interface IgetInstance {
organizationId: string;
roboticsCloudName: string;
Expand Down Expand Up @@ -171,6 +179,10 @@ export interface IuseFunctions {
values: IgetPhysicalInstances,
parameters?: ImultipleGetParameters,
) => void;
getPhysicalInstance: (
values: IgetPhysicalInstance,
parameters?: IsingleGetParameters,
) => void;
getInstance: (
values: IgetInstance,
parameters?: IsingleGetParameters,
Expand Down

0 comments on commit d1fe89a

Please sign in to comment.