From b75c3e36976f4e138bedefb61d717573b8e0c758 Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Thu, 4 Dec 2025 17:06:47 +0700 Subject: [PATCH] Update switch --- BACKEND/app/services/switch_connection.ts | 4 +-- FRONTEND/src/components/DrawerControl.tsx | 36 ++++------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/BACKEND/app/services/switch_connection.ts b/BACKEND/app/services/switch_connection.ts index 9a68022..7e8b335 100644 --- a/BACKEND/app/services/switch_connection.ts +++ b/BACKEND/app/services/switch_connection.ts @@ -295,7 +295,7 @@ export default class SwitchController { for (const line of lines) { // Match: "Gi0/1 is up, line protocol is up" const match = line.match( - /^(TenGigabitEthernet|GigabitEthernet|FastEthernet|Ethernet)\S*\s+is\s+(\S+),\s+line protocol is\s+(\S+)/i + /^(TenGigabitEthernet|GigabitEthernet|FastEthernet|Ethernet)\S*\s+is\s+(.+?),\s+line protocol is\s+(\S+)/i ) if (match) { const name = match[1] + line.split(' ')[0].replace(match[1], '') @@ -342,7 +342,7 @@ export default class SwitchController { const groupedArray = Object.values(grouped) this.ports = ports - this.portGroups = groupedArray + this.portGroups = groupedArray?.sort((a, b) => b.length - a.length) this.onData(this.portGroups, this.status) return true } diff --git a/FRONTEND/src/components/DrawerControl.tsx b/FRONTEND/src/components/DrawerControl.tsx index 127a71a..9dd21cb 100644 --- a/FRONTEND/src/components/DrawerControl.tsx +++ b/FRONTEND/src/components/DrawerControl.tsx @@ -976,12 +976,7 @@ export const DrawerSwitchControl: React.FC = ({ (dataStation?.switch?.status === "DISCONNECTED" || dataStation?.switch?.status === "TIMEOUT")) } - title={ - listPortsSelected.length === 0 || - listPortsSelected.length === listPorts.flat().length - ? "Restart All" - : "Restart Selected" - } + title={"Restart"} // mt={'xs'} miw={"80px"} size="xs" @@ -1018,10 +1013,7 @@ export const DrawerSwitchControl: React.FC = ({ }, 15000); }} > - {listPortsSelected.length === 0 || - listPortsSelected.length === listPorts.flat().length - ? "Restart All" - : "Restart Selected"} + Restart