Update physical test, load IOS

This commit is contained in:
nguyentrungthat 2026-01-19 09:28:13 +07:00
parent c5e3e796bf
commit 57e91bc422
5 changed files with 49 additions and 43 deletions

View File

@ -1319,6 +1319,7 @@ export default class LineConnection {
await this.writeCommand(`${fileName}\r\n`)
await this.writeCommand(`${server}\r\n`)
await this.writeCommand(`i/${fileName}\r\n`)
this.outputBuffer = ''
await sleep(5000)
while (true) {
if (this.outputBuffer.includes('#')) {

View File

@ -46,49 +46,50 @@ export class PhysicalPortTest {
// });
}
handleLog(line: string) {
let iface: string | null = null
let markTested = false
let state: 'up' | 'down' | undefined
handleLog(lines: string) {
for (const line of lines.split('\n')) {
let iface: string | null = null
let markTested = false
let state: 'up' | 'down' | undefined
// 1⃣ LINK / LINEPROTO
let match = line.match(LINK_REGEX)
if (match) {
iface = normalizeInterface(match[1])
state = match[2] as 'up' | 'down'
if (state === 'up') markTested = true
// 1⃣ LINK / LINEPROTO
let match = line.match(LINK_REGEX)
if (match) {
iface = normalizeInterface(match[1])
state = match[2] as 'up' | 'down'
if (state === 'up') markTested = true
}
// 2⃣ POE POWER GRANTED
match = line.match(POE_GRANTED_REGEX)
if (match) {
iface = normalizeInterface(match[1])
markTested = true
}
// 3⃣ POE DISCONNECT
match = line.match(POE_DISCONNECT_REGEX)
if (match) {
iface = normalizeInterface(match[1])
markTested = true
}
if (!iface) return
const port = this.ports.get(iface)
if (!port) return
port.lastSeen = new Date()
if (state && port.lastState === state) return
if (state) port.lastState = state
// ⭐ PASS nếu có ít nhất 1 event hợp lệ
if (markTested && !port.tested) {
port.tested = true
this.checkDone()
}
}
// 2⃣ POE POWER GRANTED
match = line.match(POE_GRANTED_REGEX)
if (match) {
iface = normalizeInterface(match[1])
markTested = true
}
// 3⃣ POE DISCONNECT
match = line.match(POE_DISCONNECT_REGEX)
if (match) {
iface = normalizeInterface(match[1])
markTested = true
}
if (!iface) return
const port = this.ports.get(iface)
if (!port) return
port.lastSeen = new Date()
if (state && port.lastState === state) return
if (state) port.lastState = state
// ⭐ PASS nếu có ít nhất 1 event hợp lệ
if (markTested && !port.tested) {
port.tested = true
this.checkDone()
}
return this.getTestedPorts()
}

View File

@ -142,7 +142,10 @@ function DrawerLogs({
offset={8}
radius="md"
opened={opened}
onClose={close}
onClose={() => {
if (isLogModalOpen) return;
close();
}}
title={
<div>
<Tooltip

View File

@ -221,7 +221,7 @@ const ModalSelectIOS = ({
const payload = {
stationId: Number(station?.id),
lineId: Number(line?.id),
iosName: ios,
iosName: ios?.name,
station: station,
outletNumber: line?.outlet || -1,
apcName: line?.apcName || line?.apc_name,

View File

@ -987,6 +987,7 @@ const ModalTerminal = ({
{line?.runningPhysical && line?.ports
? line?.ports?.map((port, i) => (
<Text
fz={"14px"}
key={i}
c={
line?.listPortsPhysical?.includes(port)