Show Device Group on Map (#12379)

* Show Device Group on Map

* style fix

* .

* .
This commit is contained in:
SourceDoctor
2021-01-02 22:06:52 +01:00
committed by GitHub
parent 7f93e2220d
commit 590b3ad123
3 changed files with 11 additions and 0 deletions
@@ -25,6 +25,7 @@
namespace App\Http\Controllers\Maps;
use App\Models\Device;
use App\Models\DeviceGroup;
use Illuminate\Http\Request;
use LibreNMS\Util\Url;
@@ -155,6 +156,11 @@ class DeviceDependencyController extends MapController
array_multisort(array_column($device_list, 'label'), SORT_ASC, $device_list);
$group_name = DeviceGroup::where('id', '=', $group_id)->first('name');
if (! empty($group_name)) {
$group_name = $group_name->name;
}
$data = [
'showparentdevicepath' => $show_device_path,
'isolated_device_id' => $this->isolatedDeviceId,
@@ -165,6 +171,7 @@ class DeviceDependencyController extends MapController
'options' => $this->visOptions(),
'nodes' => json_encode(array_values($devices_by_id)),
'edges' => json_encode($dependencies),
'group_name' => $group_name,
];
return view('map.device-dependency', $data);
+3
View File
@@ -44,8 +44,10 @@ $device_assoc_seen = [];
$ports = [];
$devices = [];
$group_name = '';
$where = '';
if (is_numeric($group) && $group) {
$group_name = dbFetchCell('SELECT `name` from `device_groups` WHERE `id` = ?', [$group]);
$where .= ' AND D1.device_id IN (SELECT `device_id` FROM `device_group_device` WHERE `device_group_id` = ?)';
$sql_array[] = $group;
$where .= ' OR D2.device_id IN (SELECT `device_id` FROM `device_group_device` WHERE `device_group_id` = ?)';
@@ -342,6 +344,7 @@ if (count($devices_by_id) > 1 && count($links) > 0) {
<form name="printmapform" method="get" action="" class="form-horizontal" role="form">
<?php if (empty($device['hostname'])) { ?>
<big><b><?=$group_name?></b></big>
<div class="pull-right">
<select name="highlight_node" id="highlight_node" class="input-sm" onChange="highlightNode()";>
<option value="0">None</option>
@@ -5,6 +5,7 @@
@section('content')
@if($node_count)
&nbsp;<big><b>{{ $group_name }}</b></big>
<div class="pull-right">
<input type="checkbox" class="custom-control-input" id="showparentdevicepath" onChange="highlightNode()" @if($showparentdevicepath) checked @endif>
<label class="custom-control-label" for="showparentdevicepath">@lang('Highlight Dependencies to Root Device')</label>