From 88f1eb3e275a1708a074e0f8d251b2077dba49e4 Mon Sep 17 00:00:00 2001
From: Florine Lefebvre <florine.lefebvre.etu@univ-lille.fr>
Date: Fri, 28 Feb 2025 13:19:34 +0100
Subject: [PATCH] ajout d'un message si aucun fil

---
 WEB-INF/vue/compte.jsp     |  2 +-
 WEB-INF/vue/fils.jsp       | 35 +++++++++++++++++++++++------------
 WEB-INF/vue/filsSuivis.jsp | 38 +++++++++++++++++++++++---------------
 3 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/WEB-INF/vue/compte.jsp b/WEB-INF/vue/compte.jsp
index 3ac5088..4007fad 100644
--- a/WEB-INF/vue/compte.jsp
+++ b/WEB-INF/vue/compte.jsp
@@ -104,7 +104,7 @@
                         <%  if (daoThread.findByCreator(username).size() == 0){ %>
                             <div class="p-2 mb-3">
                                 <div class="d-flex justify-content-center align-items-center">
-                                    <label class="fs-3">Vous n'avez pas de fil !</label>
+                                    <label class="fs-3">Vous n'avez pas de fil :</label>
                                     <a class="ms-3 align-self-center btn btn-success" href="navigation?page=creerFil">Créer un fil <i class="bi-plus-square-fill"></i></a>
                                 </div>
                             </div>
diff --git a/WEB-INF/vue/fils.jsp b/WEB-INF/vue/fils.jsp
index 4913399..16d5057 100644
--- a/WEB-INF/vue/fils.jsp
+++ b/WEB-INF/vue/fils.jsp
@@ -67,24 +67,35 @@
                     <hr />
                     <%
                         User user = daoUser.findByUsername((String) request.getSession().getAttribute("username"));
+                        if (daoThread.findThreadNotFollow(user.getUsername()).size() == 0){
                     %>
-                    <% for (Thread fil : daoThread.findThreadNotFollow(user.getUsername())) { %>
+                        <div class="p-2 mb-3">
+                            <div class="d-flex justify-content-center align-items-center">
+                                <label class="fs-3">Pas de fil disponible :</label>
+                                <a class="ms-3 align-self-center btn btn-success" href="navigation?page=creerFil">Créer un fil <i class="bi-plus-square-fill"></i></a>
+                            </div>
+                        </div>
+                    <%
+                        } else {
+                    %>
+                        <% for (Thread fil : daoThread.findThreadNotFollow(user.getUsername())) { %>
 
-                    <div class="p-2 border border-primary border-3 rounded mb-3">
-                        <div class="d-flex justify-content-between">
-                            <div class="ms-2">
-                                <p class="fs-3"><%= fil.getName() %></p>
-                                <span class="text-secondary">Par @<%= fil.getCreator()%> le <%=fil.getDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))%></span>
+                        <div class="p-2 border border-primary border-3 rounded mb-3">
+                            <div class="d-flex justify-content-between">
+                                <div class="ms-2">
+                                    <p class="fs-3"><%= fil.getName() %></p>
+                                    <span class="text-secondary">Par @<%= fil.getCreator()%> le <%=fil.getDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))%></span>
+                                </div>
+                                <a class="me-3 align-self-center btn btn-primary" href="thread?action=follow&id=<%=fil.getId_thread() %>">Suivre <i class="bi-heart-fill"></i></a>
                             </div>
-                            <a class="me-3 align-self-center btn btn-primary" href="thread?action=follow&id=<%=fil.getId_thread() %>">Suivre <i class="bi-heart-fill"></i></a>
                         </div>
-                    </div>
 
-                    <% } %>
+                        <% } %>
 
-                    <div class="bg-light p-3 d-flex justify-content-center border-top border-3">
-                        <a href="#" class="btn btn-outline-secondary">Remonter <i class="bi-arrow-up"></i></a>
-                    </div>
+                        <div class="bg-light p-3 d-flex justify-content-center border-top border-3">
+                            <a href="#" class="btn btn-outline-secondary">Remonter <i class="bi-arrow-up"></i></a>
+                        </div>
+                    <% } %>
                 </div>
             </div>
         </div>
diff --git a/WEB-INF/vue/filsSuivis.jsp b/WEB-INF/vue/filsSuivis.jsp
index a6e551d..d1721b8 100644
--- a/WEB-INF/vue/filsSuivis.jsp
+++ b/WEB-INF/vue/filsSuivis.jsp
@@ -64,26 +64,34 @@
 
                     <h1>Fils suivis !</h1>
                     <hr />
-                    <% for (Thread fil : daoThread.findThreadFollow(user.getUsername())) { %>
-
-                    <div class="p-2 border border-primary border-3 rounded mb-3">
-                        <div class="d-flex justify-content-between">
-                            <div class="ms-2">
-                                <p class="fs-3"><%= fil.getName() %></p>
-                                <span class="text-secondary">Par @<%= fil.getCreator()%> le <%=fil.getDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))%></span>
-                            </div>
-                            <div class="d-flex">
-                                <a class="me-3 align-self-center btn btn-primary" href="thread?action=open&id=<%=fil.getId_thread() %>">Ouvrir <i class="bi-chat-fill"></i></a>
-                                <a class="me-3 align-self-center btn btn-danger <% if (daoThread.isCreatorOf(user.getUsername(), fil.getId_thread())) { %> disabled <% } %>" href="thread?action=unfollow&id=<%=fil.getId_thread() %>">Ne plus suivre <i class="bi-x-circle-fill"></i></a>
-                            </div>
+                    <% if(daoThread.findThreadFollow(user.getUsername()).size() == 0){ %>
+                    <div class="p-2 mb-3">
+                        <div class="d-flex justify-content-center align-items-center">
+                            <label class="fs-3">Vous ne suivez aucun fil :</label>
+                            <a class="ms-3 align-self-center btn btn-success" href="navigation?page=fils">Voir les fils <i class="bi-threads-fill"></i></a>
                         </div>
                     </div>
+                    <% } else { %>
+                        <% for (Thread fil : daoThread.findThreadFollow(user.getUsername())) { %>
 
+                        <div class="p-2 border border-primary border-3 rounded mb-3">
+                            <div class="d-flex justify-content-between">
+                                <div class="ms-2">
+                                    <p class="fs-3"><%= fil.getName() %></p>
+                                    <span class="text-secondary">Par @<%= fil.getCreator()%> le <%=fil.getDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))%></span>
+                                </div>
+                                <div class="d-flex">
+                                    <a class="me-3 align-self-center btn btn-primary" href="thread?action=open&id=<%=fil.getId_thread() %>">Ouvrir <i class="bi-chat-fill"></i></a>
+                                    <a class="me-3 align-self-center btn btn-danger <% if (daoThread.isCreatorOf(user.getUsername(), fil.getId_thread())) { %> disabled <% } %>" href="thread?action=unfollow&id=<%=fil.getId_thread() %>">Ne plus suivre <i class="bi-x-circle-fill"></i></a>
+                                </div>
+                            </div>
+                        </div>
+                        <% } %>
+                        <div class="bg-light p-3 d-flex justify-content-center border-top border-3">
+                            <a href="#" class="btn btn-outline-secondary">Remonter <i class="bi-arrow-up"></i></a>
+                        </div>
                     <% } %>
 
-                    <div class="bg-light p-3 d-flex justify-content-center border-top border-3">
-                        <a href="#" class="btn btn-outline-secondary">Remonter <i class="bi-arrow-up"></i></a>
-                    </div>
                 </div>
             </div>
         </div>
-- 
GitLab