mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updated global search both design wise and added bgp support
This commit is contained in:
@@ -41,7 +41,6 @@ if (isset($_REQUEST['search']))
|
|||||||
foreach ($results as $result)
|
foreach ($results as $result)
|
||||||
{
|
{
|
||||||
$name = $result['hostname'];
|
$name = $result['hostname'];
|
||||||
if (strlen($name) > 36) { $name = substr($name, 0, 36) . "..."; }
|
|
||||||
if($result['disabled'] == 1)
|
if($result['disabled'] == 1)
|
||||||
{
|
{
|
||||||
$highlight_colour = '#808080';
|
$highlight_colour = '#808080';
|
||||||
@@ -85,15 +84,7 @@ if (isset($_REQUEST['search']))
|
|||||||
foreach ($results as $result)
|
foreach ($results as $result)
|
||||||
{
|
{
|
||||||
$name = $result['ifDescr'];
|
$name = $result['ifDescr'];
|
||||||
if (strlen($name) > 36)
|
|
||||||
{
|
|
||||||
$name = substr($name, 0, 36) . "...";
|
|
||||||
}
|
|
||||||
$description = $result['ifAlias'];
|
$description = $result['ifAlias'];
|
||||||
if (strlen($description) > 50)
|
|
||||||
{
|
|
||||||
$description = substr($description, 0, 50) . "...";
|
|
||||||
}
|
|
||||||
|
|
||||||
if($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0))
|
if($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0))
|
||||||
{
|
{
|
||||||
@@ -135,6 +126,54 @@ if (isset($_REQUEST['search']))
|
|||||||
print_r($json);
|
print_r($json);
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
} elseif($_REQUEST['type'] == 'bgp') {
|
||||||
|
// Search bgp peers
|
||||||
|
$results = dbFetchRows("SELECT `bgpPeers`.* AS B,`devices`.* AS D FROM `bgpPeers` LEFT JOIN `devices` ON `bgpPeers`.`device_id` = `devices`.`device_id` WHERE `astext` LIKE '%" . $search . "%' OR `bgpPeerIdentifier` LIKE '%" . $search . "%' OR `bgpPeerRemoteAs` LIKE '%" . $search . "%' ORDER BY `astext` LIMIT 8");
|
||||||
|
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 = "images/16/brick_link.png"; } else { $bgp_image = "images/16/world_link.png"; }
|
||||||
|
|
||||||
|
$bgp[]=array('count'=>count($results),
|
||||||
|
'url'=>generate_peer_url($result),
|
||||||
|
'name'=>$name,
|
||||||
|
'description'=>$description,
|
||||||
|
'localas'=>$localas,
|
||||||
|
'bgp_image'=>$bgp_image,
|
||||||
|
'remoteas'=>$remoteas,
|
||||||
|
'colours'=>$port_colour,
|
||||||
|
'hostname'=>$result['hostname']);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$json = json_encode($bgp);
|
||||||
|
print_r($json);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1607,3 +1607,8 @@ tr.search:nth-child(odd) {
|
|||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tt-dropdown-menu
|
||||||
|
{
|
||||||
|
min-width: 500px;
|
||||||
|
}
|
||||||
|
@@ -450,6 +450,11 @@ function generate_port_url($port, $vars=array())
|
|||||||
return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']), $vars);
|
return generate_url(array('page' => 'device', 'device' => $port['device_id'], 'tab' => 'port', 'port' => $port['port_id']), $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generate_peer_url($peer, $vars=array())
|
||||||
|
{
|
||||||
|
return generate_url(array('page' => 'device', 'device' => $peer['device_id'], 'tab' => 'routing', 'proto' => 'bgp'), $vars);
|
||||||
|
}
|
||||||
|
|
||||||
function generate_port_image($args)
|
function generate_port_image($args)
|
||||||
{
|
{
|
||||||
if (!$args['bg']) { $args['bg'] = "FFFFFF"; }
|
if (!$args['bg']) { $args['bg'] = "FFFFFF"; }
|
||||||
|
@@ -472,14 +472,9 @@ if(is_file("includes/print-menubar-custom.inc.php"))
|
|||||||
|
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li style="padding-top:10px">
|
<li style="padding-top:10px">
|
||||||
<form role="form" class="pull-left form-horizontal">
|
<form role="search class="navbar-form navbar-left">
|
||||||
<div class="form-group row">
|
<div class="form-group">
|
||||||
<div class="col-md-10">
|
|
||||||
<input class="input-large search-query" type="search" id="gsearch" name="gsearch" placeholder="Global Search" style="width: 250px">
|
<input class="input-large search-query" type="search" id="gsearch" name="gsearch" placeholder="Global Search" style="width: 250px">
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
@@ -547,18 +542,26 @@ if ($_SESSION['authenticated'])
|
|||||||
{
|
{
|
||||||
name: 'devices',
|
name: 'devices',
|
||||||
remote : 'ajax_search.php?search=%QUERY&type=device',
|
remote : 'ajax_search.php?search=%QUERY&type=device',
|
||||||
header: '<h5><strong>Devices</strong></h5>',
|
header : '<h5><strong> Devices</strong></h5>',
|
||||||
template: '<p"><img src="{{device_image}}" border="0" class="img_left"> <small><a href="{{url}}"><strong>{{name}}</strong> | {{device_os}} | {{version}} | {{device_hardware}} with {{device_ports}} port(s) | {{location}}</a></small></p>',
|
template: '<p><img src="{{device_image}}" border="0" class="img_left"> <small><a href="{{url}}"><strong>{{name}}</strong> | {{device_os}} | {{version}} | {{device_hardware}} with {{device_ports}} port(s) | {{location}}</a></small></p>',
|
||||||
valueKey:"name",
|
valueKey:"name",
|
||||||
engine: Hogan
|
engine: Hogan
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ports',
|
name: 'ports',
|
||||||
remote : 'ajax_search.php?search=%QUERY&type=ports',
|
remote : 'ajax_search.php?search=%QUERY&type=ports',
|
||||||
header: '<h5><strong>Ports</strong></h5>',
|
header : '<h5><strong> Ports</strong></h5>',
|
||||||
template: '<p><small><a href="{{url}}"><img src="images/icons/port.png" /> <strong>{{name}}</strong> – {{hostname}}</a></small></p>',
|
template: '<p><small><a href="{{url}}"><img src="images/icons/port.png" /> <strong>{{name}}</strong> – {{hostname}}</a></small></p>',
|
||||||
valueKey: "name",
|
valueKey: "name",
|
||||||
engine: Hogan
|
engine: Hogan
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'bgp',
|
||||||
|
remote : 'ajax_search.php?search=%QUERY&type=bgp',
|
||||||
|
header : '<h5><strong> BGP</strong></h5>',
|
||||||
|
template: '<p><small><a href="{{url}}"><img src="{{bgp_image}}" border="0" class="img_left">{{name}} - {{hostname}}<br />AS{{localas}} -> AS{{remoteas}}</a></small></p>',
|
||||||
|
valueKey: 'name',
|
||||||
|
engine: Hogan
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
</script>
|
</script>
|
||||||
|
@@ -127,8 +127,8 @@ if ($config['page_title']) { $config['page_title_prefix'] = $config['page_title'
|
|||||||
if ($config['page_refresh']) { echo(' <meta http-equiv="refresh" content="'.$config['page_refresh'].'" />' . "\n"); }
|
if ($config['page_refresh']) { echo(' <meta http-equiv="refresh" content="'.$config['page_refresh'].'" />' . "\n"); }
|
||||||
?>
|
?>
|
||||||
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
||||||
<link href="<?php echo($config['stylesheet']); ?>" rel="stylesheet" type="text/css" />
|
|
||||||
<link href="css/typeahead.js-bootstrap.css" rel="stylesheet" type="text/css" />
|
<link href="css/typeahead.js-bootstrap.css" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="<?php echo($config['stylesheet']); ?>" rel="stylesheet" type="text/css" />
|
||||||
<script src="js/jquery.min.js"></script>
|
<script src="js/jquery.min.js"></script>
|
||||||
<script src="js/bootstrap.min.js"></script>
|
<script src="js/bootstrap.min.js"></script>
|
||||||
<script src="js/bootstrap-hover-dropdown.min.js"></script>
|
<script src="js/bootstrap-hover-dropdown.min.js"></script>
|
||||||
|
Reference in New Issue
Block a user