Merge branch 'ent-1972-Graficas-en-informes' into 'develop'

fixed legend max 10 modules for chart

See merge request artica/pandorafms!3337
This commit is contained in:
Daniel Rodriguez 2020-07-13 10:02:56 +02:00
commit fe48741abe
3 changed files with 30 additions and 32 deletions

View File

@ -190,8 +190,20 @@ if ($editGraph) {
$weights = implode(',', $weight_array); $weights = implode(',', $weight_array);
} }
$count_module_array = count($module_array);
if ($count_module_array > 10) {
ui_print_warning_message(
__(
'The maximum number of items in a chart is 10. You have %s elements, only first 10 will be displayed.',
$count_module_array
)
);
}
// Modules table. // Modules table.
if (count($module_array) > 0) { if ($count_module_array > 0) {
echo "<table width='100%' cellpadding=4 cellpadding=4 class='databox filters'>"; echo "<table width='100%' cellpadding=4 cellpadding=4 class='databox filters'>";
echo '<tr> echo '<tr>
<th>'.__('P.').'</th> <th>'.__('P.').'</th>
@ -202,7 +214,7 @@ if (count($module_array) > 0) {
<th>'.__('Delete').'</th> <th>'.__('Delete').'</th>
<th>'.__('Sort').'</th>'; <th>'.__('Sort').'</th>';
$color = 0; $color = 0;
for ($a = 0; $a < count($module_array); $a++) { for ($a = 0; $a < $count_module_array; $a++) {
// Calculate table line color. // Calculate table line color.
if ($color == 1) { if ($color == 1) {
$tdcolor = 'datos'; $tdcolor = 'datos';

View File

@ -1483,6 +1483,11 @@ function graphic_combined_module(
continue; continue;
} }
// Only 10 item for chart.
if ($i > 9) {
break;
}
if (is_metaconsole()) { if (is_metaconsole()) {
$server = metaconsole_get_connection_by_id( $server = metaconsole_get_connection_by_id(
$agent_module_id['server'] $agent_module_id['server']
@ -1839,15 +1844,12 @@ function graphic_combined_module(
} }
} }
if ($automatic_custom_graph_meta) { $module = $module_item['module'];
$module = $module_item['module'];
} else {
$module = $module_item;
}
$search_in_history_db = db_search_in_history_db($datelimit); $search_in_history_db = db_search_in_history_db($datelimit);
$temp[$module] = io_safe_output(modules_get_agentmodule($module)); $temp[$module] = io_safe_output(
modules_get_agentmodule($module)
);
$query_last_value = sprintf( $query_last_value = sprintf(
' '
SELECT datos SELECT datos
@ -1975,12 +1977,7 @@ function graphic_combined_module(
} }
} }
if ($automatic_custom_graph_meta) { $module = $module_item['module'];
$module = $module_item['module'];
} else {
$module = $module_item;
}
$temp[$module] = modules_get_agentmodule($module); $temp[$module] = modules_get_agentmodule($module);
$query_last_value = sprintf( $query_last_value = sprintf(
' '
@ -2102,12 +2099,7 @@ function graphic_combined_module(
} }
} }
if ($automatic_custom_graph_meta === true) { $module = $module_item['module'];
$module = $module_item['module'];
} else {
$module = $module_item;
}
$module_data = modules_get_agentmodule($module); $module_data = modules_get_agentmodule($module);
$query_last_value = sprintf( $query_last_value = sprintf(
'SELECT datos 'SELECT datos
@ -2243,16 +2235,10 @@ function graphic_combined_module(
} }
} }
if ($automatic_custom_graph_meta) { $module = $module_item['module'];
$module = $module_item['module'];
} else {
$module = $module_item;
}
$data_module = modules_get_agentmodule($module); $data_module = modules_get_agentmodule($module);
$query_last_value = sprintf( $query_last_value = sprintf(
' 'SELECT datos
SELECT datos
FROM tagente_datos FROM tagente_datos
WHERE id_agente_modulo = %d WHERE id_agente_modulo = %d
AND utimestamp > %d AND utimestamp > %d

View File

@ -2432,7 +2432,7 @@ function pandoraFlotArea(
if (!value[x]) { if (!value[x]) {
x = x + 1; x = x + 1;
} }
if (value[x].min) { if (typeof value[x].min !== "undefined" && value[x].min) {
min_y_array = format_unit_yaxes(value[x].min); min_y_array = format_unit_yaxes(value[x].min);
min_y = min_y_array["y"]; min_y = min_y_array["y"];
min_bigger = min_y_array["unit"]; min_bigger = min_y_array["unit"];
@ -2441,7 +2441,7 @@ function pandoraFlotArea(
min_bigger = ""; min_bigger = "";
} }
if (value[x].max) { if (typeof value[x].max !== "undefined" && value[x].max) {
max_y_array = format_unit_yaxes(value[x].max); max_y_array = format_unit_yaxes(value[x].max);
max_y = max_y_array["y"]; max_y = max_y_array["y"];
max_bigger = max_y_array["unit"]; max_bigger = max_y_array["unit"];
@ -2450,7 +2450,7 @@ function pandoraFlotArea(
max_bigger = ""; max_bigger = "";
} }
if (value[x].avg) { if (typeof value[x].avg !== "undefined" && value[x].avg) {
avg_y_array = format_unit_yaxes(value[x].avg); avg_y_array = format_unit_yaxes(value[x].avg);
avg_y = avg_y_array["y"]; avg_y = avg_y_array["y"];
avg_bigger = avg_y_array["unit"]; avg_bigger = avg_y_array["unit"];