Merge remote-tracking branch 'origin/develop' into ent-4822-estado-de-consola-visual-mantenimiento

Conflicts:
	pandora_console/include/visual-console-client/vc.main.min.js
	pandora_console/include/visual-console-client/vc.main.min.js.map
This commit is contained in:
Daniel Barbero 2022-10-14 11:03:11 +02:00
commit 004f5c4763
22 changed files with 125 additions and 117 deletions

View File

@ -187,7 +187,7 @@ if (!$double_auth_enabled
}) })
.show(); .show();
// Don't allow close the dialog with X button // Don't allow close the dialog with X button
$('.ui-dialog-titlebar-close').css('display', 'none'); // $('.ui-dialog-titlebar-close').css('display', 'none');
</script> </script>
<?php <?php

View File

@ -669,13 +669,12 @@ $table_advanced->data[2][3] = __('Max. Value');
$table_advanced->data[2][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); $table_advanced->data[2][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
$table_advanced->colspan[2][4] = 3; $table_advanced->colspan[2][4] = 3;
$table_advanced->data[3][0] = __('Dynamic Threshold Interval'); $table_advanced->data[3][0] = __('Dynamic Threshold Interval');
$table_advanced->data[3][1] = html_print_extended_select_for_time( $table_advanced->data[3][1] = html_print_extended_select_for_time(
'dynamic_interval', 'dynamic_interval',
$dynamic_interval, $dynamic_interval,
'', '',
'None', __('None'),
'0', '0',
10, 10,
true, true,

View File

@ -265,71 +265,75 @@ $delete_user = (bool) get_parameter('user_del', false);
if ($delete_user === true) { if ($delete_user === true) {
// Delete user. // Delete user.
$id_user = get_parameter('delete_user', 0); $id_user = get_parameter('delete_user', 0);
if (users_is_admin($id_user) === true && users_is_admin() === false) { if ($id_user !== 0) {
db_pandora_audit( if (users_is_admin($id_user) === true && users_is_admin() === false) {
AUDIT_LOG_ACL_VIOLATION,
'Trying to delete admininstrator user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
// Only allow delete user if is not the actual user.
if ($id_user != $config['id_user']) {
$user_row = users_get_user_by_id($id_user);
$result = delete_user($id_user);
if ($result) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT, AUDIT_LOG_ACL_VIOLATION,
__('Deleted user %s', io_safe_output($id_user)) 'Trying to delete admininstrator user by non administrator user '.$config['id_user']
); );
include 'general/noaccess.php';
exit;
} }
ui_print_result_message( // Only allow delete user if is not the actual user.
$result, if ($id_user != $config['id_user']) {
__('Successfully deleted'), $user_row = users_get_user_by_id($id_user);
__('There was a problem deleting the user')
);
// Delete the user in all the consoles. $result = delete_user($id_user);
if (is_metaconsole() === true && isset($_GET['delete_all'])) {
$servers = metaconsole_get_servers(); if ($result) {
foreach ($servers as $server) { db_pandora_audit(
// Connect to the remote console. AUDIT_LOG_USER_MANAGEMENT,
if (metaconsole_connect($server) === NOERR) { __('Deleted user %s', io_safe_output($id_user))
// Delete the user. );
$result = delete_user($id_user); }
ui_print_result_message(
$result,
__('Successfully deleted'),
__('There was a problem deleting the user')
);
// Delete the user in all the consoles.
if (is_metaconsole() === true && isset($_GET['delete_all'])) {
$servers = metaconsole_get_servers();
foreach ($servers as $server) {
// Connect to the remote console.
if (metaconsole_connect($server) === NOERR) {
// Delete the user.
$result = delete_user($id_user);
if ($result) {
db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT,
__('Deleted user %s from metaconsole', io_safe_input($id_user))
);
}
// Restore the db connection.
metaconsole_restore_db();
}
// Log to the metaconsole too.
if ($result) { if ($result) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT, AUDIT_LOG_USER_MANAGEMENT,
__('Deleted user %s from metaconsole', io_safe_input($id_user)) __('Deleted user %s from %s', io_safe_input($id_user), io_safe_input($server['server_name']))
); );
} }
// Restore the db connection. ui_print_result_message(
metaconsole_restore_db(); $result,
} __('Successfully deleted from %s', io_safe_input($server['server_name'])),
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
// Log to the metaconsole too.
if ($result) {
db_pandora_audit(
AUDIT_LOG_USER_MANAGEMENT,
__('Deleted user %s from %s', io_safe_input($id_user), io_safe_input($server['server_name']))
); );
} }
ui_print_result_message(
$result,
__('Successfully deleted from %s', io_safe_input($server['server_name'])),
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
);
} }
} else {
ui_print_error_message(__('There was a problem deleting the user'));
} }
} else { } else {
ui_print_error_message(__('There was a problem deleting the user')); ui_print_error_message(__('ID user cannot be empty'));
} }
} else if (isset($_GET['profile_del'])) { } else if (isset($_GET['profile_del'])) {
// Delete profile. // Delete profile.
@ -586,6 +590,10 @@ $rowPair = true;
$iterator = 0; $iterator = 0;
$cont = 0; $cont = 0;
foreach ($info as $user_id => $user_info) { foreach ($info as $user_id => $user_info) {
if (empty($user_id) === true) {
continue;
}
// User profiles. // User profiles.
if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) { if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_field_filter( $user_profiles = db_get_all_rows_field_filter(

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -9499,14 +9499,16 @@ function api_set_new_user($id, $thrash2, $other, $thrash3)
{ {
global $config; global $config;
// if (defined ('METACONSOLE')) {
// return;
// }
if (!check_acl($config['id_user'], 0, 'UM')) { if (!check_acl($config['id_user'], 0, 'UM')) {
returnError('forbidden', 'string'); returnError('forbidden', 'string');
return; return;
} }
if (empty($id) === true) {
returnError('Id cannot be empty.');
return;
}
$idk = get_header('idk'); $idk = get_header('idk');
if (is_management_allowed($idk) === false) { if (is_management_allowed($idk) === false) {
returnError('centralized'); returnError('centralized');
@ -9528,6 +9530,11 @@ function api_set_new_user($id, $thrash2, $other, $thrash3)
$values['section'] = $other['data'][11]; $values['section'] = $other['data'][11];
$values['session_time'] = $other['data'][12]; $values['session_time'] = $other['data'][12];
if (empty($password) === true) {
returnError('Password cannot be empty.');
return;
}
if (!create_user($id, $password, $values)) { if (!create_user($id, $password, $values)) {
returnError('The user could not created'); returnError('The user could not created');
} else { } else {
@ -11734,14 +11741,16 @@ function api_set_delete_user($id, $thrash1, $thrash2, $thrash3)
{ {
global $config; global $config;
// if (defined ('METACONSOLE')) {
// return;
// }
if (!check_acl($config['id_user'], 0, 'UM')) { if (!check_acl($config['id_user'], 0, 'UM')) {
returnError('forbidden', 'string'); returnError('forbidden', 'string');
return; return;
} }
if (empty($id) === true) {
returnError('Id cannot be empty.');
return;
}
$idk = get_header('idk'); $idk = get_header('idk');
if (is_management_allowed($idk) === false) { if (is_management_allowed($idk) === false) {
returnError('centralized'); returnError('centralized');

View File

@ -784,14 +784,7 @@ function config_update_config()
case 'perf': case 'perf':
// PERFORMANCE SETUP. // PERFORMANCE SETUP.
if (config_update_value('event_purge', get_parameter('event_purge'), true) === false) { if (config_update_value('event_purge', get_parameter('event_purge'), true) === false) {
$check_metaconsole_events_history = get_parameter('metaconsole_events_history', -1); $error_update[] = __('Event purge');
$error_update[] = $check_metaconsole_events_history;
}
if ($check_metaconsole_events_history != -1) {
if (config_update_value('metaconsole_events_history', get_parameter('metaconsole_events_history'), true) === false) {
$error_update[] = __('Max. days before delete events');
}
} }
if (config_update_value('trap_purge', get_parameter('trap_purge'), true) === false) { if (config_update_value('trap_purge', get_parameter('trap_purge'), true) === false) {
@ -2107,10 +2100,6 @@ function config_process_config()
config_update_value('event_purge', 15); config_update_value('event_purge', 15);
} }
if (!isset($config['metaconsole_events_history'])) {
config_update_value('metaconsole_events_history', 0);
}
if (!isset($config['realtimestats'])) { if (!isset($config['realtimestats'])) {
config_update_value('realtimestats', 1); config_update_value('realtimestats', 1);
} }

View File

@ -1472,7 +1472,6 @@ function events_get_all(
// Secondary groups. // Secondary groups.
$event_lj = ''; $event_lj = '';
if (!$user_is_admin || ($user_is_admin && isset($groups) === true && $groups > 0)) { if (!$user_is_admin || ($user_is_admin && isset($groups) === true && $groups > 0)) {
db_process_sql('SET group_concat_max_len = 9999999');
if ((bool) $filter['search_secondary_groups'] === true) { if ((bool) $filter['search_secondary_groups'] === true) {
$event_lj = events_get_secondary_groups_left_join($table); $event_lj = events_get_secondary_groups_left_join($table);
} }
@ -1486,6 +1485,8 @@ function events_get_all(
unset($fields[$idx]); unset($fields[$idx]);
} }
db_process_sql('SET group_concat_max_len = 9999999');
$group_selects = sprintf( $group_selects = sprintf(
',COUNT(id_evento) AS event_rep, ',COUNT(id_evento) AS event_rep,
%s %s
@ -1694,7 +1695,7 @@ function events_get_all(
$result_meta = Promise\wait( $result_meta = Promise\wait(
parallelMap( parallelMap(
$metaconsole_connections, $metaconsole_connections,
function ($node_int) use ($sql) { function ($node_int) use ($sql, $history) {
try { try {
if (is_metaconsole() === true if (is_metaconsole() === true
&& (int) $node_int > 0 && (int) $node_int > 0
@ -1703,7 +1704,7 @@ function events_get_all(
$node->connect(); $node->connect();
} }
$res = db_get_all_rows_sql($sql); $res = db_get_all_rows_sql($sql, $history);
if ($res === false) { if ($res === false) {
$res = []; $res = [];
} }
@ -1834,7 +1835,7 @@ function events_get_all(
} }
} }
return db_get_all_rows_sql($sql); return db_get_all_rows_sql($sql, $history);
} }

View File

@ -2070,7 +2070,7 @@ function html_print_extended_select_for_time(
$custom_fields=false, $custom_fields=false,
$style_icon='', $style_icon='',
$no_change=false, $no_change=false,
$allow_zero=false $allow_zero=0
) { ) {
global $config; global $config;
$admin = is_user_admin($config['id_user']); $admin = is_user_admin($config['id_user']);
@ -2084,32 +2084,21 @@ function html_print_extended_select_for_time(
$fields['-2'] = __('No change'); $fields['-2'] = __('No change');
} }
if (! $selected) { if (empty($selected) === false
foreach ($fields as $t_key => $t_value) { && $selected !== '0'
if ($t_key != -1) { && isset($fields[$selected]) === false
if ($nothing == '') { ) {
// -1 means 'custom' $allow_zero = false;
$selected = $t_key;
break;
} else {
$selected = $nothing;
break;
}
}
}
}
// Allow the use of the value zero.
if ($allow_zero === true) {
$selected_zero = true;
} else {
$selected_zero = ($selected != 0) ? true : false;
}
if (($selected !== false) && (!isset($fields[$selected]) && $selected_zero)) {
$fields[$selected] = human_time_description_raw($selected, true); $fields[$selected] = human_time_description_raw($selected, true);
} }
if (empty($nothing) === true
&& (empty($selected) === true
|| $selected === '0')
) {
$selected = 300;
}
$units = [ $units = [
1 => __('seconds'), 1 => __('seconds'),
SECONDS_1MINUTE => __('minutes'), SECONDS_1MINUTE => __('minutes'),
@ -2175,14 +2164,23 @@ function html_print_extended_select_for_time(
$uniq_name.'_units', $uniq_name.'_units',
'1', '1',
''.$script, ''.$script,
$nothing, '',
$nothing_value, 0,
false, false,
false, false,
false, false,
$class, $class,
$readonly, $readonly,
'font-size: xx-small;'.$select_style 'padding: 7px 3px;'.$select_style,
false,
false,
false,
'',
false,
false,
false,
false,
false
); );
echo ' <a href="javascript:">'.html_print_image( echo ' <a href="javascript:">'.html_print_image(
'images/list.png', 'images/list.png',
@ -2197,7 +2195,7 @@ function html_print_extended_select_for_time(
echo '</div>'; echo '</div>';
echo "<script type='text/javascript'> echo "<script type='text/javascript'>
$(document).ready (function () { $(document).ready (function () {
period_select_init('".$uniq_name."', ".(($allow_zero) ? 'true' : 'null')."); period_select_init('".$uniq_name."', ".(($allow_zero) ? 1 : 0).");
period_select_events('".$uniq_name."'); period_select_events('".$uniq_name."');
}); });
function period_select_".$name."_update(seconds) { function period_select_".$name."_update(seconds) {

View File

@ -886,7 +886,6 @@ function period_select_init(name, allow_zero) {
// Manual mode is hidden by default // Manual mode is hidden by default
$("#" + name + "_manual").css("display", "none"); $("#" + name + "_manual").css("display", "none");
$("#" + name + "_default").css("display", "inline"); $("#" + name + "_default").css("display", "inline");
// If the text input is empty, we put on it 5 minutes by default // If the text input is empty, we put on it 5 minutes by default
if ($("#text-" + name + "_text").val() == "") { if ($("#text-" + name + "_text").val() == "") {
$("#text-" + name + "_text").val(300); $("#text-" + name + "_text").val(300);
@ -897,7 +896,7 @@ function period_select_init(name, allow_zero) {
} else { } else {
$("#" + name + "_select option:eq(1)").prop("selected", true); $("#" + name + "_select option:eq(1)").prop("selected", true);
} }
} else if ($("#text-" + name + "_text").val() == 0 && allow_zero != true) { } else if ($("#text-" + name + "_text").val() == 0 && allow_zero == 1) {
$("#" + name + "_units option:last").prop("selected", false); $("#" + name + "_units option:last").prop("selected", false);
$("#" + name + "_manual").css("display", "inline"); $("#" + name + "_manual").css("display", "inline");
$("#" + name + "_default").css("display", "none"); $("#" + name + "_default").css("display", "none");
@ -1041,10 +1040,10 @@ function adjustTextUnits(name) {
var restInt = parseInt(rest).toString(); var restInt = parseInt(rest).toString();
if (rest != restInt && unitsSelected == false) { if (rest != restInt && unitsSelected == false) {
$("#" + name + "_units option:eq(" + ($(this).index() - 1) + ")").prop( var value_selected = $(
"selected", "#" + name + "_units option:eq(" + ($(this).index() - 1) + ")"
true ).val();
); $("#" + name + "_units").val(value_selected);
$("#text-" + name + "_text").val(restPrev); $("#text-" + name + "_text").val(restPrev);
unitsSelected = true; unitsSelected = true;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1475,7 +1475,9 @@ if ($pure) {
} }
// If the history event is not enabled, dont show the history tab. // If the history event is not enabled, dont show the history tab.
if (isset($config['metaconsole_events_history']) === false || $config['metaconsole_events_history'] != 1) { if (isset($config['history_db_enabled']) === false
|| (bool) $config['history_db_enabled'] === false
) {
unset($onheader['history']); unset($onheader['history']);
} }

View File

@ -660,7 +660,6 @@ sub pandora_load_config_pdb ($) {
$conf->{'_delete_old_network_matrix'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_network_matrix'"); $conf->{'_delete_old_network_matrix'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_network_matrix'");
$conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'"); $conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'");
$conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'"); $conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'");
$conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'");
$conf->{'_netflow_max_lifetime'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_max_lifetime'"); $conf->{'_netflow_max_lifetime'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_max_lifetime'");
$conf->{'_netflow_nfexpire'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_nfexpire'"); $conf->{'_netflow_nfexpire'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_nfexpire'");
$conf->{'_netflow_path'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_path'"); $conf->{'_netflow_path'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'netflow_path'");

View File

@ -525,17 +525,21 @@ export default class Clock extends Item<ClockProps> {
const element: HTMLDivElement = document.createElement("div"); const element: HTMLDivElement = document.createElement("div");
element.className = "digital-clock"; element.className = "digital-clock";
const { width } = this.getElementSize(); // Destructuring assigment: http://es6-features.org/#ObjectMatchingShorthandNotation const { width, height } = this.getElementSize(); // Destructuring assigment: http://es6-features.org/#ObjectMatchingShorthandNotation
let modified = width;
if (height < width) {
modified = height;
}
// Calculate font size to adapt the font to the item size. // Calculate font size to adapt the font to the item size.
const baseTimeFontSize = 20; // Per 100px of width. const baseTimeFontSize = 35; // Per 100px of width.
const dateFontSizeMultiplier = 0.5; const dateFontSizeMultiplier = 0.5;
const tzFontSizeMultiplier = 6 / this.props.clockTimezone.length; const tzFontSizeMultiplier = 6 / this.props.clockTimezone.length;
const timeFontSize = (baseTimeFontSize * width) / 100; const timeFontSize = (baseTimeFontSize * modified) / 100;
const dateFontSize = const dateFontSize =
(baseTimeFontSize * dateFontSizeMultiplier * width) / 100; (baseTimeFontSize * dateFontSizeMultiplier * modified) / 100;
const tzFontSize = Math.min( const tzFontSize = Math.min(
(baseTimeFontSize * tzFontSizeMultiplier * width) / 100, (baseTimeFontSize * tzFontSizeMultiplier * modified) / 100,
(width / 100) * 10 (width / 100) * 10
); );