Skip to content

Commit 2bcb3e0

Browse files
authored
Refactor - Migrats JS functions to functions.js (#43)
* Refactor - Move JS functions to functions.js * update agent tools * update agent tools
1 parent 813960b commit 2bcb3e0

File tree

7 files changed

+156
-108
lines changed

7 files changed

+156
-108
lines changed

.github/agents/code-quality.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "This Custom agent acts as a quality assurance specialist, focusing on code quality, best practices, and maintainability."
33
name: "Code Quality Specialist"
4-
tools: ["search/codebase", "edit/editFiles", "web/githubRepo", "vscode/extensions", "execute/getTerminalOutput", "web"]
4+
tools: ['vscode/extensions', 'execute/testFailure', 'execute/getTerminalOutput', 'execute/getTaskOutput', 'execute/runInTerminal', 'execute/runTests', 'read', 'edit/createFile', 'edit/editFiles', 'search', 'web']
55
model: "Claude Sonnet 4.5"
66
---
77

.github/agents/mysql-mariadb.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "This custom agent assits with enhancements, troubleshooting, and management of MySQL and MariaDB databases."
33
name: "MySQL/ MariaDB Database Administrator"
4-
tools: ["search/codebase", "edit/editFiles", "web/githubRepo", "vscode/extensions", "execute/getTerminalOutput", "web"]
4+
tools: ['vscode/extensions', 'execute/testFailure', 'execute/getTerminalOutput', 'execute/getTaskOutput', 'execute/runInTerminal', 'execute/runTests', 'read', 'edit/createFile', 'edit/editFiles', 'search', 'web']
55
model: "Claude Sonnet 4.5"
66
---
77

.github/agents/php-devloper.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "This custom agent acts as a PHP developer, assisting with PHP code development, debugging, and optimization."
33
name: "PHP Developer"
4-
tools: ["search/codebase", "edit/editFiles", "web/githubRepo", "vscode/extensions", "execute/getTerminalOutput", "web"]
4+
tools: ['vscode/extensions', 'execute/testFailure', 'execute/getTerminalOutput', 'execute/getTaskOutput', 'execute/runInTerminal', 'execute/runTests', 'read', 'edit/createFile', 'edit/editFiles', 'search', 'web']
55
model: "Claude Sonnet 4.5"
66
---
77

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* issue: If the audit log does not exist or is not set, set it and create it
77
* issue: Audit assumes that all selected_items are numeric resulting in fatal error
88
* feature: Support for Cacti 1.3
9+
* Refactor: Migrats JS functions to functions.js
910

1011
--- 1.2 ---
1112

audit.php

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -338,54 +338,6 @@ function audit_log() {
338338
</table>
339339
<input type='hidden' id='page' value='<?php print get_request_var('page');?>'>
340340
</form>
341-
<script type='text/javascript'>
342-
function applyFilter() {
343-
strURL = 'audit.php' +
344-
'?filter='+$('#filter').val()+
345-
'&rows='+$('#rows').val()+
346-
'&page='+$('#page').val()+
347-
'&event_page='+$('#event_page').val()+
348-
'&user_id='+$('#user_id').val()+
349-
'&header=false';
350-
loadPageNoHeader(strURL);
351-
}
352-
353-
function clearFilter() {
354-
strURL = 'audit.php?clear=1&header=false';
355-
loadPageNoHeader(strURL);
356-
}
357-
358-
$(function() {
359-
$('#event_page, #user_id, #rows').change(function() {
360-
applyFilter();
361-
});
362-
363-
$('#refresh').click(function() {
364-
applyFilter();
365-
});
366-
367-
$('#clear').click(function() {
368-
clearFilter();
369-
});
370-
371-
$('#purge').click(function() {
372-
strURL = 'audit.php?action=purge&header=false';
373-
loadPageNoHeader(strURL);
374-
});
375-
376-
$('#export').click(function() {
377-
document.location = 'audit.php?action=export' +
378-
'&filter='+$('#filter').val()+
379-
'&event_page='+$('#event_page').val()+
380-
'&user_id='+$('#user_id').val();
381-
});
382-
383-
$('#form_audit').submit(function(event) {
384-
event.preventDefault();
385-
applyFilter();
386-
});
387-
});
388-
</script>
389341
</td>
390342
</tr>
391343
<?php
@@ -508,61 +460,7 @@ function clearFilter() {
508460
}
509461

510462
?>
511-
<script type='text/javascript'>
512-
var auditTimer = null;
513-
514-
function open_dialog(id) {
515-
$.get('audit.php?action=getdata&id='+id, function(data) {
516-
if (data.indexOf('narrow') > 0) {
517-
width = 400;
518-
} else {
519-
width = 700;
520-
}
521-
$('body').append('<div id="audit" style="display:block;display:none;" title="<?php print __esc('Audit Event Details', 'audit');?>">'+data+'</div>');
522-
$('#audit').dialog({
523-
minWidth: width,
524-
position: {
525-
my: 'left',
526-
at: 'right',
527-
of: $('span[id="event'+id+'"]')
528-
}
529-
});
530-
});
531-
}
532-
533-
$('span[id^="event"]').hover(function() {
534-
close_dialog();
535-
536-
id = $(this).attr('id').replace('event', '');
537-
538-
if (auditTimer != null) {
539-
clearTimeout(auditTimer);
540-
}
541-
542-
auditTimer = setTimeout(function() { open_dialog(id); }, 400);
543-
},
544-
function() {
545-
if (auditTimer != null) {
546-
clearTimeout(auditTimer);
547-
}
548-
549-
$('#dialog').hover(function() {
550-
clearTimeout(auditTimer);
551-
}, function() {
552-
auditTimer = setTimeout(function() { close_dialog(); }, 400);
553-
});
554-
555-
});
556-
557-
function close_dialog() {
558-
if ($('#audit').length) {
559-
if (typeof $('#audit').dialog() === 'function') {
560-
$('#audit').dialog('close');
561-
}
562-
$('#audit').remove();
563-
}
564-
}
565-
</script>
463+
<script type='text/javascript' src='plugins/audit/js/functions.js'></script>
566464
<?php
567465
}
568466

audit_functions.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,4 @@ function audit_config_insert() {
266266
array($page, $user_id, $action, $ip_address, $user_agent, $event_time, $post));
267267
}
268268
}
269-
}
270-
269+
}

js/functions.js

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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

Comments
 (0)