From b8714f2a65e39086978f48e5ee14f3e0b50e0ae1 Mon Sep 17 00:00:00 2001 From: Yannis Devos <yannis.devos.etu@univ-lille.fr> Date: Tue, 18 Mar 2025 10:56:04 +0100 Subject: [PATCH] Correction dans l'affichage des messages --- WEB-INF/src/controleurs/Account.java | 3 ++- WEB-INF/src/controleurs/Feed.java | 18 +++++++++--------- WEB-INF/src/controleurs/NewThread.java | 5 ++++- create.html | 2 +- css/feed.css | 23 ++++++++++++++++++++++- index.html | 2 +- 6 files changed, 39 insertions(+), 14 deletions(-) diff --git a/WEB-INF/src/controleurs/Account.java b/WEB-INF/src/controleurs/Account.java index 7213d43..647379b 100644 --- a/WEB-INF/src/controleurs/Account.java +++ b/WEB-INF/src/controleurs/Account.java @@ -45,7 +45,6 @@ public class Account extends HttpServlet { out.println("<input name=\"newPwd\" type=\"password\" placeholder=\"New password\">"); out.println("<button type=\"submit\">Change it !</button>"); out.println("</form>"); - out.println("</section>"); String npwd = req.getParameter("newPwd"); if (npwd != null){ @@ -62,6 +61,8 @@ public class Account extends HttpServlet { } } + out.println("</section>"); + // out.println("<h2>JE SAIS PAS</h2>"); // out.println("<form class=\"changepwdForm\" action=\"/s4a021-web-backend/Account?interact=del\">"); // out.println("<button type=\"submit\">Delete Account</button>"); diff --git a/WEB-INF/src/controleurs/Feed.java b/WEB-INF/src/controleurs/Feed.java index bd06780..d4558b9 100644 --- a/WEB-INF/src/controleurs/Feed.java +++ b/WEB-INF/src/controleurs/Feed.java @@ -51,9 +51,10 @@ public class Feed extends HttpServlet { out.println(PageGeneration.generateNavMenu()); + MyThread msgThread = new MyThread(0,null); + if (!messages.isEmpty()) { for (Message message : messages) { - MyThread msgThread; try { msgThread = threadDao.getThreadById(message.getThreadId()); } catch (SQLException e) { @@ -63,13 +64,6 @@ public class Feed extends HttpServlet { out.println("<h3 class=\"msgThread\">" + msgThread.getThreadName() + "</h3>"); out.println("<p class=\"msgContent\">" + message.getContent() + "</p>"); - out.println("<form 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("</form>"); - - boolean msgIsLiked = false; try { msgIsLiked = messageDao.isMessageLikedByUser(message.getMsgId(), user); @@ -78,7 +72,7 @@ public class Feed extends HttpServlet { sqle.getStackTrace(); } - out.println("<form 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) { @@ -93,6 +87,12 @@ public class Feed extends HttpServlet { out.println("<p class=\"information\">You are not following any thread yet.</p>"); } + 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("</form>"); + out.println("<div class=\"discover\">"); out.println("<a href=\"http://localhost:8080/s4a021-web-backend/Discover\">Discover new threads</a>"); out.println("<a href=\"http://localhost:8080/s4a021-web-backend/NewThread\">Create a new thread</a>"); diff --git a/WEB-INF/src/controleurs/NewThread.java b/WEB-INF/src/controleurs/NewThread.java index cb3d722..cb92271 100644 --- a/WEB-INF/src/controleurs/NewThread.java +++ b/WEB-INF/src/controleurs/NewThread.java @@ -58,9 +58,11 @@ public class NewThread extends HttpServlet { out.println("<html><body><meta charset=\"utf-8\">"); out.println("<link rel=\"icon\" type=\"image/png\" href=\"css/campus_talk.png\">"); + out.println("<link rel=\"stylesheet\" href=\"css/feed.css\">"); out.println("<title>New thread</title>"); + out.println("<section>"); out.println("<div class=\"write\">"); out.println("<h1>Create a new thread</h1>"); out.println(PageGeneration.generateNavMenu()); @@ -68,14 +70,15 @@ public class NewThread extends HttpServlet { out.println("<input name=\"threadname\" type=\"text\" placeholder=\"Name of new thread\">"); out.println("<textarea name=\"first_message\" type=\"text\" rows=\"2\" cols=\"30\" placeholder=\"Post the first message of your new thread!\"></textarea>"); out.println("<button type=\"submit\">Create</button>"); + out.println("<a class=\"link\" href=\"http://localhost:8080/s4a021-web-backend/Welcome\">Back to feed</a>"); out.println("</form>"); + out.println("</section>"); if (newThreadWasCreated) { out.println("<p class=\"information\">The thread <strong>\"" + threadname + "\"</strong> was successfully created</p>"); } - out.println("<button><a href=\"http://localhost:8080/s4a021-web-backend/Welcome\">Back to feed</a></button>"); out.println("</body>"); out.println("<footer>"); out.println("Connected as " + login); diff --git a/create.html b/create.html index 5706430..ebaa093 100644 --- a/create.html +++ b/create.html @@ -9,8 +9,8 @@ <body> <div class="form"> <section> - <h1>REGISTER</h1> <form action="http://localhost:8080/s4a021-web-backend/SignUp" method="post"> + <h1>REGISTER</h1> <input name="login" type="text" placeholder="username"> <input name="pwd" type="password" placeholder="password"> <button type="submit">Create my Account !</button> diff --git a/css/feed.css b/css/feed.css index ae25b33..540e72b 100644 --- a/css/feed.css +++ b/css/feed.css @@ -31,6 +31,16 @@ ul{ padding : 0; } +form:not(.followThread, .feedForm) { + text-align: center; + display: flex; + flex-direction: column; + width: 25%; + margin-right: auto; + margin-left: auto; + margin-top: 5%; +} + .menu_option{ text-align : center; list-style: none; @@ -45,7 +55,18 @@ ul{ transition : 0.2s; } -.menu_option>a:hover{ +form>.link { + margin-top : 5%; + background-color : white; + text-decoration: none; + color: black; + padding : 1%; + margin-right :auto; + margin-left :auto; + transition : 0.2s; +} + +.menu_option>a:hover, .link:hover{ transition : 0.3s; padding : 3%; border-radius : 5px; diff --git a/index.html b/index.html index a7fcc1a..f690b4c 100644 --- a/index.html +++ b/index.html @@ -12,8 +12,8 @@ <body> <div class="form"> <section> - <h1>LOGIN</h1> <form action="http://localhost:8080/s4a021-web-backend/LogIn" method="post"> + <h1>LOGIN</h1> <input name="login" type="text" placeholder="username"> <input name="pwd" type="password" placeholder="password"> <button type="submit">Let's go !</button> -- GitLab