2014-05-09 Alejandro Gallardo <alejandro.gallardo@artica.es>

* general/shortcut_bar.php: Updated the shortcut bar.

	* include/styles/pandora.css: Added new styles for the
	shortcut bar elements.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9900 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
alexhigh 2014-05-09 14:57:40 +00:00
parent 6abe1e3736
commit 6003af8fd8
3 changed files with 280 additions and 231 deletions

View File

@ -1,7 +1,14 @@
2014-05-09 Alejandro Gallardo <alejandro.gallardo@artica.es>
* general/shortcut_bar.php: Updated the shortcut bar.
* include/styles/pandora.css: Added new styles for the
shortcut bar elements.
2014-05-08 Alejandro Gallardo <alejandro.gallardo@artica.es>
* pandora_console/extensions/matrix_events/ajax.php,
pandora_console/extensions/matrix_events.php: Added
* extensions/matrix_events/ajax.php,
extensions/matrix_events.php: Added
files. New extension to see the latest events like if
you were the operator of the Nebuchadnezzar.

View File

@ -20,12 +20,18 @@ global $config;
check_login ();
require_once("include/functions_reporting.php");
require_once("include/functions_events.php");
if (is_ajax()) {
$save_item_shorcut = get_parameter("save_item_shorcut", 0);
$save_item_shorcut = (bool) get_parameter("save_item_shorcut");
$update_shortcut_state = (bool) get_parameter('update_shortcut_state');
$get_alerts_fired = (bool) get_parameter('get_alerts_fired');
$get_critical_events = (bool) get_parameter('get_critical_events');
$get_opened_incidents = (bool) get_parameter('get_opened_incidents');
if ($save_item_shorcut) {
$result = false;
$data = get_parameter("data", '');
$id_user = get_parameter('id_user', 0);
@ -42,76 +48,107 @@ if (is_ajax()) {
db_process_sql_update('tusuario', $shortcut_data, array('id_user' => $id_user));
}
echo json_encode($result);
return;
}
require_once("include/functions_events.php");
$update_shortcut_state = get_parameter('update_shortcut_state', 0);
$get_critical_events = get_parameter('get_critical_events', 0);
$get_opened_incidents = get_parameter('get_opened_incidents', 0);
// Update if shortcut is visible or hidden
if ($update_shortcut_state) {
$value = get_parameter('value', 0);
db_process_sql_update('tusuario', array('shortcut' => $value), array('id_user' => $config['id_user']));
$value = (int) get_parameter('value');
$result = db_process_sql_update('tusuario', array('shortcut' => $value), array('id_user' => $config['id_user']));
echo json_encode($result);
return;
}
// Get critical events (realtime update)
if ($get_alerts_fired){
echo sc_get_alerts_fired();
return;
}
// Get critical events (realtime update)
if ($get_critical_events){
$own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
$own_groups = array_keys(users_get_groups($config['id_user'], "IR"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
// Get events in the last 8 hours
$shortcut_events_update = events_get_group_events($own_groups, 28800, time());
if ($shortcut_events_update == false)
$shortcut_events_update = array();
$critical_events_update = 0;
foreach($shortcut_events_update as $event_update){
if ($event_update['criticity'] == 4 and $event_update['estado'] == 0) {
$critical_events_update++;
}
}
echo $critical_events_update;
echo sc_get_critical_events();
return;
}
// Select only opened incidents
if ($get_opened_incidents) {
$own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
$own_groups = array_keys(users_get_groups($config['id_user'], "IR"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
$sql = "SELECT count(*) total_incidents FROM tincidencia WHERE
id_grupo IN (".implode (",",array_keys ($own_groups)).") AND estado IN (0)
ORDER BY actualizacion";
echo sc_get_opened_incidents();
return;
}
return;
}
function sc_get_alerts_fired () {
global $config;
$data_reporting = reporting_get_group_stats();
return $data_reporting['monitor_alerts_fired'];
}
function sc_get_critical_events () {
global $config;
$own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
$own_groups = array_keys(users_get_groups($config['id_user'], "IR"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
// Get events in the last 8 hours
$shortcut_events_update = events_get_group_events($own_groups, 28800, time());
if ($shortcut_events_update == false)
$shortcut_events_update = array();
$critical_events_update = 0;
foreach($shortcut_events_update as $event_update){
if ($event_update['criticity'] == 4 and $event_update['estado'] == 0) {
$critical_events_update++;
}
}
return $critical_events_update;
}
function sc_get_opened_incidents () {
global $config;
$own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) {
$sql = "SELECT count(*) total_incidents
FROM tincidencia
WHERE estado = 0
ORDER BY actualizacion";
$result_incidents_update = db_get_all_rows_sql ($sql);
}
else {
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
$sql = "SELECT count(*) total_incidents
FROM tincidencia
WHERE id_grupo IN (".implode (",",array_keys ($own_groups)).")
AND estado = 0
ORDER BY actualizacion";
if (!empty($own_groups)) {
$result_incidents_update = db_get_all_rows_sql ($sql);
$result_incidents_update = db_get_all_rows_sql($sql);
}
else {
$result_incidents_update = false;
}
if ($result_incidents_update === false)
$shortcut_incidents = 0;
else
$shortcut_incidents = $result_incidents_update[0]['total_incidents'];
echo $shortcut_incidents;
}
return;
if ($result_incidents_update === false)
$shortcut_incidents = 0;
else
$shortcut_incidents = $result_incidents_update[0]['total_incidents'];
return $shortcut_incidents;
}
@ -121,127 +158,94 @@ $shortcut_state = db_get_value_filter('shortcut', 'tusuario', array('id_user' =>
if ($shortcut_state == 0)
return;
if ($shortcut_state == 2) {
echo "<div id='shortcut_button' style='position: fixed; overflow: hidden; bottom: 0px; left: 0px; width: 185px; height: 40px; background-color: #FFFFFF; border: 1px solid #808080; border-top-left-radius: 10px; border-top-right-radius: 10px;'>";
}
else {
echo "<div id='shortcut_button' style='position: fixed; overflow: hidden; bottom: 0px; left: 0px; width: 185px; height: 0px; background-color: #FFFFFF; border: 1px solid #808080; border-top-left-radius: 10px; border-top-right-radius: 10px;'>";
}
html_print_image("images/pandora_textlogo.png", false, array("title" => __("Press here to activate shortcut bar")));
echo "</div>";
if ($shortcut_state == 2) {
echo "<div id='shotcut_bar' style='position: fixed; overflow:hidden; bottom: 0px; left: 0px; width:100%; height: 20px; background-color:#DCDCDC; border: 1px solid #808080;'>";
}
else {
echo "<div id='shotcut_bar' style='position: fixed; overflow:hidden; bottom: 0px; left: 0px; width:100%; height: 0px; background-color:#DCDCDC; border: 1px solid #808080;'>";
}
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$own_info = get_user_info ($config['id_user']);
// If user is admin can see all groups
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) {
echo "<a href='index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=120&filter=fired&free_search=&filter_button=Filter'>";
}
else {
$own_groups = array_keys(users_get_groups($config['id_user'], "AR", false));
if (!empty($own_groups)) {
$alerts_group = array_shift($own_groups);
echo "<a href='index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=120&filter=fired&free_search=&ag_group=$alerts_group&filter_button=Filter'>";
}
}
html_print_image("images/bell.png", false, array("title" => __("Alerts fired"), "style" => "margin-bottom: -5px;"));
echo "&nbsp;";
$shortcut_html = "<div id='shortcut_container'>";
$shortcut_html .= "<div id='shortcut_button'>";
$shortcut_html .= html_print_image("images/control_play.png", true, array("title" => __("Press here to activate shortcut bar")));
$shortcut_html .= "</div>";
$shortcut_html .= "<div id='shortcut_bar'>";
// Calculate alerts fired
$data_reporting = reporting_get_group_stats();
$num_shortcut_items = 0;
echo "<span id='shortcut_alerts_fired' style='font-size: 9pt; color:#696969; font-weight: bold;' title='" . __('Alerts fired') . "'>" . $data_reporting['monitor_alerts_fired'] . "</span>";
if (!empty($own_groups)) {
echo "</a>";
}
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
// Alerts item
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM") || check_acl ($config['id_user'], 0, "AR")) {
$alerts_fired = sc_get_alerts_fired();
$own_info = get_user_info ($config['id_user']);
$shortcut_html .= "<a class='shortcut_item' href='index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=120&filter=fired&filter_button=Filter'>";
$shortcut_html .= html_print_image("images/op_alerts.png", true, array("title" => __("Alerts fired"), "style" => "margin-bottom: 0px;"));
$shortcut_html .= "&nbsp;";
$shortcut_html .= "<span id='shortcut_alerts_fired' title='" . __('Alerts fired') . "'>" . $alerts_fired . "</span>";
$shortcut_html .= "</a>";
// If user is admin can see all groups
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) {
echo "<a href='index.php?sec=eventos&sec2=operation/events/events&status=3&severity=4&event_view_hr=8&id_group=0&group_rep=1&filter_only_alert=-1'>";
}
else {
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
if (!empty($own_groups)){
$events_group = array_shift($own_groups);
echo "<a href='index.php?sec=eventos&sec2=operation/events/events&status=3&severity=4&event_view_hr=8&group_rep=1&id_group=$events_group&filter_only_alert=-1'>";
}
}
html_print_image("images/lightning_go.png", false, array("title" => __("Critical events"), "style" => "margin-bottom: -5px;"));
echo "&nbsp;";
// Calculate critical events (not validated)
$own_info = get_user_info ($config['id_user']);
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
$own_groups = array_keys(users_get_groups($config['id_user'], "IR"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "IR", false));
// Get events in the last 8 hours
$shortcut_events = events_get_group_events($own_groups, 28800, time());
if ($shortcut_events == false)
$shortcut_events = array();
$critical_events = 0;
foreach ($shortcut_events as $event) {
if ($event['criticity'] == 4 and $event['estado'] == 0) {
$critical_events++;
}
$num_shortcut_items++;
}
// Events item
if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM") || check_acl ($config['id_user'], 0, "IR")) {
$critical_events = sc_get_critical_events();
$shortcut_html .= "<a class='shortcut_item' href='index.php?sec=eventos&sec2=operation/events/events&status=3&severity=4&event_view_hr=8&id_group=0&group_rep=1&filter_only_alert=-1'>";
$shortcut_html .= html_print_image("images/op_events.png", true, array("title" => __("Critical events"), "style" => "margin-bottom: 0px;"));
$shortcut_html .= "&nbsp;";
$shortcut_html .= "<span id='shortcut_critical_events' title='" . __('Critical events') . "'>" . $critical_events . "</span>";
$shortcut_html .= "</a>";
$num_shortcut_items++;
}
echo "<span id='shortcut_critical_events' style='font-size: 9pt; color:#696969; font-weight: bold;' title='" . __('Critical events') . "'>" . $critical_events . "</span>";
echo "</a>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
// Calculate opened incidents (id integria incidents are not enabled)
if ($config['integria_enabled'] == 0) {
echo "<a href='index.php?sec=incidencias&sec2=operation/incidents/incident&estado=0'>";
html_print_image("images/book_edit.png", false, array("title" => __("Incidents opened"), "style" => "margin-bottom: -5px;"));
echo "&nbsp;";
// Select only opened incidents
$sql = "SELECT count(*) total_incidents FROM tincidencia WHERE
id_grupo IN (".implode (",",array_keys ($own_groups)).") AND estado IN (0)
ORDER BY actualizacion";
$shortcut_incidents = sc_get_opened_incidents();
if (!empty($own_groups)) {
$result_incidents = db_get_all_rows_sql ($sql);
}
else {
$result_incidents = false;
}
if ($result_incidents === false)
$shortcut_incidents = 0;
else
$shortcut_incidents = $result_incidents[0]['total_incidents'];
echo "<span id='shortcut_incidents_opened' style='font-size: 9pt; color:#696969; font-weight: bold;' title='" . __('Incidents opened') . "'>" . $shortcut_incidents . "</span>";
echo "</a>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$shortcut_html .= "<a class='shortcut_item' href='index.php?sec=incidencias&sec2=operation/incidents/incident&estado=0'>";
$shortcut_html .= html_print_image("images/book_edit.png", true, array("title" => __("Incidents opened"), "style" => "margin-bottom: 0px;"));
$shortcut_html .= "&nbsp;";
$shortcut_html .= "<span id='shortcut_incidents_opened' title='" . __('Incidents opened') . "'>" . $shortcut_incidents . "</span>";
$shortcut_html .= "</a>";
$num_shortcut_items++;
}
echo "&nbsp;&nbsp;&nbsp;";
echo "<span style='font-size: 9pt; color:#696969; font-weight: bold;'>|</span>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href='index.php?sec=reporting&sec2=operation/reporting/custom_reporting'>";
html_print_image("images/reporting.png", false, array("title" => __("View reports"), "style" => "margin-bottom: -5px;"));
echo "</a>";
if ($num_shortcut_items > 0) {
$shortcut_html .= "<span class='shortcut_item' href='javascript:;'>";
$shortcut_html .= "<span>|</span>";
$shortcut_html .= "</span>";
}
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$shortcut_html .= "<a class='shortcut_item' href='index.php?sec=reporting&sec2=operation/reporting/custom_reporting'>";
$shortcut_html .= html_print_image("images/op_reporting.png", true, array("title" => __("View reports"), "style" => "margin-bottom: 0px;"));
$shortcut_html .= "</a>";
$num_shortcut_items++;
echo "<a href='index.php?sec=messages&sec2=operation/messages/message'>";
html_print_image("images/email.png", false, array("title" => __("Create new message"), "style" => "margin-bottom: -5px;"));
echo "</a>";
$shortcut_html .= "<a class='shortcut_item' href='index.php?sec=workspace&sec2=operation/messages/message_list'>";
$shortcut_html .= html_print_image("images/email_mc.png", true, array("title" => __("Create new message"), "style" => "margin-bottom: 0px;"));
$shortcut_html .= "</a>";
$num_shortcut_items++;
//Quick access
// $shortcut_data = db_get_value('shortcut_data', 'tusuario', 'id_user', $config['id_user']);
// if (!empty($shortcut_data)) {
// $serialize = $shortcut_data;
// $unserialize = json_decode($serialize, true);
// $items = $unserialize['item_shorcut'];
// }
// else {
// $items = array();
// }
// $shortcut_html .= "<div id='shortcut_icons_box' style='font-size: 9pt; color:#696969; font-weight: bold; display: inline; float: right; padding-right: 20px;'>" .
// __("Shortcut: ");
// $shortcut_html .= "<ul style='display: inline; font-size: 9pt; color:#000;'>";
// foreach ($items as $item) {
// $shortcut_html .= "<li style='display: inline; padding-right: 10px;'>" . io_safe_output($item) . "</li>";
// }
// $shortcut_html .= "</ul>";
$shortcut_html .= "</div>";
$shortcut_html .= "</div>";
echo $shortcut_html;
// Login in Console and shortcut bar is disabled
// This will show and hide the shortcut value in Javascript code
@ -254,120 +258,121 @@ else {
html_print_input_hidden("shortcut_id_user", $config['id_user']);
//Quick access
$shortcut_data = db_get_value('shortcut_data', 'tusuario', 'id_user', $config['id_user']);
if (!empty($shortcut_data)) {
$serialize = $shortcut_data;
$unserialize = json_decode($serialize, true);
$items = $unserialize['item_shorcut'];
}
else {
$items = array();
}
echo "<div id='shortcut_icons_box' style='font-size: 9pt; color:#696969; font-weight: bold; display: inline; float: right; padding-right: 20px;'>" .
__("Shortcut: ");
echo "<ul style='display: inline; font-size: 9pt; color:#000;'>";
foreach ($items as $item) {
echo "<li style='display: inline; padding-right: 10px;'>" . io_safe_output($item) . "</li>";
}
echo "</ul>";
echo "</div>";
echo "</div>";
?>
<script type='text/javascript'>
$(function() {
if ($('#hidden-login_console').val() == 1){
$('#shotcut_bar').css({height: 0}).animate({ height: '20' }, 900);
$('#shortcut_button').css({height: 22}).animate({ height: '40' }, 900);
$('#shotcut_bar').css({height: 20}).animate({ height: '0' }, 900);
$('#shortcut_button').css({height:40}).animate({ height: '22' }, 900);
if (<?php echo json_encode((int) $shortcut_state); ?> < 2) {
$('#shortcut_bar').hide();
$('#shortcut_button>img')
.css('transform', 'rotate(-90deg)')
.css('-o-transform', 'rotate(-90deg)')
.css('-ms-transform', 'rotate(-90deg)')
.css('-moz-transform', 'rotate(-90deg)')
.css('-webkit-transform', 'rotate(-90deg)');
} else {
$('#shortcut_button>img')
.css('transform', 'rotate(90deg)')
.css('-o-transform', 'rotate(90deg)')
.css('-ms-transform', 'rotate(90deg)')
.css('-moz-transform', 'rotate(90deg)')
.css('-webkit-transform', 'rotate(90deg)');
}
else {
if ($('#shotcut_bar').css('height') == '0px'){
$('#shotcut_bar').css('height', '0px');
$('#shortcut_button').css('height', '22px');
}
else{
$('#shotcut_bar').css('height', '20px');
$('#shortcut_button').css('height', '40px');
}
}
$('#shortcut_button').click (function () {
if ($('#shotcut_bar').css('height') == '0px') {
$('#shotcut_bar').css({height: 0}).animate({ height: '20' }, 900);
$('#shortcut_button').css({height: 22}).animate({ height: '40' }, 900);
jQuery.post ("ajax.php",
{"page" : "general/shortcut_bar",
"update_shortcut_state": 1,
"value": 2
if ($('#shortcut_bar').is(":visible")) {
$('#shortcut_bar').slideUp();
$('#shortcut_button>img')
.css('transform', 'rotate(-90deg)')
.css('-o-transform', 'rotate(-90deg)')
.css('-ms-transform', 'rotate(-90deg)')
.css('-moz-transform', 'rotate(-90deg)')
.css('-webkit-transform', 'rotate(-90deg)');
jQuery.post (
"ajax.php",
{
"page" : "general/shortcut_bar",
"update_shortcut_state" : 1,
"value" : 1
},
function (data) {
}
function (data) {}
);
}
else {
$('#shotcut_bar').css({height: 28}).animate({ height: '0' }, 900);
$('#shortcut_button').css({height: 40}).animate({ height: '22' }, 900);
jQuery.post ("ajax.php",
{"page" : "general/shortcut_bar",
"update_shortcut_state": 1,
"value": 1
$('#shortcut_bar').slideDown();
$('#shortcut_button>img')
.css('transform', 'rotate(90deg)')
.css('-o-transform', 'rotate(90deg)')
.css('-ms-transform', 'rotate(90deg)')
.css('-moz-transform', 'rotate(90deg)')
.css('-webkit-transform', 'rotate(90deg)');
jQuery.post (
"ajax.php",
{
"page" : "general/shortcut_bar",
"update_shortcut_state" : 1,
"value" : 2
},
function (data) {
}
function (data) {}
);
}
});
});
var id_user = $('#hidden-shortcut_id_user').val();
function shortcut_check_alerts() {
jQuery.post ("ajax.php",
jQuery.post (
"ajax.php",
{
"page" : "operation/agentes/alerts_status",
"get_alert_fired": 1
"page" : "general/shortcut_bar",
"get_alerts_fired": 1
},
function (data) {
$('#shortcut_alerts_fired').text(data);
$('#shortcut_alerts_fired').html(data);
}
);
}
function shortcut_check_events() {
jQuery.post ("ajax.php",
{"page" : "general/shortcut_bar",
"get_critical_events": 1
jQuery.post (
"ajax.php",
{
"page" : "general/shortcut_bar",
"get_critical_events": 1
},
function (data) {
$('#shortcut_critical_events').text(data);
$('#shortcut_critical_events').html(data);
}
);
}
function shortcut_check_incidents() {
jQuery.post ("ajax.php",
{"page" : "general/shortcut_bar",
"get_opened_incidents": 1
jQuery.post (
"ajax.php",
{
"page" : "general/shortcut_bar",
"get_opened_incidents": 1
},
function (data) {
$('#shortcut_incidents_opened').text(data);
$('#shortcut_incidents_opened').html(data);
}
);
}
$(document).ready (function () {
//TODO: Fix the change the content for the menu as html.
setInterval("shortcut_check_alerts()", (10 * 1000)); //10 seconds between ajax request
setInterval("shortcut_check_events()", (10 * 1000)); //10 seconds between ajax request
setInterval("shortcut_check_incidents()", (10 * 1000)); //10 seconds between ajax request
//For to make a link as item for drag only put "item_drag_shortcut" as class.
//To make a link as item for drag only put "item_drag_shortcut" as class.
//TODO: In the future show better as icons and the handle some icon.
//TODO: Remove the class "item_drag_shortcut" for avoid drag.
@ -400,4 +405,4 @@ echo "</div>";
scroll: false
});
});
</script>
</script>

View File

@ -2884,3 +2884,40 @@ td.empty_field {
#table_macros textarea {
width: 96%;
}
/* Shortcut bar */
#shortcut_container {
position: fixed;
margin: 0px !important;
bottom: 0px;
left: 0px;
}
#shortcut_bar {
background-color: #333;
background-image: url(../../images/header_blackout.png);
border-top: 1px solid #808080;
border-right: 1px solid #808080;
border-top-right-radius: 5px;
}
#shortcut_button {
display: inline-block;
background-color: #333;
border: 1px solid #808080;
border-bottom: none;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
}
.shortcut_item {
padding: 2px 10px;
text-decoration: none;
}
.shortcut_item>span {
color: #eee;
font-weight: bold;
font-size: 9pt;
}