Changes in / [ad4243e:7f36551] in Git
- Files:
-
- 10 deleted
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/model/primarykeys/UserGenresPK.java
rad4243e r7f36551 1 1 package com.wediscussmovies.project.model.primarykeys; 2 3 import lombok.Data;4 2 5 3 import javax.persistence.Column; … … 8 6 import java.io.Serializable; 9 7 10 @Data11 8 @Embeddable 12 9 public class UserGenresPK implements Serializable { … … 33 30 UserGenresPK that = (UserGenresPK) o; 34 31 32 33 35 34 return userId == that.userId && genreId == that.genreId; 36 35 } -
src/main/java/com/wediscussmovies/project/querymodels/GenreLikes.java
rad4243e r7f36551 3 3 import lombok.Data; 4 4 5 import javax.persistence.Entity;6 import javax.persistence.Table;7 import java.util.Comparator;8 import java.util.Objects;9 10 5 @Data 11 6 public class GenreLikes { 12 private Integer genreId; 7 13 8 private String name; 14 9 private Long likes; 15 10 16 public static Comparator<GenreLikes> sorter = Comparator.comparing(GenreLikes::getLikes).thenComparing(GenreLikes::getName).reversed(); 17 18 public GenreLikes(Integer genreId, String name, Long likes) { 19 this.genreId = genreId; 11 public GenreLikes(String name, Long likes) { 20 12 this.name = name; 21 13 this.likes = likes; 22 23 }24 25 @Override26 public boolean equals(Object o) {27 if (this == o) return true;28 if (o == null || getClass() != o.getClass()) return false;29 GenreLikes that = (GenreLikes) o;30 return Objects.equals(genreId, that.genreId);31 }32 33 @Override34 public int hashCode() {35 return Objects.hash(genreId);36 14 } 37 15 } -
src/main/java/com/wediscussmovies/project/repository/GenreRepository.java
rad4243e r7f36551 4 4 import com.wediscussmovies.project.querymodels.GenreLikes; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.data.jpa.repository.Modifying;7 6 import org.springframework.data.jpa.repository.Query; 8 import org.springframework.data.repository.query.Param;9 7 import org.springframework.stereotype.Repository; 10 8 11 9 import javax.transaction.Transactional; 12 import java.sql.Date;13 10 import java.util.List; 14 11 … … 17 14 List<Genre> findAllByGenreType(String genre); 18 15 19 @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes(g.genre Id, g.genreType, count(ug.id.userId)) from Genre g" +16 @Query(value = "select new com.wediscussmovies.project.querymodels.GenreLikes(g.genreType, count(ug.id.userId)) from Genre g" + 20 17 " left join UserGenres ug on ug.id.genreId = g.genreId" + 21 " group by g.genre Id, g.genreType" +18 " group by g.genreType" + 22 19 " order by count(ug.id.userId) desc") 23 20 @Transactional 24 21 List<GenreLikes> findAllWithLikes(); 25 26 @Modifying27 @Query(value = "insert into project.user_genres (user_id,genre_id) values(:user_id,:genre_id)",nativeQuery = true)28 @Transactional29 void insertInto(@Param("user_id")Integer userId, @Param("genre_id")Integer genreId);30 22 } -
src/main/java/com/wediscussmovies/project/repository/MovieRepository.java
rad4243e r7f36551 4 4 import com.wediscussmovies.project.model.Person; 5 5 import org.springframework.data.jpa.repository.JpaRepository; 6 import org.springframework.data.jpa.repository.Query;7 6 import org.springframework.stereotype.Repository; 8 7 … … 14 13 List<Movie> findAllByDirector(Person director); 15 14 List<Movie> findAllByDirectorIsNull(); 16 @Query(value="select m.movieId from Movie m")17 List<Integer> findAllMovieIds();18 15 } -
src/main/java/com/wediscussmovies/project/service/GenreService.java
rad4243e r7f36551 14 14 Genre save(String genreName); 15 15 List<GenreLikes> findAllWithLikes(); 16 void likeGenre(Integer genreId,Integer userId);17 void unlikeGenre(Integer genreId,Integer userId);18 16 19 17 } -
src/main/java/com/wediscussmovies/project/service/MovieService.java
rad4243e r7f36551 6 6 import com.wediscussmovies.project.model.Person; 7 7 import com.wediscussmovies.project.model.User; 8 import org.springframework.data.jpa.repository.Query;9 8 10 9 import java.sql.Date; … … 17 16 List<Movie> searchByTitle(String title); 18 17 Movie findById(Integer id); 19 List<Integer> listAllIds();20 18 Movie save(String title, String description, String imageUrl, Date airingDate,Double rating, 21 19 Integer directorId,List<Integer> actorIds,List<Integer> genreIds); -
src/main/java/com/wediscussmovies/project/service/PersonService.java
rad4243e r7f36551 5 5 import com.wediscussmovies.project.model.Person; 6 6 import com.wediscussmovies.project.model.User; 7 import com.wediscussmovies.project.model.relation.MovieLikes;8 7 9 8 import java.sql.Date; 10 9 import java.util.List; 11 import java.util.stream.Collectors;12 10 13 11 public interface PersonService { … … 29 27 void deleteById(Integer id); 30 28 void addGradePerson(Integer personId, User user, Grade grade); 29 31 30 } -
src/main/java/com/wediscussmovies/project/service/impl/GenreServiceImpl.java
rad4243e r7f36551 1 1 package com.wediscussmovies.project.service.impl; 2 2 3 import com.wediscussmovies.project.model.User;4 3 import com.wediscussmovies.project.model.exception.GenreNotExistException; 5 import com.wediscussmovies.project.model.exception.UserNotExistException;6 import com.wediscussmovies.project.model.primarykeys.GenreLikesPK;7 import com.wediscussmovies.project.model.primarykeys.UserGenresPK;8 import com.wediscussmovies.project.model.relation.MovieLikes;9 import com.wediscussmovies.project.model.relation.UserGenres;10 4 import com.wediscussmovies.project.querymodels.GenreLikes; 11 import com.wediscussmovies.project.repository.GenreLikesRepository;12 5 import com.wediscussmovies.project.repository.GenreRepository; 13 6 import com.wediscussmovies.project.model.Genre; 14 import com.wediscussmovies.project.repository.UserRepository;15 7 import com.wediscussmovies.project.service.GenreService; 16 8 import org.springframework.stereotype.Service; … … 21 13 public class GenreServiceImpl implements GenreService { 22 14 private final GenreRepository genreRepository; 23 private final UserRepository userRepository;24 private final GenreLikesRepository genreLikesRepository;25 15 26 27 public GenreServiceImpl(GenreRepository genreRepository, UserRepository userRepository, GenreLikesRepository genreLikesRepository) { 16 public GenreServiceImpl(GenreRepository genreRepository) { 28 17 this.genreRepository = genreRepository; 29 this.userRepository = userRepository;30 this.genreLikesRepository = genreLikesRepository;31 18 } 32 19 … … 49 36 @Override 50 37 public List<GenreLikes> findAllWithLikes() { 51 List<GenreLikes> genreLikesList = this.genreRepository.findAllWithLikes(); 52 genreLikesList.sort(GenreLikes.sorter); 53 return genreLikesList; 38 return this.genreRepository.findAllWithLikes(); 54 39 } 55 40 … … 58 43 return this.genreRepository.findAll(); 59 44 } 60 61 @Override62 public void likeGenre(Integer genreId, Integer userId) {63 User user = this.userRepository.findById(userId).orElseThrow(() -> new UserNotExistException(userId.toString()));64 Genre genre = this.genreRepository.findById(genreId).orElseThrow(() -> new GenreNotExistException(genreId));65 this.genreLikesRepository.save(new UserGenres(genre, user));66 }67 68 @Override69 public void unlikeGenre(Integer genreId, Integer userId) {70 UserGenresPK movieLikesPK = new UserGenresPK(userId, genreId);71 this.genreLikesRepository.deleteById(movieLikesPK);72 }73 45 } -
src/main/java/com/wediscussmovies/project/service/impl/MovieServiceImpl.java
rad4243e r7f36551 76 76 77 77 @Override 78 public List<Integer> listAllIds() {79 return this.movieRepository.findAllMovieIds();80 }81 82 @Override83 78 @Transactional 84 79 public Movie save(String title, String description, String imageUrl, -
src/main/java/com/wediscussmovies/project/service/impl/PersonServiceImpl.java
rad4243e r7f36551 9 9 import com.wediscussmovies.project.model.primarykeys.PersonRatesPK; 10 10 import com.wediscussmovies.project.model.relation.MovieActors; 11 import com.wediscussmovies.project.model.relation.MovieRates; 11 12 import com.wediscussmovies.project.model.relation.PersonRates; 12 import com.wediscussmovies.project.repository.*; 13 import com.wediscussmovies.project.repository.MovieActorsRepository; 14 import com.wediscussmovies.project.repository.MovieRepository; 15 import com.wediscussmovies.project.repository.PersonRatesRepository; 16 import com.wediscussmovies.project.repository.PersonRepository; 13 17 import com.wediscussmovies.project.model.Person; 14 18 import com.wediscussmovies.project.service.PersonService; … … 28 32 private final MovieActorsRepository movieActorsRepository; 29 33 private final PersonRatesRepository personRatesRepository; 34 30 35 31 36 public PersonServiceImpl(PersonRepository personRepository, … … 151 156 152 157 153 154 155 158 private void addActorForMovies(Person person, List<Integer> movieIds){ 156 159 -
src/main/java/com/wediscussmovies/project/web/controller/GenreController.java
rad4243e r7f36551 1 1 package com.wediscussmovies.project.web.controller; 2 2 3 import com.wediscussmovies.project.LoggedUser;4 import com.wediscussmovies.project.model.Genre;5 import com.wediscussmovies.project.model.User;6 import com.wediscussmovies.project.model.relation.UserGenres;7 import com.wediscussmovies.project.querymodels.GenreLikes;8 import com.wediscussmovies.project.repository.GenreLikesRepository;9 3 import com.wediscussmovies.project.service.GenreService; 10 4 import org.springframework.stereotype.Controller; … … 13 7 import org.springframework.web.bind.annotation.RequestMapping; 14 8 15 import java.util.ArrayList;16 import java.util.List;17 18 9 @Controller 19 10 @RequestMapping("/genres") 20 11 public class GenreController { 21 12 private final GenreService genreService; 22 private final GenreLikesRepository genreLikesRepository;23 13 24 public GenreController(GenreService genreService , GenreLikesRepository genreLikesRepository) {14 public GenreController(GenreService genreService) { 25 15 this.genreService = genreService; 26 this.genreLikesRepository = genreLikesRepository;27 16 } 28 17 @GetMapping 29 18 public String getGenres(Model model){ 30 19 model.addAttribute("genres",genreService.findAllWithLikes()); 31 model.addAttribute("allGenres", genreService.findAll());32 20 model.addAttribute("contentTemplate","genres"); 33 addModelPropertiesForUser(model);34 21 return "template"; 35 22 } 36 37 private void addModelPropertiesForUser(Model model){38 User user = LoggedUser.getLoggedUser();39 List<UserGenres> genreLikesList = this.genreLikesRepository.findAllByUser(user);40 List<Genre> genres = new ArrayList<>();41 for(UserGenres g: genreLikesList){42 genres.add(genreService.findById(g.getId().getGenreId()));43 }44 model.addAttribute("likedGenres",genres);45 model.addAttribute("user",user);46 }47 23 } -
src/main/java/com/wediscussmovies/project/web/controller/MovieController.java
rad4243e r7f36551 9 9 import com.wediscussmovies.project.service.PersonService; 10 10 import com.wediscussmovies.project.web.DesignFrontMovies; 11 import com.wediscussmovies.project.web.PageFrontMovies;12 11 import lombok.Data; 13 12 import org.springframework.format.annotation.DateTimeFormat; … … 38 37 } 39 38 40 @GetMapping ("/old")39 @GetMapping 41 40 public String getMovies(@RequestParam(required = false) String titleQuery, Model model, 42 41 @RequestParam(required = false) String error){ … … 56 55 model.addAttribute("movie_rows", movie_rows); 57 56 model.addAttribute("contentTemplate", "moviesList"); 58 if (error != null && !error.equals(" "))59 model.addAttribute("error",error);60 return "template";61 }62 63 64 @GetMapping65 public String getMoviesAlternative(@RequestParam(required = false) String titleQuery, Model model,66 @RequestParam(required = false) String error, @RequestParam(required = false) String page){67 if (page==null){68 return "redirect:/movies?page=1";69 }70 addModelPropertiesForUser(model);71 List<Movie> movies = PageFrontMovies.getPagedMovies(page, movieService, model);72 List<List<Movie>> movie_rows = new ArrayList<>();73 DesignFrontMovies.designMovieList(movies,movie_rows);74 model.addAttribute("movies", movies);75 model.addAttribute("movie_rows", movie_rows);76 model.addAttribute("contentTemplate", "moviesListPaged");77 57 if (error != null && !error.equals(" ")) 78 58 model.addAttribute("error",error); … … 180 160 } 181 161 private void addModelProperties(Model model){ 182 model.addAttribute("directors", personService.findAllDirectors()); 162 163 model.addAttribute("directors", personService.findAllDirectors()); 183 164 model.addAttribute("actors", personService.findAllActors()); 184 165 model.addAttribute("genres", genreService.findAll()); … … 188 169 model.addAttribute("likedMovies",this.movieService.findLikedMoviesByUser(user)); 189 170 model.addAttribute("user",user); 190 }171 } 191 172 192 173 } -
src/main/java/com/wediscussmovies/project/web/controller/PersonController.java
rad4243e r7f36551 1 1 package com.wediscussmovies.project.web.controller; 2 2 3 import com.wediscussmovies.project.LoggedUser;4 3 import com.wediscussmovies.project.model.Person; 5 import com.wediscussmovies.project.model.User;6 4 import com.wediscussmovies.project.service.MovieService; 7 5 import com.wediscussmovies.project.service.PersonService; … … 137 135 } 138 136 139 private void addModelPropertiesForUser(Model model){140 User user = LoggedUser.getLoggedUser();141 model.addAttribute("user",user);142 }143 144 137 145 138 } -
src/main/resources/static/css/shared.css
rad4243e r7f36551 70 70 text-align: center; 71 71 } 72 73 #paging-section{74 width: 100%;75 clear: both;76 margin-bottom: 30px;77 }78 79 #inner-paging{80 width: fit-content;81 margin: auto;82 83 }84 85 #button-sub, #button-add{86 width: 100px;87 }88 89 #pageInput{90 font-size: 100%;91 text-align: center;92 width: 175px;93 margin: auto;94 }95 96 #button-submit-page{97 margin: auto;98 text-align: center;99 margin-top: 7px;100 display: none;101 }102 103 .visibility{104 transition: 200ms;105 opacity: 0;106 } -
src/main/resources/static/js/sharedScript.js
rad4243e r7f36551 4 4 var elements = $(".elements") 5 5 var elementGrade; 6 7 8 $("#button-add").on("click", function (){9 itemInput = $("#pageInput")10 itemInput.val(Number(itemInput.val()) + 1);11 $("#button-submit-page").click()12 })13 14 $("#button-sub").on("click", function (){15 itemInput = $("#pageInput")16 if(Number(itemInput.val()) > 1){17 itemInput.val(Number(itemInput.val()) - 1);18 $("#button-submit-page").click()19 }20 })21 22 $("#searchTitle").on("keyup", function() {23 var value = $(this).val().toLowerCase();24 console.log(value)25 $(".elements div a .title").filter(function() {26 console.log($(this).text())27 if($(this).text().toLowerCase().indexOf(value) <= -1)28 $(this).parent().parent().parent().addClass("visibility")29 else30 $(this).parent().parent().parent().removeClass("visibility")31 });32 });33 34 35 6 36 7 … … 66 37 67 38 68 /*$(".search-button-title").on("click",function (){39 $(".search-button-title").on("click",function (){ 69 40 let filter = $("#searchTitle").val() 70 41 console.log(elements) … … 79 50 } 80 51 } 81 })*/ 52 53 }) 82 54 83 55 84 56 $(".search-button").on("click",function () { 85 57 let filter = $("#searchGenre").val() 58 console.log(elements) 59 86 60 for (let item of elements) { 87 61 let genre = $(item).find(".card-genre") … … 90 64 for (let g of genre) { 91 65 92 if ( ( $(g).text().toLowerCase() === filter.toLowerCase() && !$(g).hasClass("visibility") && filter.trim().length != 0)) {66 if ($(g).text().toLowerCase() === filter.toLowerCase()) { 93 67 visible = true 94 $(item). removeClass("visibility")68 $(item).css("display","block") 95 69 break; 96 70 } 97 71 } 98 if (!visible && filter.trim().length != 0) 99 $(item).addClass("visibility") 100 else 101 $(item).removeClass("visibility") 102 72 if (!visible) 73 $(item).css("display","none") 103 74 } 104 75 }); … … 146 117 let url = "api/movies/unlike/"+ $(this).attr("movie-id")+"?userId="+ $(this).attr("user-id") 147 118 ajaxCallLike(url,button,'unlike','Немате оставено допаѓање на филмот!') 148 })149 $(document.body).on("click",".button-add-genre-liked-list",function (){150 let button = $(this)151 let url = "api/genres/like/"+ $(this).attr("genre-id") + "?userId="+ $(this).attr("user-id")152 ajaxCallLikeGenre(url,button,'like','Веќе ви се допаѓа жанрот!')153 })154 $(document.body).on("click",".button-remove-genre-liked-list",function (){155 let button = $(this)156 let url = "api/genres/unlike/"+ $(this).attr("genre-id")+"?userId="+ $(this).attr("user-id")157 ajaxCallLikeGenre(url,button,'unlike','Немате оставено допаѓање на жанрот!')158 119 }) 159 120 $(".discussion-type").change(function (){ … … 196 157 197 158 } 198 $(button).remove()199 159 } 200 160 else { … … 220 180 }) 221 181 } 222 223 224 225 function ajaxCallLikeGenre(url,button,type,message){226 $.ajax({227 url:url,228 success:function (data){229 if (data){230 let el = $(button).parent().siblings().eq(3)231 console.log(el)232 if (type=="like") {233 $(el).html(parseInt($(el).text()) + 1)234 console.log("da")235 }236 else237 $(el).html(parseInt($(el).text()) - 1)238 $(button).css("display","none")239 let userId = $(button).attr("user-id")240 let genreId=$(button).attr("genre-id")241 if (type==='like') {242 $(button).parent().append("<a class='btn btn-danger button-remove-genre-liked-list' genre-id=" + genreId + " user-id=" + userId + ">💔</a>")243 console.log("da")244 }245 else{246 $(button).parent().append("<a class='btn btn-success button-add-genre-liked-list' genre-id=" + genreId + " user-id=" + userId + ">❤</a>")247 }248 let likes_sibling = $("#"+genreId+"genre")249 value_likes = Number(likes_sibling.text())250 if(type=="like")251 value_likes+=1252 else253 value_likes-=1254 likes_sibling.text(value_likes)255 $(button).remove()256 }257 else {258 $(button).parent().append("<div>" + message +" <button class='button-confirm'>Ок</button></div>")259 }260 }261 })262 }263 264 265 182 function ajaxCallRating(url,button,type){ 266 183 model = { -
src/main/resources/templates/genres.html
rad4243e r7f36551 1 <div class="container mb-4" xmlns:sec="http://www.w3.org/1999/xhtml"> 1 <div class="container mb-4"> 2 <div class="row"> 3 <div class="col-12"> 4 <div class="table-responsive"> 5 <table class="table table-striped"> 6 <thead> 7 <tr> 8 <th scope="col">Име</th> 9 <th scope="col">Лајкови</th> 10 </tr> 11 </thead> 12 <tbody> 13 <tr th:each="genre : ${genres}" class="elements"> 14 <td th:text="${genre.getName()}"></td> 15 <td th:text="${genre.getLikes()}"></td> 2 16 3 <div class="row"> 4 <div class="col-12"> 5 <div class="table-responsive"> 6 <table class="table table-striped"> 7 <thead> 8 <tr> 9 <th scope="col">Име</th> 10 <th scope="col">Лајкови</th> 11 </tr> 12 </thead> 13 <tbody> 14 <tr th:each="genre : ${genres}" class="elements"> 15 <td th:text="${genre.getName()}"></td> 16 <td th:text="${genre.getLikes()}" th:id="${genre.getGenreId()+'genre'}"></td> 17 <td> 18 <th:block sec:authorize="isAuthenticated()" th:each="g: ${allGenres}" th:if="${g.getGenreId() == genre.getGenreId()}"> 19 <a class="btn btn-success button-add-genre-liked-list" th:genre-id="${g.getGenreId()}" th:user-id="${user.getUserId()}" th:if="${!likedGenres.contains(g)}">❤</a> 20 <a class="btn btn-danger button-remove-genre-liked-list" th:genre-id="${g.getGenreId()}" th:user-id="${user.getUserId()}" th:if="${likedGenres.contains(g)}">💔</a> 21 </th:block> 22 </td> 23 </tr> 24 </tbody> 25 </table> 26 </div> 17 </tr> 18 </tbody> 19 </table> 27 20 </div> 28 21 </div> 29 22 </div> 30 23 </div> -
src/main/resources/templates/personShow.html
rad4243e r7f36551 30 30 </div> 31 31 </div> 32 <div style="width: 45%; margin: 25px; float:left; background-color: rgb(200,200,200); padding: 10px; border-radius: 5px">33 <h2>34 <span>Бројот на оцени кои филмот ги добил:</span>35 <span th:text="${movie.getRates().size()}"></span>36 </h2>37 <hr>38 <div th:each="rating: ${movie.getRates()}" style="margin-bottom: 10px; border: 2px solid gray; border-radius: 10px; background-color: lightblue; padding: 10px; border-radius: 10px; min-height: 130px;">39 <div style="width: 60%; float:left;">40 <p th:text="${rating.getReason()}" style="text-align: justify"></p>41 </div>42 <div style="width: 30%; float:right; background-color: darkorange; border-radius: 10px 30px; color: whitesmoke; padding: 10px;">43 <h2 style="text-align: center">Rated:</h2>44 <p th:text="${rating.getStarsRated() + ' out of 10 stars'}" style="text-align: center"></p>45 </div>46 </div>47 </div>48 <div style="width: 45%; margin: 25px; float:left; background-color: rgb(200,200,200); padding: 10px; border-radius: 5px">49 <h2>50 <span>Бројот на лајкови кои филмот ги добил:</span>51 <span th:text="${movie.getLikes().size()}"></span>52 </h2>53 <hr>54 <div th:each="liked: ${movie.getLikes()}" style="margin-bottom: 10px; border: 2px solid gray; border-radius: 10px; background-color: lightblue; padding: 10px; border-radius: 10px; min-height: 60px;">55 <div style="width: 100%; float:left;">56 <h3 style="text-align: center">57 <span th:text="${liked.getUser().getName() + ' ' + liked.getUser().getSurname()}"></span>58 <span style="color: green; font-size: 100%" >✔</span>59 </h3>60 </div>61 </div>62 </div>63 32 </div> -
src/main/resources/templates/personsList.html
rad4243e r7f36551 57 57 58 58 </td> 59 60 <a class="bottom-heart btn btn-success button-add-favourite-list"61 th:movie-id="${person.getMovieId()}"62 th:user-id="${user.getUserId()}"63 th:if="${!likedPersons.contains(movie)}">❤</a>64 65 <a class="bottom-heart btn btn-danger button-remove-favourite-list"66 th:movie-id="${person.getMovieId()}" th:user-id="${user.getUserId()}"67 th:if="${likedPersons.contains(movie)}">💔</a>68 69 70 59 </th:block> 71 60 -
target/classes/static/css/shared.css
rad4243e r7f36551 70 70 text-align: center; 71 71 } 72 73 #paging-section{74 width: 100%;75 clear: both;76 margin-bottom: 30px;77 }78 79 #inner-paging{80 width: fit-content;81 margin: auto;82 83 }84 85 #button-sub, #button-add{86 width: 100px;87 }88 89 #pageInput{90 font-size: 100%;91 text-align: center;92 width: 175px;93 margin: auto;94 }95 96 #button-submit-page{97 margin: auto;98 text-align: center;99 margin-top: 7px;100 display: none;101 }102 103 .visibility{104 transition: 200ms;105 opacity: 0;106 } -
target/classes/static/js/sharedScript.js
rad4243e r7f36551 4 4 var elements = $(".elements") 5 5 var elementGrade; 6 7 8 $("#button-add").on("click", function (){9 itemInput = $("#pageInput")10 itemInput.val(Number(itemInput.val()) + 1);11 $("#button-submit-page").click()12 })13 14 $("#button-sub").on("click", function (){15 itemInput = $("#pageInput")16 if(Number(itemInput.val()) > 1){17 itemInput.val(Number(itemInput.val()) - 1);18 $("#button-submit-page").click()19 }20 })21 22 $("#searchTitle").on("keyup", function() {23 var value = $(this).val().toLowerCase();24 console.log(value)25 $(".elements div a .title").filter(function() {26 console.log($(this).text())27 if($(this).text().toLowerCase().indexOf(value) <= -1)28 $(this).parent().parent().parent().addClass("visibility")29 else30 $(this).parent().parent().parent().removeClass("visibility")31 });32 });33 34 35 6 36 7 … … 66 37 67 38 68 /*$(".search-button-title").on("click",function (){39 $(".search-button-title").on("click",function (){ 69 40 let filter = $("#searchTitle").val() 70 41 console.log(elements) … … 79 50 } 80 51 } 81 })*/ 52 53 }) 82 54 83 55 84 56 $(".search-button").on("click",function () { 85 57 let filter = $("#searchGenre").val() 58 console.log(elements) 59 86 60 for (let item of elements) { 87 61 let genre = $(item).find(".card-genre") … … 90 64 for (let g of genre) { 91 65 92 if ( ( $(g).text().toLowerCase() === filter.toLowerCase() && !$(g).hasClass("visibility") && filter.trim().length != 0)) {66 if ($(g).text().toLowerCase() === filter.toLowerCase()) { 93 67 visible = true 94 $(item). removeClass("visibility")68 $(item).css("display","block") 95 69 break; 96 70 } 97 71 } 98 if (!visible && filter.trim().length != 0) 99 $(item).addClass("visibility") 100 else 101 $(item).removeClass("visibility") 102 72 if (!visible) 73 $(item).css("display","none") 103 74 } 104 75 }); … … 146 117 let url = "api/movies/unlike/"+ $(this).attr("movie-id")+"?userId="+ $(this).attr("user-id") 147 118 ajaxCallLike(url,button,'unlike','Немате оставено допаѓање на филмот!') 148 })149 $(document.body).on("click",".button-add-genre-liked-list",function (){150 let button = $(this)151 let url = "api/genres/like/"+ $(this).attr("genre-id") + "?userId="+ $(this).attr("user-id")152 ajaxCallLikeGenre(url,button,'like','Веќе ви се допаѓа жанрот!')153 })154 $(document.body).on("click",".button-remove-genre-liked-list",function (){155 let button = $(this)156 let url = "api/genres/unlike/"+ $(this).attr("genre-id")+"?userId="+ $(this).attr("user-id")157 ajaxCallLikeGenre(url,button,'unlike','Немате оставено допаѓање на жанрот!')158 119 }) 159 120 $(".discussion-type").change(function (){ … … 196 157 197 158 } 198 $(button).remove()199 159 } 200 160 else { … … 220 180 }) 221 181 } 222 223 224 225 function ajaxCallLikeGenre(url,button,type,message){226 $.ajax({227 url:url,228 success:function (data){229 if (data){230 let el = $(button).parent().siblings().eq(3)231 console.log(el)232 if (type=="like") {233 $(el).html(parseInt($(el).text()) + 1)234 console.log("da")235 }236 else237 $(el).html(parseInt($(el).text()) - 1)238 $(button).css("display","none")239 let userId = $(button).attr("user-id")240 let genreId=$(button).attr("genre-id")241 if (type==='like') {242 $(button).parent().append("<a class='btn btn-danger button-remove-genre-liked-list' genre-id=" + genreId + " user-id=" + userId + ">💔</a>")243 console.log("da")244 }245 else{246 $(button).parent().append("<a class='btn btn-success button-add-genre-liked-list' genre-id=" + genreId + " user-id=" + userId + ">❤</a>")247 }248 let likes_sibling = $("#"+genreId+"genre")249 value_likes = Number(likes_sibling.text())250 if(type=="like")251 value_likes+=1252 else253 value_likes-=1254 likes_sibling.text(value_likes)255 $(button).remove()256 }257 else {258 $(button).parent().append("<div>" + message +" <button class='button-confirm'>Ок</button></div>")259 }260 }261 })262 }263 264 265 182 function ajaxCallRating(url,button,type){ 266 183 model = { -
target/classes/templates/genres.html
rad4243e r7f36551 1 <div class="container mb-4" xmlns:sec="http://www.w3.org/1999/xhtml"> 1 <div class="container mb-4"> 2 <div class="row"> 3 <div class="col-12"> 4 <div class="table-responsive"> 5 <table class="table table-striped"> 6 <thead> 7 <tr> 8 <th scope="col">Име</th> 9 <th scope="col">Лајкови</th> 10 </tr> 11 </thead> 12 <tbody> 13 <tr th:each="genre : ${genres}" class="elements"> 14 <td th:text="${genre.getName()}"></td> 15 <td th:text="${genre.getLikes()}"></td> 2 16 3 <div class="row"> 4 <div class="col-12"> 5 <div class="table-responsive"> 6 <table class="table table-striped"> 7 <thead> 8 <tr> 9 <th scope="col">Име</th> 10 <th scope="col">Лајкови</th> 11 </tr> 12 </thead> 13 <tbody> 14 <tr th:each="genre : ${genres}" class="elements"> 15 <td th:text="${genre.getName()}"></td> 16 <td th:text="${genre.getLikes()}" th:id="${genre.getGenreId()+'genre'}"></td> 17 <td> 18 <th:block sec:authorize="isAuthenticated()" th:each="g: ${allGenres}" th:if="${g.getGenreId() == genre.getGenreId()}"> 19 <a class="btn btn-success button-add-genre-liked-list" th:genre-id="${g.getGenreId()}" th:user-id="${user.getUserId()}" th:if="${!likedGenres.contains(g)}">❤</a> 20 <a class="btn btn-danger button-remove-genre-liked-list" th:genre-id="${g.getGenreId()}" th:user-id="${user.getUserId()}" th:if="${likedGenres.contains(g)}">💔</a> 21 </th:block> 22 </td> 23 </tr> 24 </tbody> 25 </table> 26 </div> 17 </tr> 18 </tbody> 19 </table> 27 20 </div> 28 21 </div> 29 22 </div> 30 23 </div> -
target/classes/templates/personShow.html
rad4243e r7f36551 30 30 </div> 31 31 </div> 32 <div style="width: 45%; margin: 25px; float:left; background-color: rgb(200,200,200); padding: 10px; border-radius: 5px">33 <h2>34 <span>Бројот на оцени кои филмот ги добил:</span>35 <span th:text="${movie.getRates().size()}"></span>36 </h2>37 <hr>38 <div th:each="rating: ${movie.getRates()}" style="margin-bottom: 10px; border: 2px solid gray; border-radius: 10px; background-color: lightblue; padding: 10px; border-radius: 10px; min-height: 130px;">39 <div style="width: 60%; float:left;">40 <p th:text="${rating.getReason()}" style="text-align: justify"></p>41 </div>42 <div style="width: 30%; float:right; background-color: darkorange; border-radius: 10px 30px; color: whitesmoke; padding: 10px;">43 <h2 style="text-align: center">Rated:</h2>44 <p th:text="${rating.getStarsRated() + ' out of 10 stars'}" style="text-align: center"></p>45 </div>46 </div>47 </div>48 <div style="width: 45%; margin: 25px; float:left; background-color: rgb(200,200,200); padding: 10px; border-radius: 5px">49 <h2>50 <span>Бројот на лајкови кои филмот ги добил:</span>51 <span th:text="${movie.getLikes().size()}"></span>52 </h2>53 <hr>54 <div th:each="liked: ${movie.getLikes()}" style="margin-bottom: 10px; border: 2px solid gray; border-radius: 10px; background-color: lightblue; padding: 10px; border-radius: 10px; min-height: 60px;">55 <div style="width: 100%; float:left;">56 <h3 style="text-align: center">57 <span th:text="${liked.getUser().getName() + ' ' + liked.getUser().getSurname()}"></span>58 <span style="color: green; font-size: 100%" >✔</span>59 </h3>60 </div>61 </div>62 </div>63 32 </div> -
target/classes/templates/personsList.html
rad4243e r7f36551 57 57 58 58 </td> 59 60 <a class="bottom-heart btn btn-success button-add-favourite-list"61 th:movie-id="${person.getMovieId()}"62 th:user-id="${user.getUserId()}"63 th:if="${!likedPersons.contains(movie)}">❤</a>64 65 <a class="bottom-heart btn btn-danger button-remove-favourite-list"66 th:movie-id="${person.getMovieId()}" th:user-id="${user.getUserId()}"67 th:if="${likedPersons.contains(movie)}">💔</a>68 69 70 59 </th:block> 71 60
Note:
See TracChangeset
for help on using the changeset viewer.