diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index deb6164..c3d26c9 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -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('#')) { diff --git a/BACKEND/app/services/physical_test_service.ts b/BACKEND/app/services/physical_test_service.ts index 7c90d86..d3c6546 100644 --- a/BACKEND/app/services/physical_test_service.ts +++ b/BACKEND/app/services/physical_test_service.ts @@ -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() } diff --git a/FRONTEND/src/components/Drawer/DrawerLogs.tsx b/FRONTEND/src/components/Drawer/DrawerLogs.tsx index 6cccbf1..56fe95a 100644 --- a/FRONTEND/src/components/Drawer/DrawerLogs.tsx +++ b/FRONTEND/src/components/Drawer/DrawerLogs.tsx @@ -142,7 +142,10 @@ function DrawerLogs({ offset={8} radius="md" opened={opened} - onClose={close} + onClose={() => { + if (isLogModalOpen) return; + close(); + }} title={
(