mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-03-18 21:40:41 +01:00
End of refactor
This commit is contained in:
18
src/js/AJAX/alert.js
Normal file
18
src/js/AJAX/alert.js
Normal file
@@ -0,0 +1,18 @@
|
||||
console.log("alert.js loaded");
|
||||
|
||||
function displayAlert(text) {
|
||||
let alert = document.getElementById("Alert");
|
||||
alert.innerHTML = "";
|
||||
alert.innerHTML = `
|
||||
<div class="alert alert-success" role="alert">
|
||||
${text}
|
||||
</div>`;
|
||||
setTimeout(clearAlert, 5000);
|
||||
}
|
||||
|
||||
function clearAlert() {
|
||||
let alert = document.getElementById("Alert");
|
||||
alert.innerHTML = "";
|
||||
}
|
||||
|
||||
export {displayAlert};
|
||||
130
src/js/AJAX/home.js
Normal file
130
src/js/AJAX/home.js
Normal file
@@ -0,0 +1,130 @@
|
||||
import {TokenDecode} from "./lib.js";
|
||||
import {attachSearchEventListener, removeSearchTopBar} from "./search.js";
|
||||
import {displayAlert} from "./alert.js";
|
||||
import {attachLoginPraticienDisplayEventListener, attachLoginUserDisplayEventListener, attachDisconnectEventListener} from "./login.js";
|
||||
console.log("home.js loaded");
|
||||
|
||||
function displayHomeTopBar() {
|
||||
let topbar = document.getElementById("topbar");
|
||||
topbar.innerHTML = "";
|
||||
if(sessionStorage.getItem("token") === null) {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-praticien">Vous êtes praticien ?</button> <button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-user">Se connecter</button><p> </p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
attachLoginUserDisplayEventListener();
|
||||
attachLoginPraticienDisplayEventListener();
|
||||
}
|
||||
else {
|
||||
let token = sessionStorage.getItem("token");
|
||||
let user = TokenDecode(token);
|
||||
const mailMD5 = CryptoJS.MD5(user.mail);
|
||||
if(user.type === "patient") {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<img src="https://www.gravatar.com/avatar/${mailMD5}?s=64" alt="avatar" id="avatar" style="width: 14.3%; height: auto; border-radius: 50%">
|
||||
<div>
|
||||
<a class="text-white" id="user-name-disconect">${user.name} ${user.surname}</a>
|
||||
</div>
|
||||
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="my-rdv">Mes rendez-vous</p>
|
||||
</div>
|
||||
</div>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else if (user.type === "medecin") {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<img src="https://www.gravatar.com/avatar/${mailMD5}?s=64" alt="avatar" id="avatar" style="width: 14.3%; height: auto; border-radius: 50%">
|
||||
<div>
|
||||
<a class="text-white" id="user-name-disconect">${user.name} ${user.surname}</a>
|
||||
</div>
|
||||
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="my-rdv-medecin">Mes rendez-vous practicien</p>
|
||||
</div>
|
||||
</div>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<p class="alert-danger">Erreur</p>
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function displayHome(text) {
|
||||
removeSearchTopBar();
|
||||
displayHomeTopBar();
|
||||
let container = document.getElementById("content");
|
||||
container.classList = "";
|
||||
container.innerHTML = "";
|
||||
container.innerHTML = `
|
||||
<div style="background-color: red; height: 50vh;">
|
||||
<div class="d-flex justify-content-center align-items-center" style="background-color: red;" id="Alert"></div>
|
||||
<img src="src/img/img_index.png" alt="img_index" id="img_index">
|
||||
<div id="rdv">
|
||||
<p class="text-white fw-bold fs-3">Trouvez un rendez vous avec un medecin</p>
|
||||
<form action="" class="input-group" method="post">
|
||||
<input type="text" aria-label="First name" class="form-control" id="nom" name="nom" placeholder="Nom, spécialité">
|
||||
<input type="text" aria-label="Last name" class="form-control" id="postal" name="postal" placeholder="Où ?">
|
||||
<button class="btn btn-success" type="submit" id="recherche">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center gap-5 w-100" id="cardPos">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Ligue contre le cancer</h6>
|
||||
<p class="card-text">Mois sans tabac: c’est le moment d’arrêter !</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Pharmacie Sanchez</h6>
|
||||
<p class="card-text">Le rôle du phramacien évolue: Venez nous voir.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Doct’ISEN</h6>
|
||||
<p class="card-text">Un empechement: Prevenez votre soignant.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="fixed-bottom m-2 mx-4">
|
||||
<p>Recherche de praticiens</p>
|
||||
<p>Doct’ISEN, 33 QUATER Av. du Champ de Manœuvre, 44470 Carquefou</p>
|
||||
<p class="text-secondary">Conditions générales d'utilisation • Conditions d'utilisation du site Doct'ISEN • Politique relative à la protection des données personnelles • Politique en matière de cookies • Gestion des cookies et consentement • Règles de référencement • Mentions légales</p>
|
||||
<p class="text-secondary">Annuaire des médecins du CNOM • Annuaire des chirurgiens-dentistes de l'ONCD • Ordre National des Médecins • Ordre National des Chirurgiens-Dentistes</p>
|
||||
</footer>`;
|
||||
attachSearchEventListener();
|
||||
attachLoginUserDisplayEventListener();
|
||||
if(text !== ""){
|
||||
displayAlert(text);
|
||||
}
|
||||
}
|
||||
|
||||
export {displayHome, displayHomeTopBar};
|
||||
@@ -1,5 +1,6 @@
|
||||
import {attachSearchEventListener} from "./search.js";
|
||||
import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, disconnect, displayHome, displayHomeTopBar} from "./login.js";
|
||||
import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, attachDisconnectEventListener} from "./login.js";
|
||||
import {displayHome, displayHomeTopBar} from "./home.js";
|
||||
console.log("index.js loaded");
|
||||
|
||||
|
||||
@@ -23,16 +24,6 @@ function attachReturnHomeEventListener() {
|
||||
}
|
||||
}
|
||||
|
||||
function attachDisconnectEventListener() {
|
||||
try {
|
||||
document.getElementById("user-name-disconect").addEventListener("click", function (event) {
|
||||
disconnect();
|
||||
});
|
||||
} catch (e) {
|
||||
//Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Yanis Part
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import {TokenDecode} from "./lib";
|
||||
|
||||
import {displayHome, displayHomeTopBar} from "./home.js";
|
||||
console.log("login.js loaded");
|
||||
import {attachSearchEventListener, removeSearchTopBar} from "./search.js";
|
||||
|
||||
function displayLoginUser() {
|
||||
if (sessionStorage.getItem("token") === null) {
|
||||
@@ -332,142 +330,14 @@ function attachLoginPraticienDisplayEventListener() {
|
||||
}
|
||||
}
|
||||
|
||||
function displayHomeTopBar() {
|
||||
let topbar = document.getElementById("topbar");
|
||||
topbar.innerHTML = "";
|
||||
if(sessionStorage.getItem("token") === null) {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-praticien">Vous êtes praticien ?</button> <button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-user">Se connecter</button><p> </p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
attachLoginUserDisplayEventListener();
|
||||
attachLoginPraticienDisplayEventListener();
|
||||
}
|
||||
else {
|
||||
let token = sessionStorage.getItem("token");
|
||||
let user = TokenDecode(token);
|
||||
const mailMD5 = CryptoJS.MD5(user.mail);
|
||||
if(user.type === "patient") {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<img src="https://www.gravatar.com/avatar/${mailMD5}?s=64" alt="avatar" id="avatar" style="width: 14.3%; height: auto; border-radius: 50%">
|
||||
<div>
|
||||
<a class="text-white" id="user-name-disconect">${user.name} ${user.surname}</a>
|
||||
</div>
|
||||
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="my-rdv">Mes rendez-vous</p>
|
||||
</div>
|
||||
</div>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else if (user.type === "medecin") {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<img src="https://www.gravatar.com/avatar/${mailMD5}?s=64" alt="avatar" id="avatar" style="width: 14.3%; height: auto; border-radius: 50%">
|
||||
<div>
|
||||
<a class="text-white" id="user-name-disconect">${user.name} ${user.surname}</a>
|
||||
</div>
|
||||
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="my-rdv-medecin">Mes rendez-vous practicien</p>
|
||||
</div>
|
||||
</div>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<p class="alert-danger">Erreur</p>
|
||||
</div>`;
|
||||
}
|
||||
function attachDisconnectEventListener() {
|
||||
try {
|
||||
document.getElementById("user-name-disconect").addEventListener("click", function (event) {
|
||||
disconnect();
|
||||
});
|
||||
} catch (e) {
|
||||
//Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
function displayAlert(text) {
|
||||
let alert = document.getElementById("Alert");
|
||||
alert.innerHTML = "";
|
||||
alert.innerHTML = `
|
||||
<div class="alert alert-success" role="alert">
|
||||
${text}
|
||||
</div>`;
|
||||
setTimeout(clearAlert, 5000);
|
||||
}
|
||||
|
||||
function clearAlert() {
|
||||
let alert = document.getElementById("Alert");
|
||||
alert.innerHTML = "";
|
||||
}
|
||||
|
||||
function displayHome(text) {
|
||||
removeSearchTopBar();
|
||||
displayHomeTopBar();
|
||||
let container = document.getElementById("content");
|
||||
container.classList = "";
|
||||
container.innerHTML = "";
|
||||
container.innerHTML = `
|
||||
<div style="background-color: red; height: 50vh;">
|
||||
<div class="d-flex justify-content-center align-items-center" style="background-color: red;" id="Alert"></div>
|
||||
<img src="src/img/img_index.png" alt="img_index" id="img_index">
|
||||
<div id="rdv">
|
||||
<p class="text-white fw-bold fs-3">Trouvez un rendez vous avec un medecin</p>
|
||||
<form action="" class="input-group" method="post">
|
||||
<input type="text" aria-label="First name" class="form-control" id="nom" name="nom" placeholder="Nom, spécialité">
|
||||
<input type="text" aria-label="Last name" class="form-control" id="postal" name="postal" placeholder="Où ?">
|
||||
<button class="btn btn-success" type="submit" id="recherche">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center gap-5 w-100" id="cardPos">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Ligue contre le cancer</h6>
|
||||
<p class="card-text">Mois sans tabac: c’est le moment d’arrêter !</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Pharmacie Sanchez</h6>
|
||||
<p class="card-text">Le rôle du phramacien évolue: Venez nous voir.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Information</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Doct’ISEN</h6>
|
||||
<p class="card-text">Un empechement: Prevenez votre soignant.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="fixed-bottom m-2 mx-4">
|
||||
<p>Recherche de praticiens</p>
|
||||
<p>Doct’ISEN, 33 QUATER Av. du Champ de Manœuvre, 44470 Carquefou</p>
|
||||
<p class="text-secondary">Conditions générales d'utilisation • Conditions d'utilisation du site Doct'ISEN • Politique relative à la protection des données personnelles • Politique en matière de cookies • Gestion des cookies et consentement • Règles de référencement • Mentions légales</p>
|
||||
<p class="text-secondary">Annuaire des médecins du CNOM • Annuaire des chirurgiens-dentistes de l'ONCD • Ordre National des Médecins • Ordre National des Chirurgiens-Dentistes</p>
|
||||
</footer>`;
|
||||
attachSearchEventListener();
|
||||
attachLoginUserDisplayEventListener();
|
||||
if(text !== ""){
|
||||
displayAlert(text);
|
||||
}
|
||||
}
|
||||
|
||||
export {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, disconnect, displayHome, displayHomeTopBar};
|
||||
export {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, disconnect, attachDisconnectEventListener};
|
||||
@@ -1,5 +1,5 @@
|
||||
console.log("take-rdv.js loaded");
|
||||
import {displayHome} from "./login.js";
|
||||
import {displayHome} from "./home.js";
|
||||
|
||||
function displayRDVForDate(data) {
|
||||
let container = document.getElementById("rdv-list");
|
||||
|
||||
Reference in New Issue
Block a user