From bc16d5b92fea9729c9e1b1e30692e343ce18a17a Mon Sep 17 00:00:00 2001 From: Ronaldo Richieri Date: Mon, 22 Apr 2024 09:43:07 -0300 Subject: [PATCH] Add option to log all htmx requests to browser console Add a new option to RT_Config.pm, $HtmxLogAll, which when set to a true value will cause all htmx requests to be logged to the browser console. --- etc/RT_Config.pm.in | 9 +++++++++ share/html/Elements/HeaderJavascript | 4 ++++ share/static/js/htmx-log-all.js | 1 + 3 files changed, 14 insertions(+) create mode 100644 share/static/js/htmx-log-all.js diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in index 2c4a9f3025d..334ec139feb 100644 --- a/etc/RT_Config.pm.in +++ b/etc/RT_Config.pm.in @@ -1818,6 +1818,15 @@ reason, add this to config: See also L. +=item C<$HtmxLogAll> + +Turns on logging of all HTMX requests. This is useful for debugging +HTMX requests and responses. + +=cut + +Set($HtmxLogAll, 0); + =back diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript index 6f7e91817ff..e846af6c4e3 100644 --- a/share/html/Elements/HeaderJavascript +++ b/share/html/Elements/HeaderJavascript @@ -73,4 +73,8 @@ else { @js_files = "/NoAuth/js/squished-$key.js"; } +if ( RT->Config->Get('HtmxLogAll') ) { + push @js_files, "/static/js/htmx-log-all.js"; +} + diff --git a/share/static/js/htmx-log-all.js b/share/static/js/htmx-log-all.js new file mode 100644 index 00000000000..be0b753fc12 --- /dev/null +++ b/share/static/js/htmx-log-all.js @@ -0,0 +1 @@ +htmx.logAll();