Update view Physical test và report

This commit is contained in:
nguyentrungthat 2026-02-02 16:24:28 +07:00
parent 5812e1742b
commit d33878c112
2 changed files with 539 additions and 511 deletions

View File

@ -68,11 +68,11 @@ export class PhysicalPortTest {
}
// 3⃣ POE DISCONNECT
match = line.match(POE_DISCONNECT_REGEX)
if (match) {
iface = normalizeInterface(match[1])
markTested = true
}
// match = line.match(POE_DISCONNECT_REGEX)
// if (match) {
// iface = normalizeInterface(match[1])
// markTested = true
// }
if (!iface) continue
@ -159,34 +159,37 @@ export class PhysicalPortTest {
const status = missing.length === 0 ? 'PASS' : 'WARNING'
return `
Physical Port Test Report<br/>
<br/>
Model : <b>${report.device.model ?? 'N/A'}</b><br/>
Serial Number : <b>${report.device.serial ?? 'N/A'}</b><br/>
Started At : ${moment(report.startTime).format('YYYY/MM/DD, HH:mm:ss')}<br/>
Finished At : ${moment(report.endTime).format('YYYY/MM/DD, HH:mm:ss')}<br/>
Duration : ${this.formatDuration(report.durationMs)}<br/>
Status : ${status === 'PASS' ? '✅ PASS' : '⚠️ WARNING'}<br/>
<br/>
<br/>
<b>Test Summary</b><br/>
<br/>
Total Ports : ${report.ports.length}<br/>
<b>Physical Port Test Report</b><br/>
<table cellpadding="6" cellspacing="0" border="1" style="margin-top: 10px; border-collapse: collapse; width: 100%">
<tr>
<td style="width: 50%;">
Model : <b>${report.device.model ?? 'N/A'}</b><br/>
Serial Number : <b>${report.device.serial ?? 'N/A'}</b><br/>
Status : ${status === 'PASS' ? '✅ PASS' : '⚠️ WARNING'}<br/>
</td>
<td>
Total Ports : ${report.ports.length}<br/>
Ports Tested (UP) : ${tested.length}<br/>
Ports Missing : ${missing.length}<br/>
</td>
</tr>
</table>
<br/>
<br/>
<b>Passed Ports</b><br/>
<br/>
${tested.map((p) => p.name).join('<br/>')}<br/>
${
tested.length
? `<div style="margin-top: 10px; border: 1px solid #ccc; padding: 5px; column-count: 12;">${tested.map((p) => this.normalizePortName(p.name)).join('<br/>')}</div><br/>
`
: ''
}
<br/>
${
missing.length
? `
<br/>
<b>Missing Ports</b><br/>
<br/>
${missing.map((p) => p.name).join('<br/>')}
<div style="margin-top: 10px; border: 1px solid #ccc; padding: 5px; column-count: 12;">${missing.map((p) => this.normalizePortName(p.name)).join('<br/>')}</div><br/>
`
: ''
}<br/>
@ -201,4 +204,23 @@ export class PhysicalPortTest {
return `${minutes}m ${seconds}s`
}
normalizePortName(port: string): string {
if (!port) return ''
// Example inputs: "Fa0/1", "Gi0/0/1", "Fa0/0/2"
const match = port.match(/^([A-Za-z]+)([\d/]+)$/)
if (!match) return port
const type = match[1] // Fa, Gi, Te, etc.
const numbers = match[2] // "0/1" / "0/0/1" / "0/0/2"
// Get the last part after slash
const parts = numbers.split('/')
const last = parts[parts.length - 1]
const preLast = parts?.length > 1 ? parts[parts.length - 2] : ''
return `${type?.slice(0, 2)}${preLast ? preLast + '/' : ''}${last}`
}
}

File diff suppressed because it is too large Load Diff