#10281 snmpconsole visual correction and show/hide elements

This commit is contained in:
Jonathan 2023-02-09 14:45:10 +01:00
parent d89e29244b
commit 7a8777dba2

View File

@ -917,14 +917,25 @@ class SnmpConsole extends HTML
).'</a> ';
}
$tmp->action .= '<a href="javascript: toggleVisibleExtendedInfo('.$tmp->id_trap.','.$count.');">'.html_print_image(
$tmp->action .= '<a id="eye_'.$tmp->id_trap.'" data-show="show" href="javascript: toggleVisibleExtendedInfo('.$tmp->id_trap.','.$count.');">'.html_print_image(
'images/eye.png',
true,
[
'id' => 'img_'.$tmp->id_trap,
'alt' => __('Show more'),
'title' => __('Show more'),
'class' => 'invert_filter',
]
).' '.html_print_image(
'images/eye_hide.png',
true,
[
'id' => 'img_hide_'.$tmp->id_trap,
'alt' => __('Hide details'),
'title' => __('Hide details'),
'class' => 'invert_filter',
'style' => 'display:none',
]
).'</a>';
$tmp->action .= '<a href="index.php?sec=snmpconsole&sec2=enterprise/godmode/snmpconsole/snmp_trap_editor_form&oid='.$tmp->oid.'&custom_oid='.urlencode($tmp->oid_custom).'&severity='.$tmp->severity.'&text='.io_safe_input($tmp->text).'&description='.io_safe_input($tmp->description, ENT_QUOTES).'" title="'.io_safe_input($tmp->description, ENT_QUOTES).'">'.html_print_image('images/edit.png', true, ['alt' => __('SNMP trap editor'), 'title' => __('SNMP trap editor')]).'</a>';
@ -1337,6 +1348,16 @@ class SnmpConsole extends HTML
* Show more information
*/
function toggleVisibleExtendedInfo(id, position) {
// Show all "Show more"
$('[id^=img_]').each(function() {
$(this).show();
});
// Hide all "Hide details"
$('[id^=img_hide_]').each(function() {
$(this).hide();
});
var status = $('#eye_'+id).attr('data-show');
if(status == "show"){
$('tr[id^=show_]').remove()
$.ajax({
method: 'get',
@ -1399,21 +1420,21 @@ class SnmpConsole extends HTML
}
let labelType = '<td align="left" valign="top"><b><?php echo __('Type:'); ?></td>';
let variableType = `<td align="left">${desc_trap_type}</td>`;
let variableType = `<td align="left" colspan="8">${desc_trap_type}</td>`;
tr.after(`<tr id="show_" role="row">${labelType}${variableType}</tr>`);
// Description.
if (trap['description']) {
let labelDesc = '<td align="left" valign="top"><b><?php echo __('Description:'); ?></td>';
let variableDesc = `<td align="left">${trap['description']}</td>`;
let variableDesc = `<td align="left" colspan="8">${trap['description']}</td>`;
tr.after(`<tr id="show_" role="row">${labelDesc}${variableDesc}</tr>`);
}
// Enterprise String.
let labelOid = '<td align="left" valign="top"><b><?php echo __('Enterprise String:'); ?></td>';
let variableOId = `<td align="left">${trap['oid']}</td>`;
let variableOId = `<td align="left" colspan="8">${trap['oid']}</td>`;
tr.after(`<tr id="show_" role="row">${labelOid}${variableOId}</tr>`);
@ -1433,7 +1454,7 @@ class SnmpConsole extends HTML
const string = '<a href="'+new_url+'"><?php echo __('See more details'); ?></a>';
variableBindings = `<td align="left">${string}</td>`;
variableBindings = `<td align="left" colspan="8">${string}</td>`;
} else {
labelBindings = '<td align="left" valign="top" width="15%"><b><?php echo __('Variable bindings:'); ?></b></td>';
const binding_vars = trap['oid_custom'].split("\t");
@ -1441,7 +1462,7 @@ class SnmpConsole extends HTML
binding_vars.forEach(function(oid) {
string += oid+'<br/>';
});
variableBindings = `<td align="left">${string}</td>`;
variableBindings = `<td align="left" colspan="8">${string}</td>`;
}
tr.after(`<tr id="show_" role="row">${labelBindings}${variableBindings}</tr>`);
@ -1450,6 +1471,15 @@ class SnmpConsole extends HTML
console.error(e);
}
});
$('#eye_'+id).attr('data-show', 'hide');
$('#img_'+id).hide();
$('#img_hide_'+id).show();
} else{
$('tr[id^=show_]').remove();
$('#eye_'+id).attr('data-show', 'show');
$('#img_'+id).show();
$('#img_hide_'+id).hide();
}
}
$(document).ready(function() {