Graphing Device Dependency (#10916)

* graphing Device Dependency

* remove uneeded code

* fix link to go to device Overview

* rebuild dependency map to blade/laravel

* remove uneeded file

* code climate fixes

* remove not used code

* remove blank line

* device access filter optimization

* remove blank line

* force new travis check ...

* fix deviceLink configuration

* .

* rewrite code

* moving to Maps Namespace

* retrigger tests

* some code changes

* further renaming

* retrigger tests

* some code improvements

* .

* move vis.min.js in javascript section

* Device Dependency for Device Groups

* .

* codeclimate fixes

* show child/parents of Device - even if not in Device Group

* Device Highlighting

* add missing function

* replace hardcoded get params with ->get in Controller

* redesign Controller

* code climate fixes

* fix binary operator to 'or'

* remove 'or'

* code climate fixes

* further Code changes

* move loadMissing behind merge
This commit is contained in:
SourceDoctor
2020-01-07 14:23:36 +01:00
committed by Jellyfrog
parent 03b6408e06
commit b8f2b094d7
5 changed files with 280 additions and 0 deletions

View File

@@ -34,6 +34,20 @@
<li><a href="{{ url('availability-map') }}"><i class="fa fa-arrow-circle-up fa-fw fa-lg"
aria-hidden="true"></i> @lang('Availability')
</a></li>
<li><a href="{{ url('maps/devicedependency') }}"><i class="fa fa-chain fa-fw fa-lg"
aria-hidden="true"></i> @lang('Device Dependency')</a></li>
@if($device_groups->isNotEmpty())
<li class="dropdown-submenu"><a><i class="fa fa-chain fa-fw fa-lg"
aria-hidden="true"></i> @lang('Device Groups Dependencies')
</a>
<ul class="dropdown-menu scrollable-menu">
@foreach($device_groups as $group)
<li><a href="{{ url("maps/devicedependency?group=$group->id") }}" title="{{ $group->desc }}"><i class="fa fa-chain fa-fw fa-lg" aria-hidden="true"></i>
{{ ucfirst($group->name) }}
</a></li>
@endforeach
</ul></li>
@endif
<li><a href="{{ url('map') }}"><i class="fa fa-sitemap fa-fw fa-lg"
aria-hidden="true"></i> @lang('Network')</a></li>
@if($device_groups->isNotEmpty())

View File

@@ -0,0 +1,59 @@
@extends('layouts.librenmsv1')
@section('title', __('Device Dependency Map'))
@section('content')
@if($node_count)
<div class="pull-right">
<select name="highlight_node" id="highlight_node" class="input-sm" onChange="highlightNode()";>
<option value="0">None</option>
@foreach($device_list as $device)
<option value="{{ $device['id'] }}">{{ $device['label'] }}</option>
@endforeach
</select>
</div>
<div id="visualization"></div>
@else
<div class="alert alert-success" role="alert">@lang('No devices found')</div>
@endif
@endsection
@section('javascript')
<script type="text/javascript" src="{{ asset('js/vis.min.js') }}"></script>
@endsection
@section('scripts')
<script type="text/javascript">
var height = $(window).height() - 100;
$('#visualization').height(height + 'px');
// create an array with nodes
var nodes = {!! $nodes !!};
// create an array with edges
var edges = {!! $edges !!};
// create a network
var container = document.getElementById('visualization');
var data = {
nodes: nodes,
edges: edges,
stabilize: true
};
var options = {!! $options !!};
var network = new vis.Network(container, data, options);
network.on('click', function (properties) {
if (properties.nodes > 0) {
window.location.href = "device/device="+properties.nodes+"/"
}
});
function highlightNode(e) {
highlight_node = document.getElementById("highlight_node").value;
window.location.href = 'maps/devicedependency?group={{ $group_id }}&highlight_node=' + highlight_node;
}
$('#highlight_node option[value="{{$highlight_node}}"]').prop('selected', true);
</script>
@endsection