-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from CodeURJC-DAW-2022-23/feat/search-bar
feat: search bar
- Loading branch information
Showing
17 changed files
with
317 additions
and
48 deletions.
There are no files selected for viewing
14 changes: 13 additions & 1 deletion
14
back/src/main/java/net/daw/alist/controllers/AdminPanelController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 12 additions & 2 deletions
14
back/src/main/java/net/daw/alist/controllers/TopListController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,43 @@ | ||
package net.daw.alist.utils; | ||
|
||
import net.daw.alist.models.Post; | ||
import net.daw.alist.models.User; | ||
import net.daw.alist.services.PostService; | ||
import net.daw.alist.services.UserService; | ||
import org.hibernate.engine.jdbc.BlobProxy; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.ui.Model; | ||
|
||
import javax.sql.rowset.serial.SerialBlob; | ||
import java.io.IOException; | ||
import java.sql.Blob; | ||
import java.sql.SQLException; | ||
import java.util.List; | ||
|
||
public class Utils { | ||
public Utils(UserService userService, PostService postService) { | ||
this.userService = userService; | ||
this.postService = postService; | ||
} | ||
|
||
@Autowired | ||
private UserService userService; | ||
@Autowired | ||
private PostService postService; | ||
|
||
public static Blob pathToImage(String path) throws IOException, SQLException { | ||
if (path == null) return null; | ||
Resource image = new ClassPathResource(path); | ||
Blob blob = BlobProxy.generateProxy(image.getInputStream(), image.contentLength()); | ||
return new SerialBlob(blob); | ||
} | ||
public void searchBarInitializer(Model model){ | ||
List<User> userList = userService.findAll(); | ||
model.addAttribute("searchSuggestedUsers", userList); | ||
List<Post> postList = postService.findAll(); | ||
model.addAttribute("searchSuggestedPosts", postList); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
var url = window.location.href; | ||
var signOutButton = document.getElementById("sign-out"); | ||
const profile = document.getElementsByClassName("profileNavIcon"); | ||
const heart = document.getElementsByClassName("heartNavIcon"); | ||
const compass = document.getElementsByClassName("compassNavIcon"); | ||
|
||
|
||
if(url.includes("/user/") && (signOutButton != null && signOutButton.value =='')){ | ||
profile[0].innerHTML = "<i class=\"fa-solid fa-user fa-xl\"></i>"; | ||
profile[1].innerHTML = "<i class=\"fa-solid fa-user fa-xl\"></i>"; | ||
} else if(url.includes("/followed-users/")){ | ||
heart[0].innerHTML = "<i class=\"fa-solid fa-heart fa-xl\"></i>"; | ||
heart[1].innerHTML = "<i class=\"fa-solid fa-heart fa-xl\"></i>"; | ||
} else if(url.includes("/admin-panel") || url.includes("/top-list/") || url.includes("/user/")){ | ||
} else{ | ||
compass[0].innerHTML = "<i class=\"fa-solid fa-compass fa-xl\"></i>"; | ||
compass[1].innerHTML = "<i class=\"fa-solid fa-compass fa-xl\"></i>"; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const searchInputs = document.getElementsByClassName("searchBar"); | ||
|
||
const cards = document.getElementsByClassName("card"); | ||
const usernames = document.getElementsByClassName("header"); | ||
const postTitles = document.getElementsByClassName("body"); | ||
|
||
function filterSuggestions(searchInput){ | ||
searchInput.addEventListener("input", e => { | ||
const value = e.target.value.toLowerCase(); | ||
for (let i = 0; i < cards.length; i++) { | ||
const isVisible = usernames[i].textContent.toLowerCase().includes(value) || | ||
postTitles[i].textContent.toLowerCase().includes(value); | ||
cards[i].classList.toggle("hide", !isVisible); | ||
} | ||
}) | ||
} | ||
|
||
filterSuggestions(searchInputs[0]) | ||
filterSuggestions(searchInputs[1]) | ||
|
||
function hideContainer() { | ||
//[0]: desktop div [1]: mobile div | ||
//hide suggestion box | ||
document.getElementsByClassName("autoCompleteBox")[0].style.visibility = "hidden"; | ||
document.getElementsByClassName("autoCompleteBox")[1].style.visibility = "hidden"; | ||
|
||
//add border bottom radius | ||
document.getElementsByClassName("searchBar")[0].style.borderBottomLeftRadius = "10px"; | ||
document.getElementsByClassName("searchBar")[1].style.borderBottomLeftRadius = "10px"; | ||
document.getElementsByClassName("searchWrapper")[0].style.borderBottomRightRadius = "10px"; | ||
document.getElementsByClassName("searchWrapper")[1].style.borderBottomRightRadius = "10px"; | ||
} | ||
|
||
function showContainer() { | ||
//[0]: desktop div [1]: mobile div | ||
//reveal suggestion box | ||
document.getElementsByClassName("autoCompleteBox")[0].style.visibility = "visible"; | ||
document.getElementsByClassName("autoCompleteBox")[1].style.visibility = "visible"; | ||
|
||
//remove border bottom radius | ||
document.getElementsByClassName("searchBar")[0].style.borderBottomLeftRadius = "0px"; | ||
document.getElementsByClassName("searchBar")[1].style.borderBottomLeftRadius = "0px"; | ||
document.getElementsByClassName("searchWrapper")[0].style.borderBottomRightRadius = "0px"; | ||
document.getElementsByClassName("searchWrapper")[1].style.borderBottomRightRadius = "0px"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.