Skip to content

Commit

Permalink
Unable to filter by float/fixed client (#2)
Browse files Browse the repository at this point in the history
* Unable to filter by float/fixed client

Signed-off-by: Stephanie Buser <[email protected]>
  • Loading branch information
sbuser-git authored Sep 14, 2022
1 parent ba6a131 commit 3dae888
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions cacti/plugins/grid/grid_clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@
bottom_footer();

function grid_view_get_clients_records(&$sql_where, $apply_limits = true, $rows, &$sql_params) {
/* user id sql where */
if (get_request_var('clusterid') == '0') {
/* Show all items */
} else {
$sql_where = 'WHERE (grid_clusters.clusterid = ?)';
if (get_request_var('clusterid') > '0') {
$sql_where .= ($sql_where != '' ? ' AND ':'WHERE ') . 'grid_clusters.clusterid = ?';
$sql_params[] = get_request_var('clusterid');
}

/* make sure we are looking at clients only */
if ($sql_where != '') {
$sql_where .= " AND isServer='0'";
} else {
$sql_where = "WHERE isServer='0'";
$sql_where .= ($sql_where != '' ? ' AND ':'WHERE ') . " isServer = 0";

if (get_request_var('type') > 0) {
if (get_request_var('type') == 1) {
$sql_where .= ($sql_where != '' ? ' AND ':'WHERE ') . 'licFeaturesNeeded = 16';
} else if (get_request_var('type') == 2) {
$sql_where .= ($sql_where != '' ? ' AND ':'WHERE ') . 'licFeaturesNeeded != 512';
}
}

/* filter sql where */
Expand Down Expand Up @@ -92,6 +93,26 @@ function clientsFilter() {
<td>
<input type='text' id='filter' size='30' value='<?php print get_request_var('filter');?>'>
</td>
<td>
<?php print __('Client Type', 'grid');?>
</td>
<td>
<select id='type'>
<?php
$types = array(
-1 => __esc('All Clients', 'grid'),
1 => __esc('Fixed Clients', 'grid'),
2 => __esc('Float Clients', 'grid')
);

if (cacti_sizeof($types)) {
foreach ($types as $key => $value) {
print '<option value="' . $key . '"'; if (get_request_var('type') == $key) { print ' selected'; } print '>' . $value . '</option>';
}
}
?>
</select>
</td>
<td>
<?php print __('Cluster', 'grid');?>
</td>
Expand Down Expand Up @@ -152,6 +173,10 @@ function grid_view_clients() {
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'type' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '-1'
),
'filter' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
Expand Down Expand Up @@ -198,7 +223,7 @@ function grid_view_clients() {
?>
<script type='text/javascript'>
$(function() {
$('#clusterid, #rows, #filter').change(function() {
$('#clusterid, #rows, #type, #filter').change(function() {
applyFilter();
});

Expand All @@ -215,6 +240,7 @@ function grid_view_clients() {
function applyFilter() {
strURL = 'grid_clients.php?header=false'
strURL += '&clusterid=' + $('#clusterid').val();
strURL += '&type=' + $('#type').val();
strURL += '&filter=' + $('#filter').val();
strURL += '&rows=' + $('#rows').val();
loadPageNoHeader(strURL);
Expand Down

0 comments on commit 3dae888

Please sign in to comment.