new widget grouped meter graphs pandora_enterprise#8620
This commit is contained in:
parent
836cef7830
commit
ce823dca38
|
@ -3487,12 +3487,13 @@ function agents_get_agent_custom_field($agent_id, $custom_field_name)
|
|||
/**
|
||||
* Unverified documentation.
|
||||
*
|
||||
* @param integer $id_group Module group.
|
||||
* @param array $id_agents Array of agent ids.
|
||||
* @param boolean $selection Show common (false) or all modules (true).
|
||||
* @param boolean $return Return (false) or dump to output (true).
|
||||
* @param boolean $index_by_name Use module name as key.
|
||||
* @param boolean $pure_return Return as retrieved from DB.
|
||||
* @param integer $id_group Module group.
|
||||
* @param array $id_agents Array of agent ids.
|
||||
* @param boolean $selection Show common (false) or all modules (true).
|
||||
* @param boolean $return Return (false) or dump to output (true).
|
||||
* @param boolean $index_by_name Use module name as key.
|
||||
* @param boolean $pure_return Return as retrieved from DB.
|
||||
* @param boolean $notStringModules Not string modules.
|
||||
*
|
||||
* @return array With modules or null if error.
|
||||
*/
|
||||
|
@ -3502,7 +3503,8 @@ function select_modules_for_agent_group(
|
|||
$selection,
|
||||
$return=true,
|
||||
$index_by_name=false,
|
||||
$pure_return=false
|
||||
$pure_return=false,
|
||||
$notStringModules=false
|
||||
) {
|
||||
global $config;
|
||||
$agents = (empty($id_agents)) ? [] : implode(',', $id_agents);
|
||||
|
@ -3510,6 +3512,7 @@ function select_modules_for_agent_group(
|
|||
$filter_agent_group = '';
|
||||
$filter_group = '';
|
||||
$filter_agent = '';
|
||||
$filter_not_string_modules = '';
|
||||
$selection_filter = '';
|
||||
$sql_conditions_tags = '';
|
||||
$sql_tags_inner = '';
|
||||
|
@ -3524,6 +3527,23 @@ function select_modules_for_agent_group(
|
|||
$filter_agent = ' AND tagente.id_agente IN ('.$agents.')';
|
||||
}
|
||||
|
||||
if ($notStringModules === true) {
|
||||
$filter_not_string_modules = sprintf(
|
||||
' AND (tagente_modulo.id_tipo_modulo <> %d AND
|
||||
tagente_modulo.id_tipo_modulo <> %d AND
|
||||
tagente_modulo.id_tipo_modulo <> %d AND
|
||||
tagente_modulo.id_tipo_modulo <> %d AND
|
||||
tagente_modulo.id_tipo_modulo <> %d AND
|
||||
tagente_modulo.id_tipo_modulo <> %d)',
|
||||
MODULE_TYPE_GENERIC_DATA_STRING,
|
||||
MODULE_TYPE_REMOTE_TCP_STRING,
|
||||
MODULE_TYPE_REMOTE_SNMP_STRING,
|
||||
MODULE_TYPE_ASYNC_STRING,
|
||||
MODULE_TYPE_WEB_CONTENT_STRING,
|
||||
MODULE_TYPE_REMOTE_CMD_STRING
|
||||
);
|
||||
}
|
||||
|
||||
if (!users_can_manage_group_all('AR')) {
|
||||
$group_string = implode(',', $groups);
|
||||
$filter_agent_group = " AND (
|
||||
|
@ -3567,6 +3587,7 @@ function select_modules_for_agent_group(
|
|||
$filter_agent_group
|
||||
$filter_group
|
||||
$filter_agent
|
||||
$filter_not_string_modules
|
||||
$sql_conditions_tags
|
||||
) x
|
||||
GROUP BY nombre
|
||||
|
|
|
@ -5608,7 +5608,9 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
0,
|
||||
$data['agent_ids'],
|
||||
$data['selectionModules'],
|
||||
true
|
||||
true,
|
||||
false,
|
||||
(isset($data['notStringModules']) === true && $data['notStringModules'] === true) ? true : false
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -3607,8 +3607,26 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
|
|||
}
|
||||
|
||||
|
||||
function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true, $useName=false)
|
||||
{
|
||||
/**
|
||||
* Get modules agents.
|
||||
*
|
||||
* @param integer $id_module_group ID module group.
|
||||
* @param array $id_agents Array agents.
|
||||
* @param boolean $selection Selection.
|
||||
* @param boolean $select_mode Mode.
|
||||
* @param boolean $useName Use name.
|
||||
* @param boolean $notStringModules Not string modules.
|
||||
*
|
||||
* @return array Modules for this agents.
|
||||
*/
|
||||
function get_modules_agents(
|
||||
$id_module_group,
|
||||
$id_agents,
|
||||
$selection,
|
||||
$select_mode=true,
|
||||
$useName=false,
|
||||
$notStringModules=false
|
||||
) {
|
||||
if ((bool) is_metaconsole() === true) {
|
||||
if ($select_mode === true) {
|
||||
$agents = array_reduce(
|
||||
|
@ -3657,7 +3675,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
|
|||
$selection,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
true,
|
||||
$notStringModules
|
||||
);
|
||||
|
||||
metaconsole_restore_db();
|
||||
|
@ -3744,7 +3763,10 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
|
|||
$id_module_group,
|
||||
$id_agents,
|
||||
$selection,
|
||||
false
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
$notStringModules
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1536,3 +1536,18 @@ function loadSliceWidget(settings) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function showManualThresholds(element) {
|
||||
$("#min_warning").val(null);
|
||||
$("#max_warning").val(null);
|
||||
$("#min_critical").val(null);
|
||||
$("#max_critical").val(null);
|
||||
if ($(element).is(":checked") === true) {
|
||||
$(".dashboard-input-threshold-warning").removeClass("invisible_important");
|
||||
$(".dashboard-input-threshold-critical").removeClass("invisible_important");
|
||||
} else {
|
||||
$(".dashboard-input-threshold-warning").addClass("invisible_important");
|
||||
$(".dashboard-input-threshold-critical").addClass("invisible_important");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -253,6 +253,10 @@ class GroupedMeterGraphs extends Widget
|
|||
$values['formatData'] = $decoder['formatData'];
|
||||
}
|
||||
|
||||
if (isset($decoder['manualThresholds']) === true) {
|
||||
$values['manualThresholds'] = $decoder['manualThresholds'];
|
||||
}
|
||||
|
||||
$values['label'] = 'module';
|
||||
if (isset($decoder['label']) === true) {
|
||||
$values['label'] = $decoder['label'];
|
||||
|
@ -377,8 +381,25 @@ class GroupedMeterGraphs extends Widget
|
|||
|
||||
];
|
||||
|
||||
// Format Data.
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'class' => 'dashboard-input-threshold',
|
||||
'label' => __('Manual thresholds'),
|
||||
'arguments' => [
|
||||
'name' => 'manualThresholds',
|
||||
'id' => 'manualThresholds',
|
||||
'type' => 'switch',
|
||||
'value' => $values['manualThresholds'],
|
||||
'onchange' => 'showManualThresholds(this)',
|
||||
],
|
||||
];
|
||||
|
||||
$class_invisible = '';
|
||||
if ((bool) $values['manualThresholds'] !== true) {
|
||||
$class_invisible = 'invisible_important';
|
||||
}
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'class' => 'dashboard-input-threshold dashboard-input-threshold-warning '.$class_invisible,
|
||||
'direct' => 1,
|
||||
'block_content' => [
|
||||
[
|
||||
|
@ -407,7 +428,7 @@ class GroupedMeterGraphs extends Widget
|
|||
];
|
||||
|
||||
$inputs['inputs']['row1'][] = [
|
||||
'class' => 'dashboard-input-threshold',
|
||||
'class' => 'dashboard-input-threshold dashboard-input-threshold-critical '.$class_invisible,
|
||||
'direct' => 1,
|
||||
'block_content' => [
|
||||
[
|
||||
|
@ -464,6 +485,7 @@ class GroupedMeterGraphs extends Widget
|
|||
'selectionModulesNameId' => 'selectionGroupedMeterGraphs',
|
||||
'modules_ids' => $values['moduleGroupedMeterGraphs'],
|
||||
'modules_name' => 'moduleGroupedMeterGraphs[]',
|
||||
'notStringModules' => true,
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -522,6 +544,7 @@ class GroupedMeterGraphs extends Widget
|
|||
$values['min_value'] = \get_parameter('min_value', null);
|
||||
$values['max_value'] = \get_parameter('max_value', null);
|
||||
|
||||
$values['manualThresholds'] = \get_parameter_switch('manualThresholds', 0);
|
||||
$values['min_critical'] = \get_parameter('min_critical', null);
|
||||
$values['max_critical'] = \get_parameter('max_critical', null);
|
||||
$values['min_warning'] = \get_parameter('min_warning', null);
|
||||
|
@ -792,7 +815,7 @@ class GroupedMeterGraphs extends Widget
|
|||
);
|
||||
}
|
||||
|
||||
$module_data = $this->getBoxPercentageMaths($max, $min, $data['data']);
|
||||
$module_data = $this->getBoxPercentageMaths($max, $min, (float) $data['data']);
|
||||
|
||||
$output = '';
|
||||
$output .= '<div class="container-info-module-meter">';
|
||||
|
@ -954,6 +977,10 @@ class GroupedMeterGraphs extends Widget
|
|||
float $min,
|
||||
float $value
|
||||
):float {
|
||||
if ($min === 0.00 && $max === 0.00) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (((($value - $min) / ($max - $min))) * $this->boxNumber);
|
||||
}
|
||||
|
||||
|
@ -1021,7 +1048,7 @@ class GroupedMeterGraphs extends Widget
|
|||
{
|
||||
$size = [
|
||||
'width' => (is_metaconsole() === true) ? 1000 : 900,
|
||||
'height' => 480,
|
||||
'height' => 550,
|
||||
];
|
||||
|
||||
return $size;
|
||||
|
|
|
@ -683,6 +683,7 @@ form.modal-dashboard
|
|||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 98%;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.container-grouped-meter .container-info-module-meter {
|
||||
display: flex;
|
||||
|
|
Loading…
Reference in New Issue