2013-04-09 Miguel de Dios <miguel.dedios@artica.es>
* mobile/index.php, mobile/operation/groups.php, mobile/operation/agents.php, mobile/operation/alerts.php, mobile/operation/agent.php, mobile/operation/events.php, mobile/operation/modules.php, mobile/include/style/main.css: * include/functions_alerts.php include/functions_groups.php: some changes for the mobile. * operation/agentes/ver_agente.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7945 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
366f1c2b00
commit
d08ef0febc
|
@ -1,3 +1,15 @@
|
|||
2013-04-09 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* mobile/index.php, mobile/operation/groups.php,
|
||||
mobile/operation/agents.php, mobile/operation/alerts.php,
|
||||
mobile/operation/agent.php, mobile/operation/events.php,
|
||||
mobile/operation/modules.php, mobile/include/style/main.css:
|
||||
|
||||
* include/functions_alerts.php include/functions_groups.php: some
|
||||
changes for the mobile.
|
||||
|
||||
* operation/agentes/ver_agente.php: cleaned source code style.
|
||||
|
||||
2013-04-08 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* mobile/operation/modules.php, mobile/include/style/main.css: some
|
||||
|
|
|
@ -23,7 +23,7 @@ require_once($config['homedir'] . "/include/functions_agents.php");
|
|||
require_once($config['homedir'] . '/include/functions_modules.php');
|
||||
require_once($config['homedir'] . '/include/functions_users.php');
|
||||
|
||||
function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $standby = -1, $acl = false, $total = false) {
|
||||
function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $standby = -1, $acl = false, $total = false, $id_agent = 0) {
|
||||
$sql = "";
|
||||
$alerts = array();
|
||||
|
||||
|
@ -108,6 +108,10 @@ function alerts_get_alerts($id_group = 0, $free_search = "", $status = "all", $s
|
|||
OR t2.nombre LIKE "%' . $free_search . '%"
|
||||
OR t3.nombre LIKE "%' . $free_search . '%")';
|
||||
|
||||
if ($id_agent != 0) {
|
||||
$sql .= ' AND t3.id_agente = ' . $id_agent;
|
||||
}
|
||||
|
||||
$row_alerts = db_get_all_rows_sql($sql);
|
||||
|
||||
if ($total) {
|
||||
|
|
|
@ -775,7 +775,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
|
|||
else {
|
||||
//if ($data["total_agents"] > 0) {
|
||||
if (true) {
|
||||
$row[__('Agents')] = "<a href='index.php?page=agents&id_group=" . $id_group . "'>";
|
||||
$row[__('Agents')] = "<a class='link_count' href='index.php?page=agents&id_group=" . $id_group . "'>";
|
||||
$row[__('Agents')] .= $data["total_agents"];
|
||||
$row[__('Agents')] .= "</a>";
|
||||
}
|
||||
|
@ -804,7 +804,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
|
|||
else {
|
||||
//if ($data["agents_unknown"] > 0) {
|
||||
if (true) {
|
||||
$row[__('Agents unknown')] = "<a href='index.php?page=agents&id_group=" . $id_group . "&status=3'>";
|
||||
$row[__('Agents unknown')] = "<a class='link_count' href='index.php?page=agents&id_group=" . $id_group . "&status=3'>";
|
||||
$row[__('Agents unknown')] .= $data["agents_unknown"];
|
||||
$row[__('Agents unknown')] .= "</a>";
|
||||
}
|
||||
|
@ -830,7 +830,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
|
|||
else {
|
||||
//if ($data["monitor_unknown"] > 0) {
|
||||
if (true) {
|
||||
$row[__('Unknown')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=3'>";
|
||||
$row[__('Unknown')] = "<a class='link_count' href='index.php?page=modules&id_group=" . $id_group . "&status=3'>";
|
||||
$row[__('Unknown')] .= $data["monitor_unknown"];
|
||||
$row[__('Unknown')] .= "</a>";
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
|
|||
else {
|
||||
//if ($data["monitor_not_init"] > 0) {
|
||||
if (true) {
|
||||
$row[__('Not init')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=5'>";
|
||||
$row[__('Not init')] = "<a class='link_count' href='index.php?page=modules&id_group=" . $id_group . "&status=5'>";
|
||||
$row[__('Not init')] .= $data["monitor_not_init"];
|
||||
$row[__('Not init')] .= "</a>";
|
||||
}
|
||||
|
@ -883,7 +883,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
|
|||
else {
|
||||
//if ($data["monitor_ok"] > 0) {
|
||||
if (true) {
|
||||
$row[__('Normal')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=0'>";
|
||||
$row[__('Normal')] = "<a class='link_count' href='index.php?page=modules&id_group=" . $id_group . "&status=0'>";
|
||||
$row[__('Normal')] .= $data["monitor_ok"];
|
||||
$row[__('Normal')] .= "</a>";
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
|
|||
else {
|
||||
//if ($data["monitor_warning"] > 0) {
|
||||
if (true) {
|
||||
$row[__('Warning')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=1'>";
|
||||
$row[__('Warning')] = "<a class='link_count' href='index.php?page=modules&id_group=" . $id_group . "&status=1'>";
|
||||
$row[__('Warning')] .= $data["monitor_warning"];
|
||||
$row[__('Warning')] .= "</a>";
|
||||
}
|
||||
|
@ -937,7 +937,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
|
|||
else {
|
||||
//if ($data["monitor_critical"] > 0) {
|
||||
if (true) {
|
||||
$row[__('Critical')] = "<a href='index.php?page=modules&id_group=" . $id_group . "&status=2'>";
|
||||
$row[__('Critical')] = "<a class='link_count' href='index.php?page=modules&id_group=" . $id_group . "&status=2'>";
|
||||
$row[__('Critical')] .= $data["monitor_critical"];
|
||||
$row[__('Critical')] .= "</a>";
|
||||
}
|
||||
|
@ -964,7 +964,7 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups, $
|
|||
else {
|
||||
//if ($data["monitor_alerts_fired"] > 0) {
|
||||
if (true) {
|
||||
$row[__('Alerts fired')] = "<a href='index.php?page=alerts&group=" . $id_group . "&status=fired'>";;
|
||||
$row[__('Alerts fired')] = "<a class='link_count' href='index.php?page=alerts&group=" . $id_group . "&status=fired'>";;
|
||||
$row[__('Alerts fired')] .= $data["monitor_alerts_fired"];
|
||||
$row[__('Alerts fired')] .= "</a>";
|
||||
}
|
||||
|
|
|
@ -226,6 +226,17 @@ tr.group_view_data, .group_view_data {
|
|||
text-shadow: none !important;
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
.list_groups .link_count {
|
||||
display: inline !important;
|
||||
}
|
||||
|
||||
.list_groups .link_count.ui-link-inherit {
|
||||
margin-top: -5px;
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 0;
|
||||
}
|
||||
/*END-----------Groups styles-----------------------------------------*/
|
||||
|
||||
|
||||
|
@ -432,6 +443,10 @@ table#list_events th {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.cell_0 a {
|
||||
color: #000000 !important;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 35em) {
|
||||
#list_agents .cell_2 .ui-table-cell-label,
|
||||
#list_agents .cell_3 .ui-table-cell-label,
|
||||
|
|
|
@ -33,6 +33,7 @@ require_once('operation/alerts.php');
|
|||
require_once('operation/agents.php');
|
||||
require_once('operation/modules.php');
|
||||
require_once('operation/module_graph.php');
|
||||
require_once('operation/agent.php');
|
||||
$enterpriseHook = enterprise_include('mobile/include/enterprise.class.php');
|
||||
|
||||
$system = System::getInstance();
|
||||
|
@ -124,6 +125,10 @@ switch ($action) {
|
|||
$module_graph = new ModuleGraph();
|
||||
$module_graph->show();
|
||||
break;
|
||||
case 'agent':
|
||||
$agent = new Agent();
|
||||
$agent->show();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
include_once("../include/functions_users.php");
|
||||
|
||||
class Agent {
|
||||
private $correct_acl = false;
|
||||
private $id = 0;
|
||||
private $agent = null;
|
||||
|
||||
function __construct() {
|
||||
$system = System::getInstance();
|
||||
|
||||
$this->id = $system->getRequest('id', 0);
|
||||
$this->agent = agents_get_agents(array(
|
||||
'disabled' => 0,
|
||||
'id_agente' => $this->id), array('*'));
|
||||
|
||||
if (!empty($this->agent)) {
|
||||
$this->agent = $this->agent[0];
|
||||
|
||||
|
||||
if ($system->checkACL('AR', $this->agent['id_grupo'])) {
|
||||
$this->correct_acl = true;
|
||||
}
|
||||
else {
|
||||
$this->correct_acl = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->agent = null;
|
||||
$this->correct_acl = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function show() {
|
||||
if (!$this->correct_acl) {
|
||||
$this->show_fail_acl();
|
||||
}
|
||||
else {
|
||||
$this->show_agent();
|
||||
}
|
||||
}
|
||||
|
||||
private function show_fail_acl() {
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
$ui->createPage();
|
||||
|
||||
$options['type'] = 'onStart';
|
||||
$options['title_text'] = __('You don\'t have access to this page');
|
||||
$options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database');
|
||||
$ui->addDialog($options);
|
||||
|
||||
$ui->showPage();
|
||||
}
|
||||
|
||||
private function show_agent() {
|
||||
$ui = Ui::getInstance();
|
||||
$system = System::getInstance();
|
||||
|
||||
$ui->createPage();
|
||||
if ($this->id != 0) {
|
||||
$agent_name = (string) agents_get_name ($this->id);
|
||||
|
||||
$ui->createDefaultHeader(sprintf(__("PandoraFMS: %s"), $agent_name));
|
||||
}
|
||||
else {
|
||||
$ui->createDefaultHeader(__("PandoraFMS: Agents"));
|
||||
}
|
||||
$ui->showFooter(false);
|
||||
$ui->beginContent();
|
||||
if (empty($this->agent)) {
|
||||
$ui->contentAddHtml('<span style="color: red;">' . __('No agent found') . '</span>');
|
||||
}
|
||||
else {
|
||||
$ui->contentBeginGrid();
|
||||
if ($this->agent['disabled']) {
|
||||
$agent_name = "<em>" . $agent_name . "</em>" . ui_print_help_tip(__('Disabled'), true);
|
||||
}
|
||||
else if ($agent['quiet']) {
|
||||
$agent_name = "<em>" . $agent_name . " " . html_print_image("images/dot_green.disabled.png", true, array("border" => '0', "title" => __('Quiet'), "alt" => "")) . "</em>";
|
||||
}
|
||||
else {
|
||||
$agent_name = $agent_name;
|
||||
}
|
||||
|
||||
|
||||
$addresses = agents_get_addresses($this->id);
|
||||
$address = agents_get_address($id_agente);
|
||||
foreach ($addresses as $k => $add) {
|
||||
if($add == $address) {
|
||||
unset($addresses[$k]);
|
||||
}
|
||||
}
|
||||
$ip = html_print_image('images/world.png', true, array('title' => __('IP address'))) . ' ';
|
||||
$ip .= empty($address) ? '<em>' . __('N/A') . '</em>' : $address;
|
||||
if (!empty($addresses)) {
|
||||
$ip .= ui_print_help_tip(__('Other IP addresses').': <br>'.implode('<br>',$addresses), true);
|
||||
}
|
||||
|
||||
$last_contant = '<b>' . __('Last contact') . ' / ' . __('Remote') . '</b> '
|
||||
.ui_print_timestamp ($agent["ultimo_contacto"], true);
|
||||
|
||||
$description =
|
||||
empty($agent["comentarios"]) ? '<em>' . __('N/A') . '</em>' : $this->agent["comentarios"];
|
||||
|
||||
|
||||
|
||||
$html = ui_print_group_icon ($this->agent["id_grupo"], true) . ' ';
|
||||
$html .= $agent_name . '<br />';
|
||||
$html .= $ip . '<br />';
|
||||
$html .= $last_contant . '<br />';
|
||||
$html .= $description . '<br />';
|
||||
|
||||
$ui->contentGridAddCell($html);
|
||||
ob_start();
|
||||
$html = graph_agent_status ($this->id, 160, 160, true);
|
||||
$graph_js = ob_get_clean();
|
||||
$html = $graph_js . $html;
|
||||
$html .= "<b>" . __('Events (24h)') . "</b><br />";
|
||||
$html .= graph_graphic_agentevents ($id_agente, 250, 15, 86400, '', true);
|
||||
$ui->contentGridAddCell($html);
|
||||
$ui->contentEndGrid();
|
||||
|
||||
|
||||
$modules = new Modules();
|
||||
$filters = array('id_agent' => $this->id, 'all_modules' => true);
|
||||
$modules->setFilters($filters);
|
||||
$modules->disabledColumns(array('agent'));
|
||||
$ui->contentBeginCollapsible(__('Modules'));
|
||||
$ui->contentCollapsibleAddItem($modules->listModulesHtml(0, true));
|
||||
$ui->contentEndCollapsible();
|
||||
|
||||
$alerts = new Alerts();
|
||||
$filters = array('id_agent' => $this->id, 'all_alerts' => true);
|
||||
$alerts->setFilters($filters);
|
||||
$alerts->disabledColumns(array('agent'));
|
||||
$ui->contentBeginCollapsible(__('Alerts'));
|
||||
$ui->contentCollapsibleAddItem($alerts->listAlertsHtml(true));
|
||||
$ui->contentEndCollapsible();
|
||||
|
||||
$events = new Events();
|
||||
$filters = array('id_agent' => $this->id);
|
||||
$events->setFilters($filters);
|
||||
$events->disabledColumns(array('agent'));
|
||||
$events->setReadOnly();
|
||||
$ui->contentBeginCollapsible(sprintf(__('Last %s Events'), $system->getPageSize()));
|
||||
$ui->contentCollapsibleAddItem($events->listEventsHtml(0, true));
|
||||
$ui->contentEndCollapsible();
|
||||
}
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
}
|
||||
}
|
|
@ -248,11 +248,11 @@ class Agents {
|
|||
|
||||
if (empty($agents_db))
|
||||
$agents_db = array();
|
||||
|
||||
html_debug_print($agents_db, true);
|
||||
foreach ($agents_db as $agent) {
|
||||
$row = array();
|
||||
|
||||
$row[0] = $row[__('Agent')] = io_safe_output($agent['nombre']);
|
||||
$row[0] = $row[__('Agent')] = '<a class="ui-link" data-ajax="false" href="index.php?page=agent&id=' . $agent['id_agente'] . '">' . io_safe_output($agent['nombre']) . '</a>';
|
||||
$row[1] = $row[__('Description')] = '<span class="small">' .
|
||||
ui_print_truncate_text($agent["description"], 'description', false, true) .
|
||||
'</span>';
|
||||
|
|
|
@ -22,10 +22,14 @@ class Alerts {
|
|||
private $group = 0;
|
||||
private $status = 'all';
|
||||
private $standby = -1;
|
||||
private $id_agent = 0;
|
||||
private $all_alerts = false;
|
||||
|
||||
private $alert_status_items = null;
|
||||
private $alert_standby_items = null;
|
||||
|
||||
private $columns = null;
|
||||
|
||||
function __construct() {
|
||||
$this->alert_status_items = array(
|
||||
'all_enabled' => __('All (Enabled)'),
|
||||
|
@ -39,6 +43,8 @@ class Alerts {
|
|||
'1' => __('Standby on'),
|
||||
'0' => __('Standby off'));
|
||||
|
||||
$this->columns = array('agent' => 1);
|
||||
|
||||
$system = System::getInstance();
|
||||
|
||||
if ($system->checkACL($this->acl)) {
|
||||
|
@ -86,6 +92,15 @@ class Alerts {
|
|||
}
|
||||
}
|
||||
|
||||
public function setFilters($filters) {
|
||||
if (isset($filters['id_agent'])) {
|
||||
$this->id_agent = $filters['id_agent'];
|
||||
}
|
||||
if (isset($filters['all_alerts'])) {
|
||||
$this->all_alerts = $filters['all_alerts'];
|
||||
}
|
||||
}
|
||||
|
||||
public function ajax($parameter2 = false) {
|
||||
$system = System::getInstance();
|
||||
|
||||
|
@ -193,13 +208,20 @@ class Alerts {
|
|||
$ui->showPage();
|
||||
}
|
||||
|
||||
public function disabledColumns($columns = null) {
|
||||
if (!empty($columns)) {
|
||||
foreach ($columns as $column) {
|
||||
unset($this->columns[$column]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function listAlertsHtml () {
|
||||
public function listAlertsHtml ($return = false) {
|
||||
$countAlerts = alerts_get_alerts($this->group,
|
||||
$this->free_search, $this->status, $this->standby, "LM", true);
|
||||
$this->free_search, $this->status, $this->standby, "LM", true, $this->id_agent);
|
||||
|
||||
$alerts = alerts_get_alerts($this->group,
|
||||
$this->free_search, $this->status, $this->standby, "LM");
|
||||
$this->free_search, $this->status, $this->standby, "LM", false, $this->id_agent);
|
||||
if (empty($alerts))
|
||||
$alerts = array();
|
||||
|
||||
|
@ -226,8 +248,10 @@ class Alerts {
|
|||
}
|
||||
|
||||
$row = array();
|
||||
$row[__('Agent')] = sprintf($disabled_style,
|
||||
'<a href="index.php?page=agent&id_agente=' . $alert['id_agente'] . '">' . io_safe_output($alert['agent_name'])) . '</a>';
|
||||
if ($this->columns['agent']) {
|
||||
$row[__('Agent')] = sprintf($disabled_style,
|
||||
'<a class="ui-link" data-ajax="false" href="index.php?page=agent&id=' . $alert['id_agente'] . '">' . io_safe_output($alert['agent_name'])) . '</a>';
|
||||
}
|
||||
$row[__('Module')] = sprintf($disabled_style,
|
||||
io_safe_output($alert['module_name']));
|
||||
$row[__('Template')] = sprintf($disabled_style,
|
||||
|
@ -242,12 +266,23 @@ class Alerts {
|
|||
|
||||
$ui = UI::getInstance();
|
||||
if (empty($table)) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No alerts') . '</p>');
|
||||
$html = '<p style="color: #ff0000;">' . __('No alerts') . '</p>';
|
||||
if (!$return) {
|
||||
$ui->contentAddHtml($html);
|
||||
}
|
||||
else {
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$tableHTML = new Table();
|
||||
$tableHTML->importFromHash($table);
|
||||
$ui->contentAddHtml($tableHTML->getHTML());
|
||||
if (!$return) {
|
||||
$ui->contentAddHtml($tableHTML->getHTML());
|
||||
}
|
||||
else {
|
||||
return $tableHTML->getHTML();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,18 @@ class Events {
|
|||
private $severity = -1;
|
||||
private $filter = 0;
|
||||
private $group = 0;
|
||||
private $id_agent = 0;
|
||||
private $all_events = false;
|
||||
|
||||
private $columns = null;
|
||||
|
||||
private $readOnly = false;
|
||||
|
||||
function __construct() {
|
||||
$system = System::getInstance();
|
||||
|
||||
$this->columns = array('agent' => 1);
|
||||
|
||||
if ($system->checkACL($this->acl)) {
|
||||
$this->correct_acl = true;
|
||||
}
|
||||
|
@ -36,6 +44,10 @@ class Events {
|
|||
}
|
||||
}
|
||||
|
||||
public function setReadOnly() {
|
||||
$this->readOnly = true;
|
||||
}
|
||||
|
||||
public function ajax($parameter2 = false) {
|
||||
$system = System::getInstance();
|
||||
|
||||
|
@ -262,6 +274,14 @@ class Events {
|
|||
}
|
||||
}
|
||||
|
||||
public function disabledColumns($columns = null) {
|
||||
if (!empty($columns)) {
|
||||
foreach ($columns as $column) {
|
||||
unset($this->columns[$column]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function eventsGetFilters() {
|
||||
$system = System::getInstance();
|
||||
$user = User::getInstance();
|
||||
|
@ -325,6 +345,15 @@ class Events {
|
|||
}
|
||||
}
|
||||
|
||||
public function setFilters($filters) {
|
||||
if (isset($filters['id_agent'])) {
|
||||
$this->id_agent = $filters['id_agent'];
|
||||
}
|
||||
if (isset($filters['all_events'])) {
|
||||
$this->all_events = $filters['all_events'];
|
||||
}
|
||||
}
|
||||
|
||||
private function loadPresetFilter() {
|
||||
$filter = db_get_row('tevent_filter', 'id_filter', $this->filter);
|
||||
|
||||
|
@ -621,6 +650,10 @@ class Events {
|
|||
$sql_post = " AND id_grupo = " . $this->group;
|
||||
}
|
||||
|
||||
if ($this->id_agente > 0) {
|
||||
$sql_post = " AND id_agente = " . $this->id_agente;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -635,7 +668,7 @@ class Events {
|
|||
return array('events' => $events_db, 'total' => $total_events);
|
||||
}
|
||||
|
||||
private function listEventsHtml($page = 0) {
|
||||
public function listEventsHtml($page = 0, $return = false) {
|
||||
$system = System::getInstance();
|
||||
|
||||
$listEvents = $this->getListEvents($page);
|
||||
|
@ -656,8 +689,13 @@ class Events {
|
|||
// . get_priority_class($event['criticity']);
|
||||
|
||||
$row = array();
|
||||
$row[$field_event_name] = '<a href="javascript: openDetails(' . $event['id_evento'] . ')">' .
|
||||
io_safe_output($event['evento']) . '</a>';
|
||||
if ($this->readOnly) {
|
||||
$row[$field_event_name] = io_safe_output($event['evento']);
|
||||
}
|
||||
else {
|
||||
$row[$field_event_name] = '<a href="javascript: openDetails(' . $event['id_evento'] . ')">' .
|
||||
io_safe_output($event['evento']) . '</a>';
|
||||
}
|
||||
/*
|
||||
switch ($event['estado']) {
|
||||
case 0:
|
||||
|
@ -676,8 +714,11 @@ class Events {
|
|||
*/
|
||||
|
||||
$row[$field_timestamp] = ui_print_timestamp ($event['timestamp_rep'], true);
|
||||
$row[$field_agent] = '<a href="index.php?page=agent&id_agent=' . $event["id_agente"] . '">' .
|
||||
(string) agents_get_name($event["id_agente"]) . '</a>';
|
||||
|
||||
if ($this->columns['agent']) {
|
||||
$row[$field_agent] = '<a class="ui-link" data-ajax="false" href="index.php?page=agent&id=' . $event["id_agente"] . '">' .
|
||||
(string) agents_get_name($event["id_agente"]) . '</a>';
|
||||
}
|
||||
|
||||
$row[$field_status] =
|
||||
html_print_image ("mobile/images/" .
|
||||
|
@ -705,25 +746,35 @@ class Events {
|
|||
|
||||
$ui = Ui::getInstance();
|
||||
if (empty($events)) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No events') . '</p>');
|
||||
if (!$return) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No events') . '</p>');
|
||||
}
|
||||
else {
|
||||
return '<p style="color: #ff0000;">' . __('No events') . '</p>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$table = new Table();
|
||||
$table->id = 'list_events';
|
||||
$table->setRowClass($row_class);
|
||||
$table->importFromHash($events);
|
||||
$ui->contentAddHtml($table->getHTML());
|
||||
|
||||
if ($system->getPageSize() < $total_events) {
|
||||
$ui->contentAddHtml('<div id="loading_rows">' .
|
||||
html_print_image('images/spinner.gif', true) .
|
||||
' ' . __('Loading...') .
|
||||
'</div>');
|
||||
if (!$return) {
|
||||
$ui->contentAddHtml($table->getHTML());
|
||||
|
||||
$this->addJavascriptAddBottom();
|
||||
if ($system->getPageSize() < $total_events) {
|
||||
$ui->contentAddHtml('<div id="loading_rows">' .
|
||||
html_print_image('images/spinner.gif', true) .
|
||||
' ' . __('Loading...') .
|
||||
'</div>');
|
||||
|
||||
$this->addJavascriptAddBottom();
|
||||
}
|
||||
|
||||
$this->addJavascriptDialog();
|
||||
}
|
||||
else {
|
||||
return $table->getHTML();
|
||||
}
|
||||
|
||||
$this->addJavascriptDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class Groups {
|
|||
$ui->showFooter(false);
|
||||
$ui->beginContent();
|
||||
|
||||
$ui->contentAddHtml('<div data-role="collapsible-set" data-theme="a" data-content-theme="d">');
|
||||
$ui->contentAddHtml('<div class="list_groups" data-role="collapsible-set" data-theme="a" data-content-theme="d">');
|
||||
$count = 0;
|
||||
foreach ($this->groups as $group) {
|
||||
$ui->contentAddHtml('
|
||||
|
|
|
@ -22,9 +22,13 @@ class Modules {
|
|||
private $free_search = '';
|
||||
private $module_group = -1;
|
||||
private $tag = '';
|
||||
private $id_agent = 0;
|
||||
private $all_modules = false;
|
||||
|
||||
private $list_status = null;
|
||||
|
||||
private $columns = null;
|
||||
|
||||
function __construct() {
|
||||
$system = System::getInstance();
|
||||
|
||||
|
@ -37,6 +41,8 @@ class Modules {
|
|||
AGENT_MODULE_STATUS_NOT_NORMAL => __('Not normal'), //default
|
||||
AGENT_MODULE_STATUS_NOT_INIT => __('Not init'));
|
||||
|
||||
$this->columns = array('agent' => 1);
|
||||
|
||||
if ($system->checkACL($this->acl)) {
|
||||
$this->correct_acl = true;
|
||||
}
|
||||
|
@ -72,6 +78,23 @@ class Modules {
|
|||
}
|
||||
}
|
||||
|
||||
public function setFilters($filters) {
|
||||
if (isset($filters['id_agent'])) {
|
||||
$this->id_agent = $filters['id_agent'];
|
||||
}
|
||||
if (isset($filters['all_modules'])) {
|
||||
$this->all_modules = $filters['all_modules'];
|
||||
}
|
||||
}
|
||||
|
||||
public function disabledColumns($columns = null) {
|
||||
if (!empty($columns)) {
|
||||
foreach ($columns as $column) {
|
||||
unset($this->columns[$column]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getFilters() {
|
||||
$system = System::getInstance();
|
||||
$user = User::getInstance();
|
||||
|
@ -233,6 +256,12 @@ class Modules {
|
|||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo";
|
||||
|
||||
|
||||
// Part SQL for the id_agent
|
||||
$sql_conditions_agent = '';
|
||||
if ($this->id_agent != 0) {
|
||||
$sql_conditions_agent = " AND tagente_modulo.id_agente = " . $this->id_agent;
|
||||
}
|
||||
|
||||
// Part SQL for the Group
|
||||
if ($this->group != 0) {
|
||||
$sql_conditions_group = " AND tagente.id_grupo = " . $this->group;
|
||||
|
@ -293,7 +322,7 @@ class Modules {
|
|||
WHERE ttag_module.id_tag = " . $this->tag . ")";
|
||||
}
|
||||
|
||||
$sql_conditions_all = $sql_conditions_base . $sql_conditions .
|
||||
$sql_conditions_all = $sql_conditions_base . $sql_conditions_agent . $sql_conditions .
|
||||
$sql_conditions_group . $sql_conditions_tags;
|
||||
|
||||
|
||||
|
@ -338,10 +367,12 @@ class Modules {
|
|||
$sql = " FROM tagente, tagente_modulo, tagente_estado" .
|
||||
$sql_conditions_all;
|
||||
|
||||
$sql_limit = "ORDER BY tagente.nombre ASC
|
||||
LIMIT " . (int)($page * $system->getPageSize()) . "," . (int)$system->getPageSize();
|
||||
$sql_limit = "ORDER BY tagente.nombre ASC ";
|
||||
if (!$this->all_modules) {
|
||||
$sql_limit = " LIMIT " . (int)($page * $system->getPageSize()) . "," . (int)$system->getPageSize();
|
||||
}
|
||||
|
||||
$total = db_get_value_sql($sql_total. $sql);
|
||||
$total = db_get_value_sql($sql_total. $sql); html_debug_print($sql_select . $sql . $sql_limit, true);
|
||||
$modules_db = db_get_all_rows_sql($sql_select . $sql . $sql_limit);
|
||||
|
||||
if (empty($modules_db)) {
|
||||
|
@ -351,9 +382,13 @@ class Modules {
|
|||
$modules = array();
|
||||
foreach ($modules_db as $module) {
|
||||
$row = array();
|
||||
$row[0] = $row[__('Agent name')] =
|
||||
'<span class="data"><span class="show_collapside" style="display: none; font-weight: bolder;">' . __('Agent') . ' </span>' .
|
||||
$module['agent_name'] . '</span>';
|
||||
if ($this->columns['agent']) {
|
||||
$row[0] = $row[__('Agent name')] =
|
||||
'<span class="data"><span class="show_collapside" style="display: none; font-weight: bolder;">' . __('Agent') . ' </span>' .
|
||||
'<a class="ui-link" data-ajax="false" href="index.php?page=agent&id=' . $module["id_agent"] . '">' . $module['agent_name'] . '</a>' .
|
||||
'</span>';
|
||||
}
|
||||
|
||||
$row[2] = $row[__('Module name')] =
|
||||
'<span class="data"><span class="show_collapside" style="display: none; font-weight: bolder;">' . __('Module') . ' </span>' .
|
||||
$module['module_name'];
|
||||
|
@ -458,7 +493,9 @@ class Modules {
|
|||
' ' . $output . '</a>' . '</span>';
|
||||
|
||||
if (!$ajax) {
|
||||
unset($row[0]);
|
||||
if ($this->columns['agent']) {
|
||||
unset($row[0]);
|
||||
}
|
||||
unset($row[1]);
|
||||
unset($row[2]);
|
||||
unset($row[4]);
|
||||
|
@ -474,31 +511,43 @@ class Modules {
|
|||
return array('modules' => $modules, 'total' => $total);
|
||||
}
|
||||
|
||||
private function listModulesHtml($page = 0) {
|
||||
public function listModulesHtml($page = 0, $return = false) {
|
||||
$system = System::getInstance();
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
$listModules = $this->getListModules($page);
|
||||
$ui->debug($listModules, true);
|
||||
//$ui->debug($listModules, true);
|
||||
|
||||
if ($listModules['total'] == 0) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No modules') . '</p>');
|
||||
$html = '<p style="color: #ff0000;">' . __('No modules') . '</p>';
|
||||
if (!$return) {
|
||||
$ui->contentAddHtml($html);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$table = new Table();
|
||||
$table->id = 'list_Modules';
|
||||
$table->importFromHash($listModules['modules']);
|
||||
$ui->contentAddHtml($table->getHTML());
|
||||
if (!$return) {
|
||||
$ui->contentAddHtml($table->getHTML());
|
||||
}
|
||||
else {
|
||||
$html .= $table->getHTML();
|
||||
}
|
||||
|
||||
if ($system->getPageSize() < $listModules['total']) {
|
||||
$ui->contentAddHtml('<div id="loading_rows">' .
|
||||
html_print_image('images/spinner.gif', true) .
|
||||
' ' . __('Loading...') .
|
||||
'</div>');
|
||||
|
||||
$this->addJavascriptAddBottom();
|
||||
if (!$this->all_modules) {
|
||||
if ($system->getPageSize() < $listModules['total']) {
|
||||
$ui->contentAddHtml('<div id="loading_rows">' .
|
||||
html_print_image('images/spinner.gif', true) .
|
||||
' ' . __('Loading...') .
|
||||
'</div>');
|
||||
|
||||
$this->addJavascriptAddBottom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function addJavascriptAddBottom() {
|
||||
|
|
|
@ -136,7 +136,7 @@ if (is_ajax ()) {
|
|||
AND id_alert_template = '.$id_template.'
|
||||
AND id_agente IN (' . implode(',', $idAgents) . ')';
|
||||
|
||||
if($selection_mode == 'common') {
|
||||
if ($selection_mode == 'common') {
|
||||
$sql .= ' AND (
|
||||
SELECT count(nombre)
|
||||
FROM tagente_modulo t3, talert_template_modules t4
|
||||
|
@ -847,7 +847,7 @@ foreach($config['extensions'] as $extension) {
|
|||
|
||||
//Check if OS is vmware
|
||||
$id_remote_field = db_get_value ("id_field", "tagent_custom_fields", "name", "vmware_type");
|
||||
|
||||
|
||||
$vmware_type = db_get_value_filter("description", "tagent_custom_data", array("id_field" => $id_remote_field, "id_agent" => $agent["id_agente"]));
|
||||
|
||||
if ($vmware_type != "vm") {
|
||||
|
|
Loading…
Reference in New Issue