Update DrawerControl.tsx
This commit is contained in:
parent
30b0d25d3d
commit
654ab5408e
|
|
@ -835,6 +835,24 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
|
|||
return `${last}`;
|
||||
};
|
||||
|
||||
const convertPortName = (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];
|
||||
|
||||
return `${type?.slice(0, 2)}${last}`;
|
||||
};
|
||||
|
||||
const changeShowPort = (status: string) => {
|
||||
localStorage.setItem("show-switch-port", status);
|
||||
setCheckedActive(status);
|
||||
|
|
@ -847,8 +865,8 @@ export const DrawerSwitchControl: React.FC<DrawerProps> = ({
|
|||
if (checkedActive === "config") {
|
||||
const listInterface = stationAPI?.lines
|
||||
?.filter((el) => el.interface)
|
||||
.map((el) => el.interface);
|
||||
return listInterface?.includes(portName);
|
||||
.map((el) => convertPortName(el.interface || ""));
|
||||
return listInterface?.includes(convertPortName(portName));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue