Working in the refactoring the code of reports (sql_graph_vbar, sql_graph_hbar, sql_graph_pie).
This commit is contained in:
parent
c24d8f22e7
commit
2b665f8117
|
@ -306,12 +306,103 @@ function reporting_make_reporting_data($id_report, $date, $time,
|
|||
$report,
|
||||
$content);
|
||||
break;
|
||||
case 'sql_graph_vbar':
|
||||
$report['contents'][] = reporting_sql_graph(
|
||||
$report,
|
||||
$content,
|
||||
$type,
|
||||
$force_width_chart,
|
||||
$force_height_chart,
|
||||
'sql_graph_vbar');
|
||||
break;
|
||||
case 'sql_graph_hbar':
|
||||
$report['contents'][] = reporting_sql_graph(
|
||||
$report,
|
||||
$content,
|
||||
$type,
|
||||
$force_width_chart,
|
||||
$force_height_chart,
|
||||
'sql_graph_hbar');
|
||||
break;
|
||||
case 'sql_graph_pie':
|
||||
$report['contents'][] = reporting_sql_graph(
|
||||
$report,
|
||||
$content,
|
||||
$type,
|
||||
$force_width_chart,
|
||||
$force_height_chart,
|
||||
'sql_graph_pie');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return reporting_check_structure_report($report);
|
||||
}
|
||||
|
||||
function reporting_sql_graph($report, $content, $type,
|
||||
$force_width_chart, $force_height_chart, $type_sql_graph) {
|
||||
|
||||
global $config;
|
||||
|
||||
switch ($type_sql_graph) {
|
||||
case 'netflow_area':
|
||||
$return['type'] = 'sql_graph_vbar';
|
||||
break;
|
||||
case 'sql_graph_hbar':
|
||||
$return['type'] = 'sql_graph_hbar';
|
||||
break;
|
||||
case 'sql_graph_pie':
|
||||
$return['type'] = 'sql_graph_pie';
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($content['name'])) {
|
||||
switch ($type_sql_graph) {
|
||||
case 'sql_graph_vbar':
|
||||
$return['name'] = __('SQL Graph Vertical Bars');
|
||||
break;
|
||||
case 'sql_graph_hbar':
|
||||
$return['name'] = __('SQL Graph Horizontal Bars');
|
||||
break;
|
||||
case 'sql_graph_pie':
|
||||
$return['name'] = __('SQL Graph Pie');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get chart
|
||||
reporting_set_conf_charts($width, $height, $only_image, $type, $content);
|
||||
|
||||
if (!empty($force_width_chart)) {
|
||||
$width = $force_width_chart;
|
||||
}
|
||||
|
||||
if (!empty($force_height_chart)) {
|
||||
$height = $force_height_chart;
|
||||
}
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text();
|
||||
|
||||
switch ($type) {
|
||||
case 'dinamic':
|
||||
case 'static':
|
||||
$return['chart'] = graph_custom_sql_graph(
|
||||
$content["id_rc"],
|
||||
$width,
|
||||
$height,
|
||||
$content["type"],
|
||||
true,
|
||||
ui_get_full_url(false, false, false, false));
|
||||
break;
|
||||
case 'data':
|
||||
break;
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_monitor_report($report, $content) {
|
||||
global $config;
|
||||
|
||||
|
|
|
@ -200,6 +200,15 @@ function reporting_html_print_report($report, $mini = false) {
|
|||
case 'monitor_report':
|
||||
reporting_html_monitor_report($table, $item, $mini);
|
||||
break;
|
||||
case 'sql_graph_vbar':
|
||||
reporting_html_sql_graph($table, $item);
|
||||
break;
|
||||
case 'sql_graph_hbar':
|
||||
reporting_html_sql_graph($table, $item);
|
||||
break;
|
||||
case 'sql_graph_pie':
|
||||
reporting_html_sql_graph($table, $item);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($item['type'] == 'agent_module')
|
||||
|
@ -212,6 +221,12 @@ function reporting_html_print_report($report, $mini = false) {
|
|||
}
|
||||
}
|
||||
|
||||
function reporting_html_sql_graph($table, $item) {
|
||||
$table->colspan['chart']['cell'] = 3;
|
||||
$table->cellstyle['chart']['cell'] = 'text-align: center;';
|
||||
$table->data['chart']['cell'] = $item['chart'];
|
||||
}
|
||||
|
||||
function reporting_html_monitor_report($table, $item, $mini) {
|
||||
if ($mini) {
|
||||
$font_size = '1.5';
|
||||
|
@ -4092,57 +4107,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
}
|
||||
break;
|
||||
|
||||
case 'sql_graph_vbar':
|
||||
case 'sql_graph_hbar':
|
||||
case 'sql_graph_pie':
|
||||
$sizgraph_h = 300;
|
||||
|
||||
if ($content['type'] == 'sql_graph_vbar') {
|
||||
$sizgraph_h = 400;
|
||||
}
|
||||
|
||||
if ($config['metaconsole'] == 1 && defined('METACONSOLE'))
|
||||
metaconsole_restore_db();
|
||||
|
||||
if (empty($item_title)) {
|
||||
$item_title = __('User defined graph') . " (".__($content["type"]) .")";
|
||||
}
|
||||
reporting_header_content($mini, $content, $report, $table, $item_title,
|
||||
"", "");
|
||||
|
||||
// Put description at the end of the module (if exists)
|
||||
$next_row = 1;
|
||||
if ($content["description"] != "") {
|
||||
$data_desc = array();
|
||||
$data_desc[0] = $content["description"];
|
||||
array_push ($table->data, $data_desc);
|
||||
$table->colspan[$next_row][0] = 3;
|
||||
$next_row++;
|
||||
}
|
||||
|
||||
$table->colspan[$next_row][0] = 3;
|
||||
|
||||
$table2->class = 'databox';
|
||||
$table2->width = '100%';
|
||||
|
||||
//Create the head
|
||||
$table2->head = array();
|
||||
if ($content['header_definition'] != '') {
|
||||
$table2->head = explode('|', $content['header_definition']);
|
||||
}
|
||||
|
||||
$data = array ();
|
||||
|
||||
$data[0] = graph_custom_sql_graph(
|
||||
$content["id_rc"],
|
||||
$sizgraph_w,
|
||||
$sizgraph_h,
|
||||
$content["type"],
|
||||
true,
|
||||
ui_get_full_url(false, false, false, false));
|
||||
|
||||
array_push($table->data, $data);
|
||||
break;
|
||||
case 'event_report_group':
|
||||
if (empty($item_title)) {
|
||||
$item_title = __('Group detailed event');
|
||||
|
|
Loading…
Reference in New Issue