From c7094f0fd84aa07399399843720cfedb307949f0 Mon Sep 17 00:00:00 2001
From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com>
Date: Tue, 10 Feb 2026 08:16:25 +0700
Subject: [PATCH] Update form report and UI
---
BACKEND/app/services/line_connection.ts | 8 ++--
BACKEND/app/services/physical_test_service.ts | 25 -----------
BACKEND/app/ultils/helper.ts | 38 +++++++++++++++++
.../src/components/Modal/ModalTerminal.tsx | 15 ++++---
FRONTEND/src/untils/helper.ts | 41 +++++++++++++++++++
5 files changed, 94 insertions(+), 33 deletions(-)
diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts
index c788667..46834fa 100644
--- a/BACKEND/app/services/line_connection.ts
+++ b/BACKEND/app/services/line_connection.ts
@@ -1182,7 +1182,7 @@ export default class LineConnection {
*/
endTesting() {
this.physicalTest.done = true
- this.physicalTest.resetTestedPorts()
+ // this.physicalTest.resetTestedPorts()
this.config.runningPhysical = false
this.config.runningScenario = ''
this.testingPortPoE = false
@@ -1714,10 +1714,12 @@ ${log}
- Model: ${this.config?.inventory?.pid ?? 'N/A'}
+ Model: ${this.config?.inventory?.pid ?? 'N/A'} ${this.config?.inventory?.vid ?? 'N/A'}
Serial Number: ${this.config?.inventory?.sn ?? 'N/A'}
MAC: ${dataShowVersion?.MAC_ADDRESS ?? ''}
- IOS: ${dataShowVersion?.SOFTWARE_IMAGE ?? ''}
+ IOS: ${dataShowVersion?.SOFTWARE_IMAGE ?? ''} ${dataShowVersion?.VERSION ?? ''}
+ MEM: ${dataShowVersion?.MEMORY ?? ''}
+ FLASH: ${dataShowVersion?.USB_FLASH ?? ''}
License: ${
dataShowLic
? dataShowLic
diff --git a/BACKEND/app/services/physical_test_service.ts b/BACKEND/app/services/physical_test_service.ts
index bae1870..acde15c 100644
--- a/BACKEND/app/services/physical_test_service.ts
+++ b/BACKEND/app/services/physical_test_service.ts
@@ -208,31 +208,6 @@ export class PhysicalPortTest {
: ''
}
- ────────────────────────────────
- Passed Ports
- ${
- tested.length
- ? `
-
- ${
- testedPoE?.length
- ? `|
- ${testedPoE.map((p) => this.normalizePortName(p.name)).join(' ')}
- | `
- : ''
- }
- ${
- testedSFP?.length
- ? `
- ${testedSFP.map((p) => this.normalizePortName(p.name)).join(' ')}
- | `
- : ''
- }
-
-
- `
- : ''
- }
`.trim()
}
diff --git a/BACKEND/app/ultils/helper.ts b/BACKEND/app/ultils/helper.ts
index a8e3dc7..d8c18a1 100644
--- a/BACKEND/app/ultils/helper.ts
+++ b/BACKEND/app/ultils/helper.ts
@@ -1523,3 +1523,41 @@ async function loadKeywordRules(log: string): Promise {
}
return []
}
+
+export function convertFromKilobytesString(input: string, decimals = 0): string {
+ if (!input) return '0 KB'
+ const parts = input.split('/')
+ if (parts.length === 0) return ''
+
+ const totalRamStr = parts[0].trim()
+ const trimmed = totalRamStr.trim().toUpperCase()
+
+ // Bắt dạng: 491520K, 1024KB, 1M, 1.5G, 2T
+ const match = trimmed.match(/^([\d.]+)\s*(K|M|G|T)?B?$/)
+
+ if (!match) return '0 KB'
+
+ const value = Number.parseFloat(match[1])
+ const unit = match[2] || 'K'
+
+ // Quy tất cả về KB
+ const toKB: Record = {
+ K: 1,
+ M: 1024,
+ G: 1024 ** 2,
+ T: 1024 ** 3,
+ }
+
+ let kilobytes = value * toKB[unit]
+
+ // ---- Convert KB -> đơn vị đẹp nhất ----
+ const units = ['KB', 'MB', 'GB', 'TB']
+ let unitIndex = 0
+
+ while (kilobytes >= 1024 && unitIndex < units.length - 1) {
+ kilobytes /= 1024
+ unitIndex++
+ }
+
+ return `${kilobytes.toFixed(decimals)} ${units[unitIndex]}`
+}
diff --git a/FRONTEND/src/components/Modal/ModalTerminal.tsx b/FRONTEND/src/components/Modal/ModalTerminal.tsx
index 85cc3e0..edf22d6 100644
--- a/FRONTEND/src/components/Modal/ModalTerminal.tsx
+++ b/FRONTEND/src/components/Modal/ModalTerminal.tsx
@@ -54,7 +54,7 @@ import ModalSelectLicense from "./ModalSelectLicense";
import ModalRunScenario from "./ModalRunScenario";
import DrawerScenario from "./ModalScenario";
import AutoProgress from "../Components/AutoProgress";
-import { bodyDPELP } from "../../untils/helper";
+import { bodyDPELP, convertFromKilobytesString } from "../../untils/helper";
const apiUrl = import.meta.env.VITE_BACKEND_URL;
const INIT_TICKET = {
@@ -645,7 +645,8 @@ const ModalTerminal = ({
setIsDisable(false);
}, 15000);
}
- if (activeStep === 2 && !isDisable) {
+ if (activeStep >= 2 && !isDisable) {
+ setActiveStep(3);
setIsDisable(true);
setTimeout(() => {
setIsDisable(false);
@@ -671,7 +672,7 @@ const ModalTerminal = ({
disabled={isDisable}
label="Completed"
description={
- activeStep !== 2
+ activeStep < 2
? "Complete all to send report"
: "Click to send report"
}
@@ -957,7 +958,9 @@ const ModalTerminal = ({
{findDataShowVersion() &&
findDataShowVersion()?.MEMORY
- ? findDataShowVersion()?.MEMORY + " bytes"
+ ? convertFromKilobytesString(
+ findDataShowVersion()?.MEMORY
+ )
: ""}
@@ -968,7 +971,9 @@ const ModalTerminal = ({
{findDataShowVersion() &&
findDataShowVersion()?.USB_FLASH
- ? findDataShowVersion()?.USB_FLASH + " bytes"
+ ? convertFromKilobytesString(
+ findDataShowVersion()?.USB_FLASH
+ )
: ""}
diff --git a/FRONTEND/src/untils/helper.ts b/FRONTEND/src/untils/helper.ts
index b3fd2a9..aa8470e 100644
--- a/FRONTEND/src/untils/helper.ts
+++ b/FRONTEND/src/untils/helper.ts
@@ -196,3 +196,44 @@ export const bodyDPELP = [
note: "",
},
];
+
+export function convertFromKilobytesString(
+ input: string,
+ decimals = 0
+): string {
+ if (!input) return "0 KB";
+ const parts = input.split("/");
+ if (parts.length === 0) return "";
+
+ const totalRamStr = parts[0].trim();
+ const trimmed = totalRamStr.trim().toUpperCase();
+
+ // Bắt dạng: 491520K, 1024KB, 1M, 1.5G, 2T
+ const match = trimmed.match(/^([\d.]+)\s*(K|M|G|T)?B?$/);
+
+ if (!match) return "0 KB";
+
+ const value = Number.parseFloat(match[1]);
+ const unit = match[2] || "K";
+
+ // Quy tất cả về KB
+ const toKB: Record = {
+ K: 1,
+ M: 1024,
+ G: 1024 ** 2,
+ T: 1024 ** 3,
+ };
+
+ let kilobytes = value * toKB[unit];
+
+ // ---- Convert KB -> đơn vị đẹp nhất ----
+ const units = ["KB", "MB", "GB", "TB"];
+ let unitIndex = 0;
+
+ while (kilobytes >= 1024 && unitIndex < units.length - 1) {
+ kilobytes /= 1024;
+ unitIndex++;
+ }
+
+ return `${kilobytes.toFixed(decimals)} ${units[unitIndex]}`;
+}
|