Global search: search device display (#13583)

* Global search: search device display
Add display field to search (also port_desc_descr, portName, and bgpPeerDescr)
Rewrite backend
update typeahead bundle
update devices and ports indexes
reduce some port field sizes so we can index them

* Style fixes

* remove nonsense
This commit is contained in:
Tony Murray 2021-12-06 09:12:24 -06:00 committed by GitHub
parent 29328b2e9a
commit a95efd6d2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 539 additions and 456 deletions

View File

@ -1,8 +1,8 @@
<?php
/**
* Colors.php
* Color.php
*
* -Description-
* Misc color generation
*
* 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
@ -25,9 +25,20 @@
namespace LibreNMS\Util;
class Colors
use App\Models\BgpPeer;
use App\Models\Device;
use App\Models\Port;
class Color
{
public static function percentage($percentage, $component_perc_warn = null)
/**
* Get colors for a percentage bar based on current percentage
*
* @param int|float $percentage
* @param int|float $component_perc_warn
* @return string[]
*/
public static function percentage($percentage, $component_perc_warn = null): array
{
$perc_warn = 75;
@ -73,4 +84,68 @@ class Colors
'middle' => 'afcc7c',
];
}
/**
* Get highlight color based on device status
*/
public static function forDeviceStatus(Device $device): string
{
if ($device->disabled) {
return '#808080';
}
if ($device->ignore) {
return '#000000';
}
return $device->status ? '#008000' : '#ff0000';
}
/**
* Get highlight color based on Port status
*/
public static function forPortStatus(Port $port): string
{
// Ignored ports
if ($port->ignore) {
return '#000000';
}
// Shutdown ports
if ($port->ifAdminStatus === 'down') {
return '#808080';
}
// Down Ports
if ($port->ifOperStatus !== 'up') {
return '#ff0000';
}
// Errored ports
if ($port->ifInErrors_delta > 0 || $port->ifOutErrors_delta > 0) {
return '#ffa500';
}
// Up ports
return '#008000';
}
/**
* Get highlight color based on BgpPeer status
*/
public static function forBgpPeerStatus(BgpPeer $peer): string
{
// Session inactive
if ($peer->bgpPeerAdminStatus !== 'start') {
return '#000000';
}
// Session active but errored
if ($peer->bgpPeerState !== 'established') {
return '#ffa500';
}
// Session Up
return '#008000';
}
}

View File

@ -140,9 +140,9 @@ class Html
{
$percent = min($percent, 100);
if ($colors === null) {
$colors = Colors::percentage($percent, $warn ?: null);
$colors = Color::percentage($percent, $warn ?: null);
}
$default = Colors::percentage(0);
$default = Color::percentage(0);
$left_text_color = $colors['left_text'] ?? 'ffffff';
$right_text_color = $colors['right_text'] ?? 'ffffff';
$left_color = $colors['left'] ?? $default['left'];

View File

@ -0,0 +1,72 @@
<?php
/*
* BgpSearchController.php
*
* -Description-
*
* 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 2021 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Ajax;
use App\Models\BgpPeer;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use LibreNMS\Util\Color;
use LibreNMS\Util\Url;
class BgpSearchController extends SearchController
{
public function buildQuery(string $search, Request $request): Builder
{
return BgpPeer::hasAccess($request->user())
->with('device')
->where(function (Builder $query) use ($search) {
$like_search = "%$search%";
return $query->orWhere('astext', 'LIKE', $like_search)
->orWhere('bgpPeerDescr', 'LIKE', $like_search)
->orWhere('bgpPeerIdentifier', 'LIKE', $like_search)
->orWhere('bgpPeerRemoteAs', 'LIKE', $like_search);
})
->orderBy('astext');
}
/**
* @param \App\Models\BgpPeer $peer
* @return array
*/
public function formatItem($peer): array
{
$bgp_image = $peer->bgpPeerRemoteAs == $peer->device->bgpLocalAs
? 'fa fa-square fa-lg icon-theme'
: 'fa fa-external-link-square fa-lg icon-theme';
return [
'url' => Url::deviceUrl($peer->device, ['tab' => 'routing', 'proto' => 'bgp']),
'name' => $peer->bgpPeerIdentifier,
'description' => $peer->astext,
'localas' => $peer->device->bgpLocalAs,
'bgp_image' => $bgp_image,
'remoteas' => $peer->bgpPeerRemoteAs,
'colours' => Color::forBgpPeerStatus($peer),
'hostname' => $peer->device->displayName(),
];
}
}

View File

@ -0,0 +1,104 @@
<?php
/*
* Search.php
*
* -Description-
*
* 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 2021 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Ajax;
use App\Models\Device;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use LibreNMS\Config;
use LibreNMS\Util\Color;
class DeviceSearchController extends SearchController
{
public function buildQuery(string $search, Request $request): Builder
{
$baseQuery = Device::hasAccess($request->user())
->leftJoin('locations', 'locations.id', '=', 'devices.location_id')
->select(['devices.*', 'locations.location'])
->distinct()
->orderBy('devices.hostname');
return $baseQuery
->where(function (Builder $query) use ($search, $baseQuery) {
// search filter
$like_search = "%$search%";
$query->orWhere('hostname', 'LIKE', $like_search)
->orWhere('sysName', 'LIKE', $like_search)
->orWhere('display', 'LIKE', $like_search)
->orWhere('location', 'LIKE', $like_search)
->orWhere('purpose', 'LIKE', $like_search)
->orWhere('serial', 'LIKE', $like_search)
->orWhere('notes', 'LIKE', $like_search);
if (\LibreNMS\Util\IPv4::isValid($search, false)) {
$baseQuery->leftJoin('ports', 'ports.device_id', '=', 'devices.device_id')
->leftJoin('ipv4_addresses', 'ipv4_addresses.port_id', 'ports.port_id');
$query->orWhere('ipv4_address', '=', $search)
->orWhere('overwrite_ip', '=', $search)
->orWhere('ip', '=', inet_pton($search));
} elseif (\LibreNMS\Util\IPv6::isValid($search, false)) {
$baseQuery->leftJoin('ports', 'ports.device_id', '=', 'devices.device_id')
->leftJoin('ipv6_addresses', 'ipv6_addresses.port_id', 'ports.port_id');
$query->orWhere('ipv6_address', '=', $search)
->orWhere('overwrite_ip', '=', $search)
->orWhere('ip', '=', inet_pton($search));
} elseif (ctype_xdigit($mac_search = str_replace([':', '-', '.'], '', $search))) {
$baseQuery->leftJoin('ports', 'ports.device_id', '=', 'devices.device_id');
$query->orWhere('ifPhysAddress', 'LIKE', "%$mac_search%");
}
return $query;
});
}
/**
* @param Device $device
* @return array
*/
public function formatItem($device): array
{
$name = $device->displayName();
if (! request()->get('map') && $name !== $device->sysName) {
$name .= " ($device->sysName)";
}
return [
'name' => $name,
'device_id' => $device->device_id,
'url' => \LibreNMS\Util\Url::deviceUrl($device),
'colours' => Color::forDeviceStatus($device),
'device_ports' => $device->ports()->count(),
'device_image' => $device->icon,
'device_hardware' => $device->hardware,
'device_os' => Config::getOsSetting($device->os, 'text'),
'version' => $device->version,
'location' => $device->location,
];
}
}

View File

@ -0,0 +1,76 @@
<?php
/*
* PortSearchController.php
*
* -Description-
*
* 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 2021 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Ajax;
use App\Models\Port;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use LibreNMS\Util\Color;
use LibreNMS\Util\Url;
class PortSearchController extends SearchController
{
public function buildQuery(string $search, Request $request): Builder
{
return Port::hasAccess($request->user())
->with('device')
->where('deleted', 0)
->where(function (Builder $query) use ($request) {
$search = $request->get('search');
$like_search = "%$search%";
return $query->orWhere('ifAlias', 'LIKE', $like_search)
->orWhere('ifDescr', 'LIKE', $like_search)
->orWhere('ifName', 'LIKE', $like_search)
->orWhere('port_descr_descr', 'LIKE', $like_search)
->orWhere('portName', 'LIKE', $like_search);
})
->orderBy('ifDescr');
}
/**
* @param \App\Models\Port $port
* @return array
*/
public function formatItem($port): array
{
$description = $port->getDescription();
$label = $port->getLabel();
if ($description !== $port->ifDescr && $label !== $port->ifDescr) {
$description .= " ($port->ifDescr)";
}
return [
'url' => Url::portUrl($port),
'name' => $label,
'description' => $description,
'colours' => Color::forPortStatus($port),
'hostname' => $port->device->displayName(),
'port_id' => $port->port_id,
];
}
}

View File

@ -0,0 +1,55 @@
<?php
/*
* SearchController.php
*
* -Description-
*
* 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 2021 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Ajax;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use LibreNMS\Config;
abstract class SearchController
{
public function __invoke(Request $request): JsonResponse
{
$search = $request->get('search');
if (empty($search)) {
return new JsonResponse;
}
$query = $this->buildQuery($search, $request)
->limit((int) Config::get('webui.global_search_result_limit'));
return response()->json($query->get()->map([$this, 'formatItem']));
}
abstract public function buildQuery(string $search, Request $request): Builder;
/**
* @param \Illuminate\Database\Eloquent\Model $item
* @return array
*/
abstract public function formatItem($item): array;
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ChangePortsTextFieldsToVarchar extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ports', function (Blueprint $table) {
$table->string('ifAlias')->change();
$table->string('ifType', 64)->change();
$table->string('ifPhysAddress', 64)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('ports', function (Blueprint $table) {
$table->text('ifAlias')->change();
$table->text('ifType')->change();
$table->text('ifPhysAddress')->change();
});
}
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ImproveDevicesSearchIndex extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('devices', function (Blueprint $table) {
$table->index(['hostname', 'sysName', 'display']);
$table->dropIndex('devices_hostname_index');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('devices', function (Blueprint $table) {
$table->index('hostname');
$table->dropIndex('devices_hostname_sysname_display_index');
});
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ImprovePortsSearchIndex extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ports', function (Blueprint $table) {
$table->index(['ifAlias', 'port_descr_descr', 'portName']);
$table->index(['ifDescr', 'ifName']);
$table->dropIndex('ports_ifdescr_index');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('ports', function (Blueprint $table) {
$table->index('ifDescr');
$table->dropIndex('ports_ifalias_port_descr_descr_portname_index');
$table->dropIndex('ports_ifdescr_ifname_index');
});
}
}

View File

@ -1,362 +0,0 @@
<?php
use LibreNMS\Util\Debug;
$init_modules = ['web', 'auth'];
require realpath(__DIR__ . '/..') . '/includes/init.php';
if (! Auth::check()) {
exit('Unauthorized');
}
Debug::set($_REQUEST['debug']);
$device = [];
$ports = [];
$bgp = [];
$limit = (int) \LibreNMS\Config::get('webui.global_search_result_limit');
if (isset($_REQUEST['search'])) {
$search = $_REQUEST['search'];
header('Content-type: application/json');
if (strlen($search) > 0) {
$found = 0;
if (! Auth::user()->hasGlobalRead()) {
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
$perms_sql = '`D`.`device_id` IN ' . dbGenPlaceholders(count($device_ids)) . ' AND ';
} else {
$device_ids = [];
$perms_sql = '';
}
if ($_REQUEST['type'] == 'group') {
foreach (dbFetchRows('SELECT id,name FROM device_groups WHERE name LIKE ?', ["%$search%"]) as $group) {
if ($_REQUEST['map']) {
$results[] = [
'name' => 'g:' . $group['name'],
'group_id' => $group['id'],
];
} else {
$results[] = ['name' => $group['name']];
}
}
exit(json_encode($results));
} elseif ($_REQUEST['type'] == 'alert-rules') {
foreach (dbFetchRows('SELECT name FROM alert_rules WHERE name LIKE ?', ["%$search%"]) as $rules) {
$results[] = ['name' => $rules['name']];
}
exit(json_encode($results));
} elseif ($_REQUEST['type'] == 'device') {
// Device search
$query = 'SELECT *, `D`.`device_id` AS `device_id` FROM `devices` as `D`
LEFT JOIN `locations` AS `L` ON `L`.`id` = `D`.`location_id`';
// user depending limitation
if (! Auth::user()->hasGlobalRead()) {
$query_args_list = $device_ids;
$query_filter = $perms_sql;
} else {
$query_args_list = [];
$query_filter = '';
}
// search filter
$query_filter .= '(`D`.`hostname` LIKE ?
OR `L`.`location` LIKE ?
OR `D`.`sysName` LIKE ?
OR `D`.`purpose` LIKE ?
OR `D`.`serial` LIKE ?
OR `D`.`notes` LIKE ?';
$query_args_list = array_merge($query_args_list, ["%$search%", "%$search%", "%$search%",
"%$search%", "%$search%", "%$search%", ]);
if (\LibreNMS\Util\IPv4::isValid($search, false)) {
$query .= ' LEFT JOIN `ports` AS `P` ON `P`.`device_id` = `D`.`device_id`
LEFT JOIN `ipv4_addresses` AS `V4` ON `V4`.`port_id` = `P`.`port_id`';
$query_filter .= ' OR `V4`.`ipv4_address` LIKE ?
OR `D`.`overwrite_ip` LIKE ?
OR `D`.`ip` = ? ';
$query_args_list = array_merge($query_args_list, ["%$search%", "%$search%", inet_pton($search)]);
} elseif (\LibreNMS\Util\IPv6::isValid($search, false)) {
$query .= ' LEFT JOIN `ports` AS `P` ON `P`.`device_id` = `D`.`device_id`
LEFT JOIN `ipv6_addresses` AS `V6` ON `V6`.`port_id` = `P`.`port_id`';
$query_filter .= ' OR `V6`.`ipv6_address` LIKE ?
OR `D`.`overwrite_ip` LIKE ?
OR `D`.`ip` = ? ';
$query_args_list = array_merge($query_args_list, ["%$search%", "%$search%", inet_pton($search)]);
} elseif (ctype_xdigit($mac_search = str_replace([':', '-', '.'], '', $search))) {
$query .= ' LEFT JOIN `ports` as `M` on `M`.`device_id` = `D`.`device_id`';
$query_filter .= ' OR `M`.`ifPhysAddress` LIKE ? ';
$query_args_list[] = "%$mac_search%";
}
$query_filter .= ')';
// result limitation
$query_args_list[] = $limit;
$results = dbFetchRows($query .
' WHERE ' . $query_filter .
' GROUP BY `D`.`hostname`
ORDER BY `D`.`hostname` LIMIT ?', $query_args_list);
if (count($results)) {
$found = 1;
$devices = count($results);
foreach ($results as $result) {
$name = $result['hostname'];
if ($_REQUEST['map'] != 1 && $result['sysName'] != $name && ! empty($result['sysName'])) {
$name .= ' (' . $result['sysName'] . ') ';
}
if ($result['disabled'] == 1) {
$highlight_colour = '#808080';
} elseif ($result['ignored'] == 1 && $result['disabled'] == 0) {
$highlight_colour = '#000000';
} elseif ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#ff0000';
} elseif ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#008000';
}
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D` WHERE ' . $perms_sql . ' `I`.`device_id` = `D`.`device_id` AND `I`.`ignore` = 0 AND `I`.`deleted` = 0 AND `D`.`device_id` = ?', array_merge($device_ids, [$result['device_id']]));
$device[] = [
'name' => $name,
'device_id' => $result['device_id'],
'url' => \LibreNMS\Util\Url::deviceUrl((int) $result['device_id']),
'colours' => $highlight_colour,
'device_ports' => $num_ports,
'device_image' => getIcon($result),
'device_hardware' => $result['hardware'],
'device_os' => \LibreNMS\Config::getOsSetting($result['os'], 'text'),
'version' => $result['version'],
'location' => $result['location'],
];
}//end foreach
}//end if
$json = json_encode($device);
exit($json);
} elseif ($_REQUEST['type'] == 'ports') {
// Search ports
if (Auth::user()->hasGlobalRead()) {
$results = dbFetchRows(
'SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE ? OR `ifDescr` LIKE ? OR `ifName` LIKE ? ORDER BY ifDescr LIMIT ?',
["%$search%", "%$search%", "%$search%", $limit]
);
} else {
$results = dbFetchRows(
"SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D` WHERE $perms_sql `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE ? OR `ifDescr` LIKE ? OR `ifName` LIKE ?) ORDER BY ifDescr LIMIT ?",
array_merge($device_ids, ["%$search%", "%$search%", "%$search%", $limit])
);
}
if (count($results)) {
$found = 1;
foreach ($results as $result) {
$name = $result['ifDescr'] == $result['ifAlias'] ? $result['ifName'] : $result['ifDescr'];
$description = \LibreNMS\Util\Clean::html($result['ifAlias'], []);
if ($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0)) {
// Errored ports
$port_colour = '#ffa500';
} elseif ($result['deleted'] == 0 && ($result['ignore'] == 1 || $result['ignore'] == 1)) {
// Ignored ports
$port_colour = '#000000';
} elseif ($result['deleted'] == 0 && $result['ifAdminStatus'] == 'down' && $result['ignore'] == 0 && $result['ignore'] == 0) {
// Shutdown ports
$port_colour = '#808080';
} elseif ($result['deleted'] == 0 && $result['ifOperStatus'] == 'down' && $result['ifAdminStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) {
// Down ports
$port_colour = '#ff0000';
} elseif ($result['deleted'] == 0 && $result['ifOperStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) {
// Up ports
$port_colour = '#008000';
}//end if
$ports[] = [
'count' => count($results),
'url' => generate_port_url($result),
'name' => $name,
'description' => $description,
'colours' => $port_colour,
'hostname' => format_hostname($result),
'port_id' => $result['port_id'],
];
}//end foreach
}//end if
$json = json_encode($ports);
exit($json);
} elseif ($_REQUEST['type'] == 'bgp') {
// Search bgp peers
$results = dbFetchRows(
"SELECT `bgpPeers`.*,`D`.* FROM `bgpPeers`, `devices` AS `D` WHERE $perms_sql `bgpPeers`.`device_id`=`D`.`device_id` AND (`astext` LIKE ? OR `bgpPeerIdentifier` LIKE ? OR `bgpPeerRemoteAs` LIKE ?) ORDER BY `astext` LIMIT ?",
array_merge($device_ids, ["%$search%", "%$search%", "%$search%", $limit])
);
if (count($results)) {
$found = 1;
foreach ($results as $result) {
$name = $result['bgpPeerIdentifier'];
$description = $result['astext'];
$remoteas = $result['bgpPeerRemoteAs'];
$localas = $result['bgpLocalAs'];
if ($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] != 'established') {
// Session active but errored
$port_colour = '#ffa500';
} elseif ($result['bgpPeerAdminStatus'] != 'start') {
// Session inactive
$port_colour = '#000000';
} elseif ($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] == 'established') {
// Session Up
$port_colour = '#008000';
}
if ($result['bgpPeerRemoteAs'] == $result['bgpLocalAs']) {
$bgp_image = 'fa fa-square fa-lg icon-theme';
} else {
$bgp_image = 'fa fa-external-link-square fa-lg icon-theme';
}
$bgp[] = [
'count' => count($results),
'url' => \LibreNMS\Util\Url::generate(['page' => 'device', 'device' => $result['device_id'], 'tab' => 'routing', 'proto' => 'bgp'], []),
'name' => $name,
'description' => $description,
'localas' => $localas,
'bgp_image' => $bgp_image,
'remoteas' => $remoteas,
'colours' => $port_colour,
'hostname' => format_hostname($result),
];
}//end foreach
}//end if
$json = json_encode($bgp);
exit($json);
} elseif ($_REQUEST['type'] == 'applications') {
// Device search
$results = dbFetchRows(
"SELECT * FROM `applications` INNER JOIN `devices` AS `D` ON `D`.`device_id` = `applications`.`device_id` WHERE $perms_sql (`app_type` LIKE ? OR `hostname` LIKE ?) ORDER BY hostname LIMIT ?",
array_merge($device_ids, ["%$search%", "%$search%", $limit])
);
if (count($results)) {
$found = 1;
$devices = count($results);
foreach ($results as $result) {
$name = $result['app_type'];
if ($result['disabled'] == 1) {
$highlight_colour = '#808080';
} elseif ($result['ignored'] == 1 && $result['disabled'] == 0) {
$highlight_colour = '#000000';
} elseif ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#ff0000';
} elseif ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#008000';
}
$device[] = [
'name' => $name,
'hostname' => format_hostname($result),
'app_id' => $result['app_id'],
'device_id' => $result['device_id'],
'colours' => $highlight_colour,
'device_image' => getIcon($result),
'device_hardware' => $result['hardware'],
'device_os' => \LibreNMS\Config::getOsSetting($result['os'], 'text'),
'version' => $result['version'],
'location' => $result['location'],
];
}//end foreach
}//end if
$json = json_encode($device);
exit($json);
} elseif ($_REQUEST['type'] == 'munin') {
// Device search
$results = dbFetchRows(
"SELECT * FROM `munin_plugins` INNER JOIN `devices` AS `D` ON `D`.`device_id` = `munin_plugins`.`device_id` WHERE $perms_sql (`mplug_type` LIKE ? OR `mplug_title` LIKE ? OR `hostname` LIKE ?) ORDER BY hostname LIMIT ?",
array_merge($device_ids, ["%$search%", "%$search%", "%$search%", $limit])
);
if (count($results)) {
$found = 1;
$devices = count($results);
foreach ($results as $result) {
$name = $result['mplug_title'];
if ($result['disabled'] == 1) {
$highlight_colour = '#808080';
} elseif ($result['ignored'] == 1 && $result['disabled'] == 0) {
$highlight_colour = '#000000';
} elseif ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#ff0000';
} elseif ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#008000';
}
$device[] = [
'name' => $name,
'hostname' => format_hostname($result),
'device_id' => $result['device_id'],
'colours' => $highlight_colour,
'device_image' => getIcon($result),
'device_hardware' => $result['hardware'],
'device_os' => \LibreNMS\Config::getOsSetting($result['os'], 'text'),
'version' => $result['version'],
'location' => $result['location'],
'plugin' => $result['mplug_type'],
];
}//end foreach
}//end if
$json = json_encode($device);
exit($json);
} elseif ($_REQUEST['type'] == 'iftype') {
// Device search
$results = dbFetchRows(
"SELECT `ports`.ifType FROM `ports` WHERE $perms_sql `ifType` LIKE ? GROUP BY ifType ORDER BY ifType LIMIT ?",
array_merge($device_ids, ["%$search%", $limit])
);
if (count($results)) {
$found = 1;
$devices = count($results);
foreach ($results as $result) {
$device[] = [
'filter' => $result['ifType'],
];
}//end foreach
}//end if
$json = json_encode($device);
exit($json);
} elseif ($_REQUEST['type'] == 'bill') {
// Device search
if (Auth::user()->hasGlobalRead()) {
$results = dbFetchRows(
'SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` WHERE `bill_name` LIKE ? OR `bill_notes` LIKE ? LIMIT ?',
["%$search%", "%$search%", $limit]
);
} else {
$results = dbFetchRows(
'SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` INNER JOIN `bill_perms` ON `bills`.bill_id = `bill_perms`.bill_id WHERE `bill_perms`.user_id = ? AND (`bill_name` LIKE ? OR `bill_notes` LIKE ?) LIMIT ?',
[Auth::id(), "%$search%", "%$search%", $limit]
);
}
$json = json_encode($results);
exit($json);
}//end if
}//end if
}//end if

File diff suppressed because one or more lines are too long

View File

@ -51,7 +51,7 @@ function var_get($v)
function toner2colour($descr, $percent)
{
$colour = \LibreNMS\Util\Colors::percentage(100 - $percent, null);
$colour = \LibreNMS\Util\Color::percentage(100 - $percent, null);
if (substr($descr, -1) == 'C' || stripos($descr, 'cyan') !== false) {
$colour['left'] = '55D6D3';

View File

@ -26,7 +26,7 @@ if ($width > '500') {
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr(short_hrDeviceDescr($mempool['mempool_descr']), $descr_len);
$perc = round($mempool['mempool_perc'], 0);
$background = \LibreNMS\Util\Colors::percentage($perc, $mempool['mempool_perc_warn']);
$background = \LibreNMS\Util\Color::percentage($perc, $mempool['mempool_perc_warn']);
$rrd_options .= " DEF:{$mempool['mempool_id']}used=$rrd_filename:used:AVERAGE";
$rrd_options .= " DEF:{$mempool['mempool_id']}free=$rrd_filename:free:AVERAGE";

View File

@ -35,7 +35,7 @@ $descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr(short_hrDeviceDescr($component
$perc = $components['memory_used'] * 100 / $components['memory_total'];
$background = \LibreNMS\Util\Colors::percentage($perc, 75);
$background = \LibreNMS\Util\Color::percentage($perc, 75);
$rrd_options .= " DEF:qfp_used=$rrd_filename:InUse:AVERAGE";
$rrd_options .= " DEF:qfp_free=$rrd_filename:Free:AVERAGE";

View File

@ -20,7 +20,7 @@ $descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($storage['storage_descr'], 16)
$percentage = round($storage['storage_perc'], 0);
$background = \LibreNMS\Util\Colors::percentage($percentage, $storage['storage_perc_warn']);
$background = \LibreNMS\Util\Color::percentage($percentage, $storage['storage_perc_warn']);
$rrd_options .= " DEF:used=$rrd_filename:used:AVERAGE";
$rrd_options .= " DEF:free=$rrd_filename:free:AVERAGE";

View File

@ -14,7 +14,7 @@ if ($colour['left'] == null) {
$descr = \LibreNMS\Data\Store\Rrd::safeDescr(substr(str_pad($toner['supply_descr'], 26), 0, 26));
$background = \LibreNMS\Util\Colors::percentage((100 - $toner['supply_current']));
$background = \LibreNMS\Util\Color::percentage((100 - $toner['supply_current']));
$rrd_options .= ' DEF:toner' . $toner['supply_id'] . '=' . $rrd_filename . ':toner:AVERAGE ';

View File

@ -161,7 +161,7 @@ if (bill_permitted($bill_id)) {
$percent = round((($total_data) / $bill_data['bill_quota'] * 100), 2);
$unit = 'MB';
$total_data = round($total_data, 2);
$background = \LibreNMS\Util\Colors::percentage($percent, null);
$background = \LibreNMS\Util\Color::percentage($percent, null);
$type = '&amp;ave=yes'; ?>
<td>
<?php echo format_bytes_billing($total_data) ?> of <?php echo format_bytes_billing($bill_data['bill_quota']) . ' (' . $percent . '%)' ?>
@ -181,7 +181,7 @@ if (bill_permitted($bill_id)) {
$cdr = $bill_data['bill_cdr'];
$rate_95th = round($rate_95th, 2);
$percent = round((($rate_95th) / $cdr * 100), 2);
$background = \LibreNMS\Util\Colors::percentage($percent, null);
$background = \LibreNMS\Util\Color::percentage($percent, null);
$type = '&amp;95th=yes'; ?>
<td>
<?php echo \LibreNMS\Util\Number::formatSi($rate_95th, 2, 3, '') . 'bps' ?> of <?php echo \LibreNMS\Util\Number::formatSi($cdr, 2, 3, '') . 'bps (' . $percent . '%)' ?> (95th%ile)

View File

@ -78,7 +78,7 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY
$rate_95th = Number::formatSi($history['rate_95th'], 2, 3, 'bps');
$total_data = Number::formatBase($history['traf_total'], \LibreNMS\Config::get('billing.base'), 2, 3, '');
$background = \LibreNMS\Util\Colors::percentage($percent, null);
$background = \LibreNMS\Util\Color::percentage($percent, null);
if ($type == 'CDR') {
$allowed = Number::formatSi($history['bill_allowed'], 2, 3, 'bps');

View File

@ -47,21 +47,21 @@ if ($bill_data['bill_type'] == 'quota') {
} else {
$total['per'] = round(($bill_data['total_data'] / ($bill_data['total_data'] / $cur_days * $total_days) * 100), 2);
}
$total['bg'] = \LibreNMS\Util\Colors::percentage($total['per'], null);
$total['bg'] = \LibreNMS\Util\Color::percentage($total['per'], null);
$in['data'] = format_bytes_billing($bill_data['total_data_in']);
$in['allow'] = $total['allow'];
$in['ave'] = format_bytes_billing(($bill_data['total_data_in'] / $cur_days));
$in['est'] = format_bytes_billing(($bill_data['total_data_in'] / $cur_days * $total_days));
$in['per'] = ! empty($bill_data['total_data']) ? round(($bill_data['total_data_in'] / $bill_data['total_data'] * 100), 2) : 0;
$in['bg'] = \LibreNMS\Util\Colors::percentage($in['per'], null);
$in['bg'] = \LibreNMS\Util\Color::percentage($in['per'], null);
$out['data'] = format_bytes_billing($bill_data['total_data_out']);
$out['allow'] = $total['allow'];
$out['ave'] = format_bytes_billing(($bill_data['total_data_out'] / $cur_days));
$out['est'] = format_bytes_billing(($bill_data['total_data_out'] / $cur_days * $total_days));
$out['per'] = ! empty($bill_data['total_data']) ? round(($bill_data['total_data_out'] / $bill_data['total_data'] * 100), 2) : 0;
$out['bg'] = \LibreNMS\Util\Colors::percentage($out['per'], null);
$out['bg'] = \LibreNMS\Util\Color::percentage($out['per'], null);
$ousage['over'] = ($bill_data['total_data'] - ($bill_data['bill_quota']));
$ousage['over'] = (($ousage['over'] < 0) ? '0' : $ousage['over']);
@ -71,11 +71,11 @@ $ousage['ave'] = format_bytes_billing(($ousage['over'] / $cur_days));
$ousage['est'] = format_bytes_billing(($ousage['over'] / $cur_days * $total_days));
$ousage['per'] = round((($bill_data['total_data'] / $bill_data['bill_quota'] * 100) - 100), 2);
$ousage['per'] = (($ousage['per'] < 0) ? '0' : $ousage['per']);
$ousage['bg'] = \LibreNMS\Util\Colors::percentage($ousage['per'], null);
$ousage['bg'] = \LibreNMS\Util\Color::percentage($ousage['per'], null);
function showPercent($per)
{
$background = \LibreNMS\Util\Colors::percentage($per, null);
$background = \LibreNMS\Util\Color::percentage($per, null);
$right_background = $background['right'];
$left_background = $background['left'];
$res = print_percentage_bar(200, 20, $per, null, 'ffffff', $left_background, $per . '%', 'ffffff', $right_background);

View File

@ -50,10 +50,10 @@ foreach ($entity_state['group']['c6kxbar'] as $index => $entry) {
}
$percent_in = $fabric['cc6kxbarStatisticsInUtil'];
$background_in = \LibreNMS\Util\Colors::percentage($percent_in, null);
$background_in = \LibreNMS\Util\Color::percentage($percent_in, null);
$percent_out = $fabric['cc6kxbarStatisticsOutUtil'];
$background_out = \LibreNMS\Util\Colors::percentage($percent_out, null);
$background_out = \LibreNMS\Util\Color::percentage($percent_out, null);
$graph_array = [];
$graph_array['height'] = '100';

View File

@ -1,7 +1,7 @@
<?php
use Illuminate\Support\Arr;
use LibreNMS\Util\Colors;
use LibreNMS\Util\Color;
use LibreNMS\Util\Html;
use LibreNMS\Util\Number;
use LibreNMS\Util\Url;
@ -57,7 +57,7 @@ if ($mempools->isNotEmpty()) {
$total = Number::formatBi($mempool->mempool_total);
$used = Number::formatBi($mempool->mempool_used);
$free = Number::formatBi($mempool->mempool_free);
$percent_colors = Colors::percentage($mempool->mempool_perc, $mempool->mempool_perc_warn ?: null);
$percent_colors = Color::percentage($mempool->mempool_perc, $mempool->mempool_perc_warn ?: null);
$graph_array = [
'type' => 'mempool_usage',

View File

@ -27,7 +27,7 @@ if (count($processors)) {
$percent = $proc['processor_usage'];
if (\LibreNMS\Config::get('cpu_details_overview') === true) {
$background = \LibreNMS\Util\Colors::percentage($percent, $proc['processor_perc_warn']);
$background = \LibreNMS\Util\Color::percentage($percent, $proc['processor_perc_warn']);
$graph_array['id'] = $proc['processor_id'];
@ -95,7 +95,7 @@ if (count($processors)) {
//Add a row with CPU desc, count and percent graph
$percent_usage = ceil($values['usage'] / $values['count']);
$percent_warn = $values['warn'] / $values['count'];
$background = \LibreNMS\Util\Colors::percentage($percent_usage, $percent_warn);
$background = \LibreNMS\Util\Color::percentage($percent_usage, $percent_warn);
echo '
<tr>

View File

@ -46,7 +46,7 @@ if (count($drives)) {
$total = Number::formatBi($drive['storage_size']);
$free = Number::formatBi($drive['storage_free']);
$used = Number::formatBi($drive['storage_used']);
$background = \LibreNMS\Util\Colors::percentage($percent, $drive['storage_perc_warn']);
$background = \LibreNMS\Util\Color::percentage($percent, $drive['storage_perc_warn']);
$graph_array = [];
$graph_array['height'] = '100';

View File

@ -135,7 +135,7 @@ foreach (dbFetchRows($sql, $param) as $bill) {
$total_data = "<b>$total_data</b>";
}
$background = \LibreNMS\Util\Colors::percentage($percent, null);
$background = \LibreNMS\Util\Color::percentage($percent, null);
$right_background = $background['right'];
$left_background = $background['left'];
$overuse_formatted = (($overuse <= 0) ? '-' : "<span style='color: #${background['left']}; font-weight: bold;'>$overuse_formatted</span>");

View File

@ -67,7 +67,7 @@ foreach (dbFetchRows($sql, $param) as $processor) {
$graph_array_zoom['width'] = '400';
$link = 'graphs/id=' . $graph_array['id'] . '/type=' . $graph_array['type'] . '/from=' . $graph_array['from'] . '/to=' . $graph_array['to'] . '/';
$mini_graph = \LibreNMS\Util\Url::overlibLink($link, \LibreNMS\Util\Url::graphTag($graph_array), \LibreNMS\Util\Url::graphTag($graph_array_zoom));
$background = \LibreNMS\Util\Colors::percentage($perc, $processor['processor_perc_warn']);
$background = \LibreNMS\Util\Color::percentage($perc, $processor['processor_perc_warn']);
$bar_link = \LibreNMS\Util\Url::overlibLink($link, print_percentage_bar(400, 20, $perc, $perc . '%', 'ffffff', $background['left'], (100 - $perc) . '%', 'ffffff', $background['right']), \LibreNMS\Util\Url::graphTag($graph_array_zoom));
$response[] = [

View File

@ -79,7 +79,7 @@ foreach (dbFetchRows($sql, $param) as $drive) {
$graph_array_zoom['width'] = '400';
$link = 'graphs/id=' . $graph_array['id'] . '/type=' . $graph_array['type'] . '/from=' . $graph_array['from'] . '/to=' . $graph_array['to'] . '/';
$mini_graph = \LibreNMS\Util\Url::overlibLink($link, \LibreNMS\Util\Url::graphTag($graph_array), \LibreNMS\Util\Url::graphTag($graph_array_zoom));
$background = \LibreNMS\Util\Colors::percentage($perc, $drive['storage_perc_warn']);
$background = \LibreNMS\Util\Color::percentage($perc, $drive['storage_perc_warn']);
$bar_link = \LibreNMS\Util\Url::overlibLink($link, print_percentage_bar(400, 20, $perc, "$used / $total", 'ffffff', $background['left'], $free, 'ffffff', $background['right']), \LibreNMS\Util\Url::graphTag($graph_array_zoom));
$response[] = [

View File

@ -70,7 +70,7 @@ foreach (dbFetchRows($sql, $param) as $toner) {
$graph_array_zoom['width'] = '400';
$link = 'graphs/id=' . $graph_array['id'] . '/type=' . $graph_array['type'] . '/from=' . $graph_array['from'] . '/to=' . $graph_array['to'] . '/';
$mini_graph = \LibreNMS\Util\Url::overlibLink($link, \LibreNMS\Util\Url::graphTag($graph_array), \LibreNMS\Util\Url::graphTag($graph_array_zoom));
$background = \LibreNMS\Util\Colors::percentage(100 - $perc, null);
$background = \LibreNMS\Util\Color::percentage(100 - $perc, null);
$bar_link = print_percentage_bar(400, 20, $perc, "$perc%", 'ffffff', $background['left'], $free, 'ffffff', $background['right']);
$response[] = [

View File

@ -545,7 +545,7 @@ devices:
- { Field: disable_notify, Type: tinyint, 'Null': false, Extra: '', Default: '0' }
Indexes:
PRIMARY: { Name: PRIMARY, Columns: [device_id], Unique: true, Type: BTREE }
devices_hostname_index: { Name: devices_hostname_index, Columns: [hostname], Unique: false, Type: BTREE }
devices_hostname_sysname_display_index: { Name: devices_hostname_sysname_display_index, Columns: [hostname, sysName, display], Unique: false, Type: BTREE }
devices_last_poll_attempted_index: { Name: devices_last_poll_attempted_index, Columns: [last_poll_attempted], Unique: false, Type: BTREE }
devices_last_polled_index: { Name: devices_last_polled_index, Columns: [last_polled], Unique: false, Type: BTREE }
devices_os_index: { Name: devices_os_index, Columns: [os], Unique: false, Type: BTREE }
@ -614,7 +614,7 @@ device_outages:
- { Field: going_down, Type: bigint, 'Null': false, Extra: '' }
- { Field: up_again, Type: bigint, 'Null': true, Extra: '' }
Indexes:
PRIMARY: { Name: PRIMARY, Columns: [ id ], Unique: true, Type: BTREE }
PRIMARY: { Name: PRIMARY, Columns: [id], Unique: true, Type: BTREE }
device_outages_device_id_going_down_unique: { Name: device_outages_device_id_going_down_unique, Columns: [device_id, going_down], Unique: true, Type: BTREE }
device_outages_device_id_index: { Name: device_outages_device_id_index, Columns: [device_id], Unique: false, Type: BTREE }
device_perf:
@ -1441,9 +1441,9 @@ ports:
- { Field: ifAdminStatus_prev, Type: varchar(16), 'Null': true, Extra: '' }
- { Field: ifDuplex, Type: varchar(12), 'Null': true, Extra: '' }
- { Field: ifMtu, Type: int, 'Null': true, Extra: '' }
- { Field: ifType, Type: text, 'Null': true, Extra: '' }
- { Field: ifAlias, Type: text, 'Null': true, Extra: '' }
- { Field: ifPhysAddress, Type: text, 'Null': true, Extra: '' }
- { Field: ifType, Type: varchar(64), 'Null': true, Extra: '' }
- { Field: ifAlias, Type: varchar(255), 'Null': true, Extra: '' }
- { Field: ifPhysAddress, Type: varchar(64), 'Null': true, Extra: '' }
- { Field: ifHardType, Type: varchar(64), 'Null': true, Extra: '' }
- { Field: ifLastChange, Type: 'bigint unsigned', 'Null': false, Extra: '', Default: '0' }
- { Field: ifVlan, Type: varchar(8), 'Null': false, Extra: '', Default: '' }
@ -1495,7 +1495,8 @@ ports:
Indexes:
PRIMARY: { Name: PRIMARY, Columns: [port_id], Unique: true, Type: BTREE }
ports_device_id_ifindex_unique: { Name: ports_device_id_ifindex_unique, Columns: [device_id, ifIndex], Unique: true, Type: BTREE }
ports_ifdescr_index: { Name: ports_ifdescr_index, Columns: [ifDescr], Unique: false, Type: BTREE }
ports_ifalias_port_descr_descr_portname_index: { Name: ports_ifalias_port_descr_descr_portname_index, Columns: [ifAlias, port_descr_descr, portName], Unique: false, Type: BTREE }
ports_ifdescr_ifname_index: { Name: ports_ifdescr_ifname_index, Columns: [ifDescr, ifName], Unique: false, Type: BTREE }
ports_adsl:
Columns:
- { Field: port_id, Type: 'int unsigned', 'Null': false, Extra: '' }
@ -1994,12 +1995,12 @@ syslog:
Indexes:
PRIMARY: { Name: PRIMARY, Columns: [seq], Unique: true, Type: BTREE }
syslog_device_id_index: { Name: syslog_device_id_index, Columns: [device_id], Unique: false, Type: BTREE }
syslog_device_id_priority_index: { Name: syslog_device_id_priority_index, Columns: [device_id, priority], Unique: false, Type: BTREE }
syslog_device_id_program_index: { Name: syslog_device_id_program_index, Columns: [device_id, program], Unique: false, Type: BTREE }
syslog_device_id_timestamp_index: { Name: syslog_device_id_timestamp_index, Columns: [device_id, timestamp], Unique: false, Type: BTREE }
syslog_priority_level_index: { Name: syslog_priority_level_index, Columns: [priority, level], Unique: false, Type: BTREE }
syslog_program_index: { Name: syslog_program_index, Columns: [program], Unique: false, Type: BTREE }
syslog_timestamp_index: { Name: syslog_timestamp_index, Columns: [timestamp], Unique: false, Type: BTREE }
syslog_device_id_program_index: { Name: syslog_device_id_program_index, Columns: [device_id, program], Unique: false, Type: BTREE }
syslog_device_id_priority_index: { Name: syslog_device_id_priority_index, Columns: [device_id, priority], Unique: false, Type: BTREE }
tnmsneinfo:
Columns:
- { Field: id, Type: 'int unsigned', 'Null': false, Extra: auto_increment }

View File

@ -378,33 +378,6 @@ parameters:
count: 1
path: html/ajax_listports.php
-
message:
"""
#^Call to deprecated function dbFetchCell\\(\\)\\:
Please use Eloquent instead; https\\://laravel\\.com/docs/eloquent$#
"""
count: 1
path: html/ajax_search.php
-
message:
"""
#^Call to deprecated function dbFetchRows\\(\\)\\:
Please use Eloquent instead; https\\://laravel\\.com/docs/eloquent$#
"""
count: 11
path: html/ajax_search.php
-
message:
"""
#^Call to deprecated function dbGenPlaceholders\\(\\)\\:
Please use Eloquent instead; https\\://laravel\\.com/docs/eloquent$#
"""
count: 1
path: html/ajax_search.php
-
message:
"""

View File

@ -5380,21 +5380,6 @@ parameters:
count: 1
path: LibreNMS/Util/CiHelper.php
-
message: "#^Method LibreNMS\\\\Util\\\\Colors\\:\\:percentage\\(\\) has no return type specified\\.$#"
count: 1
path: LibreNMS/Util/Colors.php
-
message: "#^Method LibreNMS\\\\Util\\\\Colors\\:\\:percentage\\(\\) has parameter \\$component_perc_warn with no type specified\\.$#"
count: 1
path: LibreNMS/Util/Colors.php
-
message: "#^Method LibreNMS\\\\Util\\\\Colors\\:\\:percentage\\(\\) has parameter \\$percentage with no type specified\\.$#"
count: 1
path: LibreNMS/Util/Colors.php
-
message: "#^Property LibreNMS\\\\Util\\\\Dns\\:\\:\\$resolver has no type specified\\.$#"
count: 1

View File

@ -604,7 +604,7 @@
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: ajax_url + "_search.php?search=%QUERY&type=device",
url: ajax_url + "/search/device?search=%QUERY",
filter: function (devices) {
return $.map(devices, function (device) {
return {
@ -627,11 +627,10 @@
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: ajax_url + "_search.php?search=%QUERY&type=ports",
url: ajax_url + "/search/port/?search=%QUERY",
filter: function (ports) {
return $.map(ports, function (port) {
return {
count: port.count,
url: port.url,
name: port.name,
description: port.description,
@ -647,11 +646,10 @@
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: ajax_url + "_search.php?search=%QUERY&type=bgp",
url: ajax_url + "/search/bgp/?search=%QUERY",
filter: function (bgp_sessions) {
return $.map(bgp_sessions, function (bgp) {
return {
count: bgp.count,
url: bgp.url,
name: bgp.name,
description: bgp.description,
@ -679,10 +677,7 @@
$('#gsearch').typeahead({
hint: true,
highlight: true,
minLength: 1,
classNames: {
menu: cssMenu
}
minLength: 1
},
{
source: devices.ttAdapter(),
@ -692,7 +687,7 @@
valueKey: 'name',
templates: {
header: '<h5><strong>&nbsp;Devices</strong></h5>',
suggestion: Handlebars.compile('<p><a href="@{{url}}"><img src="@{{device_image}}" border="0"> <small><strong>@{{name}}</strong> | @{{device_os}} | @{{version}} | @{{device_hardware}} with @{{device_ports}} port(s) | @{{location}}</small></a></p>')
suggestion: Handlebars.compile('<p><a href="@{{url}}"><img src="@{{device_image}}" style="float: left; min-height: 32px; margin-right: 5px;"> <small><strong>@{{name}}</strong> | @{{device_os}} | @{{version}} <br /> @{{device_hardware}} with @{{device_ports}} port(s) | @{{location}}</small></a></p>')
}
},
{

View File

@ -108,6 +108,9 @@ Route::group(['middleware' => ['auth'], 'guard' => 'auth'], function () {
Route::resource('pollergroup', 'PollerGroupController', ['only' => ['destroy']]);
// misc ajax controllers
Route::group(['namespace' => 'Ajax'], function () {
Route::get('search/bgp', 'BgpSearchController');
Route::get('search/device', 'DeviceSearchController');
Route::get('search/port', 'PortSearchController');
Route::post('set_map_group', 'AvailabilityMapController@setGroup');
Route::post('set_map_view', 'AvailabilityMapController@setView');
Route::post('set_resolution', 'ResolutionController@set');