|
| 1 | +/* |
| 2 | + +-------------------------------------------------------------------------+ |
| 3 | + | Copyright (C) 2004-2025 The Cacti Group | |
| 4 | + | | |
| 5 | + | This program is free software; you can redistribute it and/or | |
| 6 | + | modify it under the terms of the GNU General Public License | |
| 7 | + | as published by the Free Software Foundation; either version 2 | |
| 8 | + | of the License, or (at your option) any later version. | |
| 9 | + | | |
| 10 | + | This program is distributed in the hope that it will be useful, | |
| 11 | + | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | + | GNU General Public License for more details. | |
| 14 | + +-------------------------------------------------------------------------+ |
| 15 | + | Cacti: The Complete RRDTool-based Graphing Solution | |
| 16 | + +-------------------------------------------------------------------------+ |
| 17 | + | This code is designed, written, and maintained by the Cacti Group. See | |
| 18 | + | about.php and/or the AUTHORS file for specific developer information. | |
| 19 | + +-------------------------------------------------------------------------+ |
| 20 | + | http://www.cacti.net/ | |
| 21 | + +-------------------------------------------------------------------------+ |
| 22 | +*/ |
| 23 | + |
| 24 | +/** |
| 25 | + * Audit Plugin JavaScript Functions |
| 26 | + * |
| 27 | + * This file contains all JavaScript functions for the Audit plugin |
| 28 | + */ |
| 29 | + |
| 30 | +/** |
| 31 | + * Apply filter to audit log |
| 32 | + */ |
| 33 | +function audit_applyFilter() { |
| 34 | + strURL = 'audit.php' + |
| 35 | + '?filter='+$('#filter').val()+ |
| 36 | + '&rows='+$('#rows').val()+ |
| 37 | + '&page='+$('#page').val()+ |
| 38 | + '&event_page='+$('#event_page').val()+ |
| 39 | + '&user_id='+$('#user_id').val()+ |
| 40 | + '&header=false'; |
| 41 | + loadPageNoHeader(strURL); |
| 42 | +} |
| 43 | + |
| 44 | +/** |
| 45 | + * Clear all filters |
| 46 | + */ |
| 47 | +function audit_clearFilter() { |
| 48 | + strURL = 'audit.php?clear=1&header=false'; |
| 49 | + loadPageNoHeader(strURL); |
| 50 | +} |
| 51 | + |
| 52 | +/** |
| 53 | + * Global variable to store audit timer |
| 54 | + */ |
| 55 | +var auditTimer = null; |
| 56 | + |
| 57 | +/** |
| 58 | + * Open dialog to display audit event details |
| 59 | + * @param {number} id - The audit event ID |
| 60 | + */ |
| 61 | +function audit_open_dialog(id) { |
| 62 | + $.get('audit.php?action=getdata&id='+id, function(data) { |
| 63 | + var width; |
| 64 | + if (data.indexOf('narrow') > 0) { |
| 65 | + width = 400; |
| 66 | + } else { |
| 67 | + width = 700; |
| 68 | + } |
| 69 | + $('body').append('<div id="audit" style="display:block;display:none;" title="Audit Event Details">'+data+'</div>'); |
| 70 | + $('#audit').dialog({ |
| 71 | + minWidth: width, |
| 72 | + position: { |
| 73 | + my: 'left', |
| 74 | + at: 'right', |
| 75 | + of: $('span[id="event'+id+'"]') |
| 76 | + } |
| 77 | + }); |
| 78 | + }); |
| 79 | +} |
| 80 | + |
| 81 | +/** |
| 82 | + * Close audit dialog |
| 83 | + */ |
| 84 | +function audit_close_dialog() { |
| 85 | + if ($('#audit').length) { |
| 86 | + if (typeof $('#audit').dialog() === 'function') { |
| 87 | + $('#audit').dialog('close'); |
| 88 | + } |
| 89 | + $('#audit').remove(); |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +/** |
| 94 | + * Initialize audit event handlers on document ready |
| 95 | + */ |
| 96 | +$(function() { |
| 97 | + // Filter change event handlers |
| 98 | + $('#event_page, #user_id, #rows').change(function() { |
| 99 | + audit_applyFilter(); |
| 100 | + }); |
| 101 | + |
| 102 | + $('#refresh').click(function() { |
| 103 | + audit_applyFilter(); |
| 104 | + }); |
| 105 | + |
| 106 | + $('#clear').click(function() { |
| 107 | + audit_clearFilter(); |
| 108 | + }); |
| 109 | + |
| 110 | + $('#purge').click(function() { |
| 111 | + strURL = 'audit.php?action=purge&header=false'; |
| 112 | + loadPageNoHeader(strURL); |
| 113 | + }); |
| 114 | + |
| 115 | + $('#export').click(function() { |
| 116 | + document.location = 'audit.php?action=export' + |
| 117 | + '&filter='+$('#filter').val()+ |
| 118 | + '&event_page='+$('#event_page').val()+ |
| 119 | + '&user_id='+$('#user_id').val(); |
| 120 | + }); |
| 121 | + |
| 122 | + $('#form_audit').submit(function(event) { |
| 123 | + event.preventDefault(); |
| 124 | + audit_applyFilter(); |
| 125 | + }); |
| 126 | + |
| 127 | + // Hover event handlers for audit event details |
| 128 | + $('span[id^="event"]').hover(function() { |
| 129 | + audit_close_dialog(); |
| 130 | + |
| 131 | + id = $(this).attr('id').replace('event', ''); |
| 132 | + |
| 133 | + if (auditTimer != null) { |
| 134 | + clearTimeout(auditTimer); |
| 135 | + } |
| 136 | + |
| 137 | + auditTimer = setTimeout(function() { audit_open_dialog(id); }, 400); |
| 138 | + }, |
| 139 | + function() { |
| 140 | + if (auditTimer != null) { |
| 141 | + clearTimeout(auditTimer); |
| 142 | + } |
| 143 | + |
| 144 | + $('#dialog').hover(function() { |
| 145 | + clearTimeout(auditTimer); |
| 146 | + }, function() { |
| 147 | + auditTimer = setTimeout(function() { audit_close_dialog(); }, 400); |
| 148 | + }); |
| 149 | + }); |
| 150 | +}); |
0 commit comments