Commit 32321809 authored by roxane.carraux's avatar roxane.carraux
Browse files

add search page in nav

parent da50e57a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                .antMatchers("/admin/**").hasAnyAuthority("ADMIN")
                .antMatchers("/allPropositionByMentor").hasAnyAuthority("MENTOR")
                .antMatchers("/allRequestByPoulain").hasAnyAuthority("POULAIN")
                .antMatchers("/search").hasAnyAuthority("POULAIN","MENTOR","ADMIN")
                .and()
            .formLogin()
                .loginPage("/login").permitAll()
+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ public class HelpPropositionController {
    @Autowired
    private HelpPropositionValidator helpPropositionValidator;
    

    /**
     * Source : https://attacomsian.com/blog/spring-boot-thymeleaf-pagination 
     */
+22 −10
Original line number Diff line number Diff line
@@ -28,21 +28,31 @@ public class MainController {
    HelpPropositionRepository helpPropositionRepository;

    @GetMapping("/search")
    public String search(Map<String, Object> model, @RequestParam(name = "branch") String branch, @RequestParam(name = "datebegin", required = false) String datebegin, @RequestParam(name = "dateend", required = false) String dateend, @RequestParam(name = "timebegin", required = false) String timebegin, @RequestParam(name = "timeend", required = false) String timeend, @RequestParam(name = "type") int type) throws ParseException {
    public String search(Map<String, Object> model, 
    @RequestParam(name = "branch", required = false) String branch, 
    @RequestParam(name = "datebegin", required = false) String datebegin,
    @RequestParam(name = "dateend", required = false) String dateend,
    @RequestParam(name = "timebegin", required = false) String timebegin, 
    @RequestParam(name = "timeend", required = false) String timeend, 
    @RequestParam(name = "type", required = false) String type) throws ParseException {

        List<HelpRequest> allListHelpRequest = new ArrayList<>();
        List<HelpProposition> allListHelpProposition = new ArrayList<>();

        if (type == 1){ // HelpRequest
        if(type != null && type.length() > 0)
        {
            int modelType=Integer.parseInt(type);
            if (modelType == 1){ // HelpRequest
                allListHelpRequest = helpRequestRepository.findByBranchLike("%"+branch+"%");
            }
        else if (type == 2){ // HelpProposition 
            else if (modelType == 2){ // HelpProposition 
                allListHelpProposition = helpPropositionRepository.findByBranchLike("%"+branch+"%");
            }
            else { // both
                allListHelpRequest = helpRequestRepository.findByBranchLike("%"+branch+"%");
                allListHelpProposition = helpPropositionRepository.findByBranchLike("%"+branch+"%");
            }
        }

        // Date begin
        if (datebegin != null && datebegin.length() > 0){
@@ -78,4 +88,6 @@ public class MainController {
        return "search";
    }


    
}
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -32,10 +32,16 @@
                        <li><a href="/allPropositionByPoulain">Your propositions</a></li>
                        <li><a href="/allRequestByPoulain">Your requests</a></li>
                    </ul>

                    <a th:if="${session.isAdmin == 'true'}" class='dropdown-trigger right' href='#' data-target='dropdown-admin' style="padding:0px 20px;">Admin pages <span>&#9660;</span></a>
                    <ul id='dropdown-admin' class='dropdown-content'>
                        <li><a href="/admin">Admin</a></li>
                    </ul>

                    <a th:if="${session.isPoulain == 'true' ||session.isMentor == 'true' || session.isAdmin == 'true'}" class='dropdown-trigger right' href='#' data-target='dropdown-search' style="padding:0px 20px;">Search pages<span>&#9660;</span></a>
                    <ul id='dropdown-search' class='dropdown-content'>
                        <li><a href="/search">Search</a></li>
                    </ul>
                </div>
            </nav>
        </header>