Permalink
Browse files

mobile: implement remote filtering (fixes #328)

  • Loading branch information...
sni committed Jan 11, 2018
1 parent 217fd5a commit e61a37f034fcccdb1281bd1fe300a892633c2fa4
View
@@ -7,6 +7,7 @@ next:
- LMD:
- only restart lmd on timeouts when neccessary
- Mobile:
- implement remote filtering
- add alerts and notifications button to extinfo page
2.18 Mon Dec 25 15:27:06 CET 2017
@@ -80,13 +80,18 @@ sub index {
$data = $c->{'db'}->get_service_stats(filter => [ Thruk::Utils::Auth::get_auth_filter($c, 'services'), $servicefilter ]);
}
elsif($type eq 'hosts') {
if(defined $c->req->parameters->{'host'}) {
if(defined $c->req->parameters->{'host'} || defined $c->req->parameters->{'filter'}) {
$hostfilter = { 'name' => $c->req->parameters->{'host'} };
my $commentfilter = { 'host_name' => $c->req->parameters->{'host'} };
if(defined $c->req->parameters->{'filter'}) {
$hostfilter = { 'name' => { '~~' => $c->req->parameters->{'filter'} } };
$commentfilter = { 'host_name' => { '~~' => $c->req->parameters->{'filter'} } };
}
$comments = $c->{'db'}->get_comments(
filter => [ Thruk::Utils::Auth::get_auth_filter( $c, 'comments' ), { 'host_name' => $c->req->parameters->{'host'} }, { 'service_description' => undef } ],
filter => [ Thruk::Utils::Auth::get_auth_filter( $c, 'comments' ), $commentfilter, { 'service_description' => undef } ],
sort => { 'DESC' => 'id' } );
$downtimes = $c->{'db'}->get_downtimes(
filter => [ Thruk::Utils::Auth::get_auth_filter( $c, 'downtimes' ), { 'host_name' => $c->req->parameters->{'host'} }, { 'service_description' => undef } ],
filter => [ Thruk::Utils::Auth::get_auth_filter( $c, 'downtimes' ), $commentfilter, { 'service_description' => undef } ],
sort => { 'DESC' => 'id' } );
}
$data = $c->{'db'}->get_hosts(filter => [ Thruk::Utils::Auth::get_auth_filter($c, 'hosts'), $hostfilter ], pager => 1);
@@ -95,9 +100,18 @@ sub index {
}
}
elsif($type eq 'services') {
if(defined $c->req->parameters->{'host'}) {
if(defined $c->req->parameters->{'host'} || defined $c->req->parameters->{'filter'}) {
$servicefilter = { 'description' => $c->req->parameters->{'service'},
'host_name' => $c->req->parameters->{'host'} };
my $commentfilter = { 'host_name' => $c->req->parameters->{'host'}, 'service_description' => $c->req->parameters->{'service'}, };
if(defined $c->req->parameters->{'filter'}) {
$servicefilter = { -or => [ {'description' => { '~~' => $c->req->parameters->{'filter'} } },
{ 'host_name' => { '~~' => $c->req->parameters->{'filter'} } },
]};
$commentfilter = { -or => [ {'service_description' => { '~~' => $c->req->parameters->{'filter'} } },
{ 'host_name' => { '~~' => $c->req->parameters->{'filter'} } },
]};
}
$comments = $c->{'db'}->get_comments(
filter => [ Thruk::Utils::Auth::get_auth_filter( $c, 'comments' ), { 'host_name' => $c->req->parameters->{'host'} }, { 'service_description' => $c->req->parameters->{'service'} } ],
sort => { 'DESC' => 'id' } );
@@ -68,12 +68,28 @@ jQuery(document).ready(function(e){
refresh_host_status();
refresh_service_status();
jQuery("#hosts_list_data").on("filterablebeforefilter", function(e, data) { filterablebeforefilter(e, data, ThrukMobile.page_hosts_list) });
jQuery("#services_list_data").on("filterablebeforefilter", function(e, data) { filterablebeforefilter(e, data, ThrukMobile.page_services_list) });
/* hide notice about fullscreen mode */
if(window.navigator.standalone == true) {
jQuery('#fullscreenteaser').hide();
}
});
function filterablebeforefilter(e, data, pageref) {
var val = data.input.val();
var hash = document.location.hash.replace(/[\?&]filter=.*/, "");
if(val != "") {
hash = hash+"&filter="+encoder(val);
}
window.parent.history.replaceState({}, "", hash);
if(jQuery('.more').length == 0 && val == "") {
return;
}
pageref(null, null, null, null, null, 1);
}
/* return host status text */
function get_host_status(host) {
if(host.has_been_checked == 0) { return("PENDING"); }

0 comments on commit e61a37f

Please sign in to comment.