This commit is contained in:
Pablo Aragon 2023-03-07 09:51:53 +01:00
parent 62afce562f
commit 6c6943c591
2 changed files with 195 additions and 167 deletions

View File

@ -66,12 +66,19 @@ if (check_acl_restricted_all($config['id_user'], 0, 'LM')) {
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
alerts_meta_print_header(); alerts_meta_print_header();
} else { } else {
ui_print_page_header( ui_print_standard_header(
__('Alerts').' » '.__('Alert actions'), __('Alerts'),
'images/gm_alerts.png', 'images/gm_alerts.png',
false, false,
'', '',
true true,
[],
[
[
'link' => '',
'label' => __('Alert actions'),
],
]
); );
} }
@ -230,22 +237,15 @@ $url = 'index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&search_string='
// Filter table. // Filter table.
$table_filter = new stdClass(); $table_filter = new stdClass();
$table_filter->width = '100%'; $table_filter->width = '100%';
$table_filter->class = 'databox filters filter-table-adv'; $table_filter->class = 'databox filters no_border filter-table-adv';
$table_filter->style = []; $table_filter->style = [];
$table_filter->style[0] = 'width: 33%'; $table_filter->style[0] = 'width: 33%';
$table_filter->style[1] = 'width: 33%';
$table_filter->style[2] = 'width: 33%'; $table_filter->style[2] = 'width: 33%';
$table_filter->style[4] = 'width: 33%';
$table_filter->data = []; $table_filter->data = [];
$table_filter->colspan = [];
$table_filter->colspan[1][0] = 3;
$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][0] = html_print_label_input_block( $table_filter->data[0][0] = html_print_label_input_block(
__('Search'), __('Search'),
html_print_input_text( html_print_input_text(
@ -264,19 +264,22 @@ if (users_can_manage_group_all('LM') === true) {
$return_all_group = true; $return_all_group = true;
} }
$table_filter->data[0][2] = __('Group');
$table_filter->data[0][3] = html_print_select_groups( $table_filter->data[0][1] = html_print_label_input_block(
$config['id_user'], __('Group'),
'LM', html_print_select_groups(
$return_all_group, $config['id_user'],
'group_search', 'LM',
$group_search, $return_all_group,
'', 'group_search',
'', $group_search,
0, '',
true '',
0,
true
)
); );
$table_filter->data[0][4] = __('Command');
$commands_sql = db_get_all_rows_filter( $commands_sql = db_get_all_rows_filter(
'talert_commands', 'talert_commands',
['id_group' => array_keys(users_get_groups(false, 'LW'))], ['id_group' => array_keys(users_get_groups(false, 'LW'))],
@ -290,39 +293,54 @@ $commands_sql = db_get_all_rows_filter(
); );
$commands = db_get_all_rows_sql($commands_sql); $commands = db_get_all_rows_sql($commands_sql);
$table_filter->data[0][5] = html_print_select(
index_array($commands, 'id', 'name'), $table_filter->data[0][2] = html_print_label_input_block(
'id_command_search', __('Command'),
$id_command_search, html_print_select(
'', index_array($commands, 'id', 'name'),
__('None'), 'id_command_search',
0, $id_command_search,
true, '',
false, __('None'),
true, 0,
'', true,
false, false,
'width:150px' true,
'',
false,
'width:100%'
)
); );
$table_filter->data[0][6] = '<div class="action-buttons">';
$table_filter->data[0][6] .= html_print_submit_button( $table_filter->data[1][0] = '<div class="float-right">';
$table_filter->data[1][0] .= html_print_submit_button(
__('Search'), __('Search'),
'', '',
false, false,
'class="sub search"', [
'icon' => 'search',
'class' => 'mini',
],
true true
); );
$table_filter->data[0][5] .= '</div>'; $table_filter->data[1][0] .= '</div>';
$show_table_filter = '<form method="post" action="'.$url.'">'; $show_table_filter = '<form method="post" action="'.$url.'">';
$show_table_filter .= html_print_table($table_filter, true); $show_table_filter .= ui_toggle(
html_print_table($table_filter, true),
'<span class="subsection_header_title">'.__('Search').'</span>',
__('Search'),
'search',
true,
false,
'',
'white-box-content no_border',
'filter-datatable-main box-flat white_table_graph fixed_filter_bar '
);
$show_table_filter .= '</form>'; $show_table_filter .= '</form>';
if (is_metaconsole()) {
ui_toggle($show_table_filter, __('Show Options')); echo $show_table_filter;
} else {
echo $show_table_filter;
}
$table = new stdClass(); $table = new stdClass();
@ -435,11 +453,14 @@ foreach ($actions as $action) {
$data[3] .= html_print_input_hidden('id', $id_action, true); $data[3] .= html_print_input_hidden('id', $id_action, true);
$data[3] .= html_print_input_image( $data[3] .= html_print_input_image(
'dup', 'dup',
'images/copy.png', 'images/copy.svg',
1, 1,
'', '',
true, true,
['title' => __('Duplicate')] [
'title' => __('Duplicate'),
'class' => 'main_menu_icon invert_filter',
]
); );
$data[3] .= '</form> '; $data[3] .= '</form> ';
@ -449,11 +470,14 @@ foreach ($actions as $action) {
$data[4] .= html_print_input_hidden('id', $id_action, true); $data[4] .= html_print_input_hidden('id', $id_action, true);
$data[4] .= html_print_input_image( $data[4] .= html_print_input_image(
'del', 'del',
'images/cross.png', 'images/delete.svg',
1, 1,
'', '',
true, true,
['title' => __('Delete')] [
'title' => __('Delete'),
'class' => 'main_menu_icon invert_filter',
]
); );
$data[4] .= '</form> '; $data[4] .= '</form> ';
} else { } else {
@ -464,10 +488,10 @@ foreach ($actions as $action) {
array_push($table->data, $data); array_push($table->data, $data);
} }
ui_pagination($total_actions, $url); $pagination = '';
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'); $pagination = ui_pagination($total_actions, $url, 0, 0, true, 'offset', false, '');
} 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') ]);
} }
@ -477,7 +501,7 @@ if (is_management_allowed() === true) {
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'&offset='.$offset.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_action&pure='.$pure.'&offset='.$offset.'">';
$button = html_print_submit_button(__('Create'), 'create', false, ['icon' => 'wand'], true); $button = html_print_submit_button(__('Create'), 'create', false, ['icon' => 'wand'], true);
html_print_input_hidden('create_alert', 1); html_print_input_hidden('create_alert', 1);
html_print_action_buttons($button); html_print_action_buttons($button, ['right_content' => $pagination]);
echo '</form>'; echo '</form>';
echo '</div>'; echo '</div>';
} }

View File

@ -158,43 +158,34 @@ html_print_div(
$table = new stdClass(); $table = new stdClass();
$table->id = 'table_macros'; $table->id = 'table_macros';
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filters'; $table->class = 'databox filters filter-table-adv';
if (defined('METACONSOLE')) {
if ($id) {
$table->head[0] = __('Update Action');
} else {
$table->head[0] = __('Create Action');
}
$table->head_colspan[0] = 4;
$table->headstyle[0] = 'text-align: center';
}
$table->style = []; $table->style = [];
$table->style[0] = 'font-weight: bold';
$table->size = []; $table->size = [];
$table->size[0] = '20%'; $table->size[0] = '50%';
$table->size[1] = '50%';
$table->data = []; $table->data = [];
$table->data[0][0] = __('Name');
$table->data[0][1] = html_print_input_text( $table->data[0][0] = html_print_label_input_block(
'name', __('Name'),
$name, html_print_input_text(
'', 'name',
35, $name,
255, '',
true, 35,
false, 255,
false, true,
'', false,
'', false,
'', '',
'', '',
false, '',
'', '',
'', false,
'', '',
(!$is_management_allowed | $disabled) '',
'',
(!$is_management_allowed | $disabled)
)
); );
if (io_safe_output($name) == 'Monitoring Event') { if (io_safe_output($name) == 'Monitoring Event') {
@ -205,34 +196,30 @@ if (io_safe_output($name) == 'Monitoring Event') {
); );
} }
$table->colspan[0][1] = 2;
$table->data[1][0] = __('Group');
$own_info = get_user_info($config['id_user']); $own_info = get_user_info($config['id_user']);
$return_all_group = false; $return_all_group = false;
if (users_can_manage_group_all('LW') === true || $disabled) { if (users_can_manage_group_all('LW') === true || $disabled) {
$return_all_group = true; $return_all_group = true;
} }
$table->data[1][1] = '<div class="w250px inline">'.html_print_select_groups( $table->data[0][1] = html_print_label_input_block(
false, __('Group'),
'LW', html_print_select_groups(
$return_all_group, false,
'group', 'LW',
$group, $return_all_group,
'', 'group',
'', $group,
0, '',
true, '',
false, 0,
true, true,
'', false,
(!$is_management_allowed | $disabled) true,
).'</div>'; 'w100p',
$table->colspan[1][1] = 2; (!$is_management_allowed | $disabled)
)
);
$create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Integria IMS Ticket')); $create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Integria IMS Ticket'));
@ -242,7 +229,6 @@ if (!is_metaconsole() && $config['integria_enabled'] == 0 && $create_ticket_comm
$sql_exclude_command_id = ' AND id <> '.$create_ticket_command_id; $sql_exclude_command_id = ' AND id <> '.$create_ticket_command_id;
} }
$table->data[2][0] = __('Command');
$commands_sql = db_get_all_rows_filter( $commands_sql = db_get_all_rows_filter(
'talert_commands', 'talert_commands',
'id_group IN ('.implode(',', array_keys(users_get_groups(false, 'LW'))).')'.$sql_exclude_command_id, 'id_group IN ('.implode(',', array_keys(users_get_groups(false, 'LW'))).')'.$sql_exclude_command_id,
@ -254,56 +240,65 @@ $commands_sql = db_get_all_rows_filter(
false, false,
true true
); );
$table->data[2][1] = html_print_select_from_sql(
$commands_sql, $create_command = ' ';
'id_command',
$id_command,
'',
'',
0,
true,
false,
false,
(!$is_management_allowed | $disabled)
);
$table->data[2][1] .= ' ';
if ($is_management_allowed === true if ($is_management_allowed === true
&& check_acl($config['id_user'], 0, 'PM') && !$disabled && check_acl($config['id_user'], 0, 'PM') && !$disabled
) { ) {
$table->data[2][1] .= __('Create Command'); $create_command .= __('Create Command');
$table->data[2][1] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">'; $create_command .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
$table->data[2][1] .= html_print_image('images/add.png', true); $create_command .= html_print_image('images/add.png', true);
$table->data[2][1] .= '</a>'; $create_command .= '</a>';
} }
$table->data[2][1] .= '<div id="command_description" ></div>'; $create_command .= '<div id="command_description" ></div>';
$table->colspan[2][1] = 2;
$table->data[3][0] = __('Threshold'); $table->data[1][0] = html_print_label_input_block(
$table->data[3][1] = html_print_extended_select_for_time( __('Command'),
'action_threshold', html_print_select_from_sql(
$action_threshold, $commands_sql,
'', 'id_command',
'', $id_command,
'', '',
false, '',
true, 0,
false, true,
true, false,
'', false,
(!$is_management_allowed | $disabled), (!$is_management_allowed | $disabled)
false, ).$create_command
'',
false,
true
); );
$table->colspan[3][1] = 2;
$table->data[4][0] = ''; $table->data[1][1] = html_print_label_input_block(
$table->data[4][1] = __('Firing'); __('Threshold'),
$table->data[4][2] = __('Recovery'); html_print_extended_select_for_time(
$table->cellstyle[4][1] = 'font-weight: bold;'; 'action_threshold',
$table->cellstyle[4][2] = 'font-weight: bold;'; $action_threshold,
'',
'',
'',
false,
true,
false,
true,
'w100p',
(!$is_management_allowed | $disabled),
false,
'',
false,
true
)
);
$table->data[2][0] = html_print_label_input_block(
__('Recovery'),
''
);
$table->data[2][1] = html_print_label_input_block(
__('Recovery'),
''
);
$table->data[5][0] = __('Command preview'); $table->data[5][0] = __('Command preview');
$table->data[5][1] = html_print_textarea( $table->data[5][1] = html_print_textarea(
@ -372,40 +367,49 @@ for ($i = 1; $i <= $config['max_macro_fields']; $i++) {
$offset = (int) get_parameter('offset', 0); $offset = (int) get_parameter('offset', 0);
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&pure='.$pure.'&offset='.$offset.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions&pure='.$pure.'&offset='.$offset.'" class="max_floating_element_size">';
$table_html = html_print_table($table, true); $table_html = html_print_table($table, true);
$backButton = '';
$submitButton = '';
echo $table_html; echo $table_html;
if ($is_management_allowed === true) { if ($is_management_allowed === true) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
if ($id) { if ($id) {
html_print_input_hidden('id', $id); html_print_input_hidden('id', $id);
if (!$disabled) { if (!$disabled) {
html_print_input_hidden('update_action', 1); html_print_input_hidden('update_action', 1);
html_print_submit_button( $submitButton = html_print_submit_button(
__('Update'), __('Update'),
'create', 'create',
false, false,
'class="sub upd"' ['icon' => 'wand'],
true
); );
} else { } else {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; $backButton = html_print_button(
echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_actions">'; __('Back'),
html_print_submit_button(__('Back'), 'back', false, 'class="sub upd"'); 'back',
echo '</form>'; false,
echo '</div>'; "window.location.href = 'index.php?sec=galertas&sec2=godmode/alerts/alert_actions'",
[
'icon' => 'back',
'class' => 'secondary',
],
true
);
} }
} else { } else {
html_print_input_hidden('create_action', 1); html_print_input_hidden('create_action', 1);
html_print_submit_button( $submitButton = html_print_submit_button(
__('Create'), __('Create'),
'create', 'create',
false, false,
'class="sub wand"' ['icon' => 'wand'],
true
); );
} }
echo '</div>'; html_print_action_buttons($submitButton.$backButton);
} }
echo '</form>'; echo '</form>';