Changeset 7f36551 in Git
- Timestamp:
- 02/06/22 22:56:26 (3 years ago)
- Branches:
- main
- Children:
- 3c0f9a9, ad4243e
- Parents:
- 42d565b
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/LoggedUser.java
r42d565b r7f36551 18 18 return null; 19 19 } 20 20 21 } -
src/main/java/com/wediscussmovies/project/model/Movie.java
r42d565b r7f36551 40 40 @OneToMany(mappedBy = "movie", fetch = FetchType.LAZY) 41 41 private Collection<MovieActors> actors; 42 @OneToMany(mappedBy = "movie" )42 @OneToMany(mappedBy = "movie", fetch = FetchType.LAZY) 43 43 private Collection<MovieGenres> genres; 44 44 @OneToMany(mappedBy = "movie") -
src/main/java/com/wediscussmovies/project/web/controller/MovieController.java
r42d565b r7f36551 8 8 import com.wediscussmovies.project.service.MovieService; 9 9 import com.wediscussmovies.project.service.PersonService; 10 import com.wediscussmovies.project.web.DesignFrontMovies; 10 11 import lombok.Data; 11 12 import org.springframework.format.annotation.DateTimeFormat; … … 47 48 } 48 49 49 Authentication auth = SecurityContextHolder.getContext().getAuthentication();50 addModelPropertiesForUser(model); 50 51 51 if (!(auth instanceof AnonymousAuthenticationToken)){52 UserDetails userDetails = (UserDetails) auth.getPrincipal();53 User user = (User) userDetails;54 model.addAttribute("likedMovies",this.movieService.findLikedMoviesByUser(user));55 model.addAttribute("user",user);56 }57 List<Movie> movieList = movies;58 52 List<List<Movie>> movie_rows = new ArrayList<>(); 59 for(int i=0; i<movieList.size(); i+=4){ 60 int j = i+4; 61 if(j>movieList.size()) 62 j=movieList.size(); 63 movie_rows.add(movieList.subList(i, j)); 64 } 53 DesignFrontMovies.designMovieList(movies,movie_rows); 65 54 model.addAttribute("movies", movies); 66 55 model.addAttribute("movie_rows", movie_rows); … … 74 63 public String getMovie(@PathVariable Integer id, Model model){ 75 64 model.addAttribute("movie", movieService.findById(id)); 76 77 Authentication auth = SecurityContextHolder.getContext().getAuthentication(); 78 if (!(auth instanceof AnonymousAuthenticationToken)){ 79 UserDetails userDetails = (UserDetails) auth.getPrincipal(); 80 User user = (User) userDetails; 81 model.addAttribute("likedMovies",this.movieService.findLikedMoviesByUser(user)); 82 model.addAttribute("user",user); 83 } 84 65 addModelPropertiesForUser(model); 85 66 model.addAttribute("contentTemplate", "movieShow"); 86 67 return "template"; … … 184 165 model.addAttribute("genres", genreService.findAll()); 185 166 } 167 private void addModelPropertiesForUser(Model model){ 168 User user = LoggedUser.getLoggedUser(); 169 model.addAttribute("likedMovies",this.movieService.findLikedMoviesByUser(user)); 170 model.addAttribute("user",user); 171 } 172 186 173 } -
src/main/java/com/wediscussmovies/project/web/controller/UsersController.java
r42d565b r7f36551 8 8 import com.wediscussmovies.project.service.MovieService; 9 9 import com.wediscussmovies.project.service.UserService; 10 import com.wediscussmovies.project.web.DesignFrontMovies; 10 11 import org.springframework.stereotype.Controller; 11 12 import org.springframework.ui.Model; … … 65 66 List<Movie> movieList = this.movieService.findLikedMoviesByUser(LoggedUser.getLoggedUser()); 66 67 List<List<Movie>> movie_rows = new ArrayList<>(); 67 for(int i=0; i<movieList.size(); i+=4){ 68 int j = i+4; 69 if(j>movieList.size()) 70 j= movieList.size(); 71 movie_rows.add(movieList.subList(i, j)); 72 } 68 DesignFrontMovies.designMovieList(movieList,movie_rows); 73 69 model.addAttribute("movie_rows", movie_rows); 74 70 model.addAttribute("contentTemplate","favoriteList"); -
src/main/resources/static/js/sharedScript.js
r42d565b r7f36551 39 39 $(".search-button-title").on("click",function (){ 40 40 let filter = $("#searchTitle").val() 41 console.log(elements) 41 42 for (let item of elements){ 42 let title = item.cells[0].innerText43 let title = $(item).find(".card-title").text() 43 44 if (title.toLowerCase() === filter.toLowerCase()){ 45 console.log("Da") 44 46 $(item).css("display","block") 45 47 } … … 54 56 $(".search-button").on("click",function () { 55 57 let filter = $("#searchGenre").val() 56 for (let item of elements) { 57 let genre = item.cells[4].children; 58 console.log(elements) 59 60 for (let item of elements) { 61 let genre = $(item).find(".card-genre") 58 62 let visible = false; 59 63 60 for ( g of genre) {64 for (let g of genre) { 61 65 62 66 if ($(g).text().toLowerCase() === filter.toLowerCase()) { -
src/main/resources/templates/moviesList.html
r42d565b r7f36551 12 12 <div class="container mb-4"> 13 13 <div class="row" th:each="row: ${movie_rows}" > 14 <div class="col-md-3 " th:each="movie: ${row}" >14 <div class="col-md-3 elements" th:each="movie: ${row}" > 15 15 <div class="card-body card bg-image" th:style="'background:url(' + ${movie.getImageUrl()} + ') no-repeat center #eee;'"> 16 16 <a class="card-text-center" style="color: white" th:href="@{'/movies/{id}' (id=${movie.getMovieId()})}" > 17 17 <h3 class="card-title title" th:text="${movie.getTitle()}"></h3> 18 <span th:each="genre: ${movie.getGenres()}" th:text="${genre?.getGenre()?.getGenreType()}" hidden class="card-genre"></span> 19 18 20 </a> 19 21 <h3 class="card-text bottom" th:text="${'Rated '+movie.getImdbRating()}"></h3> -
target/classes/static/css/shared.css
r42d565b r7f36551 40 40 transition: 400ms; 41 41 color:black; 42 -webkit-text-stroke-color: gray;42 -webkit-text-stroke-color: white; 43 43 } 44 44 -
target/classes/static/js/sharedScript.js
r42d565b r7f36551 39 39 $(".search-button-title").on("click",function (){ 40 40 let filter = $("#searchTitle").val() 41 console.log(elements) 41 42 for (let item of elements){ 42 let title = item.cells[0].innerText43 let title = $(item).find(".card-title").text() 43 44 if (title.toLowerCase() === filter.toLowerCase()){ 45 console.log("Da") 44 46 $(item).css("display","block") 45 47 } … … 54 56 $(".search-button").on("click",function () { 55 57 let filter = $("#searchGenre").val() 56 for (let item of elements) { 57 let genre = item.cells[4].children; 58 console.log(elements) 59 60 for (let item of elements) { 61 let genre = $(item).find(".card-genre") 58 62 let visible = false; 59 63 60 for ( g of genre) {64 for (let g of genre) { 61 65 62 66 if ($(g).text().toLowerCase() === filter.toLowerCase()) { -
target/classes/templates/moviesList.html
r42d565b r7f36551 12 12 <div class="container mb-4"> 13 13 <div class="row" th:each="row: ${movie_rows}" > 14 <div class="col-md-3 " th:each="movie: ${row}" >14 <div class="col-md-3 elements" th:each="movie: ${row}" > 15 15 <div class="card-body card bg-image" th:style="'background:url(' + ${movie.getImageUrl()} + ') no-repeat center #eee;'"> 16 16 <a class="card-text-center" style="color: white" th:href="@{'/movies/{id}' (id=${movie.getMovieId()})}" > 17 17 <h3 class="card-title title" th:text="${movie.getTitle()}"></h3> 18 <span th:each="genre: ${movie.getGenres()}" th:text="${genre?.getGenre()?.getGenreType()}" hidden class="card-genre"></span> 19 18 20 </a> 19 21 <h3 class="card-text bottom" th:text="${'Rated '+movie.getImdbRating()}"></h3>
Note:
See TracChangeset
for help on using the changeset viewer.