mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
Extended events
Former-commit-id: f2e0925ce58042dc9c9505a0d0fcf1a424c8a0bb
This commit is contained in:
parent
091f6ace96
commit
49cf9d5db0
@ -397,6 +397,10 @@ if ($get_extended_event) {
|
|||||||
// Tabs.
|
// Tabs.
|
||||||
$tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>";
|
$tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>";
|
||||||
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>';
|
||||||
|
if ($event['extended_info'] == 1) {
|
||||||
|
$tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Related').'</span></a></li>';
|
||||||
|
}
|
||||||
|
|
||||||
$tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Details').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Details').'</span></a></li>';
|
||||||
$tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/custom_field_col.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Agent fields').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/custom_field_col.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Agent fields').'</span></a></li>';
|
||||||
$tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Comments').'</span></a></li>';
|
$tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Comments').'</span></a></li>';
|
||||||
@ -487,6 +491,10 @@ if ($get_extended_event) {
|
|||||||
|
|
||||||
$details = events_page_details($event, $server);
|
$details = events_page_details($event, $server);
|
||||||
|
|
||||||
|
if ($event['extended_info'] == 1) {
|
||||||
|
$related = events_page_related($event, $server);
|
||||||
|
}
|
||||||
|
|
||||||
// Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct
|
// Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct
|
||||||
// node connection was lost.
|
// node connection was lost.
|
||||||
if ($meta) {
|
if ($meta) {
|
||||||
@ -515,7 +523,7 @@ if ($get_extended_event) {
|
|||||||
|
|
||||||
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>';
|
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||||
|
|
||||||
$out = '<div id="tabs" style="height:95%; overflow: auto">'.$tabs.$notifications.$loading.$general.$details.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
$out = '<div id="tabs" style="height:95%; overflow: auto">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
||||||
|
|
||||||
$js = '<script>
|
$js = '<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
@ -533,30 +541,53 @@ if ($get_extended_event) {
|
|||||||
$js .= '$tabs.tabs( "option", "active", 1);';
|
$js .= '$tabs.tabs( "option", "active", 1);';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'custom_fields':
|
case 'related':
|
||||||
$js .= '$tabs.tabs( "option", "active", 2);';
|
$js .= '$tabs.tabs( "option", "active", 2);';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'comments':
|
case 'custom_fields':
|
||||||
$js .= '$tabs.tabs( "option", "active", 3);';
|
$js .= '$tabs.tabs( "option", "active", 3);';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'responses':
|
case 'comments':
|
||||||
$js .= '$tabs.tabs( "option", "active", 4);';
|
$js .= '$tabs.tabs( "option", "active", 4);';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'custom_data':
|
case 'responses':
|
||||||
$js .= '$tabs.tabs( "option", "active", 5);';
|
$js .= '$tabs.tabs( "option", "active", 5);';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'custom_data':
|
||||||
|
$js .= '$tabs.tabs( "option", "active", 6);';
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Ignore.
|
// Ignore.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$js .= '
|
$js .= '});';
|
||||||
});
|
|
||||||
</script>';
|
if ($event['extended_info'] == 1) {
|
||||||
|
$js .= '
|
||||||
|
$("#link_related").click(function (){
|
||||||
|
$.post ({
|
||||||
|
url : "ajax.php",
|
||||||
|
data : {
|
||||||
|
page: "include/ajax/events_extended",
|
||||||
|
get_extended_info: 1,
|
||||||
|
id_event: '.$event['id_evento'].'
|
||||||
|
},
|
||||||
|
dataType : "html",
|
||||||
|
success: function (data) {
|
||||||
|
$("#related_data").html(data);
|
||||||
|
console.log("vamos puta");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});';
|
||||||
|
}
|
||||||
|
|
||||||
|
$js .= '</script>';
|
||||||
|
|
||||||
echo $out.$js;
|
echo $out.$js;
|
||||||
}
|
}
|
||||||
|
104
pandora_console/include/ajax/events_extended.php
Normal file
104
pandora_console/include/ajax/events_extended.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Manage AJAX response for event pages.
|
||||||
|
*
|
||||||
|
* @category Ajax
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Events extended
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2019 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_events.php';
|
||||||
|
|
||||||
|
|
||||||
|
enterprise_include_once('meta/include/functions_events_meta.php');
|
||||||
|
enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
// Check ACLs.
|
||||||
|
if (is_user_admin($config['id_user']) === true) {
|
||||||
|
// Do nothing if you're admin, you get full access.
|
||||||
|
$allowed = true;
|
||||||
|
} else if ($config['id_user'] == $event['owner_user']) {
|
||||||
|
// Do nothing if you're the owner user, you get access.
|
||||||
|
$allowed = true;
|
||||||
|
} else if ($event['id_grupo'] == 0) {
|
||||||
|
// If the event has access to all groups, you get access.
|
||||||
|
$allowed = true;
|
||||||
|
} else {
|
||||||
|
// Get your groups.
|
||||||
|
$groups = users_get_groups($config['id_user'], 'ER');
|
||||||
|
|
||||||
|
if (in_array($event['id_grupo'], array_keys($groups))) {
|
||||||
|
// If event group is among the groups of the user, you get access.
|
||||||
|
$__ignored_line = true;
|
||||||
|
} else {
|
||||||
|
// If all the access types fail, abort.
|
||||||
|
$allowed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($allowed === false) {
|
||||||
|
echo 'Access denied';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id_event = get_parameter('id_event', null);
|
||||||
|
$get_extended_info = get_parameter('get_extended_info', 0);
|
||||||
|
|
||||||
|
|
||||||
|
if ($get_extended_info == 1) {
|
||||||
|
if (isset($id_event) === falsse) {
|
||||||
|
echo 'Internal error. Invalid event.';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$extended_info = events_get_extended_events($id_event);
|
||||||
|
|
||||||
|
$table = new StdClass();
|
||||||
|
//
|
||||||
|
// Details.
|
||||||
|
//
|
||||||
|
$table->width = '100%';
|
||||||
|
$table->data = [];
|
||||||
|
$table->head = [];
|
||||||
|
$table->style[0] = 'min-width:120px; text-align: left;';
|
||||||
|
$table->style[1] = 'text-align: left;';
|
||||||
|
$table->cellspacing = 2;
|
||||||
|
$table->cellpadding = 2;
|
||||||
|
$table->class = 'alternate rounded_cells';
|
||||||
|
|
||||||
|
$output = [];
|
||||||
|
$output[] = '<b>'.__('Timestamp').'</b>';
|
||||||
|
$output[] = '<b>'.__('Description').'</b>';
|
||||||
|
$table->data[] = $output;
|
||||||
|
|
||||||
|
foreach ($extended_info as $data) {
|
||||||
|
$output = [];
|
||||||
|
$output[] = date('Y/m/d H:i:s', $data['utimestamp']);
|
||||||
|
$output[] = io_safe_output($data['description']);
|
||||||
|
$table->data[] = $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
html_print_table($table);
|
||||||
|
}
|
@ -2611,20 +2611,19 @@ function events_get_extended_events(int $id_evento)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the 'extended' page in event view.
|
* Generates the 'related' page in event view.
|
||||||
*
|
*
|
||||||
* @param array $event To be displayed.
|
* @param array $event To be displayed.
|
||||||
* @param string $server Server (if in metaconsole environment).
|
* @param string $server Server (if in metaconsole environment).
|
||||||
*
|
*
|
||||||
* @return string HTML to be displayed.
|
* @return string HTML to be displayed.
|
||||||
*/
|
*/
|
||||||
function events_page_extended($event, $server='')
|
function events_page_related($event, $server='')
|
||||||
{
|
{
|
||||||
$html = '';
|
$html = '<div id="extended_event_related_page" class="extended_event_pages">';
|
||||||
|
$html .= '<h4>'.__('Extended information').'</h4>';
|
||||||
$data = [];
|
$html .= '<div id="related_data"><p>'.__('Loading').'...</p></div>';
|
||||||
$data[0] = __('Extended events');
|
$html .= '</div>';
|
||||||
$data[1] = '';
|
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user