Merge branch 'ent-10012-item-grafico-coincidencias-informe-logs' into 'develop'

Ent 10012 item grafico coincidencias informe logs

See merge request artica/pandorafms!5989
This commit is contained in:
Gorka Sanchez 2023-07-10 14:12:09 +00:00
commit 31eea778ee
7 changed files with 185 additions and 2 deletions

View File

@ -12,4 +12,6 @@ DELETE FROM tconfig WHERE token = 'refr';
ALTER TABLE `tusuario` ADD COLUMN `session_max_time_expire` INT NOT NULL DEFAULT 0 AFTER `auth_token_secret`;
ALTER TABLE `treport_content` ADD COLUMN `period_range` INT NULL DEFAULT 0 AFTER `period`;
COMMIT;

View File

@ -321,6 +321,21 @@ switch ($action) {
$full_text = empty($es['full_text']) ? 0 : $es['full_text'];
break;
case 'event_report_log_table':
$period = $item['period'];
$period_range = $item['period_range'];
$description = $item['description'];
$es = json_decode($item['external_source'], true);
$id_agents = $es['id_agents'];
$source = $es['source'];
$search = $es['search'];
$log_number = empty($es['log_number']) ? $log_number : $es['log_number'];
$full_text = empty($es['full_text']) ? 0 : $es['full_text'];
$show_graph = $item['show_graph'];
$group_by_agent = $item['group_by_agent'];
break;
case 'simple_graph':
$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
$percentil = isset($style['percentil']) ? (bool) $style['percentil'] : 0;
@ -1025,6 +1040,7 @@ switch ($action) {
case 'prediction_date':
case 'simple_baseline_graph':
case 'event_report_log':
case 'event_report_log_table':
case 'increment':
$label = (isset($style['label'])) ? $style['label'] : '';
break;
@ -1411,6 +1427,29 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_period_range" class="datos">
<td class="bolder">
<?php
echo __('Period range');
ui_print_help_tip(
__('This is the time range in which the files are grouped. For example, 1 day will group the files by day and will count them.')
);
?>
</td>
<td >
<?php
html_print_extended_select_for_time(
'period_range',
$period_range,
'',
'',
'0',
10
);
?>
</td>
</tr>
<tr id="row_last_value" class="datos">
<td class="bolder" class="datos">
<?php
@ -5295,6 +5334,12 @@ $(document).ready (function () {
return false;
}
break;
case 'event_report_log_table':
if ($("#id_agents3").val() == '') {
dialog_message('#message_no_agent');
return false;
}
break;
case 'permissions_report':
if ($("#checkbox-select_by_group").prop("checked") && $("select#users_groups>option:selected").val() == undefined) {
dialog_message('#message_no_group');
@ -6385,6 +6430,7 @@ function chooseType() {
$("#row_description").hide();
$("#row_label").hide();
$("#row_period").hide();
$("#row_period_range").hide();
$("#row_agent").hide();
$("#row_module").hide();
$("#row_period").hide();
@ -6559,7 +6605,24 @@ function chooseType() {
loadLogAgents();
break;
break;
case 'event_report_log_table':
$("#log_help_tip").css("visibility", "visible");
$("#row_description").show();
$("#row_period").show();
$("#row_period_range").show();
$("#row_search").show();
$("#row_log_number").show();
$("#agents_row").show();
$("#row_source").show();
$("#row_historical_db_check").hide();
$("#row_show_graph").show();
$("#row_group_by_agent").show();
loadLogAgents();
break;
case 'increment':
$("#row_description").show();
@ -7522,9 +7585,68 @@ function dialog_message(message_id) {
}
});
}
function control_period_range() {
let value_period_range = $('#row_period_range #hidden-period_range').val();
let current_value = $('#row_period #hidden-period').val();
let min_range = (current_value/12);
if(min_range > value_period_range) {
$('#row_period_range div:nth-child(2) select option').removeAttr("selected");
$('#row_period_range div:nth-child(1)').hide();
$('#row_period_range div:nth-child(2)').show();
setTimeout(() => {
if(min_range >= 2592000) {
$('#row_period_range input').val(Math.round((min_range/2592000) * 100) / 100);
$('#row_period_range div:nth-child(2) select option[value="2592000"]').attr("selected", "selected");
$('#row_period_range div:nth-child(2) select').val(2592000);
$('#row_period_range #hidden-period_range').val(min_range);
return;
}
if(min_range >= 604800) {
$('#row_period_range input').val(Math.round((min_range/604800) * 100) / 100);
$('#row_period_range div:nth-child(2) select option[value="604800"]').attr("selected", "selected");
$('#row_period_range div:nth-child(2) select').val(604800);
$('#row_period_range #hidden-period_range').val(min_range);
return;
}
if(min_range >= 86400) {
$('#row_period_range input').val(Math.round((min_range/86400) * 100) / 100);
$('#row_period_range div:nth-child(2) select option[value="86400"]').attr("selected", "selected");
$('#row_period_range div:nth-child(2) select').val(86400);
$('#row_period_range #hidden-period_range').val(min_range);
return;
}
if(min_range >= 3600) {
$('#row_period_range input').val(Math.round((min_range/3600) * 100) / 100);
$('#row_period_range div:nth-child(2) select option[value="3600"]').attr("selected", "selected");
$('#row_period_range div:nth-child(2) select').val(3600);
$('#row_period_range #hidden-period_range').val(min_range);
return;
}
if(min_range >= 60) {
$('#row_period_range input').val(Math.round((min_range/60) * 100) / 100);
$('#row_period_range div:nth-child(2) select option[value="60"]').attr("selected", "selected");
$('#row_period_range div:nth-child(2) select option[value="60"]').val(60);
$('#row_period_range #hidden-period_range').val(min_range);
return;
}
}, 800);
}
}
$(document).ready(function () {
$('[id^=period], #combo_graph_options, #combo_sla_sort_options').next().css('z-index', 0);
$('#row_period input').change(function(e){
control_period_range();
});
$('#row_period select').change(function(e){
control_period_range();
});
$('#row_period_range input').change(function(e){
control_period_range();
});
$('#row_period_range select').change(function(e){
control_period_range();
});
});
</script>

View File

@ -1621,6 +1621,27 @@ switch ($action) {
$good_format = true;
break;
case 'event_report_log_table':
$agents_to_report = get_parameter('id_agents3');
$source = get_parameter('source', '');
$search = get_parameter('search', '');
$full_text = (integer) get_parameter('full_text', 0);
$log_number = get_parameter('log_number', '');
$es['source'] = $source;
$es['id_agents'] = $agents_to_report;
$es['search'] = $search;
$es['full_text'] = $full_text;
$es['log_number'] = $log_number;
$values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period');
$values['period_range'] = get_parameter('period_range');
$values['show_graph'] = get_parameter('combo_graph_options');
$values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent');
$good_format = true;
break;
case 'prediction_date':
$values['period'] = get_parameter('period1');
$values['top_n'] = get_parameter(
@ -2605,6 +2626,27 @@ switch ($action) {
$good_format = true;
break;
case 'event_report_log_table':
$agents_to_report = get_parameter('id_agents3');
$source = get_parameter('source', '');
$search = get_parameter('search', '');
$full_text = (integer) get_parameter('full_text', 0);
$log_number = get_parameter('log_number', '');
$es['source'] = $source;
$es['id_agents'] = $agents_to_report;
$es['search'] = $search;
$es['full_text'] = $full_text;
$es['log_number'] = $log_number;
$values['external_source'] = json_encode($es);
$values['period'] = get_parameter('period');
$values['period_range'] = get_parameter('period_range');
$values['show_graph'] = get_parameter('combo_graph_options');
$values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent');
$good_format = true;
break;
case 'agent_module':
case 'agent_module_status':
$agents_to_report_text = get_parameter('id_agents2-multiple-text');

View File

@ -412,6 +412,13 @@ function reporting_make_reporting_data(
);
break;
case 'event_report_log_table':
$report['contents'][] = reporting_log_table(
$report,
$content
);
break;
case 'increment':
$report['contents'][] = reporting_increment(
$report,

View File

@ -259,6 +259,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_log($table, $item);
break;
case 'event_report_log_table':
reporting_html_log_table($table, $item);
break;
case 'permissions_report':
reporting_html_permissions($table, $item);
break;

View File

@ -944,6 +944,11 @@ function reports_get_report_types($template=false, $not_editor=false)
'optgroup' => __('Log'),
'name' => __('Log report'),
];
$types['event_report_log_table'] = [
'optgroup' => __('Log'),
'name' => __('Log report by period'),
];
}
if ($template === false) {

View File

@ -1572,6 +1572,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`id_agent_module` BIGINT UNSIGNED NULL DEFAULT NULL,
`type` VARCHAR(30) DEFAULT 'simple_graph',
`period` INT NOT NULL DEFAULT 0,
`period_range` INT DEFAULT 0,
`order` INT NOT NULL DEFAULT 0,
`name` VARCHAR(300) NULL,
`description` MEDIUMTEXT,