2012-04-13 Sergio Martin <sergio.martin@artica.es>

* include/functions_visual_map.php
	include/ajax/visual_console_builder.ajax.php
	godmode/reporting/visual_console_builder.editor.js: Fixed several
	bugs in the simple value item in the visual console and unified 
	repeated code merged from 4.0



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5971 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-04-13 11:15:14 +00:00
parent 9169cd5ea5
commit 74553e4e34
4 changed files with 107 additions and 110 deletions

View File

@ -1,3 +1,11 @@
2012-04-13 Sergio Martin <sergio.martin@artica.es>
* include/functions_visual_map.php
include/ajax/visual_console_builder.ajax.php
godmode/reporting/visual_console_builder.editor.js: Fixed several
bugs in the simple value item in the visual console and unified
repeated code merged from 4.0
2012-04-13 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_config.php, index.php,

View File

@ -258,6 +258,7 @@ function updateAction() {
break;
case 'simple_value':
$("#text_" + idItem).html(values['label']);
$("#simplevalue_" + idItem).html(getModuleValue(idItem,values['process_simple_value']));
break;
case 'label':
$("#" + idItem).css('color', values['label_color']);
@ -394,10 +395,6 @@ function createAction() {
alert($("#message_alert_no_module").html());
validate = false;
}
if ((values['process_simple_value'] == 0)) {
alert($("#message_alert_no_process").html());
validate = false;
}
break;
}
@ -769,11 +766,14 @@ function getModuleGraph(id_data) {
return img;
}
function getModuleValue(id_data) {
function getModuleValue(id_data, process_simple_value) {
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});
if(process_simple_value != undefined) {
parameter.push ({name: "process_simple_value", value: process_simple_value});
}
jQuery.ajax({
async: false,
url: "ajax.php",

View File

@ -89,47 +89,12 @@ switch ($action) {
$unit_text = false;
$layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element));
switch ($layoutData['type']) {
case SIMPLE_VALUE:
case SIMPLE_VALUE_MAX:
$unit = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']);
$unit = trim(io_safe_output($unit));
$value = reporting_get_agentmodule_data_max ($layoutData['id_agente_modulo'], 86400, 0);
if ($value === false) {
$returnValue = __('Unknown');
}
else {
$returnValue = format_for_graph($returnValue, 2);
if (!empty($unit_text))
$returnValue .= " " . $unit_text;
}
break;
case SIMPLE_VALUE_MIN:
$unit = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']);
$unit = trim(io_safe_output($unit));
$value = reporting_get_agentmodule_data_min ($layoutData['id_agente_modulo'], 86400, 0);
if ($value === false) {
$returnValue = __('Unknown');
}
else {
$returnValue = format_for_graph($returnValue, 2);
if (!empty($unit_text))
$returnValue .= " " . $unit_text;
}
break;
case SIMPLE_VALUE_AVG:
$unit = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']);
$unit = trim(io_safe_output($unit));
$value = reporting_get_agentmodule_data_average ($layoutData['id_agente_modulo'], 86400, 0);
if ($value === false) {
$returnValue = __('Unknown');
}
else {
$returnValue = format_for_graph($returnValue, 2);
if (!empty($unit_text))
$returnValue .= " " . $unit_text;
}
$type = visual_map_get_simple_value_type($process_simple_value);
$returnValue = visual_map_get_simple_value($type, $layoutData['id_agente_modulo']);
break;
case PERCENTILE_BAR:
case PERCENTILE_BUBBLE:
@ -235,9 +200,9 @@ switch ($action) {
break;
case 'update':
case 'move':
$values = array();
switch ($type) {
case 'background':
$values = array();
if ($background !== null)
$values['background'] = $background;
if ($width !== null)
@ -248,13 +213,13 @@ switch ($action) {
echo (int)$result;
break;
case 'simple_value':
$values['type'] = visual_map_get_simple_value_type($process_simple_value);
case 'percentile_bar':
case 'percentile_item':
case 'static_graph':
case 'module_graph':
case 'label':
case 'icon':
$values = array();
if ($label !== null) {
$values['label'] = $label;
}
@ -456,21 +421,8 @@ switch ($action) {
$values['height'] = $height;
break;
case 'simple_value':
//This allows min, max and avg process in a simple value
switch ($process_simple_value){
case 0:
$values['type'] = SIMPLE_VALUE;
break;
case 1:
$values['type'] = SIMPLE_VALUE_MIN;
break;
case 2:
$values['type'] = SIMPLE_VALUE_MAX;
break;
case 3:
$values['type'] = SIMPLE_VALUE_AVG;
break;
}
//This allows min, max and avg process in a simple value
$values['type'] = visual_map_get_simple_value_type($process_simple_value);
break;
case 'label':
$values['type'] = LABEL;

View File

@ -234,57 +234,10 @@ function visual_map_print_item($layoutData) {
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
case SIMPLE_VALUE_AVG:
$unit_text = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $id_module);
$unit_text = trim(io_safe_output($unit_text));
echo '<div id="' . $id . '" class="item simple_value" style="left: 0px; top: 0px; color: ' . $color . '; text-align: center; position: absolute; display: inline-block; ' . $sizeStyle . ' top: ' . $top . 'px; left: ' . $left . 'px;">';
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;
switch ($type){
case SIMPLE_VALUE:
$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;
echo ' <strong>' . $value . '</strong>';
break;
case SIMPLE_VALUE_MAX:
$value = reporting_get_agentmodule_data_max ($id_module, 86400, 0);
if ($value === false) {
$value = __('Unknown');
}
else {
$value = format_for_graph($value, 2);
if (!empty($unit_text))
$value .= " " . $unit_text;
}
echo ' <strong> ' . $value . '</strong>';
break;
case SIMPLE_VALUE_MIN:
$value = reporting_get_agentmodule_data_min ($id_module, 86400, 0);
if ($value === false) {
$value = __('Unknown');
}
else {
$value = format_for_graph($value, 2);
if (!empty($unit_text))
$value .= " " . $unit_text;
}
echo ' <strong> ' . $value . '</strong>';
break;
case SIMPLE_VALUE_AVG:
$value = reporting_get_agentmodule_data_average ($id_module, 86400, 0);
if ($value === false) {
$value = __('Unknown');
}
else {
$value = format_for_graph($value, 2);
if (!empty($unit_text))
$value .= " " . $unit_text;
}
echo ' <strong> ' . $value . '</strong>';
break;
}
$value = visual_map_get_simple_value($type, $id_module);
echo ' <span id="simplevalue_' . $id . '" style="font-weight:bold;">' . $value . '</span>';
echo '</div>';
break;
case LABEL:
@ -328,6 +281,90 @@ function visual_map_print_item($layoutData) {
}
}
/**
* The function to get simple value type from the value of process type in the form
*
* @param int process simple value from form
*
* @return int type among the constants:
* 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:
return SIMPLE_VALUE;
break;
case 1:
return SIMPLE_VALUE_MIN;
break;
case 2:
return SIMPLE_VALUE_MAX;
break;
case 3:
return SIMPLE_VALUE_AVG;
break;
}
}
/**
* The function to get the simple value of a module
*
* @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
*
* @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);
$unit_text = trim(io_safe_output($unit_text));
switch ($type){
case SIMPLE_VALUE:
$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);
if ($value === false) {
$value = __('Unknown');
}
else {
$value = format_for_graph($value, 2);
if (!empty($unit_text))
$value .= " " . $unit_text;
}
return $value;
break;
case SIMPLE_VALUE_MIN:
$value = reporting_get_agentmodule_data_min ($id_module, 86400, 0);
if ($value === false) {
$value = __('Unknown');
}
else {
$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);
if ($value === false) {
$value = __('Unknown');
}
else {
$value = format_for_graph($value, 2);
if (!empty($unit_text))
$value .= " " . $unit_text;
}
return $value;
break;
}
}
/**
* The function to save the new elements of agents make as wizard.
*