Skip to content

Commit

Permalink
minor filter behavior changes
Browse files Browse the repository at this point in the history
required for plugin changes
  • Loading branch information
cigamit committed Mar 30, 2016
1 parent 231dabf commit 4ff4980
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions include/themes/dark/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ function themeReady() {
minLength: 0,
select: function(event,ui) {
$('#host_id').val(ui.item.id);
if (typeof applyFilter === 'function') {
applyFilter();
}else{
if (typeof applyGraphFilter === 'function') {
applyGraphFilter();
}else{
applyFilter();
}
}
}).addClass('ui-state-default ui-selectmenu-text').css('border', 'none').css('background-color', 'transparent');
Expand Down
6 changes: 3 additions & 3 deletions include/themes/modern/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ function themeReady() {
minLength: 0,
select: function(event,ui) {
$('#host_id').val(ui.item.id);
if (typeof applyFilter === 'function') {
applyFilter();
}else{
if (typeof applyGraphFilter === 'function') {
applyGraphFilter();
}else{
applyFilter();
}
}
}).addClass('ui-state-default ui-selectmenu-text').css('border', 'none').css('background-color', 'transparent');
Expand Down
9 changes: 4 additions & 5 deletions lib/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1254,16 +1254,15 @@ function get_host_array() {
return $return_devices;
}

function get_allowed_ajax_hosts($include_any = true, $include_none = true) {
function get_allowed_ajax_hosts($include_any = true, $include_none = true, $sql_where = '') {
$return = array();

$term = get_filter_request_var('term', FILTER_CALLBACK, array('options' => 'sanitize_search_string'));
if ($term != '') {
$sql_where = "hostname LIKE '%$term%' OR description LIKE '%$term%' OR notes LIKE '%$term%'";
}else{
$sql_where = "";
$sql_where .= (strlen($sql_where) ? ' AND ':'') . "hostname LIKE '%$term%' OR description LIKE '%$term%' OR notes LIKE '%$term%'";
}

$hosts = get_allowed_devices($sql_where, 'description', 30);
$hosts = get_allowed_devices($sql_where, 'description', 30);

if (get_request_var('term') == '') {
if ($include_any) {
Expand Down
4 changes: 2 additions & 2 deletions lib/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ function html_graph_tabs_right($current_user) {
}
}

function html_host_filter($host_id = '-1', $call_back = 'applyFilter') {
function html_host_filter($host_id = '-1', $call_back = 'applyFilter', $sql_where = '') {
$theme = get_selected_theme();

if ($theme == 'classic') {
Expand All @@ -1355,7 +1355,7 @@ function html_host_filter($host_id = '-1', $call_back = 'applyFilter') {
<option value='-1'<?php if (get_request_var('host_id') == '-1') {?> selected<?php }?>>Any</option>
<option value='0'<?php if (get_request_var('host_id') == '0') {?> selected<?php }?>>None</option>
<?php
$hosts = db_fetch_assoc("SELECT id, CONCAT_WS('',description,' (',hostname,')') AS name FROM host ORDER BY description, hostname");
$hosts = db_fetch_assoc("SELECT id, CONCAT_WS('',description,' (',hostname,')') AS name FROM host $sql_where ORDER BY description, hostname");

if (sizeof($hosts) > 0) {
foreach ($hosts as $host) {
Expand Down
6 changes: 3 additions & 3 deletions lib/html_graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ function html_graph_preview_filter($page, $action, $devices_where = '', $templat
?>
<tr class='even noprint'>
<td class='noprint'>
<form id='form_graph_view' method='post' action='<?php print $page;?>?action=preview'>
<form id='form_graph_view' method='post' action='<?php print $page;?>?action=<?php print $action;?>'>
<table id='device' class='filterTable'>
<tr>
<?php print html_host_filter(get_request_var('host_id'), 'applyGraphFilter');?>
<?php print html_host_filter(get_request_var('host_id'), 'applyGraphFilter()', $devices_where);?>
<td>
Template
</td>
Expand Down Expand Up @@ -330,7 +330,7 @@ function html_graph_preview_filter($page, $action, $devices_where = '', $templat
var graph_start=<?php print get_current_graph_start();?>;
var graph_end=<?php print get_current_graph_end();?>;
var timeOffset=<?php print date('Z');?>;
var pageAction ='<?php print $action;?>';
var pageAction = '<?php print $action;?>';
var graphPage = '<?php print $page;?>';
var date1Open = false;
var date2Open = false;
Expand Down

0 comments on commit 4ff4980

Please sign in to comment.