mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-20 04:14:58 +02:00
Added the option 'last value' for the items 'general' and 'exception' in reports. TICKET: #1819
(cherry picked from commit 0952b96b49035516e27170fe6352f347f0811a69) Conflicts: pandora_console/include/javascript/pandora.js
This commit is contained in:
parent
42d90c5793
commit
30a05aa62f
@ -568,8 +568,25 @@ html_print_input_hidden('id_item', $idItem);
|
||||
<td style="">
|
||||
<?php
|
||||
html_print_extended_select_for_time ('period', $period, '', '', '0', 10);
|
||||
?></td>
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_last_value" style="" class="datos">
|
||||
<td style="vertical-align: top;" class="datos">
|
||||
<?php
|
||||
echo __('Last value');
|
||||
ui_print_help_tip(__('Warning: period 0 reports cannot be used to show information back in time. Information contained in this kind of reports will be always reporting the most recent information'));
|
||||
?>
|
||||
</td>
|
||||
<td style="">
|
||||
<?php
|
||||
html_print_checkbox('last_value', '1',
|
||||
($period === 0), false, false, 'set_last_value_period();');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_resolution" style="" class="datos">
|
||||
<td style="vertical-align: top;">
|
||||
<?php
|
||||
@ -1424,7 +1441,8 @@ $(document).ready (function () {
|
||||
minuteText: '<?php echo __('Minute');?>',
|
||||
secondText: '<?php echo __('Second');?>',
|
||||
currentText: '<?php echo __('Now');?>',
|
||||
closeText: '<?php echo __('Close');?>'});
|
||||
closeText: '<?php echo __('Close');?>'
|
||||
});
|
||||
});
|
||||
|
||||
function create_custom_graph() {
|
||||
@ -1451,7 +1469,11 @@ function create_custom_graph() {
|
||||
jQuery.ajax ({
|
||||
data: params1.join ("&"),
|
||||
type: 'POST',
|
||||
url: action= <?php echo '"' . ui_get_full_url(false, false, false, false) . '"'; ?> + "/ajax.php",
|
||||
url: action= <?php
|
||||
echo '"' .
|
||||
ui_get_full_url(false, false, false, false) .
|
||||
'"';
|
||||
?> + "/ajax.php",
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
success: function (data) {
|
||||
@ -1899,6 +1921,7 @@ function chooseType() {
|
||||
$("#row_netflow_filter").hide();
|
||||
$("#row_max_values").hide();
|
||||
$("#row_resolution").hide();
|
||||
$("#row_last_value").hide();
|
||||
|
||||
// SLA list default state
|
||||
$("#sla_list").hide();
|
||||
@ -2159,6 +2182,12 @@ function chooseType() {
|
||||
$("#row_order_uptodown").show();
|
||||
$("#row_show_resume").show();
|
||||
$("#row_show_in_two_columns").show();
|
||||
|
||||
$("#row_last_value").show();
|
||||
if ($("#hidden-period").val() == 0) {
|
||||
$("#row_period").hide();
|
||||
$("input[name='last_value']").prop("checked", true);
|
||||
}
|
||||
break;
|
||||
case 'group_report':
|
||||
$("#row_group").show();
|
||||
@ -2191,6 +2220,12 @@ function chooseType() {
|
||||
$("#row_show_resume").show();
|
||||
$("#row_show_graph").show();
|
||||
$("#row_show_in_two_columns").show();
|
||||
|
||||
$("#row_last_value").show();
|
||||
if ($("#hidden-period").val() == 0) {
|
||||
$("#row_period").hide();
|
||||
$("input[name='last_value']").prop("checked", true);
|
||||
}
|
||||
break;
|
||||
case 'agent_module':
|
||||
$("#row_description").show();
|
||||
@ -2292,4 +2327,19 @@ function chooseType() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function set_last_value_period() {
|
||||
var checked = $("input[name='last_value']").prop("checked");
|
||||
|
||||
if (checked) {
|
||||
$("#row_period").hide();
|
||||
period_set_value($("#hidden-period").attr('class'), 0);
|
||||
alert("<?php
|
||||
echo __('Warning: period 0 reports cannot be used to show information back in time. Information contained in this kind of reports will be always reporting the most recent information');
|
||||
?>");
|
||||
}
|
||||
else {
|
||||
$("#row_period").show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -639,7 +639,13 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
|
||||
echo '<div id="'.$uniq_name.'_default" style="width:100%;display:inline;">';
|
||||
html_print_select ($fields, $uniq_name . '_select', $selected,"" . $script,
|
||||
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
|
||||
echo ' <a href="javascript:">'.html_print_image('images/pencil.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('Custom'), 'title' => __('Custom'), 'style' => 'width: 18px;')).'</a>';
|
||||
echo ' <a href="javascript:">' .
|
||||
html_print_image('images/pencil.png', true,
|
||||
array('class' => $uniq_name . '_toggler',
|
||||
'alt' => __('Custom'),
|
||||
'title' => __('Custom'),
|
||||
'style' => 'width: 18px;')) .
|
||||
'</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div id="'.$uniq_name.'_manual" style="width:100%;display:inline;">';
|
||||
@ -648,7 +654,12 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
|
||||
html_print_input_hidden ($name, $selected, false, $uniq_name);
|
||||
html_print_select ($units, $uniq_name . '_units', 1, "" . $script,
|
||||
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
|
||||
echo ' <a href="javascript:">'.html_print_image('images/default_list.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('List'), 'title' => __('List'), 'style' => 'width: 18px;')).'</a>';
|
||||
echo ' <a href="javascript:">' .
|
||||
html_print_image('images/default_list.png', true,
|
||||
array('class' => $uniq_name . '_toggler',
|
||||
'alt' => __('List'),
|
||||
'title' => __('List'), 'style' => 'width: 18px;')) .
|
||||
'</a>';
|
||||
echo '</div>';
|
||||
echo "<script type='text/javascript'>
|
||||
$(document).ready (function () {
|
||||
|
@ -308,16 +308,21 @@ function reporting_get_agentmodule_data_min ($id_agent_module, $period=0, $date
|
||||
*
|
||||
* @return float The sumatory of the module values in the interval.
|
||||
*/
|
||||
function reporting_get_agentmodule_data_sum ($id_agent_module, $period=0, $date = 0) {
|
||||
function reporting_get_agentmodule_data_sum ($id_agent_module,
|
||||
$period = 0, $date = 0) {
|
||||
|
||||
global $config;
|
||||
|
||||
// Initialize variables
|
||||
if (empty ($date)) $date = get_system_time ();
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$search_in_history_db = db_search_in_history_db($datelimit);
|
||||
|
||||
$id_module_type = db_get_value ('id_tipo_modulo', 'tagente_modulo','id_agente_modulo', $id_agent_module);
|
||||
$module_name = db_get_value ('nombre', 'ttipo_modulo', 'id_tipo', $id_module_type);
|
||||
$id_module_type = db_get_value ('id_tipo_modulo', 'tagente_modulo',
|
||||
'id_agente_modulo', $id_agent_module);
|
||||
$module_name = db_get_value ('nombre', 'ttipo_modulo', 'id_tipo',
|
||||
$id_module_type);
|
||||
$module_interval = modules_get_interval ($id_agent_module);
|
||||
$uncompressed_module = is_module_uncompressed ($module_name);
|
||||
|
||||
@ -330,11 +335,12 @@ function reporting_get_agentmodule_data_sum ($id_agent_module, $period=0, $date
|
||||
$module_inc = is_module_inc ($module_name);
|
||||
|
||||
// Get module data
|
||||
$interval_data = db_get_all_rows_sql ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module .
|
||||
' AND utimestamp > ' . (int) $datelimit .
|
||||
' AND utimestamp < ' . (int) $date .
|
||||
' ORDER BY utimestamp ASC', $search_in_history_db);
|
||||
$interval_data = db_get_all_rows_sql('
|
||||
SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = ' . (int) $id_agent_module . '
|
||||
AND utimestamp > ' . (int) $datelimit . '
|
||||
AND utimestamp < ' . (int) $date . '
|
||||
ORDER BY utimestamp ASC', $search_in_history_db);
|
||||
if ($interval_data === false) $interval_data = array ();
|
||||
|
||||
// Uncompressed module data
|
||||
@ -5360,6 +5366,11 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
$mod_name = modules_get_agentmodule_name ($row['id_agent_module']);
|
||||
$ag_name = modules_get_agentmodule_agent_name ($row['id_agent_module']);
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$data_res[$key] =
|
||||
modules_get_last_value($row['id_agent_module']);
|
||||
}
|
||||
else {
|
||||
switch ($row['operation']) {
|
||||
case 'sum':
|
||||
$data_res[$key] =
|
||||
@ -5383,6 +5394,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
$row['id_agent_module'], $content['period']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$unit = db_get_value('unit', 'tagente_modulo',
|
||||
'id_agente_modulo',
|
||||
@ -5592,6 +5604,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
$found = false;
|
||||
if (strcmp($a, $agent_name) == 0
|
||||
&& strcmp($m, $module_name . ' (' . $g['operation'] . ')') == 0) {
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$value_res =
|
||||
modules_get_last_value($g['id_agent_module']);
|
||||
}
|
||||
else {
|
||||
switch ($g['operation']) {
|
||||
case 'sum':
|
||||
$value_res = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
@ -5607,6 +5625,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
$value_res = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($value_res === false) {
|
||||
$data[$i] = '--';
|
||||
@ -5666,6 +5685,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$min =
|
||||
modules_get_last_value($generals[$i]['id_agent_module']);
|
||||
}
|
||||
else {
|
||||
switch ($generals[$i]['operation']) {
|
||||
case 'sum':
|
||||
$min = reporting_get_agentmodule_data_sum ($generals[$i]['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
@ -5681,6 +5706,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
$min = reporting_get_agentmodule_data_average ($generals[$i]['id_agent_module'], $content['period']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
|
||||
$min_name_agent_module =
|
||||
@ -5718,6 +5744,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$value =
|
||||
modules_get_last_value($g['id_agent_module']);
|
||||
}
|
||||
else {
|
||||
switch ($g['operation']) {
|
||||
case 'sum':
|
||||
$value = reporting_get_agentmodule_data_sum ($g['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
@ -5733,6 +5765,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
$value = reporting_get_agentmodule_data_average ($g['id_agent_module'], $content['period']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($value !== false) {
|
||||
if ($value > $max) {
|
||||
@ -6247,17 +6280,26 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
}
|
||||
}
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$min =
|
||||
modules_get_last_value($exceptions[$i]['id_agent_module']);
|
||||
}
|
||||
else {
|
||||
switch ($exceptions[$i]['operation']) {
|
||||
case 'avg':
|
||||
$min = reporting_get_agentmodule_data_average($exceptions[$i]['id_agent_module'], $content['period']);
|
||||
$min = reporting_get_agentmodule_data_average(
|
||||
$exceptions[$i]['id_agent_module'], $content['period']);
|
||||
break;
|
||||
case 'max':
|
||||
$min = reporting_get_agentmodule_data_max($exceptions[$i]['id_agent_module'], $content['period']);
|
||||
$min = reporting_get_agentmodule_data_max(
|
||||
$exceptions[$i]['id_agent_module'], $content['period']);
|
||||
break;
|
||||
case 'min':
|
||||
$min = reporting_get_agentmodule_data_min($exceptions[$i]['id_agent_module'], $content['period']);
|
||||
$min = reporting_get_agentmodule_data_min(
|
||||
$exceptions[$i]['id_agent_module'], $content['period']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
|
||||
//Restore dbconnection
|
||||
@ -6286,6 +6328,11 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
$unit = db_get_value('unit', 'tagente_modulo',
|
||||
'id_agente_modulo', $exc['id_agent_module']);
|
||||
|
||||
if ($content['period'] == 0) {
|
||||
$value =
|
||||
modules_get_last_value($exceptions[$i]['id_agent_module']);
|
||||
}
|
||||
else {
|
||||
switch ($exc['operation']) {
|
||||
case 'avg':
|
||||
$value = reporting_get_agentmodule_data_average ($exc['id_agent_module'], $content['period']);
|
||||
@ -6297,6 +6344,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||
$value = reporting_get_agentmodule_data_min ($exc['id_agent_module'], $content['period']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($value !== false) {
|
||||
if ($value > $max) $max = $value;
|
||||
|
@ -501,25 +501,27 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) {
|
||||
*/
|
||||
function period_select_init(name) {
|
||||
// Manual mode is hidden by default
|
||||
$('#'+name+'_manual').hide();
|
||||
$('#'+name+'_default').show();
|
||||
$('#' + name + '_manual').hide();
|
||||
$('#' + name + '_default').show();
|
||||
|
||||
// If the text input is empty, we put on it 5 minutes by default
|
||||
if($('#text-'+name+'_text').val() == '') {
|
||||
$('#text-'+name+'_text').val(300);
|
||||
if ($('#text-' + name + '_text').val() == '') {
|
||||
$('#text-' + name + '_text').val(300);
|
||||
// Set the value in the hidden field too
|
||||
$('.'+name).val(300);
|
||||
if($('#'+name+'_select option:eq(0)').val() == 0) {
|
||||
$('#'+name+'_select option:eq(2)').attr('selected', 'selected');
|
||||
$('.' + name).val(300);
|
||||
if ($('#' + name + '_select option:eq(0)').val() == 0) {
|
||||
$('#' + name + '_select option:eq(2)')
|
||||
.attr('selected', 'selected');
|
||||
}
|
||||
else {
|
||||
$('#'+name+'_select option:eq(1)').attr('selected', 'selected');
|
||||
$('#' + name + '_select option:eq(1)')
|
||||
.attr('selected', 'selected');
|
||||
}
|
||||
}
|
||||
else if($('#text-'+name+'_text').val() == 0) {
|
||||
$('#'+name+'_units option:last').removeAttr('selected');
|
||||
$('#'+name+'_manual').show();
|
||||
$('#'+name+'_default').hide();
|
||||
else if ($('#text-' + name + '_text').val() == 0) {
|
||||
$('#' + name + '_units option:last').removeAttr('selected');
|
||||
$('#' + name + '_manual').show();
|
||||
$('#' + name + '_default').hide();
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,58 +534,67 @@ function period_select_init(name) {
|
||||
* @param name string with the name of the select for time
|
||||
*/
|
||||
function period_select_events(name) {
|
||||
$('.'+name+'_toggler').click(function() {
|
||||
$('.' + name + '_toggler').click(function() {
|
||||
toggleBoth(name);
|
||||
$('#text-'+name+'_text').focus();
|
||||
$('#text-' + name + '_text').focus();
|
||||
});
|
||||
|
||||
adjustTextUnits(name);
|
||||
|
||||
// When select a default period, is setted in seconds
|
||||
$('#'+name+'_select').change(function() {
|
||||
var value = $('#'+name+'_select').val();
|
||||
$('#' + name + '_select').change(function() {
|
||||
var value = $('#' + name + '_select').val();
|
||||
|
||||
if(value == -1) {
|
||||
if (value == -1) {
|
||||
value = 300;
|
||||
toggleBoth(name);
|
||||
$('#text-'+name+'_text').focus();
|
||||
$('#text-' + name + '_text').focus();
|
||||
}
|
||||
|
||||
$('.'+name).val(value);
|
||||
$('#text-'+name+'_text').val(value);
|
||||
$('.' + name).val(value);
|
||||
$('#text-' + name + '_text').val(value);
|
||||
|
||||
adjustTextUnits(name);
|
||||
});
|
||||
|
||||
// When select a custom units, the default period changes to 'custom' and
|
||||
// the time in seconds is calculated into hidden input
|
||||
$('#'+name+'_units').change(function() {
|
||||
// When select a custom units, the default period changes to
|
||||
// 'custom' and the time in seconds is calculated into hidden input
|
||||
$('#' + name + '_units').change(function() {
|
||||
selectFirst(name);
|
||||
calculateSeconds(name);
|
||||
});
|
||||
|
||||
// When write any character into custom input, it check to convert it to
|
||||
// integer and calculate in seconds into hidden input
|
||||
$('#text-'+name+'_text').keyup (function () {
|
||||
var cleanValue = parseInt($('#text-'+name+'_text').val());
|
||||
if(isNaN(cleanValue)) {
|
||||
// When write any character into custom input, it check to convert
|
||||
// it to integer and calculate in seconds into hidden input
|
||||
$('#text-' + name + '_text').keyup (function () {
|
||||
var cleanValue = parseInt($('#text-' + name + '_text').val());
|
||||
if (isNaN(cleanValue)) {
|
||||
cleanValue = '';
|
||||
}
|
||||
|
||||
$('#text-'+name+'_text').val(cleanValue);
|
||||
$('#text-' + name + '_text').val(cleanValue);
|
||||
|
||||
selectFirst(name+'_select');
|
||||
selectFirst(name + '_select');
|
||||
calculateSeconds(name);
|
||||
});
|
||||
}
|
||||
|
||||
function period_set_value(name, value) {
|
||||
$("#text-" + name + "_text").val(value);
|
||||
adjustTextUnits(name);
|
||||
calculateSeconds(name);
|
||||
selectFirst(name + '_select');
|
||||
$("#" + name + "_manual").hide();
|
||||
$("#" + name + "_default").show();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Select first option of a select if is not value=0
|
||||
*
|
||||
*/
|
||||
|
||||
function selectFirst(name) {
|
||||
if($('#'+name+' option:eq(0)').val() == 0) {
|
||||
if ($('#'+name+' option:eq(0)').val() == 0) {
|
||||
$('#'+name+' option:eq(1)').attr('selected', 'selected');
|
||||
}
|
||||
else {
|
||||
@ -598,16 +609,15 @@ function selectFirst(name) {
|
||||
* work properly when the divs are into a hiden div
|
||||
*
|
||||
*/
|
||||
|
||||
function toggleBoth(name) {
|
||||
if($('#'+name+'_default').css('display') == 'none') {
|
||||
if ($('#'+name+'_default').css('display') == 'none') {
|
||||
$('#'+name+'_default').css('display','inline');
|
||||
}
|
||||
else {
|
||||
$('#'+name+'_default').css('display','none');
|
||||
}
|
||||
|
||||
if($('#'+name+'_manual').css('display') == 'none') {
|
||||
if ($('#'+name+'_manual').css('display') == 'none') {
|
||||
$('#'+name+'_manual').css('display','inline');
|
||||
}
|
||||
else {
|
||||
@ -621,9 +631,10 @@ function toggleBoth(name) {
|
||||
*
|
||||
*/
|
||||
function calculateSeconds(name) {
|
||||
var calculated = $('#text-'+name+'_text').val()*$('#'+name+'_units').val();
|
||||
var calculated =
|
||||
$('#text-' + name + '_text').val() * $('#' + name + '_units').val();
|
||||
|
||||
$('.'+name).val(calculated);
|
||||
$('.' + name).val(calculated);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -632,11 +643,11 @@ function calculateSeconds(name) {
|
||||
*
|
||||
*/
|
||||
function period_select_update(name, seconds) {
|
||||
$('#text-'+name+'_text').val(seconds);
|
||||
$('#text-' + name + '_text').val(seconds);
|
||||
adjustTextUnits(name);
|
||||
calculateSeconds(name);
|
||||
$('#'+name+'_manual').show();
|
||||
$('#'+name+'_default').hide();
|
||||
$('#' + name + '_manual').show();
|
||||
$('#' + name + '_default').hide();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user