From cae72a738daebca9607e87c76106b8767212c770 Mon Sep 17 00:00:00 2001 From: Yannis Devos <yannis.devos.etu@univ-lille.fr> Date: Tue, 18 Mar 2025 12:21:59 +0100 Subject: [PATCH] Correction fonctionnement affichage des messages --- WEB-INF/src/controleurs/Feed.java | 17 +++++++++++++---- WEB-INF/src/controleurs/Following.java | 2 +- css/feed.css | 25 ++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/WEB-INF/src/controleurs/Feed.java b/WEB-INF/src/controleurs/Feed.java index 331e2d8..3ac8fa4 100644 --- a/WEB-INF/src/controleurs/Feed.java +++ b/WEB-INF/src/controleurs/Feed.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; @WebServlet("/Welcome") public class Feed extends HttpServlet { @@ -54,6 +55,15 @@ public class Feed extends HttpServlet { MyThread msgThread = new MyThread(0,null); if (!messages.isEmpty()) { + + try { + Message msg = messages.get(0); + msgThread = threadDao.getThreadById(msg.getThreadId()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + out.println("<h2 class=\"feedMsgThread\"> Thread : <span style=\"color : grey\">" + msgThread.getThreadName().toUpperCase() + "</span></h2>"); for (Message message : messages) { try { msgThread = threadDao.getThreadById(message.getThreadId()); @@ -61,8 +71,7 @@ public class Feed extends HttpServlet { throw new RuntimeException(e); } out.println("<div class=\"message\">"); - out.println("<h3 class=\"msgThread\">" + msgThread.getThreadName() + "</h3>"); - out.println("<p class=\"msgContent\">" + message.getContent() + "</p>"); + out.println("<p class=\"msgContent\"><strong style=\"color : grey\">" + userDao.getUserById(message.getSenderId()).getUserName() + "</strong> : " + message.getContent() + "</p>"); boolean msgIsLiked = false; try { @@ -72,7 +81,7 @@ public class Feed extends HttpServlet { sqle.getStackTrace(); } - out.println("<form class=\"feedForm\" action=\"http://localhost:8080/s4a021-web-backend/LikeMessage\" method=\"post\">"); + out.println("<form class=\"feedForm\" action=\"http://localhost:8080/s4a021-web-backend/LikeMessage\" method=\"post\">"); out.println("<input name=\"messageid\" type=\"hidden\" value=\"" + message.getMsgId() +"\">"); if (msgIsLiked) { @@ -90,7 +99,7 @@ public class Feed extends HttpServlet { out.println("<form class=\"feedForm\" action=\"http://localhost:8080/s4a021-web-backend/PostMessage\" method=\"post\">"); out.println("<textarea name=\"message\" rows=\"2\" cols=\"30\" placeholder=\"Post a message in this thread\"></textarea>"); out.println("<input name=\"threadid\" type=\"hidden\" value=\"" + msgThread.getId() + "\">"); - out.println("<button type=\"submit\">Post</button>"); + out.println("<button class=\"postButton\" type=\"submit\">Post</button>"); out.println("</form>"); out.println("<div class=\"discover\">"); diff --git a/WEB-INF/src/controleurs/Following.java b/WEB-INF/src/controleurs/Following.java index 6892137..c5745db 100644 --- a/WEB-INF/src/controleurs/Following.java +++ b/WEB-INF/src/controleurs/Following.java @@ -74,7 +74,7 @@ public class Following extends HttpServlet { } else { out.println("<h3>You are not following any thread yet.</h3>"); - out.println("<button><a href=\"\">Discover new threads</a></button>"); + out.println("<button><a href=\"http://localhost:8080/s4a021-web-backend/Discover\">Discover new threads</a></button>"); } out.println("</body>"); diff --git a/css/feed.css b/css/feed.css index 540e72b..4b1ea20 100644 --- a/css/feed.css +++ b/css/feed.css @@ -7,6 +7,14 @@ body{ background-color: #232323; } +toCenter{ + text-align: center; +} + +.feedMsgThread{ + margin-top : 5%; +} + .menu{ display: flex; align-items: center; @@ -31,7 +39,7 @@ ul{ padding : 0; } -form:not(.followThread, .feedForm) { +form:not(.followThread, .feedForm, .feedFormu) { text-align: center; display: flex; flex-direction: column; @@ -41,6 +49,16 @@ form:not(.followThread, .feedForm) { margin-top: 5%; } +textarea{ + margin-top : 1%; + margin-right : auto; + margin-left : auto; +} + +postButton{ +} + + .menu_option{ text-align : center; list-style: none; @@ -73,6 +91,7 @@ form>.link { } .discover{ + margin-top : 5%; text-align : center; } @@ -83,7 +102,7 @@ form>.link { } .information{ - margin-top : 10%; - margin-bottom : 2%; + margin-top : 5%; + margin-bottom : 5%; text-align : center; } \ No newline at end of file -- GitLab