mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
This reverts commit c273ab28af.
This commit is contained in:
@@ -29,7 +29,7 @@ if (isset($_REQUEST['search'])) {
|
||||
}
|
||||
|
||||
if ($_REQUEST['type'] == 'group') {
|
||||
foreach (dbFetchRows("SELECT id, name FROM device_groups WHERE name LIKE ?", ["%$search%"]) as $group) {
|
||||
foreach (dbFetchRows("SELECT id,name FROM device_groups WHERE name LIKE ?", ["%$search%"]) as $group) {
|
||||
if ($_REQUEST['map']) {
|
||||
$results[] = array(
|
||||
'name' => 'g:'.$group['name'],
|
||||
@@ -50,23 +50,13 @@ if (isset($_REQUEST['search'])) {
|
||||
} elseif ($_REQUEST['type'] == 'device') {
|
||||
// Device search
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
if (\LibreNMS\Util\IPv4::isValid($search, false) || \LibreNMS\Util\IPv6::isValid($search, false)) {
|
||||
// Device search ip, overwrite_ip, or hostname by address; sort by ip
|
||||
$results = dbFetchRows(
|
||||
"SELECT *, inet6_ntoa(`ip`) as `ntoa_ip` FROM `devices` LEFT JOIN `locations` on `locations`.`id` = `devices`.`location_id` WHERE inet6_ntoa(`devices`.`ip`) LIKE ? OR `devices`.`overwrite_ip` LIKE ? OR `devices`.`hostname` LIKE ? ORDER BY `ip`, `hostname` LIMIT ?",
|
||||
["$search%", "$search%", "$search%", $limit]
|
||||
);
|
||||
} else {
|
||||
// Device search ip, overwrite_ip, hostname, location, sysname, purpose, or notes; sort by hostname
|
||||
$results = dbFetchRows(
|
||||
"SELECT *, inet6_ntoa(ip) as `ntoa_ip` FROM `devices` LEFT JOIN `locations` ON `locations`.`id` = `devices`.`location_id` WHERE inet6_ntoa(`devices`.`ip`) LIKE ? OR `devices`.`overwrite_ip` LIKE ? OR `devices`.`hostname` LIKE ? OR `locations`.`location` LIKE ? OR `devices`.`sysName` LIKE ? OR `devices`.`purpose` LIKE ? OR `devices`.`notes` LIKE ? ORDER BY `devices`.`hostname` LIMIT ?",
|
||||
["%$search%", "%$search%", "%$search%", "%$search%", "%$search%", "%$search%", "%$search%", $limit]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Device search hostname, sysname, or location by non-address for users without global read access
|
||||
$results = dbFetchRows(
|
||||
"SELECT *, inet6_ntoa(ip) as `ntoa_ip` FROM `devices` AS `D` LEFT JOIN `locations` ON `locations`.`id` = `D`.`location_id` WHERE $perms_sql AND (D.`hostname` LIKE ? OR D.`sysName` LIKE ? OR `locations`.`location` LIKE ?) ORDER BY hostname LIMIT ?",
|
||||
"SELECT * FROM `devices` LEFT JOIN `locations` ON `locations`.`id` = `devices`.`location_id` WHERE `devices`.`hostname` LIKE ? OR `locations`.`location` LIKE ? OR `devices`.`sysName` LIKE ? OR `devices`.`purpose` LIKE ? OR `devices`.`notes` LIKE ? ORDER BY `devices`.hostname LIMIT ?",
|
||||
["%$search%", "%$search%", "%$search%", "%$search%", "%$search%", $limit]
|
||||
);
|
||||
} else {
|
||||
$results = dbFetchRows(
|
||||
"SELECT * FROM `devices` AS `D` LEFT JOIN `locations` ON `locations`.`id` = `D`.`location_id` WHERE $perms_sql AND (D.`hostname` LIKE ? OR D.`sysName` LIKE ? OR `locations`.`location` LIKE ?) ORDER BY hostname LIMIT ?",
|
||||
array_merge($device_ids, ["%$search%", "%$search%", "%$search%", $limit])
|
||||
);
|
||||
}
|
||||
@@ -92,6 +82,7 @@ if (isset($_REQUEST['search'])) {
|
||||
|
||||
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D` WHERE ' . $perms_sql . ' AND `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[] = array(
|
||||
'name' => $name,
|
||||
'device_id' => $result['device_id'],
|
||||
@@ -100,10 +91,9 @@ if (isset($_REQUEST['search'])) {
|
||||
'device_ports' => $num_ports,
|
||||
'device_image' => getIcon($result),
|
||||
'device_hardware' => $result['hardware'],
|
||||
'device_os' => \LibreNMS\Config::getOsSetting($result['os'], 'text'),
|
||||
'device_os' => \LibreNMS\Config::getOsSetting($result['os'], 'text'),
|
||||
'version' => $result['version'],
|
||||
'location' => $result['location'],
|
||||
'device_ip' => $result['ntoa_ip']
|
||||
);
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
@@ -582,7 +582,6 @@
|
||||
device_image: device.device_image,
|
||||
url: device.url,
|
||||
name: device.name,
|
||||
device_ip: device.device_ip,
|
||||
device_os: device.device_os,
|
||||
version: device.version,
|
||||
device_hardware: device.device_hardware,
|
||||
@@ -663,7 +662,7 @@
|
||||
valueKey: 'name',
|
||||
templates: {
|
||||
header: '<h5><strong> Devices</strong></h5>',
|
||||
suggestion: Handlebars.compile('<p><a href="@{{url}}"><img src="@{{device_image}}" border="0"> <small><strong>@{{name}}</strong>@{{#if device_ip}} | <i>@{{device_ip}}</i>@{{/if}}@{{#if device_os}} | @{{device_os}}@{{/if}}@{{#if version}} @{{version}}@{{/if}}@{{#if device_hardware}} | @{{device_hardware}}@{{/if}}@{{#if device_ports}} with @{{device_ports}} port(s)@{{/if}}@{{#if location}} | @{{location}}@{{/if}}</small></a></p>')
|
||||
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>')
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -674,7 +673,7 @@
|
||||
valueKey: 'name',
|
||||
templates: {
|
||||
header: '<h5><strong> Ports</strong></h5>',
|
||||
suggestion: Handlebars.compile('<p><a href="@{{url}}"><small><i class="fa fa-link fa-sm icon-theme" aria-hidden="true"></i> <strong>@{{name}}</strong> - @{{hostname}}@{{#if description}} <i>@{{description}}</i>@{{/if}}</small></a></p>')
|
||||
suggestion: Handlebars.compile('<p><a href="@{{url}}"><small><i class="fa fa-link fa-sm icon-theme" aria-hidden="true"></i> <strong>@{{name}}</strong> – @{{hostname}}<br /><i>@{{description}}</i></small></a></p>')
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -685,7 +684,7 @@
|
||||
valueKey: 'name',
|
||||
templates: {
|
||||
header: '<h5><strong> BGP Sessions</strong></h5>',
|
||||
suggestion: Handlebars.compile('<p><a href="@{{url}}"><small><i class="@{{bgp_image}}" aria-hidden="true"></i> @{{name}} - @{{hostname}} - AS@{{localas}} -> AS@{{remoteas}}</small></a></p>')
|
||||
suggestion: Handlebars.compile('<p><a href="@{{url}}"><small><i class="@{{bgp_image}}" aria-hidden="true"></i> @{{name}} - @{{hostname}}<br />AS@{{localas}} -> AS@{{remoteas}}</small></a></p>')
|
||||
}
|
||||
}).on('typeahead:select', function (ev, suggestion) {
|
||||
window.location.href = suggestion.url;
|
||||
|
||||
Reference in New Issue
Block a user