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

* include/graphs/functions_gd.php, include/graphs/fgraph.php:
	cleaned source code style.
	
	* include/functions_visual_map.php,
	include/ajax/visual_console_builder.ajax.php,
	godmode/reporting/visual_console_builder.editor.js,
	godmode/reporting/visual_console_builder.editor.php: fixed the
	strange behavior of the bars and bubbles in the editor.
	
	MERGED FROM 4.0.2




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6475 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-06-11 10:24:02 +00:00
parent 7f640bfcdd
commit f6e725f19b
7 changed files with 81 additions and 52 deletions

View File

@ -1,3 +1,16 @@
2012-06-11 Miguel de Dios <miguel.dedios@artica.es>
* include/graphs/functions_gd.php, include/graphs/fgraph.php:
cleaned source code style.
* include/functions_visual_map.php,
include/ajax/visual_console_builder.ajax.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.editor.php: fixed the
strange behavior of the bars and bubbles in the editor.
MERGED FROM 4.0.2
2012-06-11 Dario Rodriguez <dario.rodriguez@artica.es> 2012-06-11 Dario Rodriguez <dario.rodriguez@artica.es>
* operation/tree.php: Include functions_gis.php file that * operation/tree.php: Include functions_gis.php file that

View File

@ -153,7 +153,7 @@ function updateAction() {
values = readFields(); values = readFields();
// TODO VALIDATE DATA // TODO VALIDATE DATA
switch (selectedItem) { switch (selectedItem) {
case 'background': case 'background':
if(values['width'] == 0 && values['height'] == 0) { if(values['width'] == 0 && values['height'] == 0) {
@ -179,7 +179,7 @@ function updateAction() {
success: function (data) { success: function (data) {
$("#background_img").attr('src', data); $("#background_img").attr('src', data);
} }
}); });
idElement = 0; idElement = 0;
break; break;
@ -326,6 +326,7 @@ function readFields() {
values['type_percentile'] = $("input[name=type_percentile]:checked").val(); values['type_percentile'] = $("input[name=type_percentile]:checked").val();
values['value_show'] = $("input[name=value_show]:checked").val(); values['value_show'] = $("input[name=value_show]:checked").val();
return values; return values;
} }
@ -581,8 +582,8 @@ function setAspectRatioBackground(side) {
url: "ajax.php", url: "ajax.php",
data: parameter, data: parameter,
type: "POST", type: "POST",
dataType: 'json', dataType: "json",
success: function (data) { success: function(data) {
old_width = parseInt($("#background").css('width').replace('px', '')); old_width = parseInt($("#background").css('width').replace('px', ''));
old_height = parseInt($("#background").css('height').replace('px', '')); old_height = parseInt($("#background").css('height').replace('px', ''));
@ -790,6 +791,9 @@ function getModuleValue(id_data, process_simple_value) {
} }
function getPercentileBar(id_data, values) { function getPercentileBar(id_data, values) {
max_percentile = values['max_percentile'];
width_percentile = values['width_percentile'];
var parameter = Array(); var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
@ -805,11 +809,14 @@ function getPercentileBar(id_data, values) {
success: function (data) success: function (data)
{ {
module_value = data['value']; module_value = data['value'];
max_percentile = data['max_percentile']; //max_percentile = data['max_percentile'];
width_percentile = data['width_percentile']; //width_percentile = data['width_percentile'];
unit_text = false unit_text = false;
if (data['unit_text'] != false)
if ((data['unit_text'] != false) || typeof(data['unit_text']) != 'boolean') {
unit_text = data['unit_text']; unit_text = data['unit_text'];
}
colorRGB = data['colorRGB']; colorRGB = data['colorRGB'];
} }
}); });
@ -837,7 +844,7 @@ function getPercentileBar(id_data, values) {
else else
var percentile = 100; var percentile = 100;
if (unit_text == false) { if (unit_text == false && typeof(unit_text) == 'boolean') {
value_text = percentile + "%"; value_text = percentile + "%";
} }
else { else {
@ -852,6 +859,9 @@ function getPercentileBar(id_data, values) {
} }
function getPercentileBubble(id_data, values) { function getPercentileBubble(id_data, values) {
max_percentile = values['max_percentile'];
width_percentile = values['width_percentile'];
var parameter = Array(); var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
@ -867,10 +877,10 @@ function getPercentileBubble(id_data, values) {
success: function (data) success: function (data)
{ {
module_value = data['value']; module_value = data['value'];
max_percentile = data['max_percentile']; //max_percentile = data['max_percentile'];
width_percentile = data['width_percentile']; //width_percentile = data['width_percentile'];
unit_text = false unit_text = false
if (data['unit_text'] != false) if ((data['unit_text'] != false) || typeof(data['unit_text']) != 'boolean')
unit_text = data['unit_text']; unit_text = data['unit_text'];
colorRGB = data['colorRGB']; colorRGB = data['colorRGB'];
} }
@ -899,7 +909,7 @@ function getPercentileBubble(id_data, values) {
else else
var percentile = 100; var percentile = 100;
if (unit_text == false) { if (unit_text == false && typeof(unit_text) == 'boolean') {
value_text = percentile + "%"; value_text = percentile + "%";
} }
else { else {

View File

@ -265,7 +265,7 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde
<tr id="label_color_row" class="static_graph percentile_bar percentile_item module_graph simple_value label datos"> <tr id="label_color_row" class="static_graph percentile_bar percentile_item module_graph simple_value label datos">
<td><?php echo __('Label color');?></td> <td><?php echo __('Label color');?></td>
<td><?php html_print_input_text_extended ('label_color', '#000000', 'text-'.'label_color', '', 7, 7, false, '', 'class="label_color"', false);?></td> <td><?php html_print_input_text_extended ('label_color', '#000000', 'text-'.'label_color', '', 7, 7, false, '', 'class="label_color"', false);?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<?php <?php
@ -333,7 +333,6 @@ ui_require_javascript_file('wz_jsgraphics');
ui_require_javascript_file('pandora_visual_console'); ui_require_javascript_file('pandora_visual_console');
//ui_require_jquery_file ('autocomplete'); //ui_require_jquery_file ('autocomplete');
ui_require_javascript_file('visual_console_builder.editor', 'godmode/reporting/'); ui_require_javascript_file('visual_console_builder.editor', 'godmode/reporting/');
// Javascript file for base 64 encoding of label parameter // Javascript file for base 64 encoding of label parameter
ui_require_javascript_file ('encode_decode_base64'); ui_require_javascript_file ('encode_decode_base64');
?> ?>

View File

@ -78,7 +78,7 @@ switch ($action) {
preg_match("/src='(.*)'/", $img, $matches); preg_match("/src='(.*)'/", $img, $matches);
$url = $matches[1]; $url = $matches[1];
echo $url; echo $url;
break; break;
case 'get_layout_data': case 'get_layout_data':
$layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element)); $layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element));
@ -101,6 +101,9 @@ switch ($action) {
default: default:
$returnValue = db_get_sql ('SELECT datos FROM tagente_estado WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); $returnValue = db_get_sql ('SELECT datos FROM tagente_estado WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']);
//html_debug_print($value_show);
//html_debug_print($layoutData);
if (($layoutData['type'] == PERCENTILE_BAR) || if (($layoutData['type'] == PERCENTILE_BAR) ||
($layoutData['type'] == PERCENTILE_BUBBLE)) { ($layoutData['type'] == PERCENTILE_BUBBLE)) {
if ($value_show == 'value') { if ($value_show == 'value') {
@ -109,7 +112,13 @@ switch ($action) {
$unit_text_db = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); $unit_text_db = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']);
$unit_text_db = trim(io_safe_output($unit_text_db)); $unit_text_db = trim(io_safe_output($unit_text_db));
$unit_text = false; if ($value_show == 'value') {
//Set empty string unit at the moment
//and change for old false value
$unit_text = '';
}
if (!empty($unit_text_db)) if (!empty($unit_text_db))
$unit_text = $unit_text_db; $unit_text = $unit_text_db;
} }

View File

@ -149,10 +149,10 @@ function visual_map_print_item($layoutData) {
$colorStatus = "#ffff00"; $colorStatus = "#ffff00";
break; break;
case 3: case 3:
//Unknown
default: default:
$colorStatus = "#5A5AFF"; //Unknown
// Default is Blue (Other) // Default is Blue (Other)
$colorStatus = "#5A5AFF";
break; break;
} }
@ -198,12 +198,10 @@ function visual_map_print_item($layoutData) {
} }
if ( $max_percentile > 0) if ( $max_percentile > 0)
$percentile = $module_value / $max_percentile * 100; $percentile = format_numeric($module_value / $max_percentile * 100, 0);
else else
$percentile = 100; $percentile = 100;
$percentile = round($percentile);
echo '<div id="' . $id . '" class="item percentile_item" style="color: ' . $color . '; text-align: center; position: absolute; display: inline-block; ' . $sizeStyle . ' top: ' . $top . 'px; left: ' . $left . 'px;">'; echo '<div id="' . $id . '" class="item percentile_item" style="color: ' . $color . '; text-align: center; position: absolute; display: inline-block; ' . $sizeStyle . ' top: ' . $top . 'px; left: ' . $left . 'px;">';
echo $text . '<br />'; echo $text . '<br />';

View File

@ -48,17 +48,17 @@ include_once('functions_utils.php');
*/ */
if (isset($_GET['homeurl'])) { if (isset($_GET['homeurl'])) {
$homeurl = $_GET['homeurl']; $homeurl = $_GET['homeurl'];
} }
else $homeurl = ''; else $homeurl = '';
if (isset($_GET['ttl'])) { if (isset($_GET['ttl'])) {
$ttl = $_GET['ttl']; $ttl = $_GET['ttl'];
} }
else $ttl_param = 1; else $ttl_param = 1;
if (isset($_GET['graph_type'])) { if (isset($_GET['graph_type'])) {
$graph_type = $_GET['graph_type']; $graph_type = $_GET['graph_type'];
} }
else $graph_type = ''; else $graph_type = '';
@ -147,16 +147,16 @@ function histogram($chart_data, $width, $height, $font, $max, $title, $mode, $tt
$graph['max'] = $max; $graph['max'] = $max;
$graph['title'] = $title; $graph['title'] = $title;
$graph['mode'] = $mode; $graph['mode'] = $mode;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='include/graphs/functions_gd.php?static_graph=1&graph_type=histogram&ttl=".$ttl."&id_graph=".$id_graph."'>"; return "<img src='include/graphs/functions_gd.php?static_graph=1&graph_type=histogram&ttl=".$ttl."&id_graph=".$id_graph."'>";
} }
function progressbar($progress, $width, $height, $title, $font, $mode = 1, function progressbar($progress, $width, $height, $title, $font, $mode = 1,
$out_of_lim_str = false, $out_of_lim_image = false, $ttl = 1) { $out_of_lim_str = false, $out_of_lim_image = false, $ttl = 1) {
$graph = array(); $graph = array();
$graph['progress'] = $progress; $graph['progress'] = $progress;
$graph['width'] = $width; $graph['width'] = $width;
$graph['height'] = $height; $graph['height'] = $height;
@ -165,9 +165,9 @@ function progressbar($progress, $width, $height, $title, $font, $mode = 1,
$graph['title'] = $title; $graph['title'] = $title;
$graph['font'] = $font; $graph['font'] = $font;
$graph['mode'] = $mode; $graph['mode'] = $mode;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='include/graphs/functions_gd.php?static_graph=1&graph_type=progressbar&ttl=".$ttl."&id_graph=".$id_graph."'>"; return "<img src='include/graphs/functions_gd.php?static_graph=1&graph_type=progressbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
} }
@ -182,9 +182,9 @@ function slicesbar_graph($chart_data, $period, $width, $height, $colors, $font,
$graph['font'] = $font; $graph['font'] = $font;
$graph['round_corner'] = $round_corner; $graph['round_corner'] = $round_corner;
$graph['color'] = $colors; $graph['color'] = $colors;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$home_url."include/graphs/functions_pchart.php?static_graph=1&graph_type=slicebar&ttl=".$ttl."&id_graph=".$id_graph."'>"; return "<img src='".$home_url."include/graphs/functions_pchart.php?static_graph=1&graph_type=slicebar&ttl=".$ttl."&id_graph=".$id_graph."'>";
} }
@ -211,9 +211,9 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
$graph['font'] = $font; $graph['font'] = $font;
$graph['font_size'] = $font_size; $graph['font_size'] = $font_size;
$graph['force_steps'] = $force_steps; $graph['force_steps'] = $force_steps;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=vbar&ttl=".$ttl."&id_graph=".$id_graph."'>"; return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=vbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
} }
} }
@ -263,17 +263,17 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$graph['water_mark'] = $water_mark_file; $graph['water_mark'] = $water_mark_file;
$graph['font'] = $font; $graph['font'] = $font;
$graph['font_size'] = $font_size; $graph['font_size'] = $font_size;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$homeurl."include/graphs/functions_pchart.php?static_graph=1&graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>"; return "<img src='".$homeurl."include/graphs/functions_pchart.php?static_graph=1&graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
} }
} }
function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color, function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
$legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "",
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $homeurl = '') { $water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $homeurl = '') {
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) { if (empty($chart_data)) {
@ -302,23 +302,23 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />"; return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
} }
} }
function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color, function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
$legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "",
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $homeurl = '') { $water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $homeurl = '') {
setup_watermark($water_mark, $water_mark_file, $water_mark_url); setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) { if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />'; return '<img src="' . $no_data_image . '" />';
} }
if($flash_chart) { if($flash_chart) {
return flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url); return flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
} }
else { else {
//Stack the data //Stack the data
stack_data($chart_data, $legend, $color); stack_data($chart_data, $legend, $color);
@ -369,7 +369,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />"; return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
} }
} }
function kiviat_graph($graph_type, $flash_chart, $chart_data, $width, $height, $no_data_image, $ttl = 1, $homedir="") { function kiviat_graph($graph_type, $flash_chart, $chart_data, $width, $height, $no_data_image, $ttl = 1, $homedir="") {
@ -381,9 +381,9 @@ function kiviat_graph($graph_type, $flash_chart, $chart_data, $width, $height, $
$graph['data'] = $chart_data; $graph['data'] = $chart_data;
$graph['width'] = $width; $graph['width'] = $width;
$graph['height'] = $height; $graph['height'] = $height;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$homedir."include/graphs/functions_pchart.php?static_graph=1&graph_type=".$graph_type."&ttl=".$ttl."&id_graph=" . $id_graph . "' />"; return "<img src='".$homedir."include/graphs/functions_pchart.php?static_graph=1&graph_type=".$graph_type."&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
} }
@ -423,9 +423,9 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
$graph['font'] = $font; $graph['font'] = $font;
$graph['font_size'] = $font_size; $graph['font_size'] = $font_size;
$graph['force_steps'] = $force_steps; $graph['force_steps'] = $force_steps;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$homedir."include/graphs/functions_pchart.php?static_graph=1&graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>"; return "<img src='".$homedir."include/graphs/functions_pchart.php?static_graph=1&graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
} }
} }
@ -449,7 +449,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
// This library allows only 8 colors // This library allows only 8 colors
$max_values = 8; $max_values = 8;
if(count($chart_data) > $max_values) { if(count($chart_data) > $max_values) {
$chart_data_trunc = array(); $chart_data_trunc = array();
$n = 1; $n = 1;

View File

@ -25,18 +25,18 @@ else if(file_exists('../functions.php')) {
} }
$types = array('histogram', 'progressbar'); $types = array('histogram', 'progressbar');
$id_graph = get_parameter('id_graph', false); $id_graph = get_parameter('id_graph', false);
$graph_type = get_parameter('graph_type', ''); $graph_type = get_parameter('graph_type', '');
if($id_graph && in_array($graph_type, $types)) { if($id_graph && in_array($graph_type, $types)) {
if (!$id_graph) { if (!$id_graph) {
exit; exit;
} }
$graph = unserialize_in_temp($id_graph); $graph = unserialize_in_temp($id_graph);
if (!isset($graph)) { if (!isset($graph)) {
exit; exit;
} }