From bdd7cc1317e870b75bc63435b83cdea290c9a661 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 28 May 2019 09:48:09 +0200 Subject: [PATCH] Flex agent view --- pandora_console/include/functions_ui.php | 322 +++++++++++------- pandora_console/include/styles/pandora.css | 30 +- pandora_console/include/styles/progress.css | 1 + .../agentes/estado_generalagente.php | 4 +- 4 files changed, 222 insertions(+), 135 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 153f314647..30cadf25f2 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1,23 +1,33 @@ @@ -293,7 +314,8 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t '.$text_title.' '; if (!$no_close_bool) { - // Use the no_meta parameter because this image is only in the base console + // Use the no_meta parameter because this image is only in + // the base console. $output .= ''.html_print_image('images/blade.png', true, false, false, false, true).''; } @@ -330,11 +352,12 @@ function ui_print_message($message, $class='', $attributes='', $return=false, $t /** * Prints an error message. * - * @param mixed The string error message or array ('title', 'message', 'icon', 'no_close') to be displayed - * @param string Any other attributes to be set for the tag. - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $message The string error message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -347,11 +370,12 @@ function ui_print_error_message($message, $attributes='', $return=false, $tag='h /** * Prints an operation success message. * - * @param mixed The string message or array ('title', 'message', 'icon', 'no_close') to be displayed - * @param string Any other attributes to be set for the tag. - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $message The string message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -364,11 +388,12 @@ function ui_print_success_message($message, $attributes='', $return=false, $tag= /** * Prints an operation info message. * - * @param mixed The string message or array ('title', 'message', 'icon', 'no_close') to be displayed - * @param string Any other attributes to be set for the tag. - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $message The string message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -378,6 +403,18 @@ function ui_print_info_message($message, $attributes='', $return=false, $tag='h3 } +/** + * Prints an operation info message - empty data. + * + * @param mixed $message The string message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). + * + * @return string HTML code if return parameter is true. + */ function ui_print_empty_data($message, $attributes='', $return=false, $tag='h3') { return ui_print_message($message, 'info', $attributes, $return, $tag); @@ -387,14 +424,16 @@ function ui_print_empty_data($message, $attributes='', $return=false, $tag='h3') /** * Evaluates a result using empty() and then prints an error or success message * - * @param mixed The results to evaluate. 0, NULL, false, '' or - * array() is bad, the rest is good - * @param mixed The string or array ('title', 'message') to be displayed if the result was good - * @param mixed The string or array ('title', 'message') to be displayed if the result was bad - * @param string Any other attributes to be set for the h3 - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $result The results to evaluate. 0, NULL, false, '' or + * array() is bad, the rest is good. + * @param mixed $good The string or array ('title', 'message') to be + * displayed if the result was good. + * @param mixed $bad The string or array ('title', 'message') to be + * displayed if the result was bad. + * @param string $attributes Any other attributes to be set for the h3. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -419,11 +458,12 @@ function ui_print_result_message($result, $good='', $bad='', $attributes='', $re /** * Prints an warning message. * - * @param mixed The string warning message or array ('title', 'message', 'icon', 'no_close') to be displayed - * @param string Any other attributes to be set for the tag. - * @param bool Whether to output the string or return it - * @param string What tag to use (you could specify something else than - * h3 like div or h2) + * @param mixed $message The string message or array + * ('title', 'message', 'icon', 'no_close') to be displayed. + * @param string $attributes Any other attributes to be set for the tag. + * @param boolean $return Whether to output the string or return it. + * @param string $tag What tag to use (you could specify something else + * than h3 like div or h2). * * @return string HTML code if return parameter is true. */ @@ -438,13 +478,13 @@ function ui_print_warning_message($message, $attributes='', $return=false, $tag= * with as title the correctly formatted full timestamp and a time comparation * in the tag * - * @param int Any type of timestamp really, but we prefer unixtime - * @param bool Whether to output the string or return it - * @param array An array with different options for this function - * Key html_attr: which html attributes to add (defaults to none) - * Key tag: Which html tag to use (defaults to span) - * Key prominent: Overrides user preference and display "comparation" or "timestamp" - * key units: The type of units. + * @param integer $unixtime Any type of timestamp really, but we prefer unixtime. + * @param boolean $return Whether to output the string or return it. + * @param array $option An array with different options for this function + * Key html_attr: which html attributes to add (defaults to none) + * Key tag: Which html tag to use (defaults to span) + * Key prominent: Overrides user preference and display "comparation" or "timestamp" + * key units: The type of units. * * @return string HTML code if return parameter is true. */ @@ -452,7 +492,8 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) { global $config; - // TODO: Add/use a javascript timer for the seconds so it automatically updates as time passes by + // TODO: Add/use a javascript timer for the seconds so it automatically + // updates as time passes by. if (isset($option['html_attr'])) { $attributes = $option['html_attr']; } else { @@ -481,7 +522,7 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) $unixtime = time_w_fixed_tz($unixtime); } - // prominent_time is either timestamp or comparation + // Prominent_time is either timestamp or comparation. if ($unixtime <= 0) { $title = __('Unknown').'/'.__('Never'); $data = __('Unknown'); @@ -507,13 +548,13 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) switch ($tag) { default: // Usually tags have title attributes, so by default we add, - // then fall through to add attributes and data + // then fall through to add attributes and data. $output .= ' title="'.$title.'" '.$style.'>'.$data.''; break; case 'h1': case 'h2': case 'h3': - // Above tags don't have title attributes + // Above tags don't have title attributes. $output .= ' '.$attributes.' '.$style.'>'.$data.''; break; } @@ -529,8 +570,8 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) /** * Prints a username with real name, link to the user_edit page etc. * - * @param string The username to render - * @param bool Whether to return or print + * @param string $username The username to render. + * @param boolean $return Whether to return or print. * * @return string HTML code if return parameter is true. */ @@ -546,6 +587,13 @@ function ui_print_username($username, $return=false) } +/** + * Show a notification. + * + * @param boolean $return Return or direct echo. + * + * @return string HTML. + */ function ui_print_tags_warning($return=false) { $msg = '
'; @@ -563,11 +611,14 @@ function ui_print_tags_warning($return=false) /** * Print group icon within a link * - * @param int Group id - * @param bool Whether to return or print - * @param string What path to use (relative to images/). Defaults to groups_small - * @param string Style for group image - * @param bool Whether the group have link or not + * @param integer $id_group Group id. + * @param boolean $return Whether to return or print. + * @param string $path What path to use (relative to images/). + * Defaults to groups_small. + * @param string $style Style for group image. + * @param boolean $link Whether the group have link or not. + * @param boolean $force_show_image Force show image. + * @param boolean $show_as_image Show as image. * * @return string HTML code if return parameter is true. */ @@ -583,7 +634,7 @@ function ui_print_group_icon($id_group, $return=false, $path='groups_small', $st $output = ''; - // Don't show link in metaconsole + // Don't show link in metaconsole. if (defined('METACONSOLE')) { $link = false; } @@ -630,9 +681,12 @@ function ui_print_group_icon($id_group, $return=false, $path='groups_small', $st /** * Print group icon within a link. Other version. * - * @param int Group id - * @param bool Whether to return or print - * @param string What path to use (relative to images/). Defaults to groups_small + * @param integer $id_group Group id. + * @param boolean $return Whether to return or print. + * @param string $path What path to use (relative to images/). + * Defaults to groups_small. + * @param string $style Extra styles. + * @param boolean $link Add anchor. * * @return string HTML code if return parameter is true. */ @@ -674,10 +728,15 @@ function ui_print_group_icon_path($id_group, $return=false, $path='images/groups /** * Get the icon of an operating system. * - * @param int Operating system id - * @param bool Whether to also append the name of the OS after the icon - * @param bool Whether to return or echo the result - * @param bool Whether to apply skin or not + * @param integer $id_os Operating system id. + * @param boolean $name Whether to also append the name of OS after icon. + * @param boolean $return Whether to return or echo the result. + * @param boolean $apply_skin Whether to apply skin or not. + * @param boolean $networkmap Networkmap. + * @param boolean $only_src Only_src. + * @param boolean $relative Relative. + * @param boolean $options Options. + * @param boolean $big_icons Big_icons. * * @return string HTML with icon of the OS */ @@ -744,6 +803,18 @@ function ui_print_os_icon( } +/** + * Print type agent icon. + * + * @param boolean $id_os Id_os. + * @param boolean $remote_contact Remote_contact. + * @param boolean $contact Contact. + * @param boolean $return Return. + * @param integer $remote Remote. + * @param string $version Version. + * + * @return string HTML. + */ function ui_print_type_agent_icon( $id_os=false, $remote_contact=false, @@ -753,15 +824,15 @@ function ui_print_type_agent_icon( $version='' ) { if ($id_os == 19) { - // Satellite + // Satellite. $options['title'] = __('Satellite'); $output = html_print_image('images/op_satellite.png', true, $options, false, false, false, true); } else if ($remote_contact == $contact && $remote == 0 && $version == '') { - // Network + // Network. $options['title'] = __('Network'); $output = html_print_image('images/network.png', true, $options, false, false, false, true); } else { - // Software + // Software. $options['title'] = __('Software'); $output = html_print_image('images/data.png', true, $options, false, false, false, true); } @@ -773,20 +844,31 @@ function ui_print_type_agent_icon( /** * Prints an agent name with the correct link * - * @param int Agent id - * @param bool Whether to return the string or echo it too - * @param int Now uses styles to accomplish this - * @param string Style of name in css. - * @param string server url to concatenate at the begin of the link - * @param string extra parameters to concatenate in the link - * @param string name of the agent to avoid the query in some cases - * @param bool if the agent will provided with link or not - * @param bool use the agent alias or the name + * @param integer $id_agent Agent id. + * @param boolean $return Whether to return the string or echo it too. + * @param integer $cutoff Now uses styles to accomplish this. + * @param string $style Style of name in css. + * @param boolean $cutname Cut names. + * @param string $server_url Server url to concatenate at the begin of the link. + * @param string $extra_params Extra parameters to concatenate in the link. + * @param string $known_agent_name Name of the agent to avoid the query in some cases. + * @param boolean $link If the agent will provided with link or not. + * @param boolean $alias Use the agent alias or the name. * * @return string HTML with agent name and link */ -function ui_print_agent_name($id_agent, $return=false, $cutoff='agent_medium', $style='', $cutname=false, $server_url='', $extra_params='', $known_agent_name=false, $link=true, $alias=true) -{ +function ui_print_agent_name( + $id_agent, + $return=false, + $cutoff='agent_medium', + $style='', + $cutname=false, + $server_url='', + $extra_params='', + $known_agent_name=false, + $link=true, + $alias=true +) { if ($known_agent_name === false) { if ($alias) { $agent_name = (string) agents_get_alias($id_agent); @@ -808,14 +890,14 @@ function ui_print_agent_name($id_agent, $return=false, $cutoff='agent_medium', $ } if ($link) { - $url = $server_url.'index.php?sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$id_agent.$extra_params; + $url = $server_url.'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent.$extra_params; - $output = ''.$agent_name.''; + $output = ''.$agent_name.''; } else { $output = ''.$agent_name.''; } - // TODO: Add a pretty javascript (using jQuery) popup-box with agent details + // TODO: Add a pretty javascript (using jQuery) popup-box with agent details. if ($return) { return $output; } @@ -827,16 +909,19 @@ function ui_print_agent_name($id_agent, $return=false, $cutoff='agent_medium', $ /** * Formats a row from the alert table and returns an array usable in the table function * - * @param array A valid (non empty) row from the alert table - * @param bool Whether or not this is a combined alert - * @param bool Whether to print the agent information with the module information - * @param string Tab where the function was called from (used for urls) - * @param mixed Style for agent name or default (false) + * @param array $alert A valid (non empty) row from the alert table. + * @param boolean $agent Whether or not this is a combined alert. + * @param string $url Tab where the function was called from (used for urls). + * @param mixed $agent_style Style for agent name or default (false). * * @return array A formatted array with proper html for use in $table->data (6 columns) */ -function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) -{ +function ui_format_alert_row( + $alert, + $agent=true, + $url='', + $agent_style=false +) { global $config; if (!isset($alert['server_data'])) { @@ -856,7 +941,7 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) include_once $config['homedir'].'/include/functions_alerts.php'; $isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); $id_group = (int) get_parameter('ag_group', 0); - // 0 is the All group (selects all groups) + // 0 is the All group (selects all groups). if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if ($agent) { $index = [ @@ -956,13 +1041,13 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) $server = db_get_row('tmetaconsole_setup', 'id', $alert['server_data']['id']); if (metaconsole_connect($server) == NOERR) { - // Get agent data from node + // Get agent data from node. $agente = db_get_row('tagente', 'id_agente', $alert['id_agent']); metaconsole_restore_db(); } } else { - // Get agent id + // Get agent id. $id_agent = modules_get_agentmodule_agent($alert['id_agent_module']); $agente = db_get_row('tagente', 'id_agente', $id_agent); } @@ -972,9 +1057,11 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) $data = []; - // Validate checkbox + // Validate checkbox. if (!defined('METACONSOLE')) { - if (check_acl($config['id_user'], $id_group, 'LW') || check_acl($config['id_user'], $id_group, 'LM')) { + if (check_acl($config['id_user'], $id_group, 'LW') + || check_acl($config['id_user'], $id_group, 'LM') + ) { $data[$index['validate']] = ''; $data[$index['validate']] .= html_print_checkbox( @@ -996,7 +1083,6 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) // Restore the default connection. metaconsole_restore_db(); $errors++; - // break; It does not work in the php7 version remplace for: return false; } } @@ -1018,14 +1104,14 @@ function ui_format_alert_row($alert, $agent=true, $url='', $agent_style=false) } } - // Standby + // Standby. $data[$index['standby']] = ''; if (isset($alert['standby']) && $alert['standby'] == 1) { $data[$index['standby']] = html_print_image('images/bell_pause.png', true, ['title' => __('Standby on')]); } if (!defined('METACONSOLE')) { - // Force alert execution + // Force alert execution. if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) { if ($alert['force_execution'] == 0) { $data[$index['force_execution']] = ''.html_print_image('images/target.png', true, ['border' => '0', 'title' => __('Force')]).''; @@ -2464,7 +2550,7 @@ function ui_print_status_image($type, $title='', $return=false, $options=false, * * @param integer $progress Progress. * @param string $width Width. - * @param string $height Height. + * @param integer $height Height in 'em'. * @param string $color Color. * @param boolean $return Return or paint (if false). * @@ -2473,7 +2559,7 @@ function ui_print_status_image($type, $title='', $return=false, $options=false, function ui_progress( $progress, $width='100%', - $height='2.5em', + $height='2.5', $color='#80ba27', $return=true ) { @@ -2490,8 +2576,8 @@ function ui_progress( } ui_require_css_file('progress'); - $output .= '
'; - $output .= ''.$progress.'%'; + $output .= '
'; + $output .= ''.$progress.'%'; $output .= '
'; $output .= '
'; @@ -4155,7 +4241,7 @@ function ui_get_error($error_code='') function ui_include_time_picker($echo_tags=false) { if (is_ajax() || $echo_tags) { - echo ''; + echo ''; } else { ui_require_jquery_file('ui-timepicker-addon'); } @@ -4251,8 +4337,8 @@ function ui_print_module_string_value( $title_dialog = modules_get_agentmodule_agent_alias($id_agente_module).' / '.$module_name; $salida = '
".$value.'
'.'".''.$sub_string.' '."".html_print_image('images/zoom.png', true).''.''; + style='display: none; width: 100%; height: 100%; overflow: auto; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left' title='".$title_dialog."'>".$value.'
".''.$sub_string.' '."".html_print_image('images/zoom.png', true).''; } } } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 4a6bd33de0..c3758e49ac 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5987,6 +5987,9 @@ div#bullets_modules div { display: flex; margin-bottom: 20px; width: 100%; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-between; } .agent_details_col { @@ -5994,15 +5997,22 @@ div#bullets_modules div { background-color: #fff; border: 1px solid #e2e2e2; border-radius: 5px; + flex: 0 1 auto; + margin: 5px auto; } .agent_details_col_left { - width: 40%; - min-width: 500px; + width: 49.5%; + min-width: 455px; } - -.agent_details_col.agent_details_col_left { - width: 50%; +.agent_details_col_right { + width: 49.5%; + min-width: 455px; +} +@media screen and (max-width: 1200px) { + .agent_details_col { + flex: 1 1 auto; + } } .agent_details_content .agent_details_bullets { @@ -6010,16 +6020,6 @@ div#bullets_modules div { left: -20%; } -.agent_details_col_right { - width: 62%; - margin-left: 20px; - min-width: 670px; -} - -.agent_details_col.agent_details_col_right { - width: 50%; -} - .buttons_agent_view { display: flex; justify-content: flex-end; diff --git a/pandora_console/include/styles/progress.css b/pandora_console/include/styles/progress.css index 14cf494e85..84c3224f27 100644 --- a/pandora_console/include/styles/progress.css +++ b/pandora_console/include/styles/progress.css @@ -6,6 +6,7 @@ span.progress_text { } div.progress_main { + display: inline-block; text-align: center; height: 2.5em; border: 1px solid #80ba27; diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index fabd3898a9..325f0c654e 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -1,6 +1,6 @@ '.__('Other IP addresses').''; if (!empty($addresses)) { - $data_opcional[] = '
'.implode('
', $addresses).'
'; + $data_opcional[] = '
'.implode('
', $addresses).'
'; } array_push($data_opcional);