From c27b9c6a22a7af5f485bd48a37a4ff5e6f93d901 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 5 Mar 2012 17:56:56 +0000 Subject: [PATCH] 2012-03-05 Miguel de Dios * extensions/update_manager/main.php, general/shortcut_bar.php, godmode/reporting/reporting_builder.item_editor.php, godmode/reporting/reporting_builder.php, godmode/reporting/reporting_builder.preview.php, include/functions_api.php, include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, operation/events/events_list.php, operation/netflow/nf_live_view.php: cleaned source code style. * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the enterprise feature that have been wrong for years. * general/header.php: changed to load the jquery-ui and jquery javascript library to last version. * extensions/insert_data.php, extensions/snmp_explorer.php, godmode/agentes/agent_manager.php, include/ajax/agent.php, include/javascript/pandora.js, operation/agentes/exportdata.php, operation/events/events.php: changed the unknow plugin autocomplete for the autocomple from jquery-ui. * include/functions_ui.php: cleaned source code style and into the function "ui_process_page_head" added the blacklist hardwrote for to use old jquery. * include/styles/jquery-ui-1.8.17.custom.css, include/javascript/jquery-1.7.1.min.js, include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last version of Jquery and Jquery-ui. Merge from the branch "pandora_4.0" * godmode/reporting/visual_console_builder.constans.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.editor.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/javascript/pandora_visual_console.js: changed the unknow plugin autocomplete for the autocomple from jquery-ui and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". * images/percentile_item.disabled.png, images/percentile_item.png: added images for button of percentile item (new item in visual map). * include/styles/pandora.css: added the style for the new button percentile item. * include/functions_graph.php, include/graphs/fgraph.php, include/graphs/functions_gd.php: cleaned source code style, and added the params to set text and color in the function "progress_bar" and added function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the name "progress_bubble". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 54 ++ pandora_console/extensions/insert_data.php | 112 ++-- pandora_console/extensions/snmp_explorer.php | 4 +- .../extensions/update_manager/main.php | 2 +- pandora_console/general/header.php | 125 ++-- pandora_console/general/shortcut_bar.php | 2 +- .../godmode/agentes/agent_manager.php | 116 +++- .../godmode/agentes/manage_config_remote.php | 208 ------- pandora_console/godmode/menu.php | 3 +- .../reporting_builder.item_editor.php | 64 +- .../godmode/reporting/reporting_builder.php | 18 +- .../reporting/reporting_builder.preview.php | 8 +- .../visual_console_builder.constans.php | 1 + .../visual_console_builder.editor.js | 448 +++++++++----- .../visual_console_builder.editor.php | 98 ++- .../images/percentile_item.disabled.png | Bin 0 -> 317 bytes pandora_console/images/percentile_item.png | Bin 0 -> 450 bytes pandora_console/include/ajax/agent.php | 105 ++++ .../ajax/visual_console_builder.ajax.php | 156 ++++- pandora_console/include/functions_api.php | 30 +- pandora_console/include/functions_graph.php | 62 +- pandora_console/include/functions_html.php | 2 +- pandora_console/include/functions_ui.php | 21 +- .../include/functions_visual_map.php | 306 +++++++--- pandora_console/include/graphs/fgraph.php | 33 +- .../include/graphs/functions_gd.php | 264 +++++--- pandora_console/include/htmlawed.php | 39 +- .../include/javascript/jquery-1.7.1.min.js | 4 + .../jquery.jquery-ui-1.8.17.custom.min.js | 356 +++++++++++ pandora_console/include/javascript/pandora.js | 264 +++++--- .../javascript/pandora_visual_console.js | 41 +- pandora_console/include/pchart_graph.php | 5 +- .../styles/jquery-ui-1.8.17.custom.css | 572 ++++++++++++++++++ pandora_console/include/styles/pandora.css | 8 +- .../operation/agentes/exportdata.php | 169 ++++-- pandora_console/operation/events/events.php | 82 ++- .../operation/events/events_list.php | 89 +-- .../operation/netflow/nf_live_view.php | 8 +- 38 files changed, 2903 insertions(+), 976 deletions(-) delete mode 100644 pandora_console/godmode/agentes/manage_config_remote.php create mode 100644 pandora_console/images/percentile_item.disabled.png create mode 100644 pandora_console/images/percentile_item.png create mode 100644 pandora_console/include/javascript/jquery-1.7.1.min.js create mode 100644 pandora_console/include/javascript/jquery.jquery-ui-1.8.17.custom.min.js create mode 100644 pandora_console/include/styles/jquery-ui-1.8.17.custom.css diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1de1b9398f..7e031a58bd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,57 @@ +2012-03-05 Miguel de Dios + + * extensions/update_manager/main.php, general/shortcut_bar.php, + godmode/reporting/reporting_builder.item_editor.php, + godmode/reporting/reporting_builder.php, + godmode/reporting/reporting_builder.preview.php, include/functions_api.php, + include/functions_html.php, include/htmlawed.php, include/pchart_graph.php, + operation/events/events_list.php, operation/netflow/nf_live_view.php: + cleaned source code style. + + * godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the + enterprise feature that have been wrong for years. + + * general/header.php: changed to load the jquery-ui and jquery javascript + library to last version. + + * extensions/insert_data.php, extensions/snmp_explorer.php, + godmode/agentes/agent_manager.php, include/ajax/agent.php, + include/javascript/pandora.js, operation/agentes/exportdata.php, + operation/events/events.php: changed the unknow plugin autocomplete for + the autocomple from jquery-ui. + + * include/functions_ui.php: cleaned source code style and into the function + "ui_process_page_head" added the blacklist hardwrote for to use old jquery. + + * include/styles/jquery-ui-1.8.17.custom.css, + include/javascript/jquery-1.7.1.min.js, + include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last + version of Jquery and Jquery-ui. + + Merge from the branch "pandora_4.0" + + * godmode/reporting/visual_console_builder.constans.php, + godmode/reporting/visual_console_builder.editor.js, + godmode/reporting/visual_console_builder.editor.php, + include/functions_visual_map.php, + include/ajax/visual_console_builder.ajax.php, + include/javascript/pandora_visual_console.js: changed the unknow + plugin autocomplete for the autocomple from jquery-ui and added function to + paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the + name "progress_bubble". + + * images/percentile_item.disabled.png, images/percentile_item.png: added + images for button of percentile item (new item in visual map). + + * include/styles/pandora.css: added the style for the new button percentile + item. + + * include/functions_graph.php, include/graphs/fgraph.php, + include/graphs/functions_gd.php: cleaned source code style, and added the + params to set text and color in the function "progress_bar" and added + function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) + with the name "progress_bubble". + 2012-03-05 Vanessa Gil * operation/search_alerts.php: Fixed sql error. diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 03ec746abb..3c2d679625 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -177,53 +177,42 @@ function mainInsertData() { echo ""; ui_require_css_file ('datepicker'); - ui_require_jquery_file ('ui.core'); - ui_require_jquery_file ('ui.datepicker'); ui_require_jquery_file ('timeentry'); - ui_require_jquery_file ('autocomplete'); ?> onfocus="javascript: if (fieldKeyWordEmpty) $('#keywords').val('');" size="100" style="background: white url('images/lupa_15x15.png') no-repeat right; padding: 0; padding-left:0px; margin: 0; width: 90%; height: 19px; margin-bottom: 5px; margin-left: 2px;" /> - + - + @@ -192,15 +191,17 @@ if ($config["metaconsole"] == 0){ - - + - diff --git a/pandora_console/godmode/agentes/manage_config_remote.php b/pandora_console/godmode/agentes/manage_config_remote.php deleted file mode 100644 index 607628c7f7..0000000000 --- a/pandora_console/godmode/agentes/manage_config_remote.php +++ /dev/null @@ -1,208 +0,0 @@ -ERROR: ".__('No selected agents to copy').""; - echo ""; - echo ''; - echo '
 
'; - echo ''; - echo ''; - echo ''; - exit; - } - } - else { - echo "

ERROR: ".__('No source agent selected')."

"; - echo ""; - echo ''; - echo '
 
'; - echo ''; - echo ''; - echo ''; - exit; - } - - // Source - $id_origen = get_parameter ("origen"); - - // Security check here - if (!users_access_to_agent ($id_origen)) { - db_pandora_audit("ACL Violation", "Trying to forge a source agent in remote config tool"); - require ("general/noaccess.php"); - exit; - } - - // Copy files - for ($a=0;$a
".__('Making copy of configuration file for')." [".$agent_name_src."] ".__('to')." [".$agent_name_dst."]"; - - $agent_md5_src = md5($agent_name_src); - $agent_md5_dst = md5($agent_name_dst); - - copy ( $config["remote_config"]."/md5/".$agent_md5_src.".md5", $config["remote_config"]."/md5/".$agent_md5_dst.".md5" ); - copy ( $config["remote_config"]."/conf/".$agent_md5_src.".conf", $config["remote_config"]."/conf/".$agent_md5_dst.".conf" ); - } // for each destination agent - } //end if copy modules or alerts - - - // ============ - // Form view - // ============ - } else { - - // title - // Header - ui_print_page_header (__("Remote configuration management"), "images/god1.png", false, "", true, ""); - echo '
'; - echo ""; - - // Source group - echo ''; - - // Destination agent - echo ''; - // Form buttons - echo ''; - echo '
'. __('Source group'). '

'; - - $group_select = users_get_groups ($config['id_user']); - $grouplist = implode (',', array_keys ($group_select)); - - echo html_print_select_groups($config['id_user'], "AR", true, 'id_group', $id_group, '', '', '', true, false, true, '', false, 'width:180px;'); - echo '  '; - echo ''; - echo '

'; - - // Source agent - echo ''. __('Source agent').''; - ui_print_help_icon ('duplicateconfig'); - echo '

'; - - // Show combo with SOURCE agents - if ($id_group > 0) - $sql1 = "SELECT * FROM tagente WHERE id_grupo = $id_group ORDER BY nombre "; - else - $sql1 = "SELECT * FROM tagente WHERE id_grupo IN ($grouplist) ORDER BY nombre"; - echo ''; - echo '
'; - echo ''.__('To agent(s):').'

'; - echo "'; - echo '
'; - echo ''; - echo '
'; - } - -?> - - diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index bd5bc06267..cd9c210279 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -29,8 +29,7 @@ if (check_acl ($config['id_user'], 0, "AW")) { $menu["gagente"]["sec2"] = "godmode/agentes/modificar_agente"; $menu["gagente"]["id"] = "god-agents"; - $sub = array (); - $sub["godmode/agentes/manage_config_remote"]["text"] = __('Duplicate config'); + $sub = array (); if (check_acl ($config["id_user"], 0, "PM")) { $sub["godmode/groups/group_list"]["text"] = __('Manage groups'); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 758d9921b9..49e3de2194 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -370,19 +370,54 @@ html_print_input_hidden('id_item', $idItem); - + + + - - + + + + + - - + + + + + + - - + + + + + + @@ -395,7 +430,11 @@ html_print_input_hidden('id_item', $idItem); - + + + @@ -439,10 +478,11 @@ html_print_input_hidden('id_item', $idItem); 'background: url(images/lightning.png) no-repeat right;')) - . ui_print_help_tip(__("Type at least two characters to search"), false); - html_print_input_hidden ('server_name', $server_name); + html_print_input_text_extended ('agent', agents_get_name ($idAgent), + 'text-agent', '', 30, 100, false, '', + array('style' => 'background: url(images/lightning.png) no-repeat right;')) + . ui_print_help_tip(__("Type at least two characters to search"), false); + html_print_input_hidden ('server_name', $server_name); ?> diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 53f297fcd6..2c5b5e5f4a 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -236,7 +236,8 @@ switch ($action) { $values['top_n_value'] = get_parameter('quantity'); $values['text'] = get_parameter('text'); $good_format = true; - }else{ + } + else { $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('radiobutton_max_min_avg'); $values['top_n_value'] = get_parameter('quantity'); @@ -316,12 +317,13 @@ switch ($action) { $values['description'] = get_parameter('description'); // Support for projection graph, prediction date and SLA reports // 'top_n_value', 'top_n' and 'text' fields will be reused for these types of report - if ($values['type'] == 'projection_graph'){ + if ($values['type'] == 'projection_graph') { $values['period'] = get_parameter('period1'); $values['top_n_value'] = get_parameter('period2'); $values['text'] = get_parameter('text'); $good_format = true; - }else if ($values['type'] == 'prediction_date'){ + } + else if ($values['type'] == 'prediction_date') { $values['period'] = get_parameter('period1'); $values['top_n'] = get_parameter('radiobutton_max_min_avg'); $values['top_n_value'] = get_parameter('quantity'); @@ -333,13 +335,15 @@ switch ($action) { } $intervals = get_parameter('max_interval') . ';' . get_parameter('min_interval'); $values['text'] = $intervals; - }else if ($values['type'] == 'SLA'){ + } + else if ($values['type'] == 'SLA') { $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('combo_sla_sort_options',0); $values['top_n_value'] = get_parameter('quantity'); $values['text'] = get_parameter('text'); $good_format = true; - }else{ + } + else { $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter('radiobutton_max_min_avg',0); $values['top_n_value'] = get_parameter('quantity'); @@ -349,7 +353,7 @@ switch ($action) { $values['id_agent'] = get_parameter('id_agent'); $values['id_gs'] = get_parameter('id_custom_graph'); $values['id_agent_module'] = get_parameter('id_agent_module'); - switch ($config['dbtype']){ + switch ($config['dbtype']) { case "mysql": case "postgresql": $values['only_display_wrong'] = get_parameter('checkbox_only_display_wrong'); @@ -371,7 +375,7 @@ switch ($action) { $values['friday'] = get_parameter('friday', 0); $values['saturday'] = get_parameter('saturday', 0); $values['sunday'] = get_parameter('sunday', 0); - switch ($config['dbtype']){ + switch ($config['dbtype']) { case "mysql": case "postgresql": $values['time_from'] = get_parameter('time_from'); diff --git a/pandora_console/godmode/reporting/reporting_builder.preview.php b/pandora_console/godmode/reporting/reporting_builder.preview.php index 1c2527a405..a24d41ce03 100644 --- a/pandora_console/godmode/reporting/reporting_builder.preview.php +++ b/pandora_console/godmode/reporting/reporting_builder.preview.php @@ -138,11 +138,12 @@ $(document).ready (function () { /* Show/hide begin date reports controls */ $("#checkbox-enable_init_date").click(function() { flag = $("#checkbox-enable_init_date").is(':checked'); - if (flag == true){ + if (flag == true) { $("#table1-1-3").css("display", ""); $("#table1-1-4").css("display", ""); $("#table1-1-5").css("display", "none"); - }else{ + } + else { $("#table1-1-3").css("display", "none"); $("#table1-1-4").css("display", "none"); $("#table1-1-5").css("display", ""); @@ -183,7 +184,8 @@ switch ($config["dbtype"]) { if ($contents === false) { return; -} else { +} +else { foreach($contents as $content) { $id_report = $content['id_rc']; switch ($content['type']) { diff --git a/pandora_console/godmode/reporting/visual_console_builder.constans.php b/pandora_console/godmode/reporting/visual_console_builder.constans.php index 0c36857435..80a0d7c0aa 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.constans.php +++ b/pandora_console/godmode/reporting/visual_console_builder.constans.php @@ -22,4 +22,5 @@ define('ICON', 5); define('SIMPLE_VALUE_MAX', 6); define('SIMPLE_VALUE_MIN', 7); define('SIMPLE_VALUE_AVG', 8); +define('PERCENTILE_BUBBLE', 9); ?> diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index bddd8c60fd..8887312c4d 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -44,7 +44,11 @@ function initJavascript() { eventsItems(); eventsTextAgent(); - draw_lines(lines, 'background'); + //Fixed to wait the load of images. + $(window).load(function() { + draw_lines(lines, 'background', true); + } + ); $(".item").css('z-index', '1'); //For paint the icons over lines } @@ -52,61 +56,90 @@ function initJavascript() { function eventsTextAgent() { var idText = $("#ip_text").html(); - $("#text-agent").autocomplete( - "ajax.php", - { - minChars: 2, - scroll:true, - extraParams: { - page: "operation/agentes/exportdata", - all: "enabled", - search_agents: 1, - id_group: function() { return $("#group").val(); } - }, - formatItem: function (data, i, total) { - if (total == 0) - $("#text-agent").css('background-color', '#cc0000'); - else - $("#text-agent").css('background-color', ''); - if (data == "") - return false; - return data[0]+'
' + idText + ': '+data[1]+''; - }, - delay: 200 - } - ); - - $("#text-agent").result ( - function () { - selectAgent = true; - var agent_name = this.value; - $('#module').fadeOut ('normal', function () { - $('#module').empty (); - var inputs = []; - inputs.push ("filter=disabled = 0"); - inputs.push ("agent_name=" + agent_name); - inputs.push ("get_agent_modules_json=1"); - inputs.push ("page=operation/agentes/ver_agente"); - jQuery.ajax ({ - data: inputs.join ("&"), - type: 'GET', - url: action="ajax.php", - timeout: 10000, - dataType: 'json', - success: function (data) { - $('#module').append ($('').attr ('value', 0).text ("--")); - jQuery.each (data, function (i, val) { - s = js_html_entity_decode (val['nombre']); - $('#module').append ($('').attr ('value', val['id_agente_modulo']).text (s)); - }); - $('#module').fadeIn ('normal'); - } - }); - }); - + $("#text-agent").autocomplete({ + minLength: 2, + source: function( request, response ) { + var term = request.term; //Word to search - } - ); + var params = []; + params.push("all=enabled"); + params.push("search_agents_2=1"); + params.push("page=operation/agentes/exportdata"); + params.push("id_group="+ $("#group").val()); + params.push("q="+ term); + jQuery.ajax ({ + data: params.join ("&"), + async: false, + type: 'POST', + url: action="ajax.php", + timeout: 10000, + dataType: 'json', + success: function (data) { + response(data); + return; + } + }); + return; + }, + select: function( event, ui ) { + var agent_name = ui.item.name; + + //Put the name + $(this).val(agent_name); + + //Fill the modules select box + $('#module').fadeOut ('normal', function () { + $('#module').empty (); + var inputs = []; + inputs.push ("filter=disabled = 0"); + inputs.push ("agent_name=" + agent_name); + inputs.push ("get_agent_modules_json=1"); + inputs.push ("page=operation/agentes/ver_agente"); + jQuery.ajax ({ + data: inputs.join ("&"), + type: 'GET', + url: action="ajax.php", + timeout: 10000, + dataType: 'json', + success: function (data) { + $('#module').append ($('').attr ('value', 0).text ("--")); + jQuery.each (data, function (i, val) { + s = js_html_entity_decode (val['nombre']); + $('#module').append ($('').attr ('value', val['id_agente_modulo']).text (s)); + }); + $('#module').fadeIn ('normal'); + } + }); + }); + + return false; + } + }) + .data( "autocomplete")._renderItem = function( ul, item ) { + if (item.ip == '') { + text = "" + item.name + ""; + } + else { + text = "" + item.name + + "
IP:" + item.ip + "
"; + } + + return $("
  • ") + .data("item.autocomplete", item) + .append(text) + .appendTo(ul); + }; + + //Force the size of autocomplete + $(".ui-autocomplete").css("max-height", "100px"); + $(".ui-autocomplete").css("overflow-y", "auto"); + /* prevent horizontal scrollbar */ + $(".ui-autocomplete").css("overflow-x", "hidden"); + /* add padding to account for vertical scrollbar */ + $(".ui-autocomplete").css("padding-right", "20px"); + + //Force to style of items + $(".ui-autocomplete").css("text-align", "left"); } function cancelAction() { @@ -131,7 +164,7 @@ function updateAction() { $("#background").css('height', values['height']); //$("#background").css('background', 'url(images/console/background/' + values['background'] + ')'); - + var params = []; params.push("get_image_path=1"); params.push("img_src=images/console/background/" + values['background']); @@ -154,7 +187,7 @@ function updateAction() { $("#text_" + idItem).html(values['label']); $("#" + idItem).css('color', values['label_color']); - + switch ($('#hidden-status_' + idItem).val()) { case '1': //Critical (BAD) @@ -178,7 +211,7 @@ function updateAction() { suffix = ".png"; // Default is Grey (Other) } - + var params = []; params.push("get_image_path=1"); params.push("img_src=images/console/icons/" + values['image'] + suffix); @@ -194,7 +227,7 @@ function updateAction() { $("#image_" + idItem).attr('src', data); } }); - + if ((values['width'] != 0) && (values['height'] != 0)) { $("#image_" + idItem).attr('width', values['width']); $("#image_" + idItem).attr('height', values['height']); @@ -209,8 +242,15 @@ function updateAction() { } break; case 'percentile_bar': + case 'percentile_item': $("#text_" + idItem).html(values['label']); - $("#image_" + idItem).attr('src', getPercentileBar(idItem)); + if (values['type_percentile'] == 'bubble') { + $("#image_" + idItem).attr('src', getPercentileBubble(idItem, values)); + } + else { + $("#image_" + idItem).attr('src', getPercentileBar(idItem, values)); + } + break; case 'module_graph': $("#text_" + idItem).html(values['label']); @@ -225,10 +265,9 @@ function updateAction() { $("#text_" + idItem).html(values['label']); break; case 'icon': - var params = []; params.push("get_image_path=1"); - params.push("img_src=" + getImageElement(idItem)); + params.push("img_src=images/console/icons/" + values['image'] + ".png"); params.push("page=include/ajax/skins.ajax"); params.push("only_src=1"); jQuery.ajax ({ @@ -241,7 +280,7 @@ function updateAction() { $("#image_" + idItem).attr('src', data); } }); - + if ((values['width'] != 0) && (values['height'] != 0)) { $("#image_" + idItem).attr('width', values['width']); $("#image_" + idItem).attr('height', values['height']); @@ -258,7 +297,7 @@ function updateAction() { } updateDB(selectedItem, idItem , values); - + actionClick(); } @@ -283,6 +322,8 @@ function readFields() { values['max_percentile'] = $("input[name=max_percentile]").val(); values['width_module_graph'] = $("input[name=width_module_graph]").val(); values['height_module_graph'] = $("input[name=height_module_graph]").val(); + values['type_percentile'] = $("input[name=type_percentile]:checked").val(); + values['value_show'] = $("input[name=value_show]:checked").val(); return values; } @@ -312,6 +353,7 @@ function createAction() { } break; case 'percentile_bar': + case 'percentile_item': if ((values['agent'] == '')) { alert($("#message_alert_no_agent").html()); validate = false; @@ -370,11 +412,11 @@ function actionClick() { if (openPropertiesPanel) { activeToolboxButton('static_graph', true); - activeToolboxButton('percentile_bar', true); activeToolboxButton('module_graph', true); activeToolboxButton('simple_value', true); activeToolboxButton('label', true); activeToolboxButton('icon', true); + activeToolboxButton('percentile_item', true); $(".item").draggable("enable"); $("#background").resizable('enable'); @@ -393,11 +435,11 @@ function actionClick() { $("#background").resizable('disable'); activeToolboxButton('static_graph', false); - activeToolboxButton('percentile_bar', false); activeToolboxButton('module_graph', false); activeToolboxButton('simple_value', false); activeToolboxButton('label', false); activeToolboxButton('icon', false); + activeToolboxButton('percentile_item', false); activeToolboxButton('edit_item', false); activeToolboxButton('delete_item', false); @@ -405,6 +447,7 @@ function actionClick() { if (creationItem != null) { //Create a item + activeToolboxButton(creationItem, true); item = creationItem; $("#button_update_row").css('display', 'none'); @@ -414,8 +457,10 @@ function actionClick() { } else if (selectedItem != null) { //Edit a item + item = selectedItem; toolbuttonActive = item; + activeToolboxButton(toolbuttonActive, true); $("#button_create_row").css('display', 'none'); $("#button_update_row").css('display', ''); cleanFields(); @@ -482,6 +527,28 @@ function loadFieldsFromDB(item) { if (key == 'max_percentile') $("input[name=max_percentile]").val(val); if (key == 'width_module_graph') $("input[name=width_module_graph]").val(val); if (key == 'height_module_graph') $("input[name=height_module_graph]").val(val); + + if (key == 'type_percentile') { + if (val == 'percentile') { + $("input[name=type_percentile][value=percentile]") + .attr("checked", "checked"); + } + else { + $("input[name=type_percentile][value=bubble]") + .attr("checked", "checked"); + } + } + + if (key == 'value_show') { + if (val == 'percent') { + $("input[name=value_show][value=percent]") + .attr("checked", "checked"); + } + else { + $("input[name=value_show][value=value]") + .attr("checked", "checked"); + } + } }); } }); @@ -583,10 +650,16 @@ function hiddenFields(item) { $("#percentile_bar_row_1").css('display', 'none'); $("#percentile_bar_row_1." + item).css('display', ''); - + $("#percentile_bar_row_2").css('display', 'none'); $("#percentile_bar_row_2." + item).css('display', ''); + $("#percentile_item_row_3").css('display', 'none'); + $("#percentile_item_row_3." + item).css('display', ''); + + $("#percentile_item_row_4").css('display', 'none'); + $("#percentile_item_row_4." + item).css('display', ''); + $("#period_row").css('display', 'none'); $("#period_row." + item).css('display', ''); @@ -697,13 +770,13 @@ function getModuleValue(id_data) { return module_value; } -function getPercentileBar(id_data) { +function getPercentileBar(id_data, values) { var parameter = Array(); - var percentile = 0; parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "action", value: "get_module_value"}); parameter.push ({name: "id_element", value: id_data}); + parameter.push ({name: "value_show", value: values['value_show']}); jQuery.ajax({ async: false, url: "ajax.php", @@ -715,6 +788,10 @@ function getPercentileBar(id_data) { module_value = data['value']; max_percentile = data['max_percentile']; width_percentile = data['width_percentile']; + unit_text = false + if (data['unit_text'] != false) + unit_text = data['unit_text']; + colorRGB = data['colorRGB']; } }); @@ -736,14 +813,84 @@ function getPercentileBar(id_data) { }); - if ( max_percentile > 0) - percentile = module_value / max_percentile * 100; + var percentile = Math.round(module_value / max_percentile * 100); else - percentile = 100; + var percentile = 100; + + if (unit_text == false) { + value_text = percentile + "%"; + } + else { + value_text = module_value + " " + unit_text; + } var img = 'include/graphs/fgraph.php?homeurl=../../&graph_type=progressbar&height=15&' + - 'width=' + width_percentile + '&mode=1&progress=' + percentile + '&font=' + font; + 'width=' + width_percentile + '&mode=1&progress=' + percentile + + '&font=' + font + '&value_text=' + value_text + '&colorRGB=' + colorRGB; + + return img; +} + +function getPercentileBubble(id_data, values) { + var parameter = Array(); + + parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); + parameter.push ({name: "action", value: "get_module_value"}); + parameter.push ({name: "id_element", value: id_data}); + parameter.push ({name: "value_show", value: values['value_show']}); + jQuery.ajax({ + async: false, + url: "ajax.php", + data: parameter, + type: "POST", + dataType: 'json', + success: function (data) + { + module_value = data['value']; + max_percentile = data['max_percentile']; + width_percentile = data['width_percentile']; + unit_text = false + if (data['unit_text'] != false) + unit_text = data['unit_text']; + colorRGB = data['colorRGB']; + } + }); + + + //Get the actual system font. + parameter = Array(); + parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); + parameter.push ({name: "action", value: "get_font"}); + jQuery.ajax({ + async: false, + url: "ajax.php", + data: parameter, + type: "POST", + dataType: 'json', + success: function (data) + { + font = data['font']; + } + }); + + + if ( max_percentile > 0) + var percentile = Math.round(module_value / max_percentile * 100); + else + var percentile = 100; + + if (unit_text == false) { + value_text = percentile + "%"; + } + else { + value_text = module_value + " " + unit_text; + } + + var img = 'include/graphs/fgraph.php?homeurl=../../&graph_type=progressbubble&height=' + width_percentile + '&' + + 'width=' + width_percentile + '&mode=1&progress=' + percentile + + '&font=' + font + '&value_text=' + value_text + '&colorRGB=' + colorRGB; + return img; } @@ -809,13 +956,13 @@ function createItem(type, values, id_data) { sizeStyle = 'width: ' + values['width'] + 'px; height: ' + values['height'] + 'px;'; imageSize = 'width="' + values['width'] + '" height="' + values['height'] + '"'; } - + var element_status= null; var parameter = Array(); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "get_element_status", value: "1"}); parameter.push ({name: "id_element", value: id_data}); - + jQuery.ajax ({ type: 'POST', url: action="ajax.php", @@ -826,14 +973,14 @@ function createItem(type, values, id_data) { element_status = data; } }); - + var img_src= null; var parameter = Array(); parameter.push ({name: "page", value: "include/ajax/skins.ajax"}); parameter.push ({name: "get_image_path", value: "1"}); parameter.push ({name: "img_src", value: getImageElement(id_data)}); parameter.push ({name: "only_src", value: "1"}); - + jQuery.ajax ({ type: 'POST', url: action="ajax.php", @@ -847,27 +994,41 @@ function createItem(type, values, id_data) { item = $('
    ' + + + 'style="color: ' + values['label_color'] + + '; text-align: center; position: absolute; display: inline-block; ' + + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' + '
    ' + '' + values['label'] + '' + '
    ' ); break; case 'percentile_bar': - sizeStyle = ''; - imageSize = ''; + case 'percentile_item': + var sizeStyle = ''; + var imageSize = ''; - item = $('
    ' + - '' + values['label'] + '
    ' + - '' + - '
    ' - ); + if (values['type_percentile'] == 'percentile') { + item = $('
    ' + + '' + values['label'] + '
    ' + + '' + + '
    ' + ); + } + else { + item = $('
    ' + + '' + values['label'] + '
    ' + + '' + + '
    ' + ); + } break; case 'module_graph': sizeStyle = ''; imageSize = ''; - item = $('
    ' + + item = $('
    ' + '' + values['label'] + '
    ' + '' + '
    ' @@ -877,14 +1038,14 @@ function createItem(type, values, id_data) { sizeStyle = ''; imageSize = ''; - item = $('
    ' + + item = $('
    ' + ' ' + values['label'] + '' + '' + getModuleValue(id_data) + '' + '
    ' ); break; case 'label': - item = $('
    ' + + item = $('
    ' + '' + values['label'] + '' + '
    ' ); @@ -916,8 +1077,8 @@ function createItem(type, values, id_data) { img_src = data; } }); - - item = $('
    ' + + + item = $('
    ' + '
    ' + '
    ' ); @@ -934,7 +1095,7 @@ function createItem(type, values, id_data) { "color": visual_map_get_color_line_status(id_data) }; lines.push(line); - refresh_lines(lines, 'background'); + refresh_lines(lines, 'background', true); } } @@ -980,24 +1141,24 @@ function updateDB_visual(type, idElement , values, event, top, left) { case 'module_graph': $("#image_" + idElement).attr("src", getModuleGraph(idElement)); case 'static_graph': - case 'percentile_bar': + case 'percentile_item': case 'simple_value': case 'label': case 'icon': if ((typeof(values['mov_left']) != 'undefined') && (typeof(values['mov_top']) != 'undefined')) { - $("#" + idElement).css('top', '0px').css('margin-top', top + 'px'); - $("#" + idElement).css('left', '0px').css('margin-left', left + 'px'); + $("#" + idElement).css('top', '0px').css('top', top + 'px'); + $("#" + idElement).css('left', '0px').css('left', left + 'px'); } else if ((typeof(values['absolute_left']) != 'undefined') && (typeof(values['absolute_top']) != 'undefined')) { - $("#" + idElement).css('top', '0px').css('margin-top', top + 'px'); - $("#" + idElement).css('left', '0px').css('margin-left', left + 'px'); + $("#" + idElement).css('top', '0px').css('top', top + 'px'); + $("#" + idElement).css('left', '0px').css('left', left + 'px'); } $("#" + idElement).css('color', values['label_color']); found = false; jQuery.each(lines, function(i, line) { - if (lines[i]['id'] == idElement) { + if (lines[i]['node_begin'] == idElement) { found = true; if (values['parent'] == 0) { lines.splice(i); @@ -1021,7 +1182,7 @@ function updateDB_visual(type, idElement , values, event, top, left) { lines.push(line); } - refresh_lines(lines, 'background'); + refresh_lines(lines, 'background', true); break; case 'background': if(values['width'] == '0' || values['height'] == '0'){ @@ -1067,11 +1228,8 @@ function updateDB(type, idElement , values, event) { if ((typeof(values['mov_left']) != 'undefined') && (typeof(values['mov_top']) != 'undefined')) { - top = parseInt($("#" + idElement).css('margin-top').replace('px', '')); - left = parseInt($("#" + idElement).css('margin-left').replace('px', '')); - - top = top + parseInt(values['mov_top']); - left = left + parseInt(values['mov_left']); + top = parseInt($("#" + idElement).css('top').replace('px', '')); + left = parseInt($("#" + idElement).css('left').replace('px', '')); } else if ((typeof(values['absolute_left']) != 'undefined') && (typeof(values['absolute_top']) != 'undefined')) { @@ -1080,8 +1238,15 @@ function updateDB(type, idElement , values, event) { } if ((typeof(top) != 'undefined') && (typeof(left) != 'undefined')) { - parameter.push ({name: 'top', value: top}); - parameter.push ({name: 'left', value: left}); + if ((typeof(values['top']) == 'undefined') && + (typeof(values['left']) == 'undefined')) { + parameter.push ({name: 'top', value: top}); + parameter.push ({name: 'left', value: left}); + } + else { + values['top'] = top; + values['left'] = left; + } } success_update = false; @@ -1127,7 +1292,7 @@ function deleteDB(idElement) { lines.splice(i); } }); - refresh_lines(lines, 'background'); + refresh_lines(lines, 'background', true); $('#' + idElement).remove(); activeToolboxButton('delete_item', false); @@ -1187,13 +1352,13 @@ function eventsItems(drag) { activeToolboxButton('delete_item', true); activeToolboxButton('show_grid', false); } - if ($(divParent).hasClass('percentile_bar')) { + if ($(divParent).hasClass('percentile_item')) { creationItem = null; - selectedItem = 'percentile_bar'; + selectedItem = 'percentile_item'; idItem = $(divParent).attr('id'); activeToolboxButton('edit_item', true); activeToolboxButton('delete_item', true); - activeToolboxButton('show_grid', false); + activeToolboxButton('show_grid', false); } if ($(divParent).hasClass('module_graph')) { creationItem = null; @@ -1238,54 +1403,39 @@ function eventsItems(drag) { } }); - $(".item").draggable({grid: drag}); + //Set the limit of draggable in the div with id "background" and set drag + //by default is false. + $(".item").draggable({containment: "#background", grid: drag}); $('.item').bind('dragstart', function(event, ui) { event.stopPropagation(); if (!openPropertiesPanel) { - divParent = $(event.target).parent(); unselectAll(); - $(divParent).css('border', '2px blue dotted'); + $(event.target).css('border', '2px blue dotted'); - if ($(divParent).hasClass('static_graph')) { - creationItem = null; + selectedItem = null; + if ($(event.target).hasClass('static_graph')) { selectedItem = 'static_graph'; - idItem = $(divParent).attr('id'); - activeToolboxButton('edit_item', true); - activeToolboxButton('delete_item', true); } - if ($(divParent).hasClass('percentile_bar')) { - creationItem = null; - selectedItem = 'percentile_bar'; - idItem = $(divParent).attr('id'); - activeToolboxButton('edit_item', true); - activeToolboxButton('delete_item', true); + if ($(event.target).hasClass('percentile_item')) { + selectedItem = 'percentile_item'; } - if ($(divParent).hasClass('module_graph')) { - creationItem = null; + if ($(event.target).hasClass('module_graph')) { selectedItem = 'module_graph'; - idItem = $(divParent).attr('id'); - activeToolboxButton('edit_item', true); - activeToolboxButton('delete_item', true); } - if ($(divParent).hasClass('simple_value')) { - creationItem = null; + if ($(event.target).hasClass('simple_value')) { selectedItem = 'simple_value'; - idItem = $(divParent).attr('id'); - activeToolboxButton('edit_item', true); - activeToolboxButton('delete_item', true); } - if ($(divParent).hasClass('label')) { - creationItem = null; + if ($(event.target).hasClass('label')) { selectedItem = 'label'; - idItem = $(divParent).attr('id'); - activeToolboxButton('edit_item', true); - activeToolboxButton('delete_item', true); } - if ($(divParent).hasClass('icon')) { - creationItem = null; + if ($(event.target).hasClass('icon')) { selectedItem = 'icon'; - idItem = $(divParent).attr('id'); + } + + if (selectedItem != null) { + creationItem = null; + idItem = $(event.target).attr('id'); activeToolboxButton('edit_item', true); activeToolboxButton('delete_item', true); } @@ -1296,7 +1446,6 @@ function eventsItems(drag) { event.stopPropagation(); var values = {}; - values['mov_left'] = ui.position.left; values['mov_top'] = ui.position.top; @@ -1371,8 +1520,8 @@ function move_elements_resize(original_width, original_height, width, height) { .replace('ui-draggable', '').replace('ui-draggable-disabled', '') .replace(/^\s+/g,'').replace(/\s+$/g,''); - old_height = parseInt($(item).css('margin-top').replace('px', '')); - old_width = parseInt($(item).css('margin-left').replace('px', '')); + old_height = parseInt($(item).css('top').replace('px', '')); + old_width = parseInt($(item).css('left').replace('px', '')); ratio_width = width / original_width; ratio_height = height / original_height; @@ -1401,7 +1550,8 @@ function click_button_toolbox(id) { actionClick(); break; case 'percentile_bar': - toolbuttonActive = creationItem = 'percentile_bar'; + case 'percentile_item': + toolbuttonActive = creationItem = 'percentile_item'; actionClick(); break; case 'module_graph': @@ -1441,7 +1591,7 @@ function click_button_toolbox(id) { //And it is necesary to re-code more parts of code to change //this method. activeToolboxButton('static_graph', false); - activeToolboxButton('percentile_bar', false); + activeToolboxButton('percentile_item', false); activeToolboxButton('module_graph', false); activeToolboxButton('simple_value', false); activeToolboxButton('label', false); @@ -1468,7 +1618,7 @@ function click_button_toolbox(id) { } activeToolboxButton('static_graph', true); - activeToolboxButton('percentile_bar', true); + activeToolboxButton('percentile_item', true); activeToolboxButton('module_graph', true); activeToolboxButton('simple_value', true); activeToolboxButton('label', true); @@ -1584,8 +1734,8 @@ function showGrid() { .replace('ui-draggable', '').replace('ui-draggable-disabled', '') .replace(/^\s+/g,'').replace(/\s+$/g,''); - pos_y = parseInt($(item).css('margin-top').replace('px', '')); - pos_x = parseInt($(item).css('margin-left').replace('px', '')); + pos_y = parseInt($(item).css('top').replace('px', '')); + pos_x = parseInt($(item).css('left').replace('px', '')); pos_y = Math.floor(pos_y / SIZE_GRID) * SIZE_GRID; pos_x = Math.floor(pos_x / SIZE_GRID) * SIZE_GRID; diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php index c7b8e396cb..fb98d3f80b 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.php +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -47,7 +47,7 @@ foreach ($all_images as $image_file) { echo '
    '; echo '
    '; visual_map_print_button_editor('static_graph', __('Static Graph'), 'left', false, 'camera_min', true); - visual_map_print_button_editor('percentile_bar', __('Percentile Bar'), 'left', false, 'percentile_min', true); + visual_map_print_button_editor('percentile_item', __('Percentile Item'), 'left', false, 'percentile_item_min', true); visual_map_print_button_editor('module_graph', __('Module Graph'), 'left', false, 'graph_min', true); visual_map_print_button_editor('simple_value', __('Simple Value'), 'left', false, 'binary_min', true); visual_map_print_button_editor('label', __('Label'), 'left', false, 'label_min', true); @@ -97,15 +97,27 @@ echo '