Files
librenms-librenms/app/Http/Controllers/Maps/MapController.php
SourceDoctor b8f2b094d7 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
2020-01-07 14:23:36 +01:00

97 lines
3.1 KiB
PHP

<?php
/**
* DependencyController.php
*
* Controller for graphing Relationships
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2019 Thomas Berberich
* @author Thomas Berberich <sourcehhdoctor@gmail.com>
*/
namespace App\Http\Controllers\Maps;
use App\Http\Controllers\Controller;
use LibreNMS\Config;
class MapController extends Controller
{
protected function visOptions()
{
return Config::get('network_map_vis_options');
}
protected function nodeDisabledStyle()
{
return ['color' => [
'highlight' => [
'background' => Config::get('network_map_legend.di.node'),
],
'border' => Config::get('network_map_legend.di.border'),
'background' => Config::get('network_map_legend.di.node'),
],
];
}
protected function nodeHighlightStyle()
{
return ['color' => [
'highlight' => [
'border' => Config::get('network_map_legend.highlight.border'),
],
'border' => Config::get('network_map_legend.highlight.border'),
],
'borderWidth' => Config::get('network_map_legend.highlight.borderWidth'),
];
}
protected function nodeDownStyle()
{
return ['color' => [
'highlight' => [
'background' => Config::get('network_map_legend.dn.node'),
'border' => Config::get('network_map_legend.dn.border'),
],
'border' => Config::get('network_map_legend.dn.border'),
'background' => Config::get('network_map_legend.dn.node'),
],
];
}
protected function nodeUpStyle()
{
return [];
}
protected function deviceStyle($device, $highlight_node = 0)
{
if ($device->disabled) {
$device_style = $this->nodeDisabledStyle();
} elseif (! $device->status) {
$device_style = $this->nodeDownStyle();
} else {
$device_style = $this->nodeUpStyle();
}
if ($device->device_id == $highlight_node) {
$device_style = array_merge($device_style, $this->nodeHighlightStyle());
}
return $device_style;
}
}