mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 03:19:05 +02:00
10067-Alerts triggered filter tree view
This commit is contained in:
parent
73d7345844
commit
0fa03f28b3
@ -133,6 +133,11 @@ class Tree
|
|||||||
|
|
||||||
protected function getEmptyModuleFilterStatus()
|
protected function getEmptyModuleFilterStatus()
|
||||||
{
|
{
|
||||||
|
if ($this->filter['statusModule'] === 'fired') {
|
||||||
|
$this->filter['statusModuleOriginal'] = $this->filter['statusModule'];
|
||||||
|
$this->filter['statusModule'] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!isset($this->filter['statusModule']) ||
|
!isset($this->filter['statusModule']) ||
|
||||||
$this->filter['statusModule'] == -1
|
$this->filter['statusModule'] == -1
|
||||||
@ -288,6 +293,11 @@ class Tree
|
|||||||
|
|
||||||
protected function getModuleStatusFilter()
|
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';
|
$show_init_condition = ($this->filter['show_not_init_agents']) ? '' : ' AND ta.notinit_count <> ta.total_count';
|
||||||
|
|
||||||
if ($this->getEmptyModuleFilterStatus()) {
|
if ($this->getEmptyModuleFilterStatus()) {
|
||||||
@ -341,6 +351,11 @@ class Tree
|
|||||||
|
|
||||||
protected function getModuleStatusFilterFromTestado($state=false, $without_ands=false)
|
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'];
|
$selected_status = ($state !== false && $state !== self::TV_DEFAULT_AGENT_STATUS) ? $state : $this->filter['statusModule'];
|
||||||
|
|
||||||
$filter = [modules_get_state_condition($selected_status)];
|
$filter = [modules_get_state_condition($selected_status)];
|
||||||
@ -819,6 +834,11 @@ class Tree
|
|||||||
|
|
||||||
protected function processAgent(&$agent, $server=false)
|
protected function processAgent(&$agent, $server=false)
|
||||||
{
|
{
|
||||||
|
if ($this->filter['statusModule'] === 'fired') {
|
||||||
|
$this->filter['statusModuleOriginal'] = $this->filter['statusModule'];
|
||||||
|
$this->filter['statusModule'] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$agent['type'] = 'agent';
|
$agent['type'] = 'agent';
|
||||||
|
@ -1375,7 +1375,6 @@ var TreeController = {
|
|||||||
.removeClass("leaf-closed")
|
.removeClass("leaf-closed")
|
||||||
.removeClass("leaf-error")
|
.removeClass("leaf-error")
|
||||||
.addClass("leaf-loading");
|
.addClass("leaf-loading");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: controller.ajaxURL,
|
url: controller.ajaxURL,
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -1407,6 +1406,53 @@ var TreeController = {
|
|||||||
data.tree.length > 0) ||
|
data.tree.length > 0) ||
|
||||||
$group.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");
|
$node.addClass("leaf-open");
|
||||||
|
|
||||||
if ($group.length <= 0) {
|
if ($group.length <= 0) {
|
||||||
@ -1507,6 +1553,34 @@ var TreeController = {
|
|||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
init: function(data) {
|
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 (
|
if (
|
||||||
typeof data.recipient !== "undefined" &&
|
typeof data.recipient !== "undefined" &&
|
||||||
data.recipient.length > 0
|
data.recipient.length > 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user