Merge pull request 'Add connecting state for line connection process' (#17) from that into main
Reviewed-on: #17
This commit is contained in:
commit
79322507a9
|
|
@ -199,7 +199,7 @@ export default class LineConnection {
|
||||||
this.client.on('timeout', () => {
|
this.client.on('timeout', () => {
|
||||||
if (resolvedOrRejected) return
|
if (resolvedOrRejected) return
|
||||||
resolvedOrRejected = true
|
resolvedOrRejected = true
|
||||||
const message = 'Connection timeout!!\r\n'
|
const message = '\r\nConnection timeout!!\r\n'
|
||||||
this.config.output += message
|
this.config.output += message
|
||||||
this.socketIO.emit('line_output', {
|
this.socketIO.emit('line_output', {
|
||||||
stationId,
|
stationId,
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,10 @@ export class WebSocketIo {
|
||||||
|
|
||||||
const linesData = await Line.findBy('id', lineId)
|
const linesData = await Line.findBy('id', lineId)
|
||||||
const stationData = await Station.findBy('id', stationId)
|
const stationData = await Station.findBy('id', stationId)
|
||||||
|
io.emit('line_connecting', {
|
||||||
|
stationId,
|
||||||
|
lineId,
|
||||||
|
})
|
||||||
if (linesData && stationData) {
|
if (linesData && stationData) {
|
||||||
this.lineConnecting.push(lineId)
|
this.lineConnecting.push(lineId)
|
||||||
await this.connectLine(
|
await this.connectLine(
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ function App() {
|
||||||
socket.on("line_connected", (data) =>
|
socket.on("line_connected", (data) =>
|
||||||
updateValueLineStation(
|
updateValueLineStation(
|
||||||
data?.lineId,
|
data?.lineId,
|
||||||
{ status: data.status },
|
{ status: data.status, connecting: false },
|
||||||
data?.stationId
|
data?.stationId
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -169,7 +169,7 @@ function App() {
|
||||||
socket.on("line_disconnected", (data) =>
|
socket.on("line_disconnected", (data) =>
|
||||||
updateValueLineStation(
|
updateValueLineStation(
|
||||||
data?.lineId,
|
data?.lineId,
|
||||||
{ status: data.status },
|
{ status: data.status, connecting: false },
|
||||||
data?.stationId
|
data?.stationId
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -194,7 +194,7 @@ function App() {
|
||||||
socket?.on("line_error", (data) => {
|
socket?.on("line_error", (data) => {
|
||||||
updateValueLineStation(
|
updateValueLineStation(
|
||||||
data?.lineId,
|
data?.lineId,
|
||||||
{ netOutput: data.error },
|
{ netOutput: data.error, connecting: false },
|
||||||
data?.stationId
|
data?.stationId
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -327,6 +327,16 @@ function App() {
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket?.on("line_connecting", (data) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
updateValueLineStation(
|
||||||
|
data?.lineId,
|
||||||
|
{ connecting: true },
|
||||||
|
data?.stationId
|
||||||
|
);
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
// ✅ cleanup on unmount or when socket changes
|
// ✅ cleanup on unmount or when socket changes
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("init");
|
socket.off("init");
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { ButtonDPELP, ButtonScenario } from "./ButtonAction";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import { listBaudDefault } from "../untils/constanst";
|
import { listBaudDefault } from "../untils/constanst";
|
||||||
import { IconCaretRight } from "@tabler/icons-react";
|
import { IconCaretRight } from "@tabler/icons-react";
|
||||||
|
import { motion } from "motion/react";
|
||||||
|
|
||||||
const CardLine = ({
|
const CardLine = ({
|
||||||
line,
|
line,
|
||||||
|
|
@ -251,7 +252,7 @@ const CardLine = ({
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex direction={"column"} gap={"4px"} w={"100%"}>
|
<Flex justify={"space-between"} gap={"4px"} w={"100%"}>
|
||||||
<div className={classes.info_line}>
|
<div className={classes.info_line}>
|
||||||
SN:{" "}
|
SN:{" "}
|
||||||
<Text
|
<Text
|
||||||
|
|
@ -270,6 +271,19 @@ const CardLine = ({
|
||||||
{line?.inventory?.sn || ""}
|
{line?.inventory?.sn || ""}
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
|
{line?.connecting && (
|
||||||
|
<motion.div
|
||||||
|
style={{ fontSize: "11px", color: "red" }}
|
||||||
|
animate={{ opacity: [0.2, 1, 0.2] }}
|
||||||
|
transition={{
|
||||||
|
duration: 1.2,
|
||||||
|
repeat: Infinity,
|
||||||
|
ease: "easeInOut",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
connecting...
|
||||||
|
</motion.div>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex justify={"space-between"} w={"100%"} display={"none"}>
|
<Flex justify={"space-between"} w={"100%"} display={"none"}>
|
||||||
<Box>
|
<Box>
|
||||||
|
|
|
||||||
|
|
@ -997,7 +997,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
|
||||||
setIsSubmit(true);
|
setIsSubmit(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsSubmit(false);
|
setIsSubmit(false);
|
||||||
}, 5000);
|
}, 15000);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{listPortsSelected.length === 0 ||
|
{listPortsSelected.length === 0 ||
|
||||||
|
|
@ -1054,7 +1054,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
|
||||||
setIsSubmit(true);
|
setIsSubmit(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsSubmit(false);
|
setIsSubmit(false);
|
||||||
}, 5000);
|
}, 10000);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{listPortsSelected.length === 0 ||
|
{listPortsSelected.length === 0 ||
|
||||||
|
|
@ -1111,7 +1111,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
|
||||||
setIsSubmit(true);
|
setIsSubmit(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsSubmit(false);
|
setIsSubmit(false);
|
||||||
}, 5000);
|
}, 10000);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{listPortsSelected.length === 0 ||
|
{listPortsSelected.length === 0 ||
|
||||||
|
|
@ -1224,6 +1224,20 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
|
||||||
{normalizePortName(port.name)}
|
{normalizePortName(port.name)}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
display:
|
||||||
|
port.poe === "ON" ? "block" : "none",
|
||||||
|
position: "absolute",
|
||||||
|
bottom: "2px",
|
||||||
|
right: "2px",
|
||||||
|
zIndex: 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text size="10px" fs={"italic"}>
|
||||||
|
poe
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
))}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ const ModalTerminal = ({
|
||||||
setIsDisable(true);
|
setIsDisable(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsDisable(false);
|
setIsDisable(false);
|
||||||
}, 5000);
|
}, 10000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const controlSwitch = (action: string) => {
|
const controlSwitch = (action: string) => {
|
||||||
|
|
@ -346,7 +346,7 @@ const ModalTerminal = ({
|
||||||
setIsDisable(true);
|
setIsDisable(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsDisable(false);
|
setIsDisable(false);
|
||||||
}, 10000);
|
}, 15000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const findSwitchPort = (portName: string): SwitchPortsProps | null => {
|
const findSwitchPort = (portName: string): SwitchPortsProps | null => {
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ export type TLine = {
|
||||||
interface?: string;
|
interface?: string;
|
||||||
baud?: number;
|
baud?: number;
|
||||||
tickets?: TDataTicket[];
|
tickets?: TDataTicket[];
|
||||||
|
connecting?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TUser = {
|
export type TUser = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue