Merge pull request 'events' (#2) from events into master

Reviewed-on: #2
This commit is contained in:
v4l3n71n 2023-11-20 23:41:54 +01:00
commit ce4a2b077d
14 changed files with 1371 additions and 347 deletions

228
web/html/addevent.html Normal file
View File

@ -0,0 +1,228 @@
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.101.0">
<title>Dashboard Template · Bootstrap v5.2</title>
<link href="https://api.mapbox.com/mapbox-gl-js/v2.14.1/mapbox-gl.css" rel="stylesheet">
<link rel="stylesheet" href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.css" type="text/css">
<link href="../css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.css" rel="stylesheet" type="text/css" />
<!-- Favicons -->
<link rel="apple-touch-icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/apple-touch-icon.png" sizes="180x180">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
<link rel="manifest" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/manifest.json">
<link rel="mask-icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/safari-pinned-tab.svg" color="#712cf9">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon.ico">
<meta name="theme-color" content="#712cf9">
<script src="https://api.mapbox.com/mapbox-gl-js/v2.14.1/mapbox-gl.js"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify"></script>
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.polyfills.min.js"></script>
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
.b-example-divider {
height: 3rem;
background-color: rgba(0, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
}
.b-example-vr {
flex-shrink: 0;
width: 1.5rem;
height: 100vh;
}
.bi {
vertical-align: -.125em;
fill: currentColor;
}
.nav-scroller {
position: relative;
z-index: 2;
height: 2.75rem;
overflow-y: hidden;
}
.nav-scroller .nav {
display: flex;
flex-wrap: nowrap;
padding-bottom: 1rem;
margin-top: -1px;
overflow-x: auto;
text-align: center;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
</style>
<!-- Custom styles for this template -->
<link href="../css/dashboard.css" rel="stylesheet">
<link href="../css/style.css" rel="stylesheet">
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3 fs-6" href="/html/users.html"><- Retour à la liste</a>
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-nav">
<div class="nav-item text-nowrap">
<a class="nav-link px-3" id="signout" href="#">Deconnecté</a>
</div>
</div>
</header>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="position-sticky pt-3 sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/html/users.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Utilisateurs
</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/html/events.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Évènements
</a>
</li>
</ul>
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="alert alert-warning alert-dismissible hidden" id="notModifiedAlert" role="alert">
<div>Evènement non ajouté, car le pseudo ou l'adresse mail existe déjà</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-success alert-dismissible hidden" id="createUserAlert" role="alert">
<div>Vous avez créée l'évènement <span id="displayUser"></span></div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-warning alert-dismissible hidden" id="usernameExistAlert" role="alert">
<div>Pseudo déjà pris</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-warning alert-dismissible hidden" id="emailExistAlert" role="alert">
<div>Email déjà pris</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="notAuthorizedAlert" role="alert">
<div>Action non autorisée</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="forbiddenAlert" role="alert">
<div>Action interdite</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="internalServerAlert" role="alert">
<div>Erreur interne du serveur</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="syntaxAlert" role="alert">
<div>Erreur d'entrée dans le formulaire</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="unknownAlert" role="alert">
<div>Erreur inconnue</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Évènement</h1>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="nameUpdate">Nom</span>
<input id="nameUpdateInput" type="text" class="form-control" placeholder="Nom" aria-label="Pseudo" aria-describedby="nameUpdate">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="placeUpdate">Lieu</span>
<div id="placeUpdateInput"></div>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="organizersUpdate">Organisateurs</span>
<input id="organizersUpdateInput" type="text" class="form-control" placeholder="Organisateurs" aria-label="Organisateurs" aria-describedby="organizersUpdate">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="start_dateUpdate">Date de début de l'évènement</span>
<input id="start_dateUpdateInput" type="datetime-local" class="form-control" placeholder="Date de début de l'évènement" aria-label="Date de début de l'évènement" aria-describedby="start_dateUpdate">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="end_dateUpdate">Date de fin de l'évènement</span>
<input id="end_dateUpdateInput" type="datetime-local" class="form-control" placeholder="Date de fin de l'évènement" aria-label="Date de fin de l'évènement" aria-describedby="end_dateUpdate">
</div>
<div class="d-grid gap-2 col-6 mx-auto">
<button type="button" class="btn btn-success" id="addUser">Ajouter l'évènement</button>
</div>
</main>
</div>
</div>
<script src="../js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<script src="../js/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
<script src="../js/config.js"></script>
<script src="../js/library.js"></script>
<script src="../js/geosearch.js"></script>
<script src="../js/addItem.js"></script>
<script src="../js/tags.js"></script>
</body></html>

View File

@ -27,6 +27,7 @@
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<style>
.bd-placeholder-img {
font-size: 1.125rem;
@ -109,7 +110,12 @@
Utilisateurs
</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/html/events.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Évènements
</a>
</li>
</ul>
@ -227,5 +233,5 @@
<script src="../js/config.js"></script>
<script src="../js/library.js"></script>
<script src="../js/addUser.js"></script>
<script src="../js/addItem.js"></script>
</body></html>

364
web/html/event.html Normal file
View File

@ -0,0 +1,364 @@
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.101.0">
<title>Dashboard Template · Bootstrap v5.2</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.2/examples/dashboard/">
<link rel="stylesheet" href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.css" type="text/css">
<link href="../css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.css" rel="stylesheet" type="text/css" />
<!-- Favicons -->
<link rel="apple-touch-icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/apple-touch-icon.png" sizes="180x180">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
<link rel="manifest" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/manifest.json">
<link rel="mask-icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/safari-pinned-tab.svg" color="#712cf9">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon.ico">
<meta name="theme-color" content="#712cf9">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/v2.14.1/mapbox-gl.js"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify"></script>
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.polyfills.min.js"></script>
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
.b-example-divider {
height: 3rem;
background-color: rgba(0, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
}
.b-example-vr {
flex-shrink: 0;
width: 1.5rem;
height: 100vh;
}
.bi {
vertical-align: -.125em;
fill: currentColor;
}
.nav-scroller {
position: relative;
z-index: 2;
height: 2.75rem;
overflow-y: hidden;
}
.nav-scroller .nav {
display: flex;
flex-wrap: nowrap;
padding-bottom: 1rem;
margin-top: -1px;
overflow-x: auto;
text-align: center;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
</style>
<!-- Custom styles for this template -->
<link href="../css/dashboard.css" rel="stylesheet">
<link href="../css/style.css" rel="stylesheet">
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3 fs-6" href="/html/users.html"><- Retour à la liste</a>
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-nav">
<div class="nav-item text-nowrap">
<a class="nav-link px-3" id="signout" href="#">Deconnecté</a>
</div>
</div>
</header>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="position-sticky pt-3 sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/html/users.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Utilisateurs
</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/html/events.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Évènements
</a>
</li>
</ul>
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="alert alert-warning alert-dismissible hidden" id="notModifiedAlert" role="alert">
<div>Évènement non modifié</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="notAuthorizedAlert" role="alert">
<div>Création d'évènement non autorisée avec ce compte</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="forbiddenAlert" role="alert">
<div>Action interdite</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="noContentAlert" role="alert">
<div>Évènement non modifié</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="internalServerAlert" role="alert">
<div>Erreur interne du serveur</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="unknownAlert" role="alert">
<div>Erreur inconnue</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="usernameAlert" role="alert">
<div>Champ pseudo vide</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="emailAlert" role="alert">
<div>Champ email vide</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="firstNameAlert" role="alert">
<div>Champ prenom vide</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="nameAlert" role="alert">
<div>Champ nom vide</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Évènement</h1>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="idUpdate">ID</span>
<input id="idUpdateInput" type="text" class="form-control" placeholder="" aria-label="Id" aria-describedby="idUpdate" disabled>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="nameUpdate">Nom</span>
<input id="nameUpdateInput" type="text" class="form-control" placeholder="Nom" aria-label="Nom" aria-describedby="nameUpdate">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="placeUpdate">Lieu</span>
<div id="placeUpdateInput"></div>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="organizersUpdate">Organisateurs</span>
<input id="organizersUpdateInput" type="text" class="form-control" placeholder="Organisateurs" aria-label="Organisateurs" aria-describedby="organizersUpdate">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="start_dateUpdate">Date de début</span>
<input id="start_dateUpdateInput" type="datetime-local" class="form-control" placeholder="Date de début" aria-label="Date de début" aria-describedby="start_dateUpdate">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="start_dateUpdate">Date de fin</span>
<input id="end_dateUpdateInput" type="datetime-local" class="form-control" placeholder="Date de fin" aria-label="Date de fin" aria-describedby="start_dateUpdate">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="connected_atUpdate">Dernière connexion</span>
<input id="connected_atUpdateInput" type="text" class="form-control" placeholder="" aria-label="Dernière connexion" aria-describedby="connected_atUpdate" disabled>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="created_atUpdate">Date de création</span>
<input id="created_atUpdateInput" type="text" class="form-control" placeholder="" aria-label="Date de création" aria-describedby="created_atUpdate" disabled>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="updated_atUpdate">Date de mise à jour</span>
<input id="updated_atUpdateInput" type="text" class="form-control" placeholder="" aria-label="Date de mise à jour" aria-describedby="updated_atUpdate" disabled>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="disabled_atUpdate">Date de désactivation</span>
<input id="disabled_atUpdateInput" type="text" class="form-control" placeholder="" aria-label="Date de désactivation" aria-describedby="disabled_atUpdate" disabled>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="deleted_atUpdate">Date de suppression</span>
<input id="deleted_atUpdateInput" type="text" class="form-control" placeholder="" aria-label="Date de suppression" aria-describedby="deleted_atUpdate" disabled>
</div>
<div class="input-group mb-3">
<label class="input-group-text" for="statusSelector">Statut</label>
<select class="form-select" id="statusSelector" disabled>
<option value="-2" selected>Statut</option>
<option value="-1">En cours de suppression</option>
<option value="0">Desactivé</option>
<option value="1">Activé</option>
<option value="2">En attente de validation</option>
</select>
</div>
<div class="d-grid gap-2 col-6 mx-auto">
<button type="button" class="btn btn-success hidden" id="enableUser" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'évènement</button>
<button type="button" class="btn btn-success hidden" id="cancelUser" data-bs-toggle="modal" data-bs-target="#cancelUserModal">Annuler la suppression de l'évènement</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateUserModal">Mettre à jour l'évènement</button>
<button type="button" class="btn btn-warning hidden" id="disableUser" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'évènement</button>
<button type="button" class="btn btn-danger" id="removeUser" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'évènement</button>
</div>
<div class="modal fade" id="updateUserModal" tabindex="-1" aria-labelledby="updateUserModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="updateUserModalLabel">Mettre à jour l'utilisateur</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Voulez-vous mettre à jour l'utilisateur ?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
<button type="button" class="btn btn-primary" id="updateUserButton">Mettre à jour</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="disableUserModal" tabindex="-1" aria-labelledby="disableUserModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="disableUserModalLabel">Désactiver l'utilisateur</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Voulez-vous désactiver l'évènement ?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
<button type="button" class="btn btn-warning" id="disableUserButton">Désactiver</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="removeUserModal" tabindex="-1" aria-labelledby="removeUserModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="updateUserModalLabel">Supprimer l'utilisateur</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Etes-vous sûr de supprimer l'évènement ?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
<button type="button" class="btn btn-danger" id="removeUserButton">Supprimer</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="enableUserModal" tabindex="-1" aria-labelledby="enableUserModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="enableUserModalLabel">Activer l'utilisateur</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Voulez-vous activer l'évènement ?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
<button type="button" class="btn btn-success" id="enableUserButton">Activer</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="cancelUserModal" tabindex="-1" aria-labelledby="cancelUserModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="cancelUserModalLabel">Annuler la suppression de l'utilisateur</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Voulez-vous annuler la suppression de l'évènement ?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
<button type="button" class="btn btn-success" id="cancelUserButton">Annuler la suppression de l'évènement</button>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
<script src="../js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<script src="../js/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
<script src="../js/config.js"></script>
<script src="../js/library.js"></script>
<script src="../js/geosearch.js"></script>
<script src="../js/item.js"></script>
<script src="../js/tags.js"></script>
</body></html>

217
web/html/events.html Normal file
View File

@ -0,0 +1,217 @@
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.101.0">
<title>Dashboard Template · Bootstrap v5.2</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.2/examples/dashboard/">
<link href="../css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- Favicons -->
<link rel="apple-touch-icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/apple-touch-icon.png" sizes="180x180">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
<link rel="manifest" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/manifest.json">
<link rel="mask-icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/safari-pinned-tab.svg" color="#712cf9">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon.ico">
<meta name="theme-color" content="#712cf9">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
.b-example-divider {
height: 3rem;
background-color: rgba(0, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
}
.b-example-vr {
flex-shrink: 0;
width: 1.5rem;
height: 100vh;
}
.bi {
vertical-align: -.125em;
fill: currentColor;
}
.nav-scroller {
position: relative;
z-index: 2;
height: 2.75rem;
overflow-y: hidden;
}
.nav-scroller .nav {
display: flex;
flex-wrap: nowrap;
padding-bottom: 1rem;
margin-top: -1px;
overflow-x: auto;
text-align: center;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
}
</style>
<!-- Custom styles for this template -->
<link href="../css/dashboard.css" rel="stylesheet">
<link href="../css/style.css" rel="stylesheet">
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3 fs-6" href="#">Company name</a>
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<input class="form-control form-control-dark w-100 rounded-0 border-0" id=searchUser type="text" placeholder="Search" aria-label="Search">
<div class="navbar-nav">
<div class="nav-item text-nowrap">
<a class="nav-link px-3" id="signout" href="#">Deconnecté</a>
</div>
</div>
</header>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="position-sticky pt-3 sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/html/users.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Utilisateurs
</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Évènements
</a>
</li>
</ul>
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Évènements</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group me-2">
<button type="button" id=addUser class="btn btn-sm btn-outline-secondary">Ajouter un évènement</button>
</div>
</div>
</div>
<h2>Liste d'évènement</h2>
<div class="table-responsive">
<div class="row g-3">
<div class="col-auto">
<label for="inputStatus" class="form-label">Statut</label>
<select class="form-select" id="inputStatus" aria-label="Default select example">
<option value="-2" selected>Tout</option>
<option value="-1">En cours de suppression</option>
<option value="0">Desactivé</option>
<option value="1">Activé</option>
<option value="2">En cours de validation</option>
</select>
</div>
<div class="col-auto">
<label for="inputPages" class="form-label">Page :</label>
<select class="form-select" id="inputPages" aria-label="Page">
<option value="20" selected>20</option>
<option value="40">40</option>
<option value="60">60</option>
<option value="80">80</option>
<option value="100">100</option>
</select>
</div>
</div>
</div>
<br />
<button type="button" class="btn btn-success" id="enableUserButton" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'évènement</button>
<button type="button" class="btn btn-warning " id="disableUserButton" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'évènement</button>
<button type="button" class="btn btn-danger" id="removeUserButton" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'évènement</button>
<br /><br /><br />
<table id=users class="table table-striped table-sm">
<thead>
<tr>
<th><input type="checkbox" id="checkboxPrincipal" aria-label="Checkbox for following text input"></th>
<th scope="col">ID</th>
<th scope="col">Nom</th>
<th scope="col">Lieu</th>
<th scope="col">Date de début</th>
<th scope="col">Date de fin</th>
<th scope="col">Statut</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" class="checkboxList" userid="" aria-label="Checkbox for following text input"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><span class="activeStatus hidden">Activé</span><span class="disableStatus hidden">Désactivé</span><span class="confirmStatus hidden">En attente de confirmation</span><span class="removeStatus hidden">En attente de suppression</span><span class="unknownStatus hidden">Statut inconnu</span></td>
<td><button type="button" class="btn btn-primary" data-bs-toggle="modal" userid="" data-bs-target="#updateUserModal">Modifier</button></td>
</tr>
</tbody>
</table>
<nav aria-label="Page navigation" class="hidden" id="page">
<ul class="pagination justify-content-center">
<li class="page-item disabled" id="previousPage"><a class="page-link" href="#" tabindex="-1" aria-disabled="true">Précédent</a></li>
<li class="page-item"><a class="page-link" href="/html/users.html?page=1">1</a></li>
<li class="page-item" id="nextPage"> <a class="page-link" href="#">Suivant</a></li>
</ul>
</div>
</main>
</div>
</div>
<script src="../js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<script src="../js/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
<script src="../js/config.js"></script>
<script src="../js/library.js"></script>
<script src="../js/lists.js"></script>
</body></html>

View File

@ -110,6 +110,13 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/html/events.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Évènements
</a>
</li>
</ul>
@ -234,6 +241,11 @@
<input id="updated_atUpdateInput" type="text" class="form-control" placeholder="" aria-label="Date de mise à jour" aria-describedby="updated_atUpdate" disabled>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="disabled_atUpdate">Date de désactivation</span>
<input id="disabled_atUpdateInput" type="text" class="form-control" placeholder="" aria-label="Date de désactivation" aria-describedby="disabled_atUpdate" disabled>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="deleted_atUpdate">Date de suppression</span>
<input id="deleted_atUpdateInput" type="text" class="form-control" placeholder="" aria-label="Date de suppression" aria-describedby="deleted_atUpdate" disabled>
@ -357,5 +369,5 @@
<script src="../js/config.js"></script>
<script src="../js/library.js"></script>
<script src="../js/user.js"></script>
<script src="../js/item.js"></script>
</body></html>

View File

@ -112,9 +112,12 @@
Utilisateurs
</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/html/events.html">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home align-text-bottom" aria-hidden="true"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
Évènements
</a>
</li>
</ul>
@ -138,7 +141,7 @@
<div class="row g-3">
<div class="col-auto">
<label for="inputRoles" class="form-label">Roles</label>
<label for="inputRoles" class="form-label">Rôle :</label>
<select class="form-select" id="inputRoles" aria-label="Default select example">
<option value="All" selected>Tout</option>
<option value="Admin">Administrateurs</option>
@ -146,7 +149,7 @@
</select>
</div>
<div class="col-auto">
<label for="inputStatus" class="form-label">Statut</label>
<label for="inputStatus" class="form-label">Statut :</label>
<select class="form-select" id="inputStatus" aria-label="Default select example">
<option value="-2" selected>Tout</option>
<option value="-1">En cours de suppression</option>
@ -155,13 +158,30 @@
<option value="2">En cours de validation</option>
</select>
</div>
</div>
<br />
<button type="button" class="btn btn-success" id="enableUserButton" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'utilisateur</button>
<button type="button" class="btn btn-warning " id="disableUserButton" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'utilisateur</button>
<button type="button" class="btn btn-danger" id="removeUserButton" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'utilisateur</button>
<br /><br /><br />
<div class="col-auto">
<label for="inputPages" class="form-label">Page :</label>
<select class="form-select" id="inputPages" aria-label="Page">
<option value="20" selected>20</option>
<option value="40">40</option>
<option value="60">60</option>
<option value="80">80</option>
<option value="100">100</option>
</select>
</div>
</div>
<br /><br />
<div class="row g-3">
<div class="col-auto">
<button type="button" class="btn btn-success" id="enableUserButton" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'utilisateur</button>
</div>
<div class="col-auto">
<button type="button" class="btn btn-warning " id="disableUserButton" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'utilisateur</button>
</div>
<div class="col-auto">
<button type="button" class="btn btn-danger" id="removeUserButton" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'utilisateur</button>
</div>
</div>
<br /><br /><br />
<table id=users class="table table-striped table-sm">
<thead>
<tr>
@ -206,5 +226,5 @@
<script src="../js/config.js"></script>
<script src="../js/library.js"></script>
<script src="../js/users.js"></script>
<script src="../js/lists.js"></script>
</body></html>

145
web/js/addItem.js Normal file
View File

@ -0,0 +1,145 @@
checkToken();
signOut();
closeButton();
pathURL = document.location.pathname.split("/")[document.location.pathname.split("/").length-1].split(".")[0].replace("add","")
if (pathURL == "event"){
lastdate = new Date();
document.getElementById("start_dateUpdateInput").value=lastdate.getFullYear()+"-"+lastdate.getMonth()+"-"+lastdate.getDate()+"T00:00";
document.getElementById("end_dateUpdateInput").value=lastdate.getFullYear()+"-"+lastdate.getMonth()+"-"+lastdate.getDate()+"T06:00";
}
document.getElementById("addUser").addEventListener("click", function(){
switch (pathURL){
case "user":
var updateProfil = ["username", "email", "firstName", "birth", "password"];
break;
case "event":
var updateProfil = ["name", "place", "start_date", "end_date"];
break;
default:
var updateProfil = []
break;
}
var updateOk = true;
for (var i=0; i<updateProfil.length; i++){
if(updateProfil[i] == "place"){
size = document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value.length
} else {
size= document.getElementById(updateProfil[i]+"UpdateInput").value.length
}
if(size == 0){
updateOk = false;
document.getElementById(updateProfil[i]+"Alert").classList.remove("hidden");
}
}
if(updateOk){
var selector = { "roles": ""};
var listSelector = [ "roles"];
for (var i=0; i<listSelector.length; i++){
var options = document.querySelectorAll("#"+listSelector[i]+"Selector option");
for (var j=0; j<options.length; j++){
if(options[j].selected){
selector[listSelector[i]] = options[j].value;
}
}
}
switch(pathURL){
case "user":
dataPut = {
"username": document.getElementById("usernameUpdateInput").value,
"email": document.getElementById("emailUpdateInput").value,
"name": document.getElementById("nameUpdateInput").value,
"firstName": document.getElementById("firstNameUpdateInput").value,
"birth": document.getElementById("birthUpdateInput").value,
"password": document.getElementById("passwordUpdateInput").value,
"roles": selector["roles"]
};
break;
case "event":
organizers = []
listValue = JSON.parse(document.getElementById("organizersUpdateInput").value)
for (var i=0; i<listValue.length; i++){
organizers.push(listValue[i]["value"])
}
dataPut = {
"name": document.getElementById("nameUpdateInput").value,
"place": document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value,
"start_date": document.getElementById("start_dateUpdateInput").value,
"end_date": document.getElementById("end_dateUpdateInput").value,
"organizers":organizers,
"latitude": document.getElementById("placeUpdateInput").getAttribute("data-latitude"),
"longitude": document.getElementById("placeUpdateInput").getAttribute("data-longitude")
};
break;
default:
dataPut = {};
break;
}
instance({
method : "put",
url:pathURL+"s",
withCredentials: true,
data: dataPut
}).then(function(response){
var idAlert = "";
switch(response.status){
case 201:
idAlert="createUser"
switch (pathURL){
case "user":
input = "username";
break;
case "event":
input = "name";
break;
default:
input = "";
break;
}
var user = document.getElementById(input+"UpdateInput").value;
if(user.length > 0){
document.getElementById("displayUser").textContent=user;
}
break;
case 204:
idAlert="notModified"
break;
default:
idAlert="unknown";
break
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
}).catch(function(error){
console.log(error);
switch(error.status){
case 401:
listExist = [ "username", "email" ];
for(var i=0; i<listExist.length; i++){
if(error.response.data[listExist[i]]){
document.getElementById(listExist[i]+"ExistAlert").classList.remove("hidden");
}1
}
idAlert="notAuthorized";
break;
case 403:
idAlert="forbidden";
break;
case 403:
idAlert="syntaxe";
break;
case 500:
idAlert="internalServer";
break;
default:
idAlert="unknown";
break;
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
});
}
});

View File

@ -1,97 +0,0 @@
checkToken();
signOut();
closeButton();
document.getElementById("addUser").addEventListener("click", function(){
var updateProfil = ["username", "email", "firstName", "birth", "password"];
var updateOk = true;
for (var i=0; i<updateProfil.length; i++){
if(document.getElementById(updateProfil[i]+"UpdateInput").value.length == 0){
updateOk = false;
document.getElementById(updateProfil[i]+"Alert").classList.remove("hidden");
}
}
if(updateOk){
var selector = { "roles": ""};
var listSelector = [ "roles"];
for (var i=0; i<listSelector.length; i++){
var options = document.querySelectorAll("#"+listSelector[i]+"Selector option");
for (var j=0; j<options.length; j++){
if(options[j].selected){
selector[listSelector[i]] = options[j].value;
}
}
}
dataPut = {
"id": "",
"username": document.getElementById("usernameUpdateInput").value,
"email": document.getElementById("emailUpdateInput").value,
"name": document.getElementById("nameUpdateInput").value,
"firstName": document.getElementById("firstNameUpdateInput").value,
"birth": document.getElementById("birthUpdateInput").value,
"status": 1,
"password": document.getElementById("passwordUpdateInput").value,
"roles": selector["roles"],
"created_at": "",
"updated_at": "",
"deleted_at": "",
"connected_at": ""
}
instance({
method : "put",
url:"users",
withCredentials: true,
data: dataPut
}).then(function(response){
var idAlert = "";
switch(response.status){
case 201:
idAlert="createUser"
var user = document.getElementById("usernameUpdateInput").value;
if(user.length > 0){
document.getElementById("displayUser").textContent=user;
}
break;
case 204:
idAlert="notModified"
break;
default:
idAlert="unknown";
break
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
}).catch(function(error){
console.log(error);
switch(error.response.status){
case 401:
listExist = [ "username", "email" ];
for(var i=0; i<listExist.length; i++){
if(error.response.data[listExist[i]]){
document.getElementById(listExist[i]+"ExistAlert").classList.remove("hidden");
}
}
idAlert="notAuthorized";
break;
case 403:
idAlert="forbidden";
break;
case 403:
idAlert="syntaxe";
break;
case 500:
idAlert="internalServer";
break;
default:
idAlert="unknown";
break;
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
});
}
});

20
web/js/geosearch.js Normal file
View File

@ -0,0 +1,20 @@
mapboxgl.accessToken = 'pk.eyJ1IjoidmFsY3plODAiLCJhIjoiY2xpY2FhOTM5MGxwczNrdGV6a2J1Z2Q4diJ9.I_WRpX1aO4z32ajcE2Ef7A';
const geocoder = new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
types: 'country,region,place,postcode,locality,neighborhood,poi'
});
geocoder.addTo('#placeUpdateInput');
place = document.getElementById("placeUpdateInput");
geocoder.on("result", (e) => {
place.setAttribute("data-latitude", e.result.center[1]);
place.setAttribute("data-longitude", e.result.center[0]);
});
geocoder.on("clear", () => {
place.setAttribute("data-latitude", "");
place.setAttribute("data-longitude", "");
});

266
web/js/item.js Normal file
View File

@ -0,0 +1,266 @@
checkToken();
signOut();
closeButton();
pathURL = document.location.pathname.split("/")[document.location.pathname.split("/").length-1].split(".")[0]
var id = getQuery("id");
if(id.length > 0){
instance.get(pathURL + "s/"+id, {withCredentials: true})
.then(function(response){
switch(pathURL){
case "user":
var listValue = [ "id", "username", "name", "firstName", "email", "birth"];
break;
case "event":
var listValue = [ "id", "name", "organizers", "place", "start_date", "end_date"];
break;
default:
var listValue = []
break;
}
var listTime = ["connected_at", "created_at", "updated_at", "deleted_at", "disabled_at"];
for (var i=0; i<listValue.length; i++){
if(response.data[listValue[i]] != null){
switch(listValue[i]){
case "place":
document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value = response.data[listValue[i]];
document.getElementById("placeUpdateInput").setAttribute("data-latitude", response.data["latitude"]);
document.getElementById("placeUpdateInput").setAttribute("data-longitude", response.data["longitude"])
break;
case "organizers":
if (response.data[listValue[i]].length > 0 ){
listOrga = []
for (var j=0; j<response.data[listValue[i]].length; j++){
listOrga.push({"value":response.data[listValue[i]][j]});
}
valueJson = JSON.stringify(listOrga);
document.getElementById(listValue[i]+"UpdateInput").value=valueJson;
}
break;
default:
document.getElementById(listValue[i]+"UpdateInput").value=response.data[listValue[i]];
break;
}
}
}
for (var i=0; i<listTime.length; i++){
if(response.data[listTime[i]] != null){
document.getElementById(listTime[i]+"UpdateInput").value=new Date(response.data[listTime[i]]).toLocaleString();
}
}
var listSelector = ["roles", "status"];
for (var i=0; i<listSelector.length; i++){
if (document.getElementById(listSelector[i]+"Selector") != null){
var select = document.getElementById(listSelector[i]+"Selector").querySelectorAll("option");
for (var j=0; j<select.length; j++){
if(select[j].value == response.data[listSelector[i]]){
select[j].setAttribute("selected", true);
}
}
}
}
var buttonUser = "";
switch(response.data.status){
case 1:
buttonUser = "disableUser";
break;
case 2:
buttonUser = "enableUser";
break;
case -1:
buttonUser = "cancelUser";
document.getElementById("removeUser").classList.add("hidden");
break;
case 0:
buttonUser = "enableUser";
break;
default:
break;
}
if(buttonUser.length > 0){
document.getElementById(buttonUser).classList.remove("hidden");
}
var listModalButton = ["disable", "enable", "cancel", "remove"];
for (var i=0; i<listModalButton.length; i++){
document.getElementById(listModalButton[i]+"UserButton").addEventListener("click", function(e){
var httpMethod = ""
var httpUrl = "";
var idInput = document.getElementById("idUpdateInput").value;
switch(e.currentTarget.id){
case "disableUserButton":
httpMethod = "delete";
httpUrl = pathURL + "s/"+idInput;
break;
case "removeUserButton":
httpMethod = "delete";
httpUrl = pathURL + "s/"+idInput+"?remove=true";
break;
default:
httpMethod = "patch";
httpUrl = pathURL + "s/"+idInput;
break;
}
instance({
method: httpMethod,
url: httpUrl,
withCredentials: true
})
.then(function(response){
if(response.status == 200){
location.href="/html/"+pathURL+".html?id="+idInput;
}
})
.catch(function(error){
console.log(error);
});
});
}
})
.catch(function(error){
console.log(error);
});
document.getElementById("updateUserButton").addEventListener("click", function(){
switch(pathURL){
case "user":
var updateProfil = [ "id", "username", "name", "firstName", "email", "birth"];
break;
case "event":
var updateProfil = [ "id", "name", "place", "organizers", "start_date", "end_date"];
break;
default:
var updateProfil = []
break;
}
var updateOk = true;
for (var i=0; i<updateProfil.length; i++){
switch(updateProfil[i]){
case "place":
size = document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value.length;
break;
case "organizers":
organizers = [];
listValue = JSON.parse(document.getElementById("organizersUpdateInput").value)
for (var J=0; J<listValue.length; J++){
organizers.push(listValue[J]["value"])
}
break;
default:
size = document.getElementById(updateProfil[i]+"UpdateInput").value.length;
break;
}
if(size == 0){
updateOk = false;
document.getElementById(updateProfil[i]+"Alert").classList.remove("hidden");
}
}
if(updateOk){
var selector = { "roles": "", "status": 0};
var listSelector = [ "roles", "status"];
for (var i=0; i<listSelector.length; i++){
var options = document.querySelectorAll("#"+listSelector[i]+"Selector option");
for (var j=0; j<options.length; j++){
if(options[j].selected){
selector[listSelector[i]] = options[j].value;
}
}
}
switch (pathURL){
case "user":
dataPut = {
"id": document.getElementById("idUpdateInput").value,
"username": document.getElementById("usernameUpdateInput").value,
"email": document.getElementById("emailUpdateInput").value,
"name": document.getElementById("nameUpdateInput").value,
"firstName": document.getElementById("firstNameUpdateInput").value,
"birth": document.getElementById("birthUpdateInput").value,
"status": selector["status"],
"password": document.getElementById("passwordUpdateInput").value,
"roles": selector["roles"],
"created_at": "",
"updated_at": "",
"deleted_at": "",
"disabled_at":"",
"connected_at": ""
};
break;
case "event":
dataPut = {
"id": document.getElementById("idUpdateInput").value,
"name": document.getElementById("nameUpdateInput").value,
"place": document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value,
"latitude": document.getElementById("placeUpdateInput").getAttribute("data-latitude"),
"longitude": document.getElementById("placeUpdateInput").getAttribute("data-longitude"),
"start_date": document.getElementById("start_dateUpdateInput").value,
"end_date": document.getElementById("end_dateUpdateInput").value,
"status": selector["status"],
"organizers":organizers,
"created_at": "",
"updated_at": "",
"deleted_at": "",
"disabled_at":"",
};
break;
default:
datePut = {};
break;
}
instance({
method : "put",
url:pathURL+"s/"+document.getElementById("idUpdateInput").value,
withCredentials: true,
data: dataPut
}).then(function(response){
var idAlert = "";
switch(response.status){
case 200:
location.reload();
break;
case 304:
idAlert="noContent";
break;
default:
idAlert="unknown";
break;
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
}).catch(function(error){
var idAlert = "";
switch(error.status){
case 401:
idAlert="notAuthorized";
break;
case 403:
idAlert="forbidden";
break;
case 500:
idAlert="internalServer";
break;
default:
idAlert="unknown";
break;
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
});
}
});
}

View File

@ -21,44 +21,53 @@ function checkToken(){
}
function buildParam(e, id){
function buildParam(typeInput){
var search = document.getElementById("searchUser").value;
var param = "";
var listParam = ["page", "nbPages"];
if(id.length > 0){
var select = document.getElementById(id);
var getId = select.options[select.selectedIndex].value;
if(id == "inputRoles"){
var status = e.target.value;
if(status != "-2"){
param = param + "status="+status+"&";
}
if(getId != "All"){
param = param + "roles="+getId;
var listParam = ["skip"];
if(typeInput.length > 0){
listId =["inputRoles", "inputStatus", "inputPages"]
for (var i=0; i<listId.length; i++) {
var select = document.getElementById(listId[i]);
if (select != null){
var getId = select.options[select.selectedIndex].value;
switch (listId[i])
{
case "inputRoles":
if (getId != "All"){
param = param + "roles=" + getId + "&";
}
break;
case "inputStatus":
if (getId != "-2"){
param = param + "status=" + getId + "&";
}
break;
case "inputPages":
param = param + "limit=" + getId + "&";
break;
default:
break;
}
}
}
if(id == "inputStatus"){
var roles = e.target.value;
if(getId != "-2"){
param = param + "status="+getId+"&";
}
if(roles != "All"){
param = param + "roles="+roles+"&";
}
}
} else {
listParam.push("roles");
listParam.push("status");
listParam.push("limit");
}
if(search.length > 0){
if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(search)){
param = param + "email="+search+"&";
} else {
} else if (/^[a-fA-F0-9]{24}$/.test(search)){
param = param + "id="+search+"&";
}
} else {
param = param + "name="+search+"&";
}
} else {
listParam.push("email"); listParam.push("id");
listParam.push("email"); listParam.push("id"); listParam.push("name");
}
for (var i=0; i<listParam.length; i++){

View File

@ -1,5 +1,7 @@
checkToken();
signOut();
pathURL = document.location.pathname.split("/")[document.location.pathname.split("/").length-1].split(".")[0]
var param = {}
param["limit"] = 20;
@ -12,7 +14,7 @@ for(var i=0; i<listSearch.length; i++){
}
}
var listQuery = [{"query": "roles", "id":"inputRoles"}, {"query":"status", "id":"inputStatus"}]
var listQuery = [{"query": "roles", "id":"inputRoles"}, {"query":"status", "id":"inputStatus"}, {"query":"limit", "id":"inputPages"}]
for (var i=0; i<listQuery.length; i++){
var query = getQuery(listQuery[i]["query"]);
@ -28,7 +30,7 @@ for (var i=0; i<listQuery.length; i++){
}
instance.get("users/count", { withCredentials: true }).then(function(response){
instance.get(pathURL+"/count", { withCredentials: true }).then(function(response){
var count = response.data["count"] / param["limit"];
var reste = response.data["count"] % param["limit"];
@ -54,7 +56,7 @@ instance.get("users/count", { withCredentials: true }).then(function(response){
var aPage = document.querySelectorAll(".page-item")[newPage].querySelector("a");
aPage.text=newPage;
var newPage = updateParam("page", newpage);
aPage.href="/html/users.html?"+newPage;
aPage.href="/html/"+pathURL+".html?"+newPage;
}
document.querySelectorAll(".page-item")[page].classList.add("active");
if(page != 1){
@ -83,7 +85,7 @@ for (var i=0; i<listQuery.length; i++){
}
}
instance.get("users", {withCredentials: true, params:param}).then(function(response){
instance.get(pathURL, {withCredentials: true, params:param}).then(function(response){
var listData = response.data;
if(!Array.isArray(listData)){
var listData = []
@ -113,15 +115,15 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
switch(e.currentTarget.id){
case "disableUserButton":
httpMethod = "delete";
httpUrl = "users/groups";
httpUrl = pathURL+"/groups";
break;
case "removeUserButton":
httpMethod = "delete";
httpUrl = "users/groups?remove=true";
httpUrl = pathURL+"/groups?remove=true";
break;
default:
httpMethod = "patch";
httpUrl = "users/groups";
httpUrl = pathURL+"/groups";
break;
}
instance({
@ -132,7 +134,7 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
})
.then(function(response){
if(response.status == 200){
location.href="/html/users.html";
location.href="/html/"+pathURL+".html";
}
})
.catch(function(error){
@ -150,9 +152,19 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
td = trAll[i].querySelectorAll("td");
td[0].querySelector("input").setAttribute("userid", listData[i].id)
td[1].textContent = listData[i].id;
td[2].textContent = listData[i].username;
td[3].textContent = listData[i].email;
td[4].textContent = listData[i].roles;
if(pathURL == "users"){
td[2].textContent = listData[i].username;
td[3].textContent = listData[i].email;
td[4].textContent = listData[i].roles;
last_id = 5;
}
if(pathURL == "events"){
td[2].textContent = listData[i].name;
td[3].textContent = listData[i].place;
td[4].textContent = listData[i].start_date;
td[5].textContent = listData[i].start_date;
last_id = 6;
}
var classTd = "";
switch(listData[i].status){
case 1:
@ -171,14 +183,14 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
classTd = ".unknownStatus"
break;
}
td[5].querySelector(".activeStatus").classList.add("hidden");
td[5].querySelector(classTd).classList.remove("hidden");
td[last_id].querySelector(".activeStatus").classList.add("hidden");
td[last_id].querySelector(classTd).classList.remove("hidden");
td[6].querySelector("button").setAttribute("userid", listData[i].id)
td[last_id + 1].querySelector("button").setAttribute("userid", listData[i].id)
td[6].querySelector("button").addEventListener("click", function(e){
td[last_id + 1].querySelector("button").addEventListener("click", function(e){
var id = e.currentTarget.getAttribute("userid");
location.href="/html/user.html?id="+id;
location.href="/html/"+pathURL.slice(0, -1)+".html?id="+id;
});
}
@ -194,25 +206,28 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
document.getElementById("addUser").addEventListener("click", function(){
location.href="/html/adduser.html";
location.href="/html/add"+pathURL.slice(0, -1)+".html";
});
document.getElementById("searchUser").addEventListener("keydown", function(ev){
if(ev.key === "Enter"){
var param = buildParam("", "");
location.href="/html/users.html?"+param;
var param = buildParam("");
location.href="/html/"+pathURL+".html?"+param;
}
});
document.getElementById("inputStatus").addEventListener("change", function(e){
var param = buildParam(e, "inputRoles");
location.href="/html/users.html?"+param;
});
listInput = ["Status", "Pages" ]
if (pathURL=="users"){
listInput.append("Roles")
}
document.getElementById("inputRoles").addEventListener("change", function(e){
var param = buildParam(e, "inputStatus");
location.href="/html/users.html?"+param;
});
for (var i=0; i<listInput.length; i++){
document.getElementById("input"+listInput[i]).addEventListener("change", function(e){
var param = buildParam("inputSelect");
location.href="/html/"+pathURL+".html?"+param;
});
}

2
web/js/tags.js Normal file
View File

@ -0,0 +1,2 @@
var input = document.getElementById("organizersUpdateInput");
new Tagify(input);

View File

@ -1,183 +0,0 @@
checkToken();
signOut();
closeButton();
var id = getQuery("id");
if(id.length > 0){
instance.get("users/"+id, {withCredentials: true})
.then(function(response){
var listValue = [ "id", "username", "name", "firstName", "email", "birth"];
var listTime = ["connected_at", "created_at", "updated_at", "deleted_at"];
for (var i=0; i<listValue.length; i++){
if(response.data[listValue[i]] != null){
document.getElementById(listValue[i]+"UpdateInput").value=response.data[listValue[i]];
}
}
for (var i=0; i<listTime.length; i++){
if(response.data[listTime[i]] != null){
document.getElementById(listTime[i]+"UpdateInput").value=new Date(response.data[listTime[i]]).toLocaleString();
}
}
var listSelector = ["roles", "status"];
for (var i=0; i<listSelector.length; i++){
var select = document.getElementById(listSelector[i]+"Selector").querySelectorAll("option");
for (var j=0; j<select.length; j++){
if(select[j].value == response.data[listSelector[i]]){
select[j].setAttribute("selected", true);
}
}
}
var buttonUser = "";
switch(response.data.status){
case 1:
buttonUser = "disableUser";
break;
case 2:
buttonUser = "enableUser";
break;
case -1:
buttonUser = "cancelUser";
document.getElementById("removeUser").classList.add("hidden");
break;
case 0:
buttonUser = "enableUser";
break;
default:
break;
}
if(buttonUser.length > 0){
document.getElementById(buttonUser).classList.remove("hidden");
}
var listModalButton = ["disable", "enable", "cancel", "remove"];
for (var i=0; i<listModalButton.length; i++){
document.getElementById(listModalButton[i]+"UserButton").addEventListener("click", function(e){
var httpMethod = ""
var httpUrl = "";
var idInput = document.getElementById("idUpdateInput").value;
switch(e.currentTarget.id){
case "disableUserButton":
httpMethod = "delete";
httpUrl = "users/"+idInput;
break;
case "removeUserButton":
httpMethod = "delete";
httpUrl = "users/"+idInput+"?remove=true";
break;
default:
httpMethod = "patch";
httpUrl = "users/"+idInput;
break;
}
instance({
method: httpMethod,
url: httpUrl,
withCredentials: true
})
.then(function(response){
if(response.status == 200){
location.href="/html/user.html?id="+idInput;
}
})
.catch(function(error){
console.log(error);
});
});
}
})
.catch(function(error){
console.log(error);
});
document.getElementById("updateUserButton").addEventListener("click", function(){
var updateProfil = ["id", "username", "email", "firstName", "birth"];
var updateOk = true;
for (var i=0; i<updateProfil.length; i++){
if(document.getElementById(updateProfil[i]+"UpdateInput").value.length == 0){
updateOk = false;
document.getElementById(updateProfil[i]+"Alert").classList.remove("hidden");
}
}
if(updateOk){
var selector = { "roles": "", "status": 0};
var listSelector = [ "roles", "status"];
for (var i=0; i<listSelector.length; i++){
var options = document.querySelectorAll("#"+listSelector[i]+"Selector option");
for (var j=0; j<options.length; j++){
if(options[j].selected){
selector[listSelector[i]] = options[j].value;
}
}
}
dataPut = {
"id": document.getElementById("idUpdateInput").value,
"username": document.getElementById("usernameUpdateInput").value,
"email": document.getElementById("emailUpdateInput").value,
"name": document.getElementById("nameUpdateInput").value,
"firstName": document.getElementById("firstNameUpdateInput").value,
"birth": document.getElementById("birthUpdateInput").value,
"status": selector["status"],
"password": document.getElementById("passwordUpdateInput").value,
"roles": selector["roles"],
"created_at": "",
"updated_at": "",
"deleted_at": "",
"connected_at": ""
}
instance({
method : "put",
url:"users/"+document.getElementById("idUpdateInput").value,
withCredentials: true,
data: dataPut
}).then(function(response){
var idAlert = "";
switch(response.status){
case 200:
location.reload();
break;
case 304:
idAlert="noContent";
break;
default:
idAlert="unknown";
break;
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
}).catch(function(error){
var idAlert = "";
switch(error.status){
case 401:
idAlert="notAuthorized";
break;
case 403:
idAlert="forbidden";
break;
case 500:
idAlert="internalServer";
break;
default:
idAlert="unknown";
break;
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
});
}
});
}