From 1a86c5904954db3edf65cb0fc597718303c454a3 Mon Sep 17 00:00:00 2001 From: "andrew.ng" Date: Wed, 27 May 2026 14:37:43 +0700 Subject: [PATCH] Update loading note, shorten Issue Zulip --- BACKEND/app/services/line_connection.ts | 10 +++-- BACKEND/providers/socket_io_provider.ts | 11 ++++- FRONTEND/src/App.tsx | 10 +++++ .../components/Components/LoaderOverlay.tsx | 41 +++++++++++++++++++ .../src/components/Modal/ModalTerminal.tsx | 31 +++++++------- FRONTEND/src/untils/types.ts | 1 + 6 files changed, 84 insertions(+), 20 deletions(-) create mode 100644 FRONTEND/src/components/Components/LoaderOverlay.tsx diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index 45106ce..e524bf9 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -616,6 +616,10 @@ export default class LineConnection { return } if (script?.send_result || script?.sendResult) { + this.socketIO.emit('loading_note', { + stationId: this.config.stationId, + lineId: this.config.id, + }) const detectLog = await this.detectLogWithAI(this.outputALLScenario) const result = mapToLineFormat({ lineNumber: this.config.lineNumber, @@ -2318,7 +2322,7 @@ Ports Missing/Down: ${missing.length}\n\n`
Receiving & Inspection Notes
-
${dataIncomingBySN?.packagePo?.receivedBy?.fullName || 'Unknown'} · ${dataIncomingBySN?.packagePo?.receivedDate ? momentTZ(dataIncomingBySN?.packagePo?.receivedDate).tz(timeZone).format('DD MMM, HH:mm') : ''}
+
${dataIncomingBySN?.packagePo?.receivedBy?.fullName || 'Unknown'} · ${dataIncomingBySN?.packagePo?.receivedDate ? momentTZ(dataIncomingBySN?.packagePo?.receivedDate).tz(timeZone).format('DD MMM YYYY, HH:mm') : ''}
⚠ Warning from Warehouse
@@ -2404,7 +2408,7 @@ Ports Missing/Down: ${missing.length}\n\n` ${this?.userTest?.dpelp?.name || 'Unknown'}
- ${momentTZ(this?.userTest?.dpelp?.time).tz(timeZone).format('DD MMM YYYY, HH:mm')} + ${momentTZ(this?.userTest?.dpelp?.time || new Date()).tz(timeZone).format('DD MMM YYYY, HH:mm')}
@@ -2462,7 +2466,7 @@ Ports Missing/Down: ${missing.length}\n\n` Software Check - ${this?.userTest?.dpelp?.name || ''} · ${momentTZ(this?.userTest?.dpelp?.time).tz(timeZone).format('DD MMM YYYY, HH:mm')} + ${this?.userTest?.dpelp?.name || ''} · ${momentTZ(this?.userTest?.dpelp?.time || new Date()).tz(timeZone).format('DD MMM YYYY, HH:mm')} diff --git a/BACKEND/providers/socket_io_provider.ts b/BACKEND/providers/socket_io_provider.ts index 2467f0d..e6d686b 100644 --- a/BACKEND/providers/socket_io_provider.ts +++ b/BACKEND/providers/socket_io_provider.ts @@ -1439,6 +1439,11 @@ export class WebSocketIo { return html } + shortenResult(text: string) { + const match = text.match(/RESULT:.*?(?=SUMMARY:)/s); + return match ? match[0].trim().replace(/,\s*$/, '') : text; + } + /** * Generates a Zulip-compatible Markdown table string from the results array. * Uses
to force line breaks within the License cell. @@ -1467,6 +1472,10 @@ export class WebSocketIo { ? item.issues.map((i: string) => `• ${i.replace('|', '')}`).join(' --') : '- No issues detected.' + const issue = item.issues?.length ? item.issues.join("\n") : "- No issues detected." + const shortenedIssue = this.shortenResult(issue).split("\n") + const issuesMdShort = shortenedIssue.map((i: string) => `• ${i.replace('|', '')}`).join(' --') + msg += `| ${item.line || ''}` + ` | ${item.pid || ''} ${item.vid ? ` (${item.vid})` : ''}` + @@ -1474,7 +1483,7 @@ export class WebSocketIo { ` | ${item.mac || ''}` + ` | ${item.ios || ''}` + ` | ${licenseMd}` + - ` | ${issuesMd}` + + ` | ${issuesMdShort}` + ` |\n` } diff --git a/FRONTEND/src/App.tsx b/FRONTEND/src/App.tsx index 802c85e..335c5fd 100644 --- a/FRONTEND/src/App.tsx +++ b/FRONTEND/src/App.tsx @@ -405,6 +405,7 @@ function App() { data: data.data, inventory: data.inventory, latestScenario: data.latestScenario, + loadingNote: false, }, data?.stationId, ); @@ -549,6 +550,14 @@ function App() { } }); + socket?.on("loading_note", (data) => { + updateValueLineStation( + data?.lineId, + { loadingNote: true }, + data?.stationId, + ); + }); + // ✅ cleanup on unmount or when socket changes return () => { socket.off("init"); @@ -569,6 +578,7 @@ function App() { socket.off("test_port_physical"); socket.off("feature_tested"); socket.off("summary_tested"); + socket.off("loading_note"); }; }, [socket, stations, selectedLine]); diff --git a/FRONTEND/src/components/Components/LoaderOverlay.tsx b/FRONTEND/src/components/Components/LoaderOverlay.tsx new file mode 100644 index 0000000..154c855 --- /dev/null +++ b/FRONTEND/src/components/Components/LoaderOverlay.tsx @@ -0,0 +1,41 @@ +import { Box, Center, Loader } from "@mantine/core"; +import React from "react"; + +interface LoaderOverlayProps { + isLoading: boolean; + children: React.ReactNode; + size?: "xs" | "sm" | "md" | "lg" | "xl"; +} + +const LoaderOverlay: React.FC = ({ + isLoading, + children, + size = "md", +}) => { + return ( + + {children} + {isLoading && ( + + + + )} + + ); +}; + +export default LoaderOverlay; diff --git a/FRONTEND/src/components/Modal/ModalTerminal.tsx b/FRONTEND/src/components/Modal/ModalTerminal.tsx index bc54e09..4a101bf 100644 --- a/FRONTEND/src/components/Modal/ModalTerminal.tsx +++ b/FRONTEND/src/components/Modal/ModalTerminal.tsx @@ -56,6 +56,7 @@ import ModalRunScenario from "./ModalRunScenario"; import DrawerScenario from "./ModalScenario"; import ModalLineHistory from "./ModalLineHistory"; import AutoProgress from "../Components/AutoProgress"; +import LoaderOverlay from "../Components/LoaderOverlay"; import { bodyDPELP, convertFromKilobytesString } from "../../untils/helper"; const apiUrl = import.meta.env.VITE_BACKEND_URL; @@ -1079,10 +1080,6 @@ const ModalTerminal = ({ mb={"4px"} variant="light" onClick={() => { - setIsDisable(true); - setTimeout(() => { - setIsDisable(false); - }, 3000); socket?.emit("update_note", { lineId: line?.id, stationId: stationItem?.id, @@ -1104,18 +1101,20 @@ const ModalTerminal = ({ - -