From ef30239cc611d37d494d8bc8e7669a861059786e Mon Sep 17 00:00:00 2001 From: marcos Date: Fri, 24 Apr 2020 16:43:18 +0200 Subject: [PATCH 01/15] add delete confirmation dialog --- pandora_console/views/dashboard/cell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/views/dashboard/cell.php b/pandora_console/views/dashboard/cell.php index ab7a9c4457..16631e10b5 100644 --- a/pandora_console/views/dashboard/cell.php +++ b/pandora_console/views/dashboard/cell.php @@ -58,7 +58,7 @@ if ($manageDashboards !== 0) { $output .= ' '; } - $output .= ''; + $output .= ''; $output .= html_print_image( 'images/input_delete_white.png', true, From ccd58897eed567b44792bc798163714900337a03 Mon Sep 17 00:00:00 2001 From: marcos Date: Mon, 27 Apr 2020 16:40:50 +0200 Subject: [PATCH 02/15] Add confirmation window --- .../include/javascript/pandora_dashboards.js | 14 ++++++++++++-- pandora_console/views/dashboard/cell.php | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 4cc52254c0..73e85ec2d4 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -244,8 +244,18 @@ function initialiceLayout(data) { } $("#delete-widget-" + id).click(function(event) { - var nodo = event.target.offsetParent; - deleteCell(id, nodo.parentNode); + // eslint-disable-next-line no-undef + confirmDialog({ + title: "Are you sure?", + message: "", + cancel: "Cancel", + ok: "Ok", + onAccept: function() { + // Continue execution. + var nodo = event.target.offsetParent; + deleteCell(id, nodo.parentNode); + } + }); }); $("#configure-widget-" + id).click(function() { diff --git a/pandora_console/views/dashboard/cell.php b/pandora_console/views/dashboard/cell.php index 16631e10b5..ab7a9c4457 100644 --- a/pandora_console/views/dashboard/cell.php +++ b/pandora_console/views/dashboard/cell.php @@ -58,7 +58,7 @@ if ($manageDashboards !== 0) { $output .= ' '; } - $output .= ''; + $output .= ''; $output .= html_print_image( 'images/input_delete_white.png', true, From d644714fcbf4802a5955bbc8ba55168159cd3cda Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 28 Apr 2020 01:00:18 +0200 Subject: [PATCH 03/15] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index b0e1dfd2fa..523181e2f2 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.745-200427 +Version: 7.0NG.745-200428 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index a18b44f7bb..755ad44239 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.745-200427" +pandora_version="7.0NG.745-200428" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index dcc75385d5..0e18dfdd7c 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.745'; -use constant AGENT_BUILD => '200427'; +use constant AGENT_BUILD => '200428'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 8ec5f51840..11fade9631 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.745 -%define release 200427 +%define release 200428 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 13df17a99f..7bc044126b 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.745 -%define release 200427 +%define release 200428 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 9346e31820..5f1c0c695f 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.745" -PI_BUILD="200427" +PI_BUILD="200428" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 34903208e7..c7c5a370ec 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200427} +{200428} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 4b8214678b..60999e7bcb 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.745(Build 200427)") +#define PANDORA_VERSION ("7.0NG.745(Build 200428)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 7ac9c876cb..0ea81cdbe2 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.745(Build 200427))" + VALUE "ProductVersion", "(7.0NG.745(Build 200428))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index af9777b590..0bf20c5534 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.745-200427 +Version: 7.0NG.745-200428 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index dd2d124fa0..714cdb78f5 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.745-200427" +pandora_version="7.0NG.745-200428" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index aaad3eac16..b5ef2ab619 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC200427'; +$build_version = 'PC200428'; $pandora_version = 'v7.0NG.745'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index fdec4bda99..e5d18e26cb 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index b86b94cc6c..5a35c1ee3b 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.745 -%define release 200427 +%define release 200428 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c47d8ec0d4..d56bb7210e 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.745 -%define release 200427 +%define release 200428 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index d84959849e..c76b610c95 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.745" -PI_BUILD="200427" +PI_BUILD="200428" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index ca35510679..5f0a7553c8 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.745 PS200427"; +my $version = "7.0NG.745 PS200428"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index f806e39455..9ce644e612 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.745 PS200427"; +my $version = "7.0NG.745 PS200428"; # save program name for logging my $progname = basename($0); From 8cd1c0b83f01c4ddcbbd5bba767c694a07faa84c Mon Sep 17 00:00:00 2001 From: marcos Date: Tue, 28 Apr 2020 10:12:20 +0200 Subject: [PATCH 04/15] add body message on confirmation modal --- pandora_console/include/javascript/pandora_dashboards.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 73e85ec2d4..83723c4718 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -247,7 +247,8 @@ function initialiceLayout(data) { // eslint-disable-next-line no-undef confirmDialog({ title: "Are you sure?", - message: "", + message: + "

If you delete it, will can't be recovered

", cancel: "Cancel", ok: "Ok", onAccept: function() { From 8d733398875d6cf83ba441b74eaa8fb42214c9f8 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 28 Apr 2020 10:37:09 +0200 Subject: [PATCH 05/15] Windows environment spaces in binary file names --- pandora_server/lib/PandoraFMS/Tools.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 10f57b1e15..c3182f9d41 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -1458,7 +1458,7 @@ sub pandora_block_ping($@) { if (-x $pa_config->{'fping'}) { # fping timeout in milliseconds - $cmd = $pa_config->{'fping'} . " -a -q -t " . (1000 * $pa_config->{'networktimeout'}) . " " . (join (' ', @hosts)); + $cmd = '"'.$pa_config->{'fping'} . '" -a -q -t ' . (1000 * $pa_config->{'networktimeout'}) . " " . (join (' ', @hosts)); @output = `$cmd 2>$DEVNULL`; } else { # Ping scan From 72f9c051eb1f8af5ba13fc61b7ea6b9f8ef0c544 Mon Sep 17 00:00:00 2001 From: marcos Date: Tue, 28 Apr 2020 10:44:13 +0200 Subject: [PATCH 06/15] changed message confirmation dialog --- pandora_console/include/javascript/pandora_dashboards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 83723c4718..842bd5daaa 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -248,7 +248,7 @@ function initialiceLayout(data) { confirmDialog({ title: "Are you sure?", message: - "

If you delete it, will can't be recovered

", + "

All changes made to this widget will be lost

", cancel: "Cancel", ok: "Ok", onAccept: function() { From 744bac67362e0b431f1c268f6ae5c6e22edfe267 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 28 Apr 2020 11:21:33 +0200 Subject: [PATCH 07/15] avoid problems while encoding json --- .../lib/PandoraFMS/DiscoveryServer.pm | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 8cee68d538..55764c5ddd 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -1684,17 +1684,23 @@ sub PandoraFMS::Recon::Base::update_progress ($$) { my ($self, $progress) = @_; my $stats = {}; - if (defined($self->{'summary'}) && $self->{'summary'} ne '') { - $stats->{'summary'} = $self->{'summary'}; + eval { + local $SIG{__DIE__}; + if (defined($self->{'summary'}) && $self->{'summary'} ne '') { + $stats->{'summary'} = $self->{'summary'}; + } + + $stats->{'step'} = $self->{'step'}; + $stats->{'c_network_name'} = $self->{'c_network_name'}; + $stats->{'c_network_percent'} = $self->{'c_network_percent'}; + + # Store progress, last contact and overall status. + db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?', + time (), $progress, encode_json($stats), $self->{'task_id'}); + }; + if ($@) { + $self->call('Message', "Problems updating progress $@"); } - - $stats->{'step'} = $self->{'step'}; - $stats->{'c_network_name'} = $self->{'c_network_name'}; - $stats->{'c_network_percent'} = $self->{'c_network_percent'}; - - # Store progress, last contact and overall status. - db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?', - time (), $progress, encode_json($stats), $self->{'task_id'}); } 1; From 3ad1b5f2e3a23b099e5064b4bd3e43798a80d0f8 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 28 Apr 2020 12:19:46 +0200 Subject: [PATCH 08/15] trace if failed to encode json (summary) --- pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 55764c5ddd..631194e212 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -1694,12 +1694,16 @@ sub PandoraFMS::Recon::Base::update_progress ($$) { $stats->{'c_network_name'} = $self->{'c_network_name'}; $stats->{'c_network_percent'} = $self->{'c_network_percent'}; + my %t = %{$stats}; + # Store progress, last contact and overall status. db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?', - time (), $progress, encode_json($stats), $self->{'task_id'}); + time (), $progress, encode_json(\%t), $self->{'task_id'}); }; if ($@) { - $self->call('Message', "Problems updating progress $@"); + $self->call('message', "Problems updating progress $@", 5); + db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?', + time (), $progress, "{}", $self->{'task_id'}); } } From 2bfee57a67efb1390876e5509bce9efc783dc973 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 28 Apr 2020 12:46:13 +0200 Subject: [PATCH 09/15] perl multilib json workaround --- .../lib/PandoraFMS/DiscoveryServer.pm | 16 +++--- pandora_server/lib/PandoraFMS/Tools.pm | 54 +++++++++++++++++++ 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 631194e212..b8b6f228e9 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -26,7 +26,7 @@ use Thread::Semaphore; use IO::Socket::INET; use POSIX qw(strftime ceil); -use JSON qw(decode_json encode_json); +use JSON; use Encode qw(encode_utf8); use MIME::Base64; @@ -336,14 +336,14 @@ sub exec_recon_script ($$$) { my $macros = safe_output($task->{'macros'}); - # \r and \n should be escaped for decode_json(). + # \r and \n should be escaped for p_decode_json(). $macros =~ s/\n/\\n/g; $macros =~ s/\r/\\r/g; my $decoded_macros; if ($macros) { eval { - $decoded_macros = decode_json(encode_utf8($macros)); + $decoded_macros = p_decode_json($pa_config, $macros); }; } @@ -980,7 +980,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { my $data; eval { local $SIG{__DIE__}; - $data = decode_json(decode_base64($row->{'data'})); + $data = p_decode_json($self->{'pa_config'}, decode_base64($row->{'data'})); }; if ($@) { $self->call('message', "ERROR JSON: $@", 3); @@ -1245,7 +1245,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { eval { local $SIG{__DIE__}; $encoded = encode_base64( - encode_json($data) + p_encode_json($self->{'pa_config'}, $data) ); }; @@ -1344,7 +1344,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) { eval { local $SIG{__DIE__}; $encoded = encode_base64( - encode_json($self->{'agents_found'}->{$addr}) + p_encode_json($self->{'pa_config'}, $self->{'agents_found'}->{$addr}) ); }; @@ -1694,11 +1694,9 @@ sub PandoraFMS::Recon::Base::update_progress ($$) { $stats->{'c_network_name'} = $self->{'c_network_name'}; $stats->{'c_network_percent'} = $self->{'c_network_percent'}; - my %t = %{$stats}; - # Store progress, last contact and overall status. db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?', - time (), $progress, encode_json(\%t), $self->{'task_id'}); + time (), $progress, p_encode_json($self->{'pa_config'}, $stats), $self->{'task_id'}); }; if ($@) { $self->call('message', "Problems updating progress $@", 5); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index c3182f9d41..4b1486f0ef 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -31,6 +31,9 @@ use LWP::UserAgent; use threads; use threads::shared; +use JSON; +use Encode qw/decode_utf8 encode_utf8/; + use lib '/usr/lib/perl5'; use PandoraFMS::Sendmail; @@ -152,6 +155,8 @@ our @EXPORT = qw( dateTimeToTimestamp get_user_agent ui_get_full_url + p_encode_json + p_decode_json ); # ID of the different servers @@ -2353,6 +2358,55 @@ sub ui_get_full_url { } +################################################################################ +# Encodes a json. +################################################################################ +sub p_encode_json { + my ($pa_config, $data) = @_; + + # Initialize JSON manager. + my $json = JSON->new->allow_nonref; + my $encoded_data; + + eval { + local $SIG{__DIE__}; + if ($JSON::VERSION > 2.90) { + $encoded_data = $json->encode($data); + } else { + $encoded_data = encode_utf8($json->encode($data)); + } + }; + if ($@){ + if (defined($data)) { + logger($pa_config, 'Failed to encode data: '.$@, 5); + } + } + + return $encoded_data; +} + +################################################################################ +# Dencodes a json. +################################################################################ +sub p_decode_json { + my ($pa_config, $data) = @_; + + # Initialize JSON manager. + my $json = JSON->new->allow_nonref; + my $decoded_data; + + if ($JSON::VERSION > 2.90) { + $decoded_data = $json->decode($data); + } else { + if (!is_empty($decoded_data)) { + $decoded_data = decode_json($data); + } + } + + return $decoded_data; +} + + 1; __END__ From dfa31d5227746e79de02e086fb0a8bd1787f7a9b Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 28 Apr 2020 13:26:57 +0200 Subject: [PATCH 10/15] updates --- pandora_server/lib/PandoraFMS/Recon/Base.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index 4b3a920f9f..bbe7802097 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -2109,16 +2109,16 @@ sub snmp_get_value($$$) { my ($self, $device, $oid) = @_; my $effective_oid = $oid; - if (is_enabled($self->{'translate_snmp'})) { + if (is_enabled($self->{'translate_snmp'}) && $oid !~ /^[\.\d]+$/) { $effective_oid = `snmptranslate $oid -On 2>$DEVNULL`; - chomp($effective_oid); + $effective_oid =~ s/[\r\n]//g; } my @output = $self->snmp_get($device, $effective_oid); - + foreach my $line (@output) { - chomp($line); - return $1 if ($line =~ /^$effective_oid\s+=\s+\S+:\s+(.*)$/); + $line =~ s/[\r\n]//g; + return $1 if ($line =~ /^$effective_oid\s+=\s+\S+:\s+(.*)/); } return undef; From bcc68c00342ad946d8767d20ba5852a8e488784d Mon Sep 17 00:00:00 2001 From: marcos Date: Tue, 28 Apr 2020 13:42:27 +0200 Subject: [PATCH 11/15] add modal on Webchat --- pandora_console/operation/users/webchat.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandora_console/operation/users/webchat.php b/pandora_console/operation/users/webchat.php index 809ccaa000..86b2da9a3c 100644 --- a/pandora_console/operation/users/webchat.php +++ b/pandora_console/operation/users/webchat.php @@ -111,6 +111,18 @@ echo "
".html_print_button( var first_time = true; $(document).ready(function() { + confirmDialog({ + title: "Attention", + message: + "

This feature will be removed from the console in the next version of Pandora FMS.

If you want to keep the history, make a backup.

", + cancel: "Cancel", + ok: "Ok", + onAccept: function() { + // Continue execution. + var nodo = event.target.offsetParent; + deleteCell(id, nodo.parentNode); + } + }); $("input[name=\"message_box\"]").keydown(function(e) { //Enter key. if (e.keyCode == 13) { From 2d48c6737743debede14bb751b187b03ea886388 Mon Sep 17 00:00:00 2001 From: marcos Date: Tue, 28 Apr 2020 13:56:43 +0200 Subject: [PATCH 12/15] add modal on Webchat --- pandora_console/operation/users/webchat.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandora_console/operation/users/webchat.php b/pandora_console/operation/users/webchat.php index 86b2da9a3c..94eb12ddcf 100644 --- a/pandora_console/operation/users/webchat.php +++ b/pandora_console/operation/users/webchat.php @@ -118,9 +118,7 @@ echo "
".html_print_button( cancel: "Cancel", ok: "Ok", onAccept: function() { - // Continue execution. - var nodo = event.target.offsetParent; - deleteCell(id, nodo.parentNode); + // Nothing to do. } }); $("input[name=\"message_box\"]").keydown(function(e) { From 456848485e0ed2d3e49369b61b677d40a7714592 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 29 Apr 2020 01:00:16 +0200 Subject: [PATCH 13/15] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 523181e2f2..b708dce8e6 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.745-200428 +Version: 7.0NG.745-200429 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 755ad44239..69f07f1867 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.745-200428" +pandora_version="7.0NG.745-200429" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 0e18dfdd7c..33c760d6e7 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.745'; -use constant AGENT_BUILD => '200428'; +use constant AGENT_BUILD => '200429'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 11fade9631..6cca8e9045 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.745 -%define release 200428 +%define release 200429 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 7bc044126b..4468620be4 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.745 -%define release 200428 +%define release 200429 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 5f1c0c695f..63be0a81a0 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.745" -PI_BUILD="200428" +PI_BUILD="200429" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index c7c5a370ec..842fab367d 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200428} +{200429} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 60999e7bcb..33bb9d924c 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.745(Build 200428)") +#define PANDORA_VERSION ("7.0NG.745(Build 200429)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 0ea81cdbe2..afad38a508 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.745(Build 200428))" + VALUE "ProductVersion", "(7.0NG.745(Build 200429))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 0bf20c5534..80657291b8 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.745-200428 +Version: 7.0NG.745-200429 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 714cdb78f5..112641ee54 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.745-200428" +pandora_version="7.0NG.745-200429" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index b5ef2ab619..5f9108d553 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC200428'; +$build_version = 'PC200429'; $pandora_version = 'v7.0NG.745'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index e5d18e26cb..9709ddabc3 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 5a35c1ee3b..5ae8014aa5 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.745 -%define release 200428 +%define release 200429 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index d56bb7210e..a4ac8e8a2d 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.745 -%define release 200428 +%define release 200429 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index c76b610c95..4b1c0a8624 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.745" -PI_BUILD="200428" +PI_BUILD="200429" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 5f0a7553c8..cd31864126 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.745 PS200428"; +my $version = "7.0NG.745 PS200429"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 9ce644e612..4f32707308 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.745 PS200428"; +my $version = "7.0NG.745 PS200429"; # save program name for logging my $progname = basename($0); From 8a019bd8f4e2e73422897016e99896df9f94759c Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 30 Apr 2020 01:00:16 +0200 Subject: [PATCH 14/15] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.rhel7.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index b708dce8e6..47c033edb1 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.745-200429 +Version: 7.0NG.745-200430 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 69f07f1867..fa4ac528ad 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.745-200429" +pandora_version="7.0NG.745-200430" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 33c760d6e7..40a8cce5bd 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.745'; -use constant AGENT_BUILD => '200429'; +use constant AGENT_BUILD => '200430'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 6cca8e9045..417fdbd25f 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.745 -%define release 200429 +%define release 200430 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 4468620be4..3b757bcb0b 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.745 -%define release 200429 +%define release 200430 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 63be0a81a0..20843fd36b 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.745" -PI_BUILD="200429" +PI_BUILD="200430" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 842fab367d..2489f4a42a 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200429} +{200430} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 33bb9d924c..8af31057fa 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.745(Build 200429)") +#define PANDORA_VERSION ("7.0NG.745(Build 200430)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index afad38a508..6d1c21ee76 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.745(Build 200429))" + VALUE "ProductVersion", "(7.0NG.745(Build 200430))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 80657291b8..5c07d48952 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.745-200429 +Version: 7.0NG.745-200430 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 112641ee54..f32adfe212 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.745-200429" +pandora_version="7.0NG.745-200430" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 5f9108d553..35e1ac44bb 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC200429'; +$build_version = 'PC200430'; $pandora_version = 'v7.0NG.745'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 9709ddabc3..dab768e0c2 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 5ae8014aa5..06451be8cb 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.745 -%define release 200429 +%define release 200430 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index a4ac8e8a2d..ab7c0bde25 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.745 -%define release 200429 +%define release 200430 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 4b1c0a8624..53e8a13159 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.745" -PI_BUILD="200429" +PI_BUILD="200430" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index cd31864126..c45083b994 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.745 PS200429"; +my $version = "7.0NG.745 PS200430"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 4f32707308..fd8770cfc8 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.745 PS200429"; +my $version = "7.0NG.745 PS200430"; # save program name for logging my $progname = basename($0); From c308d49c255801b2820b549899f2ebb7c34c8cc9 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 30 Apr 2020 14:08:56 +0200 Subject: [PATCH 15/15] Fix retrocompatibility --- .../include/functions_reporting.php | 8 +- .../include/lib/Dashboard/Manager.php | 11 + .../include/lib/Dashboard/Widget.php | 30 +- .../lib/Dashboard/Widgets/agent_module.php | 567 +----------------- .../lib/Dashboard/Widgets/alerts_fired.php | 31 +- .../include/lib/Dashboard/Widgets/clock.php | 27 +- .../lib/Dashboard/Widgets/custom_graph.php | 49 +- .../lib/Dashboard/Widgets/events_list.php | 83 ++- .../include/lib/Dashboard/Widgets/example.php | 19 +- .../Widgets/graph_module_histogram.php | 69 ++- .../lib/Dashboard/Widgets/groups_status.php | 27 +- .../Dashboard/Widgets/maps_made_by_user.php | 27 +- .../lib/Dashboard/Widgets/maps_status.php | 27 +- .../lib/Dashboard/Widgets/module_icon.php | 89 ++- .../lib/Dashboard/Widgets/module_status.php | 89 ++- .../Dashboard/Widgets/module_table_value.php | 65 +- .../lib/Dashboard/Widgets/module_value.php | 73 ++- .../lib/Dashboard/Widgets/monitor_health.php | 25 +- .../lib/Dashboard/Widgets/network_map.php | 51 +- .../include/lib/Dashboard/Widgets/post.php | 27 +- .../include/lib/Dashboard/Widgets/reports.php | 27 +- .../lib/Dashboard/Widgets/service_map.php | 35 +- .../lib/Dashboard/Widgets/single_graph.php | 61 +- .../lib/Dashboard/Widgets/sla_percent.php | 79 ++- .../Dashboard/Widgets/system_group_status.php | 89 ++- .../lib/Dashboard/Widgets/tactical.php | 45 +- .../include/lib/Dashboard/Widgets/top_n.php | 6 +- .../Widgets/top_n_events_by_group.php | 57 +- .../Widgets/top_n_events_by_module.php | 70 ++- .../lib/Dashboard/Widgets/tree_view.php | 130 +++- .../include/lib/Dashboard/Widgets/url.php | 27 +- .../lib/Dashboard/Widgets/wux_transaction.php | 49 +- .../Widgets/wux_transaction_stats.php | 47 +- pandora_console/include/styles/dashboards.css | 4 + pandora_console/views/dashboard/cell.php | 1 + 35 files changed, 1503 insertions(+), 618 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index e2ea109bca..98eb1b5025 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -8993,22 +8993,22 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru if ($html) { $tdata[0] = '
- '.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), $servers['down']), true).''.progress_bar($servers['health'], $width, $height, '', 0).'
'; + '.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), (int) $servers['down']), true).''.progress_bar($servers['health'], $width, $height, '', 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; $tdata[0] = '
- '.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), $data['monitor_not_normal']), true).''.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'
'; + '.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), (int) $data['monitor_not_normal']), true).''.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; $tdata[0] = '
- '.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), $data['monitor_not_init']), true).''.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'
'; + '.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), (int) $data['monitor_not_init']), true).''.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; $tdata[0] = '
- '.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), $data['monitor_alerts_fired']), true).''.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'
'; + '.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), (int) $data['monitor_alerts_fired']), true).''.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 8671e64e3a..cd03419a60 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -1042,6 +1042,17 @@ class Manager $cellData['id_widget'] = $this->widgetId; } } + + $instance = $this->instanceWidget(); + $cellData['options'] = $instance->decoders( + $instance->getOptionsWidget() + ); + + if (isset($cellData['options']['title']) === false) { + $cellData['options']['title'] = $instance->getDescription(); + } + + $cellData['options'] = json_encode($cellData['options']); } View::render( diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index 9e3d0c3ead..f8dbffe39b 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -59,7 +59,7 @@ class Widget $cellClass = new Cell($this->cellId, $this->dashboardId); $this->dataCell = $cellClass->get(); - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); } return $this; @@ -535,6 +535,34 @@ class Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder):array + { + $values = []; + + if (isset($decoder['title']) === true) { + $values['title'] = $decoder['title']; + } + + if (isset($decoder['background-color']) === true) { + $values['background'] = $decoder['background-color']; + } + + if (isset($decoder['background']) === true) { + $values['background'] = $decoder['background']; + } + + return $values; + + } + + /** * Size Cell. * diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index e9f0c4c0a2..96cc7c7d92 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -169,489 +169,11 @@ class AgentModuleWidget extends Widget // This forces at least a first configuration. $this->configurationRequired = false; - if (empty($this->values['moduleId']) === true) { - $this->configurationRequired = true; - } $this->overflow_scrollbars = false; } - /* - // DO NOT CHANGE THIS VALUE. - $id_group = isset($this->options['search_group_'.$id]) ? $this->options['search_group_'.$id] : 0; - - $agent_conf_key = 'id_agent_'.$id; - $id_agent = $this->options[$agent_conf_key]; - $module_conf_key = 'id_module_'.$id; - $id_module = $this->options[$module_conf_key]; - $recursion_checked = $this->options['recursion']; - - $this->add_configuration( - 'search_group_'.$id, - __('Group'), - OPTION_TREE_GROUP_SELECT - ); - - $list_agents = agents_get_group_agents( - $id_group, - false, - 'lower', - false, - $recursion_checked - ); - - if (!isset($this->options['selection_agent_module_'.$id]) - || $this->options['selection_agent_module_'.$id] == '' - || $this->options['selection_agent_module_'.$id] == null - ) { - $selection_agent_module = 'common'; - } else { - $selection_agent_module = $this->options['selection_agent_module_'.$id]; - } - - $limit_common = ''; - $sql = false; - if (!empty($id_agent)) { - if ($selection_agent_module == 'common') { - $limit_common = sprintf( - ' AND (SELECT count(nombre) - FROM tagente_modulo t2 - WHERE t2.delete_pending = 0 - AND t1.nombre = t2.nombre - AND t2.id_agente IN (%s)) = (%d)', - implode(',', (array) $id_agent), - count($id_agent) - ); - } - - $sql = sprintf( - 'SELECT DISTINCT nombre - FROM tagente_modulo t1 - WHERE id_agente IN (%s) - AND delete_pending = 0 %s ORDER BY nombre', - implode(', ', (array) $id_agent), - $limit_common - ); - } - - if (empty($id_module)) { - $this->options[$module_conf_key] = index_array( - db_get_all_rows_sql($sql), - 'nombre', - 'nombre' - ); - } - - $this->add_configuration( - 'recursion', - __('Recursion'), - OPTION_BOOLEAN - ); - - $this->add_configuration( - $agent_conf_key, - __('Agent'), - OPTION_SELECT_MULTISELECTION, - ['values' => $list_agents] - ); - - $this->add_configuration( - 'selection_agent_module_'.$id, - __('Show common modules'), - OPTION_SINGLE_SELECT, - [ - 'values' => [ - 'common' => __('Show common modules'), - 'all' => __('Show all modules'), - ], - ] - ); - - $this->add_configuration( - $module_conf_key, - __('Module'), - OPTION_SELECT_MULTISELECTION, - [ - 'values' => index_array( - db_get_all_rows_sql($sql), - 'nombre', - 'nombre' - ), - ] - ); - - $this->add_configuration( - '', - '', - OPTION_CUSTOM_INPUT, - [ - 'widget' => $this, - 'entire_row' => true, - 'update' => false, - ] - ); - */ - - - function print_configuration_custom($return=true) - { - $id = $this->getId(); - ob_start(); - - ?> - - $module) { - if ($module == $name) { - $modules_by_name[($cont - 1)]['id'][] = $key; - } else { - $name = $module; - $modules_by_name[$cont]['name'] = $name; - $modules_by_name[$cont]['id'][] = $key; - $cont ++; - } - } - - foreach ($agents as $agent) { - if (!users_access_to_agent($agent['id_agente'])) { - continue; - } - - $row = []; - $row['agent_status'] = agents_get_status($agent['id_agente'], true); - $row['agent_name'] = $agent['nombre']; - $row['agent_alias'] = $agent['alias']; - $agent_modules = agents_get_modules($agent['id_agente']); - - $row['modules'] = []; - foreach ($modules_by_name as $module) { - $row['modules'][$module['name']] = null; - foreach ($module['id'] as $module_id) { - if (array_key_exists($module_id, $agent_modules)) { - $row['modules'][$module['name']] = modules_get_agentmodule_status($module_id); - break; - } - } - } - - $return[] = $row; - } - - return $return; - } - - - public function generate_view_agent_module($visual_data) - { - $table_data = '
'; - $table_data .= ''; - - if (!empty($visual_data)) { - $table_data .= ''; - - $array_names = []; - - foreach ($visual_data as $data) { - foreach ($data['modules'] as $module_name => $module) { - if ($module === null || in_array($module_name, $array_names)) { - continue; - } else { - $array_names[] = $module_name; - } - } - } - - natcasesort($array_names); - foreach ($array_names as $module_name) { - $file_name = ui_print_truncate_text( - $module_name, - 'module_small', - false, - true, - false, - '...' - ); - $table_data .= ''; - } - - foreach ($visual_data as $row) { - $table_data .= ""; - switch ($row['agent_status']) { - case AGENT_STATUS_ALERT_FIRED: - $rowcolor = COL_ALERTFIRED; - $textcolor = '#000'; - break; - - case AGENT_STATUS_CRITICAL: - $rowcolor = COL_CRITICAL; - $textcolor = '#FFF'; - break; - - case AGENT_STATUS_WARNING: - $rowcolor = COL_WARNING; - $textcolor = '#000'; - break; - - case AGENT_STATUS_NORMAL: - $rowcolor = COL_NORMAL; - $textcolor = '#FFF'; - break; - - case AGENT_STATUS_UNKNOWN: - case AGENT_STATUS_ALL: - default: - $rowcolor = COL_UNKNOWN; - $textcolor = '#FFF'; - break; - } - - $file_name = ui_print_truncate_text( - $row['agent_alias'], - 'agent_small', - false, - true, - false, - '...' - ); - $table_data .= "'; - - foreach ($row['modules'] as $module_name => $module) { - if ($module === null) { - if (in_array($module_name, $array_names)) { - $table_data .= ""; - } else { - continue; - } - } else { - $table_data .= "'; - } - } - - $table_data .= ''; - } - } else { - $table_data .= ''; - } - - $table_data .= '
'.__('Agents').' / '.__('Modules').''.$file_name.'
".$file_name.'"; - switch ($module) { - case AGENT_STATUS_NORMAL: - $table_data .= ui_print_status_image( - 'module_ok.png', - __( - '%s in %s : NORMAL', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case AGENT_STATUS_CRITICAL: - $table_data .= ui_print_status_image( - 'module_critical.png', - __( - '%s in %s : CRITICAL', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case AGENT_STATUS_WARNING: - $table_data .= ui_print_status_image( - 'module_warning.png', - __( - '%s in %s : WARNING', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case AGENT_STATUS_UNKNOWN: - $table_data .= ui_print_status_image( - 'module_unknown.png', - __( - '%s in %s : UNKNOWN', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case 4: - $table_data .= ui_print_status_image( - 'module_no_data.png', - __( - '%s in %s : Not initialize', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - - case AGENT_STATUS_ALERT_FIRED: - default: - $table_data .= ui_print_status_image( - 'module_alertsfired.png', - __( - '%s in %s : ALERTS FIRED', - $module_name, - $row['agent_alias'] - ), - true, - [ - 'width' => '20px', - 'height' => '20px', - ] - ); - break; - } - - $table_data .= '
'.__('Please configure this widget before usage').'
'; - $table_data .= '
'; - - return $table_data; - } - - /** * Generates inputs for form (specific). * @@ -666,38 +188,12 @@ class AgentModuleWidget extends Widget // Retrieve global - common inputs. $inputs = parent::getFormInputs(); - // Autocomplete agents. $inputs[] = [ - 'label' => __('Agent'), - 'arguments' => [ - 'type' => 'autocomplete_agent', - 'name' => 'agentAlias', - 'id_agent_hidden' => $values['agentId'], - 'name_agent_hidden' => 'agentId', - 'server_id_hidden' => $values['metaconsoleId'], - 'name_server_hidden' => 'metaconsoleId', - 'return' => true, - 'module_input' => true, - 'module_name' => 'moduleId', - 'module_none' => false, - 'size' => 0, - ], - ]; - - // Autocomplete module. - $inputs[] = [ - 'label' => __('Module'), - 'arguments' => [ - 'type' => 'autocomplete_module', - 'fields' => $fields, - 'name' => 'moduleId', - 'selected' => $values['moduleId'], - 'return' => true, - 'sort' => false, - 'agent_id' => $values['agentId'], - 'metaconsole_id' => $values['metaconsoleId'], - 'style' => 'width: inherit;', - ], + 'label' => \ui_print_error_message( + __('This widget has been removed'), + '', + true + ), ]; return $inputs; @@ -714,12 +210,6 @@ class AgentModuleWidget extends Widget // Retrieve global - common inputs. $values = parent::getPost(); - $values['agentId'] = \get_parameter('agentId', 0); - $values['metaconsoleId'] = \get_parameter('metaconsoleId', 0); - $values['moduleId'] = \get_parameter('moduleId', 0); - $values['period'] = \get_parameter('period', 0); - $values['showLegend'] = \get_parameter_switch('showLegend'); - return $values; } @@ -733,45 +223,14 @@ class AgentModuleWidget extends Widget { global $config; - // TODO:XXX WIP. - return 'WIP in this widget'; - /* - $this->body = ''; - $id_agent = $this->options['id_agent_'.$this->getId()]; - if (! check_acl($config['id_user'], 0, 'AR')) { - $this->body = __('You don\'t have access'); - return; - } - - $id_module = $this->options['id_module_'.$this->getId()]; - if ($id_agent) { - $sql = 'SELECT id_agente,nombre,alias - FROM tagente - WHERE id_agente IN ('.implode(',', $id_agent).') - ORDER BY id_agente'; - $agents = db_get_all_rows_sql($sql); - if ($agents === false) { - $agents = []; - } - - $sql = 'SELECT id_agente_modulo,nombre - FROM tagente_modulo - WHERE id_agente IN ('.implode(',', $id_agent).") - AND nombre IN ('".implode("','", $id_module)."') - AND delete_pending = 0 ORDER BY nombre"; - $modules = index_array(db_get_all_rows_sql($sql), 'id_agente_modulo', 'nombre'); - if ($modules === false) { - $modules = []; - } - } else { - $agents = []; - $modules = []; - } - - $visual_data = $this->generate_data_agent_module($agents, $modules); - - $this->body .= $this->generate_view_agent_module($visual_data); - */ + $output .= '
'; + $output .= \ui_print_error_message( + __('This widget has been removed'), + '', + true + ); + $output .= '
'; + return $output; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php b/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php index de76b7a744..4aadb73dae 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php +++ b/pandora_console/include/lib/Dashboard/Widgets/alerts_fired.php @@ -146,7 +146,7 @@ class AlertsFiredWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -176,6 +176,31 @@ class AlertsFiredWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['group']) === true) { + $values['groupId'] = $decoder['group']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -234,7 +259,7 @@ class AlertsFiredWidget extends Widget $output = ''; - if ($this->values['groupId'] === 0) { + if ((int) $this->values['groupId'] === 0) { $groups = users_get_groups(false, 'AR', false); } else { $groups = [$this->values['groupId'] => '']; @@ -254,7 +279,7 @@ class AlertsFiredWidget extends Widget $flag = false; foreach ($groups as $id_group => $name) { - $alerts_group = get_group_alerts($id_group); + $alerts_group = get_group_alerts([$id_group]); if (isset($alerts_group['simple']) === true) { $alerts_group = $alerts_group['simple']; } diff --git a/pandora_console/include/lib/Dashboard/Widgets/clock.php b/pandora_console/include/lib/Dashboard/Widgets/clock.php index 5c7b793b9e..8ad514e023 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/clock.php +++ b/pandora_console/include/lib/Dashboard/Widgets/clock.php @@ -142,7 +142,7 @@ class ClockWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class ClockWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['clock_type']) === true) { + $values['clockType'] = $decoder['clock_type']; + } + + if (isset($decoder['clockType']) === true) { + $values['clockType'] = $decoder['clockType']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php index 61d5a49904..b35ce233a1 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/custom_graph.php @@ -104,6 +104,13 @@ class CustomGraphWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -141,8 +148,11 @@ class CustomGraphWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -173,6 +183,43 @@ class CustomGraphWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['id_graph']) === true) { + $values['id_graph'] = $decoder['id_graph']; + } + + if (isset($decoder['stacked']) === true) { + $values['type'] = $decoder['stacked']; + } + + if (isset($decoder['type']) === true) { + $values['type'] = $decoder['type']; + } + + if (isset($decoder['period']) === true) { + $values['period'] = $decoder['period']; + } + + if (isset($decoder['showLegend']) === true) { + $values['showLegend'] = $decoder['showLegend']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index 1d0d4a3563..90c863472e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -147,7 +147,7 @@ class EventsListWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +177,71 @@ class EventsListWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['type']) === true) { + $values['eventType'] = $decoder['type']; + } + + if (isset($decoder['eventType']) === true) { + $values['eventType'] = $decoder['eventType']; + } + + if (isset($decoder['event_view_hr']) === true) { + $values['maxHours'] = $decoder['event_view_hr']; + } + + if (isset($decoder['maxHours']) === true) { + $values['maxHours'] = $decoder['maxHours']; + } + + if (isset($decoder['limit']) === true) { + $values['limit'] = $decoder['limit']; + } + + if (isset($decoder['status']) === true) { + $values['eventStatus'] = $decoder['status']; + } + + if (isset($decoder['eventStatus']) === true) { + $values['eventStatus'] = $decoder['eventStatus']; + } + + if (isset($decoder['severity']) === true) { + $values['severity'] = $decoder['severity']; + } + + if (isset($decoder['id_groups']) === true) { + if (is_array($decoder['id_groups']) === true) { + $decoder['id_groups'][0] = implode(',', $decoder['id_groups']); + } + + $values['groupId'] = $decoder['id_groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['tagsId']) === true) { + $values['tagsId'] = $decoder['tagsId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -416,13 +481,15 @@ class EventsListWidget extends Widget $filter['limit'] = $this->values['limit']; $filter['order'] = '`utimestamp` DESC'; - if ((int) $this->values['severity'] === 20) { - $filter['criticity'] = [ - EVENT_CRIT_WARNING, - EVENT_CRIT_CRITICAL, - ]; - } else if ((int) $this->values['severity'] !== -1) { - $filter['criticity'] = $this->values['severity']; + if (isset($this->values['severity']) === true) { + if ((int) $this->values['severity'] === 20) { + $filter['criticity'] = [ + EVENT_CRIT_WARNING, + EVENT_CRIT_CRITICAL, + ]; + } else if ((int) $this->values['severity'] !== -1) { + $filter['criticity'] = $this->values['severity']; + } } if (empty($this->values['tagsId']) === false) { diff --git a/pandora_console/include/lib/Dashboard/Widgets/example.php b/pandora_console/include/lib/Dashboard/Widgets/example.php index e7d431cd5a..8c0664464c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/example.php +++ b/pandora_console/include/lib/Dashboard/Widgets/example.php @@ -142,7 +142,7 @@ class WelcomeWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -168,6 +168,23 @@ class WelcomeWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php index 067bbef1fd..948b20acc7 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php +++ b/pandora_console/include/lib/Dashboard/Widgets/graph_module_histogram.php @@ -106,6 +106,13 @@ class GraphModuleHistogramWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -148,8 +155,11 @@ class GraphModuleHistogramWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -179,6 +189,63 @@ class GraphModuleHistogramWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['period']) === true) { + $values['period'] = $decoder['period']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/groups_status.php b/pandora_console/include/lib/Dashboard/Widgets/groups_status.php index 7e2c449bbd..5b7fa16395 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/groups_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/groups_status.php @@ -142,7 +142,7 @@ class GroupsStatusWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class GroupsStatusWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['groups']) === true) { + $values['groupId'] = $decoder['groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php b/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php index f285abdc08..f480c45389 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_made_by_user.php @@ -158,7 +158,7 @@ class MapsMadeByUser extends Widget $this->cellId = $cellId; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -188,6 +188,31 @@ class MapsMadeByUser extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['id_layout']) === true) { + $values['vcId'] = $decoder['id_layout']; + } + + if (isset($decoder['vcId']) === true) { + $values['vcId'] = $decoder['vcId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php index 083a3bd2b3..783cca2b0c 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php @@ -142,7 +142,7 @@ class MapsStatusWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class MapsStatusWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['maps']) === true) { + if (is_array($decoder['maps']) === true) { + $decoder['maps'][0] = implode(',', $decoder['maps']); + } + + $values['maps'] = $decoder['maps']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_icon.php b/pandora_console/include/lib/Dashboard/Widgets/module_icon.php index 10ed9f8948..e8335e4661 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_icon.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_icon.php @@ -114,6 +114,13 @@ class ModuleIconWidget extends Widget */ protected $dashboardId; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -151,8 +158,11 @@ class ModuleIconWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -183,6 +193,83 @@ class ModuleIconWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_value_'.$this->cellId]) === true) { + $values['sizeValue'] = $decoder['size_value_'.$this->cellId]; + } + + if (isset($decoder['sizeValue']) === true) { + $values['sizeValue'] = $decoder['sizeValue']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['size_icon_'.$this->cellId]) === true) { + $values['sizeIcon'] = $decoder['size_icon_'.$this->cellId]; + } + + if (isset($decoder['sizeIcon']) === true) { + $values['sizeIcon'] = $decoder['sizeIcon']; + } + + if (isset($decoder['icon_module_'.$this->cellId]) === true) { + $values['imageSrc'] = $decoder['icon_module_'.$this->cellId]; + } + + if (isset($decoder['imageSrc']) === true) { + $values['imageSrc'] = $decoder['imageSrc']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_status.php b/pandora_console/include/lib/Dashboard/Widgets/module_status.php index 06fd65afd3..e4dc1c65f6 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_status.php @@ -106,6 +106,13 @@ class ModuleStatusWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -146,8 +153,11 @@ class ModuleStatusWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +187,83 @@ class ModuleStatusWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_value_'.$this->cellId]) === true) { + $values['sizeValue'] = $decoder['size_value_'.$this->cellId]; + } + + if (isset($decoder['sizeValue']) === true) { + $values['sizeValue'] = $decoder['sizeValue']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['size_icon_'.$this->cellId]) === true) { + $values['sizeIcon'] = $decoder['size_icon_'.$this->cellId]; + } + + if (isset($decoder['sizeIcon']) === true) { + $values['sizeIcon'] = $decoder['sizeIcon']; + } + + if (isset($decoder['icon_module_'.$this->cellId]) === true) { + $values['imageSrc'] = $decoder['icon_module_'.$this->cellId]; + } + + if (isset($decoder['imageSrc']) === true) { + $values['imageSrc'] = $decoder['imageSrc']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php b/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php index a817ffce8b..fc07f1c2a7 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_table_value.php @@ -107,6 +107,13 @@ class ModuleTableValueWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -148,8 +155,11 @@ class ModuleTableValueWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -179,6 +189,59 @@ class ModuleTableValueWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_text_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_text_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['separator_data_'.$this->cellId]) === true) { + $values['separator'] = $decoder['separator_data_'.$this->cellId]; + } + + if (isset($decoder['separator']) === true) { + $values['separator'] = $decoder['separator']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_value.php b/pandora_console/include/lib/Dashboard/Widgets/module_value.php index b1606be21b..b862cc4d71 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_value.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_value.php @@ -109,6 +109,13 @@ class ModuleValueWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -146,8 +153,11 @@ class ModuleValueWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +187,67 @@ class ModuleValueWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_value_'.$this->cellId]) === true) { + $values['sizeValue'] = $decoder['size_value_'.$this->cellId]; + } + + if (isset($decoder['sizeValue']) === true) { + $values['sizeValue'] = $decoder['sizeValue']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php b/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php index 0d364de6ee..476bf327e9 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php +++ b/pandora_console/include/lib/Dashboard/Widgets/monitor_health.php @@ -142,7 +142,7 @@ class MonitorHealthWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -164,14 +164,28 @@ class MonitorHealthWidget extends Widget // This forces at least a first configuration. $this->configurationRequired = false; - if (isset($this->values['title']) === false) { - $this->configurationRequired = true; - } $this->overflow_scrollbars = false; } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -234,8 +248,11 @@ class MonitorHealthWidget extends Widget $data['mW'] = (int) $all_data['_monitors_warning_']; $data['mC'] = (int) $all_data['_monitors_critical_']; $data['mNN'] = (int) $all_data['_monitor_not_normal_']; + $data['monitor_not_normal'] = (int) $all_data['_monitor_not_normal_']; + $data['monitor_not_init'] = (int) $all_data['_monitors_not_init_']; $data['monitor_alerts'] = (int) $all_data['_monitors_alerts_']; $data['mAFired'] = (int) $all_data['_monitors_alerts_fired_']; + $data['monitor_alerts_fired'] = (int) $all_data['_monitors_alerts_fired_']; $data['total_agents'] = (int) $all_data['_total_agents_']; diff --git a/pandora_console/include/lib/Dashboard/Widgets/network_map.php b/pandora_console/include/lib/Dashboard/Widgets/network_map.php index c873bbbec1..27880e71cb 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/network_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/network_map.php @@ -154,7 +154,7 @@ class NetworkMapWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -184,6 +184,55 @@ class NetworkMapWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['networkmaps']) === true) { + $values['networkmapId'] = $decoder['networkmaps']; + } + + if (isset($decoder['networkmapId']) === true) { + $values['networkmapId'] = $decoder['networkmapId']; + } + + if (isset($decoder['map_translate_x']) === true) { + $values['xOffset'] = $decoder['map_translate_x']; + } + + if (isset($decoder['xOffset']) === true) { + $values['xOffset'] = $decoder['xOffset']; + } + + if (isset($decoder['map_translate_y']) === true) { + $values['yOffset'] = $decoder['map_translate_y']; + } + + if (isset($decoder['yOffset']) === true) { + $values['yOffset'] = $decoder['yOffset']; + } + + if (isset($decoder['zoom_level_dash']) === true) { + $values['zoomLevel'] = $decoder['zoom_level_dash']; + } + + if (isset($decoder['zoomLevel']) === true) { + $values['zoomLevel'] = $decoder['zoomLevel']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/post.php b/pandora_console/include/lib/Dashboard/Widgets/post.php index be8bdd9193..6844a3de7a 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/post.php +++ b/pandora_console/include/lib/Dashboard/Widgets/post.php @@ -142,7 +142,7 @@ class PostWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class PostWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['textit']) === true) { + $values['text'] = $decoder['textit']; + } + + if (isset($decoder['text']) === true) { + $values['text'] = $decoder['text']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/reports.php b/pandora_console/include/lib/Dashboard/Widgets/reports.php index 5ae3a5c70d..b042877ed2 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/reports.php +++ b/pandora_console/include/lib/Dashboard/Widgets/reports.php @@ -148,7 +148,7 @@ class ReportsWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -178,6 +178,31 @@ class ReportsWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['id_report']) === true) { + $values['reportId'] = $decoder['id_report']; + } + + if (isset($decoder['reportId']) === true) { + $values['reportId'] = $decoder['reportId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php index 401852b070..92209fcf93 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php @@ -146,7 +146,7 @@ class ServiceMapWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -176,6 +176,39 @@ class ServiceMapWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['service_id']) === true) { + $values['serviceId'] = $decoder['service_id']; + } + + if (isset($decoder['serviceId']) === true) { + $values['serviceId'] = $decoder['serviceId']; + } + + if (isset($decoder['show_legend']) === true) { + $values['showLegend'] = (int) $decoder['show_legend']; + } + + if (isset($decoder['showLegend']) === true) { + $values['showLegend'] = $decoder['showLegend']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php index bd7969dc72..e4e3462024 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/single_graph.php +++ b/pandora_console/include/lib/Dashboard/Widgets/single_graph.php @@ -106,6 +106,13 @@ class SingleGraphWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -143,8 +150,11 @@ class SingleGraphWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -174,6 +184,55 @@ class SingleGraphWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['period']) === true) { + $values['period'] = $decoder['period']; + } + + if (isset($decoder['show_full_legend']) === true) { + $values['showLegend'] = $decoder['show_full_legend']; + } + + if (isset($decoder['showLegend']) === true) { + $values['showLegend'] = $decoder['showLegend']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php index 3cd1e72fc4..df88cb28fa 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php +++ b/pandora_console/include/lib/Dashboard/Widgets/sla_percent.php @@ -110,6 +110,13 @@ class SLAPercentWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -147,8 +154,11 @@ class SLAPercentWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -178,6 +188,71 @@ class SLAPercentWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['label_'.$this->cellId]) === true) { + $values['label'] = $decoder['label_'.$this->cellId]; + } + + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['id_module_'.$this->cellId]) === true) { + $values['moduleId'] = $decoder['id_module_'.$this->cellId]; + } + + if (isset($decoder['moduleId']) === true) { + $values['moduleId'] = $decoder['moduleId']; + } + + if (isset($decoder['size_value_'.$this->cellId]) === true) { + $values['sizeValue'] = $decoder['size_value_'.$this->cellId]; + } + + if (isset($decoder['sizeValue']) === true) { + $values['sizeValue'] = $decoder['sizeValue']; + } + + if (isset($decoder['size_label_'.$this->cellId]) === true) { + $values['sizeLabel'] = $decoder['size_label_'.$this->cellId]; + } + + if (isset($decoder['sizeLabel']) === true) { + $values['sizeLabel'] = $decoder['sizeLabel']; + } + + if (isset($decoder['period']) === true) { + $values['period'] = $decoder['period']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -387,7 +462,7 @@ class SLAPercentWidget extends Widget if (empty($label) === false) { // Div Label. - $output .= '
'.$label.'
'; + $output .= '
'.$label.'
'; } $output .= '
'; diff --git a/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php b/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php index 65df0b83d4..8f0bbc00bb 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/system_group_status.php @@ -142,7 +142,7 @@ class SystemGroupStatusWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -164,14 +164,80 @@ class SystemGroupStatusWidget extends Widget // This forces at least a first configuration. $this->configurationRequired = false; - if (empty($this->values['groupId']) === true) { - $this->configurationRequired = true; - } $this->overflow_scrollbars = false; } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['status']) === true) { + if (is_array($decoder['status']) === true) { + $compatibilityStatus = []; + foreach ($decoder['status'] as $key => $value) { + switch ((int) $value) { + case 2: + $compatibilityStatus[] = AGENT_STATUS_WARNING; + break; + + case 3: + $compatibilityStatus[] = AGENT_STATUS_CRITICAL; + break; + + case 4: + $compatibilityStatus[] = 4; + break; + + default: + case 1: + $compatibilityStatus[] = AGENT_STATUS_NORMAL; + break; + } + } + + $decoder['status'][0] = implode(',', $compatibilityStatus); + } + + $values['status'] = $decoder['status']; + } else { + $values['status'][0] = implode( + ',', + [ + AGENT_STATUS_NORMAL, + AGENT_STATUS_WARNING, + AGENT_STATUS_CRITICAL, + 4, + ] + ); + } + + if (isset($decoder['id_groups']) === true) { + if (is_array($decoder['id_groups']) === true) { + $decoder['id_groups'][0] = implode(',', $decoder['id_groups']); + } + + $values['groupId'] = $decoder['id_groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -186,6 +252,19 @@ class SystemGroupStatusWidget extends Widget // Retrieve global - common inputs. $inputs = parent::getFormInputs(); + // Default values. + if (isset($values['status']) === false) { + $values['status'][0] = implode( + ',', + [ + AGENT_STATUS_NORMAL, + AGENT_STATUS_WARNING, + AGENT_STATUS_CRITICAL, + 4, + ] + ); + } + // Restrict access to group. $inputs[] = [ 'label' => __('Groups'), @@ -439,7 +518,7 @@ class SystemGroupStatusWidget extends Widget } } - $height = (count($table->data) * 30); + $height = (count($table->data) * 32); $style = 'min-width:200px; min-height:'.$height.'px;'; $output = '
'; if ($flag_groups === true) { diff --git a/pandora_console/include/lib/Dashboard/Widgets/tactical.php b/pandora_console/include/lib/Dashboard/Widgets/tactical.php index bee5f4164c..2003a6facb 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/tactical.php +++ b/pandora_console/include/lib/Dashboard/Widgets/tactical.php @@ -160,7 +160,7 @@ class TacticalWidget extends Widget $this->pmAccess = \users_can_manage_group_all('PM'); // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -193,6 +193,43 @@ class TacticalWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['statusmonitors']) === true) { + $values['statusMonitor'] = $decoder['statusmonitors']; + } + + if (isset($decoder['statusMonitor']) === true) { + $values['statusMonitor'] = $decoder['statusMonitor']; + } + + if (isset($decoder['serverperf']) === true) { + $values['serverPerformance'] = $decoder['serverperf']; + } + + if (isset($decoder['serverPerformance']) === true) { + $values['serverPerformance'] = $decoder['serverPerformance']; + } + + if (isset($decoder['summary']) === true) { + $values['summary'] = $decoder['summary']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -366,7 +403,7 @@ class TacticalWidget extends Widget ); } - if ($this->values['statusMonitor'] === 1) { + if ((int) $this->values['statusMonitor'] === 1) { $table = new \stdClass(); $table->width = '100%'; @@ -396,7 +433,7 @@ class TacticalWidget extends Widget $output .= \html_print_table($table, true); } - if ($this->values['serverPerformance'] === 1 + if ((int) $this->values['serverPerformance'] === 1 && $this->pmAccess === true ) { $table = new \stdClass(); @@ -414,7 +451,7 @@ class TacticalWidget extends Widget $output .= \html_print_table($table, true); } - if ($this->values['summary'] === 1) { + if ((int) $this->values['summary'] === 1) { $table = new \stdClass(); $table->width = '100%'; $table->class = ''; diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n.php b/pandora_console/include/lib/Dashboard/Widgets/top_n.php index a7b8198546..7029b07bad 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n.php @@ -375,7 +375,7 @@ class TopNWidget extends Widget } // This function check ACL. - $agents = agents_get_group_agents(0, ['aliasRegex' => $agentRegex]); + $agents = @agents_get_group_agents(0, ['aliasRegex' => $agentRegex]); $agentsId = \array_keys($agents); $agentsIdString = \implode(',', $agentsId); @@ -414,7 +414,7 @@ class TopNWidget extends Widget $quantity ); - $modules = \db_get_all_rows_sql( + $modules = @db_get_all_rows_sql( $sql, $search_in_history_db ); @@ -422,7 +422,7 @@ class TopNWidget extends Widget if (empty($modules) === true) { $output .= '
'; $output .= \ui_print_info_message( - __('There are no Agent/Modules defined'), + __('There are no agents/modules found matching filter set'), '', true ); diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php index 10ddfb881a..2acd7f32fa 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php @@ -147,7 +147,7 @@ class TopNEventByGroupWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +177,59 @@ class TopNEventByGroupWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['amount']) === true) { + $values['amountShow'] = $decoder['amount']; + } + + if (isset($decoder['amountShow']) === true) { + $values['amountShow'] = $decoder['amountShow']; + } + + if (isset($decoder['event_view_hr']) === true) { + $values['maxHours'] = $decoder['event_view_hr']; + } + + if (isset($decoder['maxHours']) === true) { + $values['maxHours'] = $decoder['maxHours']; + } + + if (isset($decoder['id_groups']) === true) { + if (is_array($decoder['id_groups']) === true) { + $implode = implode(',', $decoder['id_groups']); + $values['groupId'] = []; + $values['groupId'][0] = $implode; + } + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['legend_position']) === true) { + $values['legendPosition'] = $decoder['legend_position']; + } + + if (isset($decoder['legendPosition']) === true) { + $values['legendPosition'] = $decoder['legendPosition']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -320,8 +373,8 @@ class TopNEventByGroupWidget extends Widget GROUP BY id_agente ORDER BY count DESC LIMIT %d', - implode(',', $this->values['groupId']), $timestamp, + implode(',', $this->values['groupId']), $this->values['amountShow'] ); } else { diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php index 4d9187bf80..4bbaee22a8 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php @@ -147,7 +147,7 @@ class TopNEventByModuleWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,6 +177,59 @@ class TopNEventByModuleWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['amount']) === true) { + $values['amountShow'] = $decoder['amount']; + } + + if (isset($decoder['amountShow']) === true) { + $values['amountShow'] = $decoder['amountShow']; + } + + if (isset($decoder['event_view_hr']) === true) { + $values['maxHours'] = $decoder['event_view_hr']; + } + + if (isset($decoder['maxHours']) === true) { + $values['maxHours'] = $decoder['maxHours']; + } + + if (isset($decoder['id_groups']) === true) { + if (is_array($decoder['id_groups']) === true) { + $decoder['id_groups'][0] = implode(',', $decoder['id_groups']); + } + + $values['groupId'] = $decoder['id_groups']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['legend_position']) === true) { + $values['legendPosition'] = $decoder['legend_position']; + } + + if (isset($decoder['legendPosition']) === true) { + $values['legendPosition'] = $decoder['legendPosition']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * @@ -311,20 +364,26 @@ class TopNEventByModuleWidget extends Widget if ($all_group === false) { $sql = sprintf( - 'SELECT id_agentmodule, COUNT(*) AS count + 'SELECT id_agente, + id_agentmodule, + event_type, + COUNT(*) AS count FROM tevento WHERE utimestamp >= %d AND id_grupo IN (%s) GROUP BY id_agentmodule, event_type ORDER BY count DESC LIMIT %d', - implode(',', $this->values['groupId']), $timestamp, + implode(',', $this->values['groupId']), $this->values['amountShow'] ); } else { $sql = sprintf( - 'SELECT id_agentmodule, COUNT(*) AS count + 'SELECT id_agente, + id_agentmodule, + event_type, + COUNT(*) AS count FROM tevento WHERE utimestamp >= %d GROUP BY id_agentmodule, event_type @@ -353,8 +412,9 @@ class TopNEventByModuleWidget extends Widget $name = __('System'); } else { $name_agent = io_safe_output( - agents_get_alias($row['id_agentmodule']) + agents_get_alias($row['id_agente']) ); + $name_module = io_safe_output( modules_get_agentmodule_name($row['id_agentmodule']) ); diff --git a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php index 9176bec9ef..994cceac73 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/tree_view.php +++ b/pandora_console/include/lib/Dashboard/Widgets/tree_view.php @@ -155,7 +155,7 @@ class TreeViewWidget extends Widget $this->cellId = $cellId; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -177,14 +177,136 @@ class TreeViewWidget extends Widget // This forces at least a first configuration. $this->configurationRequired = false; - if (isset($this->values['groupId']) === false) { - $this->configurationRequired = true; - } $this->overflow_scrollbars = false; } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['tab']) === true) { + $values['typeTree'] = $decoder['tab']; + } + + if (isset($decoder['typeTree']) === true) { + $values['typeTree'] = $decoder['typeTree']; + } + + if (isset($decoder['search_group']) === true) { + $values['groupId'] = $decoder['search_group']; + } + + if (isset($decoder['groupId']) === true) { + $values['groupId'] = $decoder['groupId']; + } + + if (isset($decoder['open_all_nodes']) === true) { + $values['openAllGroups'] = $decoder['open_all_nodes']; + } + + if (isset($decoder['openAllGroups']) === true) { + $values['openAllGroups'] = $decoder['openAllGroups']; + } + + if (isset($decoder['status_agent']) === true) { + switch ((int) $decoder['status_agent']) { + case 0: + $values['agentStatus'] = AGENT_STATUS_NORMAL; + break; + + case 1: + $values['agentStatus'] = AGENT_STATUS_CRITICAL; + break; + + case 2: + $values['agentStatus'] = AGENT_STATUS_WARNING; + break; + + case 3: + $values['agentStatus'] = AGENT_STATUS_UNKNOWN; + break; + + case 5: + $values['agentStatus'] = AGENT_STATUS_NOT_INIT; + break; + + default: + case -1: + $values['agentStatus'] = AGENT_STATUS_ALL; + break; + } + } + + if (isset($decoder['agentStatus']) === true) { + $values['agentStatus'] = $decoder['agentStatus']; + } + + if (isset($decoder['search_agent']) === true) { + $values['filterAgent'] = $decoder['search_agent']; + } + + if (isset($decoder['filterAgent']) === true) { + $values['filterAgent'] = $decoder['filterAgent']; + } + + if (isset($decoder['status_module']) === true) { + switch ((int) $decoder['status_module']) { + case 0: + $values['moduleStatus'] = AGENT_MODULE_STATUS_NORMAL; + break; + + case 1: + $values['moduleStatus'] = AGENT_MODULE_STATUS_CRITICAL_BAD; + break; + + case 2: + $values['moduleStatus'] = AGENT_MODULE_STATUS_WARNING; + break; + + case 3: + $values['moduleStatus'] = AGENT_MODULE_STATUS_UNKNOWN; + break; + + case 5: + $values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_INIT; + break; + + default: + case -1: + $values['moduleStatus'] = -1; + break; + } + + $values['moduleStatus'] = $decoder['status_module']; + } + + if (isset($decoder['moduleStatus']) === true) { + $values['moduleStatus'] = $decoder['moduleStatus']; + } + + if (isset($decoder['search_module']) === true) { + $values['filterModule'] = $decoder['search_module']; + } + + if (isset($decoder['filterModule']) === true) { + $values['filterModule'] = $decoder['filterModule']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/url.php b/pandora_console/include/lib/Dashboard/Widgets/url.php index 70a841a9fd..4259f1abb1 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/url.php +++ b/pandora_console/include/lib/Dashboard/Widgets/url.php @@ -142,7 +142,7 @@ class UrlWidget extends Widget $this->gridWidth = $gridWidth; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -172,6 +172,31 @@ class UrlWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['url']) === true) { + $values['urlText'] = $decoder['url']; + } + + if (isset($decoder['urlText']) === true) { + $values['urlText'] = $decoder['urlText']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php index 92de8445e2..47c002f2ad 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php +++ b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction.php @@ -106,6 +106,13 @@ class WuxWidget extends Widget */ protected $gridWidth; + /** + * Cell ID. + * + * @var integer + */ + protected $cellId; + /** * Construct. @@ -142,8 +149,11 @@ class WuxWidget extends Widget // Grid Width. $this->gridWidth = $gridWidth; + // Cell Id. + $this->cellId = $cellId; + // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -173,6 +183,43 @@ class WuxWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['wux_transaction_'.$this->cellId]) === true) { + $values['transactionId'] = $decoder['wux_transaction_'.$this->cellId]; + } + + if (isset($decoder['transactionId']) === true) { + $values['transactionId'] = $decoder['transactionId']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction_stats.php b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction_stats.php index 25b4270715..49187dcb05 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/wux_transaction_stats.php +++ b/pandora_console/include/lib/Dashboard/Widgets/wux_transaction_stats.php @@ -154,7 +154,7 @@ class WuxStatsWidget extends Widget $this->cellId = $cellId; // Options. - $this->values = $this->getOptionsWidget(); + $this->values = $this->decoders($this->getOptionsWidget()); // Positions. $this->position = $this->getPositionWidget(); @@ -184,6 +184,51 @@ class WuxStatsWidget extends Widget } + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + if (isset($decoder['id_agent_'.$this->cellId]) === true) { + $values['agentId'] = $decoder['id_agent_'.$this->cellId]; + } + + if (isset($decoder['agentId']) === true) { + $values['agentId'] = $decoder['agentId']; + } + + if (isset($decoder['metaconsoleId']) === true) { + $values['metaconsoleId'] = $decoder['metaconsoleId']; + } + + if (isset($decoder['wux_transaction_'.$this->cellId]) === true) { + $values['transactionId'] = $decoder['wux_transaction_'.$this->cellId]; + } + + if (isset($decoder['transactionId']) === true) { + $values['transactionId'] = $decoder['transactionId']; + } + + if (isset($decoder['view_all_stats']) === true) { + $values['allStats'] = $decoder['view_all_stats']; + } + + if (isset($decoder['allStats']) === true) { + $values['allStats'] = $decoder['allStats']; + } + + return $values; + } + + /** * Generates inputs for form (specific). * diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 0db5cd6cb3..f3b41ccb2c 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -487,3 +487,7 @@ div#main_pure { .info_box tbody tr td.icon { padding-right: 10px !important; } + +.content-widget .databox.filters > tbody > tr > td { + padding-right: 30px; +} diff --git a/pandora_console/views/dashboard/cell.php b/pandora_console/views/dashboard/cell.php index ab7a9c4457..bdba1fffe9 100644 --- a/pandora_console/views/dashboard/cell.php +++ b/pandora_console/views/dashboard/cell.php @@ -34,6 +34,7 @@ if ($redraw === false) { $output .= '
'; $output .= '
'; + if ((int) $cellData['id_widget'] !== 0) { $options = json_decode($cellData['options'], true); $output .= $options['title'];