Added pagination and filter box in alert actions - #5365
This commit is contained in:
parent
015b1b55b2
commit
d799ac0739
|
@ -175,6 +175,52 @@ if ($delete_action) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$search_string = (string) get_parameter('search_string', '');
|
||||||
|
$group = (int) get_parameter('group', 0);
|
||||||
|
$url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions';
|
||||||
|
|
||||||
|
// Filter table.
|
||||||
|
$table_filter = new stdClass();
|
||||||
|
$table_filter->width = '100%';
|
||||||
|
$table_filter->class = 'databox filters';
|
||||||
|
$table_filter->style = [];
|
||||||
|
$table_filter->style[0] = 'font-weight: bold';
|
||||||
|
$table_filter->style[2] = 'font-weight: bold';
|
||||||
|
$table_filter->data = [];
|
||||||
|
|
||||||
|
$table_filter->data[0][0] = __('Search');
|
||||||
|
$table_filter->data[0][1] = html_print_input_text(
|
||||||
|
'search_string',
|
||||||
|
$search_string,
|
||||||
|
'',
|
||||||
|
25,
|
||||||
|
255,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$table_filter->data[0][2] = __('Group');
|
||||||
|
$table_filter->data[0][3] = html_print_select_groups($config['id_user'], 'LM', true, 'group', $group, '', '', 0, true);
|
||||||
|
$table_filter->data[0][4] = '<div class="action-buttons">';
|
||||||
|
$table_filter->data[0][4] .= html_print_submit_button(
|
||||||
|
__('Search'),
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
'class="sub search"',
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$table_filter->data[0][4] .= '</div>';
|
||||||
|
|
||||||
|
|
||||||
|
$show_table_filter = '<form method="post" action="'.$url.'">';
|
||||||
|
$show_table_filter .= html_print_table($table_filter, true);
|
||||||
|
$show_table_filter .= '</form>';
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
ui_toggle($show_table_filter, __('Show Options'));
|
||||||
|
} else {
|
||||||
|
echo $show_table_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$table = new stdClass();
|
$table = new stdClass();
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->class = 'info_table';
|
$table->class = 'info_table';
|
||||||
|
@ -196,10 +242,18 @@ $table->align[2] = 'left';
|
||||||
$table->align[3] = 'left';
|
$table->align[3] = 'left';
|
||||||
|
|
||||||
$filter = [];
|
$filter = [];
|
||||||
if (!is_user_admin($config['id_user'])) {
|
if (!is_user_admin($config['id_user']) && $group === 0) {
|
||||||
$filter['talert_actions.id_group'] = array_keys(users_get_groups(false, 'LM'));
|
$filter['talert_actions.id_group'] = array_keys(users_get_groups(false, 'LM'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($group !== 0) {
|
||||||
|
$filter['talert_actions.id_group'] = $group;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search_string !== '') {
|
||||||
|
$filter['talert_actions.name'] = '%'.$search_string.'%';
|
||||||
|
}
|
||||||
|
|
||||||
$actions = db_get_all_rows_filter(
|
$actions = db_get_all_rows_filter(
|
||||||
'talert_actions INNER JOIN talert_commands ON talert_actions.id_alert_command = talert_commands.id',
|
'talert_actions INNER JOIN talert_commands ON talert_actions.id_alert_command = talert_commands.id',
|
||||||
$filter,
|
$filter,
|
||||||
|
@ -209,6 +263,12 @@ if ($actions === false) {
|
||||||
$actions = [];
|
$actions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pagination.
|
||||||
|
$total_actions = count($actions);
|
||||||
|
$offset = (int) get_parameter('offset');
|
||||||
|
$limit = (int) $config['block_size'];
|
||||||
|
$actions = array_slice($actions, $offset, $limit);
|
||||||
|
|
||||||
$rowPair = true;
|
$rowPair = true;
|
||||||
$iterator = 0;
|
$iterator = 0;
|
||||||
foreach ($actions as $action) {
|
foreach ($actions as $action) {
|
||||||
|
@ -254,8 +314,10 @@ foreach ($actions as $action) {
|
||||||
array_push($table->data, $data);
|
array_push($table->data, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui_pagination($total_actions, $url);
|
||||||
if (isset($data)) {
|
if (isset($data)) {
|
||||||
html_print_table($table);
|
html_print_table($table);
|
||||||
|
ui_pagination($total_actions, $url, 0, 0, false, 'offset', true, 'pagination-bottom');
|
||||||
} else {
|
} else {
|
||||||
ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]);
|
ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue