From ea513994607b6869d006248db9a70d90da18c727 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian <daniel.cebrian@pandorafms.com> Date: Wed, 1 Mar 2023 17:27:32 +0100 Subject: [PATCH 01/24] #10347 create view tactic for groups with monitoring and alerts --- pandora_console/godmode/groups/tactical.php | 189 ++++++++ pandora_console/include/functions_graph.php | 177 +++++++ pandora_console/include/functions_groups.php | 447 ++++++++++++++++-- .../include/javascript/tactical_groups.js | 1 + pandora_console/include/lib/Group.php | 34 +- .../include/styles/tactical_groups.css | 15 + 6 files changed, 831 insertions(+), 32 deletions(-) create mode 100644 pandora_console/godmode/groups/tactical.php create mode 100644 pandora_console/include/javascript/tactical_groups.js create mode 100644 pandora_console/include/styles/tactical_groups.css diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php new file mode 100644 index 0000000000..7f095f8472 --- /dev/null +++ b/pandora_console/godmode/groups/tactical.php @@ -0,0 +1,189 @@ +<?php +/** + * Group tactic view. + * + * @category Group Tactic View + * @package Pandora FMS + * @subpackage Opensource + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +// Test id group. +$id_group = 9; + +global $config; + +check_login(); + +if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access Group Management' + ); + include 'general/noaccess.php'; + return; +} + +if (is_metaconsole() === false) { + // Header. + ui_print_standard_header( + __('View tactic'), + 'images/group.png', + false, + '', + false, + [], + [ + [ + 'link' => '', + 'label' => __('Monitoring'), + ], + [ + 'link' => '', + 'label' => __('Tactic group'), + ], + ] + ); +} + +ui_require_css_file('tactical_groups'); +ui_require_javascript_file('tactical_groups'); +$groups = groups_get_children($id_group); +$id_groups = []; +if (count($groups) > 0) { + foreach ($groups as $key => $value) { + $id_groups[] = $value['id_grupo']; + } +} else { + $id_groups[] = $id_group; +} + + +echo '<div id="tactic_view">'; +echo '<table style="width: 100%;">'; +echo '<tr>'; +echo '<td class="tactical_group_left_column">'; +$table_col1 = new stdClass(); +$table_col1->class = 'no-class'; +$table_col1->data = []; +$table_col1->rowclass[] = ''; +$table_col1->headstyle[0] = 'text-align:center;'; +$table_col1->width = '100%'; +$table_col1->data[0][0] = groups_get_heat_map_agents($id_groups, 320, 100); +$table_col1->data[1][0] = tactical_groups_get_agents_and_monitoring($id_groups); + +$distribution_by_so = '<table cellpadding=0 cellspacing=0 class="databox pies mrgn_top_15px" width=100%><tr><td style="width:50%;">'; +$distribution_by_so .= '<fieldset class="padding-0 databox tactical_set" id="distribution_by_so_graph">'; +$distribution_by_so .= '<legend>'.__('Distribution by so').'</legend>'; +$distribution_by_so .= html_print_image('images/spinner.gif', true, ['id' => 'spinner_distribution_by_so_graph']); +$distribution_by_so .= '</fieldset>'; +$distribution_by_so .= '</td></tr></table>'; + + +$table_col1->data[2][0] = $distribution_by_so; + + +ui_toggle( + html_print_table($table_col1, true), + __('Monitoring'), + '', + '', + false, + false +); + +echo '</td>'; +echo '<td class="tactical_group_left_column">'; +$table_col2 = new stdClass(); +$table_col2->class = 'no-class'; +$table_col2->data = []; +$table_col2->rowclass[] = ''; +$table_col2->headstyle[0] = 'text-align:center;'; +$table_col2->width = '100%'; +$table_col2->data[0][0] = tactical_groups_get_stats_alerts($id_groups); +$table_col2->data[1][0] = groups_get_stats_modules_status($id_groups); + +$events_by_agents_group = '<table cellpadding=0 cellspacing=0 class="databox pies mrgn_top_15px" width=100%><tr><td style="width:50%;">'; +$events_by_agents_group .= '<fieldset class="padding-0 databox tactical_set" id="events_by_agents_group_graph">'; +$events_by_agents_group .= '<legend>'.__('Events by agent').'</legend>'; +$events_by_agents_group .= html_print_image('images/spinner.gif', true, ['id' => 'spinner_events_by_agents_group_graph']); +$events_by_agents_group .= '</fieldset>'; +$events_by_agents_group .= '</td></tr></table>'; + + +$table_col2->data[2][0] = $events_by_agents_group; +ui_toggle( + html_print_table($table_col2, true), + __('Alerts'), + '', + '', + false, + false +); +echo '</td>'; +echo '<td class="tactical_group_right_column">'; +$table_col3 = new stdClass(); +$table_col3->class = 'no-class'; +$table_col3->data = []; +$table_col3->rowclass[] = ''; +$table_col3->headstyle[0] = 'text-align:center;'; +$table_col3->width = '100%'; +$table_col3->data[0][0] = 'En desarrollo'; + + +ui_toggle( + html_print_table($table_col3, true), + __('Agents'), + '', + '', + false, + false +); +echo '</td>'; +echo '</tr>'; +echo '</table>'; + + +?> +<script type="text/javascript"> + $(document).ready(function () { + var parameters = {}; + parameters["page"] = "include/ajax/group"; + parameters["method"] = 'distributionBySoGraph'; + parameters["id_group"] = <?php echo $id_group; ?>; + + $.ajax({type: "GET",url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",data: parameters, + success: function(data) { + $("#spinner_distribution_by_so_graph").hide(); + $("#distribution_by_so_graph").append(data); + } + }); + + parameters["method"] = 'groupEventsByAgent'; + $.ajax({type: "GET",url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",data: parameters, + success: function(data) { + $("#spinner_events_by_agents_group_graph").hide(); + $("#events_by_agents_group_graph").append(data); + } + }); + + }); +</script> \ No newline at end of file diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 0f6d03fee7..98ad504b54 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5339,3 +5339,180 @@ function get_baseline_data( $result['agent_alias'] = $array_data[0]['sum0']['agent_alias']; return ['sum0' => $result]; } + + +function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true) +{ + global $config; + + $id_groups = [$id_group]; + + if ($recursive == true) { + $groups = groups_get_children($id_group); + if (count($groups) > 0) { + $id_groups = []; + foreach ($groups as $key => $value) { + $id_groups[] = $value['id_grupo']; + } + } + } + + $sql = sprintf( + 'SELECT COUNT(id_agente) AS count, + os.name + FROM tagente a + LEFT JOIN tconfig_os os ON a.id_os = os.id_os + WHERE a.id_grupo IN (%s) + GROUP BY os.id_os', + implode(',', $id_groups) + ); + + $result = db_get_all_rows_sql($sql, false, false); + if ($result === false) { + $result = []; + } + + $labels = []; + $data = []; + foreach ($result as $key => $row) { + $labels[] = $row['name']; + $data[] = $row['count']; + } + + $water_mark = [ + 'file' => $config['homedir'].'/images/logo_vertical_water.png', + 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), + ]; + + $options = [ + 'width' => $width, + 'height' => $height, + 'waterMark' => $water_mark, + 'legend' => [ + 'display' => true, + 'position' => 'right', + 'align' => 'center', + ], + 'labels' => $labels, + ]; + + return pie_graph( + $data, + $options + ); + +} + + +function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWaterMark=true, $time_limit=false, $recursive=true) +{ + global $config; + + $data = []; + $labels = []; + $loop = 0; + define('NUM_PIECES_PIE_2', 6); + + // Add tags condition to filter. + $tags_condition = tags_get_acl_tags( + $config['id_user'], + 0, + 'ER', + 'event_condition', + 'AND' + ); + + if ($time_limit && $config['event_view_hr']) { + $tags_condition .= ' AND utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')'; + } + + $id_groups = [$id_group]; + if ($recursive === true) { + $groups = groups_get_children($id_group); + if (count($groups) > 0) { + $id_groups = []; + foreach ($groups as $key => $value) { + $id_groups[] = $value['id_grupo']; + } + } + } + + $filter_groups = ' AND te.id_grupo IN ('.implode(',', $id_groups).') '; + + // This will give the distinct id_agente, give the id_grupo that goes + // with it and then the number of times it occured. GROUP BY statement + // is required if both DISTINCT() and COUNT() are in the statement. + $sql = sprintf( + 'SELECT DISTINCT(id_agente) AS id_agente, + COUNT(id_agente) AS count + FROM tevento te + WHERE 1=1 AND estado = 0 %s %s + GROUP BY id_agente + ORDER BY count DESC LIMIT 8', + $tags_condition, + $filter_groups + ); + $result = db_get_all_rows_sql($sql, false, false); + if ($result === false) { + $result = []; + } + + $system_events = 0; + $other_events = 0; + + foreach ($result as $row) { + $row['id_grupo'] = agents_get_agent_group($row['id_agente']); + if (!check_acl($config['id_user'], $row['id_grupo'], 'ER') == 1) { + continue; + } + + if ($loop >= NUM_PIECES_PIE_2) { + $other_events += $row['count']; + } else { + if ($row['id_agente'] == 0) { + $system_events += $row['count']; + } else { + $alias = agents_get_alias($row['id_agente']); + $name = mb_substr($alias, 0, 25).' #'.$row['id_agente'].' ('.$row['count'].')'; + $labels[] = io_safe_output($name); + $data[] = $row['count']; + } + } + + $loop++; + } + + if ($system_events > 0) { + $name = __('SYSTEM').' ('.$system_events.')'; + $labels[] = io_safe_output($name); + $data[] = $system_events; + } + + // Sort the data. + arsort($data); + if ($noWaterMark) { + $water_mark = [ + 'file' => $config['homedir'].'/images/logo_vertical_water.png', + 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), + ]; + } else { + $water_mark = []; + } + + $options = [ + 'width' => $width, + 'height' => $height, + 'waterMark' => $water_mark, + 'legend' => [ + 'display' => true, + 'position' => 'right', + 'align' => 'center', + ], + 'labels' => $labels, + ]; + + return pie_graph( + $data, + $options + ); +} diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 20841bf26a..752ec4396a 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1276,7 +1276,7 @@ function groups_get_not_init_agents($group, $agent_filter=[], $module_filter=[], * * @return integer Number of monitors. */ -function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false) +function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true) { if (empty($group)) { return 0; @@ -1291,7 +1291,11 @@ function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[] } $group_str = implode(',', $groups); - $groups_clause = "AND (ta.id_grupo IN ($group_str) OR tasg.id_group IN ($group_str))"; + if ($secondary_group === true) { + $groups_clause = "AND (ta.id_grupo IN ($group_str) OR tasg.id_group IN ($group_str))"; + } else { + $groups_clause = "AND (ta.id_grupo IN ($group_str))"; + } $tags_clause = ''; @@ -1401,10 +1405,12 @@ function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[] ON tam.id_agente_modulo = tae.id_agente_modulo $modules_clause INNER JOIN tagente ta - ON tam.id_agente = ta.id_agente - LEFT JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - AND ta.disabled = 0 + ON tam.id_agente = ta.id_agente"; + if ($secondary_group === true) { + $sql .= ' LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent'; + } + + $sql .= "AND ta.disabled = 0 $agent_name_filter $agents_clause WHERE tam.disabled = 0 @@ -1450,8 +1456,9 @@ function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[] } $status_columns_str = implode(',', $status_columns_array); + $status_columns_str_sum = implode('+', $status_columns_array); - $sql = "SELECT SUM($status_columns_str) FROM + $sql = "SELECT SUM($status_columns_str_sum) FROM (SELECT DISTINCT(ta.id_agente), $status_columns_str FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent @@ -1486,11 +1493,11 @@ function groups_get_monitors_counter($group, $agent_filter=[], $module_filter=[] * * @return integer Number of monitors. */ -function groups_get_total_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false) +function groups_get_total_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true) { // Always modify the module status filter $module_filter['status'] = AGENT_MODULE_STATUS_ALL; - return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime); + return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group); } @@ -1511,11 +1518,11 @@ function groups_get_total_monitors($group, $agent_filter=[], $module_filter=[], * * @return integer Number of monitors. */ -function groups_get_normal_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false) +function groups_get_normal_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true) { // Always modify the module status filter $module_filter['status'] = AGENT_MODULE_STATUS_NORMAL; - return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime); + return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group); } @@ -1536,11 +1543,11 @@ function groups_get_normal_monitors($group, $agent_filter=[], $module_filter=[], * * @return integer Number of monitors. */ -function groups_get_critical_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false) +function groups_get_critical_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true) { // Always modify the module status filter $module_filter['status'] = AGENT_MODULE_STATUS_CRITICAL_BAD; - return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime); + return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group); } @@ -1561,11 +1568,11 @@ function groups_get_critical_monitors($group, $agent_filter=[], $module_filter=[ * * @return integer Number of monitors. */ -function groups_get_warning_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false) +function groups_get_warning_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true) { // Always modify the module status filter $module_filter['status'] = AGENT_MODULE_STATUS_WARNING; - return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime); + return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group); } @@ -1586,11 +1593,11 @@ function groups_get_warning_monitors($group, $agent_filter=[], $module_filter=[] * * @return integer Number of monitors. */ -function groups_get_unknown_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false) +function groups_get_unknown_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true) { // Always modify the module status filter $module_filter['status'] = AGENT_MODULE_STATUS_UNKNOWN; - return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime); + return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group); } @@ -1611,11 +1618,11 @@ function groups_get_unknown_monitors($group, $agent_filter=[], $module_filter=[] * * @return integer Number of monitors. */ -function groups_get_not_init_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false) +function groups_get_not_init_monitors($group, $agent_filter=[], $module_filter=[], $strict_user=false, $groups_and_tags=false, $realtime=false, $secondary_group=true) { // Always modify the module status filter $module_filter['status'] = AGENT_MODULE_STATUS_NOT_INIT; - return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime); + return groups_get_monitors_counter($group, $agent_filter, $module_filter, $strict_user, $groups_and_tags, $realtime, $secondary_group); } @@ -1746,7 +1753,7 @@ function groups_monitor_total_counters($group_array, $search_in_testado=false) } -function groups_agents_total_counters($group_array) +function groups_agents_total_counters($group_array, $secondary_groups=true) { $default_total = [ 'ok' => 0, @@ -1763,30 +1770,36 @@ function groups_agents_total_counters($group_array) } $group_clause = implode(',', $group_array); - $group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))"; + if ($secondary_groups === true) { + $group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))"; + } else { + $group_clause = "(ta.id_grupo IN ($group_clause))"; + } $condition_critical = agents_get_status_clause(AGENT_STATUS_CRITICAL); $condition_warning = agents_get_status_clause(AGENT_STATUS_WARNING); $condition_unknown = agents_get_status_clause(AGENT_STATUS_UNKNOWN); $condition_not_init = agents_get_status_clause(AGENT_STATUS_NOT_INIT); $condition_normal = agents_get_status_clause(AGENT_STATUS_NORMAL); + $sql = "SELECT SUM(IF($condition_normal, 1, 0)) AS ok, SUM(IF($condition_critical, 1, 0)) AS critical, SUM(IF($condition_warning, 1, 0)) AS warning, SUM(IF($condition_unknown, 1, 0)) AS unknown, SUM(IF($condition_not_init, 1, 0)) AS not_init, COUNT(ta.id_agente) AS total - FROM tagente ta - WHERE ta.disabled = 0 + FROM tagente ta + WHERE ta.disabled = 0 AND ta.id_agente IN ( - SELECT ta.id_agente FROM tagente ta - LEFT JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE ta.disabled = 0 - AND $group_clause - GROUP BY ta.id_agente - ) - "; + SELECT ta.id_agente FROM tagente ta"; + if ($secondary_groups === true) { + $sql .= ' LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent'; + } + + $sql .= " WHERE ta.disabled = 0 + AND $group_clause + GROUP BY ta.id_agente + )"; $agents = db_get_row_sql($sql); @@ -2438,3 +2451,375 @@ function groups_get_group_deep($id_group) return $deep; } + + +function groups_get_heat_map_agents(array $id_group, float $width=0, float $height=0) +{ + ui_require_css_file('heatmap'); + + if (is_array($id_group) === false) { + $id_group = [$id_group]; + } + + $sql = 'SELECT * FROM tagente WHERE id_grupo IN('.implode(',', $id_group).')'; + + $all_agents = db_get_all_rows_sql($sql); + hd($sql, true); + if (empty($all_agents)) { + return null; + } + + $total_agents = count($all_agents); + + // Best square. + $high = (float) max($width, $height); + $low = 0.0; + + while (abs($high - $low) > 0.000001) { + $mid = (($high + $low) / 2.0); + $midval = (floor($width / $mid) * floor($height / $mid)); + if ($midval >= $total_agents) { + $low = $mid; + } else { + $high = $mid; + } + } + + $square_length = min(($width / floor($width / $low)), ($height / floor($height / $low))); + + // Print starmap. + $html = sprintf( + '<svg id="svg_%s" style="width: %spx; height: %spx;">', + $id_group, + $width, + $height + ); + + $html .= '<g>'; + $row = 0; + $column = 0; + $x = 0; + $y = 0; + $cont = 1; + + foreach ($all_agents as $key => $value) { + // Colour by status. + $status = agents_get_status_from_counts($value); + + switch ($status) { + case 5: + // Not init status. + $status = 'notinit'; + break; + + case 1: + // Critical status. + $status = 'critical'; + break; + + case 2: + // Warning status. + $status = 'warning'; + break; + + case 0: + // Normal status. + $status = 'normal'; + break; + + case 3: + case -1: + default: + // Unknown status. + $status = 'unknown'; + break; + } + + $html .= sprintf( + '<rect id="%s" x="%s" y="%s" row="%s" col="%s" width="%s" height="%s" class="%s_%s" onclick="showInfoAgent('.$value['id_agente'].')"></rect>', + 'rect_'.$cont, + $x, + $y, + $row, + $column, + $square_length, + $square_length, + $status, + random_int(1, 10) + ); + + $y += $square_length; + $row++; + if ((int) ($y + $square_length) > (int) $height) { + $y = 0; + $x += $square_length; + $row = 0; + $column++; + } + + if ((int) ($x + $square_length) > (int) $width) { + $x = 0; + $y += $square_length; + $column = 0; + $row++; + } + + $cont++; + } + ?> + <script type="text/javascript"> + $(document).ready(function() { + const total_modules = '<?php echo $total_agents; ?>'; + + function getRandomInteger(min, max) { + return Math.floor(Math.random() * max) + min; + } + + function oneSquare(solid, time) { + var randomPoint = getRandomInteger(1, total_modules); + let target = $(`#rect_${randomPoint}`); + let class_name = target.attr('class'); + class_name = class_name.split('_')[0]; + setTimeout(function() { + target.removeClass(); + target.addClass(`${class_name}_${solid}`); + oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900)); + }, time); + } + + let cont = 0; + while (cont < Math.ceil(total_modules / 3)) { + oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900)); + cont ++; + } + }); + </script> + <?php + $html .= '</g>'; + $html .= '</svg>'; + + return $html; +} + + +function tactical_groups_get_agents_and_monitoring($id_groups) +{ + global $config; + + $data = [ + 'total_agents' => groups_agents_total_counters($id_groups, false)['total'], + 'monitor_total' => groups_get_total_monitors($id_groups, [], [], false, false, false, false), + ]; + + // Link URLS + $urls = []; + $urls['total_agents'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60'; + $urls['monitor_total'] = $config['homeurl'].'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=60&status=-1'; + + $table_am = html_get_predefined_table(); + $tdata = []; + $tdata[0] = html_print_image('images/agent.png', true, ['title' => __('Total agents'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[1] = $data['total_agents'] <= 0 ? '-' : $data['total_agents']; + $tdata[1] = '<a class="big_data" href="'.$urls['total_agents'].'">'.$tdata[1].'</a>'; + + if ($data['total_agents'] > 500 && !enterprise_installed()) { + $tdata[2] = "<div id='agentsmodal' class='publienterprise' title='".__('Enterprise version not installed')."'><img data-title='Enterprise version' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>"; + } + + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Monitor checks'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[4] = $data['monitor_total'] <= 0 ? '-' : $data['monitor_total']; + $tdata[4] = '<a class="big_data" href="'.$urls['monitor_total'].'">'.$tdata[4].'</a>'; + + /* + Hello there! :) + We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger’ of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :( + You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years. + */ + if ($data['total_agents']) { + if (($data['monitor_total'] / $data['total_agents'] > 100) && !enterprise_installed()) { + $tdata[5] = "<div id='monitorcheckmodal' class='publienterprise' title='Community version' ><img data-title='".__('Enterprise version not installed')."' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>"; + } + } + + $table_am->rowclass[] = ''; + $table_am->data[] = $tdata; + + $output = '<fieldset class="databox tactical_set"> + <legend>'.__('Total agents and monitors').'</legend>'.html_print_table($table_am, true).'</fieldset>'; + + return $output; +} + + +function tactical_groups_get_stats_alerts($id_groups) +{ + global $config; + + $alerts = groups_monitor_alerts_total_counters($id_groups); + $data = [ + 'monitor_alerts' => $alerts['total'], + 'monitor_alerts_fired' => $alerts['fired'], + + ]; + + $urls = []; + $urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60'; + $urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&disabled=fired'; + + // Alerts table. + $table_al = html_get_predefined_table(); + + $tdata = []; + $tdata[0] = html_print_image('images/bell.png', true, ['title' => __('Defined alerts'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[1] = $data['monitor_alerts'] <= 0 ? '-' : $data['monitor_alerts']; + $tdata[1] = '<a class="big_data" href="'.$urls['monitor_alerts'].'">'.$tdata[1].'</a>'; + + /* + Hello there! :) + We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger’ of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :( + You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years. + */ + + if ($data['monitor_alerts'] > $data['total_agents'] && !enterprise_installed()) { + $tdata[2] = "<div id='alertagentmodal' class='publienterprise' title='Community version' ><img data-title='".__('Enterprise version not installed')."' class='img_help forced_title' data-use_title_for_force_title='1' src='images/alert_enterprise.png'></div>"; + } + + $tdata[3] = html_print_image( + 'images/bell_error.png', + true, + [ + 'title' => __('Fired alerts'), + 'class' => 'invert_filter', + ], + false, + false, + false, + true + ); + $tdata[4] = $data['monitor_alerts_fired'] <= 0 ? '-' : $data['monitor_alerts_fired']; + $tdata[4] = '<a style="color: '.COL_ALERTFIRED.';" class="big_data" href="'.$urls['monitor_alerts_fired'].'">'.$tdata[4].'</a>'; + $table_al->rowclass[] = ''; + $table_al->data[] = $tdata; + + if (!is_metaconsole()) { + $output = '<fieldset class="databox tactical_set"> + <legend>'.__('Defined and fired alerts').'</legend>'.html_print_table($table_al, true).'</fieldset>'; + } else { + // Remove the defined alerts cause with the new cache table is difficult to retrieve them. + unset($table_al->data[0][0], $table_al->data[0][1]); + + $table_al->class = 'tactical_view'; + $table_al->style = []; + $output = '<fieldset class="tactical_set"> + <legend>'.__('Fired alerts').'</legend>'.html_print_table($table_al, true).'</fieldset>'; + } + + return $output; +} + + +function groups_get_stats_modules_status($id_groups, $graph_width=250, $graph_height=150, $links=false, $data_agents=false) +{ + global $config; + + $data = [ + 'monitor_critical' => groups_get_critical_monitors($id_groups, [], [], false, false, false, false), + 'monitor_warning' => groups_get_warning_monitors($id_groups, [], [], false, false, false, false), + 'monitor_ok' => groups_get_normal_monitors($id_groups, [], [], false, false, false, false), + 'monitor_unknown' => groups_get_unknown_monitors($id_groups, [], [], false, false, false, false), + 'monitor_not_init' => groups_get_not_init_monitors($id_groups, [], [], false, false, false, false), + ]; + + // Link URLS. + if ($links === false) { + $urls = []; + $urls['monitor_critical'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_CRITICAL_BAD.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; + $urls['monitor_warning'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_WARNING.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; + $urls['monitor_ok'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NORMAL.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; + $urls['monitor_unknown'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_UNKNOWN.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; + $urls['monitor_not_init'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NOT_INIT.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; + } else { + $urls = []; + $urls['monitor_critical'] = $links['monitor_critical']; + $urls['monitor_warning'] = $links['monitor_warning']; + $urls['monitor_ok'] = $links['monitor_ok']; + $urls['monitor_unknown'] = $links['monitor_unknown']; + $urls['monitor_not_init'] = $links['monitor_not_init']; + } + + // Fixed width non interactive charts + $status_chart_width = $graph_width; + + // Modules by status table + $table_mbs = html_get_predefined_table(); + + $tdata = []; + $tdata[0] = html_print_image('images/module_critical.png', true, ['title' => __('Monitor critical')], false, false, false, true); + $tdata[1] = $data['monitor_critical'] <= 0 ? '-' : $data['monitor_critical']; + $tdata[1] = '<a style="color: '.COL_CRITICAL.';" class="big_data line_heigth_initial" href="'.$urls['monitor_critical'].'">'.$tdata[1].'</a>'; + + $tdata[2] = html_print_image('images/module_warning.png', true, ['title' => __('Monitor warning')], false, false, false, true); + $tdata[3] = $data['monitor_warning'] <= 0 ? '-' : $data['monitor_warning']; + $tdata[3] = '<a style="color: '.COL_WARNING_DARK.';" class="big_data line_heigth_initial" href="'.$urls['monitor_warning'].'">'.$tdata[3].'</a>'; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; + + $tdata = []; + $tdata[0] = html_print_image('images/module_ok.png', true, ['title' => __('Monitor normal')], false, false, false, true); + $tdata[1] = $data['monitor_ok'] <= 0 ? '-' : $data['monitor_ok']; + $tdata[1] = '<a style="color: '.COL_NORMAL.';" class="big_data" href="'.$urls['monitor_ok'].'">'.$tdata[1].'</a>'; + + $tdata[2] = html_print_image('images/module_unknown.png', true, ['title' => __('Monitor unknown')], false, false, false, true); + $tdata[3] = $data['monitor_unknown'] <= 0 ? '-' : $data['monitor_unknown']; + $tdata[3] = '<a style="color: '.COL_UNKNOWN.';" class="big_data line_heigth_initial" href="'.$urls['monitor_unknown'].'">'.$tdata[3].'</a>'; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; + + $tdata = []; + $tdata[0] = html_print_image('images/module_notinit.png', true, ['title' => __('Monitor not init')], false, false, false, true); + $tdata[1] = $data['monitor_not_init'] <= 0 ? '-' : $data['monitor_not_init']; + $tdata[1] = '<a style="color: '.COL_NOTINIT.';" class="big_data line_heigth_initial" href="'.$urls['monitor_not_init'].'">'.$tdata[1].'</a>'; + + $tdata[2] = $tdata[3] = ''; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; + + if ($data['monitor_checks'] > 0) { + $tdata = []; + $table_mbs->colspan[count($table_mbs->data)][0] = 4; + $table_mbs->cellstyle[count($table_mbs->data)][0] = 'text-align: center;'; + $tdata[0] = '<div id="outter_status_pie" style="height: '.$graph_height.'px">'.'<div id="status_pie" style="margin: auto; width: '.$status_chart_width.'px;">'.graph_agent_status(false, $graph_width, $graph_height, true, true, $data_agents).'</div></div>'; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; + } + + if (!is_metaconsole()) { + $output = ' + <fieldset class="databox tactical_set"> + <legend>'.__('Monitors by status').'</legend>'.html_print_table($table_mbs, true).'</fieldset>'; + } else { + $table_mbs->class = 'tactical_view'; + $table_mbs->style = []; + $output = ' + <fieldset class="tactical_set"> + <legend>'.__('Monitors by status').'</legend>'.html_print_table($table_mbs, true).'</fieldset>'; + } + + return $output; +} + + +function groups_get_agents_group($id_groups) +{ + global $config; + + if (is_array($id_groups) === false) { + $id_groups = [$id_groups]; + } + + if ($rows === false) { + $rows = []; + } + + return $rows; +} \ No newline at end of file diff --git a/pandora_console/include/javascript/tactical_groups.js b/pandora_console/include/javascript/tactical_groups.js new file mode 100644 index 0000000000..cf2a8ca42d --- /dev/null +++ b/pandora_console/include/javascript/tactical_groups.js @@ -0,0 +1 @@ +function showInfoAgent(id_agent) {} diff --git a/pandora_console/include/lib/Group.php b/pandora_console/include/lib/Group.php index 1f34f941fd..745b1e4039 100644 --- a/pandora_console/include/lib/Group.php +++ b/pandora_console/include/lib/Group.php @@ -43,7 +43,11 @@ class Group extends Entity * * @var array */ - private static $ajaxMethods = ['getGroupsForSelect']; + private static $ajaxMethods = [ + 'getGroupsForSelect', + 'distributionBySoGraph', + 'groupEventsByAgent', + ]; /** @@ -473,4 +477,32 @@ class Group extends Entity } + public static function distributionBySoGraph() + { + global $config; + $id_group = get_parameter('id_group', ''); + include_once $config['homedir'].'/include/functions_graph.php'; + + $out = '<div style="flex: 0 0 300px; width:99%; height:100%;">'; + $out .= graph_so_by_group($id_group); + $out .= '<div>'; + echo $out; + return; + } + + + public static function groupEventsByAgent() + { + global $config; + $id_group = get_parameter('id_group', ''); + include_once $config['homedir'].'/include/functions_graph.php'; + + $out = '<div style="flex: 0 0 300px; width:99%; height:100%;">'; + $out .= graph_events_agent_by_group($id_group, 300, 200, true, true); + $out .= '<div>'; + echo $out; + return; + } + + } diff --git a/pandora_console/include/styles/tactical_groups.css b/pandora_console/include/styles/tactical_groups.css new file mode 100644 index 0000000000..423292a336 --- /dev/null +++ b/pandora_console/include/styles/tactical_groups.css @@ -0,0 +1,15 @@ +.tactical_group_left_column { + vertical-align: top; + min-width: 30em; + width: 30%; + padding-top: 0px; +} +.tactical_group_right_column { + width: 40%; + vertical-align: top; + min-width: 30em; + padding-top: 0px; +} +rect { + cursor: pointer; +} From a4a5650a01f7ef084daaf54bb3b150757fb090f3 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian <daniel.cebrian@pandorafms.com> Date: Thu, 2 Mar 2023 11:10:37 +0100 Subject: [PATCH 02/24] #10347 added modal in heatmap agent --- pandora_console/godmode/groups/tactical.php | 2 +- pandora_console/include/functions_groups.php | 17 ----- .../include/javascript/tactical_groups.js | 19 ++++- pandora_console/include/lib/Group.php | 71 +++++++++++++++++++ .../include/styles/tactical_groups.css | 10 +++ 5 files changed, 100 insertions(+), 19 deletions(-) diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 7f095f8472..faa1628ec0 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -160,7 +160,7 @@ ui_toggle( echo '</td>'; echo '</tr>'; echo '</table>'; - +echo '<div id="modal-info-agent"></div>' ?> <script type="text/javascript"> diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 752ec4396a..0179eb884d 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -2464,7 +2464,6 @@ function groups_get_heat_map_agents(array $id_group, float $width=0, float $heig $sql = 'SELECT * FROM tagente WHERE id_grupo IN('.implode(',', $id_group).')'; $all_agents = db_get_all_rows_sql($sql); - hd($sql, true); if (empty($all_agents)) { return null; } @@ -2806,20 +2805,4 @@ function groups_get_stats_modules_status($id_groups, $graph_width=250, $graph_he } return $output; -} - - -function groups_get_agents_group($id_groups) -{ - global $config; - - if (is_array($id_groups) === false) { - $id_groups = [$id_groups]; - } - - if ($rows === false) { - $rows = []; - } - - return $rows; } \ No newline at end of file diff --git a/pandora_console/include/javascript/tactical_groups.js b/pandora_console/include/javascript/tactical_groups.js index cf2a8ca42d..41a85794a7 100644 --- a/pandora_console/include/javascript/tactical_groups.js +++ b/pandora_console/include/javascript/tactical_groups.js @@ -1 +1,18 @@ -function showInfoAgent(id_agent) {} +/* global $ */ +function showInfoAgent(id_agent) { + load_modal({ + target: $("#modal-info-agent"), + url: "ajax.php", + modal: { + title: "Info agent", + cancel: "close" + }, + onshow: { + page: "include/ajax/group", + method: "loadInfoAgent", + extradata: { + idAgent: id_agent + } + } + }); +} diff --git a/pandora_console/include/lib/Group.php b/pandora_console/include/lib/Group.php index 745b1e4039..a7714e217e 100644 --- a/pandora_console/include/lib/Group.php +++ b/pandora_console/include/lib/Group.php @@ -47,6 +47,7 @@ class Group extends Entity 'getGroupsForSelect', 'distributionBySoGraph', 'groupEventsByAgent', + 'loadInfoAgent', ]; @@ -505,4 +506,74 @@ class Group extends Entity } + public static function loadInfoAgent() + { + $extradata = get_parameter('extradata', ''); + echo '<div class="info-agent">'; + + if (empty($extradata) === false) { + $extradata = json_decode(io_safe_output($extradata), true); + $agent = agents_get_agent($extradata['idAgent']); + + if (is_array($agent)) { + $status_img = agents_tree_view_status_img( + $agent['critical_count'], + $agent['warning_count'], + $agent['unknown_count'], + $agent['total_count'], + $agent['notinit_count'] + ); + $table = new \stdClass(); + $table->class = 'table_modal_alternate'; + $table->data = [ + [ + __('Id'), + $agent['id_agente'], + ], + [ + __('Agent name'), + '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$agent['id_agente'].'"><b>'.$agent['nombre'].'</b></a>', + ], + [ + __('Alias'), + $agent['alias'], + ], + [ + __('Ip Address'), + $agent['direccion'], + ], + [ + __('Status'), + $status_img, + ], + [ + __('Group'), + groups_get_name($agent['id_grupo']), + ], + [ + __('Interval'), + $agent['intervalo'], + ], + [ + __('Operative system'), + get_os_name($agent['id_os']), + ], + [ + __('Server name'), + $agent['server_name'], + ], + [ + __('Description'), + $agent['comentarios'], + ], + ]; + + html_print_table($table); + } + } + + echo '</div>'; + } + + } diff --git a/pandora_console/include/styles/tactical_groups.css b/pandora_console/include/styles/tactical_groups.css index 423292a336..ec8a5cf9c2 100644 --- a/pandora_console/include/styles/tactical_groups.css +++ b/pandora_console/include/styles/tactical_groups.css @@ -13,3 +13,13 @@ rect { cursor: pointer; } +.info-agent { + width: 100%; + max-height: 400px; +} +.info-agent table { + width: 100%; +} +#modal-info-agent { + display: none; +} From dc6256058f0996c875923541d9b8f68b6c628929 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian <daniel.cebrian@pandorafms.com> Date: Thu, 2 Mar 2023 13:48:14 +0100 Subject: [PATCH 03/24] #10347 added list agents in tactical view groups --- pandora_console/godmode/groups/tactical.php | 50 +++++- pandora_console/include/functions_graph.php | 12 +- pandora_console/include/lib/Group.php | 147 ++++++++++++++++++ .../include/styles/tactical_groups.css | 3 + 4 files changed, 202 insertions(+), 10 deletions(-) diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index faa1628ec0..250d4d83a9 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -26,9 +26,6 @@ * ============================================================================ */ -// Test id group. -$id_group = 9; - global $config; check_login(); @@ -42,6 +39,11 @@ if (! check_acl($config['id_user'], 0, 'PM')) { return; } +$id_group = get_parameter('id', ''); +if (empty($id_group) === true) { + return; +} + if (is_metaconsole() === false) { // Header. ui_print_standard_header( @@ -132,7 +134,7 @@ $events_by_agents_group .= '</td></tr></table>'; $table_col2->data[2][0] = $events_by_agents_group; ui_toggle( html_print_table($table_col2, true), - __('Alerts'), + __('Alerts and events'), '', '', false, @@ -146,8 +148,46 @@ $table_col3->data = []; $table_col3->rowclass[] = ''; $table_col3->headstyle[0] = 'text-align:center;'; $table_col3->width = '100%'; -$table_col3->data[0][0] = 'En desarrollo'; +try { + $columns = [ + 'alias', + 'status', + 'alerts', + 'ultimo_contacto_remoto', + ]; + + $columnNames = [ + __('Alias'), + __('Status'), + __('Alerts'), + __('Ultimo contacto remoto'), + ]; + + // Load datatables user interface. + $table_col3->data[3][0] = ui_print_datatable( + [ + 'id' => 'list_agents_tactical', + 'class' => 'info_table', + 'style' => 'width: 100%', + 'columns' => $columns, + 'column_names' => $columnNames, + 'return' => true, + 'ajax_url' => 'include/ajax/group', + 'ajax_data' => [ + 'method' => 'getAgentsByGroup', + 'id_group' => $id_group, + ], + 'no_sortable_columns' => [-1], + 'order' => [ + 'field' => 'alias', + 'direction' => 'asc', + ], + ] + ); +} catch (Exception $e) { + echo $e->getMessage(); +} ui_toggle( html_print_table($table_col3, true), diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 98ad504b54..2d847fa50c 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5341,7 +5341,7 @@ function get_baseline_data( } -function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true) +function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true, $noWaterMark=true) { global $config; @@ -5379,10 +5379,12 @@ function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true) $data[] = $row['count']; } - $water_mark = [ - 'file' => $config['homedir'].'/images/logo_vertical_water.png', - 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), - ]; + if ($noWaterMark === false) { + $water_mark = [ + 'file' => $config['homedir'].'/images/logo_vertical_water.png', + 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), + ]; + } $options = [ 'width' => $width, diff --git a/pandora_console/include/lib/Group.php b/pandora_console/include/lib/Group.php index a7714e217e..aa4e3c85d7 100644 --- a/pandora_console/include/lib/Group.php +++ b/pandora_console/include/lib/Group.php @@ -48,6 +48,7 @@ class Group extends Entity 'distributionBySoGraph', 'groupEventsByAgent', 'loadInfoAgent', + 'getAgentsByGroup', ]; @@ -576,4 +577,150 @@ class Group extends Entity } + public static function getAgentsByGroup() + { + global $config; + + $data = []; + $id_group = get_parameter('id_group', ''); + $id_groups = [$id_group]; + $groups = groups_get_children($id_group); + + if (count($groups) > 0) { + $id_groups = []; + foreach ($groups as $key => $value) { + $id_groups[] = $value['id_grupo']; + } + } + + $start = get_parameter('start', 0); + $length = get_parameter('length', $config['block_size']); + $orderDatatable = get_datatable_order(true); + $pagination = ''; + $order = ''; + + try { + ob_start(); + if (isset($orderDatatable)) { + switch ($orderDatatable['field']) { + case 'alerts': + $orderDatatable['field'] = 'fired_count'; + break; + + case 'status': + $orderDatatable['field'] = 'total_count'; + + default: + $orderDatatable['field'] = $orderDatatable['field']; + break; + } + + $order = sprintf( + ' ORDER BY %s %s', + $orderDatatable['field'], + $orderDatatable['direction'] + ); + } + + if (isset($length) && $length > 0 + && isset($start) && $start >= 0 + ) { + $pagination = sprintf( + ' LIMIT %d OFFSET %d ', + $length, + $start + ); + } + + $sql = sprintf( + 'SELECT alias, + critical_count, + warning_count, + unknown_count, + total_count, + notinit_count, + ultimo_contacto_remoto, + fired_count + FROM tagente t + WHERE disabled = 0 AND + total_count <> notinit_count AND + id_grupo IN (%s) + %s %s', + implode(',', $id_groups), + $order, + $pagination + ); + + $data = db_get_all_rows_sql($sql); + + $sql = sprintf( + 'SELECT alias, + critical_count, + warning_count, + unknown_count, + total_count, + notinit_count, + ultimo_contacto_remoto, + fired_count + FROM tagente t + WHERE disabled = 0 AND + total_count <> notinit_count AND + id_grupo IN (%s) + %s', + implode(',', $id_groups), + $order, + ); + + $count_agents = db_get_num_rows($sql); + + foreach ($data as $key => $agent) { + $status_img = agents_tree_view_status_img( + $agent['critical_count'], + $agent['warning_count'], + $agent['unknown_count'], + $agent['total_count'], + $agent['notinit_count'] + ); + $data[$key]['alias'] = '<a href="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$agent['id_agente'].'"><b>'.$agent['alias'].'</b></a>'; + $data[$key]['status'] = $status_img; + $data[$key]['alerts'] = agents_tree_view_alert_img($agent['fired_count']); + } + + if (empty($data) === true) { + $total = 0; + $data = []; + } else { + $total = $count_agents; + } + + echo json_encode( + [ + 'data' => $data, + 'recordsTotal' => $total, + 'recordsFiltered' => $total, + ] + ); + // Capture output. + $response = ob_get_clean(); + } catch (\Exception $e) { + echo json_encode(['error' => $e->getMessage()]); + exit; + } + + json_decode($response); + if (json_last_error() === JSON_ERROR_NONE) { + echo $response; + } else { + echo json_encode( + [ + 'success' => false, + 'error' => $response, + ] + ); + } + + exit; + } + + } diff --git a/pandora_console/include/styles/tactical_groups.css b/pandora_console/include/styles/tactical_groups.css index ec8a5cf9c2..eb710851c0 100644 --- a/pandora_console/include/styles/tactical_groups.css +++ b/pandora_console/include/styles/tactical_groups.css @@ -23,3 +23,6 @@ rect { #modal-info-agent { display: none; } +#list_agents_tactical_wrapper { + max-height: 600px; +} From af5a6208833f5ae42fbfc7199c68f9c98277c23f Mon Sep 17 00:00:00 2001 From: Daniel Cebrian <daniel.cebrian@pandorafms.com> Date: Thu, 2 Mar 2023 16:22:25 +0100 Subject: [PATCH 04/24] #10347 fixed urls monitors and added name group --- pandora_console/godmode/groups/tactical.php | 4 ++-- pandora_console/include/functions_graph.php | 8 +++++--- pandora_console/include/functions_groups.php | 18 +++++++++--------- pandora_console/include/lib/Group.php | 11 +++++++---- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 250d4d83a9..352da1bdcd 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -47,7 +47,7 @@ if (empty($id_group) === true) { if (is_metaconsole() === false) { // Header. ui_print_standard_header( - __('View tactic'), + __(groups_get_name($id_group)), 'images/group.png', false, '', @@ -89,7 +89,7 @@ $table_col1->data = []; $table_col1->rowclass[] = ''; $table_col1->headstyle[0] = 'text-align:center;'; $table_col1->width = '100%'; -$table_col1->data[0][0] = groups_get_heat_map_agents($id_groups, 320, 100); +$table_col1->data[0][0] = groups_get_heat_map_agents($id_groups, 450, 100); $table_col1->data[1][0] = tactical_groups_get_agents_and_monitoring($id_groups); $distribution_by_so = '<table cellpadding=0 cellspacing=0 class="databox pies mrgn_top_15px" width=100%><tr><td style="width:50%;">'; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 2d847fa50c..4ccde63e98 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5379,11 +5379,13 @@ function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true, $data[] = $row['count']; } - if ($noWaterMark === false) { + if ($noWaterMark === true) { $water_mark = [ 'file' => $config['homedir'].'/images/logo_vertical_water.png', 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), ]; + } else { + $water_mark = []; } $options = [ @@ -5448,7 +5450,7 @@ function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWate 'SELECT DISTINCT(id_agente) AS id_agente, COUNT(id_agente) AS count FROM tevento te - WHERE 1=1 AND estado = 0 %s %s + WHERE 1=1 %s %s GROUP BY id_agente ORDER BY count DESC LIMIT 8', $tags_condition, @@ -5492,7 +5494,7 @@ function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWate // Sort the data. arsort($data); - if ($noWaterMark) { + if ($noWaterMark === true) { $water_mark = [ 'file' => $config['homedir'].'/images/logo_vertical_water.png', 'url' => ui_get_full_url('images/logo_vertical_water.png', false, false, false), diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 0179eb884d..54d0845a56 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -2612,8 +2612,8 @@ function tactical_groups_get_agents_and_monitoring($id_groups) // Link URLS $urls = []; - $urls['total_agents'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60'; - $urls['monitor_total'] = $config['homeurl'].'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=60&status=-1'; + $urls['total_agents'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_groups[0].'&recursion=1'; + $urls['monitor_total'] = $config['homeurl'].'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=60&status=-1&ag_group='.$id_groups[0].'&recursion=1'; $table_am = html_get_predefined_table(); $tdata = []; @@ -2662,8 +2662,8 @@ function tactical_groups_get_stats_alerts($id_groups) ]; $urls = []; - $urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60'; - $urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&disabled=fired'; + $urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&ag_group='.$id_groups[0]; + $urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&disabled=fired&ag_group='.$id_groups[0]; // Alerts table. $table_al = html_get_predefined_table(); @@ -2732,11 +2732,11 @@ function groups_get_stats_modules_status($id_groups, $graph_width=250, $graph_he // Link URLS. if ($links === false) { $urls = []; - $urls['monitor_critical'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_CRITICAL_BAD.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; - $urls['monitor_warning'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_WARNING.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; - $urls['monitor_ok'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NORMAL.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; - $urls['monitor_unknown'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_UNKNOWN.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; - $urls['monitor_not_init'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NOT_INIT.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_group; + $urls['monitor_critical'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_CRITICAL_BAD.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + $urls['monitor_warning'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_WARNING.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + $urls['monitor_ok'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NORMAL.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + $urls['monitor_unknown'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_UNKNOWN.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + $urls['monitor_not_init'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NOT_INIT.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; } else { $urls = []; $urls['monitor_critical'] = $links['monitor_critical']; diff --git a/pandora_console/include/lib/Group.php b/pandora_console/include/lib/Group.php index aa4e3c85d7..ce8c1a1b94 100644 --- a/pandora_console/include/lib/Group.php +++ b/pandora_console/include/lib/Group.php @@ -486,7 +486,7 @@ class Group extends Entity include_once $config['homedir'].'/include/functions_graph.php'; $out = '<div style="flex: 0 0 300px; width:99%; height:100%;">'; - $out .= graph_so_by_group($id_group); + $out .= graph_so_by_group($id_group, 300, 200, false, false); $out .= '<div>'; echo $out; return; @@ -500,7 +500,7 @@ class Group extends Entity include_once $config['homedir'].'/include/functions_graph.php'; $out = '<div style="flex: 0 0 300px; width:99%; height:100%;">'; - $out .= graph_events_agent_by_group($id_group, 300, 200, true, true); + $out .= graph_events_agent_by_group($id_group, 300, 200, false, true, true); $out .= '<div>'; echo $out; return; @@ -633,7 +633,8 @@ class Group extends Entity } $sql = sprintf( - 'SELECT alias, + 'SELECT id_agente, + alias, critical_count, warning_count, unknown_count, @@ -654,7 +655,9 @@ class Group extends Entity $data = db_get_all_rows_sql($sql); $sql = sprintf( - 'SELECT alias, + 'SELECT + id_agente, + alias, critical_count, warning_count, unknown_count, From cdf359481abf365b56d5a0666b4e060597b7249f Mon Sep 17 00:00:00 2001 From: Daniel Cebrian <daniel.cebrian@pandorafms.com> Date: Thu, 2 Mar 2023 17:06:16 +0100 Subject: [PATCH 05/24] #10347 cleared code for apply acl permission --- pandora_console/godmode/groups/tactical.php | 10 +--------- pandora_console/include/functions_graph.php | 9 +-------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 352da1bdcd..74c8158ad2 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -30,16 +30,8 @@ global $config; check_login(); -if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit( - AUDIT_LOG_ACL_VIOLATION, - 'Trying to access Group Management' - ); - include 'general/noaccess.php'; - return; -} -$id_group = get_parameter('id', ''); +$id_group = get_parameter('id_group', ''); if (empty($id_group) === true) { return; } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 4ccde63e98..d1cd1c2083 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5418,14 +5418,7 @@ function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWate define('NUM_PIECES_PIE_2', 6); // Add tags condition to filter. - $tags_condition = tags_get_acl_tags( - $config['id_user'], - 0, - 'ER', - 'event_condition', - 'AND' - ); - + $tags_condition = ''; if ($time_limit && $config['event_view_hr']) { $tags_condition .= ' AND utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')'; } From ccb0d69edd27648b82c759d154b73c4e07b565a1 Mon Sep 17 00:00:00 2001 From: Daniel Maya <daniel.maya@pandorafms.com> Date: Fri, 3 Mar 2023 09:15:51 +0100 Subject: [PATCH 06/24] #10518 Added new menu --- pandora_console/extensions/dbmanager.php | 5 ++--- pandora_console/include/ajax/alert_list.ajax.php | 1 - pandora_console/include/styles/pandora.css | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index ffcc2fdb72..3aacc776a0 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -301,12 +301,11 @@ function dbmgr_extension_main() if (is_metaconsole() === true) { // This adds a option in the operation menu. extensions_add_meta_menu_option( - 'DB interface', + __('DB interface'), 'PM', 'gextensions', 'database.png', - 'v1r1', - 'gdbman' + 'v1r1' ); extensions_add_meta_function('dbmgr_extension_main'); diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index 46792c7822..7d9e372d7e 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -639,7 +639,6 @@ if ($alert_validate === true) { } if ($get_agent_alerts_datatable === true) { - hd('holaaaaaaaaaaaaaa', true); // Datatables offset, limit and order. $filter_alert = get_parameter('filter', []); unset($filter_alert[0]); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 3f6b2ea450..ac67116004 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -640,6 +640,10 @@ select:-internal-list-box { width: 20%; } +.w21p { + width: 21%; +} + .w22p { width: 22%; } From 7562a9253af43ee731052c254d35b0012ad9de96 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian <daniel.cebrian@pandorafms.com> Date: Fri, 3 Mar 2023 13:13:49 +0100 Subject: [PATCH 07/24] #10347 refactoring and add link to events in graph --- pandora_console/godmode/groups/tactical.php | 31 ++++++- pandora_console/include/functions_graph.php | 24 +++++- pandora_console/include/functions_groups.php | 86 +++++++++++++------ .../include/javascript/tactical_groups.js | 2 +- pandora_console/include/lib/Group.php | 20 +++++ .../include/styles/tactical_groups.css | 3 + 6 files changed, 138 insertions(+), 28 deletions(-) diff --git a/pandora_console/godmode/groups/tactical.php b/pandora_console/godmode/groups/tactical.php index 74c8158ad2..037af05723 100644 --- a/pandora_console/godmode/groups/tactical.php +++ b/pandora_console/godmode/groups/tactical.php @@ -30,12 +30,32 @@ global $config; check_login(); +if (! check_acl($config['id_user'], 0, 'AR')) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access Tactical View Group' + ); + include 'general/noaccess.php'; + return; +} + + $id_group = get_parameter('id_group', ''); if (empty($id_group) === true) { return; } +$user_groups_acl = users_get_groups(false, 'AR'); +if (in_array(groups_get_name($id_group), $user_groups_acl) === false) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access Tactical View Group' + ); + include 'general/noaccess.php'; + return; +} + if (is_metaconsole() === false) { // Header. ui_print_standard_header( @@ -84,9 +104,9 @@ $table_col1->width = '100%'; $table_col1->data[0][0] = groups_get_heat_map_agents($id_groups, 450, 100); $table_col1->data[1][0] = tactical_groups_get_agents_and_monitoring($id_groups); -$distribution_by_so = '<table cellpadding=0 cellspacing=0 class="databox pies mrgn_top_15px" width=100%><tr><td style="width:50%;">'; +$distribution_by_so = '<table cellpadding=0 cellspacing=0 class="databox pies graph-distribution-so" width=100%><tr><td style="width:50%;">'; $distribution_by_so .= '<fieldset class="padding-0 databox tactical_set" id="distribution_by_so_graph">'; -$distribution_by_so .= '<legend>'.__('Distribution by so').'</legend>'; +$distribution_by_so .= '<legend>'.__('Distribution by os').'</legend>'; $distribution_by_so .= html_print_image('images/spinner.gif', true, ['id' => 'spinner_distribution_by_so_graph']); $distribution_by_so .= '</fieldset>'; $distribution_by_so .= '</td></tr></table>'; @@ -214,6 +234,13 @@ echo '<div id="modal-info-agent"></div>' success: function(data) { $("#spinner_events_by_agents_group_graph").hide(); $("#events_by_agents_group_graph").append(data); + const canvas = $('#events_by_agents_group_graph canvas')[0]; + canvas.addEventListener('click', function(event) { + var middle_canvas = $('#events_by_agents_group_graph canvas').width() / 2; + if(event.layerX < middle_canvas){ + window.location.replace("index.php?sec=eventos&sec2=operation/events/events&filter[id_group_filter]=<?php echo $id_group; ?>") + } + }); } }); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index d1cd1c2083..977076824b 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5341,6 +5341,16 @@ function get_baseline_data( } +/** + * Draw graph SO agents by group. + * + * @param [type] $id_group + * @param integer $width + * @param integer $height + * @param boolean $recursive + * @param boolean $noWaterMark + * @return string Graph + */ function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true, $noWaterMark=true) { global $config; @@ -5408,6 +5418,17 @@ function graph_so_by_group($id_group, $width=300, $height=200, $recursive=true, } +/** + * Draw graph events by group + * + * @param [type] $id_group + * @param integer $width + * @param integer $height + * @param boolean $noWaterMark + * @param boolean $time_limit + * @param boolean $recursive + * @return string Graph + */ function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWaterMark=true, $time_limit=false, $recursive=true) { global $config; @@ -5443,7 +5464,8 @@ function graph_events_agent_by_group($id_group, $width=300, $height=200, $noWate 'SELECT DISTINCT(id_agente) AS id_agente, COUNT(id_agente) AS count FROM tevento te - WHERE 1=1 %s %s + WHERE 1=1 AND estado = 0 + %s %s GROUP BY id_agente ORDER BY count DESC LIMIT 8', $tags_condition, diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 54d0845a56..1800f09652 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1642,7 +1642,7 @@ function groups_monitor_fired_alerts($group_array) } -function groups_monitor_alerts_total_counters($group_array) +function groups_monitor_alerts_total_counters($group_array, $secondary_group=true) { // If there are not groups to query, we jump to nextone $default_total = [ @@ -1656,26 +1656,32 @@ function groups_monitor_alerts_total_counters($group_array) } $group_clause = implode(',', $group_array); - $group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))"; + if ($secondary_group === true) { + $group_clause = "(tasg.id_group IN ($group_clause) OR ta.id_grupo IN ($group_clause))"; + } else { + $group_clause = "(ta.id_grupo IN ($group_clause))"; + } - $alerts = db_get_row_sql( - "SELECT - COUNT(tatm.id) AS total, - SUM(IF(tatm.times_fired > 0, 1, 0)) AS fired - FROM talert_template_modules tatm - INNER JOIN tagente_modulo tam - ON tatm.id_agent_module = tam.id_agente_modulo - INNER JOIN tagente ta - ON ta.id_agente = tam.id_agente - WHERE ta.id_agente IN ( - SELECT ta.id_agente - FROM tagente ta - LEFT JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE ta.disabled = 0 - AND $group_clause - ) AND tam.disabled = 0" - ); + $sql = 'SELECT + COUNT(tatm.id) AS total, + SUM(IF(tatm.times_fired > 0, 1, 0)) AS fired + FROM talert_template_modules tatm + INNER JOIN tagente_modulo tam + ON tatm.id_agent_module = tam.id_agente_modulo + INNER JOIN tagente ta + ON ta.id_agente = tam.id_agente + WHERE ta.id_agente IN ( + SELECT ta.id_agente + FROM tagente ta'; + if ($secondary_group === true) { + $sql .= ' LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent'; + } + + $sql .= " WHERE ta.disabled = 0 + AND $group_clause + ) AND tam.disabled = 0"; + + $alerts = db_get_row_sql($sql); return ($alerts === false) ? $default_total : $alerts; } @@ -2453,6 +2459,15 @@ function groups_get_group_deep($id_group) } +/** + * Heat map from agents by group + * + * @param array $id_group + * @param integer $width + * @param integer $height + * + * @return string Html Graph. + */ function groups_get_heat_map_agents(array $id_group, float $width=0, float $height=0) { ui_require_css_file('heatmap'); @@ -2568,14 +2583,14 @@ function groups_get_heat_map_agents(array $id_group, float $width=0, float $heig ?> <script type="text/javascript"> $(document).ready(function() { - const total_modules = '<?php echo $total_agents; ?>'; + const total_agents = '<?php echo $total_agents; ?>'; function getRandomInteger(min, max) { return Math.floor(Math.random() * max) + min; } function oneSquare(solid, time) { - var randomPoint = getRandomInteger(1, total_modules); + var randomPoint = getRandomInteger(1, total_agents); let target = $(`#rect_${randomPoint}`); let class_name = target.attr('class'); class_name = class_name.split('_')[0]; @@ -2587,7 +2602,7 @@ function groups_get_heat_map_agents(array $id_group, float $width=0, float $heig } let cont = 0; - while (cont < Math.ceil(total_modules / 3)) { + while (cont < Math.ceil(total_agents / 3)) { oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900)); cont ++; } @@ -2601,6 +2616,13 @@ function groups_get_heat_map_agents(array $id_group, float $width=0, float $heig } +/** + * Return html count from agents and monitoring by group. + * + * @param [type] $id_groups + * + * @return string Html + */ function tactical_groups_get_agents_and_monitoring($id_groups) { global $config; @@ -2650,11 +2672,17 @@ function tactical_groups_get_agents_and_monitoring($id_groups) } +/** + * Return html count from stats alerts by group. + * + * @param [type] $id_groups + * @return string Html. + */ function tactical_groups_get_stats_alerts($id_groups) { global $config; - $alerts = groups_monitor_alerts_total_counters($id_groups); + $alerts = groups_monitor_alerts_total_counters($id_groups, false); $data = [ 'monitor_alerts' => $alerts['total'], 'monitor_alerts_fired' => $alerts['fired'], @@ -2717,6 +2745,16 @@ function tactical_groups_get_stats_alerts($id_groups) } +/** + * Return html count from stats modules by group. + * + * @param [type] $id_groups + * @param integer $graph_width + * @param integer $graph_height + * @param boolean $links + * @param boolean $data_agents + * @return void + */ function groups_get_stats_modules_status($id_groups, $graph_width=250, $graph_height=150, $links=false, $data_agents=false) { global $config; diff --git a/pandora_console/include/javascript/tactical_groups.js b/pandora_console/include/javascript/tactical_groups.js index 41a85794a7..08bca2f02e 100644 --- a/pandora_console/include/javascript/tactical_groups.js +++ b/pandora_console/include/javascript/tactical_groups.js @@ -1,4 +1,4 @@ -/* global $ */ +/* global $, load_modal */ function showInfoAgent(id_agent) { load_modal({ target: $("#modal-info-agent"), diff --git a/pandora_console/include/lib/Group.php b/pandora_console/include/lib/Group.php index ce8c1a1b94..9e386d8dd0 100644 --- a/pandora_console/include/lib/Group.php +++ b/pandora_console/include/lib/Group.php @@ -479,6 +479,11 @@ class Group extends Entity } + /** + * Draw a graph distribution so by group. + * + * @return void + */ public static function distributionBySoGraph() { global $config; @@ -493,6 +498,11 @@ class Group extends Entity } + /** + * Draw a graph events agent by group. + * + * @return void + */ public static function groupEventsByAgent() { global $config; @@ -507,6 +517,11 @@ class Group extends Entity } + /** + * Draw in modal a agent info + * + * @return void + */ public static function loadInfoAgent() { $extradata = get_parameter('extradata', ''); @@ -577,6 +592,11 @@ class Group extends Entity } + /** + * Get agents by group for datatable. + * + * @return void + */ public static function getAgentsByGroup() { global $config; diff --git a/pandora_console/include/styles/tactical_groups.css b/pandora_console/include/styles/tactical_groups.css index eb710851c0..383e9ef37f 100644 --- a/pandora_console/include/styles/tactical_groups.css +++ b/pandora_console/include/styles/tactical_groups.css @@ -26,3 +26,6 @@ rect { #list_agents_tactical_wrapper { max-height: 600px; } +.graph-distribution-so { + margin-top: 55px; +} From 00b5d3f2377909cb47a3cd0618854b4360302ce4 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian <daniel.cebrian@pandorafms.com> Date: Fri, 3 Mar 2023 13:24:33 +0100 Subject: [PATCH 08/24] #1347 added links tactical view group --- pandora_console/godmode/groups/group_list.php | 7 ++++--- pandora_console/operation/agentes/estado_generalagente.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 196d6024d6..37c1c46f9b 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -875,7 +875,8 @@ if ($tab == 'tree') { $table->data = []; foreach ($groups as $key => $group) { - $url = 'index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo']; + $url_edit = 'index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo']; + $url_tactical = 'index.php?sec=gagente&sec2=godmode/groups/tactical&id_group='.$group['id_grupo']; if (is_metaconsole()) { $url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo'].'&tab=groups'; } else { @@ -884,7 +885,7 @@ if ($tab == 'tree') { $table->data[$key][0] = $group['id_grupo']; if ($is_management_allowed === true) { - $table->data[$key][1] = '<a href="'.$url.'">'.$group['nombre'].'</a>'; + $table->data[$key][1] = '<a href="'.$url_tactical.'">'.$group['nombre'].'</a>'; } else { $table->data[$key][1] = $group['nombre']; } @@ -915,7 +916,7 @@ if ($tab == 'tree') { $table->data[$key][5] = $group['description']; if ($is_management_allowed === true) { $table->cellclass[$key][6] = 'action_buttons'; - $table->data[$key][6] = '<a href="'.$url.'">'.html_print_image( + $table->data[$key][6] = '<a href="'.$url_edit.'">'.html_print_image( 'images/config.png', true, [ diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index a0bd1bca8f..6df4bcd9d2 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -401,7 +401,7 @@ $table_contact->data[] = $data; $data = []; $data[0] = '<b>'.__('Group').'</b>'; -$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$agent['id_grupo'].'">'.groups_get_name($agent['id_grupo']).'</a>'; +$data[1] = '<a href="index.php?sec=gagente&sec2=godmode/groups/tactical&id_group='.$agent['id_grupo'].'">'.groups_get_name($agent['id_grupo']).'</a>'; $table_contact->data[] = $data; $data = []; From 1f45ee33b276eb1173ae3c864cb7dac5a3954b75 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 11:14:10 +0100 Subject: [PATCH 09/24] Header icon --- pandora_console/include/functions_ui.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 1e4556965b..dbaf0fee37 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1496,6 +1496,7 @@ function ui_print_alert_template_example($id_alert_template, $return=false, $pri * @param string $image Image path. * @param boolean $is_relative Route is relative or not. * @param string $id Target id. + * @param string $isHeader If true, the view is header. * * @return string The help tip */ @@ -1505,10 +1506,17 @@ function ui_print_help_icon( $home_url='', $image='images/info@svg.svg', $is_relative=false, - $id='' + $id='', + $isHeader=false ) { global $config; + if (empty($image) === true) { + $image = 'images/info@svg.svg'; + } + + $iconClass = ($isHeader === true) ? 'header_help_icon' : 'main_menu_icon'; + // Do not display the help icon if help is disabled. if ((bool) $config['disable_help'] === true) { return ''; @@ -1533,7 +1541,7 @@ function ui_print_help_icon( $image, true, [ - 'class' => 'img_help main_menu_icon', + 'class' => 'img_help '.$iconClass, 'title' => __('Help'), 'onclick' => "open_help ('".ui_get_full_url($help_handler)."')", 'id' => $id, @@ -5053,7 +5061,7 @@ function ui_print_page_header( if (is_metaconsole() === false) { if ($help != '') { - $buffer .= "<div class='head_help head_tip'>".ui_print_help_icon($help, true, '', 'images/help_g.png').'</div>'; + $buffer .= "<div class='head_help head_tip'>".ui_print_help_icon($help, true, '', '', false, '', true).'</div>'; } } From b68fe38102c312c2996b860cb7d0bbc6f351c91b Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 11:15:01 +0100 Subject: [PATCH 10/24] Controls improve --- pandora_console/include/styles/pandora.css | 22 ++++++++++++++++++++-- pandora_console/include/styles/wizard.css | 6 ++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index f837170673..eec5727f49 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -11006,14 +11006,14 @@ pre.external_tools_output { .tag-editor .tag-editor-tag { padding: 5px !important; color: #fff !important; - background: #82b92e !important; + background: var(--primary-color) !important; border-radius: 0 2px 2px 0 !important; } .tag-editor .tag-editor-delete { padding: 5px !important; line-height: 16px !important; - background: #82b92e !important; + background: var(--primary-color) !important; border-radius: 2px 0 0 2px !important; } @@ -11187,6 +11187,10 @@ table.table_modal_alternate height: 20px; } +.header_help_icon { + width: 16px; + height: 16px; +} .main_menu_icon.arrow_up { transform: rotate(90deg); } @@ -11536,3 +11540,17 @@ table.alert-template-fields > tbody > tr > td > div > textarea { table.alert-template-fields > tbody > tr > td[id^="template-label_fields"] { text-align: center; } + +ul.tag-editor { + list-style-type: none; + padding: 0.5em !important; + margin: 0; + overflow: hidden; + border: 2px solid #c0ccdc; + border-radius: 6px; + cursor: text; + font: normal 14px sans-serif; + color: #333333; + background: #f6f7fb; + line-height: 20px; +} diff --git a/pandora_console/include/styles/wizard.css b/pandora_console/include/styles/wizard.css index ab5d011f70..fa91c6f2b9 100644 --- a/pandora_console/include/styles/wizard.css +++ b/pandora_console/include/styles/wizard.css @@ -130,6 +130,12 @@ ul.wizard li > textarea { background: #e63c52; } +.wizard .tag-editor li, +.wizard .tag-editor li:focus, +.wizard .tag-editor li:hover { + border: 0; + padding: 0; +} .wizard .time_selection_container { display: flex; align-items: baseline; From 70cf44cb8f1fa32ff5230c91dd28a2d594d2f8c0 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 11:15:58 +0100 Subject: [PATCH 11/24] Module Templates --- .../include/class/ModuleTemplates.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/class/ModuleTemplates.class.php b/pandora_console/include/class/ModuleTemplates.class.php index fb1a496246..75e4bf7ade 100644 --- a/pandora_console/include/class/ModuleTemplates.class.php +++ b/pandora_console/include/class/ModuleTemplates.class.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas * Please see http://pandorafms.org for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -708,7 +708,7 @@ class ModuleTemplates extends HTML 'action' => $this->baseUrl, 'id' => 'add_module_form', 'method' => 'POST', - 'class' => 'modal', + 'class' => 'modal filter-list-adv', 'extra' => '', ]; @@ -846,10 +846,10 @@ class ModuleTemplates extends HTML false ); // Create the table with Module Block list. - $table = new StdClasS(); + $table = new stdClass(); $table->class = 'databox data '; $table->width = '75%'; - $table->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;'; + $table->styleTable = 'border: 1px solid #ddd;'; $table->rowid = []; $table->data = []; @@ -1165,7 +1165,7 @@ class ModuleTemplates extends HTML $blockComponentList = chop($blockComponentList, ','); // Title of Block. - $blockTitle = '<div class="pdd_t_8px">'; + $blockTitle = '<div class="subsection_header_title">'; $blockTitle .= $blockTable['name']; $blockTitle .= '<div class="white_table_header_checkbox">'; $blockTitle .= html_print_input_image( @@ -1186,7 +1186,7 @@ class ModuleTemplates extends HTML $table = new StdClasS(); $table->class = 'databox data border_bt'; $table->width = '75%'; - $table->styleTable = 'margin: 2em auto 0;border: 1px solid #ddd;'; + $table->styleTable = 'margin: 0; border: 1px solid #ddd;'; $table->rowid = []; $table->data = []; @@ -1220,7 +1220,7 @@ class ModuleTemplates extends HTML switch ($module['id_format']) { case MODULE_NETWORK: $formatInfo = html_print_image( - 'images/network.png', + 'images/network-server@os.svg', true, [ 'title' => __('Network module'), @@ -1231,7 +1231,7 @@ class ModuleTemplates extends HTML case MODULE_WMI: $formatInfo = html_print_image( - 'images/wmi.png', + 'images/WMI@svg.svg', true, [ 'title' => __('WMI module'), @@ -1242,7 +1242,7 @@ class ModuleTemplates extends HTML case MODULE_PLUGIN: $formatInfo = html_print_image( - 'images/plugin.png', + 'images/plugins@svg.svg', true, [ 'title' => __('Plug-in module'), From d6a461acb8a25d5cc85928d9632dd27ad0fa3590 Mon Sep 17 00:00:00 2001 From: Jonathan <jonathan.leon@pandorafms.com> Date: Tue, 7 Mar 2023 11:21:25 +0100 Subject: [PATCH 12/24] Graph container create styles --- .../godmode/reporting/create_container.php | 257 ++++++++++-------- .../godmode/reporting/graph_container.php | 21 +- .../include/functions_container.php | 4 +- 3 files changed, 166 insertions(+), 116 deletions(-) diff --git a/pandora_console/godmode/reporting/create_container.php b/pandora_console/godmode/reporting/create_container.php index 26231fc107..a1361867b4 100644 --- a/pandora_console/godmode/reporting/create_container.php +++ b/pandora_console/godmode/reporting/create_container.php @@ -496,7 +496,7 @@ if ($edit_container) { $single_table .= "<td id='row_type_graphs' width='30%'>"; $single_table .= html_print_label_input_block( __('Type of graph'), - html_print_select($type_graphs, 'simple_type_graph', '', '', '', 0, true) + html_print_select($type_graphs, 'simple_type_graph2', '', '', '', 0, true, false, true, '', false, 'width:100%') ); $single_table .= '</td>'; @@ -543,21 +543,22 @@ if ($edit_container) { $table->width = '100%'; $table->cellspacing = 4; $table->cellpadding = 4; - $table->class = 'dat'; + $table->class = 'filter-table-adv'; $table->styleTable = 'font-weight: bold;'; $table->style[0] = 'width: 13%'; $table->data = []; + $table->size[0] = '30%'; + $table->size[1] = '30%'; + $table->size[2] = '30%'; - $data = []; - $data[0] = __('Time lapse'); - $data[0] .= ui_print_help_tip(__('This is the interval or period of time with which the graph data will be obtained. For example, a week means data from a week ago from now. '), true); - $data[1] = html_print_extended_select_for_time('period_custom', $period, '', '', '0', 10, true, false, true, '', false, $periods); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Custom graph'); + $table->data[0][0] = html_print_label_input_block( + __('Time lapse').ui_print_help_tip( + __('This is the interval or period of time with which the graph data will be obtained. For example, a week means data from a week ago from now. '), + true + ), + html_print_extended_select_for_time('period_custom', $period, '', '', '0', 10, true, 'width:100%', true, '', false, $periods) + ); $list_custom_graphs = custom_graphs_get_user($config['id_user'], false, true, 'RR'); @@ -566,29 +567,45 @@ if ($edit_container) { $graphs[$custom_graph['id_graph']] = $custom_graph['name']; } - $data[1] = html_print_select($graphs, 'id_custom_graph', $idCustomGraph, '', __('None'), 0, true); - $table->data[] = $data; - $table->rowclass[] = ''; + $table->data[0][1] = html_print_label_input_block( + __('Custom graph'), + html_print_select($graphs, 'id_custom_graph', $idCustomGraph, '', __('None'), 0, true, '', true, '', false, 'width:100%') + ); - $data = []; - $data[0] = __('Show full scale graph (TIP)').ui_print_help_tip('This option may cause performance issues', true); - $data[1] = html_print_checkbox('fullscale_2', 1, false, true); - $table->data[] = $data; - $table->rowclass[] = ''; + $table->data[0][2] = html_print_label_input_block( + __('Show full scale graph (TIP)').ui_print_help_tip('This option may cause performance issues', true), + html_print_checkbox('fullscale_2', 1, false, true) + ); - $data = []; - $data[0] = ''; - $data[1] = "<input style='float:right;' type=submit name='add_custom' class='sub add' value='".__('Add item')."'>"; - $table->data[] = $data; - $table->rowclass[] = ''; + $data_toggle = html_print_table($table, true); + $data_toggle .= html_print_div( + [ + 'class' => 'action-buttons-right-forced mrgn_right_10px', + 'content' => html_print_submit_button( + __('Add item'), + 'add_custom', + false, + [ + 'mode' => 'mini', + 'icon' => 'next', + ], + true + ), + ], + true + ); - echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>"; - echo '<tr>'; - echo '<td>'; - echo ui_toggle(html_print_table($table, true), 'Custom graph', '', '', true); - echo '</td>'; - echo '</tr>'; - echo '</table>'; + ui_toggle( + $data_toggle, + '<span class="subsection_header_title">'.__('Custom graph').'</span>', + 'container', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph' + ); unset($table); @@ -597,93 +614,113 @@ if ($edit_container) { $table->width = '100%'; $table->cellspacing = 4; $table->cellpadding = 4; - $table->class = 'dat'; + $table->class = 'filter-table-adv'; $table->styleTable = 'font-weight: bold;'; - $table->style[0] = 'width: 13%'; $table->data = []; + $table->size[0] = '30%'; + $table->size[1] = '30%'; + $table->size[2] = '30%'; - $data = []; - $data[0] = __('Time lapse'); - $data[0] .= ui_print_help_tip(__('This is the interval or period of time with which the graph data will be obtained. For example, a week means data from a week ago from now. '), true); - $data[1] = html_print_extended_select_for_time('period_dynamic', $period, '', '', '0', 10, true, false, true, '', false, $periods); - $table->data[] = $data; - $table->rowclass[] = ''; - $data = []; - $data[0] = __('Group'); - $data[1] = '<div class="w250px">'.html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'container_id_group', $id_group, '', '', '', true).'</div>'; - $table->data[] = $data; - $table->rowclass[] = ''; + $table->data[0][0] = html_print_label_input_block( + __('Time lapse').ui_print_help_tip( + __('This is the interval or period of time with which the graph data will be obtained. For example, a week means data from a week ago from now. '), + true + ), + html_print_extended_select_for_time('period_custom', $period, '', '', '0', 10, true, 'width:100%', true, '', false, $periods) + ); - $data = []; - $data[0] = __('Module group'); - $data[1] = html_print_select_from_sql( - 'SELECT * FROM tmodule_group ORDER BY name', - 'combo_modulegroup', - $modulegroup, - '', - __('All'), - false, + $table->data[0][1] = html_print_label_input_block( + __('Group'), + html_print_select_groups($config['id_user'], 'RW', $return_all_groups, 'container_id_group', $id_group, '', '', '', true) + ); + + $table->data[0][2] = html_print_label_input_block( + __('Module group'), + html_print_select_from_sql( + 'SELECT * FROM tmodule_group ORDER BY name', + 'combo_modulegroup', + $modulegroup, + '', + __('All'), + false, + true, + false, + true, + false, + 'width:100%' + ) + ); + + $table->data[1][0] = html_print_label_input_block( + __('Agent'), + html_print_input_text('text_agent', $textAgent, '', 30, 100, true) + ); + + $table->data[1][1] = html_print_label_input_block( + __('Module'), + html_print_input_text('text_agent_module', $textModule, '', 30, 100, true) + ); + + $select_tags = tags_search_tag(false, false, true); + $table->data[1][2] = html_print_label_input_block( + __('Tag'), + html_print_select( + $select_tags, + 'tag', + $tag, + '', + __('Any'), + 0, + true, + false, + false, + '', + false, + 'width:100%' + ) + ); + + $table->data[2][0] = html_print_label_input_block( + __('Type of graph'), + html_print_select($type_graphs, 'simple_type_graph2', '', '', '', 0, true, false, true, '', false, 'width:100%') + ); + + $table->data[2][1] = html_print_label_input_block( + __('Show full scale graph (TIP)').ui_print_help_tip('This option may cause performance issues', true), + html_print_checkbox('fullscale_3', 1, false, true) + ); + + $data_toggle = html_print_table($table, true); + $data_toggle .= html_print_div( + [ + 'class' => 'action-buttons-right-forced mrgn_right_10px', + 'content' => html_print_submit_button( + __('Add item'), + 'add_dynamic', + false, + [ + 'mode' => 'mini', + 'icon' => 'next', + ], + true + ), + ], true ); - $table->data[] = $data; - $table->rowclass[] = ''; - $data = []; - $data[0] = __('Agent'); - $data[1] = html_print_input_text('text_agent', $textAgent, '', 30, 100, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Module'); - $data[1] = html_print_input_text('text_agent_module', $textModule, '', 30, 100, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Tag'); - $select_tags = tags_search_tag(false, false, true); - $data[1] = html_print_select( - $select_tags, - 'tag', - $tag, + ui_toggle( + $data_toggle, + '<span class="subsection_header_title">'.__('Dynamic rules for simple module graph').'</span>', + 'container', '', - __('Any'), - 0, true, false, - false + '', + 'white-box-content', + 'box-flat white_table_graph' ); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Type of graph'); - $data[1] = html_print_select($type_graphs, 'simple_type_graph2', '', '', '', 0, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = __('Show full scale graph (TIP)').ui_print_help_tip('This option may cause performance issues', true); - $data[1] = html_print_checkbox('fullscale_3', 1, false, true); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $data[0] = ''; - $data[1] = "<input style='float:right;' type=submit name='add_dynamic' class='sub add' value='".__('Add item')."'>"; - $table->data[] = $data; - $table->rowclass[] = ''; - - echo "<table width='100%' cellpadding=4 cellspacing=4 class='databox filters'>"; - echo '<tr>'; - echo '<td>'; - echo ui_toggle(html_print_table($table, true), 'Dynamic rules for simple module graph', '', '', true); - echo '</td>'; - echo '</tr>'; - echo '</table>'; if ((bool) $id_container !== false) { $total_item = db_get_all_rows_sql('SELECT count(*) FROM tcontainer_item WHERE id_container = '.$id_container); @@ -696,7 +733,7 @@ if ($edit_container) { ui_pagination($total_item[0]['count(*)'], false, $offset, 10); $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox data'; + $table->class = 'info_table'; $table->id = 'item_table'; $table->align = []; $table->head = []; @@ -710,7 +747,7 @@ if ($edit_container) { $table->head[7] = __('Delete'); $table->data = []; - + $i = 0; foreach ($result_item as $item) { $data = []; @@ -759,6 +796,8 @@ if ($edit_container) { break; } + $table->cellclass[$i][7] = 'table_action_buttons'; + $i++; $data[7] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/create_container&edit_container=1&delete_item=1&id_item='.$item['id_ci'].'&id='.$id_container.'" onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/delete.svg', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'class' => 'invert_filter main_menu_icon']).'</a>'; @@ -801,7 +840,7 @@ echo html_print_input_hidden('id_agent', 0); } }); - $("input[name=add_custom]").click (function () { + $("#button-add_custom").click (function () { var id_custom = $("#id_custom_graph").val(); var fullscale = $("#checkbox-fullscale_2").prop("checked"); if (id_custom !== '0'){ @@ -824,7 +863,7 @@ echo html_print_input_hidden('id_agent', 0); } }); - $("input[name=add_dynamic]").click (function () { + $("#button-add_dynamic").click (function () { var agent_alias = $("#text-text_agent").val(); var module_name = $("#text-text_agent_module").val(); var time_lapse = $("#hidden-period_dynamic").attr('value'); diff --git a/pandora_console/godmode/reporting/graph_container.php b/pandora_console/godmode/reporting/graph_container.php index cbc947ef78..370285d7bf 100644 --- a/pandora_console/godmode/reporting/graph_container.php +++ b/pandora_console/godmode/reporting/graph_container.php @@ -129,11 +129,22 @@ $container = folder_get_folders(); $tree = folder_get_folders_tree_recursive($container); echo folder_togge_tree_folders($tree); if ($report_r && $report_w) { - echo "<div class='right'>"; - echo '<form method="post" class="right" action="index.php?sec=reporting&sec2=godmode/reporting/create_container">'; - html_print_submit_button(__('Create container'), 'create', false, 'class="sub next mrgn_right_5px mrgn_top_15px"'); - echo '</form>'; - echo '</div>'; + $ActionButtons[] = '<form method="post" class="right" action="index.php?sec=reporting&sec2=godmode/reporting/create_container">'; + $ActionButtons[] = '<div class="action-buttons">'; + $ActionButtons[] = html_print_submit_button( + __('Create container'), + 'create', + false, + [ + 'class' => 'sub ok submitButton', + 'icon' => 'next', + ], + true + ); + $ActionButtons[] = '</div>'; + $ActionButtons[] = '</form>'; + + html_print_action_buttons(implode('', $ActionButtons), ['type' => 'form_action']); } ?> diff --git a/pandora_console/include/functions_container.php b/pandora_console/include/functions_container.php index 502db2b4ad..e9d034f431 100644 --- a/pandora_console/include/functions_container.php +++ b/pandora_console/include/functions_container.php @@ -316,13 +316,13 @@ function ui_toggle_container($code, $name, $title='', $hidden_default=true, $ret $data[0] = '<a href="javascript:" id="tgl_ctrl_'.$uniqid.'">'.html_print_image($original, true, ['title' => $title, 'id' => 'image_'.$uniqid, 'class' => 'invert_filter']).' <b>'.$name.'</b></a>'; $data[1] = ui_print_group_icon($group, true); if ($report_r && $report_w) { - $data[2] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/create_container&edit_container=1&id='.$id_container.'">'.html_print_image('images/config.png', true, ['class' => 'invert_filter']).'</a>'; + $data[2] = '<a href="index.php?sec=reporting&sec2=godmode/reporting/create_container&edit_container=1&id='.$id_container.'">'.html_print_image('images/edit.svg', true, ['class' => 'invert_filter main_menu_icon']).'</a>'; } if ($report_r && $report_w && $report_m) { if ($id_container !== '1') { $data[2] .= '  '.'<a href="index.php?sec=reporting&sec2=godmode/reporting/graph_container&delete_container=1&id='.$id_container.'" onClick="if (!confirm(\''.__('Are you sure?').'\')) - return false;">'.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'class' => 'invert_filter']).'</a>'; + return false;">'.html_print_image('images/delete.svg', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'class' => 'invert_filter main_menu_icon']).'</a>'; } } From 8f2a2f12c67936793f06dff247dc807610794d5a Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 11:48:14 +0100 Subject: [PATCH 13/24] Templates view --- .../modules/manage_network_components.php | 126 ++++++++++-------- .../include/class/ModuleTemplates.class.php | 4 +- pandora_console/include/functions_ui.php | 6 +- 3 files changed, 75 insertions(+), 61 deletions(-) diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 44d35d3f06..a3050f02e9 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -615,18 +615,6 @@ $url = ui_get_url_refresh( true, false ); -$name_url = 'index.php?sec=templates&sec2=godmode/modules/manage_network_components'; -$table = new stdClass(); -$table->width = '100%'; -$table->class = 'databox filters'; - -$table->style = []; -$table->style[0] = 'font-weight: bold'; -$table->style[2] = 'font-weight: bold'; - -$table->data = []; - -$table->data[0][0] = __('Group'); $component_groups = network_components_get_groups(); @@ -656,54 +644,81 @@ foreach ($component_groups as $component_group_key => $component_group_val) { } } -$table->data[0][1] = html_print_select( - $component_groups, - 'search_id_group', - $search_id_group, +$name_url = 'index.php?sec=templates&sec2=godmode/modules/manage_network_components'; +$table = new stdClass(); +$table->width = '100%'; +$table->class = 'filter-table-adv'; + +$table->style = []; +$table->style[0] = 'font-weight: bold'; +$table->style[2] = 'font-weight: bold'; + +$table->data = []; + +$table->data[0][] = html_print_label_input_block( + __('Group'), + html_print_select( + $component_groups, + 'search_id_group', + $search_id_group, + '', + __('All'), + 0, + true, + false, + false, + '', + false, + 'width: 100%' + ) +); + +$table->data[0][] = html_print_label_input_block( + __('Free Search'), + html_print_input_text( + 'search_string', + $search_string, + '', + 25, + 255, + true + ).ui_print_input_placeholder( + __('Search by name, description, tcp send or tcp rcv, list matches.'), + true + ) +); + +$toggleFilters = '<form class="filters_form" method="POST" action="'.$url.'">'; +$toggleFilters .= html_print_table($table, true); +$toggleFilters .= html_print_div( + [ + 'class' => 'action-buttons-right-forced', + 'content' => html_print_submit_button( + __('Filter'), + 'search', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + true +); +$toggleFilters .= '</form>'; + +ui_toggle( + $toggleFilters, + '<span class="subsection_header_title">'.__('Filters').'</span>', + 'filter_form', '', - __('All'), - 0, true, false, - false -); -$table->data[0][2] = __('Free Search').ui_print_help_tip( - __('Search by name, description, tcp send or tcp rcv, list matches.'), - true -); -$table->data[0][3] = html_print_input_text( - 'search_string', - $search_string, '', - 25, - 255, - true + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' ); -if (is_metaconsole() === true) { - $table->data[0][4] = '<div>'; -} else { - $table->data[0][4] = '<div class="action-buttons">'; -} - -$table->data[0][4] .= html_print_submit_button( - __('Search'), - 'search', - false, - 'class="sub search"', - true -); -$table->data[0][4] .= '</div>'; - -if (is_metaconsole() === true) { - $filter = '<form class="filters_form" method="post" action="'.$url.'">'; - $filter .= html_print_table($table, true); - $filter .= '</form>'; - ui_toggle($filter, __('Show Options')); -} else { - echo '<form method="post" action="'.$url.'">'; - html_print_table($table); - echo '</form>'; -} $filter = []; if ($search_id_group) { @@ -721,7 +736,6 @@ $total_components = network_components_get_network_components( ); $total_components = $total_components[0]['total']; $offset_delete = ($offset >= ($total_components - 1)) ? ($offset - $config['block_size']) : $offset; -ui_pagination($total_components, $name_url); $filter['offset'] = (int) get_parameter('offset'); $filter['limit'] = (int) $config['block_size']; $components = network_components_get_network_components( diff --git a/pandora_console/include/class/ModuleTemplates.class.php b/pandora_console/include/class/ModuleTemplates.class.php index 75e4bf7ade..e9a03a90b9 100644 --- a/pandora_console/include/class/ModuleTemplates.class.php +++ b/pandora_console/include/class/ModuleTemplates.class.php @@ -893,7 +893,7 @@ class ModuleTemplates extends HTML ); $data[3] .= html_print_input_image( 'export_profile', - 'images/csv.png', + 'images/file-csv.svg', $row['id_np'], '', true, @@ -914,7 +914,7 @@ class ModuleTemplates extends HTML $data[3] .= '</a>'; $data[3] .= '<a href="'.$this->baseUrl.'&action=export&id_np='.$row['id_np'].'" onclick="blockResubmit($(this))">'; $data[3] .= html_print_image( - 'images/csv.png', + 'images/file-csv.svg', true, [ 'title' => __('Export to CSV'), diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index dbaf0fee37..41091302fd 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -904,11 +904,11 @@ function ui_print_type_agent_icon( if ((int) $id_os === SATELLITE_OS_ID) { // Satellite. $options['title'] = __('Satellite'); - $output = html_print_image('images/satellite@svg.svg', true, ['class' => 'main_menu_icon invert_filter'], false, false, false, true); + $output = html_print_image('images/satellite@os.svg', true, ['class' => 'main_menu_icon invert_filter'], false, false, false, true); } else if ($remote_contact === $contact && $remote === 0 && empty($version) === true) { // Network. $options['title'] = __('Network'); - $output = html_print_image('images/network-server@svg.svg', true, ['class' => 'main_menu_icon invert_filter'], false, false, false, true); + $output = html_print_image('images/network-server@os.svg', true, ['class' => 'main_menu_icon invert_filter'], false, false, false, true); } else { // Software. $options['title'] = __('Software'); @@ -7162,7 +7162,7 @@ function ui_print_servertype_icon(int $id) case MODULE_NETWORK: $title = __('Network server'); - $image = 'images/network-server@svg.svg'; + $image = 'images/network-server@os.svg'; break; case MODULE_PLUGIN: From c3a297e0963403b6ba4a0ae63ee5f7b67bcd6045 Mon Sep 17 00:00:00 2001 From: daniel <daniel.barbero@artica.es> Date: Tue, 7 Mar 2023 12:18:51 +0100 Subject: [PATCH 14/24] fixed styles --- pandora_console/include/class/NetworkMap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/class/NetworkMap.class.php b/pandora_console/include/class/NetworkMap.class.php index b1c5e84763..701eb4ecfb 100644 --- a/pandora_console/include/class/NetworkMap.class.php +++ b/pandora_console/include/class/NetworkMap.class.php @@ -3601,7 +3601,7 @@ class NetworkMap url_background_grid: url_background_grid, refresh_time: '.$this->mapOptions['refresh_time'].', font_size: '.$this->mapOptions['font_size'].', - method: '.$this->map['generation_method'].', + method: '.($this->map['generation_method'] ?? 3).', base_url_homedir: "'.ui_get_full_url(false).'" }); init_drag_and_drop(); From 28a003706bc668b8bb1f6fd9e60afbd5f4a3e982 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 12:50:09 +0100 Subject: [PATCH 15/24] Action messages in modals --- .../include/class/CredentialStore.class.php | 40 +++------------ .../include/class/ModuleTemplates.class.php | 26 ++-------- .../include/class/SatelliteAgent.class.php | 51 +++++++------------ .../class/SatelliteCollection.class.php | 26 ++-------- 4 files changed, 36 insertions(+), 107 deletions(-) diff --git a/pandora_console/include/class/CredentialStore.class.php b/pandora_console/include/class/CredentialStore.class.php index 8bdc200299..befc213a8c 100644 --- a/pandora_console/include/class/CredentialStore.class.php +++ b/pandora_console/include/class/CredentialStore.class.php @@ -103,42 +103,16 @@ class CredentialStore extends Wizard */ private function ajaxMsg($type, $msg, $delete=false) { - $msg_err = 'Failed while saving: %s'; - $msg_ok = 'Successfully saved into keystore '; - - if ($delete) { - $msg_err = 'Failed while removing: %s'; - $msg_ok = 'Successfully deleted '; - } - - if ($type == 'error') { - echo json_encode( - [ - $type => ui_print_error_message( - __( - $msg_err, - $msg - ), - '', - true - ), - ] - ); + if ($type === 'error') { + $msg_title = ($delete === true) ? 'Failed while removing' : 'Failed while saving'; } else { - echo json_encode( - [ - $type => ui_print_success_message( - __( - $msg_ok, - $msg - ), - '', - true - ), - ] - ); + $msg_title = ($delete === true) ? 'Successfully deleted' : 'Successfully saved into keystore'; } + echo json_encode( + [ $type => __($msg_title).':<br>'.$msg ] + ); + exit; } diff --git a/pandora_console/include/class/ModuleTemplates.class.php b/pandora_console/include/class/ModuleTemplates.class.php index e9a03a90b9..2e777bdf4c 100644 --- a/pandora_console/include/class/ModuleTemplates.class.php +++ b/pandora_console/include/class/ModuleTemplates.class.php @@ -264,27 +264,11 @@ class ModuleTemplates extends HTML */ private function ajaxMsg($type, $msg) { - if ($type == 'error') { - echo json_encode( - [ - $type => ui_print_error_message( - __($msg), - '', - true - ), - ] - ); - } else { - echo json_encode( - [ - $type => ui_print_success_message( - __($msg), - '', - true - ), - ] - ); - } + echo json_encode( + [ + $type => __($msg), + ] + ); exit; } diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php index 0d9111a24b..aa86f25e81 100644 --- a/pandora_console/include/class/SatelliteAgent.class.php +++ b/pandora_console/include/class/SatelliteAgent.class.php @@ -959,41 +959,28 @@ class SatelliteAgent extends HTML */ private function ajaxMsg($type, $msg, $delete=false, $disable=false) { - $msg_err = 'Failed while saving: %s'; - $msg_ok = 'Successfully saved agent '; - - if ($delete === true) { - $msg_err = 'Failed while removing: %s'; - $msg_ok = 'Successfully deleted '; - } - - if ($disable === true) { - $msg_err = 'Failed while disabling: %s'; - $msg_ok = 'Successfully disabled'; - } - - if ($type == 'error') { - echo json_encode( - [ - $type => ui_print_error_message( - __($msg), - '', - true - ), - ] - ); + if ($type === 'error') { + if ($delete === true) { + $msg_title = 'Failed while removing'; + } else if ($disable === true) { + $msg_title = 'Failed while disabling'; + } else { + $msg_title = 'Failed while saving'; + } } else { - echo json_encode( - [ - $type => ui_print_success_message( - __($msg), - '', - true - ), - ] - ); + if ($delete === true) { + $msg_title = 'Successfully deleted'; + } else if ($disable === true) { + $msg_title = 'Successfully disabled'; + } else { + $msg_title = 'Successfully saved agent'; + } } + echo json_encode( + [ $type => __($msg_title).':<br>'.$msg ] + ); + exit; } diff --git a/pandora_console/include/class/SatelliteCollection.class.php b/pandora_console/include/class/SatelliteCollection.class.php index aae0cb6780..6ef72c40c4 100644 --- a/pandora_console/include/class/SatelliteCollection.class.php +++ b/pandora_console/include/class/SatelliteCollection.class.php @@ -475,27 +475,11 @@ class SatelliteCollection extends HTML */ private function ajaxMsg(string $type, string $msg) { - if ($type === 'error') { - echo json_encode( - [ - $type => ui_print_error_message( - __($msg), - '', - true - ), - ] - ); - } else { - echo json_encode( - [ - $type => ui_print_success_message( - __($msg), - '', - true - ), - ] - ); - } + echo json_encode( + [ + $type => __($msg), + ] + ); exit; } From 1db803b8f635331b3a4e49d7c3504b46e5a2d5ff Mon Sep 17 00:00:00 2001 From: daniel <daniel.barbero@artica.es> Date: Tue, 7 Mar 2023 12:59:34 +0100 Subject: [PATCH 16/24] fixed styles --- pandora_console/godmode/agentes/module_manager_editor.php | 2 +- .../godmode/agentes/module_manager_editor_network.php | 2 +- pandora_console/include/ajax/module.php | 4 ++-- pandora_console/include/functions_treeview.php | 2 +- pandora_console/include/functions_ui.php | 2 +- pandora_console/operation/agentes/estado_generalagente.php | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 66d75c98a7..c3d7563ef5 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -802,7 +802,7 @@ if ($id_agent_module) { __('Delete'), 'deleteModule', false, - 'window.location.assign(\'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$id_agent_module.')', + 'window.location.assign("index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$id_agent_module.'")', [ 'icon' => 'delete', 'mode' => 'secondary', diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 6e0af65f83..be63ddfeef 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -524,7 +524,7 @@ $data[0] .= html_print_button( __('Manage credentials'), 'manage_credentials_button', false, - 'window.location.assign(\'index.php?sec=gmodules&sec2=godmode/groups/group_list&tab=credbox\')', + 'window.location.assign("index.php?sec=gmodules&sec2=godmode/groups/group_list&tab=credbox")', [ 'mode' => 'link' ], true ); diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 086741d052..052f105eda 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -1283,7 +1283,7 @@ if (check_login()) { $linkCaption, 'additional_action_for_'.$idAgenteModulo, false, - 'window.location.assign(\'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&id_agente_modulo='.$module['id_agente_modulo'].'&refr=60'.$addedLinkParams.'\')', + 'window.location.assign("index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&id_agente_modulo='.$module['id_agente_modulo'].'&refr=60'.$addedLinkParams.'")', [ 'mode' => 'link', 'style' => 'justify-content: flex-end;', @@ -1300,7 +1300,7 @@ if (check_login()) { __('Edit'), 'edit_module_'.$idAgenteModulo, false, - 'window.location.assign(\'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&id_agent_module='.$module['id_agente_modulo'].'&edit_module='.$module['id_modulo'].'\')', + 'window.location.assign("index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&id_agent_module='.$module['id_agente_modulo'].'&edit_module='.$module['id_modulo'].'")', [ 'mode' => 'link', 'style' => 'justify-content: flex-end;', diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index b43d6bba95..e86c728fa7 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -467,7 +467,7 @@ function treeview_printAlertsTable($id_module, $server_data=[], $no_head=false) __('Go to alerts edition'), 'upd_button', false, - 'window.location.assign(\''.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name='.$module_name.'&id_agente='.$agent_id.$url_hash.'\')', + 'window.location.assign("'.$console_url.'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name='.$module_name.'&id_agente='.$agent_id.$url_hash.'")', ['icon' => 'alert'], true ), diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 41091302fd..b9a347c1de 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1210,7 +1210,7 @@ function ui_format_alert_row( $forceTitle, 'force_execution_'.$alert['id'], false, - 'window.location.assign(\''.$url.'&id_alert='.$alert['id'].'&refr=60'.$additionUrl.'\');', + 'window.location.assign("'.$url.'&id_alert='.$alert['id'].'&refr=60'.$additionUrl.'");', [ 'mode' => 'link' ], true ); diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 3e5584fe42..399ce94b24 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -396,7 +396,7 @@ $buttonsRefreshAgent = html_print_button( __('Refresh data'), 'refresh_data', false, - 'window.location.assign(\'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=60\')', + 'window.location.assign("index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=60")', [ 'mode' => 'link' ], true ); @@ -406,7 +406,7 @@ if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) { __('Force checks'), 'force_checks', false, - 'window.location.assign(\'index.php?sec=estado&sec2=operation/agentes/ver_agente&flag_agent=1&id_agente='.$id_agente.'\')', + 'window.location.assign("index.php?sec=estado&sec2=operation/agentes/ver_agente&flag_agent=1&id_agente='.$id_agente.'")', [ 'mode' => 'link' ], true ); From b31654204437d0908d5d57a0193cc0f2d3bc78ac Mon Sep 17 00:00:00 2001 From: daniel <daniel.barbero@artica.es> Date: Tue, 7 Mar 2023 14:03:04 +0100 Subject: [PATCH 17/24] fixed styles --- .../modules/manage_inventory_modules.php | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/pandora_console/godmode/modules/manage_inventory_modules.php b/pandora_console/godmode/modules/manage_inventory_modules.php index 5422ae451b..cb06fb8933 100644 --- a/pandora_console/godmode/modules/manage_inventory_modules.php +++ b/pandora_console/godmode/modules/manage_inventory_modules.php @@ -349,22 +349,51 @@ if ($result === false) { html_print_input_hidden('multiple_delete', 1); html_print_table($table); echo '</form>'; - $tablePagination = ui_pagination($total_modules, 'index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules', $offset, 0, true, 'offset', false); - $actionButtons = []; + echo '<form id="form_create" method="post" action="index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules_form">'; + echo html_print_input_hidden('create_module_inventory', 1); + echo '<form>'; + + $tablePagination = ui_pagination( + $total_modules, + 'index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules', + $offset, + 0, + true, + 'offset', + false + ); + + $actionButtons = ''; if ($management_allowed === true) { - $actionButtons[] = html_print_submit_button(__('Delete'), 'delete_btn', false, ['icon' => 'delete', 'mode' => 'secondary', 'form' => 'form_delete'], true); - $actionButtons[] = html_print_submit_button(__('Create'), 'crt', false, ['icon' => 'wand', 'form' => 'form_create'], true); + $actionButtons .= html_print_submit_button( + __('Delete'), + 'delete_btn', + false, + [ + 'icon' => 'delete', + 'mode' => 'secondary', + 'form' => 'form_delete', + ], + true + ); - $actionButtons[] = '<form id="form_create" method="post" action="index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules_form">'; - $actionButtons[] = html_print_input_hidden('create_module_inventory', 1, true); - $actionButtons[] = '<form>'; + + $actionButtons .= html_print_submit_button( + __('Create'), + 'crt', + false, + [ + 'icon' => 'wand', + 'form' => 'form_create', + ], + true + ); } - html_print_action_buttons( - implode('', $actionButtons), + $actionButtons, [ 'type' => 'form_action', 'right_content' => $tablePagination, From d4f900d1a4ef4c39e69bc17b3d36f90e33d836d7 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 14:11:20 +0100 Subject: [PATCH 18/24] Manage inventory icons --- .../godmode/modules/manage_inventory_modules.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/modules/manage_inventory_modules.php b/pandora_console/godmode/modules/manage_inventory_modules.php index 5422ae451b..121b9e3b83 100644 --- a/pandora_console/godmode/modules/manage_inventory_modules.php +++ b/pandora_console/godmode/modules/manage_inventory_modules.php @@ -332,14 +332,16 @@ if ($result === false) { if ($management_allowed === true) { // Update module. - $data[4] = '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules_form&id_module_inventory='.$row['id_module_inventory'].'">'; - $data[4] .= html_print_image('images/config.png', true, ['border' => '0', 'title' => __('Update'), 'class' => 'invert_filter']).'</b></a>'; + $data[4] = '<div class="table_action_buttons">'; + $data[4] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules_form&id_module_inventory='.$row['id_module_inventory'].'">'; + $data[4] .= html_print_image('images/edit.svg', true, ['border' => '0', 'title' => __('Update'), 'class' => 'main_menu_icon invert_filter']).'</b></a>'; // Delete module. $data[4] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules&delete_inventory_module='.$row['id_module_inventory'].'" onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'; - $data[4] .= html_print_image('images/cross.png', true, ['border' => '0', 'title' => __('Delete'), 'class' => 'invert_filter']); + $data[4] .= html_print_image('images/delete.svg', true, ['border' => '0', 'title' => __('Delete'), 'class' => 'main_menu_icon invert_filter']); $data[4] .= '</b></a> '; $data[4] .= html_print_checkbox_extended('delete_multiple[]', $row['id_module_inventory'], false, false, '', 'class="check_delete"', true); + $data[4] .= '</div>'; } array_push($table->data, $data); From 8dbcffaa8bda7fde503e5f56256ea3b36d634c7a Mon Sep 17 00:00:00 2001 From: Jonathan <jonathan.leon@pandorafms.com> Date: Tue, 7 Mar 2023 14:15:02 +0100 Subject: [PATCH 19/24] Buttons and view report --- .../reporting_builder.item_editor.php | 29 ++++-- pandora_console/include/functions_html.php | 34 +++---- pandora_console/include/styles/pandora.css | 9 ++ .../operation/reporting/reporting_viewer.php | 98 ++++++------------- 4 files changed, 79 insertions(+), 91 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index ce755015ed..ec336eb290 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -2229,7 +2229,7 @@ $class = 'databox filters'; <tr id="row_custom_graph" class="datos"> <td class="bolder"><?php echo __('Custom graph'); ?></td> - <td > + <td class="toolbox-buttons"> <?php if ($meta) { $graphs = []; @@ -2303,21 +2303,38 @@ $class = 'databox filters'; } } - echo ' '; + if (!empty($style_button_create_custom_graph)) { + $style_create = [ + 'mode' => 'link', + 'style' => 'display:none', + ]; + } else { + $style_create = [ 'mode' => 'link' ]; + } + + if (!empty($style_button_edit_custom_graph)) { + $style_edit = [ + 'mode' => 'link', + 'style' => 'display:none', + ]; + } else { + $style_edit = [ 'mode' => 'link' ]; + } + html_print_button( __('Create'), 'create_graph', false, - 'create_custom_graph();', - 'class="sub add" '.$style_button_create_custom_graph + 'create_custom_graph()', + $style_create ); html_print_button( __('Edit'), 'edit_graph', false, - 'edit_custom_graph();', - 'class="sub config" '.$style_button_edit_custom_graph + 'edit_custom_graph()', + $style_edit ); ?> </td> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 693a14adb7..e9e60f3418 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1361,29 +1361,27 @@ function html_print_select_multiple_filtered( $output .= '<div class="arrows-container flex-column">'; - $output .= html_print_input( + $output .= html_print_image( + 'images/plus.svg', + true, [ - 'type' => 'image', - 'src' => 'images/darrowright.png', - 'return' => true, - 'options' => [ - 'title' => $texts['title-add'], - 'onclick' => $add, - 'class' => 'invert_filter', - ], + 'id' => 'right_autorefreshlist', + 'style' => 'width: 24px; margin: 10px 10px 0;', + 'alt' => __('Push selected pages into autorefresh list'), + 'title' => __('Push selected pages into autorefresh list'), + 'onclick' => $add, ] ); - $output .= html_print_input( + $output .= html_print_image( + 'images/minus.svg', + true, [ - 'type' => 'image', - 'src' => 'images/darrowleft.png', - 'return' => true, - 'options' => [ - 'title' => $texts['title-del'], - 'onclick' => $del, - 'class' => 'invert_filter', - ], + 'id' => 'left_autorefreshlist', + 'style' => 'width: 24px; margin: 10px 10px 0;', + 'alt' => __('Pop selected pages out of autorefresh list'), + 'title' => __('Pop selected pages out of autorefresh list'), + 'onclick' => $del, ] ); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index eec5727f49..ba7425f137 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -11505,6 +11505,15 @@ div[role="dialog"] { /* font-weight: bold; */ } +.font-title-font { + font-size: 13px; + line-height: 16px; + color: #161628; + text-align: left; + margin-bottom: 10px; + font-weight: bold; +} + .preimage_container span { font-size: 11pt; line-height: 28px; diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 5c3ce7a73b..26e16c7f37 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -226,77 +226,52 @@ ui_print_standard_header( // ------------------- END HEADER --------------------------------------- // ------------------------ INIT FORM ----------------------------------- -$table = new stdClass(); -$table->id = 'controls_table'; -$table->width = '100%'; -$table->class = 'filter-table-adv'; +$table2 = new stdClass(); +$table2->id = 'controls_table'; +$table2->size[2] = '50%'; +$table2->size[3] = '50%'; +$table2->style[0] = 'text-align:center'; +$table2->style[1] = 'text-align:center'; +$table2->styleTable = 'border:none'; + if (defined('METACONSOLE')) { - $table->width = '100%'; - $table->class = 'databox filters'; + $table2->width = '100%'; + $table2->class = 'databox filters'; - $table->head[0] = __('View Report'); - $table->head_colspan[0] = 5; - $table->headstyle[0] = 'text-align: center'; + $table2->head[0] = __('View Report'); + $table2->head_colspan[0] = 5; + $table2->headstyle[0] = 'text-align: center'; } -$table->style = []; -$table->style[0] = 'vertical-align: middle'; -$table->rowspan[0][0] = 2; - // Set initial conditions for these controls, later will be modified by javascript if (!$enable_init_date) { - $table->style[1] = 'display: none'; - $table->style[2] = 'display: flex;align-items: baseline;'; $display_to = 'none'; $display_item = ''; } else { - $table->style[1] = 'display: "block"'; - $table->style[2] = 'display: flex;align-items: baseline;'; $display_to = ''; $display_item = 'none'; } -$table->size = []; -$table->colspan[0][1] = 2; -$table->data = []; -$table->data[0][0] = html_print_image( - 'images/reporting32.png', - true, - [ - 'width' => '32', - 'height' => '32', - ] -); - -if (reporting_get_description($id_report)) { - $table->data[0][1] = '<div class="float-left">'.reporting_get_description($id_report).'</div>'; -} else { - $table->data[0][1] = '<div class="float-left">'.reporting_get_name($id_report).'</div>'; -} - -$table->data[0][1] .= '<div class="float-right">'.__('Set initial date').html_print_checkbox('enable_init_date', 1, $enable_init_date, true).'</br>'; - $html_menu_export = enterprise_hook('reporting_print_button_export'); if ($html_menu_export === ENTERPRISE_NOT_HOOK) { $html_menu_export = ''; } -$table->data[0][1] .= '</div>'; -$table->data[0][1] .= $html_menu_export; +$table2->data[0][2] = '<div><span class="font-title-font">'.__('Set initial date').'</span><br>'.html_print_checkbox_switch('enable_init_date', 1, $enable_init_date, true).'</div><br>'; +$table2->data[0][2] .= '<div style="display:'.$display_to.'" id="string_from"><div><span class="font-title-font">'.__('From').':</span></div>'; +$table2->data[0][2] .= html_print_input_text('date_init', $date_init, '', 12, 10, true).' '; +$table2->data[0][2] .= html_print_input_text('time_init', $time_init, '', 10, 7, true).' '; +$table2->data[0][2] .= '</div><div style="display:'.$display_item.'" id="string_items"><span class="font-title-font">'.__('Items period before').':</span></div>'; +$table2->data[0][2] .= '<div style="display:'.$display_to.'" id="string_to"><span class="font-title-font">'.__('to').':</span></div>'; +$table2->data[0][2] .= html_print_input_text('date', $date, '', 12, 10, true).' '; +$table2->data[0][2] .= html_print_input_text('time', $time, '', 10, 7, true).' '; +$table2->data[0][3] = $html_menu_export; -$table->data[1][1] = '<div>'.__('From').': </div>'; -$table->data[1][1] .= html_print_input_text('date_init', $date_init, '', 12, 10, true).' '; -$table->data[1][1] .= html_print_input_text('time_init', $time_init, '', 10, 7, true).' '; -$table->data[1][2] = '<div style="display:'.$display_item.'" id="string_items">'.__('Items period before').':</div>'; -$table->data[1][2] .= '<div style="display:'.$display_to.'" id="string_to">'.__('to').':</div>'; -$table->data[1][2] .= html_print_input_text('date', $date, '', 12, 10, true).' '; -$table->data[1][2] .= html_print_input_text('time', $time, '', 10, 7, true).' '; - $searchForm = '<form method="post" action="'.$url.'&pure='.$config['pure'].'" class="mrgn_right_0px">'; -$searchForm .= html_print_table($table, true); +$searchForm .= html_print_table($table2, true); $searchForm .= html_print_input_hidden('id_report', $id_report, true); $Actionbuttons .= html_print_submit_button( @@ -354,10 +329,6 @@ for ($i = 0; $i < count($report['contents']); $i++) { reporting_html_print_report($report, false, $config['custom_report_info']); -// ---------------------------------------------------------------------- -// The rowspan of the first row is only 2 in controls table. Why is used the same code here and in the items?? -$table->rowspan[0][0] = 1; - echo '<div id="loading" class="center">'; echo html_print_image('images/wait.gif', true, ['border' => '0']); echo '<strong>'.__('Loading').'...</strong>'; @@ -387,16 +358,15 @@ $(document).ready (function () { secondText: '<?php echo __('Second'); ?>', currentText: '<?php echo __('Now'); ?>', closeText: '<?php echo __('Close'); ?>'}); - + $.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]); - + $("#text-date").datepicker({ dateFormat: "<?php echo DATE_FORMAT_JS; ?>", changeMonth: true, changeYear: true, showAnim: "slideDown"}); - - + $('[id^=text-time_init]').timepicker({ showSecond: true, timeFormat: '<?php echo TIME_FORMAT_JS; ?>', @@ -407,29 +377,23 @@ $(document).ready (function () { secondText: '<?php echo __('Second'); ?>', currentText: '<?php echo __('Now'); ?>', closeText: '<?php echo __('Close'); ?>'}); - + $('[id^=text-date_init]').datepicker ({ dateFormat: "<?php echo DATE_FORMAT_JS; ?>", changeMonth: true, changeYear: true, showAnim: "slideDown"}); - - - $("*", "#controls_table-0").css("display", ""); //Re-show the first row of form. - + /* Show/hide begin date reports controls */ $("#checkbox-enable_init_date").click(function() { flag = $("#checkbox-enable_init_date").is(':checked'); if (flag == true) { - $("#controls_table-1-1").css("display", ""); - $("#controls_table-1-2").css("display", ""); $("#string_to").show(); + $('#string_from').show(); $("#string_items").hide(); - } - else { - $("#controls_table-1-1").css("display", "none"); - $("#controls_table-1-2").css("display", ""); + } else { $("#string_to").hide(); + $('#string_from').hide(); $("#string_items").show(); } }); From 845a63708271c9dd0329a0a0dc22b4c2fe3b912a Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 14:59:59 +0100 Subject: [PATCH 20/24] Inventory modules forms --- .../modules/manage_inventory_modules.php | 23 +- .../modules/manage_inventory_modules_form.php | 228 +++++++++++++----- 2 files changed, 172 insertions(+), 79 deletions(-) diff --git a/pandora_console/godmode/modules/manage_inventory_modules.php b/pandora_console/godmode/modules/manage_inventory_modules.php index 1b9d2aa71e..a8faa13a66 100644 --- a/pandora_console/godmode/modules/manage_inventory_modules.php +++ b/pandora_console/godmode/modules/manage_inventory_modules.php @@ -369,6 +369,17 @@ if ($result === false) { $actionButtons = ''; if ($management_allowed === true) { + $actionButtons .= html_print_submit_button( + __('Create'), + 'crt', + false, + [ + 'icon' => 'wand', + 'form' => 'form_create', + ], + true + ); + $actionButtons .= html_print_submit_button( __('Delete'), 'delete_btn', @@ -380,18 +391,6 @@ if ($result === false) { ], true ); - - - $actionButtons .= html_print_submit_button( - __('Create'), - 'crt', - false, - [ - 'icon' => 'wand', - 'form' => 'form_create', - ], - true - ); } html_print_action_buttons( diff --git a/pandora_console/godmode/modules/manage_inventory_modules_form.php b/pandora_console/godmode/modules/manage_inventory_modules_form.php index 65597d7af1..32424b7f39 100644 --- a/pandora_console/godmode/modules/manage_inventory_modules_form.php +++ b/pandora_console/godmode/modules/manage_inventory_modules_form.php @@ -26,22 +26,32 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! check_acl($config['id_user'], // Header -if (defined('METACONSOLE')) { +if (is_metaconsole() === true) { $sec = 'advanced'; enterprise_include_once('meta/include/functions_components_meta.php'); components_meta_print_header(); } else { $sec = 'gmodules'; - ui_print_page_header( - __('Module management').' » '.__('Inventory modules'), + ui_print_standard_header( + __('Module management'), 'images/op_inventory.png', false, '', - true + true, + [], + [ + [ + 'link' => '', + 'label' => __('Configuration'), + ], + [ + 'link' => '', + 'label' => __('Inventory modules'), + ], + ] ); } -// Header $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; if ($is_windows) { ui_print_error_message(__('Not supported in Windows systems')); @@ -95,82 +105,166 @@ if ($id_os == null) { $table = new stdClass(); $table->width = '100%'; -$table->class = 'databox filters'; +$table->class = 'databox filter-table-adv'; $table->style = []; -$table->style[0] = 'font-weight: bold'; +$table->style[0] = 'width: 50%'; +$table->style[1] = 'width: 50%'; $table->data = []; -$table->data[0][0] = '<strong>'.__('Name').'</strong>'; -$table->data[0][1] = html_print_input_text('name', $name, '', 45, 100, true, $disabled); -$table->data[1][0] = '<strong>'.__('Description').'</strong>'; -$table->data[1][1] = html_print_input_text('description', $description, '', 60, 500, true); -$table->data[2][0] = '<strong>'.__('OS').'</strong>'; -$table->data[2][1] = html_print_select_from_sql( - 'SELECT id_os, name FROM tconfig_os ORDER BY name', - 'id_os', - $id_os, - '', - '', - '', - $return = true + +$table->data[0][] = html_print_label_input_block( + __('Name'), + html_print_input_text( + 'name', + $name, + '', + 45, + 100, + true, + $disabled + ) ); -$table->data[3][0] = '<strong>'.__('Interpreter').'</strong>'; -$table->data[3][1] = html_print_input_text('interpreter', $interpreter, '', 25, 100, true); -$table->data[3][1] .= ui_print_help_tip(__('Left blank for the LOCAL inventory modules'), true); +$table->data[0][] = html_print_label_input_block( + __('Description'), + html_print_input_text( + 'description', + $description, + '', + 60, + 500, + true + ) +); -$table->data['block_mode'][0] = '<strong>'.__('Block Mode').'</strong>'; -$table->data['block_mode'][1] = html_print_checkbox('block_mode', 1, $block_mode, true); +$table->data[1][] = html_print_label_input_block( + __('OS'), + html_print_select_from_sql( + 'SELECT id_os, name FROM tconfig_os ORDER BY name', + 'id_os', + $id_os, + '', + '', + '', + $return = true + ) +); -$table->data[4][0] = '<strong>'.__('Format').'</strong>'; -$table->data[4][0] .= ui_print_help_tip(__('separate fields with ').SEPARATOR_COLUMN, true); -$table->data[4][1] = html_print_input_text('format', $data_format, '', 50, 100, true); +$table->data[1][] = html_print_label_input_block( + __('Interpreter'), + html_print_input_text( + 'interpreter', + $interpreter, + '', + 25, + 100, + true + ).ui_print_input_placeholder( + __('Left blank for the LOCAL inventory modules'), + true + ) +); -$table->data[5][0] = '<strong>'.__('Script mode').'</strong>'; -$table->data[5][0] .= ui_print_help_tip(__(''), true); -$table->data[5][1] = __('Use script'); -$table->data[5][1] .= html_print_radio_button( - 'script_mode', - 1, - '', - $script_mode, - true -).' '; -$table->data[5][1] .= '    '.__('Use inline code'); -$table->data[5][1] .= html_print_radio_button( - 'script_mode', - 2, - '', - $script_mode, - true -).' '; +$table->data[2][] = html_print_label_input_block( + __('Format'), + html_print_input_text( + 'format', + $data_format, + '', + 50, + 100, + true + ).ui_print_input_placeholder( + __('separate fields with ').SEPARATOR_COLUMN, + true + ) +); -$table->data[6][0] = '<strong>'.__('Script path').'</strong>'; -$table->data[6][1] = html_print_input_text('script_path', $script_path, '', 50, 1000, true); +$table->data[2][] = html_print_label_input_block( + __('Block Mode'), + html_print_checkbox_switch( + 'block_mode', + 1, + $block_mode, + true + ) +); -$table->data[7][0] = '<strong>'.__('Code').'</strong>'; -$table->data[7][0] .= ui_print_help_tip(__("Here is placed the script for the REMOTE inventory modules Local inventory modules don't use this field").SEPARATOR_COLUMN, true); +$radioButtons = []; +$radioButtons[] = html_print_radio_button('script_mode', 1, __('Script mode'), $script_mode, true); +$radioButtons[] = html_print_radio_button('script_mode', 2, __('Use inline code'), $script_mode, true); -$table->data[7][1] = html_print_textarea('code', 25, 80, base64_decode($code), '', true); +$table->data[3][] = html_print_label_input_block( + __('Script mode'), + html_print_div( + [ + 'class' => 'switch_radio_button', + 'content' => implode('', $radioButtons), + ], + true + ) +); -echo '<form name="inventorymodule" id="inventorymodule_form" method="post" +$table->colspan[4][0] = 2; + +$table->data[4][0] = html_print_label_input_block( + __('Script path'), + html_print_input_text( + 'script_path', + $script_path, + '', + 50, + 1000, + true + ), + ['div_class' => 'script_path_inventory_modules'] +); + +$table->data[4][0] .= html_print_label_input_block( + __('Code'), + html_print_textarea( + 'code', + 25, + 80, + base64_decode($code), + '', + true + ).ui_print_input_placeholder( + __("Here is placed the script for the REMOTE inventory modules Local inventory modules don't use this field").SEPARATOR_COLUMN, + true + ), + ['div_class' => 'code_inventory_modules'] +); + +echo '<form name="inventorymodule" id="inventorymodule_form" class="max_floating_element_size" method="post" action="index.php?sec='.$sec.'&sec2=godmode/modules/manage_inventory_modules">'; html_print_table($table); if ($id_module_inventory) { html_print_input_hidden('update_module_inventory', 1); html_print_input_hidden('id_module_inventory', $id_module_inventory); + $buttonCaption = __('Update'); + $buttonIcon = 'update'; } else { html_print_input_hidden('create_module_inventory', 1); + $buttonCaption = __('Create'); + $buttonIcon = 'wand'; } -echo '<div class="action-buttons" style="width: '.$table->width.'">'; -if ($id_module_inventory) { - html_print_submit_button(__('Update'), 'submit', false, 'class="sub next"'); -} else { - html_print_submit_button(__('Create'), 'submit', false, 'class="sub upd"'); -} +$actionButtons = ''; +$actionButtons = html_print_submit_button( + $buttonCaption, + 'submit', + false, + ['icon' => $buttonIcon], + true +); +$actionButtons .= html_print_go_back_button( + 'index.php?sec=gmodules&sec2=godmode/modules/manage_inventory_modules', + ['button_class' => ''], + true +); -echo '</div>'; +html_print_action_buttons($actionButtons); echo '</form>'; ?> @@ -180,21 +274,21 @@ echo '</form>'; var mode = <?php echo $script_mode; ?>; if (mode == 1) { - $('#table1-6').show(); - $('#table1-7').hide(); + $('.script_path_inventory_modules').show(); + $('.code_inventory_modules').hide(); } else { - $('#table1-7').show(); - $('#table1-6').hide(); + $('.code_inventory_modules').show(); + $('.script_path_inventory_modules').hide(); } $('input[type=radio][name=script_mode]').change(function() { if (this.value == 1) { - $('#table1-6').show(); - $('#table1-7').hide(); + $('.script_path_inventory_modules').show(); + $('.code_inventory_modules').hide(); } else if (this.value == 2) { - $('#table1-7').show(); - $('#table1-6').hide(); + $('.code_inventory_modules').show(); + $('.script_path_inventory_modules').hide(); } }); }); From d4125be1b662818b0920d02769a855569325bdbb Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 15:00:34 +0100 Subject: [PATCH 21/24] Fix visual issue with radios --- pandora_console/include/styles/pandora.css | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index eec5727f49..abb6332c13 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5803,10 +5803,10 @@ div.label_select_child_left > span { overflow: hidden; } -.switch_radio_button label { +div.switch_radio_button label { background-color: #fff; color: rgba(0, 0, 0, 0.6); - line-height: 9pt; + line-height: 6px !important; text-align: center; padding: 14px 10px; margin-right: -1px; @@ -5814,14 +5814,14 @@ div.label_select_child_left > span { transition: all 0.1s ease-in-out; } -.switch_radio_button label:first { - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; +div.switch_radio_button label:first-of-type { + border-top-left-radius: 4px !important; + border-bottom-left-radius: 4px !important; } -.switch_radio_button label:last-child { - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; +div.switch_radio_button label:last-of-type { + border-top-right-radius: 4px !important; + border-bottom-right-radius: 4px !important; margin-right: 0px; } From 1b0fe3887f90b5bb10a4048def5eacbd78008f51 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 15:08:03 +0100 Subject: [PATCH 22/24] Fixed issue with spinner --- pandora_console/godmode/groups/group_list.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 268d91dd3a..576131a8c6 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -738,14 +738,7 @@ if ($tab == 'tree') { * Group tree view. */ - echo html_print_image( - 'images/spinner.gif', - true, - [ - 'class' => 'loading_tree', - 'style' => 'display: none;', - ] - ); + ui_print_spinner(__('Loading')); echo "<div id='tree-controller-recipient'></div>"; } else { /* @@ -1041,7 +1034,7 @@ $tab = 'group_edition'; if (typeof treeController.recipient != 'undefined' && treeController.recipient.length > 0) treeController.recipient.empty(); - $(".loading_tree").show(); + showSpinner(); var parameters = {}; parameters['page'] = "include/ajax/tree.ajax"; @@ -1065,7 +1058,7 @@ $tab = 'group_edition'; data: parameters, success: function(data) { if (data.success) { - $(".loading_tree").hide(); + hideSpinner(); treeController.init({ recipient: $("div#tree-controller-recipient"), From 226b80b7c7bb399e1948ad400d6c09b3ddfdd973 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez <jose.gonzalez@pandorafms.com> Date: Tue, 7 Mar 2023 15:59:10 +0100 Subject: [PATCH 23/24] Icon revision --- pandora_console/extensions/agents_modules.php | 10 ++-- pandora_console/include/functions_ui.php | 48 +++++++++---------- .../operation/agentes/estado_agente.php | 6 +-- .../operation/agentes/group_view.php | 4 +- pandora_console/operation/heatmap.php | 14 +++--- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 44d4bc64b6..d3467b846c 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -377,17 +377,17 @@ function mainAgentsModules() $fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&pure=1& offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'&show_type='.$show_type.' - &full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>'; + &full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>'; } else if ($full_modules_selected[0] && $full_agents_id[0]) { $full_modules = urlencode(implode(';', $full_modules_selected)); $full_agents = urlencode(implode(';', $full_agents_id)); $fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&pure=1& offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&full_modules_selected='.$full_modules.'&show_type='.$show_type.' - &full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>'; + &full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>'; } else { $fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&pure=1& - offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&show_type='.$show_type.'">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>'; + offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&show_type='.$show_type.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).'</a>'; } } @@ -597,11 +597,11 @@ function mainAgentsModules() echo '<li class="nomn">'; echo '<a target="_top" href="'.$url.'">'; echo html_print_image( - 'images/normal_screen.png', + 'images/exit_fullscreen@svg.svg', true, [ 'title' => __('Back to normal mode'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); echo '</a>'; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index b9a347c1de..ba4e6bb219 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2444,35 +2444,35 @@ function ui_print_session_action_icon($action, $return=false) global $config; $key_icon = [ - 'acl' => 'images/delete.png', - 'agent' => 'images/agent.png', - 'module' => 'images/module.png', - 'alert' => 'images/bell.png', - 'incident' => 'images/default_list.png', - 'logon' => 'images/house.png', - 'logoff' => 'images/house.png', - 'massive' => 'images/config.png', - 'hack' => 'images/application_edit.png', - 'event' => 'images/lightning_go.png', - 'policy' => 'images/policies_mc.png', - 'report' => 'images/reporting.png', - 'file collection' => 'images/collection_col.png', - 'user' => 'images/user_green.png', - 'password' => 'images/lock.png', - 'session' => 'images/heart_col.png', - 'snmp' => 'images/snmp.png', - 'command' => 'images/bell.png', - 'category' => 'images/category_col.png', - 'dashboard' => 'images/dashboard_col.png', - 'api' => 'images/eye.png', - 'db' => 'images/database.png', - 'setup' => 'images/cog.png', + 'acl' => 'images/delete.svg', + 'agent' => 'images/agents@svg.svg', + 'module' => 'images/modules@svg.svg', + 'alert' => 'images/alerts.svg', + 'incident' => 'images/logs@svg.svg', + 'logon' => 'images/house@svg.svg', + 'logoff' => 'images/house@svg.svg', + 'massive' => 'images/configuration@svg.svg', + 'hack' => 'images/custom-input@svg.svg', + 'event' => 'images/event.svg', + 'policy' => 'images/policy@svg.svg', + 'report' => 'images/agent-fields.svg', + 'file collection' => 'images/file-collection@svg.svg', + 'user' => 'images/user.svg', + 'password' => 'images/password.svg', + 'session' => 'images/star@svg.svg', + 'snmp' => 'images/SNMP-network-numeric-data@svg.svg', + 'command' => 'images/external-tools@svg.svg', + 'category' => 'images/tag@svg.svg', + 'dashboard' => 'images/workstation@groups.svg', + 'api' => 'images/enable.svg', + 'db' => 'images/data-server@svg.svg', + 'setup' => 'images/configuration@svg.svg', ]; $output = ''; foreach ($key_icon as $key => $icon) { if (stristr($action, $key) !== false) { - $output = html_print_image($icon, true, ['title' => $action, 'class' => 'invert_filter'], false, false, false, true).' '; + $output = html_print_image($icon, true, ['title' => $action, 'class' => 'main_menu_icon invert_filter'], false, false, false, true).' '; break; } } diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index e96f6f6537..9898f4a290 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -1141,7 +1141,7 @@ foreach ($agents as $agent) { $data[0] .= ui_print_help_tip( __('Agent in scheduled downtime'), true, - 'images/minireloj-16.png' + 'images/clock.svg' ); $data[0] .= '</em>'; } @@ -1254,12 +1254,12 @@ foreach ($agents as $agent) { $fb64 = base64_encode(json_encode($agent_event_filter)); $data[11] = '<a href="index.php?sec=eventos&sec2=operation/events/events&fb64='.$fb64.'">'.html_print_image( - 'images/lightning.png', + 'images/event.svg', true, [ 'align' => 'middle', 'title' => __('Agent events'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).'</a>'; diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 3e602658df..f2ebbedbcf 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -289,12 +289,12 @@ if (empty($result_groups) === false) { echo "<td class='group_view_data center vertical_middle'>"; if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) { echo '<a href="index.php?sec=estado&sec2=operation/agentes/group_view&update_netgroup='.$data['_id_'].'">'.html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'border' => '0', 'title' => __('Force'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).'</a>'; } diff --git a/pandora_console/operation/heatmap.php b/pandora_console/operation/heatmap.php index a9ab10ed47..1f7337aa39 100644 --- a/pandora_console/operation/heatmap.php +++ b/pandora_console/operation/heatmap.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas * Please see http://pandorafms.org for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -64,11 +64,11 @@ if ($group_sent === true) { $is_ajax = is_ajax(); if ($is_ajax === false && $pure === false) { $viewtab['config'] = '<a id="config" href="">'.html_print_image( - 'images/setup.png', + 'images/configuration@svg.svg', true, [ 'title' => __('Config'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).'</a>'; @@ -81,11 +81,11 @@ if ($is_ajax === false && $pure === false) { ); $viewtab['full_screen'] = '<a id="full_screen" href="'.$url.'">'.html_print_image( - 'images/full_screen.png', + 'images/fullscreen@svg.svg', true, [ 'title' => __('Full screen'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).'</a>'; @@ -208,11 +208,11 @@ if ($is_ajax === false && $pure === true) { echo '<a href="'.$urlNoFull.'">'; echo html_print_image( - 'images/normal_screen.png', + 'images/exit_fullscreen@svg.svg', true, [ 'title' => __('Back to normal mode'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); echo '</a>'; From 5a41c8b61c3f83a5a86f4a4212024f8f2f5dbdde Mon Sep 17 00:00:00 2001 From: daniel <daniel.barbero@artica.es> Date: Tue, 7 Mar 2023 16:00:23 +0100 Subject: [PATCH 24/24] fixed styles --- .../modules/manage_network_components.php | 28 ++++------ .../manage_network_components_form.php | 52 +++++++++---------- 2 files changed, 35 insertions(+), 45 deletions(-) diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index a3050f02e9..7ef20ca385 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -949,30 +949,20 @@ html_print_action_buttons( ?> <script type="text/javascript"> $( document ).ready(function() { - $('[id^=checkbox-delete_multiple]').change(function(){ - if($(this).parent().parent().hasClass('checkselected')){ - $(this).parent().parent().removeClass('checkselected'); - } - else{ - $(this).parent().parent().addClass('checkselected'); + $('[id^=checkbox-delete_multiple]').click(function(){ + if($(this).prop("checked") === false ){ + $(this).prop("checked", false); + } else { + $(this).prop("checked", true); } }); - $('[id^=checkbox-all_delete]').change(function(){ - if ($("#checkbox-all_delete").prop("checked")) { - $('[id^=checkbox-delete_multiple]') - .parent() - .parent() - .addClass('checkselected'); - $(".check_delete") - .prop("checked", true); + $('#checkbox-all_delete').click(function(){ + if ($("#checkbox-all_delete").prop("checked") === true) { + $("[id^=checkbox-delete_multiple]").prop("checked", true); } else{ - $('[id^=checkbox-delete_multiple]') - .parent() - .parent() - .removeClass('checkselected'); - $(".check_delete").prop("checked", false); + $("[id^=checkbox-delete_multiple]").prop("checked", false); } }); }); diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index f4c7d3776a..427d8295f7 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -366,43 +366,43 @@ if (is_metaconsole() === true) { html_print_table($table); -html_print_input_hidden('id_component_type', $id_component_type); +$buttons = html_print_input_hidden('id_component_type', $id_component_type); if ($id) { - html_print_input_hidden('update_component', 1); - html_print_input_hidden('id', $id); + $buttons .= html_print_input_hidden('update_component', 1, true); + $buttons .= html_print_input_hidden('id', $id, true); $buttonCaption = __('Update'); $buttonIcon = 'update'; $buttonName = 'upd'; - html_print_submit_button(__('Update'), 'upd', false, 'class="sub upd"'); } else { - html_print_input_hidden('create_component', 1); - html_print_input_hidden('create_network_from_module', 0); + $buttons .= html_print_input_hidden('create_component', 1, true); + $buttons .= html_print_input_hidden('create_network_from_module', 0, true); $buttonCaption = __('Create'); $buttonIcon = 'wand'; $buttonName = 'crt'; } -html_print_div( +$buttons .= html_print_submit_button( + $buttonCaption, + $buttonName, + false, + ['icon' => $buttonIcon], + true +); + +$buttons .= html_print_button( + __('Go back'), + 'go_back', + false, + '', [ - 'class' => 'action-buttons', - 'content' => html_print_button( - __('Go back'), - 'go_back', - false, - '', - [ - 'icon' => 'back', - 'mode' => 'secondary', - ], - true - ).html_print_submit_button( - $buttonCaption, - $buttonName, - false, - ['icon' => $buttonIcon], - true - ), - ] + 'icon' => 'back', + 'mode' => 'secondary', + ], + true +); + +html_print_action_buttons( + $buttons ); echo '</form>';