Skip to content

Commit 6fb15f4

Browse files
committed
fix sw inventory filter
1 parent fe8b555 commit 6fb15f4

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

comp/core/gui/guiimpl/views/private/js/javascript.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,25 @@ $(document).on('click', '.load_more', function (e) {
251251
loadMore();
252252
});
253253

254+
// Delegate change handler for software inventory filter (works after DOMPurify sanitization)
255+
$(document).on('change', '#sw-type-filter', function () {
256+
var type = this.value;
257+
var entries = document.querySelectorAll('.sw-entry');
258+
var visibleCount = 0;
259+
entries.forEach(function(entry) {
260+
if (type === '' || entry.getAttribute('data-sw-type') === type) {
261+
entry.style.display = '';
262+
visibleCount++;
263+
} else {
264+
entry.style.display = 'none';
265+
}
266+
});
267+
var countSpan = document.getElementById('sw-filter-count');
268+
if (countSpan) {
269+
countSpan.textContent = type !== '' ? 'Showing ' + visibleCount + ' entries' : '';
270+
}
271+
});
272+
254273
// Handler for loading more lines of the currently displayed log file
255274
function loadMore() {
256275
var data = $(".log_data").html();

comp/softwareinventory/impl/status_templates/inventoryHTML.tmpl

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020
<div style="margin-bottom: 1em;">
2121
<label for="sw-type-filter"><strong>Filter by type:</strong></label>
22-
<select id="sw-type-filter" onchange="filterSoftwareByType(this.value)" style="margin-left: 0.5em; padding: 0.25em 0.5em; border-radius: 4px; border: 1px solid #ccc;">
22+
<select id="sw-type-filter" style="margin-left: 0.5em; padding: 0.25em 0.5em; border-radius: 4px; border: 1px solid #ccc;">
2323
<option value="">All ({{ $total }})</option>
2424
{{- range $type, $count := $stats }}
2525
<option value="{{ $type }}">{{ $type }} ({{ $count }})</option>
@@ -53,25 +53,5 @@
5353
</details>
5454
{{- end }}
5555
</div>
56-
<script>
57-
function filterSoftwareByType(type) {
58-
var entries = document.querySelectorAll('.sw-entry');
59-
var visibleCount = 0;
60-
entries.forEach(function(entry) {
61-
if (type === '' || entry.getAttribute('data-sw-type') === type) {
62-
entry.style.display = '';
63-
visibleCount++;
64-
} else {
65-
entry.style.display = 'none';
66-
}
67-
});
68-
var countSpan = document.getElementById('sw-filter-count');
69-
if (type !== '') {
70-
countSpan.textContent = 'Showing ' + visibleCount + ' entries';
71-
} else {
72-
countSpan.textContent = '';
73-
}
74-
}
75-
</script>
7656
{{- end }}
7757
</div>

0 commit comments

Comments
 (0)