From 8b1b4fc521611e87b19ca17e98d575b586912be5 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Wed, 28 Sep 2016 17:08:44 +0200 Subject: [PATCH] Fixed version mobile in metaconsole version. Internal ticket: 79 --- .../include/functions_reporting.php | 24 +-- pandora_console/include/functions_ui.php | 16 +- pandora_console/mobile/include/style/main.css | 2 - pandora_console/mobile/index.php | 4 +- pandora_console/mobile/operation/agent.php | 53 +++++-- pandora_console/mobile/operation/agents.php | 98 ++++++++---- pandora_console/mobile/operation/events.php | 28 ++-- pandora_console/mobile/operation/groups.php | 144 ++++++++++-------- pandora_console/mobile/operation/home.php | 120 ++++++++------- pandora_console/mobile/operation/modules.php | 33 +++- pandora_console/mobile/operation/tactical.php | 75 +++++++-- 11 files changed, 387 insertions(+), 210 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 23bd930558..d5ef8e643e 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -5441,15 +5441,15 @@ function reporting_get_stats_alerts($data, $links = false) { $table_al = html_get_predefined_table(); $tdata = array(); - $tdata[0] = html_print_image('images/bell.png', true, array('title' => __('Defined alerts'))); + $tdata[0] = html_print_image('images/bell.png', true, array('title' => __('Defined alerts')), false, false, false, true); $tdata[1] = $data["monitor_alerts"] <= 0 ? '-' : $data["monitor_alerts"]; $tdata[1] = '' . $tdata[1] . ''; - if($data["monitor_alerts"]>$data["total_agents"] && !enterprise_installed()){ + if($data["monitor_alerts"] > $data["total_agents"] && !enterprise_installed()) { $tdata[2] = "
"; } - $tdata[3] = html_print_image('images/bell_error.png', true, array('title' => __('Fired alerts'))); + $tdata[3] = html_print_image('images/bell_error.png', true, array('title' => __('Fired alerts')), false, false, false, true); $tdata[4] = $data["monitor_alerts_fired"] <= 0 ? '-' : $data["monitor_alerts_fired"]; $tdata[4] = '' . $tdata[4] . ''; $table_al->rowclass[] = ''; @@ -5513,29 +5513,29 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he $table_mbs = html_get_predefined_table(); $tdata = array(); - $tdata[0] = html_print_image('images/module_critical.png', true, array('title' => __('Monitor critical'))); + $tdata[0] = html_print_image('images/module_critical.png', true, array('title' => __('Monitor critical')), false, false, false, true); $tdata[1] = $data["monitor_critical"] <= 0 ? '-' : $data["monitor_critical"]; $tdata[1] = '' . $tdata[1] . ''; - $tdata[2] = html_print_image('images/module_warning.png', true, array('title' => __('Monitor warning'))); + $tdata[2] = html_print_image('images/module_warning.png', true, array('title' => __('Monitor warning')), false, false, false, true); $tdata[3] = $data["monitor_warning"] <= 0 ? '-' : $data["monitor_warning"]; $tdata[3] = '' . $tdata[3] . ''; $table_mbs->rowclass[] = ''; $table_mbs->data[] = $tdata; $tdata = array(); - $tdata[0] = html_print_image('images/module_ok.png', true, array('title' => __('Monitor normal'))); + $tdata[0] = html_print_image('images/module_ok.png', true, array('title' => __('Monitor normal')), false, false, false, true); $tdata[1] = $data["monitor_ok"] <= 0 ? '-' : $data["monitor_ok"]; $tdata[1] = '' . $tdata[1] . ''; - $tdata[2] = html_print_image('images/module_unknown.png', true, array('title' => __('Monitor unknown'))); + $tdata[2] = html_print_image('images/module_unknown.png', true, array('title' => __('Monitor unknown')), false, false, false, true); $tdata[3] = $data["monitor_unknown"] <= 0 ? '-' : $data["monitor_unknown"]; $tdata[3] = '' . $tdata[3] . ''; $table_mbs->rowclass[] = ''; $table_mbs->data[] = $tdata; $tdata = array(); - $tdata[0] = html_print_image('images/module_notinit.png', true, array('title' => __('Monitor not init'))); + $tdata[0] = html_print_image('images/module_notinit.png', true, array('title' => __('Monitor not init')), false, false, false, true); $tdata[1] = $data["monitor_not_init"] <= 0 ? '-' : $data["monitor_not_init"]; $tdata[1] = '' . $tdata[1] . ''; @@ -5555,7 +5555,7 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he $table_mbs->data[] = $tdata; } - if(!defined("METACONSOLE")) { + if(!is_metaconsole()) { $output = '
' . @@ -5604,7 +5604,7 @@ function reporting_get_stats_agents_monitors($data) { $table_am = html_get_predefined_table(); $tdata = array(); - $tdata[0] = html_print_image('images/agent.png', true, array('title' => __('Total agents'))); + $tdata[0] = html_print_image('images/agent.png', true, array('title' => __('Total agents')), false, false, false, true); $tdata[1] = $data["total_agents"] <= 0 ? '-' : $data["total_agents"]; $tdata[1] = '' . $tdata[1] . ''; @@ -5612,11 +5612,11 @@ function reporting_get_stats_agents_monitors($data) { $tdata[2] = "
"; } - $tdata[3] = html_print_image('images/module.png', true, array('title' => __('Monitor checks'))); + $tdata[3] = html_print_image('images/module.png', true, array('title' => __('Monitor checks')), false, false, false, true); $tdata[4] = $data["monitor_checks"] <= 0 ? '-' : $data["monitor_checks"]; $tdata[4] = '' . $tdata[4] . ''; - if(($data["monitor_checks"]/$data["total_agents"]>100) && !enterprise_installed()){ + if(($data["monitor_checks"]/$data["total_agents"] > 100) && !enterprise_installed()) { $tdata[5] = "
"; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index afb4ea55b2..33f806b8c1 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -554,7 +554,7 @@ function ui_print_group_icon ($id_group, $return = false, $path = "groups_small" $output .= '  '; else { $output .= html_print_image("images/" . $path . "/" . $icon . ".png", - true, array("style" => $style, "class" => "bot", "alt" => groups_get_name($id_group, true), "title" => groups_get_name ($id_group, true))); + true, array("style" => $style, "class" => "bot", "alt" => groups_get_name($id_group, true), "title" => groups_get_name ($id_group, true)), false, false, false, true); } } @@ -629,7 +629,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, if (empty ($icon)) { if ($only_src) { $output = html_print_image("images/" . $subfolter . "/unknown.png", - true, $options, true, $relative); + true, $options, true, $relative, false, true); } else { return "-"; @@ -637,13 +637,13 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, } else if ($apply_skin) { if ($only_src) { - $output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, true, $relative); + $output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, true, $relative, false, true); } else { if (!isset($options['title'])) { $options['title'] = $os_name; } - $output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative); + $output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative, false, true); } } else @@ -1300,10 +1300,10 @@ function ui_process_page_head ($string, $bitfield) { '; - if(defined ('METACONSOLE')){ + if(is_metaconsole()) { $output .=''; } - else{ + else { $output .=''; } $output .=' @@ -1835,7 +1835,7 @@ function ui_print_session_action_icon ($action, $return = false) { $output = ''; foreach($key_icon as $key => $icon) { if (stristr($action, $key) !== false) { - $output = html_print_image($icon, true, array('title' => $action)) . ' '; + $output = html_print_image($icon, true, array('title' => $action), false, false, false, true) . ' '; break; } } @@ -2076,7 +2076,7 @@ function ui_print_status_image ($type, $title = "", $return = false, $options = $options['title'] = $title; - return html_print_image ($imagepath, $return, $options); + return html_print_image ($imagepath, $return, $options, false, false, false, true); } /** diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css index ed349a4335..7f8d813826 100755 --- a/pandora_console/mobile/include/style/main.css +++ b/pandora_console/mobile/include/style/main.css @@ -104,7 +104,6 @@ tr.group_view_crit, .group_view_crit { } - .group_view_normal, .group_view_normal *, .group_view_norm, .group_view_norm * { background-color: #FFFFFF; @@ -129,7 +128,6 @@ tr.group_view_crit, .group_view_crit { text-shadow: none; } - .group_view_ok, .group_view_ok * { background-color: #00C000; color: #000000 !important; diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 70c4e12a54..44fadc5ca1 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -69,8 +69,8 @@ $system = System::getInstance(); //~ In this moment doesn't work the version mobile when have metaconsole version. //~ In the future versions of pandora maybe is added a mobile version of PandoraFMS Metaconsole version. -if ($system->getConfig('metaconsole')) - header ("Location: " . $system->getConfig('homeurl') . "enterprise/meta"); +//~ if ($system->getConfig('metaconsole')) + //~ header ("Location: " . $system->getConfig('homeurl') . "enterprise/meta"); require_once($system->getConfig('homedir').'/include/constants.php'); diff --git a/pandora_console/mobile/operation/agent.php b/pandora_console/mobile/operation/agent.php index 1fb7958679..2bb7877278 100644 --- a/pandora_console/mobile/operation/agent.php +++ b/pandora_console/mobile/operation/agent.php @@ -23,9 +23,17 @@ class Agent { $system = System::getInstance(); $this->id = $system->getRequest('id', 0); - $this->agent = agents_get_agents(array( - 'disabled' => 0, - 'id_agente' => $this->id), array('*')); + + if (!$system->getConfig('metaconsole')) { + $this->agent = agents_get_agents(array( + 'disabled' => 0, + 'id_agente' => $this->id), array('*')); + } + else { + $this->agent = agents_get_meta_agents(array( + 'disabled' => 0, + 'id_agente' => $this->id), array('*')); + } if (!empty($this->agent)) { $this->agent = $this->agent[0]; @@ -90,7 +98,7 @@ class Agent { $ui->createPage(); if ($this->id != 0) { - $agent_name = (string) agents_get_name ($this->id); + $agent_name = (string) $this->agent['nombre']; $ui->createDefaultHeader( sprintf('%s', $agent_name), @@ -121,8 +129,17 @@ class Agent { } - $addresses = agents_get_addresses($this->id); - $address = agents_get_address($this->id); + if ($system->getConfig('metaconsole')) { + metaconsole_connect(null, $this->agent['id_tmetaconsole_setup']); + $addresses = agents_get_addresses($this->agent['id_tagente']); + } + else + $addresses = agents_get_addresses($this->id); + + if ($system->getConfig('metaconsole')) + metaconsole_restore_db(); + + $address = $this->agent['direccion']; foreach ($addresses as $k => $add) { if ($add == $address) { unset($addresses[$k]); @@ -154,7 +171,9 @@ class Agent { $html .= $last_contact; $html .= $description; $html .= ''; - + if ($system->getConfig('metaconsole')) { + metaconsole_connect(null, $this->agent['id_tmetaconsole_setup']); + } $ui->contentGridAddCell($html, 'agent_details'); ob_start(); $html = '
'; @@ -170,26 +189,38 @@ class Agent { $html .= '
'; $html .= '
'; $html .= '
'; + $ui->contentGridAddCell($html, 'agent_graphs'); $ui->contentEndGrid(); - + if ($system->getConfig('metaconsole')) + metaconsole_restore_db(); $modules = new Modules(); - $filters = array('id_agent' => $this->id, 'all_modules' => true, 'status' => -1); + if ($system->getConfig('metaconsole')) + $filters = array('id_agent' => $this->agent['id_tagente'], 'all_modules' => true, 'status' => -1); + else + $filters = array('id_agent' => $this->id, 'all_modules' => true, 'status' => -1); $modules->setFilters($filters); $modules->disabledColumns(array('agent')); $ui->contentBeginCollapsible(__('Modules')); $ui->contentCollapsibleAddItem($modules->listModulesHtml(0, true)); $ui->contentEndCollapsible(); + if ($system->getConfig('metaconsole')) { + metaconsole_connect(null, $this->agent['id_tmetaconsole_setup']); + } $alerts = new Alerts(); - $filters = array('id_agent' => $this->id, 'all_alerts' => true); + if ($system->getConfig('metaconsole')) + $filters = array('id_agent' => $this->agent['id_tagente'], 'all_alerts' => true); + else + $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(); - + if ($system->getConfig('metaconsole')) + metaconsole_restore_db(); $events = new Events(); $events->addJavascriptDialog(); diff --git a/pandora_console/mobile/operation/agents.php b/pandora_console/mobile/operation/agents.php index 6dae8ab623..3430d088b9 100644 --- a/pandora_console/mobile/operation/agents.php +++ b/pandora_console/mobile/operation/agents.php @@ -223,40 +223,76 @@ class Agents { OR comentarios LIKE '%" . $this->free_search . "%') "; } - $total = agents_get_agents(array( - 'disabled' => 0, - 'id_grupo' => $this->group, - 'search' => $search_sql, - 'status' => $this->status), - array ('COUNT(*) AS total'), 'AR', false); + if (!$system->getConfig('metaconsole')) { + $total = agents_get_agents(array( + 'disabled' => 0, + 'id_grupo' => $this->group, + 'search' => $search_sql, + 'status' => $this->status), + array ('COUNT(*) AS total'), 'AR', false); + } + else { + $total = agents_get_meta_agents(array( + 'disabled' => 0, + 'id_grupo' => $this->group, + 'search' => $search_sql, + 'status' => $this->status), + array ('COUNT(*) AS total'), 'AR', false); + } $total = isset($total[0]['total']) ? $total[0]['total'] : 0; $order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC'); - $agents_db = agents_get_agents(array( - 'disabled' => 0, - 'id_grupo' => $this->group, - 'search' => $search_sql, - 'status' => $this->status, - 'offset' => (int) $page * $system->getPageSize(), - 'limit' => (int) $system->getPageSize()), - array ('id_agente', - 'id_grupo', - 'id_os', - 'nombre', - 'ultimo_contacto', - 'intervalo', - 'comentarios description', - 'quiet', - 'normal_count', - 'warning_count', - 'critical_count', - 'unknown_count', - 'notinit_count', - 'total_count', - 'fired_count'), - 'AR', $order); - + if (!$system->getConfig('metaconsole')) { + $agents_db = agents_get_agents(array( + 'disabled' => 0, + 'id_grupo' => $this->group, + 'search' => $search_sql, + 'status' => $this->status, + 'offset' => (int) $page * $system->getPageSize(), + 'limit' => (int) $system->getPageSize()), + array ('id_agente', + 'id_grupo', + 'id_os', + 'nombre', + 'ultimo_contacto', + 'intervalo', + 'comentarios description', + 'quiet', + 'normal_count', + 'warning_count', + 'critical_count', + 'unknown_count', + 'notinit_count', + 'total_count', + 'fired_count'), + 'AR', $order); + } + else { + $agents_db = agents_get_meta_agents(array( + 'disabled' => 0, + 'id_grupo' => $this->group, + 'search' => $search_sql, + 'status' => $this->status, + 'offset' => (int) $page * $system->getPageSize(), + 'limit' => (int) $system->getPageSize()), + array ('id_agente', + 'id_grupo', + 'id_os', + 'nombre', + 'ultimo_contacto', + 'intervalo', + 'comentarios description', + 'quiet', + 'normal_count', + 'warning_count', + 'critical_count', + 'unknown_count', + 'notinit_count', + 'total_count', + 'fired_count'), + 'AR', $order); + } if (empty($agents_db)) $agents_db = array(); @@ -340,7 +376,7 @@ class Agents { if ($system->getPageSize() < $listAgents['total']) { $ui->contentAddHtml('
' . - html_print_image('images/spinner.gif', true) . + html_print_image('images/spinner.gif', true, false, false, false, false, true) . ' ' . __('Loading...') . '
'); diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php index 106971661e..18977219e5 100644 --- a/pandora_console/mobile/operation/events.php +++ b/pandora_console/mobile/operation/events.php @@ -80,6 +80,7 @@ class Events { $events = array(); $end = 1; + foreach ($events_db as $event) { $end = 0; @@ -101,7 +102,7 @@ class Events { $img_st = str_replace("white.png", "dark.png", $img_st); } - $status_icon = html_print_image($img_st, true); + $status_icon = html_print_image($img_st, true, false, false, false, false, true); $row = array(); $row[] = '' . __('Event Name') . '
' . io_safe_output($event['evento']) . '
'; @@ -130,13 +131,17 @@ class Events { $id_event = $system->getRequest('id_event', 0); - $event = events_get_event($id_event); + $meta = false; + if ($system->getConfig('metaconsole')) + $meta = true; + + $event = events_get_event($id_event, false, $meta); if ($event) { //Check if it is a event from module. if ($event['id_agentmodule'] > 0) { $event['module_graph_link'] = '' . - html_print_image('images/chart_curve.png', true, array ("style" => 'vertical-align: middle;')) . + html_print_image('images/chart_curve.png', true, array ("style" => 'vertical-align: middle;'), false, false, false, true) . ''; } else { @@ -220,7 +225,7 @@ class Events { array ("class" => "image_status", "width" => 12, "height" => 12, - "title" => $event_criticity)); + "title" => $event_criticity), false, false, false, true); if ($event['estado'] == 1) { $user_ack = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']); @@ -252,7 +257,7 @@ class Events { } $event["status"] = $title_st; $event["status"] .= ' '; - $event["status"] .= html_print_image($img_st,true); + $event["status"] .= html_print_image($img_st,true, false, false, false, false, true); $event["group"] = groups_get_name ($event["id_grupo"], true); $event["group"] .= ui_print_group_icon ($event["id_grupo"], true); @@ -720,7 +725,7 @@ class Events { } $system = System::getInstance(); - $groups = users_get_groups($system->getConfig('id_user'), 'IR'); + $groups = users_get_groups($system->getConfig('id_user'), 'ER'); //Group selection if ($this->group > 0 && in_array ($this->group, array_keys ($groups))) { @@ -758,13 +763,18 @@ class Events { $pagination = $system->getPageSize(); } + $meta = false; + if ($system->getConfig('metaconsole')) + $meta = true; + $events_db = events_get_events_grouped($sql_post, - $offset, $pagination, false, false); + $offset, $pagination, $meta, false); + if (empty($events_db)) { $events_db = array(); } - $total_events = events_get_total_events_grouped($sql_post); + $total_events = events_get_total_events_grouped($sql_post, $meta); return array('events' => $events_db, 'total' => $total_events); } @@ -783,7 +793,7 @@ class Events { $ui->contentAddHtml($table->getHTML()); $ui->contentAddHtml('
' . - html_print_image('images/spinner.gif', true) . + html_print_image('images/spinner.gif', true, false, false, false, false, true) . ' ' . __('Loading...') . '
' . $no_events); diff --git a/pandora_console/mobile/operation/groups.php b/pandora_console/mobile/operation/groups.php index 820751cbe2..38ccdcb465 100644 --- a/pandora_console/mobile/operation/groups.php +++ b/pandora_console/mobile/operation/groups.php @@ -13,9 +13,11 @@ // GNU General Public License for more details. include_once("../include/functions_users.php"); +include_once("../include/functions_groupview.php"); class Groups { private $correct_acl = false; + private $acl = 'AR'; private $groups = array(); private $status = array(); @@ -23,7 +25,7 @@ class Groups { function __construct() { $system = System::getInstance(); - if ($system->checkACL()) { + if ($system->checkACL($this->acl)) { $this->correct_acl = true; $this->groups = $this->getListGroups(); @@ -71,11 +73,41 @@ class Groups { $ui->contentAddHtml('
'); $count = 0; + $url_agent = 'index.php?page=agents&group=%s&status=%s'; + $url_modules = 'index.php?page=modules&group=%s&status=%s'; + foreach ($this->groups as $group) { + // Calculate entire row color + if ($group["_monitors_alerts_fired_"] > 0) { + $color_class = 'group_view_alrm'; + $status_image = ui_print_status_image ('agent_alertsfired_ball.png', "", true); + } + elseif ($group["_monitors_critical_"] > 0) { + $color_class = 'group_view_crit'; + $status_image = ui_print_status_image ('agent_critical_ball.png', "", true); + } + elseif ($group["_monitors_warning_"] > 0) { + $color_class = 'group_view_warn'; + $status_image = ui_print_status_image ('agent_warning_ball.png', "", true); + } + elseif ($group["_monitors_ok_"] > 0) { + + $color_class = 'group_view_ok'; + $status_image = ui_print_status_image ('agent_ok_ball.png', "", true); + } + elseif (($group["_monitors_unknown_"] > 0) || ($group["_agents_unknown_"] > 0)) { + $color_class = 'group_view_unk'; + $status_image = ui_print_status_image ('agent_no_monitors_ball.png', "", true); + } + else { + $color_class = ''; + $status_image = ui_print_status_image ('agent_no_data_ball.png', "", true); + } + $group['icon'] = ($group['icon'] == '') ? 'world' : $group['icon']; $ui->contentAddHtml('