10067-Alerts triggered filter tree view

This commit is contained in:
Pablo Aragon 2023-04-16 20:21:29 +02:00
parent 73d7345844
commit 0fa03f28b3
2 changed files with 95 additions and 1 deletions

View File

@ -133,6 +133,11 @@ class Tree
protected function getEmptyModuleFilterStatus()
{
if ($this->filter['statusModule'] === 'fired') {
$this->filter['statusModuleOriginal'] = $this->filter['statusModule'];
$this->filter['statusModule'] = -1;
}
return (
!isset($this->filter['statusModule']) ||
$this->filter['statusModule'] == -1
@ -288,6 +293,11 @@ class Tree
protected function getModuleStatusFilter()
{
if ($this->filter['statusModule'] === 'fired') {
$this->filter['statusModuleOriginal'] = $this->filter['statusModule'];
$this->filter['statusModule'] = -1;
}
$show_init_condition = ($this->filter['show_not_init_agents']) ? '' : ' AND ta.notinit_count <> ta.total_count';
if ($this->getEmptyModuleFilterStatus()) {
@ -341,6 +351,11 @@ class Tree
protected function getModuleStatusFilterFromTestado($state=false, $without_ands=false)
{
if ($this->filter['statusModule'] === 'fired') {
$this->filter['statusModuleOriginal'] = $this->filter['statusModule'];
$this->filter['statusModule'] = -1;
}
$selected_status = ($state !== false && $state !== self::TV_DEFAULT_AGENT_STATUS) ? $state : $this->filter['statusModule'];
$filter = [modules_get_state_condition($selected_status)];
@ -819,6 +834,11 @@ class Tree
protected function processAgent(&$agent, $server=false)
{
if ($this->filter['statusModule'] === 'fired') {
$this->filter['statusModuleOriginal'] = $this->filter['statusModule'];
$this->filter['statusModule'] = -1;
}
global $config;
$agent['type'] = 'agent';

View File

@ -1375,7 +1375,6 @@ var TreeController = {
.removeClass("leaf-closed")
.removeClass("leaf-error")
.addClass("leaf-loading");
$.ajax({
url: controller.ajaxURL,
type: "POST",
@ -1407,6 +1406,53 @@ var TreeController = {
data.tree.length > 0) ||
$group.length > 0
) {
if (controller.filter.statusModule === "fired") {
var newData = { success: data.success, tree: [] };
data.tree.forEach(element => {
// Agents.
if (
typeof element.counters !== "undefined" &&
element.counters.alerts > 0
) {
var treeTmp = element;
treeTmp.counters.critical = 0;
treeTmp.counters.not_init = 0;
treeTmp.counters.ok = 0;
treeTmp.counters.unknown = 0;
treeTmp.counters.warning = 0;
treeTmp.counters.total =
element.counters.alerts;
treeTmp.critical_count = 0;
treeTmp.normal_count = 0;
treeTmp.notinit_count = 0;
treeTmp.unknown_count = 0;
treeTmp.warning_count = 0;
treeTmp.total_count = element.fired_count;
treeTmp.state_critical = 0;
treeTmp.state_normal = 0;
treeTmp.state_notinit = 0;
treeTmp.state_unknown = 0;
treeTmp.state_warning = 0;
treeTmp.state_total = element.fired_count;
newData.tree.push(treeTmp);
data = newData;
}
// Modules.
if (element.alerts > 0) {
var treeTmp = element;
newData.tree.push(treeTmp);
data = newData;
}
});
}
$node.addClass("leaf-open");
if ($group.length <= 0) {
@ -1507,6 +1553,34 @@ var TreeController = {
this.reload();
},
init: function(data) {
if (data.filter.statusModule === "fired") {
const newData = {
ajaxUrl: data.ajaxURL,
baseURL: data.baseURL,
counterTitle: data.counterTitle,
detailRecipient: data.detailRecipient,
emptyMessage: data.emptyMessage,
filter: data.filter,
foundMessage: data.foundMessage,
page: data.page,
recipient: data.recipient,
tree: []
};
data.tree.forEach(element => {
if (element.counters.alerts > 0) {
element.counters.critical = 0;
element.counters.not_init = 0;
element.counters.ok = 0;
element.counters.unknown = 0;
element.counters.warning = 0;
element.counters.total = element.counters.alerts;
newData.tree.push(element);
}
});
data = newData;
}
if (
typeof data.recipient !== "undefined" &&
data.recipient.length > 0