mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
Updated global search for new typeahead
This commit is contained in:
+39
-14
@@ -1560,20 +1560,6 @@ tr.search:nth-child(odd) {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.tt-dropdown-menu
|
||||
{
|
||||
min-width: 500px;
|
||||
left: -400px !important;
|
||||
}
|
||||
|
||||
.twitter-typeahead .tt-hint {
|
||||
display: block;
|
||||
height: 34px;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.428571429;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.ui-autocomplete {
|
||||
max-height: 100px;
|
||||
@@ -1610,3 +1596,42 @@ tr.search:nth-child(odd) {
|
||||
display:block;
|
||||
min-width: 75%;
|
||||
}
|
||||
|
||||
.tt-menu {
|
||||
position: absolute;
|
||||
top: 95%;
|
||||
left: 2.5%;
|
||||
z-index: 100;
|
||||
display: none;
|
||||
min-width: 400px;
|
||||
margin-bottom: 20px;
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
-webkit-border-radius: 8px;
|
||||
-moz-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0px 0px 0px 1px green;
|
||||
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
.tt-open {
|
||||
position: absolute;
|
||||
top: 95%;
|
||||
left: 2.5%;
|
||||
z-index: 100;
|
||||
display: none;
|
||||
min-width: 400px;
|
||||
left: -400px !important;
|
||||
margin-bottom: 20px;
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
-webkit-border-radius: 8px;
|
||||
-moz-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0px 0px 0px 1px green;
|
||||
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
+108
-27
@@ -463,9 +463,9 @@ if(is_file("includes/print-menubar-custom.inc.php"))
|
||||
?>
|
||||
|
||||
</ul>
|
||||
<form role="search" class="navbar-form navbar-right">
|
||||
<form role="search" class="navbar-form navbar-right global-search">
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="search" id="gsearch" name="gsearch" placeholder="Global Search">
|
||||
<input class="form-control typeahead" type="search" id="gsearch" name="gsearch" placeholder="Global Search">
|
||||
</div>
|
||||
</form>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
@@ -552,30 +552,111 @@ if ($_SESSION['authenticated'])
|
||||
</div>
|
||||
</nav>
|
||||
<script>
|
||||
$('#gsearch').typeahead([
|
||||
{
|
||||
name: 'devices',
|
||||
remote : 'ajax_search.php?search=%QUERY&type=device',
|
||||
header : '<h5><strong> Devices</strong></h5>',
|
||||
template: '<a href="{{url}}"><p><img src="{{device_image}}" border="0" class="img_left"> <small><strong>{{name}}</strong> | {{device_os}} | {{version}} | {{device_hardware}} with {{device_ports}} port(s) | {{location}}</small></p></a>',
|
||||
valueKey:"name",
|
||||
engine: Hogan
|
||||
},
|
||||
{
|
||||
name: 'ports',
|
||||
remote : 'ajax_search.php?search=%QUERY&type=ports',
|
||||
header : '<h5><strong> Ports</strong></h5>',
|
||||
template: '<a href="{{url}}"><p><small><img src="images/icons/port.png" /> <strong>{{name}}</strong> – {{hostname}}<br /><i>{{description}}</i></small></p></a>',
|
||||
valueKey: "name",
|
||||
engine: Hogan
|
||||
},
|
||||
{
|
||||
name: 'bgp',
|
||||
remote : 'ajax_search.php?search=%QUERY&type=bgp',
|
||||
header : '<h5><strong> BGP</strong></h5>',
|
||||
template: '<a href="{{url}}"><p><small><img src="{{bgp_image}}" border="0" class="img_left">{{name}} - {{hostname}}<br />AS{{localas}} -> AS{{remoteas}}</small></p></a>',
|
||||
valueKey: "name",
|
||||
engine: Hogan
|
||||
var devices = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('device_id'),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=device",
|
||||
filter: function (devices) {
|
||||
return $.map(devices, function (device) {
|
||||
return {
|
||||
device_id: device.device_id,
|
||||
device_image: device.device_image,
|
||||
url: device.url,
|
||||
name: device.name,
|
||||
device_os: device.device_os,
|
||||
version: device.version,
|
||||
device_hardware: device.device_hardware,
|
||||
device_ports: device.device_ports,
|
||||
location: device.location
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
var ports = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=ports",
|
||||
filter: function (ports) {
|
||||
return $.map(ports, function (port) {
|
||||
return {
|
||||
count: port.count,
|
||||
url: port.url,
|
||||
name: port.name,
|
||||
description: port.description,
|
||||
colours: port.colours,
|
||||
hostname: port.hostname
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
var bgp = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=bgp",
|
||||
filter: function (bgp_sessions) {
|
||||
return $.map(bgp_sessions, function (bgp) {
|
||||
return {
|
||||
count: bgp.count,
|
||||
url: bgp.url,
|
||||
name: bgp.name,
|
||||
description: bgp.description,
|
||||
localas: bgp.localas,
|
||||
bgp_image: bgp.bgp_image,
|
||||
remoteas: bgp.remoteas,
|
||||
colours: bgp.colours,
|
||||
hostname: bgp.hostname
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
|
||||
devices.initialize();
|
||||
ports.initialize();
|
||||
$('#gsearch').typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1
|
||||
},
|
||||
{
|
||||
source: devices.ttAdapter(),
|
||||
async: true,
|
||||
disaply: name,
|
||||
limit: 8,
|
||||
templates: {
|
||||
header: '<h5><strong> Devices</strong></h5>',
|
||||
suggestion: Handlebars.compile('<p><a href="{{url}}"><img src="{{device_image}}" border="0" class="img_left"> <small><strong>{{name}}</strong> | {{device_os}} | {{version}} | {{device_hardware}} with {{device_ports}} port(s) | {{location}}</small></a></p>')
|
||||
}
|
||||
]);
|
||||
},
|
||||
{
|
||||
source: ports.ttAdapter(),
|
||||
async: true,
|
||||
disaply: name,
|
||||
limit: 8,
|
||||
templates: {
|
||||
header: '<h5><strong> Ports</strong></h5>',
|
||||
suggestion: Handlebars.compile('<a href="{{url}}"><p><small><img src="images/icons/port.png" /> <strong>{{name}}</strong> – {{hostname}}<br /><i>{{description}}</i></small></p></a>')
|
||||
}
|
||||
},
|
||||
{
|
||||
source: bgp.ttAdapter(),
|
||||
async: true,
|
||||
disaply: name,
|
||||
limit: 8,
|
||||
templates: {
|
||||
header: '<h5><strong> BGP Sessions</strong></h5>',
|
||||
suggestion: Handlebars.compile('<a href="{{url}}"><p><small><img src="{{bgp_image}}" border="0" class="img_left">{{name}} - {{hostname}}<br />AS{{localas}} -> AS{{remoteas}}</small></p></a>')
|
||||
}
|
||||
});
|
||||
$('#gsearch').bind('typeahead:open', function(ev, suggestion) {
|
||||
$('#gsearch').addClass('search-box');
|
||||
});
|
||||
</script>
|
||||
|
||||
+2
-2
@@ -128,7 +128,6 @@ if (empty($config['favicon'])) {
|
||||
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="css/toastr.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="css/typeahead.js-bootstrap.css" rel="stylesheet" type="text/css" />
|
||||
<link href="css/jquery-ui.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="css/jquery.bootgrid.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="css/tagmanager.css" rel="stylesheet" type="text/css" />
|
||||
@@ -145,11 +144,12 @@ if (empty($config['favicon'])) {
|
||||
<script src="js/jquery.cycle2.min.js"></script>
|
||||
<script src="js/moment.min.js"></script>
|
||||
<script src="js/bootstrap-datetimepicker.min.js"></script>
|
||||
<script src="js/typeahead.min.js"></script>
|
||||
<script src="js/typeahead.bundle.min.js"></script>
|
||||
<script src="js/jquery-ui.min.js"></script>
|
||||
<script src="js/tagmanager.js"></script>
|
||||
<script src="js/mktree.js"></script>
|
||||
<script src="js/jquery.bootgrid.min.js"></script>
|
||||
<script src="js/handlebars.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
<!-- Begin
|
||||
|
||||
Reference in New Issue
Block a user