diff --git a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/ConnectionCustomToast.java b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/ConnectionCustomToast.java index 8540370a2b..5026d96d98 100644 --- a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/ConnectionCustomToast.java +++ b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/ConnectionCustomToast.java @@ -2,7 +2,7 @@ Pandora FMS - http://pandorafms.com ================================================== -Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +Copyright (c) 2005-2023 Pandora FMS Please see http://pandorafms.org for full contribution list This program is free software; you can redistribute it and/or diff --git a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Help.java b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Help.java index 32d73a7fa8..60708495c1 100644 --- a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Help.java +++ b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Help.java @@ -2,7 +2,7 @@ Pandora FMS - http://pandorafms.com ================================================== -Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +Copyright (c) 2005-2023 Pandora FMS Please see http://pandorafms.org for full contribution list This program is free software; you can redistribute it and/or diff --git a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Options.java b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Options.java index 2cd8542fa0..782448ace6 100644 --- a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Options.java +++ b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/Options.java @@ -2,7 +2,7 @@ Pandora FMS - http://pandorafms.com ================================================== -Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +Copyright (c) 2005-2023 Pandora FMS Please see http://pandorafms.org for full contribution list This program is free software; you can redistribute it and/or diff --git a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/PandoraWebView.java b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/PandoraWebView.java index 4c566ff0f4..5b03bd03d3 100644 --- a/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/PandoraWebView.java +++ b/extras/PandoraFMS_android_console/src/pandorafms/pandorafmsandroidconsole/PandoraWebView.java @@ -2,7 +2,7 @@ Pandora FMS - http://pandorafms.com ================================================== -Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +Copyright (c) 2005-2023 Pandora FMS Please see http://pandorafms.org for full contribution list This program is free software; you can redistribute it and/or diff --git a/extras/android-event-viewer/app/src/main/AndroidManifest.xml b/extras/android-event-viewer/app/src/main/AndroidManifest.xml index 56e27364eb..1678445c33 100644 --- a/extras/android-event-viewer/app/src/main/AndroidManifest.xml +++ b/extras/android-event-viewer/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ @@ -904,6 +917,44 @@ echo sprintf('
', $menuTypeClass); $("#agent_access").css("display",""); }); + $("#welcome-icon-header").click(function () { + if (!$('#welcome_modal_window').length){ + $(document.body).append('
'); + $(document.body).append( $('').attr('href', 'include/styles/new_installation_welcome_window.css') ); + } + // Clean DOM. + load_modal({ + target: $('#welcome_modal_window'), + url: '', + modal: { + title: "", + cancel: '', + ok: '' + }, + onshow: { + page: 'include/ajax/welcome_window', + method: 'loadWelcomeWindow', + }, + oncancel: { + page: 'include/ajax/welcome_window', + title: "", + method: 'cancelWelcome', + confirm: function (fn) { + confirmDialog({ + title: '', + message: '', + ok: '', + cancel: '', + onAccept: function() { + // Continue execution. + fn(); + } + }) + } + } + }); + }); + // Feedback. $("#feedback-header").click(function () { diff --git a/pandora_console/general/help_feedback.php b/pandora_console/general/help_feedback.php index 97d161ea61..0e1c5852ba 100644 --- a/pandora_console/general/help_feedback.php +++ b/pandora_console/general/help_feedback.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/general/last_message.php b/pandora_console/general/last_message.php index 862d3f8076..e2f6f2d5aa 100644 --- a/pandora_console/general/last_message.php +++ b/pandora_console/general/last_message.php @@ -1,9 +1,9 @@ '; echo ''; - echo ''.html_print_image( + echo ''.html_print_image( 'images/enterprise_version.png', true, [ @@ -72,7 +72,7 @@ echo '
'; - echo ''.__('Enterprise version').''; + echo ''.__('Enterprise version').''; echo ''; echo ''; diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index 1081952031..d3d9c7e686 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -1,9 +1,9 @@ '; const id = table_hover[0].id; const classes = $(`#${id}`).attr('class'); - if (id === 'icon_about') { + if (id === 'icon_about' || id === 'icon_about_operation') { return; } diff --git a/pandora_console/general/maintenance.php b/pandora_console/general/maintenance.php index 934c6df7cc..d4fa881ebf 100644 --- a/pandora_console/general/maintenance.php +++ b/pandora_console/general/maintenance.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/general/news_dialog.php b/pandora_console/general/news_dialog.php index f44eb97faa..1cbf9dea68 100644 --- a/pandora_console/general/news_dialog.php +++ b/pandora_console/general/news_dialog.php @@ -1,9 +1,9 @@ run(); +if (check_acl($config['id_user'], 0, 'AW')) { + $welcome = !$initial; + try { + $welcome_window = new WelcomeWindow($welcome); + if ($welcome_window !== null) { + $welcome_window->run(); + } + } catch (Exception $e) { + $welcome = false; } -} catch (Exception $e) { - $welcome = false; } try { if (isset($_SESSION['showed_tips_window']) === false) { $tips_window = new TipsWindow(); if ($tips_window !== null) { - $tips_window->run(); + $tips_window->run(); } } } catch (Exception $e) { diff --git a/pandora_console/general/reporting_console_node.php b/pandora_console/general/reporting_console_node.php index d566f14599..28603913d1 100644 --- a/pandora_console/general/reporting_console_node.php +++ b/pandora_console/general/reporting_console_node.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/general/sap_view.php b/pandora_console/general/sap_view.php index 1adb826e59..a03afcf75d 100644 --- a/pandora_console/general/sap_view.php +++ b/pandora_console/general/sap_view.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/general/ui/agents_list.php b/pandora_console/general/ui/agents_list.php index deaafe1bc8..6e423da67b 100644 --- a/pandora_console/general/ui/agents_list.php +++ b/pandora_console/general/ui/agents_list.php @@ -1,9 +1,9 @@ 'Pandora FMS Enterprise', - 'message' => "

This feature is not included on the Open Source version. Please visit our website to learn more about the advanced features of Pandora FMS Enterprise edition

", + 'message' => "

This feature is not included on the Open Source version. Please visit our website to learn more about the advanced features of Pandora FMS Enterprise edition

", 'no_close' => 1, ]; diff --git a/pandora_console/godmode/agentes/agent_incidents.php b/pandora_console/godmode/agentes/agent_incidents.php index e7e442e7e3..ba43f1799c 100644 --- a/pandora_console/godmode/agentes/agent_incidents.php +++ b/pandora_console/godmode/agentes/agent_incidents.php @@ -1,9 +1,9 @@ data['parent_agent'][] = html_print_label_input_block( - __('Parent'), + __('Agent parent'), ui_print_agent_autocomplete_input($paramsParentAgent) ); @@ -965,7 +965,7 @@ foreach ($fields as $field) { true ); } else if ($field['is_link_enabled']) { - list($link_text, $link_url) = json_decode($custom_value, true); + list($link_text, $link_url) = json_decode(io_safe_output($custom_value), true); if (json_last_error() !== JSON_ERROR_NONE) { $link_text = ''; @@ -1205,15 +1205,30 @@ ui_require_jquery_file('bgiframe'); $("#cascade_protection_module").attr("disabled", 'disabled'); } - $("#checkbox-cascade_protection").change(function () { - var checked = $("#checkbox-cascade_protection").is(":checked"); - - if (checked) { + $("#text-id_parent").change(function(){ + const parent = $("#text-id_parent").val(); + if (parent != '') { + $("#checkbox-cascade_protection").prop('checked', true); $("#cascade_protection_module").removeAttr("disabled"); } else { $("#cascade_protection_module").val(0); $("#cascade_protection_module").attr("disabled", 'disabled'); + $("#text-id_parent").removeAttr("required"); + $("#cascade_protection_module").empty(); + $("#checkbox-cascade_protection").prop('checked', false); + } + }); + + $("#checkbox-cascade_protection").change(function () { + var checked = $("#checkbox-cascade_protection").is(":checked"); if (checked) { + $("#cascade_protection_module").removeAttr("disabled"); + $("#text-id_parent").attr("required", "required"); + } + else { + $("#cascade_protection_module").val(0); + $("#cascade_protection_module").attr("disabled", 'disabled'); + $("#text-id_parent").removeAttr("required"); } }); diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 3e265ab8fc..9c080fcf3f 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -80,7 +80,7 @@ if (isset($_POST['template_id']) === true) { $values = [ 'id_agente' => $id_agente, 'id_tipo_modulo' => $row2['type'], - 'descripcion' => __('Created by template ').$name_template.' . '.$row2['description'], + 'descripcion' => $row2['description'], 'max' => $row2['max'], 'min' => $row2['min'], 'module_interval' => $row2['module_interval'], diff --git a/pandora_console/godmode/agentes/agent_wizard.php b/pandora_console/godmode/agentes/agent_wizard.php index aaac092355..c58963508c 100644 --- a/pandora_console/godmode/agentes/agent_wizard.php +++ b/pandora_console/godmode/agentes/agent_wizard.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index c7378ab3a6..b07fb5ca4f 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -460,6 +460,18 @@ if ($id_agente) { $templatetab['active'] = ($tab === 'template'); + // Policy tab. + $policyTab['text'] = html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=policy&id_agente='.$id_agente, + 'image' => 'images/policy@svg.svg', + 'title' => __('Manage policy'), + ], + true + ); + + $policyTab['active'] = ($tab === 'policy'); + // Inventory. $inventorytab['text'] = ''.html_print_image( 'images/hardware-software-component@svg.svg', @@ -638,6 +650,7 @@ if ($id_agente) { 'template' => $templatetab, 'inventory' => $inventorytab, 'pluginstab' => $pluginstab, + 'policy' => (enterprise_installed() === true) ? $policyTab : '', 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, @@ -654,11 +667,11 @@ if ($id_agente) { 'template' => $templatetab, 'inventory' => $inventorytab, 'pluginstab' => $pluginstab, + 'policy' => (enterprise_installed() === true) ? $policyTab : '', 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, 'agent_wizard' => $agent_wizard, - ]; } @@ -725,6 +738,11 @@ if ($id_agente) { $tab_name = __('Inventory'); break; + case 'policy': + $help_header = 'policy_tab'; + $tab_name = __('Policies'); + break; + case 'plugins': $help_header = 'plugins_tab'; $tab_name = __('Agent plugins'); @@ -2428,6 +2446,10 @@ switch ($tab) { include 'inventory_manager.php'; break; + case 'policy': + enterprise_include('operation/agentes/policy_manager.php'); + break; + default: if (enterprise_hook('switch_agent_tab', [$tab])) { // This will make sure that blank pages will have at least some diff --git a/pandora_console/godmode/agentes/configure_field.php b/pandora_console/godmode/agentes/configure_field.php index 8a3a6b2f45..839040cb00 100755 --- a/pandora_console/godmode/agentes/configure_field.php +++ b/pandora_console/godmode/agentes/configure_field.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index aed5bc69a3..25b06e2f5a 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/agentes/inventory_manager.php b/pandora_console/godmode/agentes/inventory_manager.php index adadc8dd50..3f27c3a6b3 100644 --- a/pandora_console/godmode/agentes/inventory_manager.php +++ b/pandora_console/godmode/agentes/inventory_manager.php @@ -5,7 +5,7 @@ // |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| // // ============================================================================ -// Copyright (c) 2007-2021 Artica Soluciones Tecnologicas, http://www.artica.es +// Copyright (c) 2007-2023 Pandora FMS, http://www.pandorafms.com // This code is NOT free software. This code is NOT licenced under GPL2 licence // You cannnot redistribute it without written permission of copyright holder. // ============================================================================ diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 0b27809299..9021514178 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -929,7 +929,7 @@ if ($agents !== false) { [ 'href' => ui_get_full_url( sprintf( - 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&%s_agent=%s&group_id=%s&recursion=%s&search=%s&offset=%s&sort_field=%s&sort=%s&disabled=%s', + 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&%s_agent=%s&group_id=%s&recursion=%s&search=%s&offset=%s&sort_field=%s&sort=%s&disabled=%s&os=%s', $agentDisableEnableAction, $agent['id_agente'], $ag_group, @@ -938,7 +938,8 @@ if ($agents !== false) { '', $sortField, $sort, - $disabled + $disabled, + $os ) ), 'onClick' => ($agent['id_os'] === CLUSTER_OS_ID) ? sprintf('if (!confirm(\'%s\')) return false', $agentDisableEnableCaption) : 'return true;', @@ -1071,16 +1072,20 @@ if ((bool) check_acl($config['id_user'], 0, 'AW') === true) { function () { $(".actions", this).css ("visibility", "hidden"); }); - + $("#ag_group").click ( function () { $(this).css ("width", "auto"); $(this).css ("min-width", "100px"); }); - + $("#ag_group").blur (function () { $(this).css ("width", "100px"); }); - + + var show_deploy_agent = ""; + if (show_deploy_agent !== '0'){ + $('#button-modal_deploy_agent').click(); + } }); diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 1c6126467f..5c21fa71a0 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -47,8 +47,74 @@ if (isset($policy_page) === false) { $policy_page = false; } -$checked = (bool) get_parameter('checked'); +$checked = (bool) get_parameter('status_hierachy_mode'); +$status_hierachy_mode = (bool) get_parameter('status_hierachy_mode'); $sec2 = (string) get_parameter('sec2'); +// Table for filter bar. +$filterTable = new stdClass(); +$filterTable->class = 'filter-table-adv w100p'; +$filterTable->size[0] = '20%'; +$filterTable->size[1] = '20%'; +$filterTable->size[2] = '20%'; +$filterTable->size[3] = '20%'; +$filterTable->size[4] = '20%'; +$filterTable->data = []; +$filterTable->cellstyle[0][0] = 'width:0'; +$filterTable->data[0][0] = __('Search'); +$filterTable->data[1][0] .= html_print_input_text( + 'search_string', + $search_string, + '', + 30, + 255, + true, + false, + false, + '', + '' +); + +$filterTable->data[0][0] .= html_print_input_hidden('search', 1, true); + +if ((bool) $policy_page === false) { + $filterTable->data[0][1] = __('Show in hierachy mode'); + $filterTable->data[1][1] = html_print_checkbox_switch( + 'status_hierachy_mode', + ((string) $checked), + ((string) $checked), + true, + false, + 'onChange=change_mod_filter();' + ); +} + +$filterTable->data[1][2] = html_print_submit_button( + __('Filter'), + 'filter', + false, + [ + 'icon' => 'search', + 'class' => 'float-right', + 'mode' => 'secondary mini', + ], + true +); + +// Print filter table. +echo '
'; +ui_toggle( + html_print_table($filterTable, true).'
', + ''.__('Filter').'', + __('Filter'), + 'filter', + true, + false, + '', + 'white-box-content no_border', + 'filter-datatable-main box-flat white_table_graph fixed_filter_bar' +); +echo ''; + if (isset($id_agente) === false) { return; @@ -1215,14 +1281,17 @@ html_print_div( if (/checked/.test(window.location)) { var url = window.location.toString(); if (checked) { - window.location = url.replace("checked=false", "checked=true"); + //window.location = url.replace("checked=0", "checked=1"); + $("#checkbox-status_hierachy_mode").val('1'); } else { - window.location = url.replace("checked=true", "checked=false"); + //window.location = url.replace("checked=1", "checked=0"); + $("#checkbox-status_hierachy_mode").val('0'); } } else { - window.location = window.location + "&checked=true"; + //window.location = window.location + "&checked=1"; + $("#checkbox-status_hierachy_mode").val('1'); } } diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 97531e3b12..42aa286c8a 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -10,13 +10,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 0ceeca6881..d63dff4035 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_categories.php'; require_once $config['homedir'].'/include/graphs/functions_d3.php'; use PandoraFMS\Agent; +use Psr\Log\NullLogger; include_javascript_d3(); @@ -950,6 +951,15 @@ $table_advanced->data['tags_module_parent'][0] .= html_print_div( if ((bool) $in_policies_page === false) { // Cannot select the current module to be itself parent. + if ($id_agent_module !== 0) { + $module_parent_filter['tagente_modulo.id_agente_modulo'] = '<>'.$id_agent_module; + $array_parent_module_id = []; + get_agent_module_childs($array_parent_module_id, $id_agent_module, $id_agente); + } else { + $module_parent_filter = []; + $array_parent_module_id = []; + } + $module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => '<>'.$id_agent_module] : []; $table_advanced->data['caption_tags_module_parent'][1] = __('Module parent'); // TODO. Review cause dont know not works. @@ -965,6 +975,13 @@ if ((bool) $in_policies_page === false) { false, $module_parent_filter ); + + if (empty($array_parent_module_id) === false) { + foreach ($array_parent_module_id as $key => $value) { + unset($modules_can_be_parent[$value]); + } + } + // If the user cannot have access to parent module, only print the name. if ((int) $parent_module_id !== 0 && in_array($parent_module_id, array_keys($modules_can_be_parent)) === true diff --git a/pandora_console/godmode/agentes/module_manager_editor_data.php b/pandora_console/godmode/agentes/module_manager_editor_data.php index 65bfb6c5ac..63f6a94943 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_data.php +++ b/pandora_console/godmode/agentes/module_manager_editor_data.php @@ -1,10 +1,10 @@ = 15 && $id_module_type <= 18) ? $snmp_version : 0, + ($id_module_type >= 15 && $id_module_type <= 18) ? $snmp_version : '2c', '', '', '', @@ -725,9 +720,13 @@ $(document).ready (function () { }); var custom_ip_target = ""; - if(custom_ip_target == ''){ + var ip_target = ""; + if(ip_target === 'custom'){ + $("#text-custom_ip_target").show(); + } else { $("#text-custom_ip_target").hide(); } + $('#ip_target').change(function() { if($(this).val() === 'custom') { $("#text-custom_ip_target").show(); diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 0ecf2a710b..970a2c4d9f 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -1,9 +1,9 @@ $p) { } $(document).ready(function () { - changePluginSelect(); + if ($("#id_plugin").val() === 0) { + changePluginSelect(); + } }); diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 92f98c808b..eb85a05618 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/agentes/module_manager_editor_web.php b/pandora_console/godmode/agentes/module_manager_editor_web.php index 4e97ffaa57..727e16d5bf 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_web.php +++ b/pandora_console/godmode/agentes/module_manager_editor_web.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -113,7 +113,8 @@ if ($id_policy_module > 0) { $plugin_parameter_split = explode(' ', $plugin_parameter); $plugin_parameter_final_split = ''; -foreach ($plugin_parameter_split as $key => $value) { +$new_plugin_parameter_split = array_filter($plugin_parameter_split, 'strlen'); +foreach ($new_plugin_parameter_split as $key => $value) { if (strpos($value, 'http_auth_user') === false && strpos($value, 'http_auth_pass') === false) { $plugin_parameter_final_split .= $value.' '; } @@ -317,8 +318,7 @@ foreach ($texts as $code => $text) { return; } - $(plugin_parameter).val( - 'task_begin\ncookie 0\nresource 0\ntask_end'); + $(plugin_parameter).val('task_begin\ncookie 0\nresource 0\ntask_end'); $('#button-btn_loadbasic').attr('disabled', 'disabled'); diff --git a/pandora_console/godmode/agentes/module_manager_editor_wmi.php b/pandora_console/godmode/agentes/module_manager_editor_wmi.php index 5af47b915b..c01490b7ab 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_wmi.php +++ b/pandora_console/godmode/agentes/module_manager_editor_wmi.php @@ -1,9 +1,9 @@ $(document).ready (function () { var custom_ip_target = ""; - if(custom_ip_target == ''){ + var ip_target = ""; + if(ip_target === 'custom'){ + $("#text-custom_ip_target").show(); + } else { $("#text-custom_ip_target").hide(); } + $('#ip_target').change(function() { if($(this).val() == 'custom') { $("#text-custom_ip_target").show(); diff --git a/pandora_console/godmode/agentes/pandora_networkmap_empty.editor.php b/pandora_console/godmode/agentes/pandora_networkmap_empty.editor.php index f2a8b8df64..c706a6fb09 100644 --- a/pandora_console/godmode/agentes/pandora_networkmap_empty.editor.php +++ b/pandora_console/godmode/agentes/pandora_networkmap_empty.editor.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index 2a991cac20..79516b3670 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -10,13 +10,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/agentes/planned_downtime.export_csv.php b/pandora_console/godmode/agentes/planned_downtime.export_csv.php index e0331d7895..2580b45b00 100644 --- a/pandora_console/godmode/agentes/planned_downtime.export_csv.php +++ b/pandora_console/godmode/agentes/planned_downtime.export_csv.php @@ -1,9 +1,9 @@ 'agent_modules_affected_planned_downtime', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => 'godmode/agentes/planned_downtime.list', @@ -835,7 +835,7 @@ if ($downtimes === false && $filter_performed === false) { // If user have writting permissions. if (in_array($downtime['id_group'], $groupsAD) === true) { // Stop button. - if ($downtime['type_execution'] === 'once' + if (($downtime['type_execution'] === 'once' || $downtime['type_execution'] === 'periodically') && (int) $downtime['executed'] === 1 ) { if ((bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') === true diff --git a/pandora_console/godmode/agentes/status_monitor_custom_fields.php b/pandora_console/godmode/agentes/status_monitor_custom_fields.php index 2dfb79185d..4cc84d8570 100644 --- a/pandora_console/godmode/agentes/status_monitor_custom_fields.php +++ b/pandora_console/godmode/agentes/status_monitor_custom_fields.php @@ -1,9 +1,9 @@ 'section_table_title', 'con $titledata[0] = html_print_div(['class' => 'flex-row-center', 'content' => implode('', $generalTitleContent) ], true); $table->data['general_title'] = $titledata; $table->data[0][0] = ''.__('Fields available').''; -$table->data[1][0] = html_print_select($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px'); +$table->data[1][0] = html_print_select($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px; height: auto'); $table->data[1][1] = '
'.html_print_image( 'images/darrowright.png', true, @@ -220,7 +220,7 @@ $table->data[1][2] = html_print_select( false, '', false, - 'width: 300px' + 'width: 300px; height: auto' ); echo '
'; @@ -284,7 +284,7 @@ $(document).ready (function () { } }); - $("#submit-upd_button").click(function () { + $("#button-update_button").click(function () { $("#fields_selected").find("option[value='0']").remove(); $('#fields_selected option').map(function() { $(this).prop('selected', true); diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 98b8daa39e..97a492809e 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -333,7 +333,7 @@ $show_table_filter .= ui_toggle( __('Search'), 'search', true, - false, + true, '', 'white-box-content no_border', 'filter-datatable-main box-flat white_table_graph fixed_filter_bar ' diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 271ae79784..771a842cc3 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -1,9 +1,9 @@ size = []; $table->style[0] = 'width: 50%'; $table->style[1] = 'width: 50%'; -// Add an agent selector -if (! $id_agente) { +$modules = []; + +if (is_metaconsole() === true) { $params = []; $params['return'] = true; $params['show_helptip'] = true; $params['input_name'] = 'id_agent'; $params['selectbox_id'] = 'id_agent_module'; $params['javascript_is_function_select'] = true; - $params['metaconsole_enabled'] = false; + $params['metaconsole_enabled'] = true; $params['use_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true; + $params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax'; + $table->data[0][0] = html_print_label_input_block( __('Agent'), - ui_print_agent_autocomplete_input($params) + '
'.ui_print_agent_autocomplete_input($params).'
' ); -} +} else { + // Add an agent selector. + if (! $id_agente) { + $params = []; + $params['return'] = true; + $params['show_helptip'] = true; + $params['input_name'] = 'id_agent'; + $params['selectbox_id'] = 'id_agent_module'; + $params['javascript_is_function_select'] = true; + $params['metaconsole_enabled'] = false; + $params['use_hidden_input_idagent'] = true; + $params['print_hidden_input_idagent'] = true; + $table->data[0][0] = html_print_label_input_block( + __('Agent'), + ui_print_agent_autocomplete_input($params) + ); + } -$modules = []; - -if ($id_agente) { - $modules = agents_get_modules($id_agente, false, ['delete_pending' => 0]); + if ($id_agente) { + $modules = agents_get_modules($id_agente, false, ['delete_pending' => 0]); + } } $table->data[0][1] = html_print_label_input_block( @@ -319,7 +337,8 @@ $(document).ready (function () { jQuery.post ( + "ajax.php", {"page" : "operation/agentes/estado_agente", "get_agent_module_last_value" : 1, - "id_agent_module" : this.value + "id_agent_module" : this.value, + "server_name" : $('#text-id_agent').val(), }, function (data, status) { if (data === false) { @@ -338,5 +357,4 @@ $(document).ready (function () { ); }); }); -/* ]]> */ diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 84707c193d..3dd8a831f9 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -9,12 +9,12 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ========================================================== - * Copyright (c) 2005-2022 Artica Soluciones Tecnol贸gicas S.L + * Copyright (c) 2005-2023 Pandora FMS * This code is NOT free software. This code is NOT licenced under GPL2 licence * You cannot redistribute it without written permission of copyright holder. * ============================================================================ @@ -1311,10 +1311,10 @@ function show_display_update_action(id_module_action, alert_id, alert_id_agent_m }, open: function() { $(`#update_action-div-${alert_id}`).css('overflow', 'hidden'); - $(`#action_select_ajax-${alert_id}`).select2({ - tags: true, - dropdownParent: $(`#update_action-div-${alert_id}`) - }); + //$(`#action_select_ajax-${alert_id}`).select2({ + // tags: true, + // dropdownParent: $(`#update_action-div-${alert_id}`) + //}); }, width: 600, height: 350 diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index ce42dd1675..17669ab248 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -1,9 +1,9 @@ window.location.assign("index.php?sec=estado&sec2=operation/agentes/alerts_status")'; + } } if ($delete_alert) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_alert_agent_module = (int) get_parameter('id_alert'); $temp = db_get_row('talert_template_modules', 'id', $id_alert_agent_module); @@ -241,9 +273,27 @@ if ($delete_alert) { '', true ); + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($add_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_action = (int) get_parameter('action_select'); $id_alert_module = (int) get_parameter('id_alert_module'); $fires_min = (int) get_parameter('fires_min'); @@ -280,9 +330,28 @@ if ($add_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($update_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $alert_id = (int) get_parameter('alert_id'); $id_action = (int) get_parameter('action_select_ajax-'.$alert_id); $id_module_action = (int) get_parameter('id_module_action_ajax'); @@ -321,9 +390,28 @@ if ($update_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($delete_action) { + if (is_metaconsole()) { + if (enterprise_include_once('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { + $server_name = explode(' ', io_safe_output(get_parameter('id_agent')))[0]; + $connection = metaconsole_get_connection($server_name); + if (metaconsole_load_external_db($connection) !== NOERR) { + echo json_encode(false); + // Restore db connection. + metaconsole_restore_db(); + return; + } + } + } + $id_action = (int) get_parameter('id_action'); $id_alert = (int) get_parameter('id_alert'); @@ -348,6 +436,12 @@ if ($delete_action) { '', true ); + + if (is_metaconsole()) { + // Restore db connection. + metaconsole_restore_db(); + echo ''; + } } if ($enable_alert) { diff --git a/pandora_console/godmode/alerts/alert_special_days.php b/pandora_console/godmode/alerts/alert_special_days.php index 3a8957293b..0f7685dfb8 100644 --- a/pandora_console/godmode/alerts/alert_special_days.php +++ b/pandora_console/godmode/alerts/alert_special_days.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index ba3bdeac1d..003ec45d03 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -1,9 +1,9 @@ false, 'search_string' => $search_string, 'search_type' => $search_type, + 'alert_flag' => true, ], true, false diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index e8b906b220..1a3e991fde 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -318,54 +318,59 @@ if (count($actions) == 1 && isset($actions[0])) { } else { foreach ($actions as $kaction => $action) { $table->data[$kaction][0] = $action['name']; - if ((int) $kaction === 0) { - $table->data[$kaction][0] .= ui_print_help_tip( - __('The default actions will be executed every time that the alert is fired and no other action is executed'), - true - ); - } - - foreach ($action['escalation'] as $k => $v) { - if ($v > 0) { - $table->data[$kaction][$k] = html_print_image( - 'images/tick.png', - true, - ['class' => 'invert_filter'] - ); + if (count($action['escalation']) > 1) { + foreach ($action['escalation'] as $k => $v) { + $table->head[$k] = '#'.$k; + if ($v > 0) { + $table->data[$kaction][$k] .= html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); + } else { + $table->data[$kaction][$k] = html_print_image( + 'images/blade.png', + true + ); + } + } + } else { + $table->head[1] = __('Every time that the alert is fired'); + if (count($action['escalation']) > 0) { + if ($action['escalation'][0] > 0) { + $table->data[$kaction][1] .= html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); + } else { + $table->data[$kaction][1] = html_print_image( + 'images/blade.png', + true + ); + } } else { - $table->data[$kaction][$k] = html_print_image( + $table->data[$kaction][1] = html_print_image( 'images/blade.png', true ); } - - if (count($table->head) <= count($action['escalation'])) { - if ($k == count($action['escalation'])) { - if ($k == 1) { - $table->head[$k] = __('Every time that the alert is fired'); - } else { - $table->head[$k] = '>#'.($k - 1); - } - } else { - $table->head[$k] = '#'.$k; - } - } } $action_threshold = ($action['module_action_threshold'] > 0) ? $action['module_action_threshold'] : $action['action_threshold']; if ($action_threshold == 0) { - $table->data[$kaction][($k + 1)] = __('No'); + $table->data[$kaction][] = __('No'); } else { - $table->data[$kaction][($k + 1)] = human_time_description_raw( + $table->data[$kaction][] = human_time_description_raw( $action_threshold, true, 'tiny' ); } - - $table->head[($k + 1)] = __('Threshold'); } + + $table->head[] = __('Threshold'); } html_print_table($table); diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index fb654828fe..033171953b 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -1,9 +1,9 @@ $previous_name, ]; - $result = alerts_update_alert_template($id, $values); + if ($name_check === false) { + $result = alerts_update_alert_template($id, $values); + } else { + ui_print_warning_message(__('Another template with the same name already exists')); + $result = false; + } } else if ($step == 2) { $schedule = io_safe_output(get_parameter('schedule', [])); json_decode($schedule, true); @@ -487,6 +500,13 @@ $wizard_level = 'nowizard'; if ($create_template) { $name = (string) get_parameter('name'); + $name = trim(io_safe_output($name)); + if (strlen($name) === 0) { + ui_print_warning_message(__('You can\'t named a template with spaces')); + } + + $name = io_safe_input($name); + $description = (string) get_parameter('description'); $type = (string) get_parameter('type', 'critical'); $value = (string) get_parameter('value'); @@ -515,10 +535,11 @@ if ($create_template) { $values['field3_recovery'] = ' '; } - if (!$name_check) { + if ($name_check === false) { $result = alerts_create_alert_template($name, $type, $values); } else { - $result = ''; + ui_print_warning_message(__('Another template with the same name already exists')); + $result = false; } if ($result) { diff --git a/pandora_console/godmode/audit_log.php b/pandora_console/godmode/audit_log.php index fbded7819e..5f7dd89b73 100644 --- a/pandora_console/godmode/audit_log.php +++ b/pandora_console/godmode/audit_log.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/audit_log_csv.php b/pandora_console/godmode/audit_log_csv.php index 7c03d632df..a59f0eef95 100644 --- a/pandora_console/godmode/audit_log_csv.php +++ b/pandora_console/godmode/audit_log_csv.php @@ -5,7 +5,7 @@ // |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| // // ============================================================================ -// Copyright (c) 2007-2021 Artica Soluciones Tecnologicas, http://www.artica.es +// Copyright (c) 2007-2023 Pandora FMS, http://www.pandorafms.com // This code is NOT free software. This code is NOT licenced under GPL2 licence // You cannnot redistribute it without written permission of copyright holder. // ============================================================================ diff --git a/pandora_console/godmode/category/category.php b/pandora_console/godmode/category/category.php index 935d2c1d5d..46095b6efb 100755 --- a/pandora_console/godmode/category/category.php +++ b/pandora_console/godmode/category/category.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -184,7 +184,7 @@ if (empty($result) === false) { ] ).'
  '; $data[1] .= ''.html_print_image( - 'images/delet.svg', + 'images/delete.svg', true, [ 'title' => __('Delete'), diff --git a/pandora_console/godmode/category/edit_category.php b/pandora_console/godmode/category/edit_category.php index 5c30766006..e69f9f1ec6 100755 --- a/pandora_console/godmode/category/edit_category.php +++ b/pandora_console/godmode/category/edit_category.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/consoles/consoles.php b/pandora_console/godmode/consoles/consoles.php index 0158dfe14c..44016e0edf 100644 --- a/pandora_console/godmode/consoles/consoles.php +++ b/pandora_console/godmode/consoles/consoles.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/db/db_main.php b/pandora_console/godmode/db/db_main.php index 79a6c9eba7..9979b2c224 100644 --- a/pandora_console/godmode/db/db_main.php +++ b/pandora_console/godmode/db/db_main.php @@ -1,9 +1,9 @@ $available) { } $table->data[0][0] = ''.__('Fields available').''; -$table->data[1][0] = html_print_select($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px'); +$table->data[1][0] = html_print_select($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px; height: auto'); $table->data[1][1] = ''.html_print_image( 'images/arrow@svg.svg', true, @@ -160,7 +160,7 @@ $table->data[1][2] = '
'.html_print_select( false, '', false, - 'width: 300px' + 'width: 300px; height: auto' ); $table->data[1][2] .= '
'; diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php index fbc60c42b0..e230055f1e 100644 --- a/pandora_console/godmode/events/event_edit_filter.php +++ b/pandora_console/godmode/events/event_edit_filter.php @@ -1,9 +1,9 @@ $extension) { [ 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&enabled='.$file, 'image' => 'images/lightbulb_off.png', - 'title' => __('Delete'), + 'title' => __('Enable'), ], true ); @@ -305,7 +305,7 @@ foreach ($extensions as $file => $extension) { [ 'href' => 'index.php?sec=godmode/extensions&sec2=godmode/extensions&enterprise='.(int) $extension['enterprise'].'&disabled='.$file, 'image' => 'images/lightbulb.png', - 'title' => __('Delete'), + 'title' => __('Disable'), ], true ); diff --git a/pandora_console/godmode/gis_maps/configure_gis_map.php b/pandora_console/godmode/gis_maps/configure_gis_map.php index 38b67a7c4e..a6f282d2cf 100644 --- a/pandora_console/godmode/gis_maps/configure_gis_map.php +++ b/pandora_console/godmode/gis_maps/configure_gis_map.php @@ -1,8 +1,8 @@ td > span.agent_alias"); - var $layerFormGroupsListItems = $("tr.groups_list_item"); - var newLayerId = "new_" + ($("tr.layer_row").length + 1); + if ($('#hidden-current_edit_layer_id').val()!=='0') { + updateLayer(); + } else { + var $layerFormNameInput = $("input#text-layer_name_form"); + var $layerFormVisibleCheckbox = $("input#checkbox-layer_visible_form"); + var $layerFormAgentsFromGroupSelect = $("select#layer_group_form"); + var $layerFormAgentsListItems = $("tr.agents_list_item > td > span.agent_alias"); + var $layerFormGroupsListItems = $("tr.groups_list_item"); + var newLayerId = "new_" + ($("tr.layer_row").length + 1); - addLayerRow(newLayerId, { - id: newLayerId, - name: $layerFormNameInput.val(), - visible: $layerFormVisibleCheckbox.prop("checked"), - agentsFromGroup: $layerFormAgentsFromGroupSelect.val(), - agents: $layerFormAgentsListItems.map(function () { - return { - "id": $(this).data("agent-id"), - "alias": $(this).text() - }; - }).get(), - groups: $layerFormGroupsListItems.map(function () { - return { - "id": $(this).data("group-id"), - "name": $(this).data("group-name"), - "agentId": $(this).data("agent-id"), - "agentAlias": $(this).data("agent-alias") - }; - }).get() - }); + addLayerRow(newLayerId, { + id: newLayerId, + name: $layerFormNameInput.val(), + visible: $layerFormVisibleCheckbox.prop("checked"), + agentsFromGroup: $layerFormAgentsFromGroupSelect.val(), + agents: $layerFormAgentsListItems.map(function () { + return { + "id": $(this).data("agent-id"), + "alias": $(this).text() + }; + }).get(), + groups: $layerFormGroupsListItems.map(function () { + return { + "id": $(this).data("group-id"), + "name": $(this).data("group-name"), + "agentId": $(this).data("agent-id"), + "agentAlias": $(this).data("agent-alias") + }; + }).get() + }); + } +} + +function updateLayer () { + var tr = $('#layer_row_'+$('#hidden-current_edit_layer_id').val()); + var agent_alias = $("tr.agents_list_item > td > span.agent_alias").map(function () { + return { + "id": $(this).data("agent-id"), + "alias": $(this).text() + }; + }).get(); + + var groups_list_item = $("tr.groups_list_item").map(function () { + return { + "id": $(this).data("group-id"), + "name": $(this).data("group-name"), + "agentId": $(this).data("agent-id"), + "agentAlias": $(this).data("agent-alias") + }; + }).get(); + + tr.find('input.layer_name').val($("input#text-layer_name_form").val()); + tr.find('input.layer_visible').val($("input#checkbox-layer_visible_form").prop("checked")); + tr.find('input.layer_agents_from_group').val($("select#layer_group_form").val()); + tr.find('input.layer_agent_id').val(agent_alias[0]["id"]); + tr.find('input.layer_agent_alias').val(agent_alias[0]["alias"]); + tr.find('input.layer_group_id').val(groups_list_item[0]["id"]); + tr.find('input.layer_group_name').val(groups_list_item[0]["name"]); + tr.find('input.layer_agent_id_for_data').val(groups_list_item[0]["agentId"]); + tr.find('input.layer_agent_alias_for_data').val(groups_list_item[0]["agentAlias"]); } function cleanLayerEditor () { diff --git a/pandora_console/godmode/groups/configure_group.php b/pandora_console/godmode/groups/configure_group.php index 88966378de..f7fa7a76b7 100644 --- a/pandora_console/godmode/groups/configure_group.php +++ b/pandora_console/godmode/groups/configure_group.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/groups/configure_modu_group.php b/pandora_console/godmode/groups/configure_modu_group.php index 282efeb87e..67bcafd814 100644 --- a/pandora_console/godmode/groups/configure_modu_group.php +++ b/pandora_console/godmode/groups/configure_modu_group.php @@ -1,9 +1,9 @@ 'list_agents_tactical', 'class' => 'info_table', - 'style' => 'width: 99%', + 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $columnNames, 'return' => true, diff --git a/pandora_console/godmode/massive/massive_add_action_alerts.php b/pandora_console/godmode/massive/massive_add_action_alerts.php index 4b6c333468..b0ba50cce4 100755 --- a/pandora_console/godmode/massive/massive_add_action_alerts.php +++ b/pandora_console/godmode/massive/massive_add_action_alerts.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/massive/massive_add_alerts.php b/pandora_console/godmode/massive/massive_add_alerts.php index 8fbb307e97..57261a357b 100755 --- a/pandora_console/godmode/massive/massive_add_alerts.php +++ b/pandora_console/godmode/massive/massive_add_alerts.php @@ -10,13 +10,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/massive/massive_add_profiles.php b/pandora_console/godmode/massive/massive_add_profiles.php index 6fa11d357f..abd41c5314 100644 --- a/pandora_console/godmode/massive/massive_add_profiles.php +++ b/pandora_console/godmode/massive/massive_add_profiles.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index c3a65ad624..ade7a7f69b 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -9,13 +9,13 @@ * @license See below * * ______ ___ _______ _______ ________ - * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| - * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas - * Please see http://pandorafms.org for full contribution list + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com/community/ for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation for version 2. @@ -86,31 +86,39 @@ if ($do_operation) { $groups = users_get_groups(); $table = new stdClass(); -$table->class = 'databox filters'; -$table->width = '100%'; -$table->data = []; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->style[2] = 'font-weight: bold'; -$table->style[4] = 'font-weight: bold'; -$table->style[6] = 'font-weight: bold'; - -// Source selection $table->id = 'source_table'; -$table->data[0][0] = __('Group'); -$table->data[0][1] = html_print_select_groups( - false, - 'AW', - true, - 'source_id_group', - $source_id_group, - false, - '', - '', - true +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; +$table->data = []; + +// Source selection. +$table->data[0][0] = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AW', + true, + 'source_id_group', + $source_id_group, + false, + '', + '', + true, + false, + false, + 'w100p', + false, + 'width:100%' + ) ); -$table->data[0][2] = __('Group recursion'); -$table->data[0][3] = html_print_checkbox('source_recursion', 1, $source_recursion, true, false); + +$table->data[0][1] = html_print_label_input_block( + __('Group recursion'), + html_print_checkbox('source_recursion', 1, $source_recursion, true, false) +); + $status_list = []; $status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); @@ -118,37 +126,52 @@ $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); $status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); -$table->data[0][4] = __('Status'); -$table->data[0][5] = html_print_select( - $status_list, - 'status_agents_source', - 'selected', - '', - __('All'), - AGENT_STATUS_ALL, - true + +$table->data[1][0] = html_print_label_input_block( + __('Status'), + html_print_select( + $status_list, + 'status_agents_source', + 'selected', + '', + __('All'), + AGENT_STATUS_ALL, + true, + false, + true, + 'w100p' + ) ); -$table->data[0][6] = __('Agent'); -$table->data[0][6] .= ' '; -// $table->data[0][7] = html_print_select (agents_get_group_agents ($source_id_group, false, "none"), -// 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); + $agents = ( $source_id_group ? agents_get_group_agents($source_id_group, false, 'none') : agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false))) ); -$table->data[0][7] = html_print_select($agents, 'source_id_agent', $source_id_agent, false, __('Select'), 0, true); - -echo ''; +$table->data[1][1] = html_print_label_input_block( + __('Agent').' ', + html_print_select( + $agents, + 'source_id_agent', + $source_id_agent, + false, + __('Select'), + 0, + true + ) +); +echo ''; echo '
'; -echo ''; -echo ''.__('Source'); -echo ''; +echo ''.__('Source').''; html_print_table($table); echo '
'; -// Target selection + +unset($table); +// Target selection. +$table = new stdClass(); $table->id = 'target_table'; -$table->class = 'databox filters'; +$table->class = 'databox filters filter-table-adv'; +$table->width = '100%'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; $table->data = []; $modules = []; @@ -169,66 +192,64 @@ foreach ($agent_alerts as $alert) { } $tags = tags_get_user_tags(); -$table->data['tags'][0] = __('Tags'); -$table->data['tags'][1] = html_print_select( - $tags, - 'tags[]', - $tags_name, - false, - __('Any'), - -1, - true, - true, - true +$table->colspan[0][0] = 2; +$table->data[0][0] = html_print_label_input_block( + __('Tags'), + html_print_select( + $tags, + 'tags[]', + $tags_name, + false, + __('Any'), + -1, + true, + true, + true, + '', + false, + 'overflow-x: hidden;white-space: nowrap;max-width: 1136px;' + ) ); -$table->data['operations'][0] = __('Operations'); -$table->data['operations'][1] = ''; -$table->data['operations'][1] .= html_print_checkbox('copy_modules', 1, true, true); -$table->data['operations'][1] .= html_print_label(__('Copy modules'), 'checkbox-copy_modules', true); -$table->data['operations'][1] .= '
'; - -$table->data['operations'][1] .= ''; -$table->data['operations'][1] .= html_print_checkbox('copy_alerts', 1, true, true); -$table->data['operations'][1] .= html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true); -$table->data['operations'][1] .= ''; - -$table->data['form_modules_filter'][0] = __('Filter Modules'); -$table->data['form_modules_filter'][1] = html_print_input_text('filter_modules', '', '', 20, 255, true); - -$table->data[1][0] = __('Modules'); -$table->data[1][1] = ''; -$table->data[1][1] .= html_print_select( - $modules, - 'target_modules[]', - 0, - false, - '', - '', - true, - true +$table->data[1][0] = html_print_label_input_block( + __('Operations'), + ''.html_print_checkbox('copy_modules', 1, true, true).html_print_label(__('Copy modules'), 'checkbox-copy_modules', true).''.html_print_checkbox('copy_alerts', 1, true, true).html_print_label(__('Copy alerts'), 'checkbox-copy_alerts', true).'' ); -$table->data[1][1] .= ''; -$table->data[1][1] .= ''; -$table->data[1][1] .= ''.__('No modules for this agent').''; -$table->data[1][1] .= ''; -$table->data[2][0] = __('Alerts'); -$table->data[2][1] = ''; -$table->data[2][1] .= html_print_select( - $alerts, - 'target_alerts[]', - 0, - false, - '', - '', - true, - true +$table->data[1][1] = html_print_label_input_block( + __('Filter Modules'), + html_print_input_text('filter_modules', '', '', 20, 255, true) +); + +$table->colspan[2][0] = 2; +$table->data[2][0] = html_print_label_input_block( + __('Modules'), + ''.html_print_select( + $modules, + 'target_modules[]', + 0, + false, + '', + '', + true, + true + ).''.__('No modules for this agent').'' +); + +$table->colspan[3][0] = 2; +$table->data[3][0] = html_print_label_input_block( + __('Alerts'), + ''.html_print_select( + $alerts, + 'target_alerts[]', + 0, + false, + '', + '', + true, + true + ).''.__('No alerts for this agent').'' ); -$table->data[2][1] .= ''; -$table->data[2][1] .= ''; -$table->data[2][1] .= ''.__('No alerts for this agent').''; -$table->data[2][1] .= ''; echo ''; $output .= include_javascript_d3(true); $output .= ""; if (!$return) { @@ -150,7 +150,7 @@ function d3_tree_map_graph($data, $width=700, $height=700, $return=false) } -function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $tooltip=true) +function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $tooltip=true, $id_container=false) { global $config; @@ -158,6 +158,8 @@ function d3_sunburst_graph($data, $width=700, $height=700, $return=false, $toolt $data = json_encode($data); } + $id_container = ($id_container === false) ? '#sunburst' : $id_container; + $output = "
"; $output .= include_javascript_d3(true); $output .= ''; $output .= ""; if (!$return) { diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index d1856b7b4c..6b64cae989 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -2,7 +2,7 @@ // Copyright (c) 2007-2008 Sancho Lerena, slerena@gmail.com // Copyright (c) 2008 Esteban Sanchez, estebans@artica.es -// Copyright (c) 2007-2021 Artica, info@artica.es +// Copyright (c) 2007-2021 Artica, info@pandorafms.com // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License // (LGPL) as published by the Free Software Foundation; version 2 @@ -36,9 +36,16 @@ function include_javascript_dependencies_flot_graph($return=false, $mobile=false '; } + $output .= ' + '; + // NOTE: jquery.flot.threshold is not te original file. Is patched to allow multiple thresholds and filled area $output .= ' + @@ -252,7 +259,7 @@ function flot_area_graph( $return .= html_print_input_hidden( 'line_width_graph', - $config['custom_graph_width'], + (empty($params['line_width']) === true) ? $config['custom_graph_width'] : $params['line_width'], true ); $return .= "
$date_to, 'server_id' => $server_id, ]; - // TO-DO Cambiar esto para que se pase por POST, NO SE PUEDE PASAR POR GET. + update_check_config_token($tokem_config, json_encode($graph_data)); $_SESSION['slicebar'] = $tokem_config; $_SESSION['slicebar_value'] = json_encode($graph_data); diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index 26a346f461..e32e76222f 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -1,7 +1,7 @@ +// Copyright (c) 2011-2023 Pandora FMS +// http://www.pandorafms.com // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; version 2 diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index 07fa7f009e..f99f0448da 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -1,6 +1,6 @@ // Pandora FMS - http://pandorafms.com // ================================================== -// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +// Copyright (c) 2005-2023 Pandora FMS // Please see http://pandorafms.org for full contribution list // This program is free software; you can redistribute it and/or @@ -22,7 +22,7 @@ // matrix = [[0, 0, 2], // a[a => a, a => b, a => c] // [5, 0, 1], // b[b => a, b => b, b => c] // [2, 3, 0]]; // c[c => a, c => b, c => c] -function chordDiagram(recipient, elements, matrix, width) { +function chordDiagram(recipient, elements, matrix, width, height) { d3.chart = d3.chart || {}; d3.chart.chordWheel = function(options) { // Default values @@ -59,10 +59,13 @@ function chordDiagram(recipient, elements, matrix, width) { .enter() .append("svg:svg") .attr("width", width) - .attr("height", width) + .attr("height", height) .attr("class", "dependencyWheel") .append("g") - .attr("transform", "translate(" + width / 2 + "," + width / 2 + ")"); + .attr( + "transform", + "translate(" + width / 2 + "," + height / 2 + ") scale(1.2)" + ); var arc = d3.svg .arc() @@ -206,8 +209,8 @@ function chordDiagram(recipient, elements, matrix, width) { .on("mousemove", move_tooltip); function move_tooltip(d) { - x = d3.event.pageX + 10; - y = d3.event.pageY + 10; + x = d3.event.layerX + 10; + y = d3.event.layerY + 10; $("#tooltip").css("left", x + "px"); $("#tooltip").css("top", y + "px"); diff --git a/pandora_console/include/help/clippy/agent_out_of_limits.php b/pandora_console/include/help/clippy/agent_out_of_limits.php index 6b96b7f50f..3640a3d5bd 100644 --- a/pandora_console/include/help/clippy/agent_out_of_limits.php +++ b/pandora_console/include/help/clippy/agent_out_of_limits.php @@ -1,9 +1,9 @@ true, - 'intro' => ''.''.''.''.''.''.''.''.''.'
'.__('Data Configuration Module.').'
'.__('Please note that information provided here affects how the agent collect information and generate the data XML. Any data/configuration reported by the agent, different from data or description is discarded, and the configuration shown in the console prevails over any configuration coming from the agent, this applies for example for crit/warn thresholds, interval, module group, min/max value, tags, etc.').'
'.__('Information imported FIRST time from the XML will fill the information you can see in the console, but after the first import, system will ignore any update coming from the XML/Agent.').'
', + 'intro' => __('Please note that information provided here affects how the agent collect information and generate the data XML. Any data/configuration reported by the agent, different from data or description is discarded, and the configuration shown in the console prevails over any configuration coming from the agent, this applies for example for crit/warn thresholds, interval, module group, min/max value, tags, etc.').__('Information imported FIRST time from the XML will fill the information you can see in the console, but after the first import, system will ignore any update coming from the XML/Agent.'), + 'title' => __('Data Configuration Module.'), + 'img' => html_print_image( + 'images/info-warning.svg', + true, + [ + 'class' => 'main_menu_icon invert_filter', + 'style' => 'margin-left: 5px;', + ] + ), ]; $return_tours['tours']['data_configuration_module']['conf'] = []; $return_tours['tours']['data_configuration_module']['conf']['autostart'] = false; diff --git a/pandora_console/include/help/clippy/extension_cron_send_email.php b/pandora_console/include/help/clippy/extension_cron_send_email.php index ad55e7296b..946270921c 100755 --- a/pandora_console/include/help/clippy/extension_cron_send_email.php +++ b/pandora_console/include/help/clippy/extension_cron_send_email.php @@ -1,9 +1,9 @@ true, - 'intro' => ''.''.''.''.''.''.''.'
'.__('Interval Agent.').'
'.__('Please note that having agents with a monitoring interval below 300 seconds is not recommended. This will impact seriously in the performance of the server. For example, having 200 agents with one minute interval, is the same than having 1000 agents with a 5 minute interval. The probability of getting unknown modules is higher, and the impact on the server is higher because it requires a shorter response time.').'
', + 'intro' => __('Please note that having agents with a monitoring interval below 300 seconds is not recommended. This will impact seriously in the performance of the server. For example, having 200 agents with one minute interval, is the same than having 1000 agents with a 5 minute interval. The probability of getting unknown modules is higher, and the impact on the server is higher because it requires a shorter response time.'), + 'title' => __('Interval Agent.'), + 'img' => html_print_image( + 'images/info-warning.svg', + true, + [ + 'class' => 'main_menu_icon invert_filter', + 'style' => 'margin-left: 5px;', + ] + ), ]; $return_tours['tours']['interval_agent_min']['conf'] = []; $return_tours['tours']['interval_agent_min']['conf']['autostart'] = false; diff --git a/pandora_console/include/help/clippy/module_unknow.php b/pandora_console/include/help/clippy/module_unknow.php index de3c7f619a..0a7959d118 100644 --- a/pandora_console/include/help/clippy/module_unknow.php +++ b/pandora_console/include/help/clippy/module_unknow.php @@ -1,9 +1,9 @@ { + if (column === null) return; + if (typeof column !== "string") { + datacolumnsTemp = { data: column.text, className: column.class }; + datacolumns.push(datacolumnsTemp); + } else { + datacolumnsTemp = { data: column, className: "no-class" }; + datacolumns.push(datacolumnsTemp); + } +}); + +var paginationClass = "pandora_pagination"; +if (typeof dt.pagination_class !== "undefined") { + paginationClass = dt.pagination_class; +} + +var processing = ""; +if (typeof dt.processing === "undefined") { + processing = dt.processing; +} + +var ajaxReturn = ""; +var ajaxReturnFunction = ""; +if ( + typeof dt.ajax_return_operation !== "undefined" && + dt.ajax_return_operation !== "" && + typeof dt.ajax_return_operation_function !== "undefined" && + dt.ajax_return_operation_function !== "" +) { + ajaxReturn = dt.ajax_return_operation; + ajaxReturnFunction = dt.ajax_return_operation_function; +} + +var serverSide = true; +if (typeof dt.data_element !== "undefined") { + serverSide = false; +} + +var paging = true; +if (typeof dt.paging !== "undefined") { + paging = dt.paging; +} + +var pageLength = parseInt(dt.default_pagination); + +var searching = false; +if (typeof dt.searching !== "undefined" && dt.searching === true) { + searching = dt.searching; +} + +var dom = "plfrtiB"; +if (typeof dt.dom_elements !== "undefined") { + dom = dt.dom_elements; +} + +var lengthMenu = [ + [pageLength, 5, 10, 20, 100, 200, 500, 1000, -1], + [pageLength, 5, 10, 20, 100, 200, 500, 1000, "All"] +]; +if (typeof dt.pagination_options !== "undefined") { + lengthMenu = dt.pagination_options; +} + +var ordering = true; +if (typeof dt.ordering !== "undefined" && dt.ordering === false) { + ordering = dt.ordering; +} + +var order = [[0, "asc"]]; +if (typeof dt.order !== "undefined") { + order = [[dt.order.order, dt.order.direction]]; +} + +var zeroRecords = ""; +if (typeof dt.zeroRecords !== "undefined") { + zeroRecords = `${dt.zeroRecords}`; +} + +var emptyTable = ""; +if (typeof dt.emptyTable !== "undefined") { + emptyTable = `${dt.emptyTable}`; +} + +var no_sortable_columns = []; +if (typeof dt.no_sortable_columns !== "undefined") { + no_sortable_columns = Object.values(dt.no_sortable_columns); +} + +var columnDefs = []; +if (typeof dt.columnDefs === "undefined") { + columnDefs = [ + { className: "no-class", targets: "_all" }, + { bSortable: false, targets: no_sortable_columns } + ]; +} else { + columnDefs = dt.columnDefs; +} + +var csvClassName = "csv-button"; +if (dt.mini_csv === true) { + csvClassName = "mini-csv-button"; +} + +var csvFieldSeparator = ";"; +if (typeof dt.csv_field_separator !== "undefined") { + csvFieldSeparator = dt.csv_field_separator; +} + +var csvHeader = true; +if (dt.csv_header === false) { + csvHeader = false; +} + +var csvExcludeLast = ""; +if (dt.csv_exclude_latest === true) { + csvExcludeLast = "th:not(:last-child)"; +} + +var ajaxData = ""; +if (typeof dt.ajax_data !== "undefined") { + ajaxData = dt.ajax_data; +} + +$(document).ready(function() { + function checkPages() { + if (dt_table.page.info().pages > 1) { + $( + "div.pagination-child-div > .dataTables_paginate.paging_simple_numbers" + ).show(); + $(`#${dt.id}_paginate`).show(); + } else { + $( + "div.pagination-child-div > .dataTables_paginate.paging_simple_numbers" + ).hide(); + $(`#${dt.id}_paginate`).hide(); + } + } + + function moveElementsToActionButtons() { + $(".action_buttons_right_content").html( + '
' + ); + $(".pagination-child-div").append( + $(`#${dt.id}_wrapper > .dataTables_paginate.paging_simple_numbers`).attr( + "style", + "margin-right: 10px;" + ) + ); + $(".pagination-child-div").append( + $(`#${dt.id}_wrapper > .dataTables_length`) + ); + $(".pagination-child-div").append($(`#${dt.id}_wrapper > .dt-buttons`)); + $(".pagination-child-div").append( + $(`#${dt.id}_wrapper > .dataTables_filter`) + ); + } + + $.fn.dataTable.ext.errMode = "none"; + $.fn.dataTable.ext.classes.sPageButton = paginationClass; + + if (dt.mini_pagination === true) { + $.fn.dataTable.ext.classes.sPageButton = `${paginationClass} mini-pandora-pagination`; + } + + var settings_datatable = { + processing: true, + responsive: true, + serverSide, + paging, + pageLength, + searching, + dom, + lengthMenu, + ordering, + order, + columns: eval(datacolumns), + columnDefs, + language: { + url: dt.language, + processing, + zeroRecords, + emptyTable + }, + buttons: + dt.csv == 1 + ? [ + { + extend: "csv", + className: csvClassName, + text: dt.csvTextInfo, + titleAttr: dt.csvTextInfo, + title: dt.csvFileTitle, + fieldSeparator: csvFieldSeparator, + header: csvHeader, + action: function(e, dt, node, config) { + blockResubmit(node); + // Call the default csvHtml5 action method to create the CSV file + $.fn.dataTable.ext.buttons.csvHtml5.action.call( + this, + e, + dt, + node, + config + ); + }, + exportOptions: { + modifier: { + // DataTables core + order: "current", + page: "All", + search: "applied" + }, + columns: csvExcludeLast + } + } + ] + : [], + initComplete: function(settings, json) { + moveElementsToActionButtons(); + + checkPages(); + + $(`div#${dt.id}-spinner`).hide(); + }, + drawCallback: function(settings) { + if ($(`#${dt.id} tr td`).length == 1) { + $(`.datatable-msg-info-${dt.id}`) + .removeClass("invisible_important") + .show(); + $(`table#${dt.id}`).hide(); + $("div.pagination-child-div").hide(); + $("div.dataTables_info").hide(); + $(`#${dt.id}_wrapper`).hide(); + $(`.action_buttons_right_content .pagination-child-div`).hide(); + } else { + $(`.datatable-msg-info-${dt.id}`).hide(); + $(`table#${dt.id}`).show(); + $("div.pagination-child-div").show(); + $("div.dataTables_info").show(); + $(`#${dt.id}_wrapper`).show(); + + if (typeof dt.drawCallback !== "undefined") { + eval(dt.drawCallback); + } + } + + $(`div#${dt.id}-spinner`).hide(); + + checkPages(); + } + }; + + var ajaxOrData = {}; + if (typeof dt.data_element == "undefined") { + ajaxOrData = { + ajax: { + url: dt.ajax_url_full, + type: "POST", + dataSrc: function(json) { + if ($(`#${dt.form_id}_search_bt`) != undefined) { + $(`#${dt.form_id}_loading`).remove(); + } + + if (json.error) { + console.error(json.error); + $(`#error-${dt.id}`).html(json.error); + $(`#error-${dt.id}`) + .dialog({ + title: "Filter failed", + width: 630, + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + buttons: { + Ok: function() { + $(this).dialog("close"); + } + } + }) + .parent() + .addClass("ui-state-error"); + } else { + if (json.ajaxReturn !== "undefined") { + eval(`${ajaxReturnFunction}(${json.ajaxReturn})`); + } + + if (typeof dt.ajax_postprocess !== "undefined") { + if (json.data) { + json.data.forEach(function(item) { + eval(dt.ajax_postprocess); + }); + } else { + json.data = {}; + } + } + + return json.data; + } + }, + data: function(data) { + $(`div#${dt.id}-spinner`).show(); + if ($(`#button-${dt.form_id}_search_bt`) != undefined) { + var loading = ``; + $(`#button-${dt.form_id}_search_bt`) + .parent() + .append(loading); + } + + var inputs = $(`#${dt.form_id} :input`); + + var values = {}; + inputs.each(function() { + values[this.name] = $(this).val(); + }); + + $.extend(data, ajaxData); + + $.extend(data, { + filter: values, + page: dt.ajax_url + }); + + return data; + } + } + }; + } else { + ajaxOrData = { data: dt.data_element }; + } + + $.extend(settings_datatable, ajaxOrData); + var dt_table = $(`#${dt.table_id}`).DataTable(settings_datatable); + + $(`#button-${dt.form_id}_search_bt`).click(function() { + dt_table.draw().page(0); + }); + + if (typeof dt.caption !== "undefined" && dt.caption !== "") { + $(`#${dt.table_id}`).append(`${dt.caption}`); + $(".datatables_thead_tr").css("height", 0); + } + + $(function() { + $(document).on("init.dt", function(ev, settings) { + if (dt.mini_search === true) { + $(`#${dt.id}_filter > label > input`).addClass("mini-search-input"); + } + + $("div.dataTables_length").show(); + $("div.dataTables_filter").show(); + $("div.dt-buttons").show(); + + if (dt_table.page.info().pages === 0) { + $(`.action_buttons_right_content .pagination-child-div`).hide(); + } + + if (dt_table.page.info().pages === 1) { + $(`div.pagination-child-div > #${dt.table_id}_paginate`).hide(); + } else { + $(`div.pagination-child-div > #${dt.table_id}_paginate`).show(); + } + }); + }); +}); + +$(function() { + $(document).on("preInit.dt", function(ev, settings) { + $(`#${dt.id}_wrapper div.dataTables_length`).hide(); + $(`#${dt.id}_wrapper div.dataTables_filter`).hide(); + $(`#${dt.id}_wrapper div.dt-buttons`).hide(); + }); +}); diff --git a/pandora_console/include/javascript/extensions_discovery.js b/pandora_console/include/javascript/extensions_discovery.js new file mode 100644 index 0000000000..a2cb6c85d0 --- /dev/null +++ b/pandora_console/include/javascript/extensions_discovery.js @@ -0,0 +1,25 @@ +/* global $, interval */ +$(document).ready(() => { + if (interval === "0") { + setTimeout(() => { + $("#mode_interval") + .parent() + .find("[id^='interval']") + .hide(); + }, 100); + } +}); + +function changeModeInterval(e) { + if ($(e).val() === "manual") { + $(e) + .parent() + .find("[id^='interval']") + .hide(); + } else { + var interval = $(e) + .parent() + .find("div[id^='interval']")[0]; + $(interval).show(); + } +} diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index c1c7a7d4f8..f47ea18740 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -25,7 +25,7 @@ /* global show_labels:true */ /* global show_minimap:true */ /* global layer_graph */ -/* global zoom_obj */ +/* global zoom_obj_nm */ /* global disabled_drag_zoom */ /* global scale:true */ /* global link */ @@ -42,6 +42,9 @@ /* exported hide_labels */ /* exported toggle_minimap */ /* exported over_node */ +if (typeof d3_nm === "undefined") { + var d3_nm = d3; +} function draw_minimap() { // Clean the canvas. @@ -397,7 +400,8 @@ function change_shape(id_db_node) { $("#id_node_" + element.id + networkmap_id + " image").remove(); if (shape == "circle") { - d3.select("#id_node_" + element.id + networkmap_id) + d3_nm + .select("#id_node_" + element.id + networkmap_id) .insert("circle", "title") .attr("r", node_radius) .attr("class", "node_shape node_shape_circle") @@ -419,7 +423,8 @@ function change_shape(id_db_node) { show_menu("node", d); }); - d3.select("#id_node_" + element.id + networkmap_id) + d3_nm + .select("#id_node_" + element.id + networkmap_id) .append("image") .attr("class", "node_image") .attr("xlink:href", function(d) { @@ -456,7 +461,8 @@ function change_shape(id_db_node) { show_menu("node", d); }); } else if (shape == "square") { - d3.select("#id_node_" + element.id + networkmap_id) + d3_nm + .select("#id_node_" + element.id + networkmap_id) .insert("rect", "title") .attr("width", node_radius * 2) .attr("height", node_radius * 2) @@ -479,7 +485,8 @@ function change_shape(id_db_node) { show_menu("node", d); }); - d3.select("#id_node_" + element.id + networkmap_id) + d3_nm + .select("#id_node_" + element.id + networkmap_id) .append("image") .attr("class", "node_image") .attr("xlink:href", function(d) { @@ -516,7 +523,8 @@ function change_shape(id_db_node) { show_menu("node", d); }); } else if (shape == "rhombus") { - d3.select("#id_node_" + element.id + networkmap_id) + d3_nm + .select("#id_node_" + element.id + networkmap_id) .insert("rect", "title") .attr("transform", "") .attr("width", node_radius * 1.5) @@ -540,7 +548,8 @@ function change_shape(id_db_node) { show_menu("node", d); }); - d3.select("#id_node_" + element.id + networkmap_id) + d3_nm + .select("#id_node_" + element.id + networkmap_id) .append("image") .attr("class", "node_image") .attr("xlink:href", function(d) { @@ -798,7 +807,7 @@ function edit_node(data_node, dblClick) { var edit_node = null; //Only select one node - var selection = d3.selectAll(".node_selected"); + var selection = d3_nm.selectAll(".node_selected"); var id; if (selection[0].length == 1) { @@ -806,17 +815,17 @@ function edit_node(data_node, dblClick) { } else if (selection[0].length > 1) { edit_node = selection[0].pop(); } else if (dblClick) { - edit_node = d3.select("#id_node_" + data_node["id"] + networkmap_id); + edit_node = d3_nm.select("#id_node_" + data_node["id"] + networkmap_id); edit_node = edit_node[0][0]; } else { flag_edit_node = false; } if (flag_edit_node) { - d3.selectAll(".node_selected").classed("node_selected", false); - d3.select(edit_node).classed("node_selected", true); + d3_nm.selectAll(".node_selected").classed("node_selected", false); + d3_nm.select(edit_node).classed("node_selected", true); - id = d3 + id = d3_nm .select(edit_node) .attr("id") .replace("id_node_", ""); @@ -1358,7 +1367,7 @@ function hide_labels_function() { window.location.origin + "/pandora_console/images/enable.svg" ); - d3.selectAll(".node_text").style("display", "none"); + d3_nm.selectAll(".node_text").style("display", "none"); } function show_labels_function() { @@ -1371,7 +1380,7 @@ function show_labels_function() { window.location.origin + "/pandora_console/images/disable.svg" ); - d3.selectAll(".node_text").style("display", ""); + d3_nm.selectAll(".node_text").style("display", ""); } function toggle_minimap() { @@ -1411,7 +1420,7 @@ function function_close_minimap() { } function delete_nodes() { - var selection = d3.selectAll(".node_selected"); + var selection = d3_nm.selectAll(".node_selected"); selection.each(function(d) { var params = []; params.push("id=" + d.id_db); @@ -1461,7 +1470,7 @@ function delete_nodes() { }); } -function zoom(manual) { +function zoom_networkmap(manual) { if (typeof manual == "undefined") { manual = false; } @@ -1472,18 +1481,18 @@ function zoom(manual) { "translate(" + translation + ")scale(" + scale + ")" ); - zoom_obj.translate(translation); - zoom_obj.scale(scale); + zoom_obj_nm.translate(translation); + zoom_obj_nm.scale(scale); draw_minimap(); } else { - if (!disabled_drag_zoom) { - translation[0] = d3.event.translate[0]; - translation[1] = d3.event.translate[1]; - scale = d3.event.scale; + if (!disabled_drag_zoom && d3_nm.event !== null) { + translation[0] = d3_nm.event.translate[0]; + translation[1] = d3_nm.event.translate[1]; + scale = d3_nm.event.scale; - zoom_obj.translate(translation); - zoom_obj.scale(scale); + zoom_obj_nm.translate(translation); + zoom_obj_nm.scale(scale); layer_graph.attr( "transform", @@ -1493,7 +1502,7 @@ function zoom(manual) { draw_minimap(); } else { //Keep the translation before to start to dragging - zoom_obj.translate(translation); + zoom_obj_nm.translate(translation); } } } @@ -1555,7 +1564,7 @@ function set_positions_graph() { if (siblingCount > 1) { var siblings = getSiblingLinks(d.source, d.target); - var arcScale = d3.scale + var arcScale = d3_nm.scale .ordinal() .domain(siblings) .rangePoints([1, siblingCount]); @@ -1701,18 +1710,20 @@ function set_positions_graph() { } function over_node(d) { - var over = d3.select("#id_node_" + d.id + networkmap_id).classed("node_over"); + var over = d3_nm + .select("#id_node_" + d.id + networkmap_id) + .classed("node_over"); in_a_node = !in_a_node; - d3.select("#id_node_" + d.id + networkmap_id).classed("node_over", !over); + d3_nm.select("#id_node_" + d.id + networkmap_id).classed("node_over", !over); } function selected_node(d, selected_param, hold_other_selections) { if (typeof selected_param == "boolean") { selected = !selected_param; //because the next negate } else { - selected = d3 + selected = d3_nm .select("#id_node_" + d.id + networkmap_id) .classed("node_selected"); } @@ -1724,20 +1735,19 @@ function selected_node(d, selected_param, hold_other_selections) { } if (deselect_others) { - d3.selectAll(".node_selected").classed("node_selected", false); + d3_nm.selectAll(".node_selected").classed("node_selected", false); } - d3.select("#id_node_" + d.id + networkmap_id).classed( - "node_selected", - !selected - ); + d3_nm + .select("#id_node_" + d.id + networkmap_id) + .classed("node_selected", !selected); - d3.event.stopPropagation(); + d3_nm.event.stopPropagation(); } function clear_selection() { if (!flag_multiple_selection && !in_a_node) { - d3.selectAll(".node_selected").classed("node_selected", false); + d3_nm.selectAll(".node_selected").classed("node_selected", false); } } @@ -1756,10 +1766,9 @@ function update_networkmap() { type: "POST", url: window.base_url_homedir + "/ajax.php", success: function(data) { - d3.select("#id_node_" + d.id + networkmap_id + " .node_shape").style( - "fill", - data["color"] - ); + d3_nm + .select("#id_node_" + d.id + networkmap_id + " .node_shape") + .style("fill", data["color"]); } }); } @@ -1778,14 +1787,13 @@ function update_networkmap() { type: "POST", url: window.base_url_homedir + "/ajax.php", success: function(data) { - d3.selectAll(".id_module_start_" + d.id_module_start).attr( - "marker-start", - function(d) { + d3_nm + .selectAll(".id_module_start_" + d.id_module_start) + .attr("marker-start", function(d) { if (typeof module_color_status[data.status] == "undefined") return "url(#interface_start)"; else return "url(#interface_start_" + data.status + ")"; - } - ); + }); } }); } @@ -1801,14 +1809,13 @@ function update_networkmap() { type: "POST", url: window.base_url_homedir + "/ajax.php", success: function(data) { - d3.selectAll(".id_module_end_" + d.id_module_end).attr( - "marker-end", - function(d) { + d3_nm + .selectAll(".id_module_end_" + d.id_module_end) + .attr("marker-end", function(d) { if (typeof module_color_status[data.status] == "undefined") return "url(#interface_end)"; else return "url(#interface_end_" + data.status + ")"; - } - ); + }); } }); } @@ -1877,7 +1884,7 @@ function init_minimap() { translation[0] = -(x * scale) / relation_min_nodes + width_svg / 2; translation[1] = -(y * scale) / relation_min_nodes + height_svg / 2; - zoom(true); + zoom_networkmap(true); event.stopPropagation(); @@ -1932,7 +1939,7 @@ function init_minimap() { translation[0] = -(x * scale) / relation_min_nodes + width_svg / 2; translation[1] = -(y * scale) / relation_min_nodes + height_svg / 2; - zoom(true); + zoom_networkmap(true); event.stopPropagation(); return false; @@ -1944,14 +1951,14 @@ function init_minimap() { //////////////////////////////////////////////////////////////////////// function show_menu(item, data) { mouse = []; - mouse[0] = d3.event.pageX; - mouse[1] = d3.event.pageY; + mouse[0] = d3_nm.event.pageX; + mouse[1] = d3_nm.event.pageY; - window.click_menu_position_svg = [d3.event.layerX, d3.event.layerY]; + window.click_menu_position_svg = [d3_nm.event.layerX, d3_nm.event.layerY]; //stop showing browser menu - d3.event.preventDefault(); - d3.event.stopPropagation(); + d3_nm.event.preventDefault(); + d3_nm.event.stopPropagation(); switch (item) { case "node": @@ -1977,17 +1984,17 @@ function show_menu(item, data) { } }, callback: function(key, options) { - var selection = d3.selectAll(".node_children"); + var selection = d3_nm.selectAll(".node_children"); selection.each(function(d) { - d3.select("#id_node_" + d.id + networkmap_id).classed( - "node_children", - false - ); + d3_nm + .select("#id_node_" + d.id + networkmap_id) + .classed("node_children", false); }); - selection = d3.selectAll(".node_selected"); + selection = d3_nm.selectAll(".node_selected"); selection.each(function(d) { - d3.select("#id_node_" + d.id + networkmap_id) + d3_nm + .select("#id_node_" + d.id + networkmap_id) .classed("node_selected", false) .classed("node_children", true); }); @@ -2000,17 +2007,17 @@ function show_menu(item, data) { icon: "children", disabled: false, callback: function(key, options) { - var selection = d3.selectAll(".node_children"); + var selection = d3_nm.selectAll(".node_children"); selection.each(function(d) { - d3.select("#id_node_" + d.id + networkmap_id).classed( - "node_children", - false - ); + d3_nm + .select("#id_node_" + d.id + networkmap_id) + .classed("node_children", false); }); - selection = d3.selectAll(".node_selected"); + selection = d3_nm.selectAll(".node_selected"); selection.each(function(d) { - d3.select("#id_node_" + d.id + networkmap_id) + d3_nm + .select("#id_node_" + d.id + networkmap_id) .classed("node_selected", false) .classed("node_children", true); }); @@ -2021,7 +2028,7 @@ function show_menu(item, data) { if (flag_setting_interface_link_running) { if ( - d3 + d3_nm .select("#id_node_" + data.id + networkmap_id) .attr("class") .search("node_children") == -1 @@ -2037,7 +2044,7 @@ function show_menu(item, data) { } }, callback: function(key, options) { - var selection = d3.selectAll(".node_selected"); + var selection = d3_nm.selectAll(".node_selected"); selection = selection[0]; if (selection.length > 1) { alert("Only one-one relations (one father, one son)"); @@ -2066,7 +2073,7 @@ function show_menu(item, data) { if (flag_setting_relationship_running) { if ( - d3 + d3_nm .select("#id_node_" + data.id + networkmap_id) .attr("class") .search("node_children") == -1 @@ -2076,7 +2083,7 @@ function show_menu(item, data) { icon: "set_parent", disabled: false, callback: function(key, options) { - var selection = d3.selectAll(".node_selected"); + var selection = d3_nm.selectAll(".node_selected"); selection = selection[0]; if (selection.length > 1) { alert("Only one-one relations (one father, one son)"); @@ -2213,7 +2220,7 @@ function show_menu(item, data) { } function add_interface_link(data_parent) { - var selection = d3.selectAll(".node_children"); + var selection = d3_nm.selectAll(".node_children"); count = selection.size(); @@ -2381,8 +2388,8 @@ function add_interface_link_js() { } function refresh_holding_area() { - var holding_pos_x = d3.select("#holding_area_" + networkmap_id).attr("x"); - var holding_pos_y = d3.select("#holding_area_" + networkmap_id).attr("y"); + var holding_pos_x = d3_nm.select("#holding_area_" + networkmap_id).attr("x"); + var holding_pos_y = d3_nm.select("#holding_area_" + networkmap_id).attr("y"); var pos_x = parseInt(holding_pos_x) + parseInt(node_radius); var pos_y = parseInt(holding_pos_y) + parseInt(node_radius); @@ -2513,8 +2520,8 @@ function refresh_holding_area() { function refresh() { $("#spinner_networkmap").css("display", "flex"); - var holding_pos_x = d3.select("#holding_area_" + networkmap_id).attr("x"); - var holding_pos_y = d3.select("#holding_area_" + networkmap_id).attr("y"); + var holding_pos_x = d3_nm.select("#holding_area_" + networkmap_id).attr("x"); + var holding_pos_y = d3_nm.select("#holding_area_" + networkmap_id).attr("y"); var pos_x = parseInt(holding_pos_x) + parseInt(node_radius); var pos_y = parseInt(holding_pos_y) + parseInt(node_radius); @@ -2747,7 +2754,7 @@ function reset_map_from_form(new_elements) { } function set_parent(parent_data) { - var selection = d3.selectAll(".node_children"); + var selection = d3_nm.selectAll(".node_children"); var count = selection.size(); @@ -2853,10 +2860,11 @@ function set_parent(parent_data) { } function cancel_set_parent_interface() { - var selection = d3.selectAll(".node_children"); + var selection = d3_nm.selectAll(".node_children"); selection.each(function(d) { - d3.select("#id_node_" + d.id + networkmap_id) + d3_nm + .select("#id_node_" + d.id + networkmap_id) .classed("node_selected", true) .classed("node_children", false); }); @@ -2865,10 +2873,11 @@ function cancel_set_parent_interface() { } function cancel_set_parent() { - var selection = d3.selectAll(".node_children"); + var selection = d3_nm.selectAll(".node_children"); selection.each(function(d) { - d3.select("#id_node_" + d.id + networkmap_id) + d3_nm + .select("#id_node_" + d.id + networkmap_id) .classed("node_selected", true) .classed("node_children", false); }); @@ -2884,28 +2893,32 @@ function init_drag_and_drop() { window.drag_start = [0, 0]; window.drag_end = [0, 0]; - window.drag = d3.behavior + window.drag = d3_nm.behavior .drag() .on("dragstart", function() { - if (d3.event.sourceEvent.button == 2) return; + if (d3_nm.event.sourceEvent.button == 2) return; - var mouse_coords = d3.mouse(this); + var mouse_coords = d3_nm.mouse(this); drag_start[0] = drag_end[0] = mouse_coords[0]; drag_start[1] = drag_end[1] = mouse_coords[1]; flag_drag_running = true; - d3.event.sourceEvent.stopPropagation(); + d3_nm.event.sourceEvent.stopPropagation(); }) .on("dragend", function(d, i) { - if (d3.event.sourceEvent.button == 2) return; + if (d3_nm.event.sourceEvent.button == 2) return; flag_drag_running = false; - var selection = d3.selectAll(".node_selected"); + var selection = d3_nm.selectAll(".node_selected"); - var holding_pos_x = d3.select("#holding_area_" + networkmap_id).attr("x"); - var holding_pos_y = d3.select("#holding_area_" + networkmap_id).attr("y"); + var holding_pos_x = d3_nm + .select("#holding_area_" + networkmap_id) + .attr("x"); + var holding_pos_y = d3_nm + .select("#holding_area_" + networkmap_id) + .attr("y"); delete d.raw_text; selection.each(function(d) { jQuery.ajax({ @@ -2925,18 +2938,15 @@ function init_drag_and_drop() { if (data["state"] == "") { //Remove the style of nodes and links //in holding area - d3.select("#id_node_" + d.id + networkmap_id).classed( - "holding_area", - false - ); - d3.select(".source_" + d.id + networkmap_id).classed( - "holding_area_link", - false - ); - d3.select(".target_" + d.id + networkmap_id).classed( - "holding_area_link", - false - ); + d3_nm + .select("#id_node_" + d.id + networkmap_id) + .classed("holding_area", false); + d3_nm + .select(".source_" + d.id + networkmap_id) + .classed("holding_area_link", false); + d3_nm + .select(".target_" + d.id + networkmap_id) + .classed("holding_area_link", false); graph.nodes[d.id].state = ""; } } @@ -2944,12 +2954,12 @@ function init_drag_and_drop() { }); }); - d3.event.sourceEvent.stopPropagation(); + d3_nm.event.sourceEvent.stopPropagation(); }) .on("drag", function(d, i) { - if (d3.event.sourceEvent.button == 2) return; + if (d3_nm.event.sourceEvent.button == 2) return; - var mouse_coords = d3.mouse(this); + var mouse_coords = d3_nm.mouse(this); var delta = [0, 0]; delta[0] = mouse_coords[0] - drag_end[0]; @@ -2958,7 +2968,7 @@ function init_drag_and_drop() { drag_end[0] = mouse_coords[0]; drag_end[1] = mouse_coords[1]; - var selection = d3.selectAll(".node_selected"); + var selection = d3_nm.selectAll(".node_selected"); selection.each(function(d) { // We search the position of this node in the array (index). @@ -2973,7 +2983,7 @@ function init_drag_and_drop() { draw_elements_graph(); set_positions_graph(); - d3.event.sourceEvent.stopPropagation(); + d3_nm.event.sourceEvent.stopPropagation(); }); dragables.call(drag); } @@ -3154,24 +3164,25 @@ function init_graph(parameter_object) { var rect_center_y = graph.nodes[0].y; //For to catch the keyevent for the ctrl key - d3.select(document) + d3_nm + .select(document) .on("keydown", function() { - if (d3.event.keyCode == key_multiple_selection) { + if (d3_nm.event.keyCode == key_multiple_selection) { flag_multiple_selection = true; disabled_drag_zoom = true; } }) .on("keyup", function() { - if (d3.event.keyCode == key_multiple_selection) { + if (d3_nm.event.keyCode == key_multiple_selection) { flag_multiple_selection = false; disabled_drag_zoom = false; flag_multiple_selection_running = false; - d3.select("#selection_rectangle").style("display", "none"); + d3_nm.select("#selection_rectangle").style("display", "none"); } }); - window.force = d3.layout + window.force = d3_nm.layout .force() .charge(10) .linkDistance(0) @@ -3187,32 +3198,33 @@ function init_graph(parameter_object) { scale = z_dash; } - window.zoom_obj = d3.behavior.zoom(); - zoom_obj + window.zoom_obj_nm = d3_nm.behavior.zoom(); + zoom_obj_nm .scaleExtent([0.05, 1]) - .on("zoom", zoom) + .on("zoom", zoom_networkmap) .translate(translation) .scale(scale); - window.svg = d3 + window.svg = d3_nm .select("#networkconsole_" + networkmap_id) .append("svg") .attr("id", "dinamic_networkmap_svg_" + networkmap_id) .attr("width", width_svg) .attr("height", height_svg) - .call(zoom_obj) + .call(zoom_obj_nm) .on("mousedown", function() { if (flag_multiple_selection) { flag_multiple_selection_running = true; - mouse_coords = d3.mouse(this); + mouse_coords = d3_nm.mouse(this); selection_rectangle[0] = mouse_coords[0]; selection_rectangle[1] = mouse_coords[1]; selection_rectangle[2] = mouse_coords[0]; selection_rectangle[3] = mouse_coords[1]; - d3.select("#selection_rectangle") + d3_nm + .select("#selection_rectangle") .style("display", "") .attr("x", selection_rectangle[0]) .attr("y", selection_rectangle[1]) @@ -3224,11 +3236,11 @@ function init_graph(parameter_object) { }) .on("mouseup", function() { flag_multiple_selection_running = false; - d3.select("#selection_rectangle").style("display", "none"); + d3_nm.select("#selection_rectangle").style("display", "none"); }) .on("mousemove", function() { if (flag_multiple_selection_running) { - mouse_coords = d3.mouse(this); + mouse_coords = d3_nm.mouse(this); selection_rectangle[2] = mouse_coords[0]; selection_rectangle[3] = mouse_coords[1]; @@ -3247,7 +3259,8 @@ function init_graph(parameter_object) { height = selection_rectangle[1] - selection_rectangle[3]; } - d3.select("#selection_rectangle") + d3_nm + .select("#selection_rectangle") .attr("x", x) .attr("y", y) .attr("width", width) @@ -3258,24 +3271,23 @@ function init_graph(parameter_object) { sel_rec_y1 = y; sel_rec_y2 = y + height; - d3.selectAll(".node").each(function(data, i) { + d3_nm.selectAll(".node").each(function(data, i) { item_x1 = (data.x - node_radius / 2) * scale + translation[0]; item_x2 = (data.x + node_radius / 2) * scale + translation[0]; item_y1 = (data.y - node_radius / 2) * scale + translation[1]; item_y2 = (data.y + node_radius / 2) * scale + translation[1]; if ( - !d3.select(this).classed("node_selected") && + !d3_nm.select(this).classed("node_selected") && // inner circle inside selection frame item_x1 >= sel_rec_x1 && item_x2 <= sel_rec_x2 && item_y1 >= sel_rec_y1 && item_y1 <= sel_rec_y2 ) { - d3.select("#id_node_" + data.id + networkmap_id).classed( - "node_selected", - true - ); + d3_nm + .select("#id_node_" + data.id + networkmap_id) + .classed("node_selected", true); } }); } @@ -3485,7 +3497,7 @@ function init_graph(parameter_object) { } function myMouseoverCircleFunction(node_id) { - var circle = d3.select("#id_node_" + node_id + networkmap_id + " circle"); + var circle = d3_nm.select("#id_node_" + node_id + networkmap_id + " circle"); over = circle.classed("node_over"); @@ -3499,7 +3511,7 @@ function myMouseoverCircleFunction(node_id) { .attr("r", node_radius + 10); } function myMouseoutCircleFunction(node_id) { - var circle = d3.select("#id_node_" + node_id + networkmap_id + " circle"); + var circle = d3_nm.select("#id_node_" + node_id + networkmap_id + " circle"); over = circle.classed("node_over"); @@ -3514,7 +3526,7 @@ function myMouseoutCircleFunction(node_id) { } function myMouseoverSquareFunction(node_id) { - var square = d3.select("#id_node_" + node_id + networkmap_id + " rect"); + var square = d3_nm.select("#id_node_" + node_id + networkmap_id + " rect"); over = square.classed("node_over"); @@ -3530,7 +3542,7 @@ function myMouseoverSquareFunction(node_id) { .attr("transform", "translate(" + -5 + "," + -5 + ")"); } function myMouseoutSquareFunction(node_id) { - var square = d3.select("#id_node_" + node_id + networkmap_id + " rect"); + var square = d3_nm.select("#id_node_" + node_id + networkmap_id + " rect"); over = square.classed("node_over"); @@ -3547,7 +3559,7 @@ function myMouseoutSquareFunction(node_id) { } function myMouseoverRhombusFunction(node_id) { - var rhombus = d3.select("#id_node_" + node_id + networkmap_id + " rect"); + var rhombus = d3_nm.select("#id_node_" + node_id + networkmap_id + " rect"); over = rhombus.classed("node_over"); @@ -3562,7 +3574,7 @@ function myMouseoverRhombusFunction(node_id) { .attr("height", node_radius * 1.5 + 10); } function myMouseoutRhombusFunction(node_id) { - var rhombus = d3.select("#id_node_" + node_id + networkmap_id + " rect"); + var rhombus = d3_nm.select("#id_node_" + node_id + networkmap_id + " rect"); over = rhombus.classed("node_over"); @@ -3694,10 +3706,10 @@ function draw_elements_graph() { } }) .on("mouseover", function(d) { - d3.select(this).classed("link_over", true); + d3_nm.select(this).classed("link_over", true); }) .on("mouseout", function(d) { - d3.select(this).classed("link_over", false); + d3_nm.select(this).classed("link_over", false); }); //Add the reverse line for the end marker, it is invisible diff --git a/pandora_console/include/javascript/i18n/dataTables.en.json b/pandora_console/include/javascript/i18n/dataTables.en.json index 9ccd76c4ad..d80bbe6e75 100644 --- a/pandora_console/include/javascript/i18n/dataTables.en.json +++ b/pandora_console/include/javascript/i18n/dataTables.en.json @@ -6,7 +6,6 @@ "infoThousands": ",", "lengthMenu": "Show _MENU_ entries", "loadingRecords": "Loading...", - "processing": "Processing...", "search": "Search:", "zeroRecords": "No matching records found", "thousands": ",", diff --git a/pandora_console/include/javascript/jquery.pandora.controls.js b/pandora_console/include/javascript/jquery.pandora.controls.js index 731ce0c761..c42f205b60 100644 --- a/pandora_console/include/javascript/jquery.pandora.controls.js +++ b/pandora_console/include/javascript/jquery.pandora.controls.js @@ -22,7 +22,9 @@ privilege: "", serialized: false, serialized_separator: "", - nodes: [] + nodes: [], + id_os: -1, + os_agent_version: "" }; /* public methods */ @@ -53,7 +55,7 @@ } else { recursion_value = config.recursion; } - + var opts = { page: "godmode/groups/group_list", get_group_agents: 1, @@ -74,7 +76,9 @@ nodes: typeof config.nodes === "function" ? config.nodes() - : config.disabled + : config.disabled, + os_agent: config.os_agent, + os_agent_version: config.os_agent_version }; jQuery.post( @@ -319,7 +323,6 @@ let href = $("a", config.spanPreview).attr("href"); let hrefPosition = href.search("group_id="); let hrefNew = href.slice(0, hrefPosition) + "group_id=" + id_group; - jQuery.post( "ajax.php", { diff --git a/pandora_console/include/javascript/manage_extensions.js b/pandora_console/include/javascript/manage_extensions.js new file mode 100644 index 0000000000..e5c98c6a58 --- /dev/null +++ b/pandora_console/include/javascript/manage_extensions.js @@ -0,0 +1,72 @@ +/* globals $, page, url, textsToTranslate, confirmDialog*/ +$(document).ready(function() { + function loading(status) { + if (status) { + $(".spinner-fixed").show(); + $("#button-upload_button").attr("disabled", "true"); + } else { + $(".spinner-fixed").hide(); + $("#button-upload_button").removeAttr("disabled"); + } + } + + $("#uploadExtension").submit(function(e) { + e.preventDefault(); + var formData = new FormData(this); + formData.append("page", page); + formData.append("method", "validateIniName"); + loading(true); + $.ajax({ + method: "POST", + url: url, + data: formData, + processData: false, + contentType: false, + success: function(data) { + loading(false); + data = JSON.parse(data); + if (data.success) { + if (data.warning) { + confirmDialog({ + title: textsToTranslate["Warning"], + message: data.message, + strOKButton: textsToTranslate["Confirm"], + strCancelButton: textsToTranslate["Cancel"], + onAccept: function() { + loading(true); + $("#uploadExtension")[0].submit(); + }, + onDeny: function() { + return false; + } + }); + } else { + $("#uploadExtension")[0].submit(); + } + } else { + confirmDialog({ + title: textsToTranslate["Error"], + message: data.message, + ok: textsToTranslate["Ok"], + hideCancelButton: true, + onAccept: function() { + return false; + } + }); + } + }, + error: function() { + loading(false); + confirmDialog({ + title: textsToTranslate["Error"], + message: textsToTranslate["Failed to upload extension"], + ok: textsToTranslate["Ok"], + hideCancelButton: true, + onAccept: function() { + return false; + } + }); + } + }); + }); +}); diff --git a/pandora_console/include/javascript/massive_operations.js b/pandora_console/include/javascript/massive_operations.js index 6a372f703e..e5edfe1dce 100644 --- a/pandora_console/include/javascript/massive_operations.js +++ b/pandora_console/include/javascript/massive_operations.js @@ -110,6 +110,18 @@ function form_controls_massive_operations_agents(metaconsole) { $("#id_group").trigger("change"); }); + var os_agent; + $("#os_agent").change(function() { + os_agent = this.value; + $("#id_group").trigger("change"); + }); + + var os_agent_version; + $("#text-os_agent_version").keyup(function() { + os_agent_version = this.value; + $("#id_group").trigger("change"); + }); + if (metaconsole == 1) { $("#nodes").change(function() { disabled = $("#disabled").val(); @@ -142,6 +154,13 @@ function form_controls_massive_operations_agents(metaconsole) { }, disabled: function() { return disabled; + }, + os_agent: function() { + return os_agent; + }, + os_agent_version: function() { + console.log(os_agent_version); + return os_agent_version; } }; diff --git a/pandora_console/include/javascript/openlayers.pandora.js b/pandora_console/include/javascript/openlayers.pandora.js index 8d8002756a..2e66c24fed 100755 --- a/pandora_console/include/javascript/openlayers.pandora.js +++ b/pandora_console/include/javascript/openlayers.pandora.js @@ -1,6 +1,6 @@ // Pandora FMS - http://pandorafms.com // ================================================== -// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas +// Copyright (c) 2005-2023 Pandora FMS // Please see http://pandorafms.org for full contribution list // This program is free software; you can redistribute it and/or diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 22815792e0..af212f454e 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -232,6 +232,11 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) { } } + var exclude_policy_modules = 0; + if ($("#hidden-exclude_policy_modules").val() === "1") { + exclude_policy_modules = 1; + } + jQuery.post( homedir + "/ajax.php", { @@ -248,7 +253,8 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) { status_module: module_status, id_group: id_group, pendingdelete: - event.target != undefined ? event.target.dataset.pendingdelete : 0 // Get pendingdelete attribute from target + event.target != undefined ? event.target.dataset.pendingdelete : 0, // Get pendingdelete attribute from target + exclude_policy_modules }, function(data) { $("#module").empty(); @@ -2230,10 +2236,16 @@ function renewAPIToken(title, message, form) { * @param {string} title Title for show. * @param {string} message Base64 encoded message for show. */ -function showAPIToken(title, message) { +function showAPIToken(title, message_a, token, message_b) { + var message = + message_a + + ' 
' + + atob(token) + + "
 " + + message_b; confirmDialog({ title: title, - message: atob(message), + message: message, hideCancelButton: true }); } @@ -2296,16 +2308,21 @@ var formatterDataVerticalBar = function(value, ctx) { // Show about section $(document).ready(function() { - $("#icon_about").click(function() { - $("#icon_about").addClass("selected"); + $("[id^='icon_about']").click(function() { + $("[id^='icon_about']").addClass("selected"); // Hidden tips modal. $(".window").css("display", "none"); + var type_about = "about_operation"; + if ($(this).attr("id") === "icon_about") { + type_about = "about"; + } + jQuery.post( "ajax.php", { page: "include/functions_menu", - about: "true" + [type_about]: "true" }, function(data) { $("div.ui-dialog").remove(); @@ -2319,35 +2336,66 @@ $(document).ready(function() { ); }); - function openAbout() { - $("#about-tabs").dialog({ - // title: "About", - resizable: false, - draggable: false, - modal: true, - show: { - effect: "fade", - duration: 200 - }, - hide: { - effect: "fade", - duration: 200 - }, - closeOnEscape: true, - width: 700, - height: 450, + function openAbout(section = "management") { + if (section === "management") { + $("#about-tabs").dialog({ + // title: "About", + resizable: false, + draggable: false, + modal: true, + show: { + effect: "fade", + duration: 200 + }, + hide: { + effect: "fade", + duration: 200 + }, + closeOnEscape: true, + width: 700, + height: 450, - create: function() { - $("#about-tabs").tabs({}); - $(".ui-dialog-titlebar").remove(); + create: function() { + $("#about-tabs").tabs({}); + $(".ui-dialog-titlebar").remove(); - $("#about-close").click(function() { - $("#about-tabs").dialog("close"); - $("div.ui-dialog").remove(); - $("#icon_about").removeClass("selected"); - }); - } - }); + $("#about-close").click(function() { + $("#about-tabs").dialog("close"); + $("div.ui-dialog").remove(); + $("#icon_about").removeClass("selected"); + }); + } + }); + } else if (section === "operation") { + $("#about-tabs").dialog({ + // title: "About", + resizable: false, + draggable: false, + modal: true, + show: { + effect: "fade", + duration: 200 + }, + hide: { + effect: "fade", + duration: 200 + }, + closeOnEscape: true, + width: 700, + height: 450, + + create: function() { + $("#about-tabs").tabs({}); + $(".ui-dialog-titlebar").remove(); + + $("#about-close").click(function() { + $("#about-tabs").dialog("close"); + $("div.ui-dialog").remove(); + $("#icon_about_operation").removeClass("selected"); + }); + } + }); + } } }); diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 2092d30589..6c31136c34 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -55,7 +55,7 @@ function show_event_dialog(event, dialog_page) { title: event.evento, resizable: true, draggable: true, - modal: true, + modal: false, minWidth: 875, minHeight: 600, close: function() { @@ -484,7 +484,7 @@ function event_comment(current_event) { success: function() { $("#button-comment_button").removeAttr("disabled"); $("#response_loading").hide(); - $("#link_comments").click(); + $("#button-filter_comments_button").click(); } }); @@ -943,6 +943,185 @@ function process_buffers(buffers) { } } +function openSoundEventsDialogModal(settings, dialog_parameters, reload) { + let mode = $("#hidden-mode_alert").val(); + if (reload != false) { + if (mode == 0) { + let filter_id = $("#filter_id option:selected").val(); + let interval = $("#interval option:selected").val(); + let time_sound = $("#time_sound option:selected").val(); + let sound_id = $("#sound_id option:selected").val(); + let parameters = { + filter_id: filter_id, + interval: interval, + time_sound: time_sound, + sound_id: sound_id, + mode: mode + }; + parameters = JSON.stringify(parameters); + parameters = btoa(parameters); + let url = + window.location + "&settings=" + settings + "¶meters=" + parameters; + $(location).attr("href", url); + } else { + let url = window.location + "&settings=" + settings; + $(location).attr("href", url); + } + } else { + openSoundEventsDialog(settings, dialog_parameters, reload); + } +} + +function openSoundEventsDialog(settings, dialog_parameters, reload) { + let encode_settings = settings; + if (reload == undefined) { + reload = true; + } + if (dialog_parameters != undefined) { + dialog_parameters = JSON.parse(atob(dialog_parameters)); + } + settings = JSON.parse(atob(settings)); + // Check modal exists and is open. + if ( + $("#modal-sound").hasClass("ui-dialog-content") && + $("#modal-sound").dialog("isOpen") + ) { + $(".ui-dialog-titlebar-minimize").trigger("click"); + return; + } + //Modify button + $("#minimize_arrow_event_sound").removeClass("arrow_menu_up"); + $("#minimize_arrow_event_sound").addClass("arrow_menu_down"); + $("#minimize_arrow_event_sound").show(); + + // Initialize modal. + $("#modal-sound") + .empty() + .dialog({ + title: settings.title, + resizable: false, + modal: false, + width: 600, + height: 600, + open: function() { + $.ajax({ + method: "post", + url: settings.url, + data: { + page: settings.page, + drawConsoleSound: 1 + }, + dataType: "html", + success: function(data) { + $("#modal-sound").append(data); + $("#tabs-sound-modal").tabs({ + disabled: [1] + }); + + // Test sound. + $("#button-melody_sound").click(function() { + var sound = false; + if ($("#id_sound_event").length == 0) { + sound = true; + } + + test_sound_button(sound, settings.urlSound); + }); + + // Play Stop. + $("#button-start-search").click(function() { + if (reload == true) { + openSoundEventsDialogModal(encode_settings, 0, reload); + } + var mode = $("#hidden-mode_alert").val(); + var action = false; + if (mode == 0) { + action = true; + } + if ($("#button-start-search").hasClass("play")) { + $("#modal-sound").css({ + height: "500px" + }); + $("#modal-sound") + .parent() + .css({ + height: "550px" + }); + } else { + $("#modal-sound").css({ + height: "450px" + }); + $("#modal-sound") + .parent() + .css({ + height: "500px" + }); + } + + action_events_sound(action, settings); + }); + + if (reload == false && dialog_parameters != undefined) { + if ($("#button-start-search").hasClass("play")) { + $("#filter_id").val(dialog_parameters["filter_id"]); + $("#interval").val(dialog_parameters["interval"]); + $("#time_sound").val(dialog_parameters["time_sound"]); + $("#sound_id").val(dialog_parameters["sound_id"]); + + $("#filter_id").trigger("change"); + $("#interval").trigger("change"); + $("#time_sound").trigger("change"); + $("#sound_id").trigger("change"); + + $("#button-start-search").trigger("click"); + } + } + + // Silence Alert. + $("#button-no-alerts").click(function() { + if ($("#button-no-alerts").hasClass("silence-alerts") === true) { + // Remove audio. + remove_audio(); + + // Clean events. + $("#tabs-sound-modal .elements-discovered-alerts ul").empty(); + $("#tabs-sound-modal .empty-discovered-alerts").removeClass( + "invisible_important" + ); + + // Clean progress. + $("#progressbar_time").empty(); + + // Change img button. + $("#button-no-alerts") + .removeClass("silence-alerts") + .addClass("alerts"); + // Change value button. + $("#button-no-alerts").val(settings.noAlert); + $("#button-no-alerts > span").text(settings.noAlert); + + // Background button. + $(".container-button-alert").removeClass("fired"); + + // New progress. + listen_event_sound(settings); + } + }); + }, + error: function(error) { + console.error(error); + } + }); + }, + close: function() { + $("#minimize_arrow_event_sound").hide(); + remove_audio(); + $(this).dialog("destroy"); + } + }) + .show(); +} + function openSoundEventModal(settings) { if ($("#hidden-metaconsole_activated").val() === "1") { var win = open( @@ -966,6 +1145,7 @@ function openSoundEventModal(settings) { } settings = JSON.parse(atob(settings)); + // Check modal exists and is open. if ( $("#modal-sound").hasClass("ui-dialog-content") && @@ -1045,10 +1225,12 @@ function add_audio(urlSound) { sound + "' autoplay='true' hidden='true' loop='false'>" ); + $("#button-sound_events_button").addClass("animation-blink"); } function remove_audio() { $(".actions-sound-modal audio").remove(); + $("#button-sound_events_button").removeClass("animation-blink"); } function listen_event_sound(settings) { @@ -1064,6 +1246,37 @@ function listen_event_sound(settings) { } function check_event_sound(settings) { + // Update elements time. + $(".elements-discovered-alerts ul li").each(function() { + let element_time = $(this) + .children(".li-hidden") + .val(); + let obj_time = new Date(element_time); + let current_dt = new Date(); + let timestamp = current_dt.getTime() - obj_time.getTime(); + timestamp = timestamp / 1000; + if (timestamp <= 60) { + timestamp = Math.round(timestamp) + " seconds"; + } else if (timestamp <= 3600) { + let minute = Math.floor((timestamp / 60) % 60); + minute = minute < 10 ? "0" + minute : minute; + let second = Math.floor(timestamp % 60); + second = second < 10 ? "0" + second : second; + timestamp = minute + " minutes " + second + " seconds"; + } else { + let hour = Math.floor(timestamp / 3600); + hour = hour < 10 ? "0" + hour : hour; + let minute = Math.floor((timestamp / 60) % 60); + minute = minute < 10 ? "0" + minute : minute; + let second = Math.round(timestamp % 60); + second = second < 10 ? "0" + second : second; + timestamp = hour + " hours " + minute + " minutes " + second + " seconds"; + } + $(this) + .children(".li-time") + .children("span") + .html(timestamp); + }); jQuery.post( settings.url, { @@ -1117,7 +1330,13 @@ function check_event_sound(settings) { "beforeend", '
' + element.timestamp + "
" ); - $("#tabs-sound-modal .elements-discovered-alerts ul").append(li); + li.insertAdjacentHTML( + "beforeend", + '' + ); + $("#tabs-sound-modal .elements-discovered-alerts ul").prepend(li); }); // -100 delay sound. @@ -1180,3 +1399,334 @@ function getUrlAjax() { return $("#hidden-ajax_file_sound_console").val(); } } + +function addElement(name_select, id_modal) { + var modal = document.getElementById(id_modal); + var parent = $(modal).parent(); + $(modal).dialog({ + title: "Choose columns", + width: 330, + buttons: [ + { + class: + "ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next", + text: "Confirm", + click: function() { + $(modal) + .find("select option:selected") + .each(function(key, option) { + $("select[name='" + name_select + "']").append(option); + }); + var clone = $(modal).clone(); + $(modal) + .dialog("destroy") + .remove(); + $(clone).hide(); + $(parent).append(clone); + } + } + ], + close: function() { + var clone = $(modal).clone(); + $(modal) + .dialog("destroy") + .remove(); + $(clone).hide(); + $(parent).append(clone); + } + }); +} + +function removeElement(name_select, id_modal) { + var modal = document.getElementById(id_modal); + $("select[name='" + name_select + "'] option:selected").each(function( + key, + option + ) { + $(modal) + .find("select") + .append(option); + }); +} + +function get_table_events_tabs(event, filter) { + var custom_event_view_hr = $("#hidden-comments_events_max_hours_old").val(); + $.post({ + url: "ajax.php", + data: { + page: "include/ajax/events", + get_comments: 1, + event: event, + filter: filter, + custom_event_view_hr: custom_event_view_hr + }, + dataType: "html", + success: function(data) { + $("#extended_event_comments_page").empty(); + $("#extended_event_comments_page").html(data); + } + }); +} +// Define the minimize button functionality; +function hidden_dialog(dialog) { + setTimeout(function() { + $("#modal-sound").css("visibility", "hidden"); + dialog.css("z-index", "-1"); + }, 200); +} + +function show_dialog(dialog) { + setTimeout(function() { + $("#modal-sound").css("visibility", "visible"); + dialog.css("z-index", "1115"); + }, 50); +} + +/* +############################################################################# +## +## + Compacts the Modal Sound Dialog to a tiny toolbar +## + Dynamically adds a button which can reduce/reapply the dialog size +## + If alarm gets raised & minimized, the dialog window maximizes and the toolbar flashes red for 10 seconds. +## - Works fine until a link/action gets clicked. The Toolbar shifts to the bottom of the Modal-Sound Dialog. +## +############################################################################# +*/ + +$(document).ajaxSend(function(event, jqXHR, ajaxOptions) { + const requestBody = ajaxOptions.data; + try { + if (requestBody && requestBody.includes("drawConsoleSound=1")) { + console.log( + "AJAX request sent with drawConsoleSound=1:", + ajaxOptions.url + ); + + // Find the dialog element by the aria-describedby attribute + var dialog = $('[aria-describedby="modal-sound"]'); + + // Select the close button within the dialog + var closeButton = dialog.find(".ui-dialog-titlebar-close"); + + // Add the minimize button before the close button + var minimizeButton = $("