Merge branch '681-Añadir-control-flotante-a-vistas-fullscreen' into 'develop'

Added floating control in agents/modules, event list and snmp traps list

See merge request !351
This commit is contained in:
vgilc 2017-04-25 16:15:41 +02:00
commit ea6afb3701
6 changed files with 358 additions and 83 deletions

View File

@ -17,6 +17,7 @@
include_once($config['homedir'] . "/include/functions_agents.php");
include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . '/include/functions_users.php');
$refr = get_parameter('refresh', 0); // By default 30 seconds
function mainAgentsModules() {
global $config;
@ -63,7 +64,7 @@ function mainAgentsModules() {
$updated_time = $updated_info;
$modulegroup = get_parameter('modulegroup', 0);
$refr = get_parameter('refr', 30); // By default 30 seconds
$refr = get_parameter('refresh', 0); // By default 30 seconds
$group_id = (int)get_parameter('group_id', 0);
$offset = (int)get_parameter('offset', 0);
@ -97,29 +98,13 @@ function mainAgentsModules() {
serialize_in_temp($agents_id, $config['id_user']."_agents", 1);
}
$comborefr = '<form method="post" action="' . ui_get_url_refresh (array ('offset' => $offset, 'hor_offset' => $offset,'group_id' => $group_id, 'modulegroup' => $modulegroup)).'">';
$comborefr .= '<b>'.__('Refresh').'</b>';
$comborefr .= html_print_select (
array('30' => '30 ' . __('seconds'),
(string)SECONDS_1MINUTE => __('1 minute'),
(string)SECONDS_2MINUTES => __('2 minutes'),
(string)SECONDS_5MINUTES => __('5 minutes'),
(string)SECONDS_10MINUTES => __('10 minutes')),
'refr', (int)get_parameter('refr', 0),
$script = 'this.form.submit()', '', 0, true, false, false, '',
false, 'width: 100px; margin-right: 10px; margin-top: 5px;');
$comborefr .= "</form>";
if ($config["pure"] == 0) {
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;pure=1&amp;offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'">'
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;pure=1&amp;offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'">'
. html_print_image ("images/full_screen.png", true, array ("title" => __('Full screen mode')))
. "</a>";
}
else {
$fullscreen['text'] = '<a href="index.php?extension_in_menu=estado&amp;sec=extensions&amp;sec2=extensions/agents_modules&amp;refr=0&amp;offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'">'
. html_print_image ("images/normal_screen.png", true, array ("title" => __('Back to normal mode')))
. "</a>";
$config['refr'] = $refr;
}
$groups = users_get_groups ();
@ -168,26 +153,57 @@ function mainAgentsModules() {
'combo_module_groups' => $filter_module_groups,
'combo_groups' => $filter_groups);
if ($config['pure'] == 1) {
$onheader['combo_refr'] = $comborefr;
}
// Header
ui_print_page_header (__("Agents/Modules"), "images/module_mc.png", false, "", false, $updated_time);
// Old style table, we need a lot of special formatting,don't use table function
// Prepare old-style table
echo '<table style="width:100%;">';
echo "<tr>";
if ($config['pure'] == 1){
echo "<td>" . $comborefr . "</td>";
echo "<td>" . $fullscreen['text'] . "</td>";
}
else{
echo "<td> <span style='float: right;'>" . $fullscreen['text'] . "</span> </td>";
}
echo "</tr>";
echo "</table>";
if ($config['pure'] == 0){
// Header
ui_print_page_header (__("Agents/Modules"), "images/module_mc.png", false, "", false, $updated_time);
echo '<table style="width:100%;">';
echo "<tr>";
echo "<td> <span style='float: right;'>" . $fullscreen['text'] . "</span> </td>";
echo "</tr>";
echo "</table>";
} else {
$url =" index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh=$refr";
// Floating menu - Start
echo '<div id="vc-controls" style="z-index: 999">';
echo '<div id="menu_tab">';
echo '<ul class="mn">';
// Quit fullscreen
echo '<li class="nomn">';
echo '<a target="_top" href="' . $url . '">';
echo html_print_image('images/normal_screen.png', true, array('title' => __('Back to normal mode')));
echo '</a>';
echo '</li>';
// Countdown
echo '<li class="nomn">';
echo '<div class="vc-refr">';
echo '<div class="vc-countdown"></div>';
echo '<div id="vc-refr-form">';
echo __('Refresh') . ':';
echo html_print_select(get_refresh_time_array(), 'refresh', $refr, '', '', 0, true, false, false);
echo '</div>';
echo '</div>';
echo '</li>';
// Console name
echo '<li class="nomn">';
echo '<div class="vc-title">' . __('Agent/module view') . '</div>';
echo '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
// Floating menu - End
ui_require_jquery_file('countdown');
ui_require_css_file('countdown');
}
if($config['pure'] != 1){
echo '<form method="post" action="' . ui_get_url_refresh (array ('offset' => $offset, 'hor_offset' => $offset,'group_id' => $group_id, 'modulegroup' => $modulegroup)).'">';
@ -300,7 +316,7 @@ function mainAgentsModules() {
$agents = agents_get_agents ($filter_groups);
$nagents = count($agents);
if ($all_modules == false || $agents == false) {
ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no agents with modules') ) );
return;
@ -481,7 +497,7 @@ function mainAgentsModules() {
echo "</tr>";
}
echo "</table>";
echo "<div class='legend_basic' style='width: 96%'>";
@ -538,9 +554,50 @@ function mainAgentsModules() {
extensions_add_operation_menu_option(__("Agents/Modules view"), 'estado', 'agents_modules/icon_menu.png', "v1r1","view");
extensions_add_main_function('mainAgentsModules');
$ignored_params['refresh']='';
?>
<script type="text/javascript">
$(document).ready (function () {
var refr = <?php echo (int)$refr; ?>;
var pure = <?php echo (int) $config['pure']; ?>;
var href = "<?php echo ui_get_url_refresh ($ignored_params); ?>";
if (pure) {
var startCountDown = function (duration, cb) {
$('div.vc-countdown').countdown('destroy');
if (!duration) return;
var t = new Date();
t.setTime(t.getTime() + duration * 1000);
$('div.vc-countdown').countdown({
until: t,
format: 'MS',
layout: '(%M%nn%M:%S%nn%S <?php echo __('Until refresh'); ?>) ',
alwaysExpire: true,
onExpiry: function () {
$('div.vc-countdown').countdown('destroy');
url = js_html_entity_decode( href ) + duration;
$(document).attr ("location", url);
}
});
}
startCountDown(refr, false);
//~ // Auto hide controls
var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000);
$('select#refresh').change(function (event) {
refr = Number.parseInt(event.target.value, 10);
startCountDown(refr, false);
});
}
else {
$('#refresh').change(function () {
$('#hidden-vc_refr').val($('#refresh option:selected').val());
});
}
$("#group_id").change (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",

View File

@ -3752,20 +3752,24 @@ function ui_print_module_string_value($value, $id_agente_module,
* Displays a tag list
*/
function ui_print_tags_view($title = '', $tags = array()) {
$tv = '';
$tv .= '<div class="tag-wrapper">';
if ($title !== '') $tv .= '<h3>' . $title . '</h3>';
foreach ($tags as $tag) {
$tv .= '<div class=pandora-tag>';
$tv .= '<span class=pandora-tag-title>';
$tv .= $tag['title'];
$tv .= '</span>';
if (!empty($title)){
$tv .= '<div class="tag-wrapper">';
$tv .= '<h3>' . $title . '</h3>';
} else {
$tv .= '<div class="tag-wrapper" style="padding-top: 10px">';
}
foreach ($tags as $tag) {
$tv .= '<div class=pandora-tag>';
$tv .= '<span class=pandora-tag-title>';
$tv .= $tag['title'];
$tv .= '</span>';
$tv .= '<span class=pandora-tag-value>';
$tv .= $tag['value'];
$tv .= '</span>';
$tv .= '</div>';
}
$tv .= '<span class=pandora-tag-value>';
$tv .= $tag['value'];
$tv .= '</span>';
$tv .= '</div>';
}
$tv .= '</div>';
echo $tv;
}

View File

@ -232,6 +232,7 @@ $time_from = (string)get_parameter('time_from', '');
$time_to = (string)get_parameter('time_to', '');
$server_id = (int)get_parameter('server_id', 0);
$text_agent = (string) get_parameter("text_agent");
$refr = (int) get_parameter ('refresh');
if ($id_agent != 0) {
$text_agent = agents_get_alias($id_agent);
@ -286,7 +287,7 @@ $params = "search=" . rawurlencode(io_safe_input($search)) .
"&amp;status=" . $status .
"&amp;id_group=" . $id_group .
"&amp;recursion=" . $recursion .
"&amp;refr=" . (int)get_parameter("refr", 0) .
"&amp;refresh=" . (int)get_parameter("refresh", 0) .
"&amp;id_agent=" . $id_agent .
"&amp;id_agent_module=" . $id_agent_module .
"&amp;pagination=" . $pagination .
@ -306,8 +307,7 @@ $params = "search=" . rawurlencode(io_safe_input($search)) .
"&amp;date_from=" . $date_from .
"&amp;date_to=" . $date_to .
"&amp;time_from=" . $time_from .
"&amp;time_to=" . $time_to .
"&amp;pure=" . $config["pure"];
"&amp;time_to=" . $time_to;
if ($meta) {
$params .= "&amp;text_agent=" . $text_agent;
@ -443,15 +443,43 @@ if ($config["pure"] == 0 || $meta) {
}
else {
// Fullscreen
echo "<h2>" . __('Events') . " &raquo; " . __('Main event view') . "&nbsp;";
echo ui_print_help_icon ("eventview", true);
echo "&nbsp;";
// Floating menu - Start
echo '<div id="vc-controls" style="z-index: 999">';
echo '<div id="menu_tab">';
echo '<ul class="mn">';
// Quit fullscreen
echo '<li class="nomn">';
echo '<a target="_top" href="' . $url . '&amp;pure=0">';
html_print_image ("images/normalscreen.png", false,
array("title" => __('Back to normal mode')));
echo html_print_image('images/normal_screen.png', true, array('title' => __('Back to normal mode')));
echo '</a>';
echo "</h2>";
echo '</li>';
// Countdown
echo '<li class="nomn">';
echo '<div class="vc-refr">';
echo '<div class="vc-countdown"></div>';
echo '<div id="vc-refr-form">';
echo __('Refresh') . ':';
echo html_print_select(get_refresh_time_array(), 'refresh', $refr, '', '', 0, true, false, false);
echo '</div>';
echo '</div>';
echo '</li>';
// Console name
echo '<li class="nomn">';
echo '<div class="vc-title">' . __('Event viewer') . '</div>';
echo '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
// Floating menu - End
ui_require_jquery_file('countdown');
ui_require_css_file('countdown');
}
// Error div for ajax messages
@ -525,12 +553,59 @@ echo "<div id='event_response_window'></div>";
ui_require_jquery_file ('bgiframe');
ui_require_javascript_file('pandora_events');
enterprise_hook('close_meta_frame');
ui_require_javascript_file('wz_jsgraphics');
ui_require_javascript_file('pandora_visual_console');
$ignored_params['refresh']='';
?>
<script language="javascript" type="text/javascript">
/* <![CDATA[ */
$(document).ready( function() {
var refr = <?php echo (int)$refr; ?>;
var pure = <?php echo (int) $config['pure']; ?>;
var href = "<?php echo ui_get_url_refresh ($ignored_params); ?>";
// alert($(location).attr('href'));
if (pure) {
var startCountDown = function (duration, cb) {
$('div.vc-countdown').countdown('destroy');
if (!duration) return;
var t = new Date();
t.setTime(t.getTime() + duration * 1000);
$('div.vc-countdown').countdown({
until: t,
format: 'MS',
layout: '(%M%nn%M:%S%nn%S <?php echo __('Until refresh'); ?>) ',
alwaysExpire: true,
onExpiry: function () {
$('div.vc-countdown').countdown('destroy');
//cb();
url = js_html_entity_decode( href ) + duration;
$(document).attr ("location", url);
}
});
}
startCountDown(refr, false);
//~ // Auto hide controls
var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000);
$('select#refresh').change(function (event) {
refr = Number.parseInt(event.target.value, 10);
startCountDown(refr, false);
});
}
else {
$('#refresh').change(function () {
$('#hidden-vc_refr').val($('#refresh option:selected').val());
});
}
$("input[name=all_validate_box]").change (function() {
if ($(this).is(":checked")) {
$("input[name='validate_ids[]']").check();

View File

@ -632,10 +632,20 @@ $events_filter .= $botom_update;
$events_filter .= "</form>"; //This is the filter div
if (is_metaconsole())
$filter_resume['title'] = empty($id_name)
? __('No filter loaded')
: __('Filter loaded') . ': ' . $id_name;
if (is_metaconsole()){
ui_toggle($events_filter, __("Show Options"));
else
ui_toggle($events_filter, __('Event control filter'));
} else {
if($config['pure']){
ui_toggle($events_filter, __('Event control filter') .". ". $filter_resume['title']);
} else {
ui_toggle($events_filter, __('Event control filter'));
}
}
// Error div for ajax messages
echo "<div id='show_filter_error' style='display: none;'>";
@ -711,9 +721,8 @@ elseif ($group_rep == 2) {
$history);
}
$filter_resume['title'] = empty($id_name)
? __('No filter loaded')
: __('Filter loaded') . ': ' . $id_name;
// Active filter tag view call (only enterprise version)
// It is required to pass some references to enterprise function
// to translate the active filters

View File

@ -51,7 +51,7 @@ else {
// List
$list = array();
$list['text'] = '<a href="index.php?sec=estado&sec2=operation/snmpconsole/snmp_view&pure=' . $config["pure"] . '&refr=' . $refr . '">' .
$list['text'] = '<a href="index.php?sec=estado&sec2=operation/snmpconsole/snmp_view&pure=' . $config["pure"] . '&refresh=' . $refr . '">' .
html_print_image("images/op_snmp.png", true, array ("title" => __('List'))) .'</a>';
// Statistics (This file)

View File

@ -41,7 +41,8 @@ $pagination = (int) get_parameter ("pagination", $config["block_size"]);
$offset = (int) get_parameter ('offset',0);
$trap_type = (int) get_parameter ('trap_type', -1);
$group_by = (int)get_parameter('group_by', 0);
$refr = (int)get_parameter("refr", 0);
$refr = (int)get_parameter("refresh");
$default_refr = !empty($refr) ? $refr : $config['vc_refr'];
$user_groups = users_get_groups ($config['id_user'], $access, false);
@ -69,21 +70,18 @@ $url = "index.php?sec=estado&" .
$statistics['text'] = '<a href="index.php?sec=estado&sec2=operation/snmpconsole/snmp_statistics&pure=' . $config["pure"] . '&refr=' . $refr . '">' .
html_print_image("images/op_reporting.png", true, array ("title" => __('Statistics'))) .'</a>';
$list['text'] = '<a href="' . $url . '&pure=' . $config["pure"] . '&refr=' . $refr . '">' .
$list['text'] = '<a href="' . $url . '&pure=' . $config["pure"] . '&refresh=' . $refr . '">' .
html_print_image("images/op_snmp.png", true, array ("title" => __('List'))) .'</a>';
$list['active'] = true;
if ($config["pure"]) {
$fullscreen['text'] = '<a target="_top" href="'.$url.'&pure=0&refr=' . $refr . '">' . html_print_image("images/normal_screen.png", true, array("title" => __('Normal screen'))) . '</a>';
$fullscreen['text'] = '<a target="_top" href="'.$url.'&pure=0&refresh=' . $refr . '">' . html_print_image("images/normal_screen.png", true, array("title" => __('Normal screen'))) . '</a>';
}
else {
// Fullscreen
$fullscreen['text'] = '<a target="_top" href="'.$url.'&pure=1&refr=' . $refr . '">' . html_print_image("images/full_screen.png", true, array("title" => __('Full screen'))) . '</a>';
$fullscreen['text'] = '<a target="_top" href="'.$url.'&pure=1&refresh=' . $refr . '">' . html_print_image("images/full_screen.png", true, array("title" => __('Full screen'))) . '</a>';
}
// Header
ui_print_page_header(__("SNMP Console"), "images/op_snmp.png", false,
"", false, array($fullscreen, $list, $statistics));
// OPERATIONS
@ -445,7 +443,7 @@ if ($config['dbtype'] != 'oracle') {
$filter = '<form method="POST" action="index.php?' .
'sec=snmpconsole&' .
'sec2=operation/snmpconsole/snmp_view&' .
'refr=' . ((int)get_parameter('refr', 0)) . '&' .
'refresh=' . ((int)get_parameter('refresh', 0)) . '&' .
'pure=' . $config["pure"] . '">';
$filter .= html_print_table($table, true);
$filter .= '<div style="width: ' . $table->width . '; text-align: right;">';
@ -453,9 +451,7 @@ $filter .= html_print_submit_button(__('Update'), 'search', false, 'class="sub u
$filter .= '</div>';
$filter .= '</form>';
ui_toggle($filter, __('Toggle filter(s)'));
unset ($table);
@ -466,10 +462,103 @@ $trapcount = (int) db_get_value_sql($sql_count);
// No traps
if (empty ($traps)) {
// Header
ui_print_page_header(__("SNMP Console"), "images/op_snmp.png", false,
"", false, array($list, $statistics));
ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no SNMP traps in database') ) );
return;
} else{
if($config["pure"]){
echo '<div id="dashboard-controls">';
echo '<div id="menu_tab">';
echo '<ul class="mn">';
// Normal view button
echo '<li class="nomn">';
$normal_url = "index.php?" .
"sec=snmpconsole&" .
"sec2=operation/snmpconsole/snmp_view&" .
"filter_severity=" . $filter_severity . "&" .
"filter_fired=" . $filter_fired . "&" .
"filter_status=" . $filter_status . "&" .
"refresh=" . ((int)get_parameter('refresh', 0)) . "&" .
"pure=0&" .
"trap_type=" . $trap_type . "&" .
"group_by=" . $group_by . "&" .
"free_search_string=" . $free_search_string;
$urlPagination = $normal_url . "&" .
"pagination=" . $pagination . "&" .
"offset=" . $offset;
echo '<a href="' . $urlPagination . '">';
echo html_print_image('images/normal_screen.png', true, array('title' => __('Exit fullscreen')));
echo '</a>';
echo '</li>';
// Auto refresh control
echo '<li class="nomn">';
echo '<div class="dashboard-refr" style="margin-top: 6px;">';
echo '<div class="dashboard-countdown" style="display: inline;"></div>';
$normal_url = "index.php?" .
"sec=snmpconsole&" .
"sec2=operation/snmpconsole/snmp_view&" .
"filter_severity=" . $filter_severity . "&" .
"filter_fired=" . $filter_fired . "&" .
"filter_status=" . $filter_status . "&" .
"refresh=" . ((int)get_parameter('refresh', 0)) . "&" .
"pure=1&" .
"trap_type=" . $trap_type . "&" .
"group_by=" . $group_by . "&" .
"free_search_string=" . $free_search_string;
$urlPagination = $normal_url . "&" .
"pagination=" . $pagination . "&" .
"offset=" . $offset;
echo '<form id="refr-form" method="get" action="' . $urlPagination . '" style="display: inline;">';
echo __('Refresh every') . ':';
echo html_print_select(get_refresh_time_array(), 'refresh', $refr, '', '', 0, true, false, false);
echo '</form>';
echo '</li>';
html_print_input_hidden('sec', 'snmpconsole');
html_print_input_hidden('sec2', 'operation/snmpconsole/snmp_view');
html_print_input_hidden('pure', 1);
html_print_input_hidden('refresh', ($refr > 0 ? $refr : $default_refr));
// Dashboard name
echo '<li class="nomn">';
echo '<div class="dashboard-title">' . __('SNMP Traps') . '</div>';
echo '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
ui_require_css_file('pandora_enterprise', ENTERPRISE_DIR . '/include/styles/');
ui_require_css_file('pandora_dashboard', ENTERPRISE_DIR . '/include/styles/');
ui_require_css_file('cluetip');
ui_require_jquery_file('countdown');
ui_require_javascript_file('pandora_dashboard', ENTERPRISE_DIR.'/include/javascript/');
ui_require_javascript_file('wz_jsgraphics');
ui_require_javascript_file('pandora_visual_console');
} else {
// Header
ui_print_page_header(__("SNMP Console"), "images/op_snmp.png", false,
"", false, array($fullscreen, $list, $statistics));
}
}
ui_toggle($filter, __('Toggle filter(s)'));
unset ($table);
if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
for ($i = 0; $i < count($traps); $i++) {
unset($traps[$i]['rnum']);
@ -482,7 +571,7 @@ $url_snmp = "index.php?" .
"filter_severity=" . $filter_severity . "&" .
"filter_fired=" . $filter_fired . "&" .
"filter_status=" . $filter_status . "&" .
"refr=" . ((int)get_parameter('refr', 0)) . "&" .
"refresh=" . ((int)get_parameter('refresh', 0)) . "&" .
"pure=" . $config["pure"] . "&" .
"trap_type=" . $trap_type . "&" .
"group_by=" . $group_by . "&" .
@ -688,7 +777,7 @@ if ($traps !== false) {
"filter_severity=" . $filter_severity . "&" .
"filter_fired=" . $filter_fired . "&" .
"filter_status=" . $filter_status . "&" .
"refr=" . ((int)get_parameter('refr', 0)) . "&" .
"refresh=" . ((int)get_parameter('refresh', 0)) . "&" .
"pure=" . $config["pure"] . "&" .
"group_by=0&" .
"free_search_string=" . $free_search_string;
@ -855,7 +944,48 @@ echo '<div style="clear:both;">&nbsp;</div>';
?>
<script language="JavaScript" type="text/javascript">
<!--
$(document).ready( function() {
var controls = document.getElementById('dashboard-controls');
autoHideElement(controls, 1000);
var startCountDown = function (duration, cb) {
$('div.dashboard-countdown').countdown('destroy');
if (!duration) return;
var t = new Date();
t.setTime(t.getTime() + duration * 1000);
$('div.dashboard-countdown').countdown({
until: t,
format: 'MS',
layout: '(%M%nn%M:%S%nn%S <?php echo __('Until next'); ?>) ',
alwaysExpire: true,
onExpiry: function () {
$('div.dashboard-countdown').countdown('destroy');
cb();
}
});
}
// Auto refresh select
$('form#refr-form').submit(function (event) {
event.preventDefault();
});
var handleRefrChange = function (event) {
event.preventDefault();
var url = $('form#refr-form').prop('action');
var refr = Number.parseInt(event.target.value, 10);
startCountDown(refr, function () {
window.location = url + '&refresh=' + refr;
});
}
$('form#refr-form select').change(handleRefrChange).change();
});
function CheckAll() {
for (var i = 0; i < document.eventtable.elements.length; i++) {
var e = document.eventtable.elements[i];
@ -883,5 +1013,5 @@ echo '<div style="clear:both;">&nbsp;</div>';
$('.trap_info_' + id_trap).css('display', '');
}
}
//-->
</script>