diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index efcc37e1ca..17669ab248 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -281,6 +281,19 @@ if ($delete_alert) { } if ($add_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_action = (int) get_parameter('action_select'); $id_alert_module = (int) get_parameter('id_alert_module'); $fires_min = (int) get_parameter('fires_min'); @@ -317,6 +330,12 @@ if ($add_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($update_action) { @@ -421,6 +440,7 @@ if ($delete_action) { if (is_metaconsole()) { // Restore db connection. metaconsole_restore_db(); + echo ''; } } diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index bb0b046ff1..0c28269301 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -571,6 +571,11 @@ if ($show_update_action_menu) { ); $data .= ''; $data .= ''; + + if (isset($action_option['module_action_threshold']) === false) { + $action_option['module_action_threshold'] = '300'; + } + $data .= ''; $data .= ''; $data .= __('Threshold').ui_print_help_tip(__('If a value of 0 is assigned, the Threshold of the action will be used.'), true); @@ -591,7 +596,7 @@ if ($show_update_action_menu) { false, '', false, - true + false ); $data .= ''; $data .= ''; diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index d98057b97c..eec1ba849e 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1562,13 +1562,13 @@ function alerts_delete_alert_agent_module_action($id_alert_agent_module_action) * * @return mixed Actions associated or false if something goes wrong. */ -function alerts_get_alert_agent_module_actions($id_alert_agent_module, $fields=false, $server_id=-1) +function alerts_get_alert_agent_module_actions($id_alert_agent_module, $fields=false, $server_id=-1, $ignore_metaconsole=false) { if (empty($id_alert_agent_module)) { return false; } - if (defined('METACONSOLE')) { + if (defined('METACONSOLE') && $ignore_metaconsole === false) { $server = db_get_row('tmetaconsole_setup', 'id', $server_id); if (metaconsole_connect($server) == NOERR) { @@ -1602,6 +1602,7 @@ function alerts_get_alert_agent_module_actions($id_alert_agent_module, $fields=f $action['fires_min'] = $element['fires_min']; $action['fires_max'] = $element['fires_max']; $action['module_action_threshold'] = $element['module_action_threshold']; + $action['original_id'] = $element['id']; if (isset($element['id'])) { $retval[$element['id']] = $action; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d85b2c1054..1c0ea71889 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1418,7 +1418,8 @@ function ui_format_alert_row( ); } - $data[$index['module_name']] = ui_print_truncate_text(isset($alert['agent_module_name']) ? $alert['agent_module_name'] : modules_get_agentmodule_name($alert['id_agent_module']), 'module_small', false, true, true, '[…]', ''); + $alert_module_name = isset($alert['agent_module_name']) ? $alert['agent_module_name'] : modules_get_agentmodule_name($alert['id_agent_module']); + $data[$index['module_name']] = ui_print_truncate_text($alert_module_name, 'module_small', false, true, true, '[…]', ''); } $data[$index['agent_name']] .= $disabledHtmlEnd; @@ -1432,7 +1433,24 @@ function ui_format_alert_row( $data[$index['description']] .= $disabledHtmlStart.ui_print_truncate_text(io_safe_output($description), 'description', false, true, true, '[…]', '').$disabledHtmlEnd; - $actions = alerts_get_alert_agent_module_actions($alert['id'], false, $alert['server_data']['id']); + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $connection = metaconsole_get_connection($agente['server_name']); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + + $actions = alerts_get_alert_agent_module_actions($alert['id'], false, -1, true); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + } if (empty($actions) === false || $actionDefault != '') { $actionText = '
'; } $actionText .= ''; - if ($actionDefault !== '') { + if ($actionDefault !== '' && $actionDefault !== false) { $actionDefault_name = db_get_sql( sprintf( 'SELECT name FROM talert_actions WHERE id = %d', @@ -1457,6 +1513,8 @@ function ui_format_alert_row( foreach ($actions as $action) { if ($actionDefault_name === $action['name']) { $hide_actionDefault = true; + } else { + $hide_actionDefault = false; } } @@ -1509,34 +1567,34 @@ function ui_format_alert_row( metaconsole_restore_db(); } + $tableActionButtons[] = ''; + // Edit. if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM') ) { - $tableActionButtons[] = html_print_input_image( - 'update_action', - '/images/edit.svg', - 1, - 'padding:0px;', - true, - [ - 'title' => __('Update action'), - 'class' => 'main_menu_icon invert_filter', - 'onclick' => 'show_display_update_action(\''.$action['id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action['id'].'\',\''.$alert['agent_name'].'\')', - ] - ); $tableActionButtons[] = html_print_input_hidden('id_agent_module', $alert['id_agent_module'], true); - } - if (check_acl($config['id_user'], $id_group, 'LM') - ) { - $tableActionButtons[] = ''.html_print_image( - 'images/delete.svg', + if (check_acl($config['id_user'], $id_group, 'LM') + ) { + $tableActionButtons[] = ''.html_print_image( + 'images/delete.svg', + true, + [ + 'alt' => __('Delete'), + 'title' => __('Delete'), + 'class' => 'main_menu_icon invert_filter vertical_baseline', + ] + ).''; + } + + $tableActionButtons[] = ''.html_print_image( + 'images/plus-black.svg', true, [ - 'alt' => __('Delete'), - 'title' => __('Delete'), - 'class' => 'main_menu_icon invert_filter vertical_baseline', + 'title' => __('Add action'), + 'class' => 'invert_filter main_menu_icon', + 'style' => 'margin-bottom: 12px;', ] ).''; } @@ -1550,6 +1608,123 @@ function ui_format_alert_row( ); } + // Is possible manage actions if have LW permissions in the agent group of the alert module. + if (check_acl_one_of_groups($config['id_user'], $all_groups, 'LW') || check_acl($config['id_user'], $template_group, 'LM')) { + if (check_acl($config['id_user'], $template_group, 'LW')) { + $own_groups = users_get_groups($config['id_user'], 'LW', true); + } else if (check_acl($config['id_user'], $template_group, 'LM')) { + $own_groups = users_get_groups($config['id_user'], 'LM', true); + } + + $filter_groups = ''; + $filter_groups = implode(',', array_keys($own_groups)); + if ($filter_groups != null) { + $actions = alerts_get_alert_actions_filter(true, 'id_group IN ('.$filter_groups.')'); + } + + $data[$index['actions']] .= ''; + } + return $data; } diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index ffa860f634..f5a812e16d 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -656,4 +656,21 @@ function show_display_update_action(id_module_action, alert_id, alert_id_agent_m } }); } - + +function show_add_action(id_alert) { + $("#add_action-div-" + id_alert).hide () + .dialog ({ + resizable: true, + draggable: true, + modal: true, + width: 700, + title: '', + modal: true, + overlay: { + opacity: 0.5, + background: "black" + } + }) + .show (); +} + \ No newline at end of file