diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 24dd9a8146..1200676e4b 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -742,7 +742,7 @@ $(document).ready (function () { var type_name_selected = type_names[type_selected]; - if(type_name_selected.match(/_string$/) == null) { + if (type_name_selected.match(/_string$/) == null) { // Numeric types $('#string_critical').hide(); $('#string_warning').hide(); @@ -756,8 +756,8 @@ $(document).ready (function () { $('#minmax_critical').hide(); $('#minmax_warning').hide(); } - - if(type_name_selected.match(/async/) == null) { + + if (type_name_selected.match(/async/) == null) { $('#ff_timeout').hide(); $('#ff_timeout_disable').show(); } @@ -768,7 +768,7 @@ $(document).ready (function () { }); $("#id_module_type").trigger('change'); - + // Prevent the form submission when the user hits the enter button from the relationship autocomplete inputs $("#text-autocomplete_agent_name").keydown(function(event){ if(event.keyCode == 13) { // key code 13 is the enter button @@ -844,7 +844,8 @@ function change_modules_autocomplete_input () { event.preventDefault(); } }); - } else { + } + else { module_autocomplete.html(error_icon); } }, @@ -938,12 +939,12 @@ function change_lock_relation (num_row, id_relation) { var button = row.find("#disable_updates_button"); var oldSrc = button.find("img").prop("src"); var isEnabled = button.hasClass('alpha50'); - + if (row.length > 0 && !button.hasClass('working')) { button.addClass('working'); button.removeClass('alpha50'); button.find("img").prop("src", 'images/spinner.gif'); - + $.ajax({ type: "POST", url: "ajax.php", @@ -976,11 +977,11 @@ function delete_relation (num_row, id_relation) { var row = $("#module_relations-" + num_row); var button = row.find("#delete_relation_button"); var oldSrc = button.find("img").prop("src"); - + if (row.length > 0 && !button.hasClass('working')) { button.addClass('working'); button.find("img").prop("src", 'images/spinner.gif'); - + $.ajax({ type: "POST", url: "ajax.php", @@ -1008,6 +1009,7 @@ function delete_relation (num_row, id_relation) { function validate_post_process() { var post_process = $("#text-post_process").val(); var new_post_process = post_process.replace(',', '.'); + $("#text-post_process").val(new_post_process); } diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index e0efff55e3..8cafce0859 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -35,7 +35,9 @@ if (defined('METACONSOLE')) $hack_metaconsole = '../../'; if (!defined('METACONSOLE')) { - ui_print_page_header (__('Reporting') .' » ' . __('Visual Console'), "images/op_reporting.png", false, "map_builder"); + ui_print_page_header( + __('Reporting') .' » ' . __('Visual Console'), + "images/op_reporting.png", false, "map_builder"); } $id_layout = (int) get_parameter ('id_layout'); @@ -64,7 +66,7 @@ if ($delete_layout || $copy_layout) { // $vconsole_read = check_acl ($config['id_user'], $group_id, "VR"); $vconsole_write = check_acl ($config['id_user'], $group_id, "VW"); $vconsole_manage = check_acl ($config['id_user'], $group_id, "VM"); - + if (!$vconsole_write && !$vconsole_manage) { db_pandora_audit("ACL Violation", "Trying to access map builder"); @@ -73,29 +75,36 @@ if ($delete_layout || $copy_layout) { } if ($delete_layout) { - db_process_sql_delete ('tlayout_data', array ('id_layout' => $id_layout)); - $result = db_process_sql_delete ('tlayout', array ('id' => $id_layout)); + db_process_sql_delete('tlayout_data', + array ('id_layout' => $id_layout)); + $result = db_process_sql_delete('tlayout', + array ('id' => $id_layout)); if ($result) { - db_pandora_audit( "Visual console builder", "Delete visual console #$id_layout"); + db_pandora_audit( + "Visual console builder", "Delete visual console #$id_layout"); ui_print_success_message(__('Successfully deleted')); db_clean_cache(); } else { - db_pandora_audit( "Visual console builder", "Fail try to delete visual console #$id_layout"); - ui_print_error_message(__('Not deleted. Error deleting data')); + db_pandora_audit( + "Visual console builder", "Fail try to delete visual console #$id_layout"); + ui_print_error_message( + __('Not deleted. Error deleting data')); } $id_layout = 0; } - + if ($copy_layout) { // Number of inserts $ninsert = (int) 0; // Return from DB the source layout - $layout_src = db_get_all_rows_filter ("tlayout","id = " . $id_layout); + $layout_src = db_get_all_rows_filter("tlayout", + array("id" => $id_layout)); // Name of dst - $name_dst = get_parameter ("name_dst", $layout_src[0]['name'] . " copy"); + $name_dst = get_parameter ("name_dst", + $layout_src[0]['name'] . " copy"); // Create the new Console $idGroup = $layout_src[0]['id_group']; @@ -104,7 +113,12 @@ if ($delete_layout || $copy_layout) { $width = $layout_src[0]['width']; $visualConsoleName = $name_dst; - $values = array('name' => $visualConsoleName, 'id_group' => $idGroup, 'background' => $background, 'height' => $height, 'width' => $width); + $values = array( + 'name' => $visualConsoleName, + 'id_group' => $idGroup, + 'background' => $background, + 'height' => $height, + 'width' => $width); $result = db_process_sql_insert('tlayout', $values); $idNewVisualConsole = $result; @@ -113,14 +127,16 @@ if ($delete_layout || $copy_layout) { $ninsert = 1; // Return from DB the items of the source layout - $data_layout_src = db_get_all_rows_filter ("tlayout_data", "id_layout = " . $id_layout); + $data_layout_src = db_get_all_rows_filter( + "tlayout_data", + array("id_layout" => $id_layout)); if (!empty($data_layout_src)) { //By default the id parent 0 is always 0. $id_relations = array(0 => 0); - for ($a=0; $a < count($data_layout_src); $a++) { + for ($a = 0; $a < count($data_layout_src); $a++) { // Changing the source id by the new visual console id $data_layout_src[$a]['id_layout'] = $idNewVisualConsole; @@ -131,7 +147,8 @@ if ($delete_layout || $copy_layout) { unset($data_layout_src[$a]['id']); // Configure the cloned Console - $result = db_process_sql_insert('tlayout_data', $data_layout_src[$a]); + $result = db_process_sql_insert('tlayout_data', + $data_layout_src[$a]); $id_relations[$old_id] = 0; @@ -149,13 +166,15 @@ if ($delete_layout || $copy_layout) { if ($ninsert == $inserts) { //Update the ids of parents - $items = db_get_all_rows_filter ("tlayout_data", "id_layout = " . $idNewVisualConsole); + $items = db_get_all_rows_filter("tlayout_data", + array("id_layout" => $idNewVisualConsole)); foreach ($items as $item) { $new_parent = $id_relations[$item['parent_item']]; db_process_sql_update('tlayout_data', - array('parent_item' => $new_parent), array('id' => $item['id'])); + array('parent_item' => $new_parent), + array('id' => $item['id'])); } @@ -178,6 +197,7 @@ if ($delete_layout || $copy_layout) { } } +$table = new stdClass(); $table->width = '100%'; $table->data = array (); $table->head = array (); @@ -205,16 +225,21 @@ $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || $vconsoles_read) $maps = visual_map_get_user_layouts (); else - $maps = visual_map_get_user_layouts ($config['id_user'], false, false, false); + $maps = visual_map_get_user_layouts ($config['id_user'], false, + false, false); if (!$maps) { - ui_print_info_message ( array('no_close'=>true, 'message'=> __('No maps defined') ) ); + ui_print_info_message ( + array('no_close'=>true, + 'message'=> __('No maps defined'))); } else { foreach ($maps as $map) { // ACL for the visual console permission - $vconsole_write = check_acl ($config['id_user'], $map['id_group'], "VW"); - $vconsole_manage = check_acl ($config['id_user'], $map['id_group'], "VM"); + $vconsole_write = check_acl ($config['id_user'], + $map['id_group'], "VW"); + $vconsole_manage = check_acl ($config['id_user'], + $map['id_group'], "VM"); $data = array (); @@ -257,13 +282,15 @@ else { } if ($vconsoles_write || $vconsoles_manage) { - if (!defined('METACONSOLE')) + if (!defined('METACONSOLE')) { echo '
'; } echo ''; diff --git a/pandora_console/godmode/reporting/visual_console_builder.data.php b/pandora_console/godmode/reporting/visual_console_builder.data.php index 019d1c423f..86dc7698e2 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.data.php +++ b/pandora_console/godmode/reporting/visual_console_builder.data.php @@ -84,6 +84,7 @@ switch ($action) { break; } +$table = new stdClass(); $table->width = '100%'; if (defined('METACONSOLE')) { $table->width = '100%'; @@ -95,9 +96,11 @@ if (defined('METACONSOLE')) { $table->align[1] = 'left'; } $table->data = array (); -$table->data[0][0] = __('Name:'). ui_print_help_tip (__("Use [ or ( as first character, for example '[*] Map name', to render this map name in main menu"), true); +$table->data[0][0] = __('Name:') . + ui_print_help_tip(__("Use [ or ( as first character, for example '[*] Map name', to render this map name in main menu"), true); -$table->data[0][1] = html_print_input_text ('name', $visualConsoleName, '', 80, 100, true); +$table->data[0][1] = html_print_input_text('name', $visualConsoleName, + '', 80, 100, true); $table->data[1][0] = __('Group:'); $groups = users_get_groups ($config['id_user'], 'RW'); @@ -109,11 +112,15 @@ if ($own_info['is_admin'] || $vconsole_write || $vconsole_manage) else $display_all_group = false; -$table->data[1][1] = html_print_select_groups($config['id_user'], "RW", $display_all_group, 'id_group', $idGroup, '', '', '', true); -$backgrounds_list = list_files ($config['homedir'] . '/images/console/background/', "jpg", 1, 0); -$backgrounds_list = array_merge ($backgrounds_list, list_files ($config['homedir'] . '/images/console/background/', "png", 1, 0)); +$table->data[1][1] = html_print_select_groups($config['id_user'], "RW", + $display_all_group, 'id_group', $idGroup, '', '', '', true); +$backgrounds_list = list_files( + $config['homedir'] . '/images/console/background/', "jpg", 1, 0); +$backgrounds_list = array_merge($backgrounds_list, + list_files($config['homedir'] . '/images/console/background/', "png", 1, 0)); $table->data[2][0] = __('Background'); -$table->data[2][1] = html_print_select ($backgrounds_list, 'background', $background, '', '', 0, true); +$table->data[2][1] = html_print_select($backgrounds_list, 'background', + $background, '', '', 0, true); if ($action == 'new') { $textButtonSubmit = __('Save'); $classButtonSubmit = 'sub wand'; @@ -126,7 +133,8 @@ else { html_print_table($table); echo ' '; echo ""; diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index ea475e62f6..a95d35487d 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -1112,14 +1112,16 @@ function getModuleGraph(id_data) { value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "action", value: "get_layout_data"}); parameter.push ({name: "id_element", value: id_data}); + parameter.push ({name: "id_visual_console", + value: id_visual_console}); + jQuery.ajax({ async: false, url: url_ajax, data: parameter, type: "POST", dataType: 'json', - success: function (data) - { + success: function (data) { id_agente_modulo = data['id_agente_modulo']; id_custom_graph = data['id_custom_graph']; label = data['label']; @@ -1149,6 +1151,8 @@ function getModuleGraph(id_data) { parameter.push ({name: "width", value: width}); parameter.push ({name: "period", value: period}); parameter.push ({name: "background_color", value: background_color}); + parameter.push ({name: "id_visual_console", + value: id_visual_console}); jQuery.ajax({ async: false, url: url_ajax, @@ -2085,7 +2089,6 @@ function copyDB(idItem) { jQuery.ajax({ url: url_ajax, - async: false, data: parameter, type: "POST", dataType: 'json', diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index 8e3875f652..b9bb134dfc 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -29,9 +29,11 @@ if (empty($visualConsole)) { // if (!isset($vconsole_read)) // $vconsole_read = check_acl ($config['id_user'], $visualConsole['id_group'], "VR"); if (!isset($vconsole_write)) - $vconsole_write = check_acl ($config['id_user'], $visualConsole['id_group'], "VW"); + $vconsole_write = check_acl($config['id_user'], + $visualConsole['id_group'], "VW"); if (!isset($vconsole_manage)) - $vconsole_manage = check_acl ($config['id_user'], $visualConsole['id_group'], "VM"); + $vconsole_manage = check_acl($config['id_user'], + $visualConsole['id_group'], "VM"); if (!$vconsole_write && !$vconsole_manage) { db_pandora_audit("ACL Violation", @@ -47,11 +49,14 @@ enterprise_include_once('meta/include/functions_agents_meta.php'); enterprise_include_once('meta/include/functions_users_meta.php'); //Arrays for select box. -$backgrounds_list = list_files($config['homedir'] . '/images/console/background/', "jpg", 1, 0); -$backgrounds_list = array_merge($backgrounds_list, list_files ($config['homedir'] . '/images/console/background/', "png", 1, 0)); +$backgrounds_list = list_files( + $config['homedir'] . '/images/console/background/', "jpg", 1, 0); +$backgrounds_list = array_merge($backgrounds_list, + list_files($config['homedir'] . '/images/console/background/', "png", 1, 0)); $images_list = array (); -$all_images = list_files ($config['homedir'] . '/images/console/icons/', "png", 1, 0); +$all_images = list_files ($config['homedir'] . '/images/console/icons/', + "png", 1, 0); foreach ($all_images as $image_file) { if (strpos ($image_file, "_bad")) continue; @@ -63,6 +68,7 @@ foreach ($all_images as $image_file) { $images_list[$image_file] = $image_file; } +$table = new stdClass(); if (!defined('METACONSOLE')) { $table->width = '100%'; } @@ -101,8 +107,11 @@ $table->data = array(); //Background $table->data[0]['icon'] = ''; $table->data[0][0] = __('Background'); -$table->data[0][1] = html_print_select($backgrounds_list, 'background', $visualConsole['background'], '', 'None', '', true, false, true, '', false, 'width: 120px;'); -$table->data[0][2] = html_print_input_text('width', $visualConsole['width'], '', 3, 5, true) . +$table->data[0][1] = html_print_select($backgrounds_list, 'background', + $visualConsole['background'], '', 'None', '', true, false, true, '', + false, 'width: 120px;'); +$table->data[0][2] = html_print_input_text('width', + $visualConsole['width'], '', 3, 5, true) . 'x' . html_print_input_text('height', $visualConsole['height'], '', 3, 5, true); $table->data[0][3] = $table->data[0][4] = $table->data[0][5] = ''; @@ -126,51 +135,63 @@ foreach ($layoutDatas as $layoutData) { switch ($layoutData['type']) { case STATIC_GRAPH: $table->data[$i + 1]['icon'] = - html_print_image('images/camera.png', true, array('title' => __('Static Graph'))); + html_print_image('images/camera.png', true, + array('title' => __('Static Graph'))); break; case PERCENTILE_BAR: $table->data[$i + 1]['icon'] = - html_print_image('images/chart_bar.png', true, array('title' => __('Percentile Bar'))); + html_print_image('images/chart_bar.png', true, + array('title' => __('Percentile Bar'))); break; case PERCENTILE_BUBBLE: $table->data[$i + 1]['icon'] = - html_print_image('images/dot_red.png', true, array('title' => __('Percentile Bubble'))); + html_print_image('images/dot_red.png', true, + array('title' => __('Percentile Bubble'))); break; case MODULE_GRAPH: $table->data[$i + 1]['icon'] = - html_print_image('images/chart_curve.png', true, array('title' => __('Module Graph'))); + html_print_image('images/chart_curve.png', true, + array('title' => __('Module Graph'))); break; case SIMPLE_VALUE: $table->data[$i + 1]['icon'] = - html_print_image('images/binary.png', true, array('title' => __('Simple Value'))); + html_print_image('images/binary.png', true, + array('title' => __('Simple Value'))); break; case SIMPLE_VALUE_MAX: $table->data[$i + 1]['icon'] = - html_print_image('images/binary.png', true, array('title' => __('Simple Value (Process Max)'))); + html_print_image('images/binary.png', true, + array('title' => __('Simple Value (Process Max)'))); break; case SIMPLE_VALUE_MIN: $table->data[$i + 1]['icon'] = - html_print_image('images/binary.png', true, array('title' => __('Simple Value (Process Min)'))); + html_print_image('images/binary.png', true, + array('title' => __('Simple Value (Process Min)'))); break; case SIMPLE_VALUE_AVG: $table->data[$i + 1]['icon'] = - html_print_image('images/binary.png', true, array('title' => __('Simple Value (Process Avg)'))); + html_print_image('images/binary.png', true, + array('title' => __('Simple Value (Process Avg)'))); break; case LABEL: $table->data[$i + 1]['icon'] = - html_print_image('images/tag_red.png', true, array('title' => __('Label'))); + html_print_image('images/tag_red.png', true, + array('title' => __('Label'))); break; case ICON: $table->data[$i + 1]['icon'] = - html_print_image('images/photo.png', true, array('title' => __('Icon'))); + html_print_image('images/photo.png', true, + array('title' => __('Icon'))); break; case BOX_ITEM: $table->data[$i + 1]['icon'] = - html_print_image('images/box_item.png', true, array('title' => __('Box'))); + html_print_image('images/box_item.png', true, + array('title' => __('Box'))); break; case GROUP_ITEM: $table->data[$i + 1]['icon'] = - html_print_image('images/group_green.png', true, array('title' => __('Group'))); + html_print_image('images/group_green.png', true, + array('title' => __('Group'))); break; case LINE_ITEM: $table->data[$i + 1]['icon'] = @@ -235,7 +256,8 @@ foreach ($layoutDatas as $layoutData) { $table->data[$i + 1][2] = ''; break; default: - $table->data[$i + 1][2] = html_print_input_text('width_' . $idLayoutData, $layoutData['width'], '', 2, 5, true) . + $table->data[$i + 1][2] = html_print_input_text( + 'width_' . $idLayoutData, $layoutData['width'], '', 2, 5, true) . 'x' . html_print_input_text('height_' . $idLayoutData, $layoutData['height'], '', 2, 5, true); break; @@ -248,7 +270,9 @@ foreach ($layoutDatas as $layoutData) { $table->data[$i + 1][3] = ''; break; default: - $table->data[$i + 1][3] = '(' . html_print_input_text('left_' . $idLayoutData, $layoutData['pos_x'], '', 2, 5, true) . + $table->data[$i + 1][3] = '(' . + html_print_input_text('left_' . $idLayoutData, + $layoutData['pos_x'], '', 2, 5, true) . ',' . html_print_input_text('top_' . $idLayoutData, $layoutData['pos_y'], '', 2, 5, true) . ')'; break; @@ -327,7 +351,8 @@ foreach ($layoutDatas as $layoutData) { default: $cell_content_enterprise = false; if (enterprise_installed()) { - $cell_content_enterprise = enterprise_visual_map_print_list_element('agent', $layoutData); + $cell_content_enterprise = + enterprise_visual_map_print_list_element('agent', $layoutData); } if ($cell_content_enterprise === false) { $params = array(); @@ -505,7 +530,8 @@ if (!defined('METACONSOLE')) { "tab=" . $activeTab . "&" . "id_visual_console=" . $visualConsole["id"]; - echo '