Merge branch 'develop' of https://github.com/pandorafms/pandorafms into develop

This commit is contained in:
Alejandro Gallardo Escobar 2015-02-23 15:36:14 +01:00
commit e6be7e7143
5 changed files with 287 additions and 160 deletions

View File

@ -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>

View File

@ -72,7 +72,15 @@ if ($get_module_detail) {
ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
$module_id = (int)get_parameter('id_module');
$period = (int) get_parameter("period", SECONDS_1DAY);
$period = get_parameter("period", SECONDS_1DAY);
if ($period === 'undefined') {
$period = SECONDS_1DAY;
}
else {
$period = (int)$period;
}
$group = agents_get_agentmodule_group ($module_id);
$agentId = (int) get_parameter("id_agent");
$server_name = (string) get_parameter('server_name');

View File

@ -748,7 +748,13 @@ function html_print_extended_select_for_time ($name, $selected = '',
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;">';
@ -757,7 +763,12 @@ function html_print_extended_select_for_time ($name, $selected = '',
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 () {

View File

@ -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
@ -5389,6 +5395,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] =
@ -5412,6 +5423,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',
@ -5621,6 +5633,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"]);
@ -5636,6 +5654,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] = '--';
@ -5695,6 +5714,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"]);
@ -5710,6 +5735,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 =
@ -5747,6 +5773,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"]);
@ -5762,6 +5794,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) {
@ -6276,17 +6309,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
@ -6315,6 +6357,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']);
@ -6326,6 +6373,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;

View File

@ -574,10 +574,12 @@ function period_select_init(name) {
// 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 + '_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) {
@ -618,15 +620,15 @@ function period_select_events(name) {
adjustTextUnits(name);
});
// When select a custom units, the default period changes to 'custom' and
// the time in seconds is calculated into hidden input
// 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
// 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)) {
@ -640,12 +642,20 @@ function period_select_events(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) {
$('#'+name+' option:eq(1)').attr('selected', 'selected');
@ -662,7 +672,6 @@ function selectFirst(name) {
* work properly when the divs are into a hiden div
*
*/
function toggleBoth(name) {
if ($('#'+name+'_default').css('display') == 'none') {
$('#'+name+'_default').css('display','inline');
@ -685,7 +694,8 @@ 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);
}