Added link to go to agent view (node) from metaconsole in events view - #4720

This commit is contained in:
Tatiana Llorente 2019-09-30 13:31:15 +02:00
parent b072bb5314
commit 9875b7c701
1 changed files with 32 additions and 5 deletions

View File

@ -281,10 +281,16 @@ if (is_ajax()) {
function ($carry, $item) {
$tmp = (object) $item;
$tmp->hint = '';
$tmp->meta = false;
$tmp->meta = is_metaconsole();
if (is_metaconsole()) {
if ($tmp->server_name !== null) {
$tmp->data_server = metaconsole_get_servers($tmp->server_id);
$tmp->server_url_hash = metaconsole_get_servers_url_hash($tmp->data_server);
}
}
if (strlen($tmp->evento) >= 255) {
$tmp->hint = io_safe_output(chunk_split(substr($tmp->evento, 0, 600), 80, '<br>').'(...)');
$tmp->meta = is_metaconsole();
$tmp->evento = io_safe_output(substr($tmp->evento, 0, 253).'(...)');
if (strpos($tmp->evento, ' ') === false) {
$tmp->evento = substr($tmp->evento, 0, 80).'(...)';
@ -1600,6 +1606,17 @@ function process_datatables_callback(table, settings) {
function process_datatables_item(item) {
// Url to go to node from meta.
var server_url = '';
var hashdata = '';
if(item.meta === true){
if(typeof item.data_server !== 'undefined' && typeof item.server_url_hash !== 'undefined'){
server_url = item.data_server.server_url;
hashdata = item.server_url_hash;
}
}
// Grouped events.
if(item.max_id_evento) {
item.id_evento = item.max_id_evento
@ -1838,9 +1855,19 @@ function process_datatables_item(item) {
/* Update column content now to avoid json poisoning. */
// Url to agent view.
var url_link = '<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>';
var url_link_hash = '';
if(item.meta === true){
url_link = server_url+'/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=';
url_link_hash = hashdata;
}
/* Agent name link */
if (item.id_agente > 0) {
item.agent_name = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>' +item.id_agente+'">' + item.agent_name + '</a>';
item.agent_name = '<a href="'+url_link+item.id_agente+url_link_hash+'">' + item.agent_name + '</a>';
} else {
item.agent_name = '';
}
@ -1850,11 +1877,11 @@ function process_datatables_item(item) {
<?php
if (in_array('agent_name', $fields)) {
?>
item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.id_agente + '</a>';
item.id_agente = '<a href="'+url_link+item.id_agente+url_link_hash+'">' + item.id_agente + '</a>';
<?php
} else {
?>
item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.agent_name + '</a>';
item.id_agente = '<a href="'+url_link+item.id_agente+url_link_hash+'">' + item.agent_name + '</a>';
<?php
}
?>