Fix retrocompatibility

This commit is contained in:
daniel 2020-04-30 14:08:56 +02:00 committed by Alejandro Fraguas
parent 8a019bd8f4
commit c308d49c25
35 changed files with 1503 additions and 618 deletions

View File

@ -8993,22 +8993,22 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru
if ($html) {
$tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), $servers['down']), true).'</legend>'.progress_bar($servers['health'], $width, $height, '', 0).'</fieldset>';
<legend>'.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), (int) $servers['down']), true).'</legend>'.progress_bar($servers['health'], $width, $height, '', 0).'</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), $data['monitor_not_normal']), true).'</legend>'.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'</fieldset>';
<legend>'.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), (int) $data['monitor_not_normal']), true).'</legend>'.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), $data['monitor_not_init']), true).'</legend>'.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'</fieldset>';
<legend>'.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), (int) $data['monitor_not_init']), true).'</legend>'.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), $data['monitor_alerts_fired']), true).'</legend>'.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'</fieldset>';
<legend>'.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), (int) $data['monitor_alerts_fired']), true).'</legend>'.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'</fieldset>';
$table_ind->rowclass[] = '';
$table_ind->data[] = $tdata;

View File

@ -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(

View File

@ -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.
*

View File

@ -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();
?>
<script>
$(document).ready(function() {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
function recalculate_modules_select_agent_module (selection_mode) {
var idAgents = Array();
jQuery.each ($('#id_agent_<?php echo $id; ?> option:selected'), function (i, val) {
idAgents.push($(val).val());
});
jQuery.post ('ajax.php',
{"page": "operation/agentes/ver_agente",
"get_modules_group_value_name_json": 1,
"selection": selection_mode == 'all' ? 1 : 0,
"id_agents[]": idAgents
},
function (data, status) {
$('#id_module_<?php echo $id; ?>').empty ();
if (data) {
jQuery.each (data, function (id, value) {
$('#id_module_<?php echo $id; ?>')
.append ($('<option></option>')
.html(value)
.prop("value", value)
.prop("selected", 'selected'));
});
}
},
"json"
);
}
$('#search_group_<?php echo $id; ?>').on('change',function() {
jQuery.post ("ajax.php",
{
"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : this.value,
"recursion" : ($('#checkbox-recursion-<?php echo $id; ?>').is(':checked')) ? 1 : 0
},
function (data, status) {
$('#id_agent_<?php echo $id; ?>').html('');
jQuery.each (data, function(id, value) {
// Remove keys_prefix from the index.
option = $("<option></option>")
.prop("value", id)
.prop("selected", 'selected')
.html(value);
$('#id_agent_<?php echo $id; ?>').append (option);
});
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
},
"json"
);
});
$('#checkbox-recursion-<?php echo $id; ?>').on('change', function() {
($('#hidden-recursion_sent').val() === '1') ? $('#hidden-recursion_sent').val('0') : $('#hidden-recursion_sent').val('1');
jQuery.post ("ajax.php",
{
"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : $('#search_group_<?php echo $id; ?>').val(),
"recursion" : ($('#checkbox-recursion-<?php echo $id; ?>').is(':checked')) ? 1 : 0
},
function (data, status) {
$('#id_agent_<?php echo $id; ?>').html('');
jQuery.each (data, function(id, value) {
// Remove keys_prefix from the index.
option = $("<option></option>")
.prop("value", id)
.prop("selected", 'selected')
.html(value);
$('#id_agent_<?php echo $id; ?>').append (option);
});
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
},
"json"
);
});
$("#id_agent_<?php echo $id; ?>").on('change',function () {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
});
$("#selection_agent_module_<?php echo $id; ?>").on('change',function(evt) {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
});
});
</script>
<?php
return ob_get_clean();
}
public function generate_data_agent_module($agents, $all_modules)
{
$return = [];
$cont = 0;
$name = '';
foreach ($all_modules as $key => $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 = '<div>';
$table_data .= '<table class="widget_agent_module" cellpadding="1" cellspacing="0" border="0" style="background-color: #EEE;">';
if (!empty($visual_data)) {
$table_data .= '<th>'.__('Agents').' / '.__('Modules').'</th>';
$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 .= '<th style="padding: 10px;">'.$file_name.'</th>';
}
foreach ($visual_data as $row) {
$table_data .= "<tr style='height: 35px;'>";
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 .= "<td style='background-color: ".$rowcolor.";'>".$file_name.'</td>';
foreach ($row['modules'] as $module_name => $module) {
if ($module === null) {
if (in_array($module_name, $array_names)) {
$table_data .= "<td style='background-color: #DDD;'></td>";
} else {
continue;
}
} else {
$table_data .= "<td style='text-align: center; background-color: #DDD;'>";
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 .= '</td>';
}
}
$table_data .= '</tr>';
}
} else {
$table_data .= '<tr><td>'.__('Please configure this widget before usage').'</td></tr>';
}
$table_data .= '</table>';
$table_data .= '</div>';
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 .= '<div class="container-center">';
$output .= \ui_print_error_message(
__('This widget has been removed'),
'',
true
);
$output .= '</div>';
return $output;
}

View File

@ -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'];
}

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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) {

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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_'];

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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 .= '<div style="flex: 1 1; font-size:'.$sizeLabel.'px;">'.$label.'</div>';
$output .= '<div style="flex: 1 1; font-size:'.$sizeLabel.'px; text-align: left;">'.$label.'</div>';
}
$output .= '</div>';

View File

@ -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 = '<div class="container-center" style="'.$style.'">';
if ($flag_groups === true) {

View File

@ -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 = '';

View File

@ -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 .= '<div class="container-center">';
$output .= \ui_print_info_message(
__('There are no Agent/Modules defined'),
__('There are no agents/modules found matching filter set'),
'',
true
);

View File

@ -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 {

View File

@ -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'])
);

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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).
*

View File

@ -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;
}

View File

@ -34,6 +34,7 @@ if ($redraw === false) {
$output .= '<div class="header-widget">';
$output .= '<div>';
if ((int) $cellData['id_widget'] !== 0) {
$options = json_decode($cellData['options'], true);
$output .= $options['title'];