diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 2cdd80550d..f26c6ae4b3 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG-170323 +Version: 7.0NG-170419 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index becb38c025..9105172634 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG-170323" +pandora_version="7.0NG-170419" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 301c4a9f9a..486cd5eacb 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG'; -use constant AGENT_BUILD => '170323'; +use constant AGENT_BUILD => '170419'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 9e6b270a49..45427b5af1 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG -%define release 170323 +%define release 170419 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 45e33c21c6..b9e23d40de 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG -%define release 170323 +%define release 170419 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index e3a8f04b30..2d57695113 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG" -PI_BUILD="170323" +PI_BUILD="170419" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/bin/util/ifaces.vbs b/pandora_agents/win32/bin/util/ifaces.vbs index e4265c9bd2..2e3a14251f 100644 --- a/pandora_agents/win32/bin/util/ifaces.vbs +++ b/pandora_agents/win32/bin/util/ifaces.vbs @@ -40,14 +40,15 @@ If (NOT flag) Then set ifaces_cfg = objWMIService.ExecQuery("Select ipaddress from Win32_NetworkAdapterConfiguration Where Caption='" & iface.caption & "'") Wscript.StdOut.Write " "" ) then + On Error Resume Next + if (iface_cfg.IPAddress(0) <> "" ) then Wscript.StdOut.Write trim(iface_cfg.IPAddress(0)) end if next - wscript.stdOut.WriteLine "]]>" + Wscript.StdOut.WriteLine "]]>" Next Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" Wscript.StdOut.WriteLine "" -End If \ No newline at end of file +End If diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index d3dff796c8..a0eb062b51 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{170323} +{170419} ViewReadme {Yes} diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index a2a25e5f3b..23ebaaf7e8 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -38,6 +38,7 @@ #include "pandora_module_plugin.h" #include "pandora_module_ping.h" #include "pandora_module_snmpget.h" +#include "../windows/pandora_wmi.h" #include "../pandora_strutils.h" #include @@ -1137,6 +1138,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { } else if (module_freedisk_percent != "") { module = new Pandora_Module_Freedisk_Percent (module_name, module_freedisk_percent); + // Added a description with the memory free + char buffer[100]; + unsigned long memory = Pandora_Wmi::getDiskFreeSpace(module_freedisk_percent); + if (sprintf(buffer, "Free memory %s %dMB", + module_freedisk_percent.c_str(), memory) > 0) { + module->setDescription(buffer); + } } else if (module_freememory != "") { module = new Pandora_Module_Freememory (module_name); } else if (module_freememory_percent != "") { diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 3c5c0cb38a..286b4d2517 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG(Build 170323)") +#define PANDORA_VERSION ("7.0NG(Build 170419)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 3e9184102c..45c2189385 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -300,7 +300,7 @@ Pandora_Windows_Service::pandora_init () { } // Get the agent alias. - conf->getValue ("agent_alias"); + agent_alias = conf->getValue ("agent_alias"); if (agent_alias == "") { agent_alias = Pandora_Windows_Info::getSystemName (); this->conf->setValue("agent_alias", agent_alias); @@ -441,7 +441,7 @@ Pandora_Windows_Service::getXmlHeader () { agent_name = conf->getValue ("agent_name"); // Get agent alias - conf->getValue ("agent_alias"); + agent_alias = conf->getValue ("agent_alias"); // Get parent agent name parent_agent_name = conf->getValue ("parent_agent_name"); @@ -1519,7 +1519,7 @@ Pandora_Windows_Service::checkConfig (string file) { } /* Get agent name */ - tmp = conf->getValue ("agent_name"); + agent_name = conf->getValue ("agent_name"); /* Error getting agent name */ diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 309588d0da..525bd8265a 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG(Build 170323))" + VALUE "ProductVersion", "(7.0NG(Build 170419))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index b3f97d9732..5294f39adb 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG-170323 +Version: 7.0NG-170419 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 8f1eb7c5a6..89a7f14fb3 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG-170323" +pandora_version="7.0NG-170419" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/1.sql b/pandora_console/extras/mr/1.sql deleted file mode 100644 index 4379665881..0000000000 --- a/pandora_console/extras/mr/1.sql +++ /dev/null @@ -1,11 +0,0 @@ -START TRANSACTION; - -CREATE TABLE IF NOT EXISTS `ttable_test` ( - `id` int(10) unsigned NOT NULL auto_increment, - `field1` varchar(60) NOT NULL default '', - `field2` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE `tusuario` ADD COLUMN `test` tinyint(1) NOT NULL DEFAULT 0; - -COMMIT; diff --git a/pandora_console/extras/mr/2.sql b/pandora_console/extras/mr/2.sql deleted file mode 100644 index 71e7ae46d4..0000000000 --- a/pandora_console/extras/mr/2.sql +++ /dev/null @@ -1,11 +0,0 @@ -START TRANSACTION; - -CREATE TABLE IF NOT EXISTS `ttable_test2` ( - `id` int(10) unsigned NOT NULL auto_increment, - `field1` varchar(60) NOT NULL default '', - `field2` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE `tusuario` ADD COLUMN `test_nuevo2` tinyint(1) NOT NULL DEFAULT 0; - -COMMIT; diff --git a/pandora_console/extras/mr/3.sql b/pandora_console/extras/mr/3.sql deleted file mode 100644 index dd762ab02c..0000000000 --- a/pandora_console/extras/mr/3.sql +++ /dev/null @@ -1,11 +0,0 @@ -START TRANSACTION; - -CREATE TABLE IF NOT EXISTS `ttable_test3` ( - `id` int(10) unsigned NOT NULL auto_increment, - `field1` varchar(60) NOT NULL default '', - `field2` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE `tusuario` ADD COLUMN `test3` tinyint(1) NOT NULL DEFAULT 0; - -COMMIT; diff --git a/pandora_console/extras/mr/4.sql b/pandora_console/extras/mr/4.sql deleted file mode 100644 index 013936a493..0000000000 --- a/pandora_console/extras/mr/4.sql +++ /dev/null @@ -1,11 +0,0 @@ -START TRANSACTION; - -CREATE TABLE IF NOT EXISTS `ttable_test4` ( - `id` int(10) unsigned NOT NULL auto_increment, - `field1` varchar(60) NOT NULL default '', - `field2` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE `tusuario` ADD COLUMN `test4` asdfasdfa; - -COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index ed2b52115c..93307fdbc0 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1291,6 +1291,22 @@ UPDATE twidget_dashboard SET id_widget = (SELECT id FROM twidget WHERE unique_na DELETE FROM twidget WHERE unique_name = 'graph_availability'; -- --------------------------------------------------------------------- --- Table `tbackup` +-- Table `tbackup` (Extension table. Modify only if exists) -- --------------------------------------------------------------------- -ALTER TABLE tbackup ADD COLUMN `filepath` varchar(512) NOT NULL DEFAULT ""; +DROP PROCEDURE IF EXISTS addcol; +delimiter // +CREATE PROCEDURE addcol() +BEGIN +SET @vv1 = (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tbackup'); +IF @vv1>0 THEN + ALTER TABLE tbackup ADD COLUMN `filepath` varchar(512) NOT NULL DEFAULT ""; +END IF; +END; +// +CALL addcol(); +DROP PROCEDURE addcol; + +-- --------------------------------------------------------------------- +-- Table `tconfig` +-- --------------------------------------------------------------------- +UPDATE `tconfig` SET `value` = 'login_logo_v7.png' where `token`='custom_logo_login'; diff --git a/pandora_console/general/cg_items.php b/pandora_console/general/cg_items.php new file mode 100644 index 0000000000..bb76299e07 --- /dev/null +++ b/pandora_console/general/cg_items.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 534b4efba0..9487a5519c 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -293,8 +293,8 @@ if ($search != "") { $search_sql .= ")"; }else{ $search_sql = " AND ( nombre " . $order_collation . " - LIKE '%$search%' OR alias " . $order_collation . " - LIKE '%$search%') "; + LIKE LOWER('%$search%') OR alias " . $order_collation . " + LIKE LOWER('%$search%')) "; } } diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 715dcf30ec..acbf762210 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -694,7 +694,7 @@ foreach ($modules as $module) { } } - $data[1] = '' . + $data[1] = '' . html_print_image($img,true, array('title' => $title)) . ''; } diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index 120cba7efe..b1311a7846 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -1173,7 +1173,7 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri secondText: '', currentText: '', closeText: ''}); - $("#text-once_date_from, #text-once_date_to").datepicker({dateFormat: ""}); + $("#text-once_date_from, #text-once_date_to").datepicker({dateFormat: "", showButtonPanel: true}); $.datepicker.setDefaults($.datepicker.regional[ ""]); diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 62ab5b3ca9..aec32ad0ae 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -688,7 +688,7 @@ foreach ($simple_alerts as $alert) { else { $img = 'images/policies.png'; - $data[3] .= '  ' . + $data[3] .= '  ' . html_print_image($img, true, array('title' => $policyInfo['name'])) . ''; } diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 5d2db04207..f420ea168c 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -115,7 +115,7 @@ if (enterprise_installed() && $alert['id_policy_alerts'] != 0) { else { $img = 'images/policies.png'; - $policy = '' . + $policy = '' . html_print_image($img, true, array('title' => $policyInfo['name'])) . ''; } diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 4aedb3d568..ec448f0cf4 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -49,7 +49,7 @@ You can of course remove the warnings, that's why we include the source and do n ui_print_page_header (__('Module management') . ' » ' . __('Network component management'), "", false, - "network_component", true,"sell",true,"modulemodal"); + "network_component", true,"",true,"modulemodal"); $sec = 'gmodules'; } diff --git a/pandora_console/godmode/modules/manage_network_templates_form.php b/pandora_console/godmode/modules/manage_network_templates_form.php index b2176426dc..7e8078b8c9 100644 --- a/pandora_console/godmode/modules/manage_network_templates_form.php +++ b/pandora_console/godmode/modules/manage_network_templates_form.php @@ -73,9 +73,11 @@ elseif (isset ($_GET["add_module"])) { if (isset ($_GET["create"]) || isset ($_GET["update"])) { //Submitted form - $name = get_parameter_post ("name"); + $name = io_safe_output(get_parameter_post ("name")); $description = get_parameter_post ("description"); - if ($name != "") { + + if (!empty($name) && !ctype_space($name)) { + $name = io_safe_input($name); if ($id_np > 0) { //Profile exists $values = array( diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index ac342f3a13..317f562e6f 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -65,6 +65,17 @@ $change_weight = (bool) get_parameter('change_weight', false); $change_label = (bool) get_parameter('change_label', false); $id_graph = (int) get_parameter('id', 0); +if($id_graph !== 0){ + $sql = "SELECT * FROM tgraph + WHERE (private = 0 OR (private = 1 AND id_user = '".$config["id_user"]."')) + AND id_graph = ".$id_graph; + $control = db_process_sql($sql); + if(!$control){ + header('Location: index.php?sec=reporting&sec2=godmode/reporting/graphs'); + } +} + + if ($add_graph) { $name = get_parameter_post ("name"); $description = get_parameter_post ("description"); diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index dbca48c15c..310286ae69 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -298,6 +298,26 @@ function update_button_palette_callback() { break; case 'module_graph': + + if($('#dir_items').html() == 'horizontal'){ + if(parseInt($('#text-left').val()) + (parseInt($('input[name=height_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('width')) + || parseInt($('#text-left').val()) + (parseInt($('input[name=width_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('width'))){ + + alert($('#count_items').html()+' joined graph items are wider than background'); + return false; + + } + } + + if($('#dir_items').html() == 'vertical'){ + if(parseInt($('#text-top').val()) + (parseInt($('input[name=height_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('height'))){ + alert($('#count_items').html()+' joined graph items are higher than background'); + return false; + + } + } + + if($('input[name=width_module_graph]').val() == ''){ alert('Undefined width'); return false; @@ -1151,6 +1171,8 @@ function loadFieldsFromDB(item) { }); + $('#count_items').html(1); + if (data.type == 6 || data.type == 7 || data.type == 8 || data.type == 1) { $("#period_row." + item).css('display', ''); @@ -1169,6 +1191,20 @@ function loadFieldsFromDB(item) { } else { + + jQuery.get ("ajax.php", + {"page": "general/cg_items","data": data.id_custom_graph}, + function (data, status) { + if(data.split(",")[0] == 4){ + $('#count_items').html(data.split(",")[1]); + $('#dir_items').html('vertical'); + } + else if (data.split(",")[0] == 5) { + $('#count_items').html(data.split(",")[1]); + $('#dir_items').html('horizontal'); + + } + }); $("input[name='radio_choice'][value='custom_graph']") .prop('checked', true); @@ -3125,9 +3161,8 @@ function move_elements_resize(original_width, original_height, width, height) { } function unselectAll() { - $("#background").css('border', '1px lightgray solid'); - - $(".item").each(function(){ + $("#background").css('border', '1px lightgray solid'); + $(".item").each(function(){ $(this).css('border', ''); if($(this).attr('withborder') == 'true'){ $(this).css('top', '+=1'); @@ -3136,7 +3171,7 @@ function unselectAll() { } }); - + selectedItem = null; } function click_button_toolbox(id) { diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index 11e98a1004..721b1597c6 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -55,12 +55,12 @@ if (isset($_GET["server"])) { } elseif (isset($_GET["server_remote"])) { - // Headers $id_server= get_parameter_get ("server_remote"); + $ext = get_parameter ("ext", ''); ui_print_page_header (__('Remote Configuration'), "images/gm_servers.png", false, "servers", true); enterprise_include("godmode/servers/server_disk_conf_editor.php"); - } +} else { // Header ui_print_page_header (__('Pandora servers'), "images/gm_servers.png", false, "servers", true); @@ -119,7 +119,8 @@ else { $correct = false; $id_server = get_parameter ("id_server"); - $server_md5 = md5(io_safe_output(servers_get_name ($id_server,'none')), FALSE); + $ext = get_parameter ("ext", ''); + $server_md5 = md5(io_safe_output(servers_get_name ($id_server,'none') . $ext), FALSE); if (file_exists ($config["remote_config"] . "/md5/" . $server_md5 . ".srv.md5")) { // Server remote configuration editor diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 5f03a29c64..0c8f542f2d 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -124,9 +124,14 @@ foreach ($servers as $server) { } $data[7] = ui_print_timestamp ($server['keepalive'], true); + + $ext = '_server'; + if ($server['type'] != 'data') + $ext = ''; + $safe_server_name = servers_get_name($server["id_server"]); - if (!isset($names_servers[$safe_server_name])){ - if (servers_check_remote_config ($safe_server_name) && enterprise_installed()) { + if (($server['type'] == 'data' || $server['type'] == 'enterprise satellite')) { + if (servers_check_remote_config ($safe_server_name . $ext) && enterprise_installed()) { $names_servers[$safe_server_name] = true; } else { $names_servers[$safe_server_name] = false; @@ -154,8 +159,8 @@ foreach ($servers as $server) { array('title' => __('Edit'))); $data[8] .= ''; - if ($names_servers[$safe_server_name] === true) { - $data[8] .= ''; + if (($names_servers[$safe_server_name] === true) && ($server['type'] == 'data' || $server['type'] == 'enterprise satellite')) { + $data[8] .= ''; $data[8] .= html_print_image ('images/remote_configuration.png', true, array('title' => __('Remote configuration'))); $data[8] .= ''; diff --git a/pandora_console/include/ajax/double_auth.ajax.php b/pandora_console/include/ajax/double_auth.ajax.php index 642ceb778a..6d60a2d8e9 100644 --- a/pandora_console/include/ajax/double_auth.ajax.php +++ b/pandora_console/include/ajax/double_auth.ajax.php @@ -296,6 +296,8 @@ if ($get_double_auth_generation_page) { ob_clean(); ?> + + There is a new version: " . $result[0]['version'] . "

"; echo "" . + "\", \"" . $result[0]['version'] ."\", \"" . $baseurl ."\");'>" . __("Update to the last version") . ""; } else { diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index ad38e4a4e9..6941e435ba 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -2434,12 +2434,9 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $proportion_height = 0; $proportion_width = 0; - - if (!is_null($height) && !is_null($width)) { $resizedMap = true; - if ($keep_aspect_ratio) { $ratio = min($width / $layout['width'], $height / $layout['height']); $mapWidth = $ratio * $layout['width']; @@ -2453,49 +2450,48 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $dif_height = $layout["height"] - $mapHeight; $dif_width = $layout["width"] - $mapWidth; - $proportion_height = $mapHeight / $layout["height"]; $proportion_width = $mapWidth / $layout["width"]; - - if (is_metaconsole()) { - $backgroundImage = - '/include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . - $config['homeurl'] . 'images/console/background/' . - $layout["background"]; - } - else { - $backgroundImage = - '/include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . - $config['homedir'] . '/images/console/background/' . - ($layout["background"]); + if ($layout["background"] != 'None.png' ) { + if (is_metaconsole()) { + $backgroundImage = + '/include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . + $config['homeurl'] . 'images/console/background/' . + $layout["background"]; + } + else { + $backgroundImage = + '/include/Image/image_functions.php?getFile=1&thumb=1&thumb_size=' . $mapWidth . 'x' . $mapHeight . '&file=' . + $config['homedir'] . '/images/console/background/' . + ($layout["background"]); + } } } else { $mapWidth = $layout["width"]; $mapHeight = $layout["height"]; - $backgroundImage = $metaconsole_hack . 'images/console/background/' . - $layout["background"]; + $backgroundImage = ''; + if ($layout["background"] != 'None.png' ) + $backgroundImage = $metaconsole_hack . 'images/console/background/' . + $layout["background"]; } if (defined('METACONSOLE')) { echo "
"; } - echo '
'; - echo ""; + height:' . $mapHeight . 'px; + background-color:'.$layout["background_color"].';">'; + + if ($layout["background"] != 'None.png' ) + echo ""; $layout_datas = db_get_all_rows_field_filter('tlayout_data', diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 8fa3306927..47ce7665ce 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -446,7 +446,10 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { html_print_input_text('width_module_graph', 300, '', 3, 5, true) . ' X ' . html_print_input_text('height_module_graph', 180, '', 3, 5, true) . - ''; + ' X ' . + '1 '. + ' item/s + '; //Insert and modify before the buttons to create or update. @@ -587,6 +590,49 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $(".border_color").attachColorPicker(); $(".fill_color").attachColorPicker(); $(".line_color").attachColorPicker(); + + $("input[name=radio_choice]").change(function(){ + $('#count_items').html(1); + }); + + $("#custom_graph").click(function(){ + $('#count_items').html(1); + jQuery.get ("ajax.php", + {"page": "general/cg_items","data": $(this).val()}, + function (data, status) { + if(data.split(",")[0] == 8){ + size = 400+(data.split(",")[1] * 50); + if(data.split(",")[1]>3){ + size = 400+(3 * 50); + } + $('#text-width_module_graph').val(size); + $('#text-height_module_graph').val(180); + + } + else if (data.split(",")[0] == 4) { + size = data.split(",")[1]; + if(data.split(",")[1] > 1){ + $('#count_items').html(data.split(",")[1]); + $('#dir_items').html('vertical'); + } + $('#text-width_module_graph').val(300); + $('#text-height_module_graph').val(50); + } + else if (data.split(",")[0] == 5) { + size = data.split(",")[1]; + if(data.split(",")[1] > 1){ + $('#count_items').html(data.split(",")[1]); + $('#dir_items').html('horizontal'); + } + $('#text-width_module_graph').val(100); + $('#text-height_module_graph').val(100); + } + + }); + + }); + + }); "; + if (is_metaconsole()) { + return ""; + } + else { + return ""; + } } diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index b6f1eb2308..4b26484642 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -142,23 +142,31 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, } var label_conf; - - label_conf = { - show: true, - radius: 0.75, - formatter: function(label, series) { - return '
' + - series.percent.toFixed(2) + '%
'; - }, - background: { - opacity: 0.5, - color: '' - } - }; - var show_legend = true; + if((width <= 450)) { + show_legend = false; + label_conf = { + show: false + }; + } + else { + label_conf = { + show: true, + radius: 0.75, + formatter: function(label, series) { + return '
' + + series.percent.toFixed(2) + '%
'; + }, + background: { + opacity: 0.5, + color: '' + } + }; + + } + var conf_pie = { series: { pie: { @@ -176,6 +184,9 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, clickable: true } }; + if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { + conf_pie.series.pie.label = {show: false}; + } var plot = $.plot($('#'+graph_id), data, conf_pie); if (no_data == data.length) { @@ -205,17 +216,17 @@ function pandoraFlotPieCustom(graph_id, values, labels, width, var pielegends = $('#'+graph_id+' .pieLabelBackground'); pielegends.each(function () { - $(this).css('transform', "rotate(-35deg)"); + $(this).css('transform', "rotate(-35deg)").css('color', 'black'); }); var labelpielegends = $('#'+graph_id+' .pieLabel'); labelpielegends.each(function () { - $(this).css('transform', "rotate(-35deg)"); + $(this).css('transform', "rotate(-35deg)").css('color', 'black'); }); // Events $('#' + graph_id).bind('plothover', pieHover); $('#' + graph_id).bind('plotclick', Clickpie); - $('#' + graph_id).bind('mouseout',resetInteractivity); + $('#' + graph_id).bind('mouseout', resetInteractivity); $('#' + graph_id).css('margin-left', 'auto'); $('#' + graph_id).css('margin-right', 'auto'); @@ -309,15 +320,19 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, borderWidth: 1, backgroundColor: { colors: ["#FFF", "#FFF"] } }, + xaxis: { + axisLabelUseCanvas: true, + axisLabelFontSizePixels: font_size, + axisLabelFontFamily: font+'Font', + tickFormatter: xFormatter, + }, yaxis: { - axisLabelUseCanvas: true, - axisLabelFontSizePixels: 12, - axisLabelFontFamily: font+'Font', - axisLabelPadding: 3, - ticks: yFormatter, - tickSize: 1, - color: '', - }, + axisLabelUseCanvas: true, + axisLabelFontSizePixels: font_size, + axisLabelFontFamily: font+'Font', + ticks: yFormatter, + color: '', + }, legend: { show: false } @@ -339,141 +354,38 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, $('#' + graph_id).HUseTooltip(); $('#' + graph_id).css("margin-left","auto"); $('#' + graph_id).css("margin-right","auto"); - $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); - // Adjust the top of yaxis tick to set it in the middle of the bars - //yAxisHeight = $('#' + graph_id + ' .yAxis .tickLabel') - //.css('height').split('px')[0]; + //~ $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); - //~ i = 0; - //~ $('#' + graph_id + ' .yAxis .tickLabel').each(function() { - //~ $(this).css('display','none'); - //~ $(this).addClass("legend_"+i); - //~ i++; - //~ }); - - $('#' + graph_id + ' .xAxis .tickLabel').each(function() { - /* - tickTop = $(this).css('top').split('px')[0]; - tickNewTop = parseInt(parseInt(tickTop) - (yAxisHeight / 2) - 3); - $(this).css('top', tickNewTop + 'px'); - - valuesNewTop = parseInt(parseInt(tickTop) - (yAxisHeight)); - - $('#value_' + i + '_' + graph_id) - .css('top',parseInt(plot.offset().top) + parseInt(valuesNewTop)); - - pixelPerValue = parseInt(plot.width()) / maxvalue; - - inCanvasValuePos = parseInt(pixelPerValue * - ($('#value_' + i + '_' + graph_id).html())); - label_width = ($('#value_' + i + '_' + graph_id) - .css('width').split('px')[0] - 3); - - label_left_offset = plot.offset().left + inCanvasValuePos + 5; //Label located on right side of bar + 5 pixels - - //If label fit into the bar just recalculate left position to fit on right side of bar - if (inCanvasValuePos > label_width) { - label_left_offset = plot.offset().left + inCanvasValuePos - - $('#value_' + i + '_' + graph_id).css('width').split('px')[0] - 3; - } - - $('#value_' + i + '_' + graph_id) - .css('left', label_left_offset); - i++; - */ - label = parseFloat($(this).text()); - text = label.toLocaleString(); - if ( label >= 1000000) - text = text.substring(0,4) + "M"; - else if (label >= 100000) - text = text.substring(0,3) + "K"; - else if (label >= 1000) - text = text.substring(0,2) + "K"; - - $(this).text(text); - - }); - /* - // When resize the window, adjust the values - $('#' + graph_id).parent().resize(function () { - i = 0; - pixelPerValue = parseInt(plot.width()) / maxvalue; - - $('#' + graph_id + ' .yAxis .tickLabel').each(function() { - inCanvasValuePos = parseInt(pixelPerValue * - ($('#value_' + i + '_' + graph_id).html())); - label_width = ($('#value_' + i + '_' + graph_id) - .css('width').split('px')[0] - 3); - - label_left_offset = plot.offset().left + inCanvasValuePos + 5; //Label located on right side of bar + 5 pixels - - //If label fit into the bar just recalculate left position to fit on right side of bar - if (inCanvasValuePos > label_width) { - label_left_offset = plot.offset().left + inCanvasValuePos - - $('#value_' + i + '_' + graph_id) - .css('width').split('px')[0] - 3; - } - - $('#value_' + i + '_' + graph_id) - .css('left', label_left_offset); - i++; - }); - }); - - // Format functions - function xFormatter(v, axis) { - if (labels[v] != undefined) { - return labels[v]; - } - else { - return ''; - } - } - - function yFormatter(v, axis) { - return v; - } - - // Events - $('#' + graph_id).bind('plothover', function (event, pos, item) { - $('.values_' + graph_id).css('font-weight', ''); - if (item != null) { - index = item.dataIndex; - $('#value_' + index + '_' + graph_id) - .css('font-weight', 'bold'); - } - }); - - if (water_mark) { - set_watermark(graph_id, plot, - $('#watermark_image_' + graph_id).attr('src')); - } - - if (maxvalue == 0) { - - // Fixed the position for the graphs with all values in - // bars is 0. - - $(".values_" + graph_id).css("left", (plot.offset().left + 5) + "px"); - } - * */ function yFormatter(v, axis) { format = new Array(); for (i = 0; i < labels_total.length; i++) { var label = labels_total[i][1]; - var shortLabel = reduceText(label, 30); + var shortLabel = reduceText(label, 25); var title = ''; if (label !== shortLabel) { title = label; label = shortLabel; } - format.push([i,'
' + format.push([i,'
' + label + '
']); } return format; } + function xFormatter(v, axis) { + label = parseFloat(v); + text = label.toLocaleString(); + if ( label >= 1000000) + text = text.substring(0,4) + "M"; + else if (label >= 100000) + text = text.substring(0,3) + "K"; + else if (label >= 1000) + text = text.substring(0,2) + "K"; + + return '
'+text+'
'; + } + if (water_mark) { set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src')); } @@ -600,20 +512,30 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, }, xaxis: { axisLabelUseCanvas: true, - axisLabelFontSizePixels: 7, + axisLabelFontSizePixels: font_size, axisLabelFontFamily: font+'Font', axisLabelPadding: 0, ticks: xFormatter, labelWidth: 130, + labelHeight: 50, }, yaxis: { axisLabelUseCanvas: true, - axisLabelFontSizePixels: 7, + axisLabelFontSizePixels: font_size, axisLabelFontFamily: font+'Font', axisLabelPadding: 100, autoscaleMargin: 0.02, tickFormatter: function (v, axis) { - return v ; + label = parseFloat(v); + text = label.toLocaleString(); + if ( label >= 1000000) + text = text.substring(0,4) + "M"; + else if (label >= 100000) + text = text.substring(0,3) + "K"; + else if (label >= 1000) + text = text.substring(0,2) + "K"; + + return '
'+text+'
'; } }, legend: { @@ -630,82 +552,43 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, } }; + if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) + options.xaxis.labelWidth = 100; + var plot = $.plot($('#'+graph_id),datas, options ); $('#' + graph_id).VUseTooltip(); $('#' + graph_id).css("margin-left","auto"); $('#' + graph_id).css("margin-right","auto"); - $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); - // Adjust the top of yaxis tick to set it in the middle of the bars - //yAxisHeight = $('#'+graph_id+' .yAxis .tickLabel').css('height').split('px')[0]; - - //plot.getPlaceholder().onload = function(){pruebas}; - //~ i = 0; - //~ $('#'+graph_id+' .xAxis .tickLabel').each(function() { - //~ $(this).css('display','none'); - //~ $(this).addClass("legend_"+i); - //~ i++; - //~ tickNewTop = parseInt(parseInt(tickTop) - (yAxisHeight/2)-3); - //~ $(this).css('top', tickNewTop+'px'); - //~ - //~ valuesNewTop = parseInt(parseInt(tickTop) - (yAxisHeight)); - //~ - //~ $('#value_'+i+'_'+graph_id).css('top',parseInt(plot.offset().top) + parseInt(valuesNewTop)); -//~ - //~ pixelPerValue = parseInt(plot.width()) / maxvalue; - //~ - //~ inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html())); - //~ - //~ $('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3); - //~ }); - - // When resize the window, adjust the values - //~ $('#'+graph_id).parent().resize(function () { - //~ i = 0; - //~ pixelPerValue = parseInt(plot.width()) / maxvalue; - //~ - //~ $('#'+graph_id+' .yAxis .tickLabel').each(function() { - //~ inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html())); - //~ - //~ $('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3); - //~ i++; - //~ }); - //~ }); - - - - $('#'+graph_id+' .yAxis .tickLabel').each(function() { - label = parseFloat($(this).text()); - text = label.toLocaleString(); - if ( label >= 1000000) - text = text.substring(0,4) + "M"; - else if (label >= 100000) - text = text.substring(0,3) + "K"; - else if (label >= 1000) - text = text.substring(0,2) + "K"; - - $(this).text(text); - }); + //~ $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true }); $('#'+graph_id+' .xAxis .tickLabel') .css('transform', 'rotate(-45deg)') + .css('max-width','100px') .find('div') .css('position', 'relative') .css('top', '+10px') - .css('left', '-20px'); - + .css('left', '-30px'); + if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) + $('#'+graph_id+' .xAxis .tickLabel') + .find('div') + .css('top', '+0px') + .css('left', '-20px'); // Format functions function xFormatter(v, axis) { var format = new Array(); for (i = 0; i < labels_total.length; i++) { var label = labels_total[i][1]; - var shortLabel = reduceText(label, 35); + var shortLabel = reduceText(label, 28); + if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) + shortLabel = reduceText(label, 18); var title = ''; if (label !== shortLabel) { title = label; label = shortLabel; } + format.push([i, - '
' + '
' + label + '
']); } @@ -713,22 +596,13 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, } function yFormatter(v, axis) { - return v; + return '
'+v+'
'; } function lFormatter(v, axis) { - return '
'+v+'
'; + return '
'+v+'
'; } - - // Events - //~ $('#'+graph_id).bind('plothover', function (event, pos, item) { - //~ $('.values_'+graph_id).css('font-weight', ''); - //~ if(item != null) { - //~ index = item.dataIndex; - //~ $('#value_'+index+'_'+graph_id).css('font-weight', 'bold'); - //~ } - //~ }); - + if (water_mark) { set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src')); } @@ -857,7 +731,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, force_integer, separator, separator2, yellow_up, red_up, yellow_inverse, red_inverse, series_suffix_str, dashboard, vconsole, xaxisname,background_color,legend_color) { - + var threshold = true; var thresholded = false; font = font.split("/").pop().split(".").shift(); @@ -1581,7 +1455,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, // Re-calculate the graph height with the legend height if (dashboard || vconsole) { var hDiff = $('#'+graph_id).height() - $('#legend_'+graph_id).height(); - if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ){ + if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ){ } else { $('#'+graph_id).css('height', hDiff); @@ -1649,8 +1523,21 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, if (thresholded) { var zoom_data_threshold = new Array (); + var y_recal = axis_thresholded(threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, + red_threshold, extremes, red_up); + plot = $.plot($('#' + graph_id), data_base, + $.extend(true, {}, options, { + yaxis: { + max: y_recal.max, + min: y_recal.min + }, + xaxis: { + min: plot.getAxes().xaxis.min, + max: plot.getAxes().xaxis.max + } + })); zoom_data_threshold = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, - yellow_threshold, red_threshold, extremes, red_up); + red_threshold, extremes, red_up); plot.setData(zoom_data_threshold); plot.draw(); } @@ -1874,18 +1761,18 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, if (labels[v] == undefined) { return ''; } - return '
'+labels[v]+'
'; + return '
'+labels[v]+'
'; } function yFormatter(v, axis) { axis.datamin = 0; var formatted = number_format(v,force_integer,unit); - return '
'+formatted+'
'; + return '
'+formatted+'
'; } function lFormatter(v, item) { - return '
'+v+'
'; + return '
'+v+'
'; // Prepared to turn series with a checkbox //return '
'+v+'
'; } @@ -1931,28 +1818,32 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, plot = $.plot($('#' + graph_id), data_base, $.extend(true, {}, options, { yaxis: {max: max_draw}, + xaxis: { + min: plot.getAxes().xaxis.min, + max: plot.getAxes().xaxis.max + } })); thresholded = false; } else { var max_draw = plot.getAxes().yaxis.datamax; - if (max_draw < red_threshold || max_draw < yellow_threshold) { - - var maxim_data = (red_threshold < yellow_threshold) ? yellow_threshold : red_threshold - - plot = $.plot($('#' + graph_id), data_base, - $.extend(true, {}, options, { - yaxis: {max: maxim_data + (maxim_data*0.5)}, - })); - } else { - plot = $.plot($('#' + graph_id), data_base, - $.extend(true, {}, options, { - yaxis: {max: plot.getAxes().yaxis.max}, - })); - } + // Recalculate the y axis + var y_recal = axis_thresholded(threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, + red_threshold, extremes, red_up); + plot = $.plot($('#' + graph_id), data_base, + $.extend(true, {}, options, { + yaxis: { + max: y_recal.max, + min: y_recal.min + }, + xaxis: { + min: plot.getAxes().xaxis.min, + max: plot.getAxes().xaxis.max + } + })); datas = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, - yellow_threshold, red_threshold, extremes, red_up); + red_threshold, extremes, red_up); thresholded = true; } @@ -1994,7 +1885,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, $('#legend_'+graph_id).css('margin-bottom', '10px'); parent_height = parseInt( $('#menu_'+graph_id).parent().css('height').split('px')[0]); - adjust_menu(graph_id, plot, parent_height); + adjust_menu(graph_id, plot, parent_height, width); } if (!dashboard) { @@ -2054,6 +1945,7 @@ function set_watermark(graph_id, plot, watermark_src) { if ($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) { down_ticks_height = $('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height').split('px')[0]; } + var left_pos = parseInt(context.canvas.width - 3) - $('#watermark_image_'+graph_id)[0].width; var top_pos = 6; //var top_pos = parseInt(context.canvas.height - down_ticks_height - 10) - $('#watermark_image_'+graph_id)[0].height; @@ -2143,7 +2035,65 @@ function number_format(number, force_integer, unit) { return number + ' ' + shorts[pos] + unit; } -function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshold, +// Recalculate the threshold data depends on warning and critical +function axis_thresholded (threshold_data, y_min, y_max, red_threshold, extremes, red_up) { + + var y = { + min: 0, + max: 0 + }; + + // Default values + var yaxis_resize = { + up: null, + normal_up: 0, + normal_down: 0, + down: null + }; + // Resize the y axis to display all intervals + $.each(threshold_data, function() { + if (/_up/.test(this.id)){ + yaxis_resize['up'] = this.data[0][1]; + } + if (/_down/.test(this.id)){ + if (/critical/.test(this.id)) { + yaxis_resize['down'] = red_threshold; + } else { + yaxis_resize['down'] = extremes[this.id]; + } + } + if (/_normal/.test(this.id)){ + var end; + if (/critical/.test(this.id)) { + end = red_up; + } else { + end = extremes[this.id + '_2']; + } + if (yaxis_resize['normal_up'] < end) yaxis_resize['normal_up'] = end; + if (yaxis_resize['normal_down'] > this.data[0][1]) yaxis_resize['normal_down'] = this.data[0][1]; + } + }); + + // If you need to display a up or a down bar, display 10% of data height + var margin_up_or_down = (y_max - y_min)*0.10; + + // Calculate the new axis + y['max'] = yaxis_resize['normal_up'] > y_max ? yaxis_resize['normal_up'] : y_max; + y['min'] = yaxis_resize['normal_down'] > y_min ? yaxis_resize['normal_down'] : y_min; + if (yaxis_resize['up'] !== null) { + y['max'] = (yaxis_resize['up'] + margin_up_or_down) < y_max + ? y_max + : yaxis_resize['up'] + margin_up_or_down; + } + if (yaxis_resize['down'] !== null) { + y['min'] = (yaxis_resize['down'] - margin_up_or_down) < y_min + ? yaxis_resize['up'] + margin_up_or_down + : y_min; + } + + return y; +} +function add_threshold (data_base, threshold_data, y_min, y_max, red_threshold, extremes, red_up) { var datas = new Array (); @@ -2195,5 +2145,6 @@ function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshol function reduceText (text, maxLength) { if (text.length <= maxLength) return text var firstSlideEnd = parseInt((maxLength - 3) / 2); - return text.substr(0, firstSlideEnd) + '...' + text.substr(-firstSlideEnd - 3); + var str_cut = text.substr(0, firstSlideEnd); + return str_cut + '...' + text.substr(-firstSlideEnd - 3); } diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index d3bf902fd9..417a9dc497 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -205,7 +205,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, // Parent layer $return = "
"; // Set some containers to legend, graph, timestamp tooltip, etc. - $return .= "

"; + $return .= "

"; if (!empty($threshold_data)) { $yellow_up = $threshold_data['yellow_up']; @@ -265,7 +265,9 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, } $return .= html_print_input_hidden('line_width_graph', $config['custom_graph_width'], true); $return .= ""; - $return .= "
"; + $return .= "
"; if ($menu) { $height = 100; } @@ -598,7 +600,7 @@ function flot_custom_pie_chart ($flash_charts, $graph_values, $graph_id = uniqid('graph_'); - $return = "
"; + $return = "
"; if ($water_mark != '') { $return .= ""; diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index c0742e65d4..86ab6bd914 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -172,7 +172,6 @@ function delete_link(source_id, source_module_id, target_id, target_module_id, i init_drag_and_drop(); set_positions_graph(); } - $("#dialog_node_edit").dialog("close"); } }); @@ -219,6 +218,43 @@ function update_fictional_node(id_db_node) { } } +function update_node_name (id_db_node) { + if (enterprise_installed) { + var name = $("input[name='edit_name_node']").val(); + + var params = []; + params.push("update_node_name=1"); + params.push("networkmap_id=" + networkmap_id); + params.push("node_id=" + id_db_node); + params.push("name=" + name); + params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); + + jQuery.ajax ({ + data: params.join ("&"), + dataType: 'json', + type: 'POST', + url: action="ajax.php", + success: function (data) { + if (data['correct']) { + $("#dialog_node_edit").dialog("close"); + + jQuery.each(graph.nodes, function(i, element) { + if (element.id_db == id_db_node) { + graph.nodes[i].text = name; + + $("#id_node_" + i + networkmap_id + " title").html(name); + $("#id_node_" + i + networkmap_id + " tspan").html(name); + } + }); + + draw_elements_graph(); + set_positions_graph(); + } + } + }); + } +} + function change_shape(id_db_node) { if (enterprise_installed) { var shape = $("select[name='shape']").val(); @@ -532,6 +568,9 @@ function update_link(row_index, id_link) { temp_link["status_start"] = "0"; temp_link["status_end"] = "0"; + temp_link["text_start"] = data["text_start"]; + temp_link["text_end"] = data["text_end"]; + $.each(graph.nodes, function(k, node) { if (node['id_agent'] == data['id_db_target']) { temp_link["target"] = graph.nodes[k]; @@ -579,7 +618,7 @@ function add_new_link (new_link) { graph.links.push(new_link); } -function edit_node(data, dblClick) { +function edit_node(data_node, dblClick) { if (enterprise_installed) { var flag_edit_node = true; var edit_node = null @@ -594,7 +633,7 @@ function edit_node(data, dblClick) { edit_node = selection[0].pop(); } else if (dblClick){ - edit_node = d3.select("#id_node_" + data['id'] + networkmap_id); + edit_node = d3.select("#id_node_" + data_node['id'] + networkmap_id); edit_node = edit_node[0][0]; } else { @@ -615,18 +654,22 @@ function edit_node(data, dblClick) { selected_links = get_relations(node_selected); - $("select[name='shape'] option[value='" + data.shape + "']") + $("select[name='shape'] option[value='" + node_selected.shape + "']") .prop("selected", true); $("select[name='shape']").attr("onchange", - "javascript: change_shape(" + data.id_db + ");"); + "javascript: change_shape(" + node_selected.id_db + ");"); $("#node_options-fictional_node_update_button-1 input") - .attr("onclick", "update_fictional_node(" + data.id_db + ");"); + .attr("onclick", "update_fictional_node(" + node_selected.id_db + ");"); + + $("#node_options-node_name-2 input") + .attr("onclick", "update_node_name(" + node_selected.id_db + ");"); - $("#node_details-0-1").html('' + data["text"] + ''); + $("#node_details-0-1").html('' + node_selected["text"] + ''); var params = []; params.push("get_agent_info=1"); - params.push("id_agent=" + data["id_agent"]); + params.push("id_agent=" + node_selected["id_agent"]); params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); + jQuery.ajax ({ data: params.join ("&"), dataType: 'json', @@ -640,75 +683,47 @@ function edit_node(data, dblClick) { $("#node_details-1-1").html(adressess); $("#node_details-2-1").html(data["os"]); $("#node_details-3-1").html(data["group"]); - } - }); - - $("#interface_information").find("tr:gt(0)").remove(); - - var params = []; - params.push("get_interface_info=1"); - params.push("id_agent=" + data["id_agent"]); - params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); - jQuery.ajax ({ - data: params.join ("&"), - dataType: 'json', - type: 'POST', - url: action="ajax.php", - success: function (data) { - if (data.length == 0) { - $("#interface_information").find('tbody') - .append($('').html("

It has no interface to display

")); - } - else { - jQuery.each(data, function(j, interface) { - $("#interface_information").find('tbody') - .append($('') - .append($('') - .html(interface['name']) - ) - .append($('') - .html(interface['status']) - ) - .append($('') - .html(interface['graph']) - ) - .append($('') - .html(interface['ip']) - ) - .append($('') - .html(interface['mac']) - ) - ); - }); - } + + $('[aria-describedby=dialog_node_edit]').css({'top':'200px'}); + $('#foot').css({'top':parseInt($("[aria-describedby=dialog_node_edit]").css('height')+$("[aria-describedby=dialog_node_edit]").css('top')),'position':'relative'}); + + get_interface_data_to_table(node_selected, selected_links); } }); $("#dialog_node_edit" ) .dialog( "option", "title", - dialog_node_edit_title.replace("%s", data.text)); + dialog_node_edit_title.replace("%s", node_selected.text)); $("#dialog_node_edit").dialog("open"); - if (data.id_agent == -2) { + if (node_selected.id_agent == undefined || node_selected.id_agent == -2) { //Fictional node $("#node_options-fictional_node_name") .css("display", ""); $("input[name='edit_name_fictional_node']") - .val(data.text); + .val(node_selected.text); $("#node_options-fictional_node_networkmap_link") .css("display", ""); $("#edit_networkmap_to_link") - .val(data.networkmap_id); + .val(node_selected.networkmap_id); $("#node_options-fictional_node_update_button") .css("display", ""); + $("#node_options-node_name") + .css("display", "none"); + $("#node_options-node_update_button") + .css("display", "none"); } else { + $("input[name='edit_name_node']") + .val(node_selected.text); $("#node_options-fictional_node_name") .css("display", "none"); $("#node_options-fictional_node_networkmap_link") .css("display", "none"); $("#node_options-fictional_node_update_button") .css("display", "none"); + $("#node_options-node_name") + .css("display", ""); } //Clean @@ -716,124 +731,160 @@ function edit_node(data, dblClick) { //Show the no relations $("#relations_table-loading").css('display', 'none'); $("#relations_table-no_relations").css('display', ''); - - - jQuery.each(selected_links, function(i, link_each) { - - $("#relations_table-no_relations").css('display', 'none'); - $("#relations_table-loading").css('display', ''); - - var template_relation_row = $("#relations_table-template_row") - .clone(); - - $(template_relation_row).css('display', ''); - $(template_relation_row).attr('class', 'relation_link_row'); - - $("select[name='interface_source']", template_relation_row) - .attr('name', "interface_source_" + i) - .attr('id', "interface_source_" + i + networkmap_id); - $("select[name='interface_target']", template_relation_row) - .attr('name', "interface_target_" + i) - .attr('id', "interface_target_" + i + networkmap_id); - $(".edit_icon_progress", template_relation_row) - .attr('class', "edit_icon_progress_" + i); - $(".edit_icon", template_relation_row) - .attr('class', "edit_icon_" + i); - $(".edit_icon_correct", template_relation_row) - .attr('class', "edit_icon_correct_" + i); - $(".edit_icon_fail", template_relation_row) - .attr('class', "edit_icon_fail_" + i); - $(".edit_icon_link", template_relation_row) - .attr('class', "edit_icon_link_" + i) - .click(function() { - update_link(i, link_each.id_db); - } - ); - - var params = []; - params.push("get_intefaces=1"); - params.push("id_agent=" + link_each.source.id_agent); - params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); - - jQuery.ajax ({ - data: params.join ("&"), - dataType: 'json', - type: 'POST', - url: action="ajax.php", - success: function (data) { - if (data['correct']) { - $("select[name='interface_source_" + i + "']", template_relation_row).empty(); - $("select[name='interface_source_" + i + "']", template_relation_row).append(''); - jQuery.each(data['interfaces'], function(j, interface) { - - $("select[name='interface_source_" + i + "']", template_relation_row) - .append($("'); - jQuery.each(data['interfaces'], function(j, interface) { - $("select[name='interface_target_" + i + "']", template_relation_row) - .append($("'); + + $("select[name='interface_source_" + i + "']", template_relation_row).empty(); + $("select[name='interface_source_" + i + "']", template_relation_row).append(''); + jQuery.each(data['target_interfaces'], function(j, interface) { + $("select[name='interface_target_" + i + "']", template_relation_row) + .append($("