From f0b1a09fd433dcbd862ecbe1ad5b73012a46e332 Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Fri, 5 Dec 2025 09:27:43 +0700 Subject: [PATCH] Update run dpelp --- BACKEND/app/services/line_connection.ts | 15 ++++----------- BACKEND/providers/socket_io_provider.ts | 5 +++-- FRONTEND/src/components/ButtonAction.tsx | 14 +++++++------- FRONTEND/src/components/CardLine.tsx | 5 +++++ FRONTEND/src/components/DrawerControl.tsx | 8 +++----- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index 26bd2cf..c1eff0d 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -1,14 +1,7 @@ import fs from 'node:fs' import { textfsmResults } from './../ultils/templates/index.js' import net from 'node:net' -import { - appendLog, - cleanData, - getLogWithTimeScenario, - isValidJson, - mapToLineFormat, - sleep, -} from '../ultils/helper.js' +import { appendLog, cleanData, isValidJson, mapToLineFormat, sleep } from '../ultils/helper.js' import Scenario from '#models/scenario' import Station from '#models/station' import APCController from './apc_connection.js' @@ -418,7 +411,7 @@ export default class LineConnection { this.config.lineNumber ) - const logScenarios = getLogWithTimeScenario(this.outputScenario, now) || '' + const logScenarios = this.outputScenario const data = textfsmResults(logScenarios, '') try { data.forEach((item) => { @@ -485,9 +478,9 @@ export default class LineConnection { } if (step.send) { - this.outputScenario += `\n---send-command---"${step?.send ?? ''}"---${now}---\n` + this.outputScenario += `\n---send-command---"${(step?.send ?? '').toString().replace(/\r/g, '\\r').replace(/\n/g, '\\n')}"---${now}---\n` appendLog( - `\n---send-command---"${step?.send ?? ''}"---${now}---\n`, + `\n---send-command---"${(step?.send ?? '').toString().replace(/\r/g, '\\r').replace(/\n/g, '\\n')}"---${now}---\n`, this.config.stationId, this.config.stationName, this.config.stationIp, diff --git a/BACKEND/providers/socket_io_provider.ts b/BACKEND/providers/socket_io_provider.ts index e2485e8..791c3d3 100644 --- a/BACKEND/providers/socket_io_provider.ts +++ b/BACKEND/providers/socket_io_provider.ts @@ -567,8 +567,9 @@ export class WebSocketIo { await sendMessageToMail( 'andrew.ng@apactech.io', `[DPELP] Report AUTO - ${stationName} - ${dataFormat}`, - tableHTML, - ['ips@ipsupply.com.au', 'kay@ipsupply.com.au', 'joseph@apactech.io'] + tableHTML + // , + // ['ips@ipsupply.com.au', 'kay@ipsupply.com.au', 'joseph@apactech.io'] ) } catch (error) { console.log(error) diff --git a/FRONTEND/src/components/ButtonAction.tsx b/FRONTEND/src/components/ButtonAction.tsx index 384dd62..323da10 100644 --- a/FRONTEND/src/components/ButtonAction.tsx +++ b/FRONTEND/src/components/ButtonAction.tsx @@ -135,13 +135,13 @@ export const ButtonDPELP = ({ repeat: "1", note: "", }, - { - expect: "", - send: "show platform", - delay: "3000", - repeat: "1", - note: "", - }, + // { + // expect: "", + // send: "show platform", + // delay: "3000", + // repeat: "1", + // note: "", + // }, ]; socket?.emit( "run_scenario", diff --git a/FRONTEND/src/components/CardLine.tsx b/FRONTEND/src/components/CardLine.tsx index 02ed8ae..0e09833 100644 --- a/FRONTEND/src/components/CardLine.tsx +++ b/FRONTEND/src/components/CardLine.tsx @@ -406,6 +406,11 @@ const CardLine = ({ selectedLines={[line]} isDisable={isDisabled} onClick={() => { + socket?.emit("run_all_dpelp", { + lineIds: [line?.id], + stationName: stationItem.name, + stationId: Number(stationItem.id), + }); setIsDisabled(true); setTimeout(() => { setIsDisabled(false); diff --git a/FRONTEND/src/components/DrawerControl.tsx b/FRONTEND/src/components/DrawerControl.tsx index 5f816ad..d269859 100644 --- a/FRONTEND/src/components/DrawerControl.tsx +++ b/FRONTEND/src/components/DrawerControl.tsx @@ -720,11 +720,9 @@ export const DrawerSwitchControl: React.FC = ({ const [checkedActive, setCheckedActive] = useState("all"); useEffect(() => { - if (!open) { - setListPortsSelected([]); - setLoading(true); - } - }, [open]); + setListPortsSelected([]); + setLoading(true); + }, [stationId]); useEffect(() => { const value = localStorage.getItem("show-switch-port");