From 8612d8885852180940244b13d2f0e3c0a4f1e3d7 Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Tue, 3 Mar 2026 11:30:38 +0700 Subject: [PATCH] Update view IOS --- BACKEND/app/services/line_connection.ts | 12 ++++----- BACKEND/providers/socket_io_provider.ts | 3 ++- FRONTEND/src/components/CardLine.tsx | 18 +++++++++---- .../src/components/Modal/ModalSelectIOS.tsx | 27 ++++++++++--------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index a5b4304..02f3ac7 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -79,6 +79,7 @@ interface LineConfig { runningScenario: string runningPhysical: boolean listFeatureTested: string[] + isReady: boolean // history: string } @@ -140,7 +141,6 @@ export default class LineConnection { private testingPortPoE: boolean private outputTestingPortPoE: string private debounceSendSummaryReport: NodeJS.Timeout | null = null - public isReady: boolean constructor(config: LineConfig, socketIO: any, handleClearLine: () => void) { this.config = config @@ -174,7 +174,6 @@ export default class LineConnection { this.debounceSendSummaryReport = null this.testingPortPoE = false this.outputTestingPortPoE = '' - this.isReady = false } /** * Connect to line with socket @@ -251,8 +250,8 @@ export default class LineConnection { } this.config.output += cleanData(rawData) this.config.output = this.config.output.slice(-15000) - if (!this.isReady && canInputCommand(message)) { - this.isReady = true + if (!this.config.isReady && canInputCommand(message)) { + this.config.isReady = true this.socketIO.emit('update_status_ready', { stationId, lineId: id, @@ -300,7 +299,7 @@ export default class LineConnection { this.config.listFeatureTested = [] this.config.latestScenario = undefined this.physicalTest = new PhysicalPortTest([]) - this.isReady = false + this.config.isReady = false // this.config.inventory = undefined this.socketIO.emit('line_disconnected', { stationId, @@ -406,7 +405,7 @@ export default class LineConnection { this.outputBuffer = '' return } - if (!this.isReady) { + if (!this.config.isReady) { console.log('Device is not ready') return } @@ -1845,6 +1844,7 @@ ${log} runningScenario: '', runningPhysical: false, listFeatureTested: [], + isReady: false, } this.physicalTest = new PhysicalPortTest([]) } diff --git a/BACKEND/providers/socket_io_provider.ts b/BACKEND/providers/socket_io_provider.ts index d2ff63a..80fe281 100644 --- a/BACKEND/providers/socket_io_provider.ts +++ b/BACKEND/providers/socket_io_provider.ts @@ -617,7 +617,7 @@ export class WebSocketIo { let lineIds: number[] = [] for (const lineId of dataLines) { const line = this.lineMap.get(lineId) - if (line && line.isReady) { + if (line && line.config.isReady) { lineIds.push(lineId) } } @@ -905,6 +905,7 @@ export class WebSocketIo { runningScenario: '', latestScenario: latestScenario, listFeatureTested: [], + isReady: false, }, socket, async () => { diff --git a/FRONTEND/src/components/CardLine.tsx b/FRONTEND/src/components/CardLine.tsx index 6e03e62..94a5505 100644 --- a/FRONTEND/src/components/CardLine.tsx +++ b/FRONTEND/src/components/CardLine.tsx @@ -125,11 +125,19 @@ const CardLine = ({ useEffect(() => { if (line?.latestScenario?.detectAI) { - const data = - line?.latestScenario?.detectAI?.issue && - Array.isArray(line?.latestScenario?.detectAI?.issue) - ? "- " + line?.latestScenario?.detectAI?.issue?.join("\n- ") - : ""; + if ( + !line?.latestScenario?.detectAI?.issue || + line?.latestScenario?.detectAI?.issue.length === 0 + ) { + setIsShowIssue(false); + return; + } + const data = Array.isArray(line?.latestScenario?.detectAI?.issue) + ? "- " + + line?.latestScenario?.detectAI?.issue + .filter((i: string) => i.trim()) + .join("\n- ") + : ""; if (data && !data.includes("No issues detected")) setIsShowIssue(true); else setIsShowIssue(false); } else setIsShowIssue(false); diff --git a/FRONTEND/src/components/Modal/ModalSelectIOS.tsx b/FRONTEND/src/components/Modal/ModalSelectIOS.tsx index c0cef0a..6407f5d 100644 --- a/FRONTEND/src/components/Modal/ModalSelectIOS.tsx +++ b/FRONTEND/src/components/Modal/ModalSelectIOS.tsx @@ -40,28 +40,31 @@ const ModalSelectIOS = ({ const [isDisable, setIsDisable] = useState(false); const filterIos = (type: string = "") => { - // Switch: Ưu tiên các dòng 4 chữ số cụ thể - // c2960, c3560, c3750, c3850, c4500, c9xxx - const switchRegex = /^(c2960|c3560|c3750|c3850|c4500|c9\d{3})/i; + const name = (str: string) => str.toLowerCase(); - // Router: Các dòng ISR đời cũ và mới - // c18xx, c19xx, c28xx, c29xx (nhưng không phải 2960), c38xx (nhưng không phải 3850), c39xx, isr, asr + // SWITCH families + const switchRegex = + /^(c29(60|50)|c35(60|70)|c37(50)|c38(50)|c45(00)|c9\d{3}|cat\d+k|cat\d{4}|catalyst)/i; + + // ROUTER families const routerRegex = - /^(c8\d{2}|c18|c19|c28|c29(?!60)|c38(?!50)|c39|isr|asr)/i; + /^(c8\d{2}|c18\d{2}|c19\d{2}|c28\d{2}|c29(?!60)\d{2}|c38(?!50)\d{2}|c39\d{2}|isr\d*|asr\d*|csr\d*|ir\d*)/i; return listIos .filter((ios) => { + const iosName = name(ios.name); + if (type === "switch") { - return switchRegex.test(ios.name); + return switchRegex.test(iosName); } + if (type === "router") { - return routerRegex.test(ios.name); + return routerRegex.test(iosName); } - return false; + + return true; // nếu không truyền type thì trả hết }) - .filter((ios) => - ios.name.toLowerCase().includes(inputSearch.toLowerCase()) - ); + .filter((ios) => name(ios.name).includes(inputSearch.toLowerCase())); }; return (