Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

126/search-s3 #134

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion mod_app/prod-dump-12102024.json

This file was deleted.

5 changes: 5 additions & 0 deletions mod_app/static/css/s3-browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ main {

.s3-browser__title {
text-align: center;
margin-bottom: 1rem;
p {
font-size: 90%;
font-weight: 600;
Expand Down Expand Up @@ -65,6 +66,10 @@ main {
}
}

#searchInput {
height: 1.3rem;
}

.s3-browser__filter__button {
background-color: white;
border-color: inherit;
Expand Down
17 changes: 17 additions & 0 deletions mod_app/static/js/bucketItemSelectorFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,20 @@ function filterBy(elemType) {
}
});
}

function searchByText(searchTerm) {
const cardWrappers = document.querySelectorAll(".s3-browser__card__wrapper");
cardWrappers.forEach((wrapper) => {
const pTagContent = wrapper.querySelector("p")
? wrapper.querySelector("p").textContent
: "";
if (
searchTerm === "" ||
pTagContent.toLowerCase().includes(searchTerm.toLowerCase())
) {
wrapper.classList.remove("no-display");
} else {
wrapper.classList.add("no-display");
}
});
}
15 changes: 13 additions & 2 deletions mod_app/templates/bucket_items.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ <h3 class="center-text"> You are currently viewing items in the S3 bucket</h3>
<span class="btn s3-browser__filter__button" onclick="filterBy" data-type="video" id="key--video">Video</span>/
<span onclick="filterBy" class="btn s3-browser__filter__button" data-type="img" id="key--img">Image</span>/
<span onclick="filterBy" class="btn s3-browser__filter__button" data-type="none" id="view-all">View all</span>


</p>
<div class="search-container">
<input type="text" id="searchInput" placeholder="Start typing to search...">
<button onclick="handleSearch()" class="btn">Search</button>
</div>
</div>
<div class="s3-browser__wrapper">
{% for item_key, item_value in item_data.items.items %}
Expand Down Expand Up @@ -98,6 +100,15 @@ <h3 class="center-text"> You are currently viewing items in the S3 bucket</h3>
this.classList.toggle("active");

});
// search stuff
function handleSearch() {
const searchTerm = document.getElementById('searchInput').value;
searchByText(searchTerm);
};

document.getElementById('searchInput').addEventListener('input', () => {
handleSearch();
});
</script>
</body>
{% endblock %}
Loading