Skip to content

Commit

Permalink
FE AI Acception
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewaaa committed Jan 17, 2024
1 parent e2646cb commit 0501e4b
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/main/java/controller/ManageAIExercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class ManageAIExercise extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
String referer = request.getHeader("Referer");
String action = request.getParameter("action");
ExerciseManager em = new ExerciseManager();
Gson g = new Gson();
Expand All @@ -31,6 +32,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
}
em.changeMultipleReccomandation(action, Integer.parseInt(request.getParameter("userId")));
}
response.sendRedirect(request.getHeader("Referer"));
response.sendRedirect(referer);
}
}
74 changes: 74 additions & 0 deletions src/main/webapp/CSS/acceptanceExercisesAI.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#intestazione {
text-align: center; /* Centra il testo all'interno del div */
padding: 20px; /* Aggiunto spazio intorno al contenuto del div */
}

/* Stili per l'h1 all'interno del div di intestazione */
#intestazione h3 {
color: #333;
margin-bottom: 5px;
}
#intestazione h2 {
color: #333;
margin-top: 0;
margin-bottom: 10px;
}


table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
margin-left: auto;
margin-right: auto;

}


th, td {
padding: 10px;
text-align: center;
}

.buttonApprove {
display: inline-block;
padding: 8px 16px;
font-size: 14px;
font-weight: bold;
text-align: center;
text-decoration: none;
cursor: pointer;
border: 2px solid #199A8E;
color: #199A8E;
background-color: transparent;
border-radius: 3px;
transition: background-color 0.3s, color 0.3s, border-color 0.3s;
margin-bottom: 5px;
}

.buttonRemove {
display: inline-block;
padding: 8px 16px;
font-size: 14px;
font-weight: bold;
text-align: center;
text-decoration: none;
cursor: pointer;
border: 2px solid #f44336;
color: #f44336;
background-color: transparent;
border-radius: 3px;
transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.buttonApprove:hover {
background-color: #199A8E;
color: #fff;
border-color: #fff;
}

.buttonRemove:hover {
background-color: #f44336;
color: #fff;
border-color: #fff;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,64 @@

<html>
<head>
<title>TESTING</title>
<title>Gestione AI</title>
<link rel="stylesheet" href="../CSS/acceptanceExercisesAI.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2" crossorigin="anonymous"></script>
</head>
<body>

<script>
function hide(index){
$("#u"+index).hide()
}
</script>
<%
ExerciseManager em = new ExerciseManager();
List<SlimmerExercise> exercises = em.retrieveAiRaccomandation(9); //TODO: Prendilo dalla sessione
List<SlimmerExercise> exercises = em.retrieveAiRaccomandation((Integer) session.getAttribute("id"));
UserData ud = new UserData();
ArrayList<UserInfo> u = ud.getUsersAndPersonalInfoByIdTherapist(9); //TODO: Prendilo dalla sessione
ArrayList<UserInfo> u = ud.getUsersAndPersonalInfoByIdTherapist((Integer) session.getAttribute("id"));
Gson g = new GsonBuilder().disableHtmlEscaping().create();
%>

<% for (UserInfo user : u) {%>
<table border="1">
<tbody>
<h1>Paziente: <%=user.getFirstname()%> <%=user.getLastname()%></h1>
<button onclick='approveAll(<%= user.getId() %>)'>Accetta Tutto</button>
<button onclick='removeAll(<%= user.getId() %>)'>Rimuovi Tutto</button>
<% int index=0;
for (UserInfo user : u) {
index++;
boolean sentinel=false;
%>

<div id="u<%=index%>">
<table>
<tbody>
<div id="intestazione">
<h3>Paziente:</h3>
<h2><%=user.getFirstname()%> <%=user.getLastname()%></h2>
<button class="buttonApprove" onclick='approveAll(<%= user.getId() %>)'>Accetta Tutto</button>
<button class="buttonRemove" onclick='removeAll(<%= user.getId() %>)'>Rimuovi Tutto</button>
</div>
<th></th>
<th>Nome</th>
<th>Descrizione</th>
<th>Tipo</th>
<th>Difficoltà</th>
<th>Target</th>
<th></th>


<% for (SlimmerExercise ex : exercises){
if(ex.getUserId() == user.getId()){
sentinel=true;
%>
<tr>
<td><%= ex.getUserId() %></td>
<td></td>
<td><%= ex.getName() %></td>
<td><%= ex.getDescription() %></td>
<td><%= ex.getType() %></td>
<td><%= ex.getDifficulty() %></td>
<td><%= ex.getTarget() %></td>
<td><%= ex.getType() %></td>
<td>
<button onclick='approveEx(<%= g.toJson(ex) %>)'>Approva</button>
<button onclick='removeEx(<%= g.toJson(ex) %>)'>Rifiuta</button>
<button class="buttonApprove" onclick='approveEx(<%= g.toJson(ex) %>)'>Approva</button>
<button class="buttonRemove" onclick='removeEx(<%= g.toJson(ex) %>)'>Rifiuta</button>
</td>
</tr>
<%
Expand All @@ -52,7 +76,16 @@
%>
</tbody>
</table>
</div>
<%
if (!sentinel) {
%>
<script>
hide(<%=index%>);
</script>
<%
}
}
%>

Expand Down

0 comments on commit 0501e4b

Please sign in to comment.