<!doctype html>
<html lang="es" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
 <head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Meetup</title>
	<link href="/dist/css/bootstrap.min.css" rel="stylesheet">    
</head>
<body>
  <header>
	  <div class="navbar navbar-dark bg-dark box-shadow">
	        <div class="container d-flex justify-content-between">
	          <a href="/" class="navbar-brand d-flex align-items-center">
	            <strong>Messages</strong>
	          </a>
	          <span class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newMeetingModal" style="float:right;top:0;">New Message</span>
	        </div>
      </div>
	</header>
	<main>
		<section class="py-5 text-center container">
		  <div class="row py-lg-5">
		    <div class="col-lg-6 col-md-8 mx-auto">
		      <h1 class="fw-light">Messages</h1>
		      <p>Welcome <span th:text="${#authentication.name}">Username</span></p>
		    </div>
		  </div>
		</section>

	    <div class="album py-5 bg-light">
		  <div class="container">
		    <div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
		      <div class="col" th:each="msg : ${msgs}">
		        <div class="card shadow-sm">
		          <div class="card-body">
		            <p class="card-text" th:text="${msg.id}">Message id</p>
		            <p class="card-text" th:text="${msg.content}">Message text</p>
		            <div class="d-flex justify-content-between align-items-center">
		              <div class="btn-group">
		                <a type="button" class="btn btn-sm btn-outline-secondary" th:attr="href='messages/remove/'+${msg.id}">Remove</a>
		              </div>
		            </div>
		          </div>
		        </div>
		      </div>
		    </div>
		  </div>
		</div>
	</main>
	
	<div class="modal fade" id="newMeetingModal" role="dialog" aria-labelledby="newMeetingModal" aria-hidden="true">
	  <div class="modal-dialog modal-lg">
	    <div class="modal-content">
		    <div class="modal-header">
		        <h5 class="modal-title">New Message</h5>
		        <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
		        	<span aria-hidden="true">&times;</span>
		        </button>
	        </div>
	        <div class="modal-body">
	        	<div class="container-fluid">
			    	<form id="newMeetingForm" enctype='multipart/form-data' th:action="@{/messages}" method="post" style="margin-top:25px;">
						<div class="form-group">
							<label>Content</label>
							<textarea  class="form-control" name="content" cols="50" rows="5"></textarea>
						</div>
					</form>
				</div>
			</div>
			<div class="modal-footer">
		        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
		        <button class="btn btn-success" type="submit" form="newMeetingForm">Confirm</button>
	        </div>
	    </div>
	  </div>
	</div>
	
    <script src="/dist/js/bootstrap.bundle.min.js"></script>   
</body>
</html>

