Skip to content

Commit

Permalink
Add filters javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
jordandoig committed Jun 4, 2020
1 parent 3061756 commit eb21b03
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/dashboard/assets/js/filter.js
@@ -0,0 +1,22 @@
$(function () {

// Check selected namespace options on page load
const urlParams = new URLSearchParams(window.location.search);
const currentNamespaces = urlParams.getAll('ns');
currentNamespaces.forEach(ns => {
$(`input#namespace-${ns}`).prop('checked', true);
});

// Handle new filter submissions
$('#namespaceFiltersForm').on('submit', e => {
e.preventDefault();
let newParams = new URLSearchParams();
$('#namespaceFiltersForm input[type="checkbox"]').each((index, checkbox) => {
if (checkbox.checked) {
newParams.append('ns', checkbox.name);
}
});
window.location = new URL(`?${newParams.toString()}`, window.location).toString();
});
});

0 comments on commit eb21b03

Please sign in to comment.