Skip to content

Commit 5b585fd

Browse files
author
Davide Arcuri
committed
fix htmx references
1 parent ca080da commit 5b585fd

20 files changed

Lines changed: 207 additions & 209 deletions

orochi/static/js/plotly/plotly-2.34.0.min.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

orochi/static/js/plotly/plotly-latest.min.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

orochi/templates/base.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
document.documentElement.classList.remove('dark');
3232
}
3333
</script>
34-
<script src="{% static 'js/plotly/plotly-latest.min.js' %}"></script>
34+
<script src="{% static 'js/plotly/plotly-2.34.0.min.js' %}"></script>
3535
</head>
3636

3737

@@ -158,7 +158,7 @@
158158

159159
<!-- Main Layout -->
160160
<!-- Sidebar Drawer -->
161-
<div id="sidemenu" class="fixed top-0 left-0 z-40 w-80 h-screen px-4 pb-4 pt-24 overflow-y-auto no-scrollbar transition-transform -translate-x-full bg-zinc-50 border border-zinc-200 dark:bg-zinc-700 dark:border-zinc-600 border-r border-zinc-300 dark:border-zinc-600 shadow-2xl" tabindex="-1" aria-labelledby="sidemenuLabel">
161+
<div id="sidemenu" data-drawer-body-scrolling="true" data-drawer-backdrop="false" class="fixed top-0 left-0 z-40 w-80 h-screen px-4 pb-4 pt-24 overflow-y-auto no-scrollbar transition-transform -translate-x-full bg-zinc-50 border border-zinc-200 dark:bg-zinc-700 dark:border-zinc-600 border-r border-zinc-300 dark:border-zinc-600 shadow-2xl" tabindex="-1" aria-labelledby="sidemenuLabel">
162162
{% block sidebar %}{% endblock sidebar %}
163163
</div>
164164

@@ -172,7 +172,7 @@
172172
{% endblock fullpage %}
173173

174174
<!-- History Log Drawer -->
175-
<div id="leftNote" class="fixed top-0 right-0 z-[60] w-96 h-screen p-4 overflow-y-auto transition-transform translate-x-full bg-zinc-50 border border-zinc-200 dark:bg-zinc-700 dark:border-zinc-600 border-l border-zinc-300 dark:border-zinc-600 shadow-2xl" tabindex="-1" aria-labelledby="leftNoteLabel">
175+
<div id="leftNote" data-drawer-body-scrolling="true" data-drawer-backdrop="false" class="fixed top-0 right-0 z-[60] w-96 h-screen p-4 overflow-y-auto transition-transform translate-x-full bg-zinc-50 border border-zinc-200 dark:bg-zinc-700 dark:border-zinc-600 border-l border-zinc-300 dark:border-zinc-600 shadow-2xl" tabindex="-1" aria-labelledby="leftNoteLabel">
176176

177177
<h5 id="leftNoteLabel" class="inline-flex items-center mb-4 text-base font-semibold text-zinc-800 dark:text-zinc-200">
178178
<i class="fas fa-sticky-note mr-2"></i> History Log
@@ -227,6 +227,12 @@ <h5 id="changelogLabel" class="inline-flex items-center mb-6 text-xl font-bold t
227227
<script defer src="{% static 'js/fontawesome/all.min.js' %}" type="text/javascript" language="javascript"></script>
228228
<script src="{% static 'js/jquery-3.5.1.js' %}" type="text/javascript" language="javascript"></script>
229229
<script src="{% static 'js/datatables/dataTables.js' %}" type="text/javascript" language="javascript"></script>
230+
<script type="text/javascript">
231+
if ($.fn.dataTable && $.fn.dataTable.feature && $.fn.dataTable.feature.register && (!$.fn.dataTable.ext.features || !$.fn.dataTable.ext.features.register)) {
232+
$.fn.dataTable.ext.features = $.fn.dataTable.ext.features || {};
233+
$.fn.dataTable.ext.features.register = $.fn.dataTable.feature.register;
234+
}
235+
</script>
230236
<script src="{% static 'js/datatables/dataTables.buttons.min.js' %}" type="text/javascript" language="javascript"></script>
231237
<script src="{% static 'js/datatables/jszip.min.js' %}" type="text/javascript" language="javascript"></script>
232238
<script src="{% static 'js/datatables/buttons.html5.min.js' %}" type="text/javascript" language="javascript"></script>
@@ -275,11 +281,9 @@ <h5 id="changelogLabel" class="inline-flex items-center mb-6 text-xl font-bold t
275281
event.detail.headers['X-CSRFToken'] = '{{ csrf_token }}';
276282
});
277283

278-
// HTMX Re-init Flowbite after swap
284+
// HTMX Re-init Flowbite after swap (removed to prevent duplicate drawer listeners)
279285
document.body.addEventListener('htmx:afterSwap', function(evt) {
280-
if (typeof initFlowbite === 'function') {
281-
initFlowbite();
282-
}
286+
// Only initialize specific components if needed in the future, not global initFlowbite()
283287
});
284288

285289
// Theme toggle logic

orochi/templates/users/user_bookmarks.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@
9393
type: 'get',
9494
dataType: 'json',
9595
beforeSend: function () {
96-
$("#modal-update .modal-content").html('');
96+
$("#orochi-modal-content").html('');
9797
document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex');
9898
row = table.row($(btn).closest('tr')).index();
9999
},
100100
success: function (data) {
101-
$("#modal-update .modal-content").html(data.html_form);
101+
$("#orochi-modal-content").html(data.html_form);
102102
}
103103
});
104104
});

orochi/templates/users/user_rules.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@
339339
dataType: 'json',
340340
beforeSend: function () {
341341
$("#modal-update .modal-dialog").removeClass('modal-xl');
342-
$("#modal-update .modal-content").html('');
342+
$("#orochi-modal-content").html('');
343343
document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex');
344344
},
345345
success: function (data) {
346-
$("#modal-update .modal-content").html(data.html_form);
346+
$("#orochi-modal-content").html(data.html_form);
347347
initUploadFields(document.getElementById("edit-rule"));
348348
}
349349
});
@@ -440,9 +440,9 @@
440440
dataType: 'json',
441441
success: function (data) {
442442
$("#modal-update .modal-dialog").addClass('modal-xl');
443-
$("#modal-update .modal-content").html('');
443+
$("#orochi-modal-content").html('');
444444
document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex');
445-
$("#modal-update .modal-content").html(data.html_form);
445+
$("#orochi-modal-content").html(data.html_form);
446446
},
447447
error: function (data) {
448448
document.getElementById('modal-update').classList.add('hidden'); document.getElementById('modal-update').classList.remove('flex');

orochi/templates/website/index.html

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% block modal %}
55
<div id="modal-update" tabindex="-1" aria-hidden="true" class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full bg-zinc-900/50 dark:bg-zinc-900/80 backdrop-blur-sm">
66
<div class="relative p-4 w-full max-w-2xl max-h-full">
7-
<div class="relative bg-zinc-50 border border-zinc-200 dark:bg-zinc-700 dark:border-zinc-600 rounded-lg shadow-xl border border-zinc-300 dark:border-zinc-600 modal-content">
7+
<div id="orochi-modal-content" class="relative bg-white border border-zinc-200 dark:bg-zinc-800 dark:border-zinc-700 rounded-lg shadow-xl modal-content">
88
</div>
99
</div>
1010
</div>
@@ -26,7 +26,7 @@
2626
<div class="flex space-x-2">
2727
<button id="new-case" type="button" title="New Case" class="text-green-400 border border-green-400 hover:bg-green-500 hover:text-zinc-900 dark:hover:text-white focus:ring-4 focus:outline-none focus:ring-green-800 font-medium rounded-lg text-sm w-8 h-8 flex items-center justify-center transition-colors"
2828
hx-get="{% url 'website:case_create' %}"
29-
hx-target="#modal-update .modal-content"
29+
hx-target="#orochi-modal-content" hx-swap="innerHTML"
3030
onclick="document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex')">
3131
<i class="fa-solid fa-plus"></i>
3232
</button>
@@ -46,13 +46,13 @@
4646
<div class="flex space-x-2">
4747
<button id="new-index" type="button" title="New Dump" class="text-green-400 border border-green-400 hover:bg-green-500 hover:text-zinc-900 dark:hover:text-white focus:ring-4 focus:outline-none focus:ring-green-800 font-medium rounded-lg text-sm w-8 h-8 flex items-center justify-center transition-colors"
4848
hx-get="{% url 'website:index_create' %}"
49-
hx-target="#modal-update .modal-content"
49+
hx-target="#orochi-modal-content" hx-swap="innerHTML"
5050
onclick="document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex')">
5151
<i class="fa-solid fa-plus"></i>
5252
</button>
5353
<button id="new-folder" type="button" title="New Folder" class="text-blue-400 border border-blue-400 hover:bg-blue-500 hover:text-zinc-900 dark:hover:text-white focus:ring-4 focus:outline-none focus:ring-blue-800 font-medium rounded-lg text-sm w-8 h-8 flex items-center justify-center transition-colors"
5454
hx-get="{% url 'website:folder_create' %}"
55-
hx-target="#modal-update .modal-content"
55+
hx-target="#orochi-modal-content" hx-swap="innerHTML"
5656
onclick="document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex')">
5757
<i class="fa-solid fa-folder-plus"></i>
5858
</button>
@@ -133,7 +133,14 @@
133133
document.getElementById('modal-update').classList.add('hidden'); document.getElementById('modal-update').classList.remove('flex');
134134
});
135135
document.body.addEventListener('refreshCases', function(evt) {
136-
htmx.ajax('GET', window.location.href, {target: 'body'});
136+
window.location.reload();
137+
});
138+
document.body.addEventListener('htmx:targetError', function(evt) {
139+
if (evt.detail.target === '#orochi-modal-content' && evt.detail.elt.tagName === 'FORM') {
140+
evt.preventDefault();
141+
} else {
142+
console.error("HTMX targetError detail:", evt.detail);
143+
}
137144
});
138145
document.body.addEventListener('htmx:responseError', function(evt) {
139146
if (evt.detail.xhr.status === 404 && evt.detail.requestConfig.path.includes('/info')) {
@@ -227,19 +234,19 @@ <h4 class="text-xl font-bold text-zinc-900 dark:text-white mb-2">Processing Dump
227234
dataType: 'json',
228235
method: 'get',
229236
beforeSend: function () {
230-
$("#modal-update .modal-content").html('');
237+
$("#orochi-modal-content").html('');
231238
document.getElementById('modal-update').querySelector('.relative').classList.replace('max-w-2xl', 'max-w-7xl');
232239
document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex');
233240
},
234241
success: function (data) {
235242
const el = document.createElement('orochi-json-modal');
236243
el.data = { title: 'VirusTotal Report', data: data };
237-
$("#modal-update .modal-content").empty().append(el);
244+
$("#orochi-modal-content").empty().append(el);
238245
},
239246
error: function (data) {
240247
const el = document.createElement('orochi-json-modal');
241248
el.data = { title: 'VirusTotal Report', data: data.responseJSON };
242-
$("#modal-update .modal-content").empty().append(el);
249+
$("#orochi-modal-content").empty().append(el);
243250
}
244251
});
245252
});
@@ -254,19 +261,19 @@ <h4 class="text-xl font-bold text-zinc-900 dark:text-white mb-2">Processing Dump
254261
dataType: 'json',
255262
method: 'get',
256263
beforeSend: function () {
257-
$("#modal-update .modal-content").html('');
264+
$("#orochi-modal-content").html('');
258265
document.getElementById('modal-update').querySelector('.relative').classList.replace('max-w-2xl', 'max-w-7xl');
259266
document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex');
260267
},
261268
success: function (data) {
262269
const el = document.createElement('orochi-json-modal');
263270
el.data = { title: 'Maxmind Report', data: data };
264-
$("#modal-update .modal-content").empty().append(el);
271+
$("#orochi-modal-content").empty().append(el);
265272
},
266273
error: function (data) {
267274
const el = document.createElement('orochi-json-modal');
268275
el.data = { title: 'Maxmind Report', data: data.responseJSON };
269-
$("#modal-update .modal-content").empty().append(el);
276+
$("#orochi-modal-content").empty().append(el);
270277
}
271278
});
272279
});

orochi/templates/website/list_symbols.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@
111111
dataType: 'json',
112112
beforeSend: function () {
113113
$("#modal-update .modal-dialog").removeClass('modal-xl');
114-
$("#modal-update .modal-content").html('');
114+
$("#orochi-modal-content").html('');
115115
document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex');
116116
},
117117
success: function (data) {
118-
$("#modal-update .modal-content").html(data.html_form);
118+
$("#orochi-modal-content").html(data.html_form);
119119
}
120120
});
121121
});
@@ -128,11 +128,11 @@
128128
dataType: 'json',
129129
beforeSend: function () {
130130
$("#modal-update .modal-dialog").removeClass('modal-xl');
131-
$("#modal-update .modal-content").html('');
131+
$("#orochi-modal-content").html('');
132132
document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex');
133133
},
134134
success: function (data) {
135-
$("#modal-update .modal-content").html(data.html_form);
135+
$("#orochi-modal-content").html(data.html_form);
136136
$("#btn_package_add").prop('disabled', true);
137137
$("#btn_symbol_add").prop('disabled', true);
138138
$("#create_loading").hide();
@@ -158,11 +158,11 @@
158158
dataType: 'json',
159159
beforeSend: function () {
160160
$("#modal-update .modal-dialog").removeClass('modal-xl');
161-
$("#modal-update .modal-content").html('');
161+
$("#orochi-modal-content").html('');
162162
document.getElementById('modal-update').classList.remove('hidden'); document.getElementById('modal-update').classList.add('flex');
163163
},
164164
success: function (data) {
165-
$("#modal-update .modal-content").html(data.html_form);
165+
$("#orochi-modal-content").html(data.html_form);
166166
$("#btn_symbol_add").prop('disabled', true);
167167
initUploadFields(
168168
document.getElementById("symbols-upload-index"),

orochi/templates/website/partial_bookmark_create.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% load custom_tags %}
33

44
<form hx-post="{% url 'website:add_bookmark' %}"
5-
hx-target="#modal-update .modal-content"
5+
hx-target="#orochi-modal-content" hx-swap="innerHTML"
66
id="create-bookmark">
77
{{ form.media }}
88
{% csrf_token %}

orochi/templates/website/partial_case.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{% load widget_tweaks %}
22

3-
<form hx-post="{% url 'website:case_create' %}" hx-target="#modal-update .modal-content" id="create-case">
3+
<form hx-post="{{ url }}" hx-target="#orochi-modal-content" hx-swap="innerHTML" id="create-case">
44
{{ form.media }}
55
{% csrf_token %}
66

77
<!-- Modal header -->
88
<div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t border-zinc-300 dark:border-zinc-600">
9-
<h3 class="text-xl font-semibold text-zinc-900 dark:text-white">Create a new case</h3>
9+
<h3 class="text-xl font-semibold text-zinc-900 dark:text-white">
10+
{% if form.instance.pk %}Edit Case{% else %}Create a new case{% endif %}
11+
</h3>
1012
<button type="button" class="text-zinc-600 dark:text-zinc-300 bg-transparent hover:bg-zinc-100 dark:hover:bg-zinc-600 hover:text-zinc-900 dark:hover:text-white rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center" onclick="document.getElementById('modal-update').classList.add('hidden'); document.getElementById('modal-update').classList.remove('flex')">
1113
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
1214
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
@@ -19,8 +21,15 @@ <h3 class="text-xl font-semibold text-zinc-900 dark:text-white">Create a new cas
1921
<div class="p-4 md:p-5 space-y-4">
2022
{% for field in form.visible_fields %}
2123
<div class="mb-4 {% if field.errors %} has-error{% endif %}">
24+
{% if field|widget_type == 'checkboxinput' %}
25+
<div class="flex items-center">
26+
{% render_field field class="w-4 h-4 text-blue-600 bg-zinc-100 dark:bg-zinc-600 border border-zinc-300 dark:border-zinc-500 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-zinc-800 focus:ring-2" %}
27+
<label for="{{ field.id_for_label }}" class="ms-2 text-sm font-medium text-zinc-900 dark:text-white">{{ field.label }}</label>
28+
</div>
29+
{% else %}
2230
<label for="{{ field.id_for_label }}" class="block mb-2 text-sm font-medium text-zinc-900 dark:text-white">{{ field.label }}</label>
2331
{% render_field field class="bg-zinc-100 dark:bg-zinc-600 border border-zinc-400 dark:border-zinc-500 text-zinc-900 dark:text-white text-sm rounded-lg focus:ring-zinc-600 dark:focus:ring-zinc-400 focus:border-zinc-400 block w-full p-2.5" %}
32+
{% endif %}
2433
{% for error in field.errors %}
2534
<p class="mt-2 text-sm text-red-500">{{ error }}</p>
2635
{% endfor %}
@@ -39,8 +48,8 @@ <h3 class="text-xl font-semibold text-zinc-900 dark:text-white">Create a new cas
3948

4049
<!-- Modal footer -->
4150
<div class="flex items-center justify-end p-4 md:p-5 border-t border-zinc-300 dark:border-zinc-600 rounded-b">
42-
<button onclick="document.getElementById('modal-update').classList.add('hidden'); document.getElementById('modal-update').classList.remove('flex')" type="button" class="py-2.5 px-5 ms-3 text-sm font-medium text-zinc-800 dark:text-zinc-200 focus:outline-none bg-zinc-50 border border-zinc-200 dark:bg-zinc-700 dark:border-zinc-600 rounded-lg border border-zinc-400 dark:border-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-600 hover:text-zinc-900 dark:hover:text-white focus:z-10 focus:ring-4 focus:ring-zinc-600">Close</button>
43-
<button type="submit" class="text-zinc-900 dark:text-white bg-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-600 focus:ring-4 focus:outline-none focus:ring-zinc-300 dark:focus:ring-zinc-700 font-medium rounded-lg text-sm px-5 py-2.5 text-center ms-3">Create Case</button>
51+
<button onclick="document.getElementById('modal-update').classList.add('hidden'); document.getElementById('modal-update').classList.remove('flex')" type="button" class="py-2.5 px-5 ms-3 text-sm font-medium text-zinc-800 dark:text-zinc-200 focus:outline-none bg-white border border-zinc-300 dark:bg-zinc-700 dark:border-zinc-600 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-600 hover:text-zinc-900 dark:hover:text-white focus:z-10 focus:ring-4 focus:ring-zinc-600">Close</button>
52+
<button type="submit" class="text-zinc-900 dark:text-white bg-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-600 focus:ring-4 focus:outline-none focus:ring-zinc-300 dark:focus:ring-zinc-700 font-medium rounded-lg text-sm px-5 py-2.5 text-center ms-3">{% if form.instance.pk %}Update Case{% else %}Create Case{% endif %}</button>
4453
</div>
4554
</form>
4655

0 commit comments

Comments
 (0)