Update PoE Test
This commit is contained in:
parent
57e91bc422
commit
6e2f7e756d
|
|
@ -130,6 +130,7 @@ export default class LineConnection {
|
|||
private outputPhysicalTest: string
|
||||
private outputLoadIosLicense: string | boolean
|
||||
private listDeviceIos: string[]
|
||||
private debounceTimer: NodeJS.Timeout | null = null
|
||||
|
||||
constructor(config: LineConfig, socketIO: any, handleClearLine: () => void) {
|
||||
this.config = config
|
||||
|
|
@ -159,6 +160,7 @@ export default class LineConnection {
|
|||
this.outputPhysicalTest = ''
|
||||
this.outputLoadIosLicense = ''
|
||||
this.listDeviceIos = []
|
||||
this.debounceTimer = null
|
||||
}
|
||||
/**
|
||||
* Connect to line with socket
|
||||
|
|
@ -209,13 +211,18 @@ export default class LineConnection {
|
|||
}
|
||||
if (this.config.runningPhysical) {
|
||||
this.outputPhysicalTest += message
|
||||
const ports = this.physicalTest.handleLog(message)
|
||||
if (ports?.length)
|
||||
this.socketIO.emit('test_port_physical', {
|
||||
stationId,
|
||||
lineId: id,
|
||||
data: ports,
|
||||
})
|
||||
if (this.debounceTimer) clearTimeout(this.debounceTimer)
|
||||
|
||||
this.debounceTimer = setTimeout(() => {
|
||||
this.flushLogBuffer()
|
||||
}, 1000) // 1s debounce
|
||||
// const ports = this.physicalTest.handleLog(message)
|
||||
// if (ports?.length)
|
||||
// this.socketIO.emit('test_port_physical', {
|
||||
// stationId,
|
||||
// lineId: id,
|
||||
// data: ports,
|
||||
// })
|
||||
}
|
||||
if (data.toString().includes('More') || data.toString().includes('MORE'))
|
||||
this.writeCommand(' ')
|
||||
|
|
@ -1076,6 +1083,25 @@ export default class LineConnection {
|
|||
// }, 10000)
|
||||
}
|
||||
|
||||
flushLogBuffer() {
|
||||
const lines = this.outputPhysicalTest.split(/\r?\n/)
|
||||
|
||||
// giữ lại dòng cuối nếu chưa kết thúc hoàn chỉnh
|
||||
this.outputPhysicalTest = lines.pop() || ''
|
||||
|
||||
const completeLines = lines.join('\n')
|
||||
|
||||
if (completeLines.trim()) {
|
||||
const ports = this.physicalTest.handleLog(completeLines)
|
||||
if (ports?.length)
|
||||
this.socketIO.emit('test_port_physical', {
|
||||
stationId: this.config.stationId,
|
||||
lineId: this.config.id,
|
||||
data: ports,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End all testing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ export class PhysicalPortTest {
|
|||
markTested = true
|
||||
}
|
||||
|
||||
if (!iface) return
|
||||
if (!iface) continue
|
||||
|
||||
const port = this.ports.get(iface)
|
||||
if (!port) return
|
||||
if (!port) continue
|
||||
|
||||
port.lastSeen = new Date()
|
||||
|
||||
if (state && port.lastState === state) return
|
||||
if (state && port.lastState === state) continue
|
||||
if (state) port.lastState = state
|
||||
|
||||
// ⭐ PASS nếu có ít nhất 1 event hợp lệ
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
Menu,
|
||||
Modal,
|
||||
ScrollArea,
|
||||
SimpleGrid,
|
||||
Tabs,
|
||||
Text,
|
||||
Textarea,
|
||||
|
|
@ -983,9 +984,9 @@ const ModalTerminal = ({
|
|||
</Flex>
|
||||
</legend>
|
||||
<ScrollArea h={"50vh"} p={"4px"}>
|
||||
<Flex wrap={"wrap"} gap={"xs"}>
|
||||
<SimpleGrid cols={2} spacing="xs">
|
||||
{line?.runningPhysical && line?.ports
|
||||
? line?.ports?.map((port, i) => (
|
||||
? line.ports.map((port, i) => (
|
||||
<Text
|
||||
fz={"14px"}
|
||||
key={i}
|
||||
|
|
@ -998,8 +999,8 @@ const ModalTerminal = ({
|
|||
{port}
|
||||
</Text>
|
||||
))
|
||||
: ""}
|
||||
</Flex>
|
||||
: null}
|
||||
</SimpleGrid>
|
||||
</ScrollArea>
|
||||
</fieldset>
|
||||
<Flex justify={"space-between"}>
|
||||
|
|
|
|||
Loading…
Reference in New Issue