diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 0872461011..56ffc6fe23 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -1,11 +1,11 @@ '; echo '
'; // Custom ID. @@ -225,6 +222,14 @@ if (is_array($modules) === true) { } } +// Remote configuration available. +if (isset($filename) === true && file_exists($filename['md5']) === true) { + $remote_agent = true; + $agent_md5 = md5(io_safe_output(agents_get_name($id_agente)), false); +} else { + $remote_agent = false; +} + // Get Servers. $servers = servers_get_names(); // Set the agent have not server. @@ -239,6 +244,105 @@ if ($new_agent === true) { $server_name = reset($array_keys_servers_get_names); } + +// QR Code table. +if ($new_agent === false) { + $CodeQRContent = '

'.__('QR Code Agent view').'

'; + $CodeQRContent .= html_print_div(['id' => 'qr_container_image'], true); + $CodeQRContent .= html_print_anchor( + [ + 'id' => 'qr_code_agent_view', + 'href' => ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente), + ], + true + ); + $CodeQRContent .= '
'.$custom_id_div; + + // QR code div. + $CodeQRTable = html_print_div( + [ + 'class' => 'box-shadow white_box agent_qr', + 'content' => $CodeQRContent, + ], + true + ); +} else { + $CodeQRTable = ''; +} + +// Advanced mode. +if (enterprise_installed() === true) { + // Safe operation mode. + if ($new_agent === false) { + $sql_modules = db_get_all_rows_sql( + 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo + WHERE id_agente = '.$id_agente + ); + $safe_mode_modules = []; + $safe_mode_modules[0] = __('Any'); + if (is_array($sql_modules) === true) { + foreach ($sql_modules as $m) { + $safe_mode_modules[$m['id_module']] = $m['name']; + } + } + } + + // Calculate cps value - agents. + if ($new_agent === false) { + $cps_val = service_agents_cps($id_agente); + } else { + // No agent defined, use received cps as base value. + if ($cps >= 0) { + $cps_val = $cps; + } + } + + // Parent agents. + $paramsParentAgent = []; + $paramsParentAgent['return'] = true; + $paramsParentAgent['show_helptip'] = true; + $paramsParentAgent['input_name'] = 'id_parent'; + $paramsParentAgent['print_hidden_input_idagent'] = true; + $paramsParentAgent['hidden_input_idagent_name'] = 'id_agent_parent'; + $paramsParentAgent['hidden_input_idagent_value'] = $id_parent; + $paramsParentAgent['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent); + $paramsParentAgent['selectbox_id'] = 'cascade_protection_module'; + $paramsParentAgent['javascript_is_function_select'] = true; + $paramsParentAgent['cascade_protection'] = true; + if ($id_agente !== 0) { + // Deletes the agent's offspring. + $paramsParentAgent['delete_offspring_agents'] = $id_agente; + } +} + +$listIcons = gis_get_array_list_icons(); + +$arraySelectIcon = []; +foreach ($listIcons as $index => $value) { + $arraySelectIcon[$index] = $index; +} + +// Agent icons. +$path = 'images/gis_map/icons/'; +// TODO set better method the path. +$table_adv_agent_icon = '

'.__('Agent icon').'

'; +if ($icon_path == '') { + $display_icons = 'none'; + // Hack to show no icon. Use any given image to fix not found image errors. + $path_without = 'images/spinner.gif'; + $path_default = 'images/spinner.gif'; + $path_ok = 'images/spinner.gif'; + $path_bad = 'images/spinner.gif'; + $path_warning = 'images/spinner.gif'; +} else { + $display_icons = ''; + $path_without = $path.$icon_path.'.default.png'; + $path_default = $path.$icon_path.'.default.png'; + $path_ok = $path.$icon_path.'.ok.png'; + $path_bad = $path.$icon_path.'.bad.png'; + $path_warning = $path.$icon_path.'.warning.png'; +} + $tableAgent = new stdClass(); $tableAgent->id = 'simple'; $tableAgent->class = 'w100p mrgn_10px'; @@ -247,16 +351,11 @@ $tableAgent->style = []; $tableAgent->cellclass = []; $tableAgent->colspan = []; $tableAgent->rowspan = []; -/* - $tableAgent->cellpadding = 2; - $tableAgent->cellspacing = 0; - $tableAgent->rowspan[3][2] = 3; - $tableAgent->rowspan[4][2] = 3; -*/ + // Agent name. if ($new_agent === false) { $tableAgent->data['name'][0] = __('Agent name'); - $tableAgent->data['name'][1] = html_print_input_text('agente', $nombre_agente, '', 80, 100, true); + $tableAgent->data['name'][1] = html_print_input_text('agente', $nombre_agente, '', 76, 100, true); $tableAgent->data['name'][1] .= html_print_div( [ 'class' => 'moduleIdBox', @@ -271,10 +370,25 @@ if ($new_agent === false) { // Alias. $tableAgent->data['alias'][0] = __('Alias'); $tableAgent->data['alias'][1] = html_print_input_text('alias', $alias, '', 50, 100, true, false, true); - if ($new_agent === true) { $tableAgent->data['alias'][2] = __('Use alias as name'); $tableAgent->data['alias'][3] = html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true); +} else { + $tableAgent->data['alias'][2] = html_print_anchor( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$id_agente.'&disk_conf='.$agent_md5, + 'content' => html_print_image( + 'images/application_edit.png', + true, + [ + 'border' => 0, + 'title' => __('This agent can be remotely configured'), + 'class' => 'invert_filter', + ] + ), + ], + true + ); } // Ip adress. @@ -323,14 +437,18 @@ if (isset($groups[$grupo]) === true || $new_agent === true) { $tableAgent->data['primary_group'][1] .= html_print_input_hidden('grupo', $grupo, true); } -$tableAgent->data['primary_group'][1] .= '
'; -if ($id_agente === 0) { - $hidden = 'display: none;'; -} else { - $hidden = ''; -} - -$tableAgent->data['primary_group'][1] .= ui_print_group_icon($grupo, true, 'groups_small', $hidden); +$tableAgent->data['primary_group'][1] .= html_print_div( + [ + 'class' => 'mrgn_lft_5px', + 'content' => ui_print_group_icon( + $grupo, + true, + 'groups_small', + ($id_agente === 0) ? 'display: none;' : '' + ), + ], + true +); $tableAgent->data['interval'][0] = __('Interval'); $tableAgent->data['interval'][1] = html_print_extended_select_for_time( @@ -362,7 +480,12 @@ $tableAgent->data['os'][1] = html_print_select_from_sql( ); $tableAgent->data['os'][1] .= html_print_div( [ - 'content' => ''.ui_print_os_icon($id_os, false, true).'', + 'class' => 'mrgn_lft_5px', + 'content' => ui_print_os_icon( + $id_os, + false, + true + ), ], true ); @@ -379,202 +502,27 @@ $tableAgent->data['server'][1] = html_print_select( ); // Description. -$tableAgent->data['server'][0] = __('Description'); -$tableAgent->data['server'][1] = html_print_textarea( +$tableAgent->data['description'][0] = __('Description'); +$tableAgent->data['description'][1] = html_print_textarea( 'comentarios', 3, - 10, + 80, $comentarios, '', true, 'agent_description' ); -html_print_table($tableAgent); - -if (!$new_agent && $alias != '') { - $table_agent_name = '

'.__('Agent name').'

'; - $table_agent_name .= '
'; - $table_agent_name .= '
'.html_print_input_text('agente', $nombre_agente, '', 50, 100, true).'
'; - $table_agent_name .= '
'; - - if ($id_agente) { - $table_agent_name .= ''; - $table_agent_name .= ''; - $table_agent_name .= html_print_image( - 'images/zoom.png', - true, - [ - 'border' => 0, - 'title' => __('Agent detail'), - 'class' => 'invert_filter', - ] - ); - $table_agent_name .= ''; - } - - // Remote configuration available. - $remote_agent = false; - if (isset($filename)) { - if (file_exists($filename['md5'])) { - $remote_agent = true; - - $agent_name = agents_get_name($id_agente); - $agent_name = io_safe_output($agent_name); - $agent_md5 = md5($agent_name, false); - - $table_agent_name .= ''; - $table_agent_name .= html_print_image( - 'images/application_edit.png', - true, - [ - 'border' => 0, - 'title' => __('This agent can be remotely configured'), - 'class' => 'invert_filter', - ] - ); - $table_agent_name .= ''; - } - } - - $table_agent_name .= '
'; - - // QR code div. - $table_qr_code = '
'; - $table_qr_code .= '

'.__('QR Code Agent view').'

'; - $table_qr_code .= '
'; - if ($id_agente) { - $table_qr_code .= ""; - } - - // Add Custom id div. - $table_qr_code .= '
'; - $table_qr_code .= $custom_id_div; - $table_qr_code .= '
'; -} - -/* - if ($new_agent) { - $label_select_child_left = 'label_select_child_left'; - $label_select_parent = 'label_select_parent'; - } - - $table_alias = '

'.__('Alias').'

'; - $table_alias .= '
'; - $table_alias .= '
'.html_print_input_text('alias', $alias, '', 50, 100, true, false, true).'
'; - if ($new_agent) { - $table_alias .= '
'.html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name').'
'; - } - - $table_alias .= '
'; -*/ -/* - $table_ip = '

'.__('IP Address').'

'; - $table_ip .= '
'; - $table_ip .= '
'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'
'; - $table_ip .= '
'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').'
'; - $table_ip .= '
'.html_print_input( +html_print_div( [ - 'type' => 'switch', - 'id' => 'fixed_ip', - 'name' => 'fixed_ip', - 'value' => $fixed_ip, + 'class' => 'box-shadow white_table_graph white_box', + 'style' => 'display: flex; justify-content: space-between; align-items: flex-start;', + 'content' => html_print_table($tableAgent, true).$CodeQRTable, ] - ).__('Fix IP address').ui_print_help_tip(__('Avoid automatic IP address update when agent IP changes.'), true).'
'; - -$table_ip .= '
';*/ +); /* - if ($id_agente) { - $ip_all = agents_get_addresses($id_agente); - - $table_ip .= '
'; - $table_ip .= '
'; - $table_ip .= '
'.html_print_select($ip_all, 'address_list', $direccion_agente, '', '', 0, true).'
'; - $table_ip .= '
'.html_print_checkbox_switch('delete_ip', 1, false, true).__('Delete selected IPs').'
'; - $table_ip .= '
'; -}*/ - -?> - -

'.__('Primary group').'

'; - $table_primary_group .= '
'; - // Cannot change primary group if user have not permission for that group. - if (isset($groups[$grupo]) || $new_agent) { - $table_primary_group .= html_print_input( - [ - 'type' => 'select_groups', - 'returnAllGroup' => false, - 'name' => 'grupo', - 'selected' => $grupo, - 'return' => true, - 'required' => true, - 'privilege' => 'AW', - ] - ); - } else { - $table_primary_group .= groups_get_name($grupo); - $table_primary_group .= html_print_input_hidden('grupo', $grupo, true); - } - - $table_primary_group .= '
'; - if ($id_agente === 0) { - $hidden = 'display: none;'; - } else { - $hidden = ''; - } - - $table_primary_group .= ui_print_group_icon($grupo, true, 'groups_small', $hidden); - - $table_primary_group .= '
'; - - $table_interval = '

'.__('Interval').'

'; - $table_interval .= '
'; - $table_interval .= html_print_extended_select_for_time( - 'intervalo', - $intervalo, - '', - '', - '0', - 10, - true, - false, - true, - 'w40p' - ); - - - - if ($intervalo < SECONDS_5MINUTES) { - $table_interval .= clippy_context_help('interval_agent_min'); - } - - $table_interval .= '
'; - - $table_os = '

'.__('OS').'

'; - $table_os .= '
'; - $table_os .= html_print_select_from_sql( - 'SELECT id_os, name FROM tconfig_os', - 'id_os', - $id_os, - '', - '', - '0', - true - ); - $table_os .= '
'; - $table_os .= ui_print_os_icon($id_os, false, true); - $table_os .= '
'; -*/ - - -$table_satellite = ''; -if ($remote_agent === true) { + $table_satellite = ''; + if ($remote_agent === true) { // Satellite server selector. $satellite_servers = db_get_all_rows_filter( 'tserver', @@ -606,122 +554,39 @@ if ($remote_agent === true) { ] ).'
'; } -} - - - -// QR code. -echo '
-
-
'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'
-
'.$table_interval.$table_os.$table_server.$table_satellite.$table_description.'
-
'; -if (!$new_agent && $alias != '') { - echo $table_qr_code; -} - -echo '
'; - -if (enterprise_installed()) { - $adv_secondary_groups_label = '
'; - $adv_secondary_groups_label .= '

'; - $adv_secondary_groups_label .= __('Secondary groups'); - $adv_secondary_groups_label .= '

'; - $adv_secondary_groups_label .= '
'; - $select_agent_secondary = html_print_select_agent_secondary( - $agent, - $id_agente - ); - - // Safe operation mode. - if ($id_agente) { - $sql_modules = db_get_all_rows_sql( - 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo - WHERE id_agente = '.$id_agente - ); - $safe_mode_modules = []; - $safe_mode_modules[0] = __('Any'); - if (is_array($sql_modules)) { - foreach ($sql_modules as $m) { - $safe_mode_modules[$m['id_module']] = $m['name']; - } - } - - $table_adv_safe = '

'.__('Safe operation mode').'

'; - $table_adv_safe .= html_print_checkbox_switch('safe_mode', 1, $safe_mode, true); - $table_adv_safe .= __('Module').' '.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true).'
'; } +*/ - // Remote configuration. - $table_adv_remote = '

'.__('Remote configuration').'

'; - - if (!$new_agent && isset($filename) && file_exists($filename['md5'])) { - $table_adv_remote .= date('F d Y H:i:s', fileatime($filename['md5'])); - // Delete remote configuration. - $table_adv_remote .= ''; - $table_adv_remote .= html_print_image( - 'images/cross.png', - true, - [ - 'title' => __('Delete remote configuration file'), - 'style' => 'vertical-align: middle;', - 'class' => 'invert_filter', - ] - ).''; - $table_adv_remote .= ''; - } else { - $table_adv_remote .= ''.__('Not available').''; - } - - $table_adv_remote .= '
'; - - - // Calculate cps value - agents. - if ($id_agente) { - $cps_val = service_agents_cps($id_agente); - } else { - // No agent defined, use received cps as base value. - if ($cps >= 0) { - $cps_val = $cps; - } - } - - $cps_html = '
'; - $cps_html .= html_print_checkbox_switch('cps', $cps_val, ($cps >= 0), true); - $cps_html .= __('Cascade protection services').' '; - $cps_html .= '
'; - - $table_adv_cascade .= $cps_html; -} - -$table_adv_parent = '
'; -$params = []; -$params['return'] = true; -$params['show_helptip'] = true; -$params['input_name'] = 'id_parent'; -$params['print_hidden_input_idagent'] = true; -$params['hidden_input_idagent_name'] = 'id_agent_parent'; -$params['hidden_input_idagent_value'] = $id_parent; -$params['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent); -$params['selectbox_id'] = 'cascade_protection_module'; -$params['javascript_is_function_select'] = true; -$params['cascade_protection'] = true; -if ($id_agente !== 0) { - // Deletes the agent's offspring. - $params['delete_offspring_agents'] = $id_agente; -} - -$table_adv_parent .= '
'; -$table_adv_parent .= ui_print_agent_autocomplete_input($params); -if (enterprise_installed()) { - $table_adv_parent .= html_print_checkbox_switch( +// Advanced options. +$tableAdvancedAgent = new stdClass(); +$tableAdvancedAgent->id = 'advanced'; +$tableAdvancedAgent->class = 'w100p mrgn_10px'; +$tableAdvancedAgent->data = []; +$tableAdvancedAgent->style = []; +$tableAdvancedAgent->cellclass = []; +$tableAdvancedAgent->colspan = []; +$tableAdvancedAgent->rowspan = []; +// Secondary groups. +$tableAdvancedAgent->data['secondary_groups'][0] = __('Secondary groups'); +$tableAdvancedAgent->data['secondary_groups'][1] = html_print_select_agent_secondary( + $agent, + $id_agente +); +// Parent agent. +$tableAdvancedAgent->data['parent_agent'][0] = __('Parent'); +$tableAdvancedAgent->data['parent_agent'][1] = ui_print_agent_autocomplete_input($paramsParentAgent); +if (enterprise_installed() === true) { + $tableAdvancedAgent->rowclass['cascade_protection'] = 'bring_next_field'; + $tableAdvancedAgent->data['cascade_protection'][0] = __('Cascade protection modules'); + $tableAdvancedAgent->data['cascade_protection'][1] = html_print_checkbox_switch( 'cascade_protection', 1, $cascade_protection, true - ).__('Cascade protection').' '; + ); - $table_adv_parent .= __('Module').' '.html_print_select( + $tableAdvancedAgent->data['cascade_module'][0] = ''; + $tableAdvancedAgent->data['cascade_module'][1] = html_print_select( $modules_values, 'cascade_protection_module', $cascade_protection_module, @@ -732,12 +597,9 @@ if (enterprise_installed()) { ); } -$table_adv_parent .= '
'; - -// Learn mode / Normal mode. -$table_adv_module_mode = '

'.__('Module definition').'

'; -$table_adv_module_mode .= '
'; -$table_adv_module_mode .= html_print_radio_button_extended( +// Module Definition (Learn mode). +$tableAdvancedAgent->data['module_definition'][0] = __('Module definition'); +$switchButtons = html_print_radio_button_extended( 'modo', 1, __('Learning mode'), @@ -747,7 +609,7 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= html_print_radio_button_extended( +$switchButtons .= html_print_radio_button_extended( 'modo', 0, __('Normal mode'), @@ -757,7 +619,7 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= html_print_radio_button_extended( +$switchButtons .= html_print_radio_button_extended( 'modo', 2, __('Autodisable mode'), @@ -767,82 +629,28 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= '
'; -// Status (Disabled / Enabled). -$table_adv_status = '
'; -$table_adv_status .= html_print_checkbox_switch( - 'disabled', - 1, - $disabled, +$tableAdvancedAgent->data['module_definition'][1] = html_print_div( + [ + 'class' => 'switch_radio_button', + 'content' => $switchButtons, + ], true ); -$table_adv_status .= '

'.__('Disabled mode').'

'; -$table_adv_status .= '
'; -// Url address. -if (enterprise_installed()) { - $table_adv_url = '

'.__('Url address').'

'; - $table_adv_url .= html_print_input_text( - 'url_description', - $url_description, - '', - 45, - 255, - true, - false, - false, - '', - '', - '', - // Autocomplete. - 'new-password' - ).'
'; -} else { - $table_adv_url = '

'.__('Url address').'

'; - $table_adv_url .= html_print_input_text( - 'url_description', - $url_description, - '', - 45, - 255, - true - ).''; +// CPS - Cascade Protection Services. +$tableAdvancedAgent->data['cps_value'][0] = __('Cascade protection services'); +$tableAdvancedAgent->data['cps_value'][1] = html_print_checkbox_switch('cps', $cps_val, ($cps >= 0), true); + +// Update GIS data. +if ((bool) $config['activate_gis'] === true) { + $tableAdvancedAgent->data['gis'][0] = __('Update new GIS data'); + $tableAdvancedAgent->data['gis'][1] = html_print_checkbox_switch('update_gis_data', 1, ($new_agent === true), true); } -$table_adv_quiet = '
'; -$table_adv_quiet .= html_print_checkbox_switch('quiet', 1, $quiet, true); -$table_adv_quiet .= '

'.__('Quiet').'

'; -$table_adv_quiet .= '
'; - -$listIcons = gis_get_array_list_icons(); - -$arraySelectIcon = []; -foreach ($listIcons as $index => $value) { - $arraySelectIcon[$index] = $index; -} - -$path = 'images/gis_map/icons/'; -// TODO set better method the path. -$table_adv_agent_icon = '

'.__('Agent icon').'

'; -if ($icon_path == '') { - $display_icons = 'none'; - // Hack to show no icon. Use any given image to fix not found image errors. - $path_without = 'images/spinner.gif'; - $path_default = 'images/spinner.gif'; - $path_ok = 'images/spinner.gif'; - $path_bad = 'images/spinner.gif'; - $path_warning = 'images/spinner.gif'; -} else { - $display_icons = ''; - $path_without = $path.$icon_path.'.default.png'; - $path_default = $path.$icon_path.'.default.png'; - $path_ok = $path.$icon_path.'.ok.png'; - $path_bad = $path.$icon_path.'.bad.png'; - $path_warning = $path.$icon_path.'.warning.png'; -} - -$table_adv_agent_icon .= html_print_select( +// Agent Icons. +$tableAdvancedAgent->data['agent_icon'][0] = __('Agent icon'); +$tableAdvancedAgent->data['agent_icon'][1] = html_print_select( $arraySelectIcon, 'icon_path', $icon_path, @@ -850,7 +658,8 @@ $table_adv_agent_icon .= html_print_select( __('None'), '', true -).html_print_image( +); +$tableAdvancedAgent->data['agent_icon'][2] = html_print_image( $path_ok, true, [ @@ -871,51 +680,88 @@ $table_adv_agent_icon .= html_print_select( 'id' => 'icon_warning', 'style' => 'display:'.$display_icons.';', ] -).'
'; +); -if ($config['activate_gis']) { - $table_adv_gis = '

'.__('Update new GIS data:').'

'; - if ($new_agent) { - $update_gis_data = true; - } - - $table_adv_gis .= html_print_checkbox_switch('update_gis_data', 1, $update_gis_data, true).'No / Yes
'; -} - - -if (enterprise_installed()) { - $advanced_div = '
'; +// Url address. +$tableAdvancedAgent->data['url_description'][0] = __('Url address'); +if (enterprise_installed() === true) { + $tableAdvancedAgent->data['url_description'][1] = html_print_input_text( + 'url_description', + $url_description, + '', + 45, + 255, + true, + false, + false, + '', + '', + '', + // Autocomplete. + 'new-password' + ); } else { - $advanced_div = ''; +// Agent status. +$tableAdvancedAgent->data['agent_status'][0] = __('Disabled mode'); +$tableAdvancedAgent->data['agent_status'][1] = html_print_checkbox_switch( + 'disabled', + 1, + $disabled, + true +); -$table_adv_options .= '
'; -$table_adv_options .= $table_adv_parent; -$table_adv_options .= $table_adv_module_mode; -$table_adv_options .= $table_adv_cascade; +// Quiet mode. +$tableAdvancedAgent->data['agent_quiet'][0] = __('Quiet'); +$tableAdvancedAgent->data['agent_quiet'][1] = html_print_checkbox_switch('quiet', 1, $quiet, true); -if ($new_agent) { - // If agent is new, show custom id as old style format. - $table_adv_options .= $custom_id_div; +// Remote configuration. +if ($new_agent === false && isset($filename) === true && file_exists($filename['md5']) === true) { + $tableAdvancedAgent->data['remote_configuration'][0] = __('Remote configuration'); + $tableAdvancedAgent->data['remote_configuration'][1] = html_print_input_text( + 'remote_file_timestamp', + date('F d Y H:i:s', fileatime($filename['md5'])), + '', + 45, + 255, + true, + true + ); + $tableAdvancedAgent->data['remote_configuration'][1] .= html_print_anchor( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/cross.png', + true, + [ + 'title' => __('Delete remote configuration file'), + 'class' => 'vertical_middle invert_filter mrgn_lft_5px', + ] + ), + ], + true + ); } -$table_adv_options .= '
'; +// Safe operation mode. +$tableAdvancedAgent->rowclass['safe_operation'] = 'bring_next_field'; +$tableAdvancedAgent->data['safe_operation'][0] = __('Safe operation mode'); +$tableAdvancedAgent->data['safe_operation'][1] = html_print_checkbox_switch('safe_mode', 1, $safe_mode, true); +$tableAdvancedAgent->data['safe_operation_module'][0] = ''; +$tableAdvancedAgent->data['safe_operation_module'][1] = html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true); -$table_adv_options .= ' -
- '.$table_adv_gis.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.' -
'; - -if (enterprise_installed()) { - echo '
'; +if (enterprise_installed() === true) { ui_toggle( - $table_adv_options, + html_print_table($tableAdvancedAgent, true), __('Advanced options'), '', '', @@ -924,21 +770,20 @@ if (enterprise_installed()) { 'white_box white_box_opened', 'no-border flex' ); - echo '
'; } -$table = new stdClass(); -$table->width = '100%'; -$table->class = 'custom_fields_table'; - -$table->head = [ - 0 => __('Click to display'), -]; -$table->class = 'info_table'; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->data = []; -$table->rowstyle = []; +// Custom fields. +/* + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'custom_fields_table'; + $table->class = ''; + $table->style = []; + $table->style[0] = 'font-weight: bold;'; + $table->data = []; + $table->rowstyle = []; +*/ +$customOutputData = ''; $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -946,13 +791,8 @@ if ($fields === false) { $fields = []; } -$i = 0; foreach ($fields as $field) { - $id_custom_field = $field['id_field']; - - $data[0] = '
'; - $data[0] .= ''.$field['name'].''; - $data[0] .= '
'; + // Filling the data. $combo = []; $combo = $field['combo_values']; $combo = explode(',', $combo); @@ -974,15 +814,8 @@ foreach ($fields as $field) { $custom_value = ''; } - $table->rowstyle[$i] = 'cursor: pointer;user-select: none;'; - if (!empty($custom_value)) { - $table->rowstyle[($i + 1)] = 'display: table-row;'; - } else { - $table->rowstyle[($i + 1)] = 'display: none;'; - } - - if ($field['is_password_type']) { - $data_field[1] = html_print_input_text_extended( + if ((bool) $field['is_password_type'] === true) { + $customContent = html_print_input_text_extended( 'customvalue_'.$field['id_field'], $custom_value, 'customvalue_'.$field['id_field'], @@ -996,7 +829,7 @@ foreach ($fields as $field) { true ); } else { - $data_field[1] = html_print_textarea( + $customContent = html_print_textarea( 'customvalue_'.$field['id_field'], 2, 65, @@ -1006,8 +839,8 @@ foreach ($fields as $field) { ); } - if ($field['combo_values'] !== '') { - $data_field[1] = html_print_input( + if (empty($field['combo_values']) === false) { + $customContent = html_print_input( [ 'type' => 'select_search', 'fields' => $combo_values, @@ -1023,61 +856,32 @@ foreach ($fields as $field) { ); }; - $table->rowid[] = 'name_field-'.$id_custom_field; - $table->data[] = $data; - - $table->rowid[] = 'field-'.$id_custom_field; - $table->data[] = $data_field; - $i += 2; + $customOutputData .= ui_toggle( + html_print_div( + [ 'content' => $customContent ], + true + ), + $field['name'], + $field['name'], + 'custom_field_toggle_'.$field['id_field'], + true, + true, + ); } -if (enterprise_installed()) { - if (!empty($fields)) { - echo '
'; - ui_toggle( - html_print_table($table, true), - __('Custom fields'), - '', - '', - true, - false, - 'white_box white_box_opened', - 'no-border' - ); - echo '
'; - } -} else { - echo '
'; +if (empty($fields) === false) { ui_toggle( - $table_adv_options, - __('Advanced options'), + $customOutputData, + __('Custom fields'), '', '', true, false, 'white_box white_box_opened', - 'no-border flex' + 'no-border custom_fields_elements' ); - if (!empty($fields)) { - ui_toggle( - html_print_table($table, true), - __('Custom fields'), - '', - '', - true, - false, - 'white_box white_box_opened', - 'no-border' - ); - } - - echo '
'; - - echo '
'; } -echo '
'; - // The context help about the learning mode. if ($modo == 0) { echo ""; @@ -1131,6 +935,7 @@ html_print_div( ] ); +echo '
'; echo ''; ui_require_jquery_file('pandora.controls'); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index cffa073369..9caed29db0 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2210,8 +2210,8 @@ if ($disable_module) { } // UPDATE GIS. -$updateGIS = get_parameter('update_gis', 0); -if ($updateGIS) { +$updateGIS = (bool) get_parameter('update_gis', 0); +if ($updateGIS === true) { $updateGisData = get_parameter('update_gis_data'); $lastLatitude = get_parameter('latitude'); $lastLongitude = get_parameter('longitude'); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 4ed02e8df7..14f8e7b12c 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2124,35 +2124,40 @@ function html_print_extended_select_for_time( ob_start(); // Use the no_meta parameter because this image is only in the base console. echo '
'; - html_print_select( - $fields, - $uniq_name.'_select', - $selected, - ''.$script, - $nothing, - $nothing_value, - false, - false, - false, - $class, - $readonly, - 'font-size: xx-small;'.$select_style - ); + html_print_select( + $fields, + $uniq_name.'_select', + $selected, + ''.$script, + $nothing, + $nothing_value, + false, + false, + false, + $class, + $readonly, + 'font-size: xx-small;'.$select_style + ); // The advanced control is only for admins. - if ($admin) { - echo ' '.html_print_image( - 'images/pencil.png', - true, + if ($admin === true) { + html_print_anchor( [ - 'class' => $uniq_name.'_toggler '.$class.' invert_filter', - 'alt' => __('Custom'), - 'title' => __('Custom'), - 'style' => 'width: 18px; margin-bottom: -5px;'.$style_icon, - ], - false, - false, - true - ).''; + 'href' => 'javascript:', + 'content' => html_print_image( + 'images/pencil.png', + true, + [ + 'class' => $uniq_name.'_toggler '.$class.' invert_filter', + 'alt' => __('Custom'), + 'title' => __('Custom'), + 'style' => 'width: 18px; margin-bottom: -5px; margin-left: 10px'.$style_icon, + ], + false, + false, + true, + ), + ] + ); } echo '
'; @@ -6132,7 +6137,7 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) [$id_agente] ); - $name = 'secondary_groups'.$options['extra_id']; + $name = 'secondary_groups_selected'.$options['extra_id']; if ($options['only_select'] === true) { $name = 'secondary_groups'.$options['extra_id'].'[]'; } @@ -6152,7 +6157,7 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) $name, // Selected. // No select any by default. - '', + $secondary_groups_selected['for_select'], // Script. // Javascript onChange code. '', @@ -6179,7 +6184,7 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) false, // Style. // Inline styles (default). - 'min-width:170px;', + '', // Option_style. // Option style select (default). false, @@ -6212,8 +6217,8 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) ] ) ); - - $adv_secondary_groups_arrows = html_print_input_image( + /* + $adv_secondary_groups_arrows = html_print_input_image( 'add_secondary', 'images/darrowright_green.png', 1, @@ -6224,9 +6229,9 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) 'title' => __('Add secondary groups'), 'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');', ] - ); + ); - $adv_secondary_groups_arrows .= html_print_input_image( + $adv_secondary_groups_arrows .= html_print_input_image( 'remove_secondary', 'images/darrowleft_green.png', 1, @@ -6237,10 +6242,10 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) 'title' => __('Remove secondary groups'), 'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');', ] - ); + ); - $adv_secondary_groups_right .= html_print_select( - // Values. + $adv_secondary_groups_right .= html_print_select( + // Values. $secondary_groups_selected['for_select'], // HTML id. 'secondary_groups_selected'.$options['extra_id'], @@ -6264,8 +6269,8 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) false, // Style. 'min-width:170px;' - ); - + ); + */ $output = ''; if (isset($options['container']) === true && $options['container'] === true @@ -6276,13 +6281,14 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) $output .= '
'; $output .= $adv_secondary_groups_left; $output .= '
'; - $output .= '
'; - $output .= $adv_secondary_groups_arrows; - $output .= '
'; - $output .= '
'; - $output .= $adv_secondary_groups_right; - $output .= '
'; - + /* + $output .= '
'; + $output .= $adv_secondary_groups_arrows; + $output .= '
'; + $output .= '
'; + $output .= $adv_secondary_groups_right; + $output .= '
'; + */ if (isset($options['container']) === true && $options['container'] === true ) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 029b0d70b6..6a855b1781 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -5724,7 +5724,7 @@ function reporting_get_agents_by_status($data, $graph_width=250, $graph_height=1 $agent_data = []; $agent_data[0] = html_print_image('images/agent_ok.png', true, ['title' => __('Agents ok')]); - $agent_data[1] = "".format_numeric($data['agent_ok']).''; + $agent_data[1] = "".format_numeric($data['agent_ok']).''; $agent_data[2] = html_print_image('images/agent_unknown.png', true, ['title' => __('Agents unknown')]); $agent_data[3] = "".format_numeric($data['agent_unknown']).''; @@ -5844,7 +5844,7 @@ function reporting_get_events($data, $links=false) $table_events->data[0][1] = html_print_image('images/module_warning.png', true, ['title' => __('Warning events')]); $table_events->data[0][1] .= '   '."".format_numeric($data['warning']).''; $table_events->data[0][2] = html_print_image('images/module_ok.png', true, ['title' => __('OK events')]); - $table_events->data[0][2] .= '   '."".format_numeric($data['normal']).''; + $table_events->data[0][2] .= '   '."".format_numeric($data['normal']).''; $table_events->data[0][3] = html_print_image('images/module_unknown.png', true, ['title' => __('Unknown events')]); $table_events->data[0][3] .= '   '."".format_numeric($data['unknown']).''; } diff --git a/pandora_console/include/javascript/qrcode.js b/pandora_console/include/javascript/qrcode.js index c1217a383b..cd8485aafb 100755 --- a/pandora_console/include/javascript/qrcode.js +++ b/pandora_console/include/javascript/qrcode.js @@ -274,7 +274,7 @@ var QRCode; })() : (function () { // Drawing in Canvas function _onMakeImage() { this._elImage.src = this._elCanvas.toDataURL("image/png"); - this._elImage.style.display = "block"; + this._elImage.style.display = "inline"; this._elCanvas.style.display = "none"; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php index cf64cfa222..e0430eb0e0 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php +++ b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php @@ -373,7 +373,7 @@ class WuxWidget extends Widget $output .= ''; } else { $output .= __('Global status').': '; - $output .= ""; + $output .= ""; $output .= __('Ok'); $output .= ''; } diff --git a/pandora_console/include/styles/agent_manager.css b/pandora_console/include/styles/agent_manager.css index cecff8f9ac..78e58936e9 100644 --- a/pandora_console/include/styles/agent_manager.css +++ b/pandora_console/include/styles/agent_manager.css @@ -34,6 +34,7 @@ text-align: center; box-sizing: border-box; padding: 20px 0px; + margin-top: 22px; display: flex; justify-content: center; flex-direction: column; @@ -44,13 +45,10 @@ a#qr_code_agent_view { margin-top: 5px; } -.p-switch { - margin-right: 1em; -} - .sg_source, .sg_target { - width: 35%; + width: 100%; + height: 110px; } .sg_source select, diff --git a/pandora_console/include/styles/js/jquery-ui_custom.css b/pandora_console/include/styles/js/jquery-ui_custom.css index d6a39ea815..8728a78d6b 100644 --- a/pandora_console/include/styles/js/jquery-ui_custom.css +++ b/pandora_console/include/styles/js/jquery-ui_custom.css @@ -166,7 +166,9 @@ border-top-right-radius: 16px !important; border-bottom-left-radius: 16px !important; border-bottom-right-radius: 16px !important; - box-shadow: 5px 5px 19px #4e4e4e; + box-shadow: 0 10px 6px 0 rgb(0 0 0 / 13%); + border-radius: 8px; + border: 1px solid #e5e9ed; padding: 0; } .ui-dialog-titlebar { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index b556c7a517..66a943a872 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -865,7 +865,7 @@ select:-internal-list-box { margin: 0; } .box-shadow { - box-shadow: 0px 0px 15px -4px #dadada; + box-shadow: 0 3px 6px 0 rgb(0 0 0 / 13%); } .align-top td { vertical-align: top; @@ -935,10 +935,9 @@ div#container { div#main { width: 100%; - margin: 0 auto; margin-left: 3em; + margin-bottom: 3em; position: relative; - min-height: 850px; } textarea.conf_editor { @@ -5383,22 +5382,30 @@ div.label_select_child_left > span { padding: 7px 14px; margin-right: -1px; border: 1px solid #cbcbcb; - border-radius: 4px; transition: all 0.1s ease-in-out; } +.switch_radio_button label:first-child { + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; +} + +.switch_radio_button label:last-child { + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + margin-right: 0px; +} .switch_radio_button label:hover { cursor: pointer; } .switch_radio_button input:checked + label { - background-color: #82b92e; + background-color: #1d7873; box-shadow: none; color: #fff !important; } .switch_radio_button label:last-child { - margin-right: 0px; } /* @@ -5511,9 +5518,7 @@ div#bullets_modules div { .blue_color_ligther { color: #5bb6e5; } -.green_color { - color: #82b92e; -} + /* First row in agent view */ #agent_details_first_row { display: flex; @@ -5654,9 +5659,9 @@ div#status_pie { } /* White tables to show graphs */ -.white_table_graph, -.mgn_btt_20px { +.white_table_graph { margin-bottom: 20px; + max-width: 1064px; } .white_table_graph_header { @@ -6032,11 +6037,11 @@ form#modal_form_feedback ul.wizard li > textarea { /* Generic classes to reuse and facilitate the creation of custom themes */ .pandora_green_text { - color: #82b92e; + color: #1d7873; } .pandora_green_bg { - background-color: #82b92e; + background-color: #1d7873; } .default_container { @@ -7299,9 +7304,7 @@ div.graph div.legend table { .color_67 { color: #676767; } -.color_82b92e { - color: #82b92e; -} + .networkconsole { width: 100%; height: 100%; @@ -9013,7 +9016,8 @@ input[readonly], input:disabled, textarea:disabled, select:disabled, -.select2-container .select2-selection--single:disabled { +.select2-container .select2-selection--single:disabled, +.select2.select2-container.select2-container--default.select2-container--disabled { background-color: #e5e9ed; color: #8a96a6; } @@ -9482,13 +9486,6 @@ button.ui-button.ui-widget.submit-cancel:active { line-height: 32px; } -table#simple > tbody > tr { - display: flex; - flex-wrap: nowrap; - flex-direction: row; - align-items: center; -} - /* Custom Checkbox Style */ .custom_checkbox { display: inline-flex; @@ -9522,16 +9519,39 @@ table#simple > tbody > tr { /* End custom checkbox style */ -table#simple tr td { - min-height: 42px; +table#simple tr td, +table#advanced tr td { display: flex; flex-direction: row; align-items: center; - align-self: flex-start; + align-self: center; } -table#simple tr td:first-child { - width: 180px; +table#simple > tbody > tr, +table#advanced > tbody > tr { + display: flex; + flex-wrap: nowrap; + flex-direction: row; + align-items: center; + min-height: 55px; +} + +table#simple tr td:nth-child(even):not(:nth-child(2)) { + margin: 0 24px; +} + +table#simple tr td:nth-child(odd), +table#advanced tr td:nth-child(odd) { + font-size: 10pt; +} + +table tr td:first-child { + width: 190px; + align-self: flex-start !important; +} + +#secondary_groups_selected > .select2-container { + width: 480px; } .module_thresholds_fields em { @@ -9561,6 +9581,21 @@ span.ColorPickerDivSample { border-radius: 8px; border: 1px solid #c0ccdc; } +.custom_fields_elements { + display: flex; + flex-wrap: wrap; + align-items: flex-start; + justify-content: space-between; +} + +.custom_fields_elements > div { + width: 48%; + margin: 5px; +} + +tr.bring_next_field { + min-height: 36px !important; +} /* FINISH */ /* select */ @@ -9588,6 +9623,30 @@ span.ColorPickerDivSample { -webkit-user-select: none; } +.select2-container .select2-selection--multiple { + background-color: #f6f7fb !important; + height: 53px !important; + border: 1px solid #c0ccdc !important; + border-radius: 8px !important; + padding-left: 0px !important; + font: normal normal normal 12px Pandora-Light !important; + color: #2b3332 !important; + -webkit-box-sizing: border-box !important; + -moz-box-sizing: border-box !important; + box-sizing: border-box !important; +} + +.sg_source > .select2-container .select2-selection--multiple { + width: 480px !important; + height: 90px !important; + overflow: overlay; +} + +.select2-container--default + .select2-selection--multiple + .select2-selection__choice__remove { + margin-top: -4px; +} .select2-hidden-accessible { border: 0 !important; clip: rect(0 0 0 0) !important;