diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index 0d09fae..34b28eb 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -2475,6 +2475,21 @@ Ports Missing/Down: ${missing.length}\n\n` ` + // Save report to file (storage/report_sn/{SN}.html) + const reportSN = config?.inventory?.sn + if (reportSN) { + const reportDir = path.join(process.cwd(), 'storage', 'report_sn') + try { + if (!fs.existsSync(reportDir)) { + fs.mkdirSync(reportDir, { recursive: true }) + } + const reportPath = path.join(reportDir, `${reportSN}.html`) + fs.writeFileSync(reportPath, body, 'utf-8') + } catch (err) { + console.error(`Failed to save report for SN ${reportSN}:`, err) + } + } + this.updateNote(config?.inventory?.sn, this.dataDPELP as DataDPELP) await sendMessageToMail( `[ATC] - [${config.stationName} - L${config.lineNumber}] - ${this.config.inventory?.pid} - ${this.config.inventory?.sn} - Test Summary`, diff --git a/FRONTEND/src/components/FormAddEdit.tsx b/FRONTEND/src/components/FormAddEdit.tsx index 7cd1acb..eb36a38 100644 --- a/FRONTEND/src/components/FormAddEdit.tsx +++ b/FRONTEND/src/components/FormAddEdit.tsx @@ -85,15 +85,15 @@ const StationSetting = ({ form.setFieldValue("is_active", dataStation?.is_active); form.setFieldValue( "switch_control_port", - dataStation.switch_control_port + dataStation.switch_control_port, ); form.setFieldValue( "switch_control_username", - dataStation.switch_control_username + dataStation.switch_control_username, ); form.setFieldValue( "switch_control_password", - dataStation.switch_control_password + dataStation.switch_control_password, ); const dataLine = dataStation.lines.map((value) => ({ @@ -116,7 +116,7 @@ const StationSetting = ({ const lastLine = lines[lines.length - 1]; if (lastLine?.lineNumber || lastLine?.port) setLines((pre) => [...pre, lineInit]); - } + } else setLines([lineInit]); }, [lines]); useEffect(() => { @@ -138,8 +138,8 @@ const StationSetting = ({ onChange={(e) => setLines((pre) => pre.map((value, i) => - i === index ? { ...value, lineNumber: Number(e!) } : value - ) + i === index ? { ...value, lineNumber: Number(e!) } : value, + ), ) } /> @@ -150,8 +150,8 @@ const StationSetting = ({ onChange={(e) => setLines((pre) => pre.map((value, i) => - i === index ? { ...value, port: Number(e!) } : value - ) + i === index ? { ...value, port: Number(e!) } : value, + ), ) } /> @@ -162,8 +162,8 @@ const StationSetting = ({ onChange={(e) => setLines((pre) => pre.map((value, i) => - i === index ? { ...value, lineClear: Number(e!) } : value - ) + i === index ? { ...value, lineClear: Number(e!) } : value, + ), ) } /> @@ -178,8 +178,8 @@ const StationSetting = ({ onChange={(e) => setLines((pre) => pre.map((value, i) => - i === index ? { ...value, apc_name: e! } : value - ) + i === index ? { ...value, apc_name: e! } : value, + ), ) } /> @@ -190,8 +190,8 @@ const StationSetting = ({ onChange={(e) => setLines((pre) => pre.map((value, i) => - i === index ? { ...value, outlet: Number(e!) } : value - ) + i === index ? { ...value, outlet: Number(e!) } : value, + ), ) } /> @@ -204,8 +204,8 @@ const StationSetting = ({ pre.map((value, i) => i === index ? { ...value, interface: e.target.value } - : value - ) + : value, + ), ) } /> @@ -286,16 +286,16 @@ const StationSetting = ({ dataStationLines?.find((value) => value?.id === el.id) ? { ...dataStationLines?.find( - (value: TLine) => value?.id === el.id + (value: TLine) => value?.id === el.id, ), ...el, } - : el + : el, ), } - : el + : el, ) - : [...pre, station] + : [...pre, station], ); if (isEdit) { lineUpdate.forEach((el) => { @@ -345,7 +345,7 @@ const StationSetting = ({ const listStations = stations.filter((el) => el.id !== dataStation?.id); setStations(listStations); setActiveTab( - listStations.length ? listStations[0]?.id.toString() : "0" + listStations.length ? listStations[0]?.id.toString() : "0", ); notifications.show({ title: "Success", @@ -672,7 +672,7 @@ const StationSetting = ({ onChange={(e) => form.setFieldValue( "switch_control_port", - parseInt(e.toString()) + parseInt(e.toString()), ) } /> @@ -692,7 +692,7 @@ const StationSetting = ({ onChange={(e) => form.setFieldValue( "switch_control_username", - e.target.value + e.target.value, ) } /> @@ -704,7 +704,7 @@ const StationSetting = ({ onChange={(e) => form.setFieldValue( "switch_control_password", - e.target.value + e.target.value, ) } />