From 89a059e8c9bedf4879f12973bdcadeafa847a6bf Mon Sep 17 00:00:00 2001 From: "bojana.marojevikj" <bojana.marojevikj@finki.ukim.mk> Date: Wed, 19 Mar 2025 13:47:26 +0100 Subject: [PATCH 1/5] online info display --- .../service/implementation/ConsultationServiceImpl.java | 6 +++++- .../templates/consultationsDisplay/publicConsultations.html | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/mk/ukim/finki/konsultacii/service/implementation/ConsultationServiceImpl.java b/src/main/java/mk/ukim/finki/konsultacii/service/implementation/ConsultationServiceImpl.java index 5be2131..4b877c6 100644 --- a/src/main/java/mk/ukim/finki/konsultacii/service/implementation/ConsultationServiceImpl.java +++ b/src/main/java/mk/ukim/finki/konsultacii/service/implementation/ConsultationServiceImpl.java @@ -92,6 +92,10 @@ public class ConsultationServiceImpl implements ConsultationService { .map(consultation -> { var startDateTime = consultation.getOneTimeDate().atTime(consultation.getStartTime()); var endDateTime = consultation.getOneTimeDate().atTime(consultation.getEndTime()); + String roomName = consultation.getRoom().getName(); + if (consultation.getOnline()) { + roomName += ", Online"; + } return new ConsultationResponseDto( //title @@ -117,7 +121,7 @@ public class ConsultationServiceImpl implements ConsultationService { // timeTo consultation.getEndTime().toString(), // classroom - consultation.getRoom().getName(), + roomName, // deactivated consultation.getCanceledDates().stream() .map(date -> "/Date(" + date.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli() + ")/") diff --git a/src/main/resources/templates/consultationsDisplay/publicConsultations.html b/src/main/resources/templates/consultationsDisplay/publicConsultations.html index f3a9c5e..35be6bc 100644 --- a/src/main/resources/templates/consultationsDisplay/publicConsultations.html +++ b/src/main/resources/templates/consultationsDisplay/publicConsultations.html @@ -29,7 +29,7 @@ <tr th:each="consultation : ${regularConsultationTerms}"> <td th:text="${consultation.oneTimeDate} + ' (' + #{${consultation.getDayOfWeek().toString().toLowerCase()}} + ')'"></td> <td th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}"></td> - <td th:text="${consultation.room.name}"></td> + <td th:text="${consultation.room.name + (consultation.online ? ', Online' : '')}"></td> <td th:text="${consultation.studentInstructions != null ? consultation.studentInstructions : ''}"></td> </tr> </tbody> @@ -53,7 +53,7 @@ <tr th:each="consultation : ${irregularConsultationTerms}"> <td th:text="${consultation.oneTimeDate} + ' (' + #{${consultation.getDayOfWeek().toString().toLowerCase()}} + ')'"></td> <td th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}"></td> - <td th:text="${consultation.room.name}"></td> + <td th:text="${consultation.room.name + (consultation.online ? ', Online' : '')}"></td> <td th:text="${consultation.studentInstructions != null ? consultation.studentInstructions : ''}"></td> </tr> </tbody> -- GitLab From 8598cf5d3178af4bdfe970b01bba3cd4e1958cfe Mon Sep 17 00:00:00 2001 From: "bojana.marojevikj" <bojana.marojevikj@finki.ukim.mk> Date: Wed, 19 Mar 2025 14:00:18 +0100 Subject: [PATCH 2/5] display irregular consultations first --- .../professorConsultations.html | 32 +++--- .../publicConsultations.html | 101 ++++++++++-------- 2 files changed, 74 insertions(+), 59 deletions(-) diff --git a/src/main/resources/templates/consultationsDisplay/professorConsultations.html b/src/main/resources/templates/consultationsDisplay/professorConsultations.html index 4085a69..5a29f70 100644 --- a/src/main/resources/templates/consultationsDisplay/professorConsultations.html +++ b/src/main/resources/templates/consultationsDisplay/professorConsultations.html @@ -18,13 +18,10 @@ <div id="consultations"> - <div> - <h5 class="consultations-type-modal">Редовни консултации</h5> - <div th:if="${#lists.isEmpty(regularPage.getContent())}"> - <p>Нема закажани консултации</p> - </div> + <div th:unless="${#lists.isEmpty(irregularPage.getContent())}"> + <h5 class="consultations-type-modal">Дополнителни консултации</h5> <div class="row"> - <div th:each="consultation : ${regularPage.getContent()}" class="col-lg-3 col-md-4 col-sm-12 mb-4"> + <div th:each="consultation : ${irregularPage.getContent()}" class="col-lg-3 col-md-4 col-sm-12 mb-4"> <div class="consultation-div px-2 py-2 d-flex flex-column justify-content-between"> <div> <div class="d-flex align-items-top"> @@ -33,7 +30,7 @@ </div> <div class="d-flex align-items-top"> <span><img class="consultation-logos mx-2" src="/images/consultation-logo-time.png" alt=""></span> - <p th:text="|${consultation.startTime} - ${consultation.endTime}|" + <p th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}" class="time mb-0 d-inline-block ml-2"></p> </div> <div th:unless="${consultation.online==null}" class="d-flex align-items-top"> @@ -56,17 +53,17 @@ </div> </div> </div> - <div th:unless="${#lists.isEmpty(regularPage.getContent())}" th:include="fragments/regularPaging :: pageSection(${regularPage})" class="mb-4"></div> - </div> + <div th:unless="${#lists.isEmpty(irregularPage.getContent())}" th:include="fragments/irregularPaging :: pageSection(${irregularPage})" class="mb-4"></div> + </div> - <div> - <h5 class="consultations-type-modal" style="margin-top: 3rem">Дополнителни консултации</h5> - <div th:if="${#lists.isEmpty(irregularPage.getContent())}"> + <div th:unless="${#lists.isEmpty(regularPage.getContent())}"> + <h5 class="consultations-type-modal">Редовни консултации</h5> + <div th:if="${#lists.isEmpty(regularPage.getContent())}"> <p>Нема закажани консултации</p> </div> <div class="row"> - <div th:each="consultation : ${irregularPage.getContent()}" class="col-lg-3 col-md-4 col-sm-12 mb-4"> + <div th:each="consultation : ${regularPage.getContent()}" class="col-lg-3 col-md-4 col-sm-12 mb-4"> <div class="consultation-div px-2 py-2 d-flex flex-column justify-content-between"> <div> <div class="d-flex align-items-top"> @@ -75,7 +72,7 @@ </div> <div class="d-flex align-items-top"> <span><img class="consultation-logos mx-2" src="/images/consultation-logo-time.png" alt=""></span> - <p th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}" + <p th:text="|${consultation.startTime} - ${consultation.endTime}|" class="time mb-0 d-inline-block ml-2"></p> </div> <div th:unless="${consultation.online==null}" class="d-flex align-items-top"> @@ -98,9 +95,14 @@ </div> </div> </div> + <div th:unless="${#lists.isEmpty(regularPage.getContent())}" th:include="fragments/regularPaging :: pageSection(${regularPage})" class="mb-4"></div> + </div> - <div th:unless="${#lists.isEmpty(irregularPage.getContent())}" th:include="fragments/irregularPaging :: pageSection(${irregularPage})" class="mb-4"></div> + <div th:if="${#lists.isEmpty(regularPage.getContent()) and #lists.isEmpty(irregularPage.getContent())}" + class="alert alert-info mt-4" role="alert"> + <h6 class="mb-0">Нема закажани консултации.</h6> </div> + </div> </div> diff --git a/src/main/resources/templates/consultationsDisplay/publicConsultations.html b/src/main/resources/templates/consultationsDisplay/publicConsultations.html index 35be6bc..049545f 100644 --- a/src/main/resources/templates/consultationsDisplay/publicConsultations.html +++ b/src/main/resources/templates/consultationsDisplay/publicConsultations.html @@ -12,53 +12,66 @@ </header> <section id="consultations"> - <h2>Редовни консултации</h2> - <div th:if="${#lists.isEmpty(regularConsultationTerms)}"> - <p>Нема закажани консултации</p> + <div th:unless="${#lists.isEmpty(irregularConsultationTerms)}"> + <h2>Дополнителни консултации</h2> + <table th:unless="${#lists.isEmpty(irregularConsultationTerms)}" cellpadding="10"> + <thead> + <tr> + <th>Датум</th> + <th>Време</th> + <th>ПросториСР°</th> + <th>Рнструкции</th> + </tr> + </thead> + <tbody> + <tr th:each="consultation : ${irregularConsultationTerms}"> + <td th:text="${consultation.oneTimeDate} + ' (' + #{${consultation.getDayOfWeek().toString().toLowerCase()}} + ')'"></td> + <td th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}"></td> + <td th:text="${consultation.room.name + (consultation.online ? ', Online' : '')}"></td> + <td th:text="${consultation.studentInstructions != null ? consultation.studentInstructions : ''}"></td> + </tr> + </tbody> + </table> + </div> + + <div th:unless="${#lists.isEmpty(regularConsultationTerms)}"> + <h2>Редовни консултации</h2> + <table th:unless="${#lists.isEmpty(regularConsultationTerms)}" cellpadding="10"> + <thead> + <tr> + <th>Датум</th> + <th>Време</th> + <th>ПросториСР°</th> + <th>Рнструкции</th> + </tr> + </thead> + <tbody> + <tr th:each="consultation : ${regularConsultationTerms}"> + <td th:text="${consultation.oneTimeDate} + ' (' + #{${consultation.getDayOfWeek().toString().toLowerCase()}} + ')'"></td> + <td th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}"></td> + <td th:text="${consultation.room.name + (consultation.online ? ', Online' : '')}"></td> + <td th:text="${consultation.studentInstructions != null ? consultation.studentInstructions : ''}"></td> + </tr> + </tbody> + </table> </div> - <table th:unless="${#lists.isEmpty(regularConsultationTerms)}" cellpadding="10"> - <thead> - <tr> - <th>Датум</th> - <th>Време</th> - <th>ПросториСР°</th> - <th>Рнструкции</th> - </tr> - </thead> - <tbody> - <tr th:each="consultation : ${regularConsultationTerms}"> - <td th:text="${consultation.oneTimeDate} + ' (' + #{${consultation.getDayOfWeek().toString().toLowerCase()}} + ')'"></td> - <td th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}"></td> - <td th:text="${consultation.room.name + (consultation.online ? ', Online' : '')}"></td> - <td th:text="${consultation.studentInstructions != null ? consultation.studentInstructions : ''}"></td> - </tr> - </tbody> - </table> - <hr/> - <h2>Дополнителни консултации</h2> - <div th:if="${#lists.isEmpty(irregularConsultationTerms)}"> - <p>Нема закажани консултации</p> + <div th:if="${#lists.isEmpty(regularConsultationTerms) and #lists.isEmpty(irregularConsultationTerms)}"> + Нема закажани консултации РІРѕ наредните 6 дена. </div> - <table th:unless="${#lists.isEmpty(irregularConsultationTerms)}" cellpadding="10"> - <thead> - <tr> - <th>Датум</th> - <th>Време</th> - <th>ПросториСР°</th> - <th>Рнструкции</th> - </tr> - </thead> - <tbody> - <tr th:each="consultation : ${irregularConsultationTerms}"> - <td th:text="${consultation.oneTimeDate} + ' (' + #{${consultation.getDayOfWeek().toString().toLowerCase()}} + ')'"></td> - <td th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}"></td> - <td th:text="${consultation.room.name + (consultation.online ? ', Online' : '')}"></td> - <td th:text="${consultation.studentInstructions != null ? consultation.studentInstructions : ''}"></td> - </tr> - </tbody> - </table> - <a class="nav-link" href="/consultations">РќР°Савете СЃРµ</a> Р·Р° РґР° СЃРµ РїСЂРёСавите РЅР° консултациите. + + <hr/> + + <p th:unless="${#lists.isEmpty(regularConsultationTerms) and #lists.isEmpty(irregularConsultationTerms)}"> + <a class="nav-link" href="/consultations"> + РќР°Савете СЃРµ</a> Р·Р° РґР° СЃРµ РїСЂРёСавите РЅР° консултациите. + </p> + + <p th:if="${#lists.isEmpty(regularConsultationTerms) and #lists.isEmpty(irregularConsultationTerms)}"> + <a class="nav-link" href="/consultations"> + РќР°Савете СЃРµ</a> Р·Р° РґР° РіРё видите сите термини Р·Р° консултации. + </p> + </section> </div> </body> -- GitLab From fe8c287b73854dca32f1f6422a096e6a2ab7aec5 Mon Sep 17 00:00:00 2001 From: "bojana.marojevikj" <bojana.marojevikj@finki.ukim.mk> Date: Wed, 19 Mar 2025 14:06:56 +0100 Subject: [PATCH 3/5] fix --- .../java/mk/ukim/finki/konsultacii/config/AuthConfig.java | 1 + .../templates/consultationsDisplay/publicConsultations.html | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/mk/ukim/finki/konsultacii/config/AuthConfig.java b/src/main/java/mk/ukim/finki/konsultacii/config/AuthConfig.java index 169fa16..7af29ab 100644 --- a/src/main/java/mk/ukim/finki/konsultacii/config/AuthConfig.java +++ b/src/main/java/mk/ukim/finki/konsultacii/config/AuthConfig.java @@ -14,6 +14,7 @@ public class AuthConfig { .authorizeHttpRequests((requests) -> requests .requestMatchers(HttpMethod.OPTIONS).permitAll() .requestMatchers("/Consultations/GetTermsByTeacherCode").permitAll() + .requestMatchers("/display/*").permitAll() .requestMatchers(HttpMethod.POST, "/consultations").hasAnyAuthority( AppRole.STUDENT.name(), AppRole.ADMIN.name(), AppRole.PROFESSOR.name()) .requestMatchers("/auth/*", "/", "", "/display/*", "/css/*", "/js/*", "/images/*").permitAll() diff --git a/src/main/resources/templates/consultationsDisplay/publicConsultations.html b/src/main/resources/templates/consultationsDisplay/publicConsultations.html index 049545f..16ef1b7 100644 --- a/src/main/resources/templates/consultationsDisplay/publicConsultations.html +++ b/src/main/resources/templates/consultationsDisplay/publicConsultations.html @@ -14,7 +14,7 @@ <section id="consultations"> <div th:unless="${#lists.isEmpty(irregularConsultationTerms)}"> <h2>Дополнителни консултации</h2> - <table th:unless="${#lists.isEmpty(irregularConsultationTerms)}" cellpadding="10"> + <table cellpadding="10"> <thead> <tr> <th>Датум</th> @@ -36,7 +36,7 @@ <div th:unless="${#lists.isEmpty(regularConsultationTerms)}"> <h2>Редовни консултации</h2> - <table th:unless="${#lists.isEmpty(regularConsultationTerms)}" cellpadding="10"> + <table cellpadding="10"> <thead> <tr> <th>Датум</th> -- GitLab From 71c7cc95925f22a585b072849076a90d4bf8e610 Mon Sep 17 00:00:00 2001 From: "bojana.marojevikj" <bojana.marojevikj@finki.ukim.mk> Date: Wed, 19 Mar 2025 14:18:31 +0100 Subject: [PATCH 4/5] redirect consultations display --- .../web/controllers/HomeController.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/mk/ukim/finki/konsultacii/web/controllers/HomeController.java b/src/main/java/mk/ukim/finki/konsultacii/web/controllers/HomeController.java index d39a5f0..5eace65 100644 --- a/src/main/java/mk/ukim/finki/konsultacii/web/controllers/HomeController.java +++ b/src/main/java/mk/ukim/finki/konsultacii/web/controllers/HomeController.java @@ -45,15 +45,21 @@ public class HomeController { @GetMapping("/display/{professorId}") public String getProfessorConsultations(@PathVariable("professorId") String professorId, Model model) { - Professor professor = this.professorService.getProfessorById(professorId); - List<Consultation> nextWeekRegularTerms = this.consultationService.listNextWeekConsultationsByProfessor(professorId, ConsultationType.WEEKLY); - List<Consultation> nextWeekIrregularTerms = this.consultationService.listNextWeekConsultationsByProfessor(professorId, ConsultationType.ONE_TIME); - - model.addAttribute("professor", professor); - model.addAttribute("regularConsultationTerms", nextWeekRegularTerms); - model.addAttribute("irregularConsultationTerms", nextWeekIrregularTerms); + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if(authentication.getPrincipal().equals("anonymousUser")){ + Professor professor = this.professorService.getProfessorById(professorId); + List<Consultation> nextWeekRegularTerms = this.consultationService.listNextWeekConsultationsByProfessor(professorId, ConsultationType.WEEKLY); + List<Consultation> nextWeekIrregularTerms = this.consultationService.listNextWeekConsultationsByProfessor(professorId, ConsultationType.ONE_TIME); + model.addAttribute("professor", professor); + model.addAttribute("regularConsultationTerms", nextWeekRegularTerms); + model.addAttribute("irregularConsultationTerms", nextWeekIrregularTerms); - return "consultationsDisplay/publicConsultations"; + return "consultationsDisplay/publicConsultations"; + } + if(authentication.getAuthorities().stream().anyMatch(auth -> auth.getAuthority().equals("ROLE_STUDENT"))){ + return "redirect:/consultations/student/professor/"+professorId; + } + return "redirect:/consultations/professor/"+professorId; } } -- GitLab From c0e24f8ed669273887d56812429130a6bc85cabd Mon Sep 17 00:00:00 2001 From: "bojana.marojevikj" <bojana.marojevikj@finki.ukim.mk> Date: Wed, 19 Mar 2025 14:22:35 +0100 Subject: [PATCH 5/5] null safe online check --- .../templates/consultationsDisplay/publicConsultations.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/consultationsDisplay/publicConsultations.html b/src/main/resources/templates/consultationsDisplay/publicConsultations.html index 16ef1b7..ec751e7 100644 --- a/src/main/resources/templates/consultationsDisplay/publicConsultations.html +++ b/src/main/resources/templates/consultationsDisplay/publicConsultations.html @@ -27,7 +27,7 @@ <tr th:each="consultation : ${irregularConsultationTerms}"> <td th:text="${consultation.oneTimeDate} + ' (' + #{${consultation.getDayOfWeek().toString().toLowerCase()}} + ')'"></td> <td th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}"></td> - <td th:text="${consultation.room.name + (consultation.online ? ', Online' : '')}"></td> + <td th:text="${consultation.room.name + (consultation.online != null ? (consultation.online ? ', Online' : '') : '')}"></td> <td th:text="${consultation.studentInstructions != null ? consultation.studentInstructions : ''}"></td> </tr> </tbody> @@ -49,7 +49,7 @@ <tr th:each="consultation : ${regularConsultationTerms}"> <td th:text="${consultation.oneTimeDate} + ' (' + #{${consultation.getDayOfWeek().toString().toLowerCase()}} + ')'"></td> <td th:text="${consultation.startTime} + ' - ' + ${consultation.endTime}"></td> - <td th:text="${consultation.room.name + (consultation.online ? ', Online' : '')}"></td> + <td th:text="${consultation.room.name + (consultation.online != null ? (consultation.online ? ', Online' : '') : '')}"></td> <td th:text="${consultation.studentInstructions != null ? consultation.studentInstructions : ''}"></td> </tr> </tbody> -- GitLab