From 9b79fb826d5112b07ad1ab4d9bf4da7e229e0860 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Thu, 2 Dec 2021 13:34:28 +0100 Subject: [PATCH] wip reports alert actions --- .../reporting_builder.item_editor.php | 37 ++++++++++++------- .../include/functions_reporting.php | 33 ++++++++++++----- pandora_console/include/functions_ui.php | 2 +- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 9fd5316eb1..480495c2cf 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -187,11 +187,13 @@ $graph_render = (empty($config['type_mode_graph']) === true) ? 0 : $config['type $valuesGroupBy = [0 => __('None')]; $valuesGroupByDefaultAlertActions = [ - 'agent' => __('Agent'), - 'module' => __('Module'), - 'group' => __('Group'), - 'template' => __('Template'), + 'agent' => __('Agent'), + 'module' => __('Module'), + 'group' => __('Group'), ]; +if (is_metaconsole() === false) { + $valuesGroupByDefaultAlertActions['template'] = __('Template'); +} switch ($action) { case 'new': @@ -789,16 +791,21 @@ switch ($action) { $group_by = $es['group_by']; - $valuesGroupBy = [ - 'agent' => __('Agent'), - 'module' => __('Module'), - 'group' => __('Group'), - 'template' => __('Template'), - ]; - $period = $item['period']; $lapse = $item['lapse']; + + // Set values. + $valuesGroupBy = [ + 'agent' => __('Agent'), + 'module' => __('Module'), + 'group' => __('Group'), + ]; + + if (is_metaconsole() === false) { + $valuesGroupBy['template'] = __('Template'); + } + $lapse_calc = 1; break; @@ -5695,6 +5702,7 @@ function addGeneralRow() { } function chooseType() { + var meta = ''; type = $("#type").val(); $("#row_description").hide(); $("#row_label").hide(); @@ -6116,7 +6124,9 @@ function chooseType() { $("#select_agent_modules").show(); $("#agents_modules_row").show(); $("#modules_row").show(); - $("#row_alert_templates").show(); + if(meta == 0){ + $("#row_alert_templates").show(); + } $("#row_alert_actions").show(); $("#row_period").show(); $("#row_lapse").show(); @@ -6133,7 +6143,8 @@ function chooseType() { }); $("#lapse_select").attr('disabled', false); - $("#lapse_select").val(0).trigger('change'); + $("#lapse_select").val('0').trigger('change'); + $("#hidden-lapse").val('0'); } break; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 6db269c6a3..f2c325ead1 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2688,11 +2688,30 @@ function reporting_alert_report_actions($report, $content) $return['data'] = []; $es = json_decode($content['external_source'], true); + if (isset($report['id_template']) === true + && empty($resport['id_template']) === false + ) { + $modules = json_decode( + io_safe_output(base64_decode($es['module'])), + true + ); + $agents = json_decode( + io_safe_output(base64_decode($es['id_agents'])), + true + ); + } else { + if (is_metaconsole() === true) { + $server_id = metaconsole_get_id_server($content['server_name']); + $modules = [$server_id.'|'.$content['id_agent_module']]; + $agents = [$server_id.'|'.$content['id_agent']]; + } else { + $modules = [$content['id_agent_module']]; + $agents = [$content['id_agent']]; + } + } $period = $content['period']; $id_group = $content['id_group']; - $modules = $es['module']; - $agents = $es['id_agents']; $templates = $es['templates']; $actions = $es['actions']; $show_summary = $es['show_summary']; @@ -2701,14 +2720,8 @@ function reporting_alert_report_actions($report, $content) $filters = [ 'group' => $id_group, - 'agents' => json_decode( - io_safe_output(base64_decode($agents)), - true - ), - 'modules' => json_decode( - io_safe_output(base64_decode($modules)), - true - ), + 'agents' => $agents, + 'modules' => $modules, 'templates' => $templates, 'actions' => $actions, 'period' => $period, diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 03ec3ee614..8e9fe01210 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -329,7 +329,7 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t if (!$no_close_bool) { // Use the no_meta parameter because this image is only in // the base console. - $output .= ''.html_print_image('images/blade.png', true, false, false, true).''; + $output .= ''.html_print_image('images/blade.png', true, false, false, false).''; } $output .= '