From c308d49c255801b2820b549899f2ebb7c34c8cc9 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 30 Apr 2020 14:08:56 +0200 Subject: [PATCH] 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'];