This commit is contained in:
parent
6f7b821c8b
commit
3a5b0bdcbc
162 changed files with 15801 additions and 224 deletions
60
FRONT/DEV/src/utils/nodeController/initNetIntData.ts
Normal file
60
FRONT/DEV/src/utils/nodeController/initNetIntData.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { ResponseData, Interfaces, MainData, IEdge, NetworkData } from '../../const/types/types'
|
||||
import { ipsInitor } from './nodeCreator/inits/initIpArray';
|
||||
|
||||
export const initNetworkIntData = (mainGroups: ResponseData[]): { interfaces: Interfaces[], edgeData: IEdge[] } => {
|
||||
const edgeData: IEdge[] = [];
|
||||
const interfaces: Interfaces[] = [];
|
||||
|
||||
if (mainGroups) {
|
||||
mainGroups.map((el, indx) => {
|
||||
let nodeData: MainData[] = [];
|
||||
el.interfaces.map((net, index) => {
|
||||
let nodeID = `g${indx}_nw${index}`;
|
||||
let portID = `p-nw${index}`;
|
||||
let targetId = `${portID}_target-right`;
|
||||
let sourceId = `${nodeID}-source-left`;
|
||||
|
||||
if (indx === 0) {
|
||||
const edge: IEdge = {
|
||||
id: `${nodeID}-${portID}`,
|
||||
source: nodeID,
|
||||
target: portID,
|
||||
sourceHandle: sourceId,
|
||||
targetHandle: targetId,
|
||||
type: "default",
|
||||
};
|
||||
edgeData.push(edge);
|
||||
}
|
||||
|
||||
const network: NetworkData = {
|
||||
device: net.name,
|
||||
type: net.type,
|
||||
mac: net.mac_address,
|
||||
connection: net.active_connection,
|
||||
mtu: net.device_mtu,
|
||||
state: net.device_state,
|
||||
strength: net.strength
|
||||
};
|
||||
|
||||
const ipArray = ipsInitor(net);
|
||||
|
||||
let interfaceData: MainData = {
|
||||
networkData: network,
|
||||
ipArrays: ipArray
|
||||
};
|
||||
|
||||
nodeData.push(interfaceData);
|
||||
});
|
||||
|
||||
let j: Interfaces = {
|
||||
container_x: el.container_x,
|
||||
container_y: el.container_y,
|
||||
mainData: nodeData
|
||||
};
|
||||
|
||||
interfaces.push(j);
|
||||
});
|
||||
}
|
||||
|
||||
return { interfaces, edgeData };
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue