13009-Change actions in Alerts view and List of alerts

This commit is contained in:
Pablo Aragon 2024-04-01 12:04:06 +02:00
parent 29e5cf9658
commit eae3d5af69
3 changed files with 48 additions and 30 deletions

View File

@ -712,9 +712,9 @@ foreach ($simple_alerts as $alert) {
WHERE id = '.$alert['id_alert_template']
);
if ($default_action != '') {
$data[3] .= "<tr><td colspan='2'><ul class='action_list'><li>";
$data[3] .= "<tr><td colspan='2'>";
$data[3] .= db_get_sql("SELECT name FROM talert_actions WHERE id = $default_action").' <em>('.__('Default').')</em>';
$data[3] .= '</li></ul></td>';
$data[3] .= '</td>';
$data[3] .= '</tr>';
}
@ -722,7 +722,7 @@ foreach ($simple_alerts as $alert) {
$data[3] .= '<tr class="alert_action_list">';
$data[3] .= '<td>';
$data[3] .= '<ul class="action_list inline_line">';
$data[3] .= '<li class="inline_line">';
$data[3] .= '<li class="">';
if ($alert['disabled']) {
$data[3] .= '<font class="action_name italic_a">';
} else {
@ -758,7 +758,7 @@ foreach ($simple_alerts as $alert) {
$data[3] .= '</td>';
$data[3] .= '<td class="flex_center">';
$data[3] .= '<td class="flex_center table_action_buttons">';
$data[3] .= ui_print_help_tip(__('The default actions will be executed every time that the alert is fired and no other action is executed'), true);
// 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')) {
@ -786,7 +786,7 @@ foreach ($simple_alerts as $alert) {
true,
[
'title' => __('Update action'),
'class' => 'main_menu_icon invert_filter',
'class' => 'main_menu_icon invert_filter action_button_hidden',
'onclick' => 'show_display_update_action(\''.$action['id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action_id.'\',\''.$alert['id_agent_module'].'\')',
]
);

View File

@ -1502,14 +1502,41 @@ function ui_format_alert_row(
metaconsole_restore_db();
}
if (empty($actions) === false || $actionDefault != '') {
$actionText = '<div><ul class="action_list">';
$actionText = '';
if ($actionDefault !== '' && $actionDefault !== false) {
$actionDefault_name = db_get_sql(
sprintf(
'SELECT name FROM talert_actions WHERE id = %d',
$actionDefault
)
);
foreach ($actions as $action) {
$actionText .= '<div class="mrgn_btn_5px" ><span class="action_name"><li>'.$action['name'];
if ($actionDefault_name === $action['name']) {
$hide_actionDefault = true;
} else {
$hide_actionDefault = false;
}
}
if ($hide_actionDefault !== true) {
$actionText .= $actionDefault_name.' <i>('.__('Default').')</i>';
}
}
if (empty($actions) === false || $actionDefault != '') {
$actionText .= '<div><ul class="action_list">';
foreach ($actions as $action) {
$actionText .= '<div class="mrgn_btn_5px" ><span class="action_name"><li class="">';
$actionText .= '<div class="flex_center mrgn_top-22px">';
$actionText .= '<div class="mrgn_lft_0px_imp">';
$actionText .= $action['name'];
if ($action['fires_min'] != $action['fires_max']) {
$actionText .= ' ('.$action['fires_min'].' / '.$action['fires_max'].')';
}
$actionText .= '</div>';
$actionText .= '<div class="flex_center table_action_buttons mrgn_lft_0px_imp">';
$actionText .= ui_print_help_tip(__('The default actions will be executed every time that the alert is fired and no other action is executed'), true);
// Is possible manage actions if have LW permissions in the agent group of the alert module.
if (is_metaconsole() === true) {
@ -1520,7 +1547,7 @@ function ui_format_alert_row(
[
'alt' => __('Delete action'),
'title' => __('Delete action'),
'class' => 'main_menu_icon invert_filter vertical_baseline',
'class' => 'main_menu_icon invert_filter vertical_baseline action_button_hidden',
]
).'</a>';
}
@ -1534,7 +1561,7 @@ function ui_format_alert_row(
true,
[
'title' => __('Update action'),
'class' => 'main_menu_icon invert_filter',
'class' => 'main_menu_icon invert_filter action_button_hidden',
'onclick' => 'show_display_update_action(\''.$action['original_id'].'\',\''.$alert['id'].'\',\''.$alert['id_agent_module'].'\',\''.$action['original_id'].'\',\''.$alert['agent_name'].'\')',
]
);
@ -1542,32 +1569,15 @@ function ui_format_alert_row(
}
}
$actionText .= '</div>';
$actionText .= '</div>';
$actionText .= '<div id="update_action-div-'.$alert['id'].'" class="invisible">';
$actionText .= '</div>';
$actionText .= '</li></span></div>';
}
$actionText .= '</ul></div>';
if ($actionDefault !== '' && $actionDefault !== false) {
$actionDefault_name = db_get_sql(
sprintf(
'SELECT name FROM talert_actions WHERE id = %d',
$actionDefault
)
);
foreach ($actions as $action) {
if ($actionDefault_name === $action['name']) {
$hide_actionDefault = true;
} else {
$hide_actionDefault = false;
}
}
if ($hide_actionDefault !== true) {
$actionText .= $actionDefault_name.' <i>('.__('Default').')</i>';
}
}
}
$data[$index['action']] = $actionText;

View File

@ -7163,6 +7163,10 @@ div.graph div.legend table {
margin-left: 0px;
}
.mrgn_lft_0px_imp {
margin-left: 0px !important;
}
.mrgn_lft_2px {
margin-left: 2px;
}
@ -7305,6 +7309,10 @@ div.graph div.legend table {
margin-top: -15px;
}
.mrgn_top-22px {
margin-top: -22px;
}
.mrgn_top_0px {
margin-top: 0px;
}