-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
230 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
body { | ||
background-image: url("../img/background.svg"); | ||
background-size: cover; | ||
background-position: center; | ||
background-repeat: repeat; | ||
padding: 0; | ||
margin : 0; | ||
} | ||
h1,h2, label{ | ||
color : #ffffff; | ||
} | ||
|
||
#mascotte404{ | ||
width: 50%; | ||
height: auto; | ||
margin-top: 10vh; | ||
} | ||
|
||
a{ | ||
color:white; | ||
text-decoration: none; | ||
} | ||
#logo{ | ||
color: #ffffff; | ||
text-decoration: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>BookWorm : Espace Administrateur</title> | ||
<meta charset="utf-8", lang="fr"> | ||
<link rel="stylesheet" href="../frameworks/bootstrap/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="../css/config.css"> | ||
</head> | ||
<body> | ||
<h1 class="logo" style="padding-top: 5vh; padding-left: 5vh;"><a id="logo" href="./">BookWorm</a></h3> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
<h1 class="logo" style="padding-top: 10vh;">Espace Administrateur</h1> | ||
<div class="d-flex justify-content-start" style="padding-left: 5vh; padding-top: 5vh;"> | ||
<div class="dropdown" style="padding-right: 5vh;"> | ||
<button id="selectTypeButton" class="btn btn-secondary dropdown-toggle" type="button" style="background-color: #FF8C42;" data-bs-toggle="dropdown" aria-expanded="false"> | ||
Parcourir | ||
</button> | ||
<ul class="dropdown-menu"> | ||
<li><a class="dropdown-item" id="selectLivre">Livres</a></li> | ||
<li><a class="dropdown-item" id="selectAuteur">Auteurs</a></li> | ||
<li><a class="dropdown-item" id="selectPointDeVente">Points de ventes</a></li> | ||
<li><a class="dropdown-item" id="selectEditeur">Editeurs</a></li> | ||
<li><a class="dropdown-item" id="selectUtilisateur">Utilisateurs</a></li> | ||
<li><a class="dropdown-item" id="selectUtilisateur">Emprunts</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<script src="../js/config.js"></script> | ||
<script src="../frameworks/popper.min.js"></script> | ||
<script src="../frameworks/bootstrap/js/bootstrap.min.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const API_URL = 'http://192.168.1.20:8080' | ||
|
||
fetch(`${API_URL}/isAdmin?email=${encodeURIComponent(email)}&password=${encodeURIComponent(password)}`) | ||
.then(response => response.json()) | ||
.then(data => { | ||
console.log(data); | ||
if (data.content === "success") { | ||
console.log("Admin") | ||
} else { | ||
window.location.href = "/login"; | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,117 @@ | ||
const API_URL = 'http://192.168.1.20:8080' | ||
|
||
var _template = " <div class='row justify-content-center'> \ | ||
<div class='col-md-10' style='padding-top: 3vh'>\ | ||
<div class='card mb-3'>\ | ||
<h2 class='card-header'></strong>{{ titre }}</h2>\ | ||
<div class='card-body'>\ | ||
<ul class='list-group list-group-flush'>\ | ||
<li class='list-group-item'><strong><a href='/search?search={{ auteur }}&type=Auteur'><h3>{{ auteur }}<h3></a></strong></li>\ | ||
<li class='list-group-item'><img class='img-fluid align-middle' style='width: 22%;' src='/img/stars/star{{ note }}.svg'><span class='align-middle'> ({{ NoteEx }})</span></li>\ | ||
<li class='list-group-item'>Date de parution : {{ dateDeParution }}</li>\ | ||
<li class='list-group-item'><italic>{{ genre }}</italic></li>\ | ||
<li class='list-group-item'>{{ description }}</li>\ | ||
<li class='list-group-item'>Format : {{ format }}</li>\ | ||
<li class='list-group-item'>En vente chez {{ pointDeVenteName }} ({{ pointDeVente }}) à {{ prix }} €</li>\ | ||
<li class='list-group-item'> Editeur : {{ editeur }}</li>\ | ||
</ul>\ | ||
</div>\ | ||
</div>\ | ||
</div>"; | ||
const API_URL = 'http://192.168.1.20:8080'; | ||
|
||
var _template = ` | ||
<div class='row justify-content-center'> | ||
<div class='col-md-10' style='padding-top: 3vh'> | ||
<div class='card mb-3'> | ||
<h2 class='card-header'>{{ titre }}</h2> | ||
<div class='card-body'> | ||
<ul class='list-group list-group-flush'> | ||
<li class='list-group-item'> | ||
<strong> | ||
<a href='/search?search={{ auteur }}&type=Auteur'> | ||
<h3>{{ auteur }}</h3> | ||
</a> | ||
</strong> | ||
</li> | ||
<li class='list-group-item'> | ||
<img class='img-fluid align-middle' style='width: 22%;' src='/img/stars/star{{ note }}.svg'> | ||
<span class='align-middle'> ({{ NoteEx }})</span> | ||
</li> | ||
<li class='list-group-item'>Date de parution : {{ dateDeParution }}</li> | ||
<li class='list-group-item'><i>{{ genre }}</i></li> | ||
<li class='list-group-item'>{{ description }}</li> | ||
<li class='list-group-item'>Format : {{ format }}</li> | ||
<li class='list-group-item'>En vente chez {{ pointDeVenteName }} ({{ pointDeVente }}) à {{ prix }} €</li> | ||
<li class='list-group-item'>Editeur : {{ editeur }}</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
async function loadLivre(isbn) { | ||
console.log("livre: ", isbn); | ||
let response = await fetch(`${API_URL}/getLivre?isbn=${isbn}`); | ||
let response = await fetch(`${API_URL}/getLivre?isbn=${isbn}`); | ||
let livreData = await response.json(); | ||
livreData = JSON.parse(livreData["content"]); | ||
console.log("livre: ", livreData); | ||
return livreData[isbn]; | ||
} | ||
|
||
const urlParams = new URLSearchParams(window.location.search); | ||
const isbn = urlParams.get('isbn'); | ||
|
||
loadLivre(isbn).then(livreData => { | ||
if (typeof livreData === 'object' && livreData !== null) { | ||
console.log("livreData: ", livreData); | ||
let template = _template.replace("{{ titre }}", livreData["titre"]).replace("{{ auteur }}", livreData["auteur"]).replace("{{ note }}", Math.round(livreData["note"])).replace("{{ isbn }}", livreData["isbn"]).replace("{{ dateDeParution }}", livreData["dateDeParution"]).replace("{{ genre }}", livreData["genre"]).replace("{{ description }}", livreData["description"]).replace("{{ format }}", livreData["format"]).replace("{{ pointDeVente }}", livreData["pointDeVente"]).replace("{{ prix }}", livreData["prix"]).replace("{{ editeur }}", livreData["editeur"]).replace("{{ pointDeVenteName }}", livreData["pointDeVenteName"]).replace("{{ auteur }}", livreData["auteur"]).replace("{{ NoteEx }}", livreData["note"]); | ||
if (livreData["status"] == "emprunté") { | ||
document.getElementById("reservation").innerHTML = "<img class='img-fluid mx-left d-block' style='width: 70%; padding-top: 2vh' src='img/{{ status }}.svg'>".replace("{{ status }}", "borrowed"); | ||
} else if (livreData["status"] == "disponible") { | ||
document.getElementById("reservation").innerHTML = "<img class='img-fluid mx-left d-block' style='width: 70%; padding-top: 2vh' src='img/{{ status }}.svg'>".replace("{{ status }}", "available"); | ||
} else if (livreData["status"] == "hors stock") { | ||
document.getElementById("reservation").innerHTML = "<img class='img-fluid mx-left d-block' style='width: 70%; padding-top: 2vh' src='img/{{ status }}.svg'>".replace("{{ status }}", "outOfStock"); | ||
} | ||
template = template.replace("{{ isbn }}", livreData[isbn]); | ||
document.getElementById("LivreInfo").innerHTML += template; | ||
console.log('img/livres/'+isbn+'.jpg') | ||
document.getElementById("imgLivre").src = `img/livres/${isbn}.jpg`; | ||
console.log("livreData: ", livreData); | ||
|
||
let template = _template | ||
.replace("{{ titre }}", livreData.titre) | ||
.replace("{{ auteur }}", livreData.auteur) | ||
.replace("{{ auteur }}", livreData.auteur) | ||
.replace("{{ note }}", Math.round(livreData.note)) | ||
.replace("{{ dateDeParution }}", livreData.dateDeParution) | ||
.replace("{{ genre }}", livreData.genre) | ||
.replace("{{ description }}", livreData.description) | ||
.replace("{{ format }}", livreData.format) | ||
.replace("{{ pointDeVente }}", livreData.pointDeVente) | ||
.replace("{{ prix }}", livreData.prix) | ||
.replace("{{ editeur }}", livreData.editeur) | ||
.replace("{{ pointDeVenteName }}", livreData.pointDeVenteName) | ||
.replace("{{ NoteEx }}", livreData.note); | ||
|
||
document.getElementById("LivreInfo").innerHTML += template; | ||
document.getElementById("imgLivre").src = `img/livres/${isbn}.jpg`; | ||
|
||
let status = ''; | ||
if (livreData.status === "emprunté") { | ||
status = "borrowed"; | ||
} else if (livreData.status === "disponible") { | ||
status = "available"; | ||
} else if (livreData.status === "hors stock") { | ||
status = "outOfStock"; | ||
} | ||
if (status) { | ||
document.getElementById("status").innerHTML = `<img class='img-fluid mx-left d-block' style='width: 70%; padding-top: 2vh' src='img/${status}.svg'>`; | ||
} | ||
|
||
if (livreData.status === "disponible") { | ||
document.getElementById("reserver").innerHTML = `<button class='btn btn-primary' style="background-color:#FF8C42;">Réserver</button>`; | ||
document.getElementById("reserver").addEventListener("click", function () { | ||
let decodedCookie = decodeURIComponent(document.cookie).split(';'); | ||
let email = '', password = ''; | ||
decodedCookie.forEach(c => { | ||
let cookie = c.trim(); | ||
if (cookie.startsWith('email=')) { | ||
email = cookie.substring('email='.length); | ||
} | ||
if (cookie.startsWith('password=')) { | ||
password = cookie.substring('password='.length); | ||
} | ||
}); | ||
|
||
fetch(`${API_URL}/checkLogin?email=${encodeURIComponent(email)}&password=${encodeURIComponent(password)}`) | ||
.then(response => response.json()) | ||
.then(data => { | ||
if (data.content === "success") { | ||
if (confirm("Êtes-vous sûr de vouloir réserver ce livre ?")) { | ||
fetch(`${API_URL}/reserveLivre?email=${encodeURIComponent(email)}&password=${encodeURIComponent(password)}&isbn=${isbn}`) | ||
.then(response => response.json()) | ||
.then(data => { | ||
if (data.content === "success") { | ||
window.location.href = "/login"; | ||
} else { | ||
alert("Erreur lors de la réservation"); | ||
} | ||
}); | ||
} | ||
} else { | ||
window.location.href = "/login"; | ||
} | ||
}) | ||
}); | ||
} | ||
else { | ||
document.getElementById("LivreInfo").innerHTML = "<br><h2 class='text-center' style='color:white'>Oups, aucun résultat n'a été trouvé.<h2><br><img id='mascotte404' class='img-fluid mx-auto d-block w-25' src='../img/error404.svg' alt='404'>"; | ||
} | ||
|
||
}); | ||
}) |