Skip to content

Commit

Permalink
add network links
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarzin committed Mar 20, 2022
1 parent 0ea3791 commit d0dee09
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions app/Http/Controllers/Admin/ExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,33 @@ public function explore()
array_push($nodes, [ "id" => "VLAN_" . $vlan->id, "label" => $vlan->name, "image" => "/images/vlan.png" ]);
}

// subnetworks
$subnetworks = DB::table("subnetworks")->select("id","name","network_id","vlan_id")->get();
// Subnetworks
// $subnetworks = DB::table("subnetworks")->select("id","name","network_id","vlan_id")->get();
$subnetworks = Subnetwork::all();
foreach ($subnetworks as $subnetwork) {
array_push($nodes, [ "id" => "SUBNETWORK_" . $subnetwork->id, "label" => $subnetwork->name, "image" => "/images/network.png" ]);
if ($subnetwork->network_id!=null)
array_push($edges, [ "from" => "SUBNETWORK_" . $subnetwork->id, "to" => "NETWORK_" . $subnetwork->network_id ]);
if ($subnetwork->vlan_id!=null)
array_push($edges, [ "from" => "SUBNETWORK_" . $subnetwork->id, "to" => "VLAN_" . $subnetwork->vlan_id ]);
}

// Logical Servers
$logicalServers = DB::table("logical_servers")->select("id","name")->get();
$logicalServers = DB::table("logical_servers")->select("id","name","address_ip")->get();
foreach ($logicalServers as $logicalServer) {
array_push($nodes, [ "id" => "LSERVER_" . $logicalServer->id, "label" => $logicalServer->name, "image" => "/images/server.png" ]);
}


if ($logicalServer->address_ip!=null) {
foreach($subnetworks as $subnetwork) {
foreach(explode(',',$logicalServer->address_ip) as $address) {
if ($subnetwork->contains($address)) {
array_push($edges, [ "from" => "SUBNETWORK_" . $subnetwork->id, "to" => "LSERVER_" . $logicalServer->id ]);
break;
}
}
}
}
}

// Logical Servers - Physical Servers
$joins = DB::table('logical_server_physical_server')->select("physical_server_id","logical_server_id")->get();
Expand Down

0 comments on commit d0dee09

Please sign in to comment.