Update switch

This commit is contained in:
nguyentrungthat 2025-12-04 17:06:47 +07:00
parent d8c58e5361
commit b75c3e3697
2 changed files with 8 additions and 32 deletions

View File

@ -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
}

View File

@ -976,12 +976,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
(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<DrawerProps> = ({
}, 15000);
}}
>
{listPortsSelected.length === 0 ||
listPortsSelected.length === listPorts.flat().length
? "Restart All"
: "Restart Selected"}
Restart
</Button>
<Button
className={classes.buttonMenuTool}
@ -1033,12 +1025,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
(dataStation?.switch?.status === "DISCONNECTED" ||
dataStation?.switch?.status === "TIMEOUT"))
}
title={
listPortsSelected.length === 0 ||
listPortsSelected.length === listPorts.flat().length
? "Turn On All"
: "Turn On Selected"
}
title={"Turn On"}
// mt={'xs'}
miw={"80px"}
size="xs"
@ -1075,10 +1062,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
}, 10000);
}}
>
{listPortsSelected.length === 0 ||
listPortsSelected.length === listPorts.flat().length
? "Turn On All"
: "Turn On Selected"}
Turn On
</Button>
<Button
className={classes.buttonMenuTool}
@ -1090,12 +1074,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
(dataStation?.switch?.status === "DISCONNECTED" ||
dataStation?.switch?.status === "TIMEOUT"))
}
title={
listPortsSelected.length === 0 ||
listPortsSelected.length === listPorts.flat().length
? "Turn Off All"
: "Turn Off Selected"
}
title={"Turn Off"}
// mt={'xs'}
miw={"80px"}
size="xs"
@ -1132,10 +1111,7 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
}, 10000);
}}
>
{listPortsSelected.length === 0 ||
listPortsSelected.length === listPorts.flat().length
? "Turn Off All"
: "Turn Off Selected"}
Turn Off
</Button>
<Group ms="xs" style={{ display: "flex", gap: "8px" }}>
<Radio