From 6d33b6fe8315041b3d94bd6e5e1a84d8f9fdd901 Mon Sep 17 00:00:00 2001 From: zarzuelo <zarzuelo@gmail.com> Date: Thu, 6 Feb 2014 17:39:39 +0000 Subject: [PATCH] 2014-02-06 Sergio Martin <sergio.martin@artica.es> * mobile/index.php mobile/operation/visualmap.php mobile/operation/visualmaps.php mobile/operation/networkmap.php mobile/operation/home.php mobile/operation/agent.php mobile/include/style/main.css mobile/include/user.class.php: Added visual consoles in mobile console. Improve the apparience with new icons (pandora ones), better layout, etc. * godmode/reporting/map_builder.php: Fix type in gettext function git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9409 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 16 ++ .../godmode/reporting/map_builder.php | 2 +- pandora_console/mobile/include/style/main.css | 189 ++++++++++++++++-- pandora_console/mobile/include/user.class.php | 2 +- pandora_console/mobile/index.php | 14 ++ pandora_console/mobile/operation/agent.php | 6 +- pandora_console/mobile/operation/home.php | 19 +- .../mobile/operation/networkmap.php | 2 +- .../mobile/operation/visualmap.php | 145 ++++++++++++++ .../mobile/operation/visualmaps.php | 162 +++++++++++++++ 10 files changed, 533 insertions(+), 24 deletions(-) create mode 100644 pandora_console/mobile/operation/visualmap.php create mode 100644 pandora_console/mobile/operation/visualmaps.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e63809b118..45a926eaf0 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,19 @@ +2014-02-06 Sergio Martin <sergio.martin@artica.es> + + * mobile/index.php + mobile/operation/visualmap.php + mobile/operation/visualmaps.php + mobile/operation/networkmap.php + mobile/operation/home.php + mobile/operation/agent.php + mobile/include/style/main.css + mobile/include/user.class.php: Added visual + consoles in mobile console. Improve the apparience with + new icons (pandora ones), better layout, etc. + + * godmode/reporting/map_builder.php: Fix type + in gettext function + 2014-02-06 Junichi Satoh <junichi@rworks.jp> * include/languages/ja.po, include/languages/ja.mo: Updated diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 9bc0353e2b..f0675ae5e8 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -166,7 +166,7 @@ else $maps = visual_map_get_user_layouts ($config['id_user'], false, false, false); if (!$maps) { - echo '<div class="nf">'.('No maps defined').'</div>'; + echo '<div class="nf">'.__('No maps defined').'</div>'; } else { foreach ($maps as $map) { diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css index f66fab26ff..642b31d4ad 100644 --- a/pandora_console/mobile/include/style/main.css +++ b/pandora_console/mobile/include/style/main.css @@ -474,23 +474,23 @@ table.event_details td.cell_event_name { /*INIT-----------Agents styles----------------------------------------*/ .red, .redb, .redi, .error { - background: #CC0000 !important; + background: #FF4040 !important; } .green { - background: #5A8629 !important; + background: #6EB432 !important; } .orange { - background: #ffa300 !important; + background: #FF8800 !important; } .yellow { - background: #F3C500 !important; + background: #F2D400 !important; } .grey { - background: #808080 !important; + background: #AAAAAA !important; font-weight: bold; } @@ -506,7 +506,11 @@ table.event_details td.cell_event_name { } .agent_details { - line-height: 25px; + line-height: 35px; +} + +.agent_details img { + float: left; } .agent_name { @@ -516,10 +520,12 @@ table.event_details td.cell_event_name { #list_agents .cell_0 img { float: left; + margin-right: 3px; } #list_agents td:hover, #list_networkmaps td:hover, -#list_events td:hover, #list_Modules td:hover { +#list_events td:hover, #list_Modules td:hover, +#list_visualmaps td:hover { cursor: pointer; } @@ -528,6 +534,12 @@ table.event_details td.cell_event_name { padding-top: 20px; } +.agents_tiny_stats_tactical { + display: block; + text-align: center; + width: 100%; +} + @media screen and (max-width: 25em) { #list_agents .cell_2 .ui-table-cell-label, #list_agents .cell_3 .ui-table-cell-label, @@ -618,16 +630,86 @@ table.event_details td.cell_event_name { /*END-----------Alerts styles---------------------------------------*/ -/*INIT-----------Alerts styles---------------------------------------*/ +/*INIT-----------Network maps styles---------------------------------------*/ #list_networkmaps td { height: 35px; padding-top: 20px; } -/*END-----------Alerts styles---------------------------------------*/ +/*END-----------Network maps styles---------------------------------------*/ +/*INIT-----------Visual maps styles---------------------------------------*/ +#list_visualmaps td { + height: 35px; + padding-top: 20px; +} + +#rendered_visual_map div { + color: #003a3a; + text-shadow: none !important; +} + +#rendered_visual_map { + text-align: center; +} + +/* For mobiles */ +@media screen and (max-width: 750px) +{ + #rendered_visual_map div { + font-size: 6pt !important; + } +} +/* For tablets */ +@media screen and (min-width: 750px) +{ + #rendered_visual_map div { + font-size: 8pt !important; + } +} + +/* For mobiles */ +@media screen and (max-width: 750px) +{ + .resize_visual_font_size_8pt * { + font-size: 4pt !important; + } + .resize_visual_font_size_14pt * { + font-size: 6pt !important; + } + .resize_visual_font_size_24pt * { + font-size: 10pt !important; + } + .resize_visual_font_size_36pt * { + font-size: 14pt !important; + } + .resize_visual_font_size_72pt * { + font-size: 27pt !important; + } +} +/* For tablets */ +@media screen and (min-width: 750px) +{ + .resize_visual_font_size_8pt * { + font-size: 4pt !important; + } + .resize_visual_font_size_14pt * { + font-size: 7pt !important; + } + .resize_visual_font_size_24pt * { + font-size: 12pt !important; + } + .resize_visual_font_size_36pt * { + font-size: 18pt !important; + } + .resize_visual_font_size_72pt * { + font-size: 36pt !important; + } +} + +/*END-----------Visual maps styles---------------------------------------*/ /*INIT-----------Modules styles---------------------------------------*/ @media screen and (max-width: 25em) { @@ -1019,9 +1101,92 @@ table.tactical_bars { font-weight: bold; } -.ui-icon-eye { - background-image: url(../../images/eye.png) !important; +/*INIT-----------Icons styles---------------------------------------*/ + +.ui-icon-tactical_view { + background-image: url(../../../images/op_monitoring.png) !important; +} + +.ui-icon-events { + background-image: url(../../../images/op_events.png) !important; +} + +.ui-icon-groups { + background-image: url(../../../images/group.png) !important; +} + +.ui-icon-alerts { + background-image: url(../../../images/op_alerts.png) !important; +} + +.ui-icon-agents { + background-image: url(../../../images/agent_mc.png) !important; +} + +.ui-icon-modules { + background-image: url(../../../images/brick.png) !important; +} + +.ui-icon-network_maps { + background-image: url(../../../images/op_network.png) !important; +} + +.ui-icon-visual_console { + background-image: url(../../../images/visual_console.png) !important; +} + +.ui-icon-tactical_view, .ui-icon-events, +.ui-icon-groups, .ui-icon-alerts, +.ui-icon-agents, .ui-icon-modules, +.ui-icon-network_maps, .ui-icon-visual_console { + background-color: #333 !important; background-position: center; + border-radius: 15px !important; + -webkit-border-radius: 15px !important; +} + +#login_btn-container .ui-icon { + background-color: #333 !important; + border-radius: 15px !important; + -webkit-border-radius: 15px !important; +} + +/* For mobiles */ +@media screen and (max-width: 750px) +{ + .ui-icon-tactical_view, .ui-icon-events, + .ui-icon-groups, .ui-icon-alerts, + .ui-icon-agents, .ui-icon-modules, + .ui-icon-network_maps, .ui-icon-visual_console { + width: 22px !important; + height: 22px !important; + margin-top: -13px !important; + background-size: 16px 16px; + } +} +/* For tablets */ +@media screen and (min-width: 750px) +{ + .ui-icon-tactical_view, .ui-icon-events, + .ui-icon-groups, .ui-icon-alerts, + .ui-icon-agents, .ui-icon-modules, + .ui-icon-network_maps, .ui-icon-visual_console { + width: 32px !important; + height: 32px !important; + margin-top: -17px !important; + } +} + +/*END-----------Network maps styles---------------------------------------*/ + +#logout_dialog-button_close { + display: block; + margin: 0 auto; + margin-top: 20px; +} + +.ui-btn-active { + background: #6db431 !important; } span.nobold * { @@ -1043,7 +1208,7 @@ span.nobold * { display: block !important; } -#list_Modules *, #list_agents *, #list_alerts *, #list_networkmaps * { +#list_Modules *, #list_agents *, #list_alerts *, #list_networkmaps *, #list_visualmaps * { color: #222; } diff --git a/pandora_console/mobile/include/user.class.php b/pandora_console/mobile/include/user.class.php index b3caa0754d..e725b25b05 100644 --- a/pandora_console/mobile/include/user.class.php +++ b/pandora_console/mobile/include/user.class.php @@ -178,7 +178,7 @@ class User { $ui->formAddInputPassword($options); $options = array( 'value' => __('Login'), - 'icon' => 'star', + 'icon' => 'arrow-r', 'icon_pos' => 'right', 'name' => 'login_btn' ); diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 1747297d33..339ac37a6f 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -36,6 +36,8 @@ require_once('operation/module_graph.php'); require_once('operation/agent.php'); require_once('operation/networkmaps.php'); require_once('operation/networkmap.php'); +require_once('operation/visualmaps.php'); +require_once('operation/visualmap.php'); $enterpriseHook = enterprise_include('mobile/include/enterprise.class.php'); $system = System::getInstance(); @@ -78,6 +80,10 @@ switch ($action) { $module_graph = new ModuleGraph(); $module_graph->ajax($parameter2); break; + case 'visualmap': + $visualmap = new Visualmap(); + $visualmap->ajax($parameter2); + break; } return; break; @@ -152,6 +158,14 @@ switch ($action) { $networkmap = new Networkmap(); $networkmap->show(); break; + case 'visualmaps': + $visualmaps = new Visualmaps(); + $visualmaps->show(); + break; + case 'visualmap': + $visualmap = new Visualmap(); + $visualmap->show(); + break; } break; } diff --git a/pandora_console/mobile/operation/agent.php b/pandora_console/mobile/operation/agent.php index cdb2d9b6ae..c3df1c9e49 100644 --- a/pandora_console/mobile/operation/agent.php +++ b/pandora_console/mobile/operation/agent.php @@ -120,7 +120,7 @@ class Agent { $html = '<div class="agent_details">'; - $html .= ui_print_group_icon ($this->agent["id_grupo"], true) . ' '; + $html .= ui_print_group_icon ($this->agent["id_grupo"], true, "groups_small", "", false) . ' '; $html .= '<span class="agent_name">' . $agent_name . '</span><br />'; $html .= $ip; $html .= $last_contact; @@ -132,10 +132,12 @@ class Agent { $html = graph_agent_status ($this->id, 160, 160, true); $graph_js = ob_get_clean(); $html = $graph_js . $html; + unset($this->agent['fired_count']); + $html .= '<span class="agents_tiny_stats agents_tiny_stats_tactical">' . reporting_tiny_stats($this->agent, true) . ' </span><br>'; $html .= "<b>" . __('Events (24h)') . "</b><br />"; $html .= graph_graphic_agentevents( $this->id, 250, 15, 86400, ui_get_full_url(false), true); - $html .= '<br><br>'; + $html .= '<br>'; $ui->contentGridAddCell($html); $ui->contentEndGrid(); diff --git a/pandora_console/mobile/operation/home.php b/pandora_console/mobile/operation/home.php index 383bae2a34..351dcd43c3 100644 --- a/pandora_console/mobile/operation/home.php +++ b/pandora_console/mobile/operation/home.php @@ -50,41 +50,46 @@ class Home { $ui->endForm(); //List of buttons - $options = array('icon' => 'gear', + $options = array('icon' => 'tactical_view', 'pos' => 'right', 'text' => __('Tactical view'), 'href' => 'index.php?page=tactical'); $ui->contentAddHtml($ui->createButton($options)); - $options = array('icon' => 'info', + $options = array('icon' => 'events', 'pos' => 'right', 'text' => __('Events'), 'href' => 'index.php?page=events'); $ui->contentAddHtml($ui->createButton($options)); - $options = array('icon' => 'arrow-u', + $options = array('icon' => 'groups', 'pos' => 'right', 'text' => __('Groups'), 'href' => 'index.php?page=groups'); $ui->contentAddHtml($ui->createButton($options)); - $options = array('icon' => 'alert', + $options = array('icon' => 'alerts', 'pos' => 'right', 'text' => __('Alerts'), 'href' => 'index.php?page=alerts'); $ui->contentAddHtml($ui->createButton($options)); - $options = array('icon' => 'grid', + $options = array('icon' => 'agents', 'pos' => 'right', 'text' => __('Agents'), 'href' => 'index.php?page=agents'); $ui->contentAddHtml($ui->createButton($options)); - $options = array('icon' => 'check', + $options = array('icon' => 'modules', 'pos' => 'right', 'text' => __('Modules'), 'href' => 'index.php?page=modules'); $ui->contentAddHtml($ui->createButton($options)); - $options = array('icon' => 'star', + $options = array('icon' => 'network_maps', 'pos' => 'right', 'text' => __('Networkmaps'), 'href' => 'index.php?page=networkmaps'); $ui->contentAddHtml($ui->createButton($options)); + $options = array('icon' => 'visual_console', + 'pos' => 'right', + 'text' => __('Visual consoles'), + 'href' => 'index.php?page=visualmaps'); + $ui->contentAddHtml($ui->createButton($options)); $ui->endContent(); $ui->showPage(); return; diff --git a/pandora_console/mobile/operation/networkmap.php b/pandora_console/mobile/operation/networkmap.php index e40951ac77..0832b017bc 100755 --- a/pandora_console/mobile/operation/networkmap.php +++ b/pandora_console/mobile/operation/networkmap.php @@ -82,7 +82,7 @@ class Networkmap { $ui->createPage(); $ui->createDefaultHeader( sprintf("%s", - $this->network_map['name']), + $this->networkmap['name']), $ui->createHeaderButton( array('icon' => 'back', 'pos' => 'left', diff --git a/pandora_console/mobile/operation/visualmap.php b/pandora_console/mobile/operation/visualmap.php new file mode 100644 index 0000000000..7239f8ec5a --- /dev/null +++ b/pandora_console/mobile/operation/visualmap.php @@ -0,0 +1,145 @@ +<?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. + +require_once ('../include/functions_visual_map.php'); + +class Visualmap { + private $correct_acl = false; + private $acl = "RR"; + + private $id = 0; + private $visual_map = null; + + function __construct() { + $system = System::getInstance(); + + if ($system->checkACL($this->acl)) { + $this->correct_acl = true; + } + else { + $this->correct_acl = false; + } + } + + private function getFilters() { + $system = System::getInstance(); + + $this->id = (int)$system->getRequest('id', 0); + } + + public function show() { + if (!$this->correct_acl) { + $this->show_fail_acl(); + } + else { + $this->getFilters(); + + $this->visualmap = db_get_row('tlayout', + 'id', $this->id); + + $this->show_visualmap(); + } + } + + private function show_fail_acl() { + $error['title_text'] = __('You don\'t have access to this page'); + $error['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'); + $home = new Home(); + $home->show($error); + } + + public function ajax($parameter2 = false) { + $system = System::getInstance(); + + if (!$this->correct_acl) { + return; + } + else { + switch ($parameter2) { + case 'render_map': + $map_id = $system->getRequest('map_id', '0'); + $width = $system->getRequest('width', '400'); + visual_map_print_visual_map($map_id, false, true, $width); + exit; + } + } + } + + private function show_visualmap() { + $ui = Ui::getInstance(); + $system = System::getInstance(); + + $ui->createPage(); + $ui->createDefaultHeader( + sprintf("%s", + $this->visualmap['name']), + $ui->createHeaderButton( + array('icon' => 'back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=visualmaps'))); + $ui->showFooter(false); + $ui->beginContent(); + + ob_start(); + $rendered_map = '<div id="rendered_visual_map">'; + $rendered_map .= html_print_image('images/spinner.gif', true); + $rendered_map .= '</div>'; + ob_clean(); + + $ui->contentAddHtml($rendered_map); + $ui->contentAddHtml("<script type=\"text/javascript\"> + function ajax_load_map() { + //$('#rendered_visual_map').html('<img src=\"images/spinner.gif\">); + + var map_max_width = window.innerWidth * 0.90; + var map_max_height = (window.innerHeight - 47) * 0.90; + + var original_width = " . $this->visualmap['width'] . "; + var original_height = " . $this->visualmap['height'] . "; + + var map_width = map_max_width; + var map_height = original_height / (original_width / map_width); + + if(map_height > map_max_height) { + map_height = map_max_height; + map_width = original_width / (original_height / map_height); + } + + postvars = {}; + postvars[\"action\"] = \"ajax\"; + postvars[\"parameter1\"] = \"visualmap\"; + postvars[\"parameter2\"] = \"render_map\"; + postvars[\"map_id\"] = \"" . $this->id . "\"; + postvars[\"width\"] = map_width; + + $.post(\"index.php\", + postvars, + function (data) { + $('#rendered_visual_map').html(data); + }, + \"html\"); + } + + ajax_load_map(); + + $( window ).resize(function() { + ajax_load_map(); + }); + </script>"); + $ui->endContent(); + $ui->showPage(); + } +} +?> diff --git a/pandora_console/mobile/operation/visualmaps.php b/pandora_console/mobile/operation/visualmaps.php new file mode 100644 index 0000000000..e18cd1c115 --- /dev/null +++ b/pandora_console/mobile/operation/visualmaps.php @@ -0,0 +1,162 @@ +<?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. + +ob_start(); +require_once ('../include/functions_visual_map.php'); +ob_get_clean(); //Fixed unused javascript code. + +class Visualmaps { + private $correct_acl = false; + private $acl = "RR"; + + private $default = true; + private $default_filters = array(); + + private $group = 0; + private $type = 0; + + private $list_types = null; + + function __construct() { + $system = System::getInstance(); + + if ($system->checkACL($this->acl)) { + $this->correct_acl = true; + } + else { + $this->correct_acl = false; + } + } + + private function getFilters() { + $system = System::getInstance(); + $user = User::getInstance(); + + $this->default_filters['group'] = true; + $this->default_filters['type'] = true; + + $this->group = (int)$system->getRequest('group', __("Group")); + if (!$user->isInGroup($this->acl, $this->group)) { + $this->group = 0; + } + if (($this->group === __("Group")) || ($this->group == 0)) { + $this->group = 0; + } + else { + $this->default = false; + $this->default_filters['group'] = false; + } + + $this->type = $system->getRequest('type', __("Type")); + if (($this->type === __("Type")) || ($this->type === '0')) { + $this->type = '0'; + } + else { + $this->default = false; + $this->default_filters['type'] = false; + } + } + + public function show() { + if (!$this->correct_acl) { + $this->show_fail_acl(); + } + else { + $this->getFilters(); + $this->show_visualmaps(); + } + } + + private function show_fail_acl() { + $error['title_text'] = __('You don\'t have access to this page'); + $error['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'); + $home = new Home(); + $home->show($error); + } + + private function show_visualmaps() { + $ui = Ui::getInstance(); + + $ui->createPage(); + $ui->createDefaultHeader(__("Visual consoles"), + $ui->createHeaderButton( + array('icon' => 'back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=home'))); + $ui->showFooter(false); + $ui->beginContent(); + $this->listVisualmapsHtml(); + $ui->endContent(); + $ui->showPage(); + } + + private function listVisualmapsHtml() { + $system = System::getInstance(); + $ui = Ui::getInstance(); + + // Create filter + $where = array(); + // Order by type field + $where['order'] = 'type'; + + if ($this->group != '0') + $where['id_group'] = $this->group; + + if ($this->type != '0') + $where['type'] = $this->type; + + // Only display maps of "All" group if user is administrator + // or has "RR" privileges, otherwise show only maps of user group + $id_user = $system->getConfig('id_user'); + $own_info = get_user_info ($id_user); + if ($own_info['is_admin'] || $system->checkACL($this->acl)) + $maps = visual_map_get_user_layouts (); + else + $maps = visual_map_get_user_layouts ($id_user, false, false, false); + + if (empty($maps)) { + $maps = array(); + } + $list = array(); + foreach ($maps as $map) { + $row = array(); + $row[__('Name')] = '<a class="ui-link" data-ajax="false" href="index.php?page=visualmap&id=' . $map['id'] . '">' . io_safe_output($map['name']) . '</a>'; + //$row[__('Type')] = $map['type']; + $row[__('Group')] = ui_print_group_icon($map["id_group"], true, "groups_small", "" , false); + $list[] = $row; + } + + if (count($maps) == 0) { + $ui->contentAddHtml('<p style="color: #ff0000;">' . __('No maps defined') . '</p>'); + } + else { + $table = new Table(); + $table->id = 'list_visualmaps'; + $table->importFromHash($list); + $ui->contentAddHtml($table->getHTML()); + } + + $ui->contentAddHtml("<script type=\"text/javascript\"> + //Set link on entire row + $('#list_visualmaps tr').click( function() { + var link = $(this).find('a').attr('href'); + if (link != undefined) { + window.location = $(this).find('a').attr('href'); + } + }); + </script>"); + } +} +?>