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) { for (const line of lines) {
// Match: "Gi0/1 is up, line protocol is up" // Match: "Gi0/1 is up, line protocol is up"
const match = line.match( 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) { if (match) {
const name = match[1] + line.split(' ')[0].replace(match[1], '') const name = match[1] + line.split(' ')[0].replace(match[1], '')
@ -342,7 +342,7 @@ export default class SwitchController {
const groupedArray = Object.values(grouped) const groupedArray = Object.values(grouped)
this.ports = ports this.ports = ports
this.portGroups = groupedArray this.portGroups = groupedArray?.sort((a, b) => b.length - a.length)
this.onData(this.portGroups, this.status) this.onData(this.portGroups, this.status)
return true return true
} }

View File

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