Add label with macros in reports. Ticket: #37
This commit is contained in:
parent
11f1b67abd
commit
a804040d79
|
@ -51,6 +51,7 @@ $idAgent = null;
|
|||
$idAgentModule = null;
|
||||
$idCustomGraph = null;
|
||||
$text = null;
|
||||
$label = null;
|
||||
$header = null;
|
||||
$idCustom = null;
|
||||
$url = null;
|
||||
|
@ -553,7 +554,33 @@ switch ($action) {
|
|||
$max_values = $item ['top_n_value']; // Max values
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'event_report_agent':
|
||||
case 'simple_graph':
|
||||
case 'agent_configuration':
|
||||
case 'event_report_module':
|
||||
case 'alert_report_agent':
|
||||
case 'alert_report_module':
|
||||
case 'historical_data':
|
||||
case 'sumatory':
|
||||
case 'database_serialized':
|
||||
case 'monitor_report':
|
||||
case 'min_value':
|
||||
case 'max_value':
|
||||
case 'avg_value':
|
||||
case 'projection_graph':
|
||||
case 'prediction_date':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'simple_baseline_graph':
|
||||
$label = (isset($style['label'])) ? $style['label'] : '';
|
||||
break;
|
||||
default:
|
||||
$label = '';
|
||||
break;
|
||||
}
|
||||
//Restore db connection
|
||||
if ($meta && $server_name != '') {
|
||||
metaconsole_restore_db();
|
||||
|
@ -640,7 +667,6 @@ $class = 'databox filters';
|
|||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_description" style="" class="datos">
|
||||
<td style="font-weight:bold;"><?php echo __('Description'); ?></td>
|
||||
<td style="">
|
||||
|
@ -650,6 +676,16 @@ $class = 'databox filters';
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_label" style="" class="datos">
|
||||
<td style="font-weight:bold;"><?php echo __('Label') .
|
||||
ui_print_help_icon ('reports_label_field',true); ?></td>
|
||||
<td style="">
|
||||
<?php
|
||||
echo html_print_input_text ('label', $label, '', 50, 255, true);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_period" style="" class="datos">
|
||||
<td style="font-weight:bold;">
|
||||
<?php
|
||||
|
@ -2193,6 +2229,7 @@ function chooseType() {
|
|||
type = $("#type").val();
|
||||
|
||||
$("#row_description").hide();
|
||||
$("#row_label").hide();
|
||||
$("#row_period").hide();
|
||||
$("#row_agent").hide();
|
||||
$("#row_module").hide();
|
||||
|
@ -2740,6 +2777,31 @@ function chooseType() {
|
|||
$("#row_resolution").show();
|
||||
$("#row_servers").show();
|
||||
break;
|
||||
}
|
||||
switch (type) {
|
||||
case 'event_report_agent':
|
||||
case 'simple_graph':
|
||||
case 'agent_configuration':
|
||||
case 'event_report_module':
|
||||
case 'alert_report_agent':
|
||||
case 'alert_report_module':
|
||||
case 'historical_data':
|
||||
case 'sumatory':
|
||||
case 'database_serialized':
|
||||
case 'monitor_report':
|
||||
case 'min_value':
|
||||
case 'max_value':
|
||||
case 'avg_value':
|
||||
case 'projection_graph':
|
||||
case 'prediction_date':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'simple_baseline_graph':
|
||||
$("#row_label").show();
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -903,6 +903,7 @@ switch ($action) {
|
|||
$values['name'] = (string) get_parameter('name');
|
||||
$values['description'] = get_parameter('description');
|
||||
$values['type'] = get_parameter('type', null);
|
||||
$label = get_parameter('label', '');
|
||||
// Added support for projection graphs, prediction date and SLA reports
|
||||
// 'top_n_value','top_n' and 'text' fields will be reused for these types of report
|
||||
switch ($values['type']) {
|
||||
|
@ -1127,12 +1128,45 @@ switch ($action) {
|
|||
$style['event_filter_search'] =
|
||||
$event_filter_search;
|
||||
break;
|
||||
case 'event_report_agent':
|
||||
if ($label != '')
|
||||
$style['label'] = $label;
|
||||
else
|
||||
$style['label'] = '';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'simple_graph':
|
||||
// Warning. We are using this column to hold this value to avoid
|
||||
// the modification of the database for compatibility reasons.
|
||||
$style['only_avg'] = (int) get_parameter('only_avg');
|
||||
if ($label != '')
|
||||
$style['label'] = $label;
|
||||
else
|
||||
$style['label'] = '';
|
||||
break;
|
||||
case 'agent_configuration':
|
||||
case 'event_report_module':
|
||||
case 'alert_report_agent':
|
||||
case 'alert_report_module':
|
||||
case 'historical_data':
|
||||
case 'sumatory':
|
||||
case 'database_serialized':
|
||||
case 'monitor_report':
|
||||
case 'min_value':
|
||||
case 'max_value':
|
||||
case 'avg_value':
|
||||
case 'projection_graph':
|
||||
case 'prediction_date':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'simple_baseline_graph':
|
||||
if ($label != '')
|
||||
$style['label'] = $label;
|
||||
else
|
||||
$style['label'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1166,6 +1200,7 @@ switch ($action) {
|
|||
$values['type'] = get_parameter('type', null);
|
||||
$values['name'] = (string) get_parameter('name');
|
||||
$values['description'] = get_parameter('description');
|
||||
$label = get_parameter('label', '');
|
||||
|
||||
// Support for projection graph, prediction date and SLA reports
|
||||
// 'top_n_value', 'top_n' and 'text' fields will be reused for these types of report
|
||||
|
@ -1401,6 +1436,12 @@ switch ($action) {
|
|||
$style['event_filter_search'] =
|
||||
$event_filter_search;
|
||||
break;
|
||||
case 'event_report_agent':
|
||||
if ($label != '')
|
||||
$style['label'] = $label;
|
||||
else
|
||||
$style['label'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1408,6 +1449,33 @@ switch ($action) {
|
|||
// Warning. We are using this column to hold this value to avoid
|
||||
// the modification of the database for compatibility reasons.
|
||||
$style['only_avg'] = (int) get_parameter('only_avg');
|
||||
if ($label != '')
|
||||
$style['label'] = $label;
|
||||
else
|
||||
$style['label'] = '';
|
||||
break;
|
||||
case 'agent_configuration':
|
||||
case 'event_report_module':
|
||||
case 'alert_report_agent':
|
||||
case 'alert_report_module':
|
||||
case 'historical_data':
|
||||
case 'sumatory':
|
||||
case 'database_serialized':
|
||||
case 'monitor_report':
|
||||
case 'min_value':
|
||||
case 'max_value':
|
||||
case 'avg_value':
|
||||
case 'projection_graph':
|
||||
case 'prediction_date':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
case 'simple_baseline_graph':
|
||||
if ($label != '')
|
||||
$style['label'] = $label;
|
||||
else
|
||||
$style['label'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1498,6 +1498,17 @@ function agents_get_address ($id_agent) {
|
|||
return (string) db_get_value ('direccion', 'tagente', 'id_agente', (int) $id_agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description of an agent.
|
||||
*
|
||||
* @param int Agent id
|
||||
*
|
||||
* @return string The address of the given agent
|
||||
*/
|
||||
function agents_get_description ($id_agent) {
|
||||
return (string) db_get_value ('comentarios', 'tagente', 'id_agente', (int) $id_agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the agent that matches an IP address
|
||||
*
|
||||
|
|
|
@ -1024,6 +1024,17 @@ function modules_get_agentmodule_name ($id_agente_modulo) {
|
|||
return (string) db_get_value ('nombre', 'tagente_modulo', 'id_agente_modulo', (int) $id_agente_modulo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the module descripcion of an agent module.
|
||||
*
|
||||
* @param int $id_agente_modulo Agent module id.
|
||||
*
|
||||
* @return string descripcion of the given agent module.
|
||||
*/
|
||||
function modules_get_agentmodule_descripcion ($id_agente_modulo) {
|
||||
return (string) db_get_value ('descripcion', 'tagente_modulo', 'id_agente_modulo', (int) $id_agente_modulo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the module type of an agent module.
|
||||
*
|
||||
|
|
|
@ -123,7 +123,6 @@ function reporting_make_reporting_data($report = null, $id_report,
|
|||
return reporting_check_structure_report($report);
|
||||
}
|
||||
|
||||
|
||||
foreach ($contents as $content) {
|
||||
if (!empty($period)) {
|
||||
$content['period'] = $period;
|
||||
|
@ -1353,6 +1352,7 @@ function reporting_event_report_module($report, $content) {
|
|||
modules_get_agentmodule_name($content['id_agent_module']));
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$data = reporting_get_module_detailed_event(
|
||||
$content['id_agent_module'], $content['period'],
|
||||
|
@ -1520,6 +1520,7 @@ function reporting_agent_module($report, $content) {
|
|||
$return['subtitle'] = $group_name . " - " . $module_group_name;
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$return["data"] = array();
|
||||
|
||||
|
@ -2088,6 +2089,7 @@ function reporting_event_report_agent($report, $content,
|
|||
$return['subtitle'] = agents_get_name($content['id_agent']);
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$style = $content['style'];
|
||||
|
||||
|
@ -2222,6 +2224,7 @@ function reporting_historical_data($report, $content) {
|
|||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$return['keys'] = array(__('Date'), __('Data'));
|
||||
|
||||
|
@ -2258,6 +2261,7 @@ function reporting_database_serialized($report, $content) {
|
|||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$keys = array();
|
||||
if ($content['header_definition'] != '') {
|
||||
|
@ -2683,6 +2687,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||
$return['subtitle'] = $agent_name;
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$alerts = agents_get_alerts($content['id_agent']);
|
||||
|
||||
|
@ -2812,6 +2817,7 @@ function reporting_alert_report_module($report, $content) {
|
|||
$return['subtitle'] = $agent_name . " - " . $module_name;
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
|
@ -3003,6 +3009,7 @@ function reporting_monitor_report($report, $content) {
|
|||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
||||
|
@ -3156,6 +3163,7 @@ function reporting_simple_baseline_graph($report, $content,
|
|||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
// Get chart
|
||||
reporting_set_conf_charts($width, $height, $only_image, $type,
|
||||
|
@ -3216,6 +3224,7 @@ function reporting_prediction_date($report, $content) {
|
|||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name($content['id_agent_module']));
|
||||
|
@ -3265,8 +3274,7 @@ function reporting_projection_graph($report, $content,
|
|||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
|
||||
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name($content['id_agent_module']));
|
||||
|
@ -3352,6 +3360,7 @@ function reporting_agent_configuration($report, $content) {
|
|||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
||||
|
@ -3538,6 +3547,7 @@ function reporting_value($report, $content, $type) {
|
|||
$return['subtitle'] = $agent_name . " - " . $module_name;
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
$return['agent_name'] = $agent_name;
|
||||
$return['module_name'] = $module_name;
|
||||
|
@ -4358,6 +4368,12 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
|
|||
array_push ($weights, $graph_item["weight"]);
|
||||
}
|
||||
|
||||
$labels = array();
|
||||
if (in_array('label',$content['style'])) {
|
||||
$label = reporting_label_macro($content, $content['style']['label']);
|
||||
$labels = array_fill_keys($modules, $label);
|
||||
}
|
||||
|
||||
$return['chart'] = '';
|
||||
// Get chart
|
||||
reporting_set_conf_charts($width, $height, $only_image, $type,
|
||||
|
@ -4382,7 +4398,17 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
|
|||
$report["datetime"],
|
||||
$only_image,
|
||||
ui_get_full_url(false, false, false, false),
|
||||
$ttl);
|
||||
$ttl,
|
||||
false,
|
||||
false,
|
||||
'white',
|
||||
array(),
|
||||
array(),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
$labels);
|
||||
break;
|
||||
case 'data':
|
||||
break;
|
||||
|
@ -4440,6 +4466,10 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
|||
$return["date"] = reporting_get_date_text(
|
||||
$report,
|
||||
$content);
|
||||
$label = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
if ($label != '') {
|
||||
$label = reporting_label_macro($content, $label);
|
||||
}
|
||||
|
||||
$only_avg = true;
|
||||
// Due to database compatibility problems, the 'only_avg' value
|
||||
|
@ -4480,7 +4510,7 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
|||
false,
|
||||
$width,
|
||||
$height,
|
||||
'',
|
||||
$label,
|
||||
'',
|
||||
false,
|
||||
$only_avg,
|
||||
|
@ -4505,7 +4535,7 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
|||
false,
|
||||
$width,
|
||||
$height,
|
||||
'',
|
||||
$label,
|
||||
'',
|
||||
false,
|
||||
$only_avg,
|
||||
|
@ -8749,4 +8779,82 @@ function reporting_get_agentmodule_sla_working_timestamp ($period, $date_end, $w
|
|||
return $wt;
|
||||
}
|
||||
|
||||
function reporting_label_macro ($item, $label) {
|
||||
|
||||
switch ($item['type']) {
|
||||
case 'event_report_agent':
|
||||
case 'alert_report_agent':
|
||||
case 'agent_configuration':
|
||||
if (preg_match("/_agent_/", $label)) {
|
||||
$agent_name = agents_get_name($item['id_agent']);
|
||||
$label = str_replace("_agent_", $agent_name, $label);
|
||||
}
|
||||
|
||||
if (preg_match("/_agentdescription_/", $label)) {
|
||||
$agent_name = agents_get_description($item['id_agent']);
|
||||
$label = str_replace("_agentdescription_", $agent_name, $label);
|
||||
}
|
||||
|
||||
if (preg_match("/_agentgroup_/", $label)) {
|
||||
$agent_name = groups_get_name(agents_get_agent_group($item['id_agent']),true);
|
||||
$label = str_replace("_agentgroup_", $agent_name, $label);
|
||||
}
|
||||
|
||||
if (preg_match("/_address_/", $label)) {
|
||||
$agent_name = agents_get_address($item['id_agent']);
|
||||
$label = str_replace("_address_", $agent_name, $label);
|
||||
}
|
||||
break;
|
||||
case 'simple_graph':
|
||||
case 'custom_graph':
|
||||
case 'simple_baseline_graph':
|
||||
case 'event_report_module':
|
||||
case 'alert_report_module':
|
||||
case 'historical_data':
|
||||
case 'sumatory':
|
||||
case 'database_serialized':
|
||||
case 'monitor_report':
|
||||
case 'min_value':
|
||||
case 'max_value':
|
||||
case 'avg_value':
|
||||
case 'projection_graph':
|
||||
case 'prediction_date':
|
||||
case 'TTRT':
|
||||
case 'TTO':
|
||||
case 'MTBF':
|
||||
case 'MTTR':
|
||||
if (preg_match("/_agent_/", $label)) {
|
||||
$agent_name = agents_get_name($item['id_agent']);
|
||||
$label = str_replace("_agent_", $agent_name, $label);
|
||||
}
|
||||
|
||||
if (preg_match("/_agentdescription_/", $label)) {
|
||||
$agent_name = agents_get_description($item['id_agent']);
|
||||
$label = str_replace("_agentdescription_", $agent_name, $label);
|
||||
}
|
||||
|
||||
if (preg_match("/_agentgroup_/", $label)) {
|
||||
$agent_name = groups_get_name(agents_get_agent_group($item['id_agent']),true);
|
||||
$label = str_replace("_agentgroup_", $agent_name, $label);
|
||||
}
|
||||
|
||||
if (preg_match("/_address_/", $label)) {
|
||||
$agent_name = agents_get_address($item['id_agent']);
|
||||
$label = str_replace("_address_", $agent_name, $label);
|
||||
}
|
||||
|
||||
if (preg_match("/_module_/", $label)) {
|
||||
$module_name = modules_get_agentmodule_name($item['id_agent_module']);
|
||||
$label = str_replace("_module_", $module_name, $label);
|
||||
}
|
||||
|
||||
if (preg_match("/_moduledescription_/", $label)) {
|
||||
$module_description = modules_get_agentmodule_descripcion($item['id_agent_module']);
|
||||
$label = str_replace("_moduledescription_", $module_description, $label);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -38,7 +38,7 @@ include_once($config['homedir'] . "/include/functions_ui.php");
|
|||
include_once($config['homedir'] . "/include/functions_netflow.php");
|
||||
|
||||
function reporting_html_header(&$table, $mini, $title, $subtitle,
|
||||
$period, $date, $from, $to) {
|
||||
$period, $date, $from, $to, $label = '') {
|
||||
|
||||
global $config;
|
||||
|
||||
|
@ -73,7 +73,8 @@ function reporting_html_header(&$table, $mini, $title, $subtitle,
|
|||
|
||||
$data = array();
|
||||
if (empty($subtitle) && (empty($date_text))) {
|
||||
$data[] = $sizh . $title . $sizhfin;
|
||||
$title = $sizh . $title . $sizhfin;
|
||||
$data[] = $title;
|
||||
$table->colspan[0][0] = 3;
|
||||
}
|
||||
else if (empty($subtitle)) {
|
||||
|
@ -87,7 +88,11 @@ function reporting_html_header(&$table, $mini, $title, $subtitle,
|
|||
$table->colspan[0][1] = 2;
|
||||
}
|
||||
else {
|
||||
$data[] = $sizh . $title . $sizhfin;
|
||||
$title = $sizh . $title;
|
||||
if ($label != '') {
|
||||
$title .= '<br >' . __('Label: ') . $label;
|
||||
}
|
||||
$data[] = $title . $sizhfin;
|
||||
$data[] = $sizh . $subtitle . $sizhfin;
|
||||
$data[] = "<div style='text-align: right;'>" . $sizh . $date_text . $sizhfin . "</div>";
|
||||
}
|
||||
|
@ -111,14 +116,19 @@ function reporting_html_print_report($report, $mini = false) {
|
|||
$table->colspan = array ();
|
||||
$table->rowstyle = array ();
|
||||
|
||||
|
||||
if (isset($item['label']) && $item['label'] != '') {
|
||||
$label = reporting_label_macro($item, $item['label']);
|
||||
}
|
||||
else
|
||||
$label = '';
|
||||
reporting_html_header($table,
|
||||
$mini, $item['title'],
|
||||
$item['subtitle'],
|
||||
$item['date']['period'],
|
||||
$item['date']['date'],
|
||||
$item['date']['from'],
|
||||
$item['date']['to']);
|
||||
$item['date']['to'],
|
||||
$label);
|
||||
|
||||
if ($item["description"] != "") {
|
||||
$table->data['description_row']['description'] = $item["description"];
|
||||
|
|
|
@ -265,7 +265,8 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
|
|||
$vconsole,
|
||||
$agent_module_id,
|
||||
$font,
|
||||
$font_size);
|
||||
$font_size,
|
||||
$xaxisname);
|
||||
}
|
||||
else {
|
||||
$graph = array();
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
CAxis Labels Plugin for flot. :P
|
||||
Copyright (c) 2010 Xuan Luo
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
(function ($) {
|
||||
var options = { };
|
||||
|
||||
function init(plot) {
|
||||
// This is kind of a hack. There are no hooks in Flot between
|
||||
// the creation and measuring of the ticks (setTicks, measureTickLabels
|
||||
// in setupGrid() ) and the drawing of the ticks and plot box
|
||||
// (insertAxisLabels in setupGrid() ).
|
||||
//
|
||||
// Therefore, we use a trick where we run the draw routine twice:
|
||||
// the first time to get the tick measurements, so that we can change
|
||||
// them, and then have it draw it again.
|
||||
var secondPass = false;
|
||||
plot.hooks.draw.push(function (plot, ctx) {
|
||||
if (!secondPass) {
|
||||
// MEASURE AND SET OPTIONS
|
||||
$.each(plot.getAxes(), function(axisName, axis) {
|
||||
var opts = axis.options // Flot 0.7
|
||||
|| plot.getOptions()[axisName]; // Flot 0.6
|
||||
if (!opts || !opts.axisLabel)
|
||||
return;
|
||||
|
||||
var w, h;
|
||||
if (opts.axisLabelUseCanvas != false)
|
||||
opts.axisLabelUseCanvas = true;
|
||||
|
||||
if (opts.axisLabelUseCanvas) {
|
||||
// canvas text
|
||||
if (!opts.axisLabelFontSizePixels)
|
||||
opts.axisLabelFontSizePixels = 14;
|
||||
if (!opts.axisLabelFontFamily)
|
||||
opts.axisLabelFontFamily = 'sans-serif';
|
||||
// since we currently always display x as horiz.
|
||||
// and y as vertical, we only care about the height
|
||||
w = opts.axisLabelFontSizePixels;
|
||||
h = opts.axisLabelFontSizePixels;
|
||||
|
||||
} else {
|
||||
// HTML text
|
||||
var elem = $('<div class="axisLabels" style="position:absolute;">' + opts.axisLabel + '</div>');
|
||||
plot.getPlaceholder().append(elem);
|
||||
w = elem.outerWidth(true);
|
||||
h = elem.outerHeight(true);
|
||||
elem.remove();
|
||||
}
|
||||
|
||||
if (axisName.charAt(0) == 'x')
|
||||
axis.labelHeight += h;
|
||||
else
|
||||
axis.labelWidth += w;
|
||||
opts.labelHeight = axis.labelHeight;
|
||||
opts.labelWidth = axis.labelWidth;
|
||||
});
|
||||
// re-draw with new label widths and heights
|
||||
secondPass = true;
|
||||
plot.setupGrid();
|
||||
plot.draw();
|
||||
|
||||
|
||||
} else {
|
||||
// DRAW
|
||||
$.each(plot.getAxes(), function(axisName, axis) {
|
||||
var opts = axis.options // Flot 0.7
|
||||
|| plot.getOptions()[axisName]; // Flot 0.6
|
||||
if (!opts || !opts.axisLabel)
|
||||
return;
|
||||
|
||||
if (opts.axisLabelUseCanvas) {
|
||||
// canvas text
|
||||
var ctx = plot.getCanvas().getContext('2d');
|
||||
ctx.save();
|
||||
ctx.font = opts.axisLabelFontSizePixels + 'px ' +
|
||||
opts.axisLabelFontFamily;
|
||||
var width = ctx.measureText(opts.axisLabel).width;
|
||||
var height = opts.axisLabelFontSizePixels;
|
||||
var x, y;
|
||||
if (axisName.charAt(0) == 'x') {
|
||||
x = plot.getPlotOffset().left + plot.width()/2 - width/2;
|
||||
y = plot.getCanvas().height;
|
||||
} else {
|
||||
x = height * 0.72;
|
||||
y = plot.getPlotOffset().top + plot.height()/2 - width/2;
|
||||
}
|
||||
ctx.translate(x, y);
|
||||
ctx.rotate((axisName.charAt(0) == 'x') ? 0 : -Math.PI/2);
|
||||
ctx.fillText(opts.axisLabel, 0, 0);
|
||||
ctx.restore();
|
||||
|
||||
} else {
|
||||
// HTML text
|
||||
plot.getPlaceholder().find('#' + axisName + 'Label').remove();
|
||||
var elem = $('<div id="' + axisName + 'Label" class="axisLabels" style="position:absolute;">' + opts.axisLabel + '</div>');
|
||||
if (axisName.charAt(0) == 'x') {
|
||||
//~ elem.css('left', plot.getPlotOffset().left + plot.width()/4 - elem.outerWidth()/2 + 'px');
|
||||
elem.css('bottom', '0px');
|
||||
elem.css('width', '100%');
|
||||
} else {
|
||||
elem.css('top', plot.getPlotOffset().top + plot.height()/2 - elem.outerHeight()/2 + 'px');
|
||||
elem.css('left', '0px');
|
||||
}
|
||||
plot.getPlaceholder().append(elem);
|
||||
}
|
||||
});
|
||||
secondPass = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'axisLabels',
|
||||
version: '1.0'
|
||||
});
|
||||
})(jQuery);
|
|
@ -851,7 +851,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
alert_ids, legend_alerts, yellow_threshold, red_threshold,
|
||||
force_integer, separator, separator2,
|
||||
yellow_up, red_up, yellow_inverse, red_inverse,
|
||||
series_suffix_str, dashboard, vconsole) {
|
||||
series_suffix_str, dashboard, vconsole, xaxisname) {
|
||||
|
||||
var threshold = true;
|
||||
var thresholded = false;
|
||||
|
@ -1537,6 +1537,9 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
markings: markings
|
||||
},
|
||||
xaxes: [ {
|
||||
axisLabelFontSizePixels: font_size,
|
||||
axisLabelUseCanvas: false,
|
||||
axisLabel: xaxisname,
|
||||
tickFormatter: xFormatter,
|
||||
minTickSize: steps,
|
||||
color: '#000'
|
||||
|
|
|
@ -52,6 +52,8 @@ function include_javascript_dependencies_flot_graph($return = false) {
|
|||
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.symbol.min.js') .'"></script>
|
||||
<script language="javascript" type="text/javascript" src="'.
|
||||
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.exportdata.pandora.js') .'"></script>
|
||||
<script language="javascript" type="text/javascript" src="'.
|
||||
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.axislabels.js') .'"></script>
|
||||
<script language="javascript" type="text/javascript" src="'.
|
||||
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/pandora.flot.js') .'"></script>';
|
||||
$output .= "
|
||||
|
@ -112,7 +114,7 @@ function flot_area_simple_graph($chart_data, $width, $height, $color,
|
|||
$serie_types = array(), $chart_extra_data = array(),
|
||||
$yellow_threshold = 0, $red_threshold = 0, $adapt_key= '',
|
||||
$force_integer = false, $series_suffix_str = '', $menu = true,
|
||||
$background_color = 'white', $dashboard = false, $vconsole = false, $agent_module_id = 0, $font = '',$font_size = 7) {
|
||||
$background_color = 'white', $dashboard = false, $vconsole = false, $agent_module_id = 0, $font = '',$font_size = 7, $xaxisname = '') {
|
||||
|
||||
global $config;
|
||||
|
||||
|
@ -120,7 +122,7 @@ function flot_area_simple_graph($chart_data, $width, $height, $color,
|
|||
$legend, $long_index, $homeurl, $unit, 'area_simple',
|
||||
$water_mark, $serie_types, $chart_extra_data, $yellow_threshold,
|
||||
$red_threshold, $adapt_key, $force_integer, $series_suffix_str,
|
||||
$menu, $background_color, $dashboard, $vconsole, $agent_module_id,$font,$font_size);
|
||||
$menu, $background_color, $dashboard, $vconsole, $agent_module_id,$font,$font_size, $xaxisname);
|
||||
}
|
||||
|
||||
function flot_line_stacked_graph($chart_data, $width, $height, $color,
|
||||
|
@ -159,7 +161,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
|
|||
$long_index, $homeurl, $unit, $type, $water_mark, $serie_types,
|
||||
$chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key,
|
||||
$force_integer, $series_suffix_str = '', $menu = true,
|
||||
$background_color = 'white', $dashboard = false, $vconsole = false, $agent_module_id = 0,$font = '',$font_size = 7) {
|
||||
$background_color = 'white', $dashboard = false, $vconsole = false, $agent_module_id = 0,$font = '',$font_size = 7, $xaxisname = '') {
|
||||
|
||||
global $config;
|
||||
|
||||
|
@ -449,7 +451,8 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
|
|||
"'$red_inverse', \n" .
|
||||
"'$series_suffix_str',
|
||||
" . json_encode($dashboard) . ",\n
|
||||
" . json_encode($vconsole) . ");";
|
||||
" . json_encode($vconsole) . ",\n" .
|
||||
"'$xaxisname');";
|
||||
$return .= "\n//]]>";
|
||||
$return .= "</script>";
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Include/help/en
|
||||
*/
|
||||
?>
|
||||
<h1>Reports - Label field macros</h1>
|
||||
<p>
|
||||
|
||||
The following macros are also available: <br />
|
||||
<ul>
|
||||
<li><b>_agent_ </b>: Name of the agent that you selected in report item.<li />
|
||||
<li><b>_agentdescription_ </b>: Description of the agent that you selected in report item.<li />
|
||||
<li><b>_agentgroup_ </b>: Agent group name.<li />
|
||||
<li><b>_address_</b> : Address of the agent that you selected in report item.<li />
|
||||
<ul />
|
||||
<br />
|
||||
|
||||
<ul>
|
||||
Only if in form you can select a agent module.<br />
|
||||
<li><b>_module_ </b>: Module name that you selected in report item.<li />
|
||||
<li><b>_moduledescription_</b> : Description of the module that you selected in report item.<li />
|
||||
<ul />
|
||||
Example: Agent: <b>_agent_</b> / module: <b>_module_</b><br />
|
||||
|
||||
</p>
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* @package include/help/es
|
||||
*/
|
||||
?>
|
||||
<h1>Informes - Macros del campo etiqueta</h1>
|
||||
<p>
|
||||
|
||||
Lista de las macros admitidas en este campo: <br />
|
||||
<ul>
|
||||
<li><b>_agent_ </b>: Nombre del agente que ha seleccionado en el elemento del informe.<li />
|
||||
<li><b>_agentdescription_ </b>: Descripción del agente que ha seleccionado en el elemento del informe.<li />
|
||||
<li><b>_agentgroup_ </b>: Grupo del agente que ha seleccionado en el elemento del informe<li />
|
||||
<li><b>_address_</b> : Dirección del agente que ha seleccionado en el elemento del informe<li />
|
||||
<ul />
|
||||
<br />
|
||||
|
||||
<ul>
|
||||
Solamente si ha podido o puede seleccionar un módulo de agente en el elemento del informe.<br />
|
||||
<li><b>_module_ </b>: Nombre del módulo de agente que ha seleccionado en el elemento del informe.<li />
|
||||
<li><b>_moduledescription_</b> : Descripción del módulo de agente que ha seleccionado en el elemento del informe.<li />
|
||||
<ul />
|
||||
Ejemplo: Agente: <b>_agent_</b> / Módulo: <b>_module_</b><br />
|
||||
|
||||
</p>
|
Loading…
Reference in New Issue