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

* include/functions_io.php: fixed the function "io_safe_output" for
	arrays, now into the function call other function with the name
	"io_safe_output_array".
	
	* include/functions_visual_map.php,
	include/ajax/visual_console_builder.ajax.php,
	godmode/reporting/visual_console_builder.wizard.php,
	godmode/reporting/visual_console_builder.php,
	godmode/reporting/visual_console_builder.editor.js,
	godmode/reporting/visual_console_builder.elements.php,
	godmode/reporting/visual_console_builder.editor.php,
	godmode/reporting/visual_console_builder.constans.php: fixed a lot
	of things about simple value and derivates.
	
	MERGED FROM 4.0.2




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6497 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-06-11 19:13:20 +00:00
parent 7f2bbe7d02
commit bb3ed471bc
10 changed files with 154 additions and 60 deletions

View File

@ -1,3 +1,21 @@
2012-06-11 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_io.php: fixed the function "io_safe_output" for
arrays, now into the function call other function with the name
"io_safe_output_array".
* include/functions_visual_map.php,
include/ajax/visual_console_builder.ajax.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/visual_console_builder.constans.php: fixed a lot
of things about simple value and derivates.
MERGED FROM 4.0.2
2012-06-11 Dario Rodriguez <dario.rodriguez@artica.es>
* operatoin/tree.php: Fixed a bug related to html tag id

View File

@ -23,4 +23,9 @@ define('SIMPLE_VALUE_MAX', 6);
define('SIMPLE_VALUE_MIN', 7);
define('SIMPLE_VALUE_AVG', 8);
define('PERCENTILE_BUBBLE', 9);
define('PROCESS_VALUE_NONE', 0);
define('PROCESS_VALUE_MIN', 1);
define('PROCESS_VALUE_MAX', 2);
define('PROCESS_VALUE_AVG', 3);
?>

View File

@ -179,7 +179,7 @@ function updateAction() {
success: function (data) {
$("#background_img").attr('src', data);
}
});
});
idElement = 0;
break;
@ -218,7 +218,7 @@ function updateAction() {
break;
case 'simple_value':
$("#text_" + idItem).html(values['label']);
$("#simplevalue_" + idItem).html(getModuleValue(idItem,values['process_simple_value']));
$("#simplevalue_" + idItem).html(getModuleValue(idItem,values['process_simple_value'], values['period']));
break;
case 'label':
$("#" + idItem).css('color', values['label_color']);
@ -727,11 +727,12 @@ function getModuleGraph(id_data) {
return img;
}
function getModuleValue(id_data, process_simple_value) {
function getModuleValue(id_data, process_simple_value, period) {
var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "get_module_value"});
parameter.push ({name: "id_element", value: id_data});
parameter.push ({name: "period", value: period});
if(process_simple_value != undefined) {
parameter.push ({name: "process_simple_value", value: process_simple_value});
}
@ -1028,7 +1029,7 @@ function createItem(type, values, id_data) {
imageSize = '';
item = $('<div id="' + id_data + '" class="item simple_value" style="color: ' + values['label_color'] + '; text-align: center; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
'<span id="text_' + id_data + '" class="text"> ' + values['label'] + '</span>' +
'<span id="text_' + id_data + '" class="text"> ' + values['label'] + '</span> ' +
'<strong>' + getModuleValue(id_data) + '</strong>' +
'</div>'
);

View File

@ -129,9 +129,9 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde
<tr id="process_value_row" class="simple_value datos">
<td><?php echo '<span>' . __('Process') . '</span>';?></td>
<td><?php html_print_select (
array ('1' => __('Min value'),
'2' => __('Max value'),
'3' => __('Avg value')), 'process_value', '', '', __('None'), 0);?></td>
array (PROCESS_VALUE_MIN => __('Min value'),
PROCESS_VALUE_MAX => __('Max value'),
PROCESS_VALUE_AVG => __('Avg value')), 'process_value', '', '', __('None'), PROCESS_VALUE_NONE);?></td>
</tr>
<tr id="background_row_1" class="background datos">
<td><?php echo __('Background');?></td>
@ -183,7 +183,7 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde
?>
</td>
</tr>
<tr id="period_row" class="module_graph datos">
<tr id="period_row" class="module_graph simple_value datos">
<td><?php echo __('Period');?></td>
<td><?php
html_print_extended_select_for_time ('period', '', '', '', '')

View File

@ -105,6 +105,15 @@ foreach ($layoutDatas as $layoutData) {
case SIMPLE_VALUE:
$table->data[$i + 1]['icon'] = html_print_image('images/binary.png', true, array('title' => __('Simple Value')));
break;
case SIMPLE_VALUE_MAX:
$table->data[$i + 1]['icon'] = html_print_image('images/binary.png', true, array('title' => __('Simple Value (Process Max)')));
break;
case SIMPLE_VALUE_MIN:
$table->data[$i + 1]['icon'] = html_print_image('images/binary.png', true, array('title' => __('Simple Value (Process Min)')));
break;
case SIMPLE_VALUE_AVG:
$table->data[$i + 1]['icon'] = html_print_image('images/binary.png', true, array('title' => __('Simple Value (Process Avg)')));
break;
case LABEL:
$table->data[$i + 1]['icon'] = html_print_image('images/tag_red.png', true, array('title' => __('Label')));
break;
@ -157,8 +166,8 @@ foreach ($layoutDatas as $layoutData) {
$activeTab . '&action=delete&id_visual_console=' . $visualConsole["id"] . '&id_element=' . $idLayoutData . '" ' .
'onclick="javascript: if (!confirm(\'' . __('Are you sure?') . '\')) return false;">' . html_print_image('images/cross.png', true) . '</a>';
//Second row
$table->data[$i + 2]['icon'] = '';
//Agent
@ -173,8 +182,11 @@ foreach ($layoutDatas as $layoutData) {
//Modules
if (($layoutData['type'] != ICON) && ($layoutData['type'] != LABEL)) {
$sql = 'SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE disabled = 0 AND id_agente = ' . $layoutData['id_agent'];
$table->data[$i + 2][1] = html_print_select_from_sql($sql,
$modules = agents_get_modules($layoutData['id_agent']);
$modules = io_safe_output($modules);
$table->data[$i + 2][1] = html_print_select($modules,
'module_' . $idLayoutData, $layoutData['id_agente_modulo'], '', '---', 0, true);
}
else {
@ -185,16 +197,21 @@ foreach ($layoutDatas as $layoutData) {
$table->data[$i + 2][2] = '';
//Period
if ($layoutData['type'] == MODULE_GRAPH) {
$table->data[$i + 2][3] = html_print_extended_select_for_time ('period_' . $idLayoutData, $layoutData['period'], '', '--', '0', 10, true);
}
else {
$table->data[$i + 2][3] = '';
switch ($layoutData['type']) {
case MODULE_GRAPH:
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG:
$table->data[$i + 2][3] = html_print_extended_select_for_time ('period_' . $idLayoutData, $layoutData['period'], '', '--', '0', 10, true);
break;
default:
$table->data[$i + 2][3] = '';
break;
}
//Map linked
$table->data[$i + 2][4] = html_print_select_from_sql ('SELECT id, name FROM tlayout WHERE id != ' . $idVisualConsole,
'map_linked_' . $idLayoutData, $layoutData['id_layout_linked'], '', 'None', '', true);
'map_linked_' . $idLayoutData, $layoutData['id_layout_linked'], '', 'None', '', true);
$table->data[$i + 2][5] = '';
if ($alternativeStyle) {

View File

@ -137,8 +137,13 @@ switch ($activeTab) {
$values['pos_x'] = get_parameter('left_' . $id, 0);
$values['pos_y'] = get_parameter('top_' . $id, 0);
$type = db_get_value('type', 'tlayout_data', 'id', $id);
if ($type == 1) {
$values['period'] = get_parameter('period_' . $id, 0);
switch($type) {
case MODULE_GRAPH:
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG:
$values['period'] = get_parameter('period_' . $id, 0);
break;
}
$agentName = get_parameter('agent_' . $id, '');
$values['id_agent'] = agents_get_agent_id($agentName);

View File

@ -74,16 +74,16 @@ $table->data["staticgraph_modulegraph"][0] = __('Size (px)');
$table->data["staticgraph_modulegraph"][1] = __('Width').': '.html_print_input_text ('width', 0, '', 5, 5, true);
$table->data["staticgraph_modulegraph"][1] .= ' ' . __('Height').': '.html_print_input_text ('height', 0, '', 5, 5, true);
$table->rowstyle["modulegraph"] = 'display: none;';
$table->data["modulegraph"][0] = __('Period');
$table->data["modulegraph"][1] = html_print_extended_select_for_time ('period', '', '', '', '', false, true);
$table->rowstyle["modulegraph_simplevalue"] = 'display: none;';
$table->data["modulegraph_simplevalue"][0] = __('Period');
$table->data["modulegraph_simplevalue"][1] = html_print_extended_select_for_time ('period', '', '', '', '', false, true);
$table->rowstyle["simplevalue"] = 'display: none;';
$table->data["simplevalue"][0] = __('Process');
$table->data["simplevalue"][1] = html_print_select (
array (SIMPLE_VALUE_MIN => __('Min value'),
SIMPLE_VALUE_MAX => __('Max value'),
SIMPLE_VALUE_AVG => __('Avg value')), 'process_value', '', '', '', '', true);
array (PROCESS_VALUE_MIN => __('Min value'),
PROCESS_VALUE_MAX => __('Max value'),
PROCESS_VALUE_AVG => __('Avg value')), 'process_value', PROCESS_VALUE_AVG, '', __('None'), PROCESS_VALUE_NONE, true);
$table->rowstyle["percentileitem_1"] = 'display: none;';
$table->data["percentileitem_1"][0] = __('Width (px)');
@ -147,6 +147,17 @@ var show_only_enabled_modules = true;
$(document).ready (function () {
hidden_rows();
$("#process_value").change(function () {
selected = $("#process_value").val();
if (selected == <?php echo PROCESS_VALUE_NONE;?>) {
$("tr", "#wizard_table").filter(function () {return /^.*modulegraph_simplevalue.*/.test(this.id); }).hide();
}
else {
$("tr", "#wizard_table").filter(function () {return /^.*modulegraph_simplevalue.*/.test(this.id); }).show();
}
});
$("#groups").change (function () {
$('#id_agents').attr('disabled', true);
$('#id_agents').empty ();

View File

@ -57,7 +57,7 @@ $max_percentile = get_parameter('max_percentile', null);
$height_module_graph = get_parameter('height_module_graph', null);
$width_module_graph = get_parameter('width_module_graph', null);
$id_agent_module = get_parameter('id_agent_module', 0);
$process_simple_value = get_parameter('process_simple_value', 0);
$process_simple_value = get_parameter('process_simple_value', PROCESS_VALUE_NONE);
$type_percentile = get_parameter('type_percentile', 'percentile');
$value_show = get_parameter('value_show', 'percent');
@ -94,7 +94,8 @@ switch ($action) {
case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG:
$type = visual_map_get_simple_value_type($process_simple_value);
$returnValue = visual_map_get_simple_value($type, $layoutData['id_agente_modulo']);
$returnValue = visual_map_get_simple_value($type,
$layoutData['id_agente_modulo'], $period);
break;
case PERCENTILE_BAR:
case PERCENTILE_BUBBLE:
@ -222,7 +223,10 @@ switch ($action) {
echo (int)$result;
break;
case 'simple_value':
$values['type'] = visual_map_get_simple_value_type($process_simple_value);
if ($action == 'update') {
$values['type'] = visual_map_get_simple_value_type($process_simple_value);
$values['period'] = $period;
}
case 'percentile_bar':
case 'percentile_item':
case 'static_graph':
@ -430,8 +434,9 @@ switch ($action) {
$values['height'] = $height;
break;
case 'simple_value':
//This allows min, max and avg process in a simple value
$values['type'] = visual_map_get_simple_value_type($process_simple_value);
//This allows min, max and avg process in a simple value
$values['type'] = visual_map_get_simple_value_type($process_simple_value);
$values['period'] = $period;
break;
case 'label':
$values['type'] = LABEL;

View File

@ -172,6 +172,19 @@ function io_html_to_ascii($hex) {
return chr($dec);
}
/**
* Safe output function for array.
*
* @param mixed $item The item pass as reference of item.
* @param mixed $key The key of array.
* @param boolean $utf8 The encoding.
*
* @return void
*/
function io_safe_output_array(&$item, $key, $utf8 = true) {
$item = io_safe_output($item, $utf8);
}
/**
* Convert the $value encode in html entity to clear char string. This function
* should be called always to "clean" HTML encoded data; to render to a text
@ -189,7 +202,8 @@ function io_safe_output($value, $utf8 = true)
return $value;
if (is_array($value)) {
array_walk($value, "io_safe_output");
array_walk($value, "io_safe_output_array");
return $value;
}
@ -208,19 +222,19 @@ function io_safe_output($value, $utf8 = true)
//Replace the html entitie of ) for the char
$valueHtmlEncode = str_replace("&#41;", ')', $valueHtmlEncode);
//Replace the html entitie of < for the char
$valueHtmlEncode = str_replace("&lt;", '<', $valueHtmlEncode);
//Replace the html entitie of > for the char
$valueHtmlEncode = str_replace("&gt;", '>', $valueHtmlEncode);
//Revert html entities to chars
for ($i=0;$i<33;$i++) {
$valueHtmlEncode = str_ireplace("&#x".dechex($i).";",io_html_to_ascii(dechex($i)), $valueHtmlEncode);
}
}
return $valueHtmlEncode;
return $valueHtmlEncode;
}
/**

View File

@ -234,7 +234,7 @@ function visual_map_print_item($layoutData) {
case SIMPLE_VALUE_AVG:
echo '<div id="' . $id . '" class="item simple_value" style="left: 0px; top: 0px; color: ' . $color . '; text-align: center; position: absolute; ' . $sizeStyle . ' margin-top: ' . $top . 'px; margin-left: ' . $left . 'px;">';
echo $text;
$value = visual_map_get_simple_value($type, $id_module);
$value = visual_map_get_simple_value($type, $id_module, $period);
echo ' <span id="simplevalue_' . $id . '" style="font-weight:bold;">' . $value . '</span>';
echo '</div>';
break;
@ -288,19 +288,19 @@ function visual_map_print_item($layoutData) {
* SIMPLE_VALUE, SIMPLE_VALUE_MAX, SIMPLE_VALUE_MIN, SIMPLE_VALUE_AVG
*/
function visual_map_get_simple_value_type($process_simple_value) {
switch ($process_simple_value){
case 0:
switch ($process_simple_value) {
case PROCESS_VALUE_NONE:
return SIMPLE_VALUE;
break;
case 1:
break;
case PROCESS_VALUE_MIN:
return SIMPLE_VALUE_MIN;
break;
case 2:
case PROCESS_VALUE_MAX:
return SIMPLE_VALUE_MAX;
break;
case 3:
case PROCESS_VALUE_AVG:
return SIMPLE_VALUE_AVG;
break;
break;
}
}
@ -310,22 +310,26 @@ function visual_map_get_simple_value_type($process_simple_value) {
* @param int type of the retrieving choosed among the constants:
* SIMPLE_VALUE, SIMPLE_VALUE_MAX, SIMPLE_VALUE_MIN, SIMPLE_VALUE_AVG
* @param int id agent module
* @param int period The period in seconds for calculate the avg or min or max value.
*
* @return string value retrieved with units
*/
function visual_map_get_simple_value($type, $id_module) {
$unit_text = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $id_module);
function visual_map_get_simple_value($type, $id_module, $period = SECONDS_1DAY) {
$unit_text = db_get_sql ('SELECT unit
FROM tagente_modulo WHERE id_agente_modulo = ' . $id_module);
$unit_text = trim(io_safe_output($unit_text));
switch ($type){
switch ($type) {
case SIMPLE_VALUE:
$value = db_get_value ('datos', 'tagente_estado', 'id_agente_modulo', $id_module);
$value = db_get_value ('datos', 'tagente_estado',
'id_agente_modulo', $id_module);
$value = format_for_graph($value, 2);
if (!empty($unit_text))
$value .= " " . $unit_text;
return $value;
break;
case SIMPLE_VALUE_MAX:
$value = reporting_get_agentmodule_data_max ($id_module, 86400, 0);
case SIMPLE_VALUE_MAX:
$value = reporting_get_agentmodule_data_max ($id_module, $period, 0);
if ($value === false) {
$value = __('Unknown');
}
@ -337,7 +341,7 @@ function visual_map_get_simple_value($type, $id_module) {
return $value;
break;
case SIMPLE_VALUE_MIN:
$value = reporting_get_agentmodule_data_min ($id_module, 86400, 0);
$value = reporting_get_agentmodule_data_min ($id_module, $period, 0);
if ($value === false) {
$value = __('Unknown');
}
@ -345,11 +349,11 @@ function visual_map_get_simple_value($type, $id_module) {
$value = format_for_graph($value, 2);
if (!empty($unit_text))
$value .= " " . $unit_text;
}
}
return $value;
break;
case SIMPLE_VALUE_AVG:
$value = reporting_get_agentmodule_data_average ($id_module, 86400, 0);
case SIMPLE_VALUE_AVG:
$value = reporting_get_agentmodule_data_average ($id_module, $period, 0);
if ($value === false) {
$value = __('Unknown');
}
@ -357,10 +361,10 @@ function visual_map_get_simple_value($type, $id_module) {
$value = format_for_graph($value, 2);
if (!empty($unit_text))
$value .= " " . $unit_text;
}
}
return $value;
break;
}
}
}
/**
@ -489,7 +493,21 @@ function visual_map_process_wizard_add_modules ($id_modules, $image, $id_layout,
}
break;
case SIMPLE_VALUE:
$value_type = $process_value;
$value_image = '';
switch ($process_value) {
case PROCESS_VALUE_NONE:
$value_type = SIMPLE_VALUE;
break;
case PROCESS_VALUE_MIN:
$value_type = SIMPLE_VALUE_MIN;
break;
case PROCESS_VALUE_MAX:
$value_type = SIMPLE_VALUE_MAX;
break;
case PROCESS_VALUE_AVG:
$value_type = SIMPLE_VALUE_AVG;
break;
}
break;
}
@ -1055,7 +1073,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
echo '<strong>'.$layout_data['label']. ' ';
//TODO: change interface to add a period parameter, now is set to 1 day
switch ($layout_data['type']){
switch ($layout_data['type']) {
case 2:
$value = db_get_value ('datos', 'tagente_estado', 'id_agente_modulo', $layout_data['id_agente_modulo']);
$value = format_for_graph($value, 2);
@ -1064,7 +1082,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
echo $value;
break;
case 6:
$value = reporting_get_agentmodule_data_max ($layout_data['id_agente_modulo'], 86400, 0);
$value = reporting_get_agentmodule_data_max ($layout_data['id_agente_modulo'], $layout_data['period'], 0);
if ($value === false) {
$value = __('Unknown');
}
@ -1076,7 +1094,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
echo $value;
break;
case 7:
$value = reporting_get_agentmodule_data_min ($layout_data['id_agente_modulo'], 86400, 0);
$value = reporting_get_agentmodule_data_min ($layout_data['id_agente_modulo'], $layout_data['period'], 0);
if ($value === false) {
$value = __('Unknown');
}
@ -1088,7 +1106,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
echo $value;
break;
case 8:
$value = reporting_get_agentmodule_data_average($layout_data['id_agente_modulo'], 86400, 0);
$value = reporting_get_agentmodule_data_average($layout_data['id_agente_modulo'], $layout_data['period'], 0);
if ($value === false) {
$value = __('Unknown');
}