Skip to content

Commit

Permalink
fix vlans dans cartographie
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarzin committed Sep 21, 2021
1 parent 9386762 commit 443c486
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 51 deletions.
11 changes: 11 additions & 0 deletions app/Http/Controllers/Admin/CartographyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,17 @@ public function cartography(Request $request) {
foreach($certificate->logical_servers as $logical_server)
$graph .= " LOGICAL_SERVER" . $logical_server->id . "->CERT". $certificate->id;
}


foreach($routers as $router) {
$graph .= " R". $router->id . " [label=\"". $router->name . "\" shape=none labelloc=b width=1 height=1.8 image=\"". public_path("/images/router.png") . "\"]";
foreach($subnetworks as $subnetwork)
if (($router->ip_addresses!=null)&&($subnetwork->address!=null))
foreach(explode(',',$router->ip_addresses) as $address)
if ($subnetwork->contains($address))
$graph .= " SUBNET" . $subnetwork->id . "->R" . $router->id;
}

$graph .= "}";

// IMAGE
Expand Down
14 changes: 9 additions & 5 deletions app/Http/Controllers/Admin/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,12 @@ public function logicalInfrastructure(Request $request) {
return $logicalServers->pluck("id")->contains($logical_server->id);
return false;
});

// TODO: improve me
$vlans = Vlan::All()->sortBy("name")
->filter(function($item) use($subnetworks) {
return $subnetworks->pluck("vlan_id")->contains($item->id);
});
}
else {
$all_subnetworks = Subnetwork::All()->sortBy("name")->pluck("name","id");
Expand All @@ -644,6 +650,7 @@ public function logicalInfrastructure(Request $request) {
$dnsservers = Dnsserver::All()->sortBy("name");
$logicalServers = LogicalServer::All()->sortBy("name");
$certificates = Certificate::All()->sortBy("name");
$vlans = Vlan::All()->sortBy("name");
}

return view('admin/reports/logical_infrastructure',
Expand All @@ -660,7 +667,8 @@ public function logicalInfrastructure(Request $request) {
"dhcpServers",
"dnsservers",
"logicalServers",
"certificates"));
"certificates",
"vlans"));
}

public function physicalInfrastructure(Request $request) {
Expand Down Expand Up @@ -848,8 +856,6 @@ public function physicalInfrastructure(Request $request) {
return false;
});

// filtering ???
$vlans = Vlan::All()->sortBy("name");
}
else
{
Expand All @@ -866,7 +872,6 @@ public function physicalInfrastructure(Request $request) {
$physicalRouters = PhysicalRouter::All()->sortBy("name");
$wifiTerminals = WifiTerminal::All()->sortBy("name");
$physicalSecurityDevices = PhysicalSecurityDevice::All()->sortBy("name");
$vlans = Vlan::All()->sortBy("name");
}

return view('admin/reports/physical_infrastructure')
Expand All @@ -884,7 +889,6 @@ public function physicalInfrastructure(Request $request) {
->with("physicalRouters", $physicalRouters)
->with("wifiTerminals", $wifiTerminals)
->with("physicalSecurityDevices", $physicalSecurityDevices)
->with("vlans", $vlans)
;

}
Expand Down
Binary file modified public/images/certificate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/vlan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 51 additions & 3 deletions resources/views/admin/reports/logical_infrastructure.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<th>VLAN</th>
<td>
@if ($subnetwork->vlan!=null)
<a href="/admin/report/physical_infrastructure#VLAN{{ $subnetwork->vlan_id }}">{{ $subnetwork->vlan->name }}</a>
<a href="#VLAN{{ $subnetwork->vlan_id }}">{{ $subnetwork->vlan->name }}</a>
@endif
</td>
</tr>
Expand Down Expand Up @@ -317,8 +317,9 @@
</tbody>
</table>
</div>
</div>
</div>
@endforeach
</div>
</div>
@endif

Expand Down Expand Up @@ -486,10 +487,50 @@
@endif


@if ($vlans->count()>0)
<div class="card">
<div class="card-header">
Réseaux virtuels
</div>
<div class="card-body">
<p>Réseau local (LAN) virtuel permettant de regrouper logiquement des équipements en s’affranchissant des contraintes physiques.</p>
@foreach($vlans as $vlan)
<div class="row">
<div class="col-sm-6">
<table class="table table-bordered table-striped table-hover">
<thead id="VLAN{{ $vlan->id }}">
<th colspan="2">
<a href="/admin/vlans/{{ $vlan->id }}/edit">{{ $vlan->name }}</a>
</th>
</thead>
<tbody>
<tr>
<th width="20%">Description</th>
<td>{!! $vlan->description !!}</td>
</tr>
<tr>
<th width="20%">Sous-réseaux</th>
<td>
@foreach($vlan->subnetworks as $subnetwork)
<a href="/admin/report/logical_infrastructure#SUBNET{{$subnetwork->id}}">{{$subnetwork->name}}</a>
@if (!$loop->last)
,
@endif
@endforeach
</td>
</tr>
</tbody>
</table>
</div>
</div>
@endforeach
</div>
</div>
@endif




</div>
</div>
</div>
</div>
Expand All @@ -513,6 +554,7 @@
.addImage("/images/server.png", "64px", "64px")
.addImage("/images/router.png", "64px", "64px")
.addImage("/images/certificate.png", "64px", "64px")
.addImage("/images/vlan.png", "64px", "64px")
.renderDot("digraph {\
<?php $i=0; ?>\
@foreach($networks as $network) \
Expand All @@ -523,6 +565,9 @@
@endforeach\
@foreach($subnetworks as $subnetwork) \
SUBNET{{ $subnetwork->id }} [label=\"{{ $subnetwork->name }}\" shape=none labelloc=\"b\" width=1 height=1.1 image=\"/images/network.png\" href=\"#SUBNET{{$subnetwork->id}}\"]\
@if ($subnetwork->vlan_id!=null) \
SUBNET{{ $subnetwork->id }} -> VLAN{{ $subnetwork->vlan_id }}\
@endif\
@if ($subnetwork->network_id!=null) \
NET{{ $subnetwork->network_id }} -> SUBNET{{ $subnetwork->id }}\
@endif\
Expand Down Expand Up @@ -568,6 +613,9 @@
@endif\
@endforeach\
@endforeach\
@foreach($vlans as $vlan) \
VLAN{{ $vlan->id }} [label=\"{{ $vlan->name }}\" shape=none labelloc=\"b\" width=1 height=1.1 image=\"/images/vlan.png\" href=\"#VLAN{{$vlan->id}}\"]\
@endforeach\
}");
</script>
Expand Down
43 changes: 0 additions & 43 deletions resources/views/admin/reports/physical_infrastructure.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,49 +742,6 @@
</div>
</div>
@endif

@if ($vlans->count()>0)
<div class="card">
<div class="card-header">
Réseaux virtuels
</div>
<div class="card-body">
<p>Réseau local (LAN) virtuel permettant de regrouper logiquement des équipements en s’affranchissant des contraintes physiques.</p>
@foreach($vlans as $vlan)
<div class="row">
<div class="col-sm-6">
<table class="table table-bordered table-striped table-hover">
<thead id="VLAN{{ $vlan->id }}">
<th colspan="2">
<a href="/admin/vlans/{{ $vlan->id }}/edit">{{ $vlan->name }}</a>
</th>
</thead>
<tbody>
<tr>
<th width="20%">Description</th>
<td>{!! $vlan->description !!}</td>
</tr>
<tr>
<th width="20%">Sous-réseaux</th>
<td>
@foreach($vlan->subnetworks as $subnetwork)
<a href="/admin/report/logical_infrastructure#SUBNET{{$subnetwork->id}}">{{$subnetwork->name}}</a>
@if (!$loop->last)
,
@endif
@endforeach
</td>
</tr>
</tbody>
</table>
</div>
</div>
@endforeach
</div>
</div>
</div>
@endif

</div>
</div>

Expand Down

0 comments on commit 443c486

Please sign in to comment.