From 6eb071f615efd9183088d23fff2bf555a8f329f8 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 17 Jul 2013 11:12:37 +0000 Subject: [PATCH] 2013-07-17 Miguel de Dios * godmode/agentes/configurar_agente.php: fixed the default value for "prediction_module" in tagente_module. * include/graphs/functions_flot.php, include/graphs/functions_pchart.php, include/graphs/functions_gd.php, include/graphs/functions_utils.php, include/javascript/pandora_alerts.js, include/javascript/pandora_modules.js, include/javascript/pandora_events.js, include/functions_network_components.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8535 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 +++++++ .../godmode/agentes/configurar_agente.php | 2 +- .../include/functions_network_components.php | 2 +- .../include/graphs/functions_flot.php | 28 +++++++-------- .../include/graphs/functions_gd.php | 24 ++++++------- .../include/graphs/functions_pchart.php | 14 ++++---- .../include/graphs/functions_utils.php | 2 +- .../include/javascript/pandora_alerts.js | 3 +- .../include/javascript/pandora_events.js | 20 +++++------ .../include/javascript/pandora_modules.js | 34 +++++++++---------- 10 files changed, 78 insertions(+), 64 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8ff277ce95..90726de12d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2013-07-17 Miguel de Dios + + * godmode/agentes/configurar_agente.php: fixed the default value for + "prediction_module" in tagente_module. + + * include/graphs/functions_flot.php, + include/graphs/functions_pchart.php, + include/graphs/functions_gd.php, include/graphs/functions_utils.php, + include/javascript/pandora_alerts.js, + include/javascript/pandora_modules.js, + include/javascript/pandora_events.js, + include/functions_network_components.php: cleaned source code style. + 2013-07-17 Sergio Martin * operation/agentes/status_monitor.php diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 89cb14d0b4..966f9ac57b 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -741,7 +741,7 @@ if ($update_module || $create_module) { // 1.23E-10 is 0.000000000123 $post_process = (string) get_parameter ('post_process', 0.0); - $prediction_module = 1; + $prediction_module = 0; $max_timeout = (int) get_parameter ('max_timeout'); $max_retries = (int) get_parameter ('max_retries'); $min = (int) get_parameter_post ("min"); diff --git a/pandora_console/include/functions_network_components.php b/pandora_console/include/functions_network_components.php index 2a3cabefcd..13c8060455 100644 --- a/pandora_console/include/functions_network_components.php +++ b/pandora_console/include/functions_network_components.php @@ -226,7 +226,7 @@ function network_components_get_network_component ($id_network_component, $filte $network_component = db_get_row_filter ('tnetwork_component', $filter, $fields); - if(!empty($network_component) && $network_component['id_category'] != 0) { + if (!empty($network_component) && $network_component['id_category'] != 0) { $network_component['category_name'] = (string) db_get_value('name','tcategory','id',$network_component['id_category']); } diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index f9ec8bee96..4c92d84db0 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -61,7 +61,7 @@ function include_javascript_dependencies_flot_graph($return = false) { percent = parseFloat(obj.series.percent).toFixed(2); $('#hover').html(''+obj.series.label+' ('+percent+'%)'); $('.legendLabel').each(function() { - if($(this).html() == obj.series.label) { + if ($(this).html() == obj.series.label) { $(this).css('font-weight','bold'); } else { @@ -344,7 +344,7 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $return = "
"; - if($water_mark != '') { + if ($water_mark != '') { $return .= ""; $water_mark = 'true'; } @@ -356,7 +356,7 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $labels = implode($separator, $labels); $values = implode($separator, $values); - if(!empty($colors)) { + if (!empty($colors)) { $colors = implode($separator, $colors); } @@ -417,8 +417,8 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark) { $jsvar = "data_".$graph_id."_".$key; if ($multicolor) { - for($j = count($graph_data) - 1; $j>=0; $j--) { - if($j == $i) { + for ($j = count($graph_data) - 1; $j>=0; $j--) { + if ($j == $i) { $data[$jsvar.$i][$j] = $value; } else { @@ -431,7 +431,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark) { } $return .= "
$value
"; - if($value > $max) { + if ($value > $max) { $max = $value; } } @@ -522,9 +522,9 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $lon foreach ($values as $key => $value) { $jsvar = "data_".$graph_id."_".$key; - if($multicolor) { - for($j = count($graph_data) - 1; $j>=0; $j--) { - if($j == $i) { + if ($multicolor) { + for ($j = count($graph_data) - 1; $j>=0; $j--) { + if ($j == $i) { $data[$jsvar.$i][$j] = $value; } else { @@ -623,7 +623,7 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $ $i_aux = $i; while(1) { - if($i_aux <= $maxticks ) { + if ($i_aux <= $maxticks ) { break; } @@ -636,13 +636,13 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $ $acumulate = 0; $c = 0; $acumulate_data = array(); - foreach($graph_data as $label => $values) { + foreach ($graph_data as $label => $values) { $labels[] = io_safe_output($label); $i--; - foreach($values as $key => $value) { + foreach ($values as $key => $value) { $jsvar = "d_".$graph_id."_".$i; - if($key == 'data') { + if ($key == 'data') { $datacolor[$jsvar] = $colors[$value]; continue; } @@ -653,7 +653,7 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $ $c++; //$return .= "
$value
"; - if($value > $max) { + if ($value > $max) { $max = $value; } } diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index 98fda86e70..c1334d28d7 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -30,7 +30,7 @@ $types = array('histogram', 'progressbar'); $id_graph = get_parameter('id_graph', false); $graph_type = get_parameter('graph_type', ''); -if($id_graph && in_array($graph_type, $types)) { +if ($id_graph && in_array($graph_type, $types)) { if (!$id_graph) { exit; @@ -136,7 +136,7 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title, $margin_up += $rectangle_height + 1; $c++; - if(!isset($colors[$c])) { + if (!isset($colors[$c])) { $c = 0; } } @@ -161,11 +161,11 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title, // Draw a dynamic progress bubble using GDlib directly // *************************************************************************** function gd_progress_bubble ($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image, $mode = 1, $fontsize=10, $value_text = '', $colorRGB = '') { - if($out_of_lim_str === false) { + if ($out_of_lim_str === false) { $out_of_lim_str = __("Out of limits"); } - if($out_of_lim_image === false) { + if ($out_of_lim_image === false) { $out_of_lim_image = "images_graphs/outlimits.png"; } @@ -231,7 +231,7 @@ function gd_progress_bubble ($width, $height, $progress, $title, $font, $out_of_ imagefilledellipse($image, $width / 2, $height / 2, $ratingWidth, $ratingHeight, $soft_red); } - else if($rating > 0) { + else if ($rating > 0) { imagefilledellipse($image, $width / 2, $height / 2, $ratingWidth, $ratingHeight, $other_red); } @@ -342,8 +342,8 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_red); $bordercolor = $soft_red_border; } - else if($rating > 0) { - if($radius != 0) { + else if ($rating > 0) { + if ($radius != 0) { $x2 = $ratingbar30; } ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $other_red); @@ -358,8 +358,8 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius,$red); elseif ($rating == 100) ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius,$green); - else if($rating > 0){ - if($radius != 0 && $rating < 30) { + else if ($rating > 0){ + if ($radius != 0 && $rating < 30) { $x2 = $ratingbar30; } ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius,$blue); @@ -383,8 +383,8 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_red); elseif ($rating > 30) ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_yellow); - else if($rating > 0) { - if($radius != 0) { + else if ($rating > 0) { + if ($radius != 0) { $x2 = $ratingbar30; } ImageRectangleWithRoundedCorners($image, $x1, $y1, $x2, $y2, $radius, $soft_green); @@ -392,7 +392,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim break; } - if($bordercolor !== false) { + if ($bordercolor !== false) { $x1-=1; $x2 = $width-2; imageline($image, $x1+$radius, $y1, $x2-$radius, $y1, $bordercolor); diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index 3e2dcc8c05..366da7a42c 100755 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -136,7 +136,7 @@ if ($force_steps) { $pixels_between_xdata = 50; $max_xdata_display = round($width / $pixels_between_xdata); $ndata = count($data); - if($max_xdata_display > $ndata) { + if ($max_xdata_display > $ndata) { $xdata_display = $ndata; } else { @@ -522,10 +522,10 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font, } // Assign cyclic colors to bars if are setted - if($fine_colors) { + if ($fine_colors) { $c = 0; - foreach($values as $ii => $vv) { - if(!isset($fine_colors[$c])) { + foreach ($values as $ii => $vv) { + if (!isset($fine_colors[$c])) { $c = 0; } $overridePalette[$ii] = $fine_colors[$c]; @@ -600,7 +600,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font, $myPicture->drawScale($scaleSettings); - if(isset($legend)) { + if (isset($legend)) { /* Write the chart legend */ $size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); $myPicture->drawLegend($width-$size['Width'],0,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL, "BoxWidth"=>10, "BoxHeight"=>10)); @@ -710,7 +710,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, /* Set horizontal legend if is posible */ $legend_mode = LEGEND_HORIZONTAL; $size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode)); - if($size['Width'] > ($width - 5)) { + if ($size['Width'] > ($width - 5)) { $legend_mode = LEGEND_VERTICAL; $size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode)); } @@ -891,7 +891,7 @@ function pch_threshold_graph ($graph_type, $index, $data, $width, $height, $font $myPicture->drawSplineChart($settings); $myPicture->setShadow(FALSE); - if($show_legend) { + if ($show_legend) { /* Write the chart legend */ $myPicture->drawLegend(643,210,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); } diff --git a/pandora_console/include/graphs/functions_utils.php b/pandora_console/include/graphs/functions_utils.php index 1a49de477f..983a785dc4 100644 --- a/pandora_console/include/graphs/functions_utils.php +++ b/pandora_console/include/graphs/functions_utils.php @@ -51,7 +51,7 @@ function unserialize_in_temp($serial_id = null, $delete = true, $ttl = 1) { $array = json_decode($content, true); if ($delete) { - if($volume == $ttl) { + if ($volume == $ttl) { unlink($file_path); } else { diff --git a/pandora_console/include/javascript/pandora_alerts.js b/pandora_console/include/javascript/pandora_alerts.js index d6021a53c0..f233250d0f 100644 --- a/pandora_console/include/javascript/pandora_alerts.js +++ b/pandora_console/include/javascript/pandora_alerts.js @@ -19,8 +19,9 @@ function parse_alert_command (command) { function render_command_preview (original_command) { $("#textarea_command_preview").text (parse_alert_command (original_command)); } + function render_command_description (command_description) { - if(command_description != '') { + if (command_description != '') { command_description = '
'+command_description; } $("#command_description").html(command_description); diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 1e4cd1f170..7cb0637a4b 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -319,8 +319,8 @@ function get_response_target(event_id, response_id, server_id) { // Replace the custom params macros var response_params = get_response_params(response_id); - if(response_params.length > 1 || response_params[0] != '') { - for(i=0;i 1 || response_params[0] != '') { + for (i = 0; i < response_params.length; i++) { target = target.replace('_'+response_params[i]+'_',$('#'+response_params[i]).val()); } } @@ -331,7 +331,7 @@ function get_response_target(event_id, response_id, server_id) { // Perform a response and put the output into a div function perform_response(target) { var ajax_file = $('#hidden-ajax_file').val(); - + $('#re_exec_command').hide(); $('#response_loading_command').show(); $('#response_out').html(''); @@ -394,12 +394,12 @@ function event_change_status(event_ids) { $('#button-status_button').removeAttr('disabled'); $('#response_loading').hide(); show_event_dialog(event_id, $('#hidden-group_rep').val(), 'responses', data); - if(data == 'status_ok') { + if (data == 'status_ok') { } else { } } - }); + }); return false; } @@ -444,13 +444,13 @@ function event_change_owner() { // Save a comment into an event function event_comment() { var ajax_file = $('#hidden-ajax_file').val(); - + var event_id = $('#hidden-id_event').val(); var comment = $('#textarea_comment').val(); var meta = $('#hidden-meta').val(); var history = $('#hidden-history').val(); - - if(comment == '') { + + if (comment == '') { show_event_dialog(event_id, $('#hidden-group_rep').val(), 'comments', 'comment_error'); return false; } @@ -465,7 +465,7 @@ function event_comment() { $('#button-comment_button').attr('disabled','disabled'); $('#response_loading').show(); - + jQuery.ajax ({ data: params.join ("&"), type: 'POST', @@ -479,7 +479,7 @@ function event_comment() { show_event_dialog(event_id, $('#hidden-group_rep').val(), 'comments', data); } - }); + }); return false; } diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index cf16b37282..091e5c3a00 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -117,7 +117,7 @@ function configure_modules_form () { $("#text-max").attr ("value", data["max"]); $("#text-min").attr ("value", data["min"]); // Workaround to update the advanced select control from html and ajax - if(typeof 'period_select_module_interval_update' == 'function') { + if (typeof 'period_select_module_interval_update' == 'function') { period_select_module_interval_update(data["module_interval"]); } else { @@ -154,32 +154,32 @@ function configure_modules_form () { // Reset the selection of tags (put all of them into available box) $("#id_tag_selected option").each(function(){ - if($(this).attr('value') != '') { + if ($(this).attr('value') != '') { $("#id_tag_selected").find("option[value='" + $(this).attr('value') + "']").remove(); $("select[name='id_tag_available[]']").append($("").val($(this).attr('value')).html($(this).text())); } }); - if($("#id_tag_available option").length > 1) { + if ($("#id_tag_available option").length > 1) { $("#id_tag_available").find("option[value='']").remove(); } - if($("#id_tag_selected option").length == 0) { + if ($("#id_tag_selected option").length == 0) { $("select[name='id_tag_selected[]']").append($("").val('').html('None')); } - if(tags != '') { + if (tags != '') { tags = tags.split(','); // Fill the selected tags box with select ones - for(i=0; i").val($(this).attr('value')).html($(this).text())); $("#id_tag_selected").find("option[value='']").remove(); } }); - if($("#id_tag_available option").length == 0) { + if ($("#id_tag_available option").length == 0) { $("select[name='id_tag_available[]']").append($("").val('').html('None')); } } @@ -192,7 +192,7 @@ function configure_modules_form () { var legend = ''; // If exist macros, load the fields - if(data["macros"] != '' && data["macros"] != null) { + if (data["macros"] != '' && data["macros"] != null) { $('#hidden-macros').val(Base64.encode(data["macros"])); var obj = jQuery.parseJSON(data["macros"]); @@ -237,7 +237,7 @@ function configure_modules_form () { $("#text-max").attr ("value", data["max"]); $("#text-min").attr ("value", data["min"]); // Workaround to update the advanced select control from html and ajax - if(typeof 'period_select_module_interval_update' == 'function') { + if (typeof 'period_select_module_interval_update' == 'function') { period_select_module_interval_update(data["module_interval"]); } else { @@ -287,7 +287,7 @@ function configure_modules_form () { // Reset the selection of tags (put all of them into available box) $("#id_tag_selected option").each(function(){ - if($(this).attr('value') != '') { + if ($(this).attr('value') != '') { $("#id_tag_selected").find("option[value='" + $(this).attr('value') + "']").remove(); $("select[name='id_tag_available[]']").append($("").val($(this).attr('value')).html($(this).text())); } @@ -303,16 +303,16 @@ function configure_modules_form () { tags = tags.split(','); // Fill the selected tags box with select ones - for(i=0; i").val($(this).attr('value')).html($(this).text())); $("#id_tag_selected").find("option[value='']").remove(); } }); - if($("#id_tag_available option").length == 0) { + if ($("#id_tag_available option").length == 0) { $("select[name='id_tag_available[]']").append($("").val('').html('None')); } } @@ -324,7 +324,7 @@ function configure_modules_form () { $('#hidden-macros').val(''); // If exist macros, load the fields - if(data["macros"] != '' && data["macros"] != null) { + if (data["macros"] != '' && data["macros"] != null) { $('#hidden-macros').val(Base64.encode(data["macros"])); var obj = jQuery.parseJSON(data["macros"]); @@ -407,7 +407,7 @@ function configure_modules_form () { return true; }); - if(typeof $("#prediction_id_group").pandoraSelectGroupAgent == 'function') { + if (typeof $("#prediction_id_group").pandoraSelectGroupAgent == 'function') { $("#prediction_id_group").pandoraSelectGroupAgent ({ agentSelect: "select#prediction_id_agent", callbackBefore: function () { @@ -610,7 +610,7 @@ function load_plugin_macros_fields(row_model_id) { if (data['array'] != null) { $('#hidden-macros').val(data['base64']); jQuery.each (data['array'], function (i, macro) { - if(macro['desc'] != '') { + if (macro['desc'] != '') { add_macro_field(macro, row_model_id); } });