Merge branch 'ent-10092-14739-peticion-de-filtro-en-widget-tree-view' into 'develop', JJOS.

Ent 10092 14739 peticion de filtro en widget tree view

See merge request artica/pandorafms!5532
This commit is contained in:
Jimmy Olano 2023-03-05 22:56:35 +00:00
commit 6b55c65330
4 changed files with 53 additions and 7 deletions

View File

@ -214,6 +214,11 @@ class Tree
AND ta.unknown_count = 0
AND ta.normal_count > 0) ';
break;
case AGENT_STATUS_NOT_NORMAL:
$agent_status_filter = ' AND (ta.critical_count > 0
OR ta.warning_count > 0) ';
break;
}
return $agent_status_filter;
@ -285,6 +290,10 @@ class Tree
return $show_init_condition;
}
if ((int) $this->filter['statusModule'] === 6) {
return ' AND (ta.warning_count > 0 OR ta.critical_count > 0)';
}
$field_filter = modules_get_counter_by_states($this->filter['statusModule']);
if ($field_filter === false) {
return ' AND 1=0';
@ -894,6 +903,18 @@ class Tree
$agent['counters']['ok'] = $agent['normal_count'];
$agent['counters']['total'] = $agent['normal_count'];
break;
case AGENT_MODULE_STATUS_NOT_NORMAL:
if (empty($agent['critical_count']) === false) {
$agent['counters']['critical'] = $agent['critical_count'];
}
if (empty($agent['warning_count']) === false) {
$agent['counters']['warning'] = $agent['warning_count'];
}
$agent['counters']['total'] = ($agent['warning_count'] + $agent['critical_count']);
break;
}
}

View File

@ -956,6 +956,11 @@ function processTreeSearch(settings) {
agents: settings.translate.ok.agents,
modules: settings.translate.ok.modules,
none: settings.translate.ok.none
},
not_normal: {
agents: settings.translate.not_normal.agents,
modules: settings.translate.not_normal.modules,
none: settings.translate.not_normal.none
}
}
});

View File

@ -243,6 +243,10 @@ class TreeViewWidget extends Widget
$values['agentStatus'] = AGENT_STATUS_NOT_INIT;
break;
case 6:
$values['agentStatus'] = AGENT_STATUS_NOT_NORMAL;
break;
default:
case -1:
$values['agentStatus'] = AGENT_STATUS_ALL;
@ -284,6 +288,10 @@ class TreeViewWidget extends Widget
$values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_INIT;
break;
case 6:
$values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_NORMAL;
break;
default:
case -1:
$values['moduleStatus'] = -1;
@ -381,12 +389,13 @@ class TreeViewWidget extends Widget
// Agents status.
$fields = [
AGENT_STATUS_ALL => __('All'),
AGENT_STATUS_NORMAL => __('Normal'),
AGENT_STATUS_WARNING => __('Warning'),
AGENT_STATUS_CRITICAL => __('Critical'),
AGENT_STATUS_UNKNOWN => __('Unknown'),
AGENT_STATUS_NOT_INIT => __('Not init'),
AGENT_STATUS_ALL => __('All'),
AGENT_STATUS_NORMAL => __('Normal'),
AGENT_STATUS_WARNING => __('Warning'),
AGENT_STATUS_CRITICAL => __('Critical'),
AGENT_STATUS_UNKNOWN => __('Unknown'),
AGENT_STATUS_NOT_INIT => __('Not init'),
AGENT_STATUS_NOT_NORMAL => __('Not normal'),
];
$inputs[] = [
@ -420,6 +429,7 @@ class TreeViewWidget extends Widget
AGENT_MODULE_STATUS_CRITICAL_BAD => __('Critical'),
AGENT_MODULE_STATUS_UNKNOWN => __('Unknown'),
AGENT_MODULE_STATUS_NOT_INIT => __('Not init'),
AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'),
];
if (is_metaconsole() === false) {
@ -682,6 +692,11 @@ class TreeViewWidget extends Widget
'modules' => __('Normal modules'),
'none' => __('Normal'),
],
'not_normal' => [
'agents' => __('Not normal agents'),
'modules' => __('Not normal modules'),
'none' => __('Not normal'),
],
'module' => __('Module'),
'timeOnlyTitle' => __('Choose time'),
'timeText' => __('Time'),

View File

@ -484,7 +484,12 @@ enterprise_hook('close_meta_frame');
agents: "<?php echo __('Normal agents'); ?>",
modules: "<?php echo __('Normal modules'); ?>",
none: "<?php echo __('Normal'); ?>"
}
},
not_normal: {
agents: "<?php echo __('Not normal agents'); ?>",
modules: "<?php echo __('Not normal modules'); ?>",
none: "<?php echo __('Not normal'); ?>"
},
}
});
}