diff --git a/debian/classicui/autocomplete.js b/debian/classicui/autocomplete.js
new file mode 100644
index 000000000..c86e4d7d0
--- /dev/null
+++ b/debian/classicui/autocomplete.js
@@ -0,0 +1,151 @@
+// Written by Kepi (kepi.cz)
+
+$(document).ready(function() {
+ 'use strict';
+ var min_char = 3;
+ var max_items_per_cat = 10;
+ var display_services = true;
+
+ window.icingaAC = {
+ // This is number of miliseconds to cache partial result
+ // so we don't query server again and again for same terms
+ expireMsecs: 60000,
+
+ // internal variables
+ shorten: undefined,
+ results: {}
+ }
+
+ // extension for category support in autocomplete result
+ $.widget("custom.catcomplete", $.ui.autocomplete, {
+ _renderMenu: function( ul, items ) {
+ var that = this;
+ var currentCategory = "";
+ var current_id = 0;
+ $.each( items, function( index, item ) {
+ if (item.category != currentCategory) {
+ $('
').addClass('ui-autocomplete-category').html(item.category).appendTo(ul);
+ currentCategory = item.category;
+ current_id = 0;
+ }
+ if (current_id < max_items_per_cat)
+ that._renderItemData( ul, item );
+ if (current_id == max_items_per_cat)
+ $(' ').addClass('ui-menu-item').html("...").appendTo(ul);
+ current_id++;
+ });
+ }
+ });
+
+ // extend renderItem so we can add custom class
+ $.extend( $.ui.autocomplete.prototype, {
+ _renderItem: function( ul, item ) {
+ return $( '' )
+ .append( $( "" ).text( item.label ) )
+ .appendTo( ul );
+ }
+ });
+
+ // autocomplete function
+ $("#autocomplete").catcomplete( { minLength: min_char, delay : 700 }, {
+ // select function is used to open url for selected item
+ select: function( event, ui ) { top.frames['main'].location.href = ui.item.url },
+ // get results from icinga API
+ source: function(request, response) {
+ var shorten = request.term.substring(0, min_char);
+ var output = [];
+
+ if (window.icingaAC.shorten === undefined || shorten != window.icingaAC.shorten || window.icingaAC.results[window.icingaAC.shorten].expire < (new Date).getTime()) {
+ $.ajax({
+ async: false,
+ url: '/cgi-bin/icinga2-classicui/status.cgi?livesearchdata',
+ dataType: 'json',
+ data: {
+ search_string: shorten // parameter for API search
+ },
+ success: function(data) {
+
+ // prepare hosts data
+ if ( data.status.hosts ) {
+ $.each( data.status.hosts, function(index, item) {
+ output.push( {
+ category: 'Hosts',
+ url: '/cgi-bin/icinga2-classicui/status.cgi?search_string=' + encodeURIComponent(item.host_name),
+ label: item.host_display_name,
+ local_match: new Array( item.host_name, item.host_display_name, item.host_alias, item.host_address, item.host_address6 ),
+ status: item.status
+ });
+ });
+ }
+
+ // prepare services data
+ if ( data.status.services && display_services) {
+ $.each( data.status.services, function(index, item) {
+ output.push( {
+ category: 'Services ' + item.host_name,
+ url: '/cgi-bin/icinga2-classicui/extinfo.cgi?type=2&host=' + encodeURIComponent(item.host_name) + '&service=' + encodeURIComponent(item.service_description),
+ label: item.service_display_name,
+ local_match: new Array( item.service_description, item.service_display_name,
+ item.host_name + ' ' + item.service_description,
+ item.host_name + ' ' + item.service_display_name,
+ item.host_display_name + ' ' + item.service_description,
+ item.host_display_name + ' ' + item.service_display_name ),
+ value: item.host_name + ' ' + item.service_description,
+ status: item.status
+ });
+ });
+ }
+
+ // prepare host groups data
+ if ( data.status.hostgroups ) {
+ $.each( data.status.hostgroups, function(index, item) {
+ output.push( {
+ category: 'Hostgroups',
+ url: '/cgi-bin/icinga2-classicui/status.cgi?style=overview&hostgroup=' + encodeURIComponent(item.hostgroup_name),
+ local_match: new Array( item.hostgroup_name, item.hostgroup_alias ),
+ label: item.hostgroup_alias,
+ status: "group"
+ });
+ });
+ }
+
+ // prepare service groups data
+ if ( data.status.servicegroups ) {
+ $.each( data.status.servicegroups, function(index, item) {
+ output.push( {
+ category: 'Servicegroups',
+ url: '/cgi-bin/icinga2-classicui/status.cgi?style=overview&servicegroup=' + encodeURIComponent(item.servicegroup_name),
+ local_match: new Array( item.servicegroup_name, item.servicegroup_alias ),
+ label: item.servicegroup_alias,
+ status: "group"
+ });
+ });
+ }
+
+ window.icingaAC.shorten = shorten;
+ window.icingaAC.results[window.icingaAC.shorten] = {
+ expire: (new Date).getTime() + window.icingaAC.expireMsecs,
+ data: output
+ }
+ }
+ })
+ }
+
+ var matcher = new RegExp( request.term.replace(/\*/g, ".*"), "i" );
+ response( $.grep( window.icingaAC.results[window.icingaAC.shorten].data, function( item ){
+ var match_result = false;
+ $.each( item.local_match, function( index, match_item ) {
+ if (match_item !== undefined && matcher.test( match_item )) {
+ match_result = true;
+ return;
+ }
+ });
+
+ return match_result;
+ }) );
+
+ }
+ }).bind('focus', function(){ $(this).catcomplete("search"); } );
+});
+
+// vim: syntax=javascript ts=2 sw=2 sts=2 sr et
diff --git a/debian/classicui/index.html b/debian/classicui/index.html
index 156564619..e097a61e2 100644
--- a/debian/classicui/index.html
+++ b/debian/classicui/index.html
@@ -6,11 +6,11 @@
-
+
-
+
diff --git a/debian/classicui/menu.html b/debian/classicui/menu.html
index b578352ef..edb999cac 100644
--- a/debian/classicui/menu.html
+++ b/debian/classicui/menu.html
@@ -1,4 +1,4 @@
-
+
Web Interface Monitoring
@@ -6,9 +6,15 @@
+
+
+
+
+
+
+
diff --git a/debian/control b/debian/control
index 9bc821677..fb326ce80 100644
--- a/debian/control
+++ b/debian/control
@@ -73,7 +73,7 @@ Description: host and network monitoring system - documentation
Package: icinga2-classicui
Architecture: all
Depends: icinga2-common (= ${source:Version}),
- icinga-cgi (>= 1.9.0~),
+ icinga-cgi-bin | icinga-cgi (>= 1.9.0~),
${misc:Depends}
Recommends: apache2 | httpd
Description: host and network monitoring system - classic ui integration
diff --git a/debian/icinga2-classicui.install b/debian/icinga2-classicui.install
index d3679c6d2..06fde5e78 100644
--- a/debian/icinga2-classicui.install
+++ b/debian/icinga2-classicui.install
@@ -1,3 +1,4 @@
debian/classicui/*.html usr/share/icinga2/classicui
+debian/classicui/*.js usr/share/icinga2/classicui
debian/classicui/apache2.conf etc/icinga2/classicui
debian/classicui/cgi.cfg etc/icinga2/classicui