Debian: Support icinga-cgi-bin as dependency for icinga2-classicui

Also updated the HTML files and JS stuff that has to be changed for Icinga2.

Fixes #5770
This commit is contained in:
Markus Frosch 2014-03-19 20:12:12 +01:00
parent bcbc3ceff7
commit 008c2c2245
5 changed files with 176 additions and 17 deletions

151
debian/classicui/autocomplete.js vendored Normal file
View File

@ -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) {
$('<li/>').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)
$('<li/>').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 $( '<li class="status' + item.status + '">' )
.append( $( "<a>" ).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

View File

@ -6,11 +6,11 @@
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
</head>
<frameset frameborder="0" framespacing="0" rows="72,*" onLoad='document.title="Icinga: "+window.location.hostname; document.getElementById("main").focus();'>
<frameset frameborder="0" framespacing="0" rows="72,*" onLoad='document.title="Icinga2 Classic: "+window.location.hostname; document.getElementById("main").focus();'>
<frame src="/cgi-bin/icinga2-classicui/tac.cgi?tac_header" name="top" target="main" scrolling="no" />
<frameset frameborder="0" framespacing="0" cols="200,*">
<frame src="menu.html" name="menu" target="main" scrolling="auto"/>
<frame src="/cgi-bin/icinga2-classicui/tac.cgi" name="main" />
<frame src="/cgi-bin/icinga2-classicui/tac.cgi" name="main" id="main" />
</frameset>
</frameset>
<noframes>

View File

@ -1,4 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W4C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Web Interface Monitoring</title>
@ -6,9 +6,15 @@
<meta http-equiv="Content-Language" content="en" />
<meta name="robots" content="noindex, nofollow" />
<link rel="stylesheet" type="text/css" href="stylesheets/menu.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="jquery-ui/themes/base/jquery.ui.all.css" media="screen, projection" />
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript" src="jquery-ui/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="jquery-ui/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="jquery-ui/ui/jquery.ui.menu.js"></script>
<script type="text/javascript" src="jquery-ui/ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="jquery-ui/ui/jquery.ui.autocomplete.js"></script>
</head>
<body>
<div id="menu">
@ -28,7 +34,7 @@
<li class="menuli_style2">
<div class="navbarsearch">
<form method="get" action="/cgi-bin/icinga2-classicui/status.cgi" target="main">
<input type='text' name='search_string' style="width: 150px; padding: 2px; margin-left: 10px; border: 1px solid grey">
<input type='text' name='search_string' id="autocomplete" style="width: 150px; padding: 2px; margin-left: 10px; border: 1px solid grey">
</form>
</div>
</li>
@ -38,29 +44,29 @@
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/tac.cgi" target="main">Tactical Overview</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?style=hostdetail" target="main">Host Detail</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi" target="main">Service Detail</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?hostgroup=all&style=overview" target="main">Hostgroup Overview</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?hostgroup=all&style=summary" target="main">Hostgroup Summary</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi?servicegroup=all&style=overview" target="main">Servicegroup Overview</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi?servicegroup=all&style=summary" target="main">Servicegroup Summary</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?hostgroup=all&amp;style=overview" target="main">Hostgroup Overview</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?hostgroup=all&amp;style=summary" target="main">Hostgroup Summary</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi?servicegroup=all&amp;style=overview" target="main">Servicegroup Overview</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi?servicegroup=all&amp;style=summary" target="main">Servicegroup Summary</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/statusmap.cgi?host=all" target="main">Status Map</a></li>
</ul>
<h2>Problems</h2>
<ul>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi?servicestatustypes=28" target="main">Service Problems</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?servicestatustypes=28&hoststatustypes=3&serviceprops=2097162" target="main">Unhandled Services</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi?style=hostdetail&hoststatustypes=12" target="main">Host Problems</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?style=hostdetail&hoststatustypes=12&hostprops=2097162" target="main">Unhandled Hosts</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?servicestatustypes=28&amp;hoststatustypes=3&amp;serviceprops=2097162" target="main">Unhandled Services</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi?style=hostdetail&amp;hoststatustypes=12" target="main">Host Problems</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?style=hostdetail&amp;hoststatustypes=12&amp;hostprops=2097162" target="main">Unhandled Hosts</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/status.cgi?allunhandledproblems" target="main">All Unhandled Problems</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/status.cgi?allproblems" target="main">All Problems</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/outages.cgi" target="main">Network Outages</a></li>
</ul>
<h2>System</h2>
<ul>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?&type=3" target="main">Comments</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?&type=6" target="main">Downtime</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?&type=0" target="main">Process Info</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?&type=4" target="main">Performance Info</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?&type=7" target="main">Scheduling Queue</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?type=3" target="main">Comments</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?type=6" target="main">Downtime</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?type=0" target="main">Process Info</a></li>
<li class="menuli_style2"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?type=4" target="main">Performance Info</a></li>
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/extinfo.cgi?type=7" target="main">Scheduling Queue</a></li>
</ul>
<h2>Reporting</h2>
<ul>
@ -77,5 +83,6 @@
<li class="menuli_style1"><a href="/cgi-bin/icinga2-classicui/config.cgi" target="main">View Config</a></li>
</ul>
</div>
<script type="text/javascript" src="autocomplete.js"></script>
</body>
</html>

2
debian/control vendored
View File

@ -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

View File

@ -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