mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
2013-01-30 Miguel de Dios <miguel.dedios@artica.es>
* operation/agentes/estado_generalagente.php, include/functions_graph.php, include/graphs/functions_flot.php, include/graphs/fgraph.php, include/graphs/flot/pandora.flot.js: fixed the graph of events, now the pie graphs in "flot mode" has a parammeter to force the position of legend. Fixes: #3602206 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7553 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
22271cefa4
commit
b613ab5a3d
@ -1,3 +1,13 @@
|
|||||||
|
2013-01-30 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* operation/agentes/estado_generalagente.php,
|
||||||
|
include/functions_graph.php, include/graphs/functions_flot.php,
|
||||||
|
include/graphs/fgraph.php, include/graphs/flot/pandora.flot.js:
|
||||||
|
fixed the graph of events, now the pie graphs in "flot mode" has
|
||||||
|
a parammeter to force the position of legend.
|
||||||
|
|
||||||
|
Fixes: #3602206
|
||||||
|
|
||||||
2013-01-30 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
2013-01-30 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
|
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
|
||||||
|
@ -50,14 +50,16 @@ function get_graph_statistics ($chart_array) {
|
|||||||
//Get minimum
|
//Get minimum
|
||||||
if ($stats['min'] == null) {
|
if ($stats['min'] == null) {
|
||||||
$stats['min'] = $item;
|
$stats['min'] = $item;
|
||||||
} else if ($item < $stats['min']) {
|
}
|
||||||
|
else if ($item < $stats['min']) {
|
||||||
$stats['min'] = $item;
|
$stats['min'] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get maximum
|
//Get maximum
|
||||||
if ($stats['max'] == null) {
|
if ($stats['max'] == null) {
|
||||||
$stats['max'] = $item;
|
$stats['max'] = $item;
|
||||||
} else if ($item > $stats['max']) {
|
}
|
||||||
|
else if ($item > $stats['max']) {
|
||||||
$stats['max'] = $item;
|
$stats['max'] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1334,14 +1336,16 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
|
|||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
$sql = sprintf ('SELECT COUNT(id_evento) as count_number, nombre
|
$sql = sprintf ('SELECT COUNT(id_evento) AS count_number,
|
||||||
|
nombre
|
||||||
FROM tevento, tagente_modulo
|
FROM tevento, tagente_modulo
|
||||||
WHERE id_agentmodule = id_agente_modulo
|
WHERE id_agentmodule = id_agente_modulo
|
||||||
AND disabled = 0 AND tevento.id_agente = %d
|
AND disabled = 0 AND tevento.id_agente = %d
|
||||||
GROUP BY id_agentmodule, nombre LIMIT %d', $id_agent, $max_items);
|
GROUP BY id_agentmodule, nombre LIMIT %d', $id_agent, $max_items);
|
||||||
break;
|
break;
|
||||||
case "oracle":
|
case "oracle":
|
||||||
$sql = sprintf ('SELECT COUNT(id_evento) as count_number, dbms_lob.substr(nombre,4000,1) as nombre
|
$sql = sprintf ('SELECT COUNT(id_evento) AS count_number,
|
||||||
|
dbms_lob.substr(nombre,4000,1) AS nombre
|
||||||
FROM tevento, tagente_modulo
|
FROM tevento, tagente_modulo
|
||||||
WHERE (id_agentmodule = id_agente_modulo
|
WHERE (id_agentmodule = id_agente_modulo
|
||||||
AND disabled = 0 AND tevento.id_agente = %d) AND rownum <= %d
|
AND disabled = 0 AND tevento.id_agente = %d) AND rownum <= %d
|
||||||
@ -1358,13 +1362,16 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
$data[$event['nombre'].' ('.$event['count_number'].')'] = $event["count_number"];
|
$key = io_safe_output($event['nombre']) .
|
||||||
|
' ('.$event['count_number'].')';
|
||||||
|
$data[$key] = $event["count_number"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* System events */
|
/* System events */
|
||||||
$sql = "SELECT COUNT(*) FROM tevento WHERE id_agentmodule = 0 AND id_agente = $id_agent";
|
$sql = "SELECT COUNT(*)
|
||||||
|
FROM tevento
|
||||||
|
WHERE id_agentmodule = 0 AND id_agente = $id_agent";
|
||||||
$value = db_get_sql ($sql);
|
$value = db_get_sql ($sql);
|
||||||
if ($value > 0) {
|
if ($value > 0) {
|
||||||
$data[__('System').' ('.$value.')'] = $value;
|
$data[__('System').' ('.$value.')'] = $value;
|
||||||
@ -1376,7 +1383,7 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
|
|||||||
|
|
||||||
return pie3d_graph($config['flash_charts'], $data, $width, $height, __("other"),
|
return pie3d_graph($config['flash_charts'], $data, $width, $height, __("other"),
|
||||||
'', $water_mark,
|
'', $water_mark,
|
||||||
$config['fontpath'], $config['font_size']);
|
$config['fontpath'], $config['font_size'], 1, "bottom");
|
||||||
}
|
}
|
||||||
|
|
||||||
function progress_bar($progress, $width, $height, $title = '', $mode = 1, $value_text = false, $color = false, $options = false) {
|
function progress_bar($progress, $width, $height, $title = '', $mode = 1, $value_text = false, $color = false, $options = false) {
|
||||||
|
@ -434,26 +434,29 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pie3d_graph($flash_chart, $chart_data, $width, $height,
|
function pie3d_graph($flash_chart, $chart_data, $width, $height,
|
||||||
$others_str = "other", $homedir="", $water_mark = "", $font = '', $font_size = '', $ttl = 1) {
|
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||||
|
$font_size = '', $ttl = 1, $legend_position = false) {
|
||||||
return pie_graph('3d', $flash_chart, $chart_data, $width, $height,
|
return pie_graph('3d', $flash_chart, $chart_data, $width, $height,
|
||||||
$others_str, $homedir, $water_mark, $font, $font_size, $ttl);
|
$others_str, $homedir, $water_mark, $font, $font_size, $ttl, $legend_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pie2d_graph($flash_chart, $chart_data, $width, $height,
|
function pie2d_graph($flash_chart, $chart_data, $width, $height,
|
||||||
$others_str = "other", $homedir="", $water_mark = "", $font = '', $font_size = '', $ttl = 1) {
|
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||||
|
$font_size = '', $ttl = 1, $legend_position = false) {
|
||||||
return pie_graph('2d', $flash_chart, $chart_data, $width, $height,
|
return pie_graph('2d', $flash_chart, $chart_data, $width, $height,
|
||||||
$others_str, $homedir, $water_mark, $font, $font_size, $ttl);
|
$others_str, $homedir, $water_mark, $font, $font_size, $ttl, $legend_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
|
function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
|
||||||
$others_str = "other", $homedir="", $water_mark = "", $font = '', $font_size = '', $ttl = 1) {
|
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||||
|
$font_size = '', $ttl = 1, $legend_position = false) {
|
||||||
|
|
||||||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||||
|
|
||||||
// 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;
|
||||||
foreach($chart_data as $key => $value) {
|
foreach($chart_data as $key => $value) {
|
||||||
@ -472,9 +475,13 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($flash_chart) {
|
if ($flash_chart) {
|
||||||
return flot_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height, $water_mark_url, $font, $font_size);
|
return flot_pie_chart(array_values($chart_data),
|
||||||
|
array_keys($chart_data), $width, $height, $water_mark_url,
|
||||||
|
$font, $font_size, $legend_position);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
//TODO SET THE LEGEND POSITION
|
||||||
|
|
||||||
$graph = array();
|
$graph = array();
|
||||||
$graph['data'] = $chart_data;
|
$graph['data'] = $chart_data;
|
||||||
$graph['width'] = $width;
|
$graph['width'] = $width;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, water_mark, separator) {
|
function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, water_mark, separator, legend_position, height) {
|
||||||
var labels = labels.split(separator);
|
var labels = labels.split(separator);
|
||||||
var data = values.split(separator);
|
var data = values.split(separator);
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||||||
|
|
||||||
var label_conf;
|
var label_conf;
|
||||||
|
|
||||||
if(width < 400) {
|
if (width < 400) {
|
||||||
label_conf = {
|
label_conf = {
|
||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
@ -33,12 +33,12 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var plot = $.plot($('#'+graph_id), data,
|
var conf_pie = {
|
||||||
{
|
|
||||||
series: {
|
series: {
|
||||||
pie: {
|
pie: {
|
||||||
show: true,
|
show: true,
|
||||||
radius: 3/4,
|
radius: 3/4,
|
||||||
|
//offset: {top: -100},
|
||||||
label: label_conf
|
label: label_conf
|
||||||
//$label_str
|
//$label_str
|
||||||
}
|
}
|
||||||
@ -50,7 +50,26 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
|||||||
hoverable: true,
|
hoverable: true,
|
||||||
clickable: true
|
clickable: true
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
switch (legend_position) {
|
||||||
|
case 'bottom':
|
||||||
|
if (width > height)
|
||||||
|
offset = - (height / 5);
|
||||||
|
else
|
||||||
|
offset = - (width / 5);
|
||||||
|
conf_pie.series.pie.radius = 1 / 2.5;
|
||||||
|
conf_pie.series.pie.offset =
|
||||||
|
conf_pie.series.pie.offset = {top: offset};
|
||||||
|
conf_pie.legend.position = "s";
|
||||||
|
break;
|
||||||
|
case 'right':
|
||||||
|
default:
|
||||||
|
//TODO FOR TOP OR LEFT OR RIGHT
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var plot = $.plot($('#'+graph_id), data, conf_pie);
|
||||||
|
|
||||||
var legends = $('#'+graph_id+' .legendLabel');
|
var legends = $('#'+graph_id+' .legendLabel');
|
||||||
legends.each(function () {
|
legends.each(function () {
|
||||||
|
@ -314,7 +314,9 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
|||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
// Prints a FLOT pie chart
|
// Prints a FLOT pie chart
|
||||||
function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font = '', $font_size = 8) {
|
function flot_pie_chart ($values, $labels, $width, $height, $water_mark,
|
||||||
|
$font = '', $font_size = 8, $legend_position = '') {
|
||||||
|
|
||||||
include_javascript_dependencies_flot_graph();
|
include_javascript_dependencies_flot_graph();
|
||||||
|
|
||||||
$series = sizeof($values);
|
$series = sizeof($values);
|
||||||
@ -324,6 +326,16 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font =
|
|||||||
|
|
||||||
$graph_id = uniqid('graph_');
|
$graph_id = uniqid('graph_');
|
||||||
|
|
||||||
|
switch ($legend_position) {
|
||||||
|
case 'bottom':
|
||||||
|
$height = $height + (count($values) * 24);
|
||||||
|
break;
|
||||||
|
case 'right':
|
||||||
|
default:
|
||||||
|
//TODO FOR TOP OR LEFT OR RIGHT
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$return = "<div id='$graph_id' class='graph' style='width: ".$width."px; height: ".$height."px;'></div>";
|
$return = "<div id='$graph_id' class='graph' style='width: ".$width."px; height: ".$height."px;'></div>";
|
||||||
|
|
||||||
if($water_mark != '') {
|
if($water_mark != '') {
|
||||||
@ -341,7 +353,9 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font =
|
|||||||
|
|
||||||
$return .= "<script type='text/javascript'>";
|
$return .= "<script type='text/javascript'>";
|
||||||
|
|
||||||
$return .= "pandoraFlotPie('$graph_id', '$values', '$labels', '$series', '$width', $font_size, $water_mark, '$separator')";
|
$return .= "pandoraFlotPie('$graph_id', '$values', '$labels',
|
||||||
|
'$series', '$width', $font_size, $water_mark,
|
||||||
|
'$separator', '$legend_position', '$height')";
|
||||||
|
|
||||||
$return .= "</script>";
|
$return .= "</script>";
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ if ($agent === false) {
|
|||||||
|
|
||||||
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
|
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
|
||||||
|
|
||||||
if($is_extra === ENTERPRISE_NOT_HOOK) {
|
if ($is_extra === ENTERPRISE_NOT_HOOK) {
|
||||||
$is_extra = false;
|
$is_extra = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ echo '<div style="height: 10px"> </div>';
|
|||||||
//Floating div
|
//Floating div
|
||||||
echo '<div id="agent_access" style="float:right; width:320px; padding-top:10px;">';
|
echo '<div id="agent_access" style="float:right; width:320px; padding-top:10px;">';
|
||||||
|
|
||||||
if ($config["agentaccess"]){
|
if ($config["agentaccess"]) {
|
||||||
echo '<b>'.__('Agent access rate (24h)').'</b><br />';
|
echo '<b>'.__('Agent access rate (24h)').'</b><br />';
|
||||||
|
|
||||||
graphic_agentaccess($id_agente, 280, 110, 86400);
|
graphic_agentaccess($id_agente, 280, 110, 86400);
|
||||||
@ -172,7 +172,7 @@ if ($config['activate_gis']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the url description is setted
|
// If the url description is setted
|
||||||
if ($agent['url_address'] != ''){
|
if ($agent['url_address'] != '') {
|
||||||
echo '<tr><td class="datos"><b>'.__('Url address').'</b></td>';
|
echo '<tr><td class="datos"><b>'.__('Url address').'</b></td>';
|
||||||
echo '<td class="datos2" colspan="2"><a href='.$agent["url_address"].'>' . $agent["url_address"] . '</a></td></tr>';
|
echo '<td class="datos2" colspan="2"><a href='.$agent["url_address"].'>' . $agent["url_address"] . '</a></td></tr>';
|
||||||
}
|
}
|
||||||
@ -208,10 +208,10 @@ if ($fields === false) {
|
|||||||
$fields = array ();
|
$fields = array ();
|
||||||
}
|
}
|
||||||
if ($fields)
|
if ($fields)
|
||||||
foreach($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
echo '<tr><td class="datos"><b>'.$field['name'] . ui_print_help_tip (__('Custom field'), true).'</b></td>';
|
echo '<tr><td class="datos"><b>'.$field['name'] . ui_print_help_tip (__('Custom field'), true).'</b></td>';
|
||||||
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
|
$custom_value = db_get_value_filter('description', 'tagent_custom_data', array('id_field' => $field['id_field'], 'id_agent' => $id_agente));
|
||||||
if($custom_value === false || $custom_value == '') {
|
if ($custom_value === false || $custom_value == '') {
|
||||||
$custom_value = '<i>-'.__('empty').'-</i>';
|
$custom_value = '<i>-'.__('empty').'-</i>';
|
||||||
}
|
}
|
||||||
echo '<td class="datos f9" colspan="2">'.$custom_value.'</td></tr>';
|
echo '<td class="datos f9" colspan="2">'.$custom_value.'</td></tr>';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user