diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index eb46b31a82..982a5dd976 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -894,9 +894,9 @@ class Tree { break; default: $sql = $this->getSqlExtended($item_for_count, $type, $rootType, $parent, $rootID, - $serverID, $agent_search_filter, $agent_status_filter, - $agents_join, $module_search_filter, $module_status_filter, - $modules_join, $module_status_join); + $agent_search_filter, $agent_status_filter, $agents_join, + $module_search_filter, $module_status_filter, $modules_join, + $module_status_join); } return $sql; @@ -904,15 +904,15 @@ class Tree { // Override this method protected function getSqlExtended ($item_for_count, $type, $rootType, $parent, $rootID, - $serverID, $agent_search_filter, $agent_status_filter, - $agents_join, $module_search_filter, $module_status_filter, - $modules_join, $module_status_join) { + $agent_search_filter, $agent_status_filter, $agents_join, + $module_search_filter, $module_status_filter, $modules_join, + $module_status_join) { return false; } protected function getItems ($item_for_count = false) { $sql = $this->getSql($item_for_count); - + if (empty($sql)) return array(); @@ -1079,11 +1079,8 @@ class Tree { // Match with the name and type if ($item['name'] == $item2['name'] && $item['type'] == $item2['type']) { // Add the matched ids - $resultItem['id'] = array(); $resultItem['id'][$item2['serverID']] = $item2['id']; - $resultItem['rootID'] = array(); $resultItem['rootID'][$item2['serverID']] = $item2['rootID']; - $resultItem['serverID'] = array(); $resultItem['serverID'][$item2['serverID']] = $item2['rootID']; // Add the matched counters @@ -1226,6 +1223,13 @@ class Tree { 'handle' => $winHandle ); } + + // Alerts fired image + $has_alerts = (bool) db_get_value('COUNT(DISTINCT(id_agent_module))', 'talert_template_modules', 'id_agent_module', $module['id']); + + if ($has_alerts) { + $module['alertsImageHTML'] = html_print_image("images/bell.png", true, array("title" => __('Module alerts'))); + } } protected function processModules (&$modules, $server = false) { @@ -1423,7 +1427,7 @@ class Tree { $items = array(); if ($this->serverID !== false) { - + $server = metaconsole_get_servers($this->serverID); if (metaconsole_connect($server) == NOERR) { db_clean_cache(); diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 8e4f8e01fb..e70bd121e2 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -372,6 +372,8 @@ TreeController = { // console.log(error); } }); + + $content.append($graphImage); } // Data pop-up @@ -393,12 +395,38 @@ TreeController = { // console.log(error); } }); + + $content.append($dataImage); } - $content - .append($graphImage) - .append($dataImage) - .append(element.name); + // Alerts + if (typeof element.alertsImageHTML != 'undefined' + && element.alertsImageHTML.length > 0) { + + var $alertsImage = $(element.alertsImageHTML); + + $alertsImage + .addClass("module-alerts") + .click(function (e) { + TreeNodeDetailController.getController().init({ + recipient: controller.detailRecipient, + type: 'alert', + id: element.id, + serverID: element.serverID, + baseURL: controller.baseURL, + ajaxURL: controller.ajaxURL, + ajaxPage: controller.ajaxPage + }); + + // Avoid the execution of the module detail event + e.stopPropagation(); + }) + .css('cursor', 'pointer'); + + $content.append($alertsImage); + } + + $content.append(element.name); break; case 'os': if (typeof element.icon != 'undefined' && element.icon.length > 0) {