Commit 5f50a41c authored by elisabeth kee's avatar elisabeth kee

Final commit

parent 9b015b89
......@@ -13,7 +13,8 @@ public interface ProfileRepository extends CrudRepository<Profile, Long> {
Optional<Profile> findById(Long id);
@Query("SELECT p from Profile p where p.id = :id")
//Voici le code qui ne marche pas :
@Query(value = "SELECT * FROM PROFILE WHERE ID = :id", nativeQuery = true)
List<Profile> getProfileById(@Param("id") Long id);
List<Profile> findByAge(int age);
......
......@@ -36,15 +36,6 @@ public class ProfileResource {
return profiles;
}
@PUT
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Profile updateTotalyProfile(@PathParam("id") Long id, Profile p) {
p.setId(id);
return profileRepository.save(p);
}
@DELETE
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
......@@ -54,19 +45,21 @@ public class ProfileResource {
}
return Response.noContent().build();
}
/*//I dont think the Query I wrote in profile repository works...
//Voici le code qui ne marche pas :
@GET
@Path("{id}")
@Path("{id}/seeMod")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<Profile> getProfileById(@PathParam("id") Long id) {
List<Profile> profile = new ArrayList<>();
if (profileRepository.findById(id).isPresent()) {
profile = profileRepository.getProfileById(id);
Optional<Profile> optional = profileRepository.findById(id);
if (optional.isPresent()) {
profile.addAll(profileRepository.getProfileById(id));
}
return profile;
}
*/
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
......
......@@ -5,13 +5,9 @@ $(document).ready(function() {
let $listeProfilesSelect2 = $("#listProfilesSelect2");
let $listeMatches = $("#listMatches");
let $listeProfilesRegistered = $("#listProfiles");
//let $listeMyProfile= $("#myProfile");
let $selectLovers = $("#selectLovers");
let $selectLovers2 = $("#selectLovers2");
let $modifyFirstnameText = $("#firstname-modify");
let $modifyGenderButton = $("#modifyGender");
let $listModifiedProfile = $("#showModifiedProfile");
let $buttonSeeModifications = $("#seeModifications");
$.get("http://localhost:8080/api/profiles",function(resp){
resp.forEach( p => {
......@@ -61,7 +57,8 @@ $(document).ready(function() {
});
return false;
});
/*
/* //Voici une option d'avoir la possibilité de supprimer les lovers depuis la liste des options des lovers.
// Ca marche bien mais j'ai décidé de ne l'utiliser pas sur le site au final.
$listeLovers.on("click", "li button", function() {
let elemid = $(this).parent().attr('id');
let idLover = elemid.replace('lover-','');
......@@ -81,11 +78,13 @@ $(document).ready(function() {
});
});
*/
//Je ne sais pas pourquoi ça ne fonctionne pas ($('#seeModifications').click(function(){).
//Peut-être il y a une erreur dans profileRepository.java ou profileResource.java ?
$('#seeModifications').click(function(){
let idProfile = $listeProfilesSelect2.val();
$.ajax({
type: "GET",
url: "http://localhost:8080/api/profiles/"+idProfile,
url: "http://localhost:8080/api/profiles/"+idProfile+"/seeMod",
data: JSON.stringify(idProfile),
contentType: "application/json; charset=utf-8",
dataType: "json",
......@@ -231,7 +230,7 @@ $(document).ready(function() {
//$listeLovers.append(`<li id="lover-${lover.id}" class="list-group-item">${lover.partnerGender} - who likes ${lover.partnerPet} <button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete" >X</button></li>`);
}
/* Ajoute un élément li dans la liste de lovers*/
//Montre les modifications d'un profile dans une liste (pageModifyProfile) <= Ca ne marche pas pour moi...
function showModifiedProfile(profile) {
liToAppend4 = `<li id="${profile.id}" class="list-group-item">You are: ${profile.firstname} - age: ${profile.age} - gender: ${profile.gender} - who likes: ${profile.pet} - contact info: ${profile.contact}`;
profile.lovers.forEach( lover => liToAppend4+= ` - interested in: ${lover.partnerGender} - who likes ${lover.partnerPet}`);
......@@ -244,21 +243,21 @@ $(document).ready(function() {
$selectLovers.append(`<option value="${lover.id}">${lover.partnerGender} - who likes ${lover.partnerPet}</option>`);
$selectLovers2.append(`<option value="${lover.id}">${lover.partnerGender} - who likes ${lover.partnerPet}</option>`);
}
/* Ajoute un élément li pour selectionner dans la liste de profiles*/
/* Ajoute un élément li pour selectionner dans la liste de profiles (registerPage.html)*/
function appendToListProfiles(profile) {
liToAppend2 = `<li id="${profile.id}" class="list-group-item">You are: ${profile.firstname} - age: ${profile.age}`;
profile.lovers.forEach( lover => liToAppend2+= ` - interested in: ${lover.partnerGender} - who likes ${lover.partnerPet}`);
liToAppend2+= `</li>`;
$listeProfilesRegistered.append(liToAppend2);
}
/* Ajoute un élément li pour supprimer dans la liste de profiles*/
/* Ajoute un élément li pour supprimer dans la liste de profiles (pageDelete.html)*/
function appendToListProfileDelete(profile) {
liToAppend1 = `<li id="profile-${profile.id}" class="list-group-item">You are: ${profile.firstname} - age: ${profile.age}`;
profile.lovers.forEach( lover => liToAppend1+= ` - interested in: ${lover.partnerGender} - who likes ${lover.partnerPet}`);
liToAppend1+= ` <button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete" >X</button></li>`;
$listeProfilesDelete.append(liToAppend1);
}
/* Ajoute un élément li pour selectionner dans la liste de profiles*/
/* Ajoute un élément li pour selectionner dans la liste de profiles (pageFindMatches.html)*/
function appendToListProfileSelect(profile) {
liToAppend2 = `<li id="${profile.id}" class="list-group-item">You are: ${profile.firstname} - age: ${profile.age}`;
profile.lovers.forEach( lover => liToAppend2+= ` - interested in: ${lover.partnerGender} - who likes ${lover.partnerPet} <button id="${lover.id}" class="btn btn-success btn-xs" data-title="Select" data-toggle="modal" data-target="#select" >;)</button>`);
......@@ -266,7 +265,7 @@ $(document).ready(function() {
$listeProfilesSelect.append(liToAppend2);
}
/*Ajoute un élément option pour selectionner dans la liste de profiles*/
/*Ajoute un élément option pour selectionner dans la liste de profiles (pageModifyProfile.html)*/
function appendToListProfileSelect2(profile) {
optionToAppend = `<option value="${profile.id}">Name: ${profile.firstname} - age: ${profile.age} - gender: ${profile.gender} - who likes: ${profile.pet} - contact info: ${profile.contact}`;
profile.lovers.forEach( lover => optionToAppend+= ` - interested in: ${lover.partnerGender} - who likes ${lover.partnerPet}`);
......@@ -274,20 +273,12 @@ $(document).ready(function() {
$listeProfilesSelect2.append(optionToAppend);
}
/* Ajoute un élément li dans la liste de matches*/
/* Ajoute un élément li dans la liste de matches (pageFindMatches.html)*/
function appendToListMatches(profile) {
liToAppend = `<li id="profile-${profile.id}" class="list-group-item">Match name: ${profile.firstname} - age: ${profile.age} - gender: ${profile.gender} - who likes: ${profile.pet} - contact info: ${profile.contact}</li>`;
$listeMatches.append(liToAppend);
}
/* Ajoute un élément li dans la liste de matches
function appendToListMyProfile(profile) {
liToAppend = `<li id="profile-${profile.id}" class="list-group-item">name: ${profile.firstname} - age: ${profile.age} - gender: ${profile.gender} - who likes: ${profile.pet} - contact info: ${profile.contact}`;
profile.lovers.forEach( lover => liToAppend+= ` - interested in: ${lover.partnerGender} - who likes ${lover.partnerPet}`);
liToAppend+= `</li>`;
$listeMyProfile.append(liToAppend);
}*/
/* Ajout un lover à une profile existante*/
function addLoverToProfile(idProfile, idLover) {
$.ajax({
......
......@@ -11,7 +11,7 @@
<p><h1 style="color:deeppink; text-align: center;">Time to delete your profile!</h1></p>
<main>
<div class="form-group">
<label>Want to delete your profile ? Simply click on the red "X" button next to your profile :</label>
<label>Want to delete your profile ? Simply click on the "X" button next to your profile :</label>
<ul class= "list-group" id="listProfilesDelete">
</ul>
......
......@@ -10,12 +10,12 @@
<body style="background-color:honeydew; margin-left:10cm; margin-right:10cm;">
<p><h1 style="color:deeppink; text-align: center;">Time to find the love you are searching for!</h1></p>
<main>
<p>Find your profile and search for matches by clicking on your green ";)" button : </p>
<p>Find your profile and search for matches by clicking on the ";)" button : </p>
<ul class="list-group" id="listProfilesSelect">
</ul>
<p>Here are your matches : </p>
<p>Here are your matches (if any) : </p>
<ul class= "list-group" id="listMatches"></ul>
<p>Why not go ahead and contact them ? ;)</p>
<p>Feel free to contact anyone that you have matched with so that you can find love!</p>
</p>
<input type="button" id="goHome" name="homebtn" value="Go back to the home screen" class="btn btn-primary btn-sm" onclick="window.location.href='index.html'"/>
......
......@@ -25,6 +25,13 @@
<p><select id="selectLovers2"></select><input type="button" id="modifyLover" name="addbtn" value="Modify" class="btn btn-primary btn-sm"></p>
</div>
<!-- Voici le bouton qui ne marche pas pour montrer le profile après les modifications. J'ai essayé beaucoup avec
cette fonctionnalité mais je ne comprends pas pourquoi ça ne marche pas -->
<p>See your new profile now that you have made all your modifications: </p>
<p><input type="button" id="seeModifications" name="addbtn" value="Modified" class="btn btn-primary btn-sm"></p>
<ul class="list-group" id="showModifiedProfile">
</ul>
<input type="button" id="goHome" name="homebtn" value="Go back to the home screen" class="btn btn-primary btn-sm" onclick="window.location.href='index.html'"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="hello1.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment