fix color tabs and block histogram pandora_enterprise#8621

This commit is contained in:
Daniel Barbero Martin 2022-06-30 14:09:29 +02:00
parent 95fca17fa9
commit a92d50303d
6 changed files with 103 additions and 24 deletions

View File

@ -983,6 +983,14 @@ function html_print_select(
if ($select2_multiple_enable === true
&& $select2_multiple_enable_all === true
) {
$output .= 'if($("#'.$id.' > option").length !== $("#'.$id.' > option:selected").length) {
checked = false;
} else {
checked = true;
}
$("#checkbox-'.$id.'-check-all").prop("checked", checked);';
$output .= '$("#'.$id.'").on("change", function(e) {
var checked = false;
if(e.target.length !== $("#'.$id.' > option:selected").length) {
@ -994,8 +1002,6 @@ function html_print_select(
$("#checkbox-'.$id.'-check-all").prop("checked", checked);
});';
$output .= '$("#'.$id.'").trigger("change");';
$output .= 'var count_shift_'.$id.' = 0;';
$output .= 'var shift_array_'.$id.' = [];';
$output .= 'var options_selecteds_'.$id.' = [];';

View File

@ -3766,6 +3766,10 @@ function get_same_modules($agents, array $modules=[])
return [];
}
if (is_array($modules) === false || empty($modules) === true) {
return [];
}
$name_modules = modules_get_agentmodule_name_array_data(
array_values($modules)
);

View File

@ -2043,17 +2043,15 @@ function agent_multiple_change(e, info) {
},
function(data) {
var name = info.modules_name.replace("[]", "");
if (JSON.stringify($(e).val()) !== JSON.stringify(info.agent_ids)) {
$("#" + name).html("");
$("#checkbox-" + name + "-check-all").prop("checked", false);
if (data) {
jQuery.each(data, function(id, value) {
var option = $("<option></option>")
.attr("value", id)
.html(value);
$("#" + name).append(option);
});
}
$("#" + name).html("");
$("#checkbox-" + name + "-check-all").prop("checked", false);
if (data) {
jQuery.each(data, function(id, value) {
var option = $("<option></option>")
.attr("value", id)
.html(value);
$("#" + name).append(option);
});
}
},
"json"

View File

@ -230,6 +230,7 @@ class BlockHistogram extends Widget
$values['fontColor'] = $decoder['fontColor'];
}
$values['label'] = 'module';
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
@ -272,10 +273,10 @@ class BlockHistogram extends Widget
],
];
// Type clock.
// Type Label.
$fields = [
'agent' => __('Agent'),
'module' => __('Module'),
'agent' => __('Agent'),
'agent_module' => __('Agent / module'),
];
@ -344,9 +345,23 @@ class BlockHistogram extends Widget
'moduleBlockHistogram'
);
$agColor = [];
if (isset($values['agentsBlockHistogram'][0]) === true
&& empty($values['agentsBlockHistogram'][0]) === false
) {
$agColor = explode(',', $values['agentsBlockHistogram'][0]);
}
$agModule = [];
if (isset($values['moduleBlockHistogram'][0]) === true
&& empty($values['moduleBlockHistogram'][0]) === false
) {
$agModule = explode(',', $values['moduleBlockHistogram'][0]);
}
$values['moduleBlockHistogram'] = get_same_modules_all(
explode(',', $values['agentsBlockHistogram'][0]),
explode(',', $values['moduleBlockHistogram'][0])
$agColor,
$agModule
);
$values['period'] = \get_parameter('period', 0);

View File

@ -226,6 +226,11 @@ class ColorModuleTabs extends Widget
$values['formatData'] = $decoder['formatData'];
}
$values['label'] = 'module';
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
return $values;
}
@ -244,6 +249,24 @@ class ColorModuleTabs extends Widget
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Type Label.
$fields = [
'module' => __('Module'),
'agent' => __('Agent'),
'agent_module' => __('Agent / module'),
];
$inputs[] = [
'label' => __('Label'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'label',
'selected' => $values['label'],
'return' => true,
],
];
$inputs[] = [
'arguments' => [
'type' => 'select_multiple_modules_filtered_select2',
@ -295,13 +318,29 @@ class ColorModuleTabs extends Widget
'moduleColorModuleTabs'
);
$agColor = [];
if (isset($values['agentsColorModuleTabs'][0]) === true
&& empty($values['agentsColorModuleTabs'][0]) === false
) {
$agColor = explode(',', $values['agentsColorModuleTabs'][0]);
}
$agModule = [];
if (isset($values['moduleColorModuleTabs'][0]) === true
&& empty($values['moduleColorModuleTabs'][0]) === false
) {
$agModule = explode(',', $values['moduleColorModuleTabs'][0]);
}
$values['moduleColorModuleTabs'] = get_same_modules_all(
explode(',', $values['agentsColorModuleTabs'][0]),
explode(',', $values['moduleColorModuleTabs'][0])
$agColor,
$agModule
);
$values['formatData'] = \get_parameter_switch('formatData', 0);
$values['label'] = \get_parameter('label', 'module');
return $values;
}
@ -397,10 +436,13 @@ class ColorModuleTabs extends Widget
tagente_modulo.unit AS `unit`,
tagente_estado.datos AS `data`,
tagente_estado.timestamp AS `timestamp`,
tagente_estado.estado AS `status`
tagente_estado.estado AS `status`,
tagente.alias
FROM tagente_modulo
LEFT JOIN tagente_estado
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
LEFT JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
WHERE %s',
$where
);
@ -437,7 +479,23 @@ class ColorModuleTabs extends Widget
$output .= '<br>';
}
$output .= $data['name'];
$name = '';
switch ($this->values['label']) {
case 'agent':
$name = $data['alias'];
break;
case 'agent_module':
$name = $data['alias'].' / '.$data['name'];
break;
default:
case 'module':
$name = $data['name'];
break;
}
$output .= $name;
$output .= '</span>';
$output .= '<span class="widget-module-tabs-data">';
if ($data['data'] !== null && $data['data'] !== '') {
@ -499,7 +557,7 @@ class ColorModuleTabs extends Widget
{
$size = [
'width' => (is_metaconsole() === true) ? 700 : 600,
'height' => 560,
'height' => 610,
];
return $size;

View File

@ -613,8 +613,6 @@ form.modal-dashboard
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
align-content: space-around;
flex-wrap: wrap;
}