add new report custom render pandora_enterprise#8540

This commit is contained in:
Daniel Barbero Martin 2022-04-04 14:40:20 +02:00
parent 863e6c887f
commit 502b5ab0db
6 changed files with 149 additions and 20 deletions

View File

@ -4630,6 +4630,9 @@ ui_require_javascript_file(
'pandora_inventory',
ENTERPRISE_DIR.'/include/javascript/'
);
ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
ui_require_javascript_file('pandora');
?>
<script type="text/javascript">
@ -4867,6 +4870,14 @@ $(document).ready (function () {
});
});
var added_config = {
"elements": "textarea_render_definition",
"plugins": "preview, print, table, searchreplace, nonbreaking, xhtmlxtras, noneditable",
"theme_advanced_buttons1": "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
"theme_advanced_buttons2": "search,replace,|,bullist,numlist,|,undo,redo,|,link,unlink,image,|,cleanup,code,preview,|,forecolor,backcolor"
}
defineTinyMCE(added_config);
$("#checkbox-select_by_group").change(function () {
var select_by_group = $('#checkbox-select_by_group').prop('checked');
@ -6865,12 +6876,19 @@ function cleanCustomFieldRow(row) {
// Default value.
$("#macro_custom_name").val('');
$("#macro_custom_value").val('');
$("#macro_custom_width").val('');
} else {
$("#macro_custom_name_"+row).val('');
$("#macro_custom_value_"+row).val('');
$("#macro_custom_width_"+row).val('');
$("#macro_custom_height_"+row).val('');
}
$("#macro_custom_height_"+row).val('');
$("#macro_custom_period_"+row).val('');
$("#text-macro_custom_value_agent_name_"+row).val('');
$("#macro_custom_value"+row+"id_agent_module")
.val('')
.trigger('change');
}
function removeCustomFieldRow(row) {

View File

@ -1859,8 +1859,6 @@ switch ($action) {
$macro_custom_key = get_parameter('macro_custom_key', []);
$macros_definition = [];
hd($_POST);
foreach ($macro_custom_name as $key_macro => $value_macro) {
$kl = (empty($macro_custom_key[$key_macro]) === true) ? 0 : $macro_custom_key[$key_macro];
$macros_definition[$key_macro]['name'] = $value_macro;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 775 B

View File

@ -4770,8 +4770,19 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
if ($data_query === false) {
$value_query = __('Error: %s', $config['dbconnection']->error);
} else {
$width = (isset($data_macro['width']) === true) ? $data_macro['width'] : 210;
$height = (isset($data_macro['height']) === true) ? $data_macro['height'] : 210;
$width = 210;
if (isset($data_macro['width']) === true
&& empty($data_macro['width']) === false
) {
$width = $data_macro['width'];
}
$height = 210;
if (isset($data_macro['height']) === true
&& empty($data_macro['height']) === false
) {
$height = $data_macro['height'];
}
// TODO: Allow to paint horizontal and vertical bar graphs for the moment only pie graphs.
$type = 'sql_graph_pie';
@ -4885,14 +4896,39 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
break;
case 3:
// Type: SQL graph.
// Type: Simple graph.
$patterns[] = addslashes(
'/_'.$data_macro['name'].'_/'
);
$height = $config['graph_image_height'];
if (isset($data_macro['height']) === true
&& empty($data_macro['height']) === false
) {
$height = $data_macro['height'];
}
$period = SECONDS_1DAY;
if (isset($data_macro['period']) === true
&& empty($data_macro['period']) === false
) {
$period = $data_macro['period'];
}
if (is_metaconsole() === true) {
$server = db_get_row(
'tmetaconsole_setup',
'id',
$data_macro['server_id']
);
if (metaconsole_connect($server) != NOERR) {
continue;
}
}
$params = [
'agent_module_id' => $data_macro['id_agent_module'],
'period' => 86400,
'period' => $period,
'title' => '',
'label' => '',
'pure' => false,
@ -4905,12 +4941,17 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
),
'ttl' => 2,
'show_unknown' => true,
'height' => $config['graph_image_height'],
'height' => $height,
'backgroundColor' => 'transparent',
'return_img_base_64' => true,
'server_id' => (is_metaconsole() === true) ? $data_macro['server_id'] : 0,
];
$substitutions[] = '<img style="max-width:100%;" src="data:image/png;base64,'.grafico_modulo_sparse($params).'" />';
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
break;
default:

View File

@ -818,10 +818,13 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Grouped'),
'name' => __('Network interfaces'),
];
$types['custom_render'] = [
'optgroup' => __('Grouped'),
'name' => __('Custom Render'),
];
if (!$template) {
$types['custom_render'] = [
'optgroup' => __('Grouped'),
'name' => __('Custom Render'),
];
}
$types['availability'] = [
'optgroup' => __('Grouped'),
'name' => __('Availability'),
@ -1264,7 +1267,6 @@ function custom_fields_macros_report($macro, $key_macro)
$params = [];
$params['show_helptip'] = true;
$params['input_name'] = 'macro_custom_value_agent_name_'.$key_macro;
$params['value'] = agents_get_alias($macro['agent_id']);
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'macro_custom_value_agent_id_'.$key_macro;
$params['hidden_input_idagent_name'] = 'macro_custom_value['.$key_macro.'][agent_id]';
@ -1275,22 +1277,57 @@ function custom_fields_macros_report($macro, $key_macro)
$params['return'] = true;
$params['disabled_javascript_on_blur_function'] = true;
// TODO: Metaconsole.
// if (is_metaconsole() === true) {
// $params['use_input_id_server'] = true;
// $params['input_id_server_id'] = 'hidden-id_server';
// }
if (is_metaconsole() === true) {
$params['print_input_id_server'] = true;
$params['metaconsole_enabled'] = true;
$params['input_id_server_id'] = 'macro_custom_value_id_server_'.$key_macro;
$params['input_id_server_name'] = 'macro_custom_value['.$key_macro.'][server_id]';
$params['input_id_server_value'] = $macro['server_id'];
$params['value'] = agents_meta_get_alias(
$macro['agent_id'],
'none',
$macro['server_id'],
true
);
} else {
$params['value'] = agents_get_alias($macro['agent_id']);
}
$result['size'] = '<div class="custom-field-macro-report mb10">';
$result['size'] .= '<label>';
$result['size'] .= __('Agent');
$result['size'] .= '</label>';
$result['size'] .= ui_print_agent_autocomplete_input($params);
$modules = [];
if ($macro['agent_id']) {
if (isset($macro['agent_id']) === true
&& empty($macro['agent_id']) === false
) {
if (is_metaconsole() === true) {
$server = db_get_row(
'tmetaconsole_setup',
'id',
$macro['server_id']
);
if (metaconsole_connect($server) != NOERR) {
continue;
}
}
$modules = agents_get_modules(
$macro['agent_id'],
false,
['delete_pending' => 0]
);
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
}
$result['size'] .= '<label>';
$result['size'] .= __('Module');
$result['size'] .= '</label>';
$result['size'] .= html_print_select(
$modules,
'macro_custom_value['.$key_macro.'][id_agent_module]',
@ -1305,6 +1342,41 @@ function custom_fields_macros_report($macro, $key_macro)
(empty($macro['agent_id']) === true),
'min-width: 250px;margin-right: 0.5em;'
);
$result['size'] .= '</div>';
$result['size'] .= '<div class="custom-field-macro-report">';
$result['size'] .= '<label>';
$result['size'] .= __('Height');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][height]',
$macro['height'],
($key_macro === 0) ? 'macro_custom_height' : 'macro_custom_height_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '<label>';
$result['size'] .= __('Period ');
$result['size'] .= '</label>';
$result['size'] .= html_print_input_text_extended(
'macro_custom_value['.$key_macro.'][period]',
$macro['period'],
($key_macro === 0) ? 'macro_custom_period' : 'macro_custom_period_'.$key_macro,
'',
5,
255,
false,
'',
'',
true
);
$result['size'] .= '</div>';
break;
default:

View File

@ -8599,7 +8599,7 @@ div#err_msg_centralised {
line-height: 16pt;
padding: 0px;
box-sizing: border-box;
page-break-after: always;
/*page-break-after: always;*/
}
#reset-styles a:link {