mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updated all typeahead code to use new library
This commit is contained in:
@@ -1635,3 +1635,7 @@ tr.search:nth-child(odd) {
|
|||||||
-moz-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);
|
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.typeahead-left {
|
||||||
|
left: 0px !important;
|
||||||
|
}
|
||||||
|
@@ -147,24 +147,64 @@ $('#add-map').click('',function (event) {
|
|||||||
$('#map-stub').val('');
|
$('#map-stub').val('');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#map-stub').typeahead([
|
var map_devices = new Bloodhound({
|
||||||
{
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
name: 'map_devices',
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote : '/ajax_search.php?search=%QUERY&type=device&map=1',
|
remote: {
|
||||||
header : '<h5><strong> Devices</strong></h5>',
|
url: "ajax_search.php?search=%QUERY&type=device&map=1",
|
||||||
template: '{{name}}',
|
filter: function (output) {
|
||||||
valueKey:"name",
|
return $.map(output, function (item) {
|
||||||
engine: Hogan
|
return {
|
||||||
},
|
name: item.name,
|
||||||
{
|
};
|
||||||
name: 'map_groups',
|
});
|
||||||
remote : '/ajax_search.php?search=%QUERY&type=group&map=1',
|
},
|
||||||
header : '<h5><strong> Groups</strong></h5>',
|
wildcard: "%QUERY"
|
||||||
template: '{{name}}',
|
}
|
||||||
valueKey:"name",
|
});
|
||||||
engine: Hogan
|
var map_groups = new Bloodhound({
|
||||||
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
remote: {
|
||||||
|
url: "ajax_search.php?search=%QUERY&type=group&map=1",
|
||||||
|
filter: function (output) {
|
||||||
|
return $.map(output, function (item) {
|
||||||
|
return {
|
||||||
|
name: item.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
wildcard: "%QUERY"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
map_devices.initialize();
|
||||||
|
map_groups.initialize();
|
||||||
|
$('#map-stub').typeahead({
|
||||||
|
hint: true,
|
||||||
|
highlight: true,
|
||||||
|
minLength: 1,
|
||||||
|
classNames: {
|
||||||
|
menu: 'typeahead-left'
|
||||||
}
|
}
|
||||||
]);
|
},
|
||||||
|
{
|
||||||
|
source: map_devices.ttAdapter(),
|
||||||
|
async: true,
|
||||||
|
displayKey: 'name',
|
||||||
|
valueKey: name,
|
||||||
|
templates: {
|
||||||
|
suggestion: Handlebars.compile('<p> {{name}}</p>')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: map_groups.ttAdapter(),
|
||||||
|
async: true,
|
||||||
|
displayKey: 'name',
|
||||||
|
valueKey: name,
|
||||||
|
templates: {
|
||||||
|
suggestion: Handlebars.compile('<p> {{name}}</p>')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$("#start").datetimepicker({
|
$("#start").datetimepicker({
|
||||||
|
@@ -67,34 +67,98 @@ $('#create-map').on('show.bs.modal', function (event) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
var cache = {};
|
var cache = {};
|
||||||
$('#rule').typeahead([
|
var alert_rules = new Bloodhound({
|
||||||
{
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
name: 'map_rules',
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote : '/ajax_search.php?search=%QUERY&type=alert-rules',
|
remote: {
|
||||||
template: '{{name}}',
|
url: "ajax_search.php?search=%QUERY&type=alert-rules",
|
||||||
valueKey:"name",
|
filter: function (output) {
|
||||||
engine: Hogan
|
return $.map(output, function (item) {
|
||||||
|
return {
|
||||||
|
name: item.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
wildcard: "%QUERY"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alert_rules.initialize();
|
||||||
|
$('#rule').typeahead({
|
||||||
|
hint: true,
|
||||||
|
highlight: true,
|
||||||
|
minLength: 1,
|
||||||
|
classNames: {
|
||||||
|
menu: 'typeahead-left'
|
||||||
}
|
}
|
||||||
]);
|
},
|
||||||
|
{
|
||||||
|
source: alert_rules.ttAdapter(),
|
||||||
|
async: true,
|
||||||
|
displayKey: 'name',
|
||||||
|
valueKey: name,
|
||||||
|
templates: {
|
||||||
|
alert_rules: Handlebars.compile('<p> {{name}}</p>')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#target').typeahead([
|
var map_devices = new Bloodhound({
|
||||||
{
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
name: 'map_devices',
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote : '/ajax_search.php?search=%QUERY&type=device&map=1',
|
remote: {
|
||||||
header : '<h5><strong> Devices</strong></h5>',
|
url: "ajax_search.php?search=%QUERY&type=device&map=1",
|
||||||
template: '{{name}}',
|
filter: function (output) {
|
||||||
valueKey:"name",
|
return $.map(output, function (item) {
|
||||||
engine: Hogan
|
return {
|
||||||
},
|
name: item.name,
|
||||||
{
|
};
|
||||||
name: 'map_groups',
|
});
|
||||||
remote : '/ajax_search.php?search=%QUERY&type=group&map=1',
|
},
|
||||||
header : '<h5><strong> Groups</strong></h5>',
|
wildcard: "%QUERY"
|
||||||
template: '{{name}}',
|
}
|
||||||
valueKey:"name",
|
});
|
||||||
engine: Hogan
|
var map_groups = new Bloodhound({
|
||||||
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
remote: {
|
||||||
|
url: "ajax_search.php?search=%QUERY&type=group&map=1",
|
||||||
|
filter: function (output) {
|
||||||
|
return $.map(output, function (item) {
|
||||||
|
return {
|
||||||
|
name: item.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
wildcard: "%QUERY"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
map_devices.initialize();
|
||||||
|
map_groups.initialize();
|
||||||
|
$('#target').typeahead({
|
||||||
|
hint: true,
|
||||||
|
highlight: true,
|
||||||
|
minLength: 1,
|
||||||
|
classNames: {
|
||||||
|
menu: 'typeahead-left'
|
||||||
}
|
}
|
||||||
]);
|
},
|
||||||
|
{
|
||||||
|
source: map_devices.ttAdapter(),
|
||||||
|
async: true,
|
||||||
|
displayKey: 'name',
|
||||||
|
valueKey: name,
|
||||||
|
templates: {
|
||||||
|
suggestion: Handlebars.compile('<p> {{name}}</p>')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: map_groups.ttAdapter(),
|
||||||
|
async: true,
|
||||||
|
displayKey: 'name',
|
||||||
|
valueKey: name,
|
||||||
|
templates: {
|
||||||
|
suggestion: Handlebars.compile('<p> {{name}}</p>')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#map-submit').click('', function(e) {
|
$('#map-submit').click('', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@@ -206,33 +206,98 @@ $('#create-alert').on('show.bs.modal', function (event) {
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
var cache = {};
|
var cache = {};
|
||||||
$('#suggest').typeahead([
|
var suggestions = new Bloodhound({
|
||||||
{
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
name: 'suggestion',
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote : '/ajax_rulesuggest.php?device_id=<?php echo $device['device_id'];?>&term=%QUERY',
|
remote: {
|
||||||
template: '{{name}}',
|
url: "ajax_rulesuggest.php?device_id=<?php echo $device['device_id'];?>&term=%QUERY",
|
||||||
valueKey:"name",
|
filter: function (output) {
|
||||||
engine: Hogan
|
return $.map(output, function (item) {
|
||||||
|
return {
|
||||||
|
name: item.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
wildcard: "%QUERY"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
suggestions.initialize();
|
||||||
|
$('#suggest').typeahead({
|
||||||
|
hint: true,
|
||||||
|
highlight: true,
|
||||||
|
minLength: 1,
|
||||||
|
classNames: {
|
||||||
|
menu: 'typeahead-left'
|
||||||
}
|
}
|
||||||
]);
|
},
|
||||||
$('#map-stub').typeahead([
|
{
|
||||||
{
|
source: suggestions.ttAdapter(),
|
||||||
name: 'map_devices',
|
async: true,
|
||||||
remote : '/ajax_search.php?search=%QUERY&type=device&map=1',
|
displayKey: 'name',
|
||||||
header : '<h5><strong> Devices</strong></h5>',
|
valueKey: name,
|
||||||
template: '{{name}}',
|
templates: {
|
||||||
valueKey:"name",
|
suggestion: Handlebars.compile('<p> {{name}}</p>')
|
||||||
engine: Hogan
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'map_groups',
|
|
||||||
remote : '/ajax_search.php?search=%QUERY&type=group&map=1',
|
|
||||||
header : '<h5><strong> Groups</strong></h5>',
|
|
||||||
template: '{{name}}',
|
|
||||||
valueKey:"name",
|
|
||||||
engine: Hogan
|
|
||||||
}
|
}
|
||||||
]);
|
});
|
||||||
|
|
||||||
|
var map_devices = new Bloodhound({
|
||||||
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
remote: {
|
||||||
|
url: "ajax_search.php?search=%QUERY&type=device&map=1",
|
||||||
|
filter: function (output) {
|
||||||
|
return $.map(output, function (item) {
|
||||||
|
return {
|
||||||
|
name: item.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
wildcard: "%QUERY"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var map_groups = new Bloodhound({
|
||||||
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
remote: {
|
||||||
|
url: "ajax_search.php?search=%QUERY&type=group&map=1",
|
||||||
|
filter: function (output) {
|
||||||
|
return $.map(output, function (item) {
|
||||||
|
return {
|
||||||
|
name: item.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
wildcard: "%QUERY"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
map_devices.initialize();
|
||||||
|
map_groups.initialize();
|
||||||
|
$('#map-stub').typeahead({
|
||||||
|
hint: true,
|
||||||
|
highlight: true,
|
||||||
|
minLength: 1,
|
||||||
|
classNames: {
|
||||||
|
menu: 'typeahead-left'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: map_devices.ttAdapter(),
|
||||||
|
async: true,
|
||||||
|
displayKey: 'name',
|
||||||
|
valueKey: name,
|
||||||
|
templates: {
|
||||||
|
suggestion: Handlebars.compile('<p> {{name}}</p>')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: map_groups.ttAdapter(),
|
||||||
|
async: true,
|
||||||
|
displayKey: 'name',
|
||||||
|
valueKey: name,
|
||||||
|
templates: {
|
||||||
|
suggestion: Handlebars.compile('<p> {{name}}</p>')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#and, #or').click('', function(e) {
|
$('#and, #or').click('', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@@ -128,15 +128,39 @@ $('#create-group').on('show.bs.modal', function (event) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
var cache = {};
|
var cache = {};
|
||||||
$('#suggest').typeahead([
|
var suggestions = new Bloodhound({
|
||||||
{
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
name: 'suggestion',
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote : '/ajax_rulesuggest.php?device_id=-1&term=%QUERY',
|
remote: {
|
||||||
template: '{{name}}',
|
url: "ajax_rulesuggest.php?device_id=-1&term=%QUERY",
|
||||||
valueKey:"name",
|
filter: function (output) {
|
||||||
engine: Hogan
|
return $.map(output, function (item) {
|
||||||
|
return {
|
||||||
|
name: item.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
wildcard: "%QUERY"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
suggestions.initialize();
|
||||||
|
$('#suggest').typeahead({
|
||||||
|
hint: true,
|
||||||
|
highlight: true,
|
||||||
|
minLength: 1,
|
||||||
|
classNames: {
|
||||||
|
menu: 'typeahead-left'
|
||||||
}
|
}
|
||||||
]);
|
},
|
||||||
|
{
|
||||||
|
source: suggestions.ttAdapter(),
|
||||||
|
async: true,
|
||||||
|
displayKey: 'name',
|
||||||
|
valueKey: name,
|
||||||
|
templates: {
|
||||||
|
suggestion: Handlebars.compile('<p> {{name}}</p>')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#and, #or').click('', function(e) {
|
$('#and, #or').click('', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@@ -619,17 +619,27 @@ var bgp = new Bloodhound({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ($(window).width() < 768) {
|
||||||
|
var cssMenu = 'typeahead-left';
|
||||||
|
} else {
|
||||||
|
var cssMenu = '';
|
||||||
|
}
|
||||||
|
|
||||||
devices.initialize();
|
devices.initialize();
|
||||||
ports.initialize();
|
ports.initialize();
|
||||||
|
bgp.initialize();
|
||||||
$('#gsearch').typeahead({
|
$('#gsearch').typeahead({
|
||||||
hint: true,
|
hint: true,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
minLength: 1
|
minLength: 1,
|
||||||
|
classNames: {
|
||||||
|
menu: cssMenu
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
source: devices.ttAdapter(),
|
source: devices.ttAdapter(),
|
||||||
async: true,
|
async: true,
|
||||||
disaply: name,
|
display: name,
|
||||||
limit: 8,
|
limit: 8,
|
||||||
templates: {
|
templates: {
|
||||||
header: '<h5><strong> Devices</strong></h5>',
|
header: '<h5><strong> Devices</strong></h5>',
|
||||||
@@ -639,7 +649,7 @@ $('#gsearch').typeahead({
|
|||||||
{
|
{
|
||||||
source: ports.ttAdapter(),
|
source: ports.ttAdapter(),
|
||||||
async: true,
|
async: true,
|
||||||
disaply: name,
|
display: name,
|
||||||
limit: 8,
|
limit: 8,
|
||||||
templates: {
|
templates: {
|
||||||
header: '<h5><strong> Ports</strong></h5>',
|
header: '<h5><strong> Ports</strong></h5>',
|
||||||
@@ -649,7 +659,7 @@ $('#gsearch').typeahead({
|
|||||||
{
|
{
|
||||||
source: bgp.ttAdapter(),
|
source: bgp.ttAdapter(),
|
||||||
async: true,
|
async: true,
|
||||||
disaply: name,
|
display: name,
|
||||||
limit: 8,
|
limit: 8,
|
||||||
templates: {
|
templates: {
|
||||||
header: '<h5><strong> BGP Sessions</strong></h5>',
|
header: '<h5><strong> BGP Sessions</strong></h5>',
|
||||||
|
Reference in New Issue
Block a user