2012-06-13 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_config.php, include/functions_ui.php,
	include/functions.php, include/constants.php,
	mobile/operation/agents/monitor_status.php,
	godmode/setup/setup_visuals.php: started to working into the set
	a standar truncate string in all code of Pandora Console.
	
	MERGED FROM 4.0.2




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6543 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-06-13 18:01:43 +00:00
parent 3692c286b8
commit 5bc0b9947f
7 changed files with 103 additions and 18 deletions

View File

@ -1,3 +1,13 @@
2012-06-13 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_config.php, include/functions_ui.php,
include/functions.php, include/constants.php,
mobile/operation/agents/monitor_status.php,
godmode/setup/setup_visuals.php: started to working into the set
a standar truncate string in all code of Pandora Console.
MERGED FROM 4.0.2
2012-06-13 Miguel de Dios <miguel.dedios@artica.es> 2012-06-13 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_config.php, * include/functions_config.php,

View File

@ -115,6 +115,21 @@ $table->data[15][1] = html_print_select ($values, 'refr', $config["refr"], '', '
$table->data[16][0] = __('Default interval for refresh on Visual Console') . ui_print_help_tip(__('This interval will affect to Visual Console pages'), true); $table->data[16][0] = __('Default interval for refresh on Visual Console') . ui_print_help_tip(__('This interval will affect to Visual Console pages'), true);
$table->data[16][1] = html_print_select ($values, 'vc_refr', $config["vc_refr"], '', 'N/A', 0, true, false, false); $table->data[16][1] = html_print_select ($values, 'vc_refr', $config["vc_refr"], '', 'N/A', 0, true, false, false);
$table->data[17][0] = __('Agent size text') . ui_print_help_tip(__('When the agent name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true);
$table->data[17][1] = __('Small:') . html_print_input_text ('agent_size_text_small', $config["agent_size_text_small"], '', 3, 3, true);
$table->data[17][1] .= ' ' . __('Normal:') . html_print_input_text ('agent_size_text_medium', $config["agent_size_text_medium"], '', 3, 3, true);
$table->data[18][0] = __('Module size text') . ui_print_help_tip(__('When the module name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true);
$table->data[18][1] = __('Small:') . html_print_input_text ('module_size_text_small', $config["module_size_text_small"], '', 3, 3, true);
$table->data[18][1] .= ' ' . __('Normal:') . html_print_input_text ('module_size_text_medium', $config["module_size_text_medium"], '', 3, 3, true);
$table->data[19][0] = __('Description size text') . ui_print_help_tip(__('When the description name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true);
$table->data[19][1] = html_print_input_text ('description_size_text', $config["description_size_text"], '', 3, 3, true);
$table->data[20][0] = __('Item title size text') . ui_print_help_tip(__('When the item title name have a lot of characters, in some places in Pandora Console it is necesary truncate to N characters.'), true);
$table->data[20][1] = html_print_input_text ('item_title_size_text', $config["item_title_size_text"], '', 3, 3, true);
echo '<form id="form_setup" method="post">'; echo '<form id="form_setup" method="post">';
html_print_input_hidden ('update_config', 1); html_print_input_hidden ('update_config', 1);
html_print_table ($table); html_print_table ($table);

View File

@ -91,4 +91,8 @@ define('COL_NORMAL','#8ae234');
define('COL_NOTINIT','#ef2929'); define('COL_NOTINIT','#ef2929');
define('COL_UNKNOWN','#aaaaaa'); define('COL_UNKNOWN','#aaaaaa');
define('COL_ALERTFIRED','#ff8800'); define('COL_ALERTFIRED','#ff8800');
/* The styles */
/* Size of text in characters for truncate */
define('GENERIC_SIZE_TEXT', 25);
?> ?>

View File

@ -823,10 +823,8 @@ function get_event_types () {
$types['error'] = __('Error'); $types['error'] = __('Error');
$types['configuration_change'] = __('Configuration change '); $types['configuration_change'] = __('Configuration change ');
if (isset($config['text_char_long'])) { foreach ($types as $key => $type) {
foreach ($types as $key => $type) { $types[$key] = ui_print_truncate_text($type, GENERIC_SIZE_TEXT, false, true, false);
$types[$key] = ui_print_truncate_text($type, $config['text_char_long'], false, true, false);
}
} }
return $types; return $types;
@ -849,10 +847,8 @@ function get_priorities () {
$priorities[6] = __('Major'); $priorities[6] = __('Major');
$priorities[4] = __('Critical'); $priorities[4] = __('Critical');
if (isset($config['text_char_long'])) { foreach ($priorities as $key => $priority) {
foreach ($priorities as $key => $priority) { $priorities[$key] = ui_print_truncate_text($priority, GENERIC_SIZE_TEXT, false, true, false);
$priorities[$key] = ui_print_truncate_text($priority, $config['text_char_long'], false, true, false);
}
} }
return $priorities; return $priorities;

View File

@ -204,7 +204,13 @@ function config_update_config () {
config_update_value ('font_size', get_parameter('font_size', $config['font_size'])); config_update_value ('font_size', get_parameter('font_size', $config['font_size']));
config_update_value ('refr', get_parameter('refr', $config['refr'])); config_update_value ('refr', get_parameter('refr', $config['refr']));
config_update_value ('vc_refr', get_parameter('vc_refr', $config['vc_refr'])); config_update_value ('vc_refr', get_parameter('vc_refr', $config['vc_refr']));
config_update_value ('agent_size_text_small', get_parameter('agent_size_text_small', $config['agent_size_text_small']));
config_update_value ('agent_size_text_medium', get_parameter('agent_size_text_medium', $config['agent_size_text_medium']));
config_update_value ('module_size_text_small', get_parameter('module_size_text_small', $config['module_size_text_small']));
config_update_value ('module_size_text_medium', get_parameter('module_size_text_medium', $config['module_size_text_medium']));
config_update_value ('description_size_text', get_parameter('description_size_text', $config['description_size_text']));
config_update_value ('item_title_size_text', get_parameter('item_title_size_text', $config['item_title_size_text']));
enterprise_include_once('include/functions_policies.php'); enterprise_include_once('include/functions_policies.php');
$enterprise = enterprise_include_once ('include/functions_skins.php'); $enterprise = enterprise_include_once ('include/functions_skins.php');
@ -640,6 +646,30 @@ function config_process_config () {
config_update_value ('refr', ''); config_update_value ('refr', '');
} }
if (!isset($config['agent_size_text_small'])) {
config_update_value ('agent_size_text_small', 15);
}
if (!isset($config['agent_size_text_medium'])) {
config_update_value ('agent_size_text_medium', 50);
}
if (!isset($config['module_size_text_small'])) {
config_update_value ('module_size_text_small', 15);
}
if (!isset($config['module_size_text_medium'])) {
config_update_value ('module_size_text_medium', 50);
}
if (!isset($config['description_size_text'])) {
config_update_value ('description_size_text', 50);
}
if (!isset($config['item_title_size_text'])) {
config_update_value ('item_title_size_text', 40);
}
/* Finally, check if any value was overwritten in a form */ /* Finally, check if any value was overwritten in a form */
config_update_config(); config_update_config();
} }

View File

@ -32,7 +32,7 @@ require_once($config['homedir'] . '/include/functions_html.php');
* true the html artifal to show the tooltip with rest of text. * true the html artifal to show the tooltip with rest of text.
* *
* @param string $text The text to truncate. * @param string $text The text to truncate.
* @param integer $numChars Number chars (-3 for char "[...]") max the text. * @param mixed $numChars Number chars (-3 for char "[...]") max the text. Or the strings "agent_small", "agent_medium", "module_small", "module_medium", "description" or "generic" for to take the values from user config.
* @param boolean $showTextInAToopTip Flag to show the tooltip. * @param boolean $showTextInAToopTip Flag to show the tooltip.
* @param boolean $return Flag to return as string or not. * @param boolean $return Flag to return as string or not.
* @param boolean $showTextInTitle Flag to show the text on title. * @param boolean $showTextInTitle Flag to show the text on title.
@ -41,7 +41,35 @@ require_once($config['homedir'] . '/include/functions_html.php');
* *
* @return string Truncated text. * @return string Truncated text.
*/ */
function ui_print_truncate_text($text, $numChars = 25, $showTextInAToopTip = true, $return = true, $showTextInTitle = true, $suffix = '[&hellip;]', $style = false) { function ui_print_truncate_text($text, $numChars = GENERIC_SIZE_TEXT, $showTextInAToopTip = true, $return = true, $showTextInTitle = true, $suffix = '[&hellip;]', $style = false) {
global $config;
if (is_string($numChars)) {
switch ($numChars) {
case 'agent_small':
$numChars = $config['agent_size_text_small'];
break;
case 'agent_medium':
$numChars = $config['agent_size_text_medium'];
break;
case 'module_small':
$numChars = $config['module_size_text_small'];
break;
case 'module_medium':
$numChars = $config['module_size_text_medium'];
break;
case 'description':
$numChars = $config['description_size_text'];
break;
case 'item_title':
$numChars = $config['item_title_size_text'];
break;
default:
$numChars = (int)$numChars;
break;
}
}
if ($numChars == 0) { if ($numChars == 0) {
if ($return == true) { if ($return == true) {
return $text; return $text;
@ -62,7 +90,7 @@ function ui_print_truncate_text($text, $numChars = 25, $showTextInAToopTip = tru
$truncateText = $truncateText . $truncateText2; $truncateText = $truncateText . $truncateText2;
if ($showTextInTitle) { if ($showTextInTitle) {
if ($style !== false){ if ($style !== false) {
$truncateText = '<span style="' . $style . '" title="'.$text.'">'.$truncateText.'</span>'; $truncateText = '<span style="' . $style . '" title="'.$text.'">'.$truncateText.'</span>';
} }
else { else {
@ -70,9 +98,9 @@ function ui_print_truncate_text($text, $numChars = 25, $showTextInAToopTip = tru
} }
} }
if ($showTextInAToopTip) { if ($showTextInAToopTip) {
if ($style !== false){ if ($style !== false) {
$truncateText = $truncateText . '<a href="#" class="tip">&nbsp;<span style="' . $style . '">' . $text . '</span></a>'; $truncateText = $truncateText . '<a href="#" class="tip">&nbsp;<span style="' . $style . '">' . $text . '</span></a>';
} }
else { else {
$truncateText = $truncateText . '<a href="#" class="tip">&nbsp;<span>' . $text . '</span></a>'; $truncateText = $truncateText . '<a href="#" class="tip">&nbsp;<span>' . $text . '</span></a>';
} }
@ -551,7 +579,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
* *
* @return string HTML with agent name and link * @return string HTML with agent name and link
*/ */
function ui_print_agent_name ($id_agent, $return = false, $cutoff = 0, $style = '', $cutname = false) { function ui_print_agent_name ($id_agent, $return = false, $cutoff = 'agent_medium', $style = '', $cutname = false) {
$agent_name = (string) agents_get_name ($id_agent); $agent_name = (string) agents_get_name ($id_agent);
$agent_name_full = $agent_name; $agent_name_full = $agent_name;
if ($cutname) { if ($cutname) {

View File

@ -55,7 +55,7 @@ class MonitorStatus {
$fields[4] = __('Not normal'); //default $fields[4] = __('Not normal'); //default
$fields[5] = __('Not init'); $fields[5] = __('Not init');
foreach ($fields as $key => $field) { foreach ($fields as $key => $field) {
$fields[$key] = ui_print_truncate_text($field, $config['text_char_long'], false, true, false); $fields[$key] = ui_print_truncate_text($field, GENERIC_SIZE_TEXT, false, true, false);
} }
$table->data[0][3] = html_print_select ($fields, "status", $status, '', '', -1, true); $table->data[0][3] = html_print_select ($fields, "status", $status, '', '', -1, true);
$table->data[1][0] = '<span alt="' . __('Module group') . '" title="' . __('Module group') . '"><b>' . __('M') . '</b></span>'; $table->data[1][0] = '<span alt="' . __('Module group') . '" title="' . __('Module group') . '"><b>' . __('M') . '</b></span>';
@ -216,13 +216,15 @@ class MonitorStatus {
$data[] = str_replace('<img src="' , '<img width="15" height="15" src="../../', $statusImg); $data[] = str_replace('<img src="' , '<img width="15" height="15" src="../../', $statusImg);
$data[] = '<a href="index.php?page=agent&id=' . $row['id_agent'] . '">' . ui_print_truncate_text($row['agent_name'], 25, true, true) . '</a>'; $data[] = '<a href="index.php?page=agent&id=' . $row['id_agent'] . '">' .
ui_print_truncate_text($row['agent_name'], 25, true, true) . '</a>';
$data[] = '<a href="index.php?page=agent&action=view_module_graph&id=' . $row['id_agente_modulo'] . '">' . $data[] = '<a href="index.php?page=agent&action=view_module_graph&id=' . $row['id_agente_modulo'] . '">' .
ui_print_truncate_text($row['module_name'], 25, true, true) . '</a>'; ui_print_truncate_text($row['module_name'], 25, true, true) . '</a>';
if (is_numeric($row["datos"])) if (is_numeric($row["datos"]))
$data[] = format_numeric($row["datos"]); $data[] = format_numeric($row["datos"]);
else else
$data[] = "<span title='".$row['datos']."' style='white-space: nowrap;'>".substr(io_safe_output($row["datos"]),0,12)."</span>"; $data[] = "<span title='".$row['datos']."' style='white-space: nowrap;'>" .
substr(io_safe_output($row["datos"]),0,12)."</span>";
$data[] = ui_print_timestamp ($row["utimestamp"], true, array('units' => 'tiny')); $data[] = ui_print_timestamp ($row["utimestamp"], true, array('units' => 'tiny'));