From 1ee447d2c72b5fbfdee16191a2fe86cd671f80b8 Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Thu, 27 Nov 2025 10:21:13 +0700 Subject: [PATCH] Refactor CLI close logic and comment out debug log Commented out the debug log in LineConnection's write method for cleaner output. Updated App.tsx to close CLI only for lines in the currently active station tab, improving accuracy when switching tabs. --- BACKEND/app/services/line_connection.ts | 6 +++--- FRONTEND/src/App.tsx | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index 27dd03d..02d0a1f 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -237,9 +237,9 @@ export default class LineConnection { return } - console.log( - `Write command "${cmd}" to line ${this.config.lineNumber} of ${this.config.stationName}` - ) + // console.log( + // `Write command "${cmd.toString().replace(/\r/g, '\\r').replace(/\n/g, '\\n')}" to line ${this.config.lineNumber} of ${this.config.stationName}` + // ) this.client.write(cmd) if (userName) { diff --git a/FRONTEND/src/App.tsx b/FRONTEND/src/App.tsx index 658c938..bbfaca9 100644 --- a/FRONTEND/src/App.tsx +++ b/FRONTEND/src/App.tsx @@ -593,8 +593,9 @@ function App() { ))} onChange={(id) => { - if (selectedLines.length > 0) { - selectedLines.forEach((el) => { + const station = stations.find((el) => el.id === Number(activeTab)); + if (station) { + (station?.lines || [])?.forEach((el) => { if (el?.userOpenCLI === user?.userName) socket?.emit("close_cli", { lineId: el?.id,