From 373ab32bb5b7d787f51178330ccb445f7c7e945b Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 16 Mar 2021 11:54:40 +0100 Subject: [PATCH] Add pagination to commands view --- .../godmode/alerts/alert_commands.php | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 8407a88f97..517af45387 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -46,6 +46,8 @@ $create_command = (bool) get_parameter('create_command'); $delete_command = (bool) get_parameter('delete_command'); $copy_command = (bool) get_parameter('copy_command'); +$url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands'; + if (is_ajax()) { $get_alert_command = (bool) get_parameter('get_alert_command'); if ($get_alert_command) { @@ -634,6 +636,12 @@ if ($commands === false) { $commands = []; } +// Pagination. +$total_commands = count($commands); +$offset = (int) get_parameter('offset'); +$limit = (int) $config['block_size']; +$commands = array_slice($commands, $offset, $limit); + foreach ($commands as $command) { $data = []; @@ -678,10 +686,17 @@ foreach ($commands as $command) { array_push($table->data, $data); } -if (count($table->data) > 0) { +ui_pagination($total_commands, $url); +if (isset($data) === true && count($table->data) > 0) { html_print_table($table); + ui_pagination($total_commands, $url, 0, 0, false, 'offset', true, 'pagination-bottom'); } else { - ui_print_info_message(['no_close' => true, 'message' => __('No alert commands configured') ]); + ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('No alert commands configured'), + ] + ); } if ($is_central_policies_on_node === false && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) { @@ -716,4 +731,4 @@ enterprise_hook('close_meta_frame'); }); } - \ No newline at end of file +