dashboard done + UI/UX fix

This commit is contained in:
Olivier PARPAILLON
2024-11-26 15:35:11 +01:00
parent 5e5e5e9ca7
commit 119051eef8
16 changed files with 271 additions and 49 deletions

2
.env
View File

@@ -15,7 +15,7 @@
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
###> symfony/framework-bundle ###
APP_ENV=prod
APP_ENV=dev
APP_SECRET=ba1ab1eaa1c6662c10564a7a82901198
###< symfony/framework-bundle ###

View File

@@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241125095027 extends AbstractMigration
final class Version20241125154648 extends AbstractMigration
{
public function getDescription(): string
{
@@ -20,12 +20,12 @@ final class Version20241125095027 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE lieu ADD ville VARCHAR(255) NOT NULL, ADD code_postal INT NOT NULL');
$this->addSql('ALTER TABLE sortie ADD motif_annul LONGTEXT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE lieu DROP ville, DROP code_postal');
$this->addSql('ALTER TABLE sortie DROP motif_annul');
}
}

View File

@@ -38,7 +38,7 @@ class AdminController extends AbstractController
{
$token = $tokenStorage->getToken();
$userConnect = $token?->getUser();
return $this->render('admin/index.html.twig', [
return $this->render('admin/list.html.twig', [
'profile' => $userConnect,
'controller_name' => 'AdminController',
]);

View File

@@ -17,7 +17,7 @@ class LieuController extends AbstractController
#[Route('/lieu', name: 'app_lieu')]
public function index(): Response
{
return $this->render('lieu/index.html.twig', [
return $this->render('lieu/list.html.twig', [
'controller_name' => 'LieuController',
]);
}

View File

@@ -22,22 +22,15 @@ class MainController extends AbstractController
$token = $tokenStorage->getToken();
$userConnect = $token?->getUser();
// Récupérer les paramètres de filtre
$search = $request->query->get('search', '');
$siteId = $request->query->get('site', '');
$startDate = $request->query->get('start_date', '');
$endDate = $request->query->get('end_date', '');
$organisateur = $request->query->get('organisateur', false);
$inscrit = $request->query->get('inscrit', false);
$nonInscrit = $request->query->get('non_inscrit', false);
$passees = $request->query->get('passees', false);
$sorties = $sortieRepository->findForDashboard();
$sortiesParticipation = $sortieRepository->findUserParticipation($userConnect);
$sortiesOrganisation = $sortieRepository->findUserOrganisation($userConnect);
$sorties = $sortieRepository->findWithFilters($search, $siteId, $startDate, $endDate, $organisateur, $inscrit, $nonInscrit, $passees, $userConnect);
return $this->render('main/index.html.twig', [
return $this->render('main/dashboard.html.twig', [
'profile' => $userConnect,
'sorties' => $sorties,
'sites' => $sortieRepository->findAllSites(),
'sortiesParticipation' => $sortiesParticipation,
'sortiesOrganisation' => $sortiesOrganisation,
]);
}

View File

@@ -116,6 +116,6 @@ class PasswordResetController extends AbstractController
return $this->redirectToRoute('app_login');
}
return $this->render('password_reset/index.html.twig', ['token' => $token]);
return $this->render('password_reset/list.html.twig', ['token' => $token]);
}
}

View File

@@ -7,6 +7,7 @@ use App\Form\SortieType;
use App\Repository\EtatRepository;
use App\Repository\LieuRepository;
use App\Repository\ParticipantRepository;
use App\Repository\SortieRepository;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -18,6 +19,34 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
#[Route('/sortie', name: 'sortie_')]
class SortieController extends AbstractController
{
#[Route('/liste', name: 'list', methods: ['GET'])]
public function index(
TokenStorageInterface $tokenStorage,
SortieRepository $sortieRepository,
Request $request
): Response {
$token = $tokenStorage->getToken();
$userConnect = $token?->getUser();
// Récupérer les paramètres de filtre
$search = $request->query->get('search', '');
$siteId = $request->query->get('site', '');
$startDate = $request->query->get('start_date', '');
$endDate = $request->query->get('end_date', '');
$organisateur = $request->query->get('organisateur', false);
$inscrit = $request->query->get('inscrit', false);
$nonInscrit = $request->query->get('non_inscrit', false);
$passees = $request->query->get('passees', false);
$sorties = $sortieRepository->findWithFilters($search, $siteId, $startDate, $endDate, $organisateur, $inscrit, $nonInscrit, $passees, $userConnect);
return $this->render('sortie/list.html.twig', [
'profile' => $userConnect,
'sorties' => $sorties,
'sites' => $sortieRepository->findAllSites(),
]);
}
#[Route('/creates', name: 'create', methods: ['GET', 'POST'])]
public function create(
Request $request,

View File

@@ -67,6 +67,35 @@ class SortieRepository extends ServiceEntityRepository
return $qb->getQuery()->getResult();
}
public function findForDashboard()
{
return $this->createQueryBuilder('s')
->orderBy('s.dateLimiteInscription', 'ASC')
->andWhere('s.dateHeureDebut >= :lastMonth')
->setParameter('lastMonth', (new \DateTime())->modify('-1 month'))
->getQuery()
->getResult();
}
public function findUserParticipation($userConnect)
{
return $this->createQueryBuilder('s')
->leftJoin('s.participants', 'p')
->where('p.idParticipant = :user')
->setParameter('user', $userConnect->getIdParticipant())
->getQuery()
->getResult();
}
public function findUserOrganisation($userConnect)
{
return $this->createQueryBuilder('s')
->leftJoin('s.organisateur', 'o')
->where('o.idParticipant = :user')
->setParameter('user', $userConnect->getIdParticipant())
->getQuery()
->getResult();
}
public function findAllSites()
{
return $this->getEntityManager()

View File

@@ -11,24 +11,7 @@
<h1 class="text-2xl font-semibold mb-4">Gestion des utilisateurs</h1>
<!-- Actions: Import/Export -->
<div class="flex flex-row items-center mb-4">
<form action="{{ path('participant_import') }}" method="post" enctype="multipart/form-data" class="flex items-center">
<button
type="submit"
class="bg-green-500 text-white mr-4 px-4 py-2 rounded hover:bg-green-600">
Importer CSV
</button>
<input
type="file"
name="csv_file"
accept=".csv"
class="block w-full text-sm text-gray-500
file:mr-4 file:py-2 file:px-4
file:rounded file:border-0
file:text-sm file:font-semibold
file:bg-gray-800 file:text-white
hover:file:bg-gray-700" />
</form>
<div class="flex flex-row mb-4 justify-between">
<button
id="openModal"
class="bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 items-end justify-end">
@@ -38,9 +21,16 @@
<!-- Participants Table -->
<form method="POST" action="{{ path('participant_export') }}">
<button type="submit" class="bg-blue-500 text-white px-4 py-2 mb-4 rounded hover:bg-blue-600">
<a href="{{ path('participant_export') }}">Exporter CSV</a>
</button>
<div class="flex flex-row">
<button
id="openModalCsv" type="button"
class="bg-green-500 text-white mb-4 mr-4 px-4 py-2 rounded hover:bg-green-600">
Importer CSV
</button>
<button type="submit" class="bg-blue-500 text-white px-4 py-2 mb-4 rounded hover:bg-blue-600">
<a href="{{ path('participant_export') }}">Exporter CSV</a>
</button>
</div>
<div class="overflow-x-auto bg-white rounded shadow">
<table class="min-w-full bg-white divide-y divide-gray-200">
<thead class="bg-gray-50">
@@ -195,6 +185,36 @@
</div>
</div>
<div id="modalCsv" class="fixed inset-0 z-50 hidden bg-gray-900 bg-opacity-50">
<div class="flex justify-center items-center min-h-screen">
<div class="bg-white p-6 rounded shadow-md w-1/3">
<h2 class="text-xl font-semibold mb-4">Importer un CSV</h2>
<form id="addCSVForm" method="post" enctype="multipart/form-data" class="flex flex-col items-center" action="{{ path('participant_import') }}">
<div class="mb-4">
<input
type="file"
name="csv_file"
accept=".csv"
class="block w-full text-sm text-gray-500
file:mr-4 file:py-2 file:px-4
file:rounded file:border-0
file:text-sm file:font-semibold
file:bg-gray-800 file:text-white
hover:file:bg-gray-700" />
</div>
<div class="flex flex-row">
<button
type="submit"
class="bg-green-500 text-white mr-4 px-4 py-2 rounded hover:bg-green-600">
Importer CSV
</button>
<button type="button" id="closeModalCsv" class="ml-2 bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-700">Annuler</button>
</div>
</form>
</div>
</div>
</div>
{# Modale import CSV#}
<script>
@@ -209,6 +229,16 @@
});
</script>
<script>
document.getElementById('openModalCsv').addEventListener('click', function() {
document.getElementById('modalCsv').classList.remove('hidden')
})
document.getElementById('closeModalCsv').addEventListener('click', function() {
document.getElementById('modalCsv').classList.add('hidden')
})
</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const selectAllCheckbox = document.getElementById('selectAll');

View File

@@ -0,0 +1,135 @@
{% extends 'main/base.html.twig' %}
{% block head %}
<head>
<meta charset="UTF-8">
{% block title %}&#128227; Sortie.com {{ profile.pseudo }} &#128266;{% endblock %}
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
</head>
{% endblock %}
{% block content %}
<h3 class="text-center text-base mb-8 mt-4 font-bold uppercase">Bonjour, {{ profile.nom }} {{ profile.prenom }}</h3>
{# Tableau des sorties globales#}
<div class="flex flex-col bg-white shadow-lg rounded-lg mx-8 mb-10">
<h4 class="text-start bg-gray-50 items-start justify-start text-base p-2 font-bold uppercase">Les sorties en cours</h4>
<table class="min-w-full bg-white divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nom</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Etat</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Adresse</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date début</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Durée</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date limite inscription</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
{% for sortie in sorties %}
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.nom }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.etat.libelle }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{{ sortie.lieu ? (sortie.lieu.ville ?: '') ~ ' ' ~ (sortie.lieu.codePostal ?: '') ~ ', ' ~ (sortie.lieu.rue ?: '') : '' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.dateHeureDebut|date('d/m/Y H:i') }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.duree }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.dateLimiteInscription|date('d/m/Y H:i') }}</td>
<td class="flex flex-row px-6 py-4 whitespace-nowrap text-base text-gray-900">
{% if not sortie.participants.contains(app.user) and sortie.etat.libelle == 'Ouverte' %}
<form action="{{ path('sortie_inscription', { id: sortie.idSortie }) }}" method="post">
<button type="submit">🔔</button>
</form>
{% elseif sortie.participants.contains(app.user) and sortie.etat.libelle == 'Ouverte' %}
<form method="post" action="{{ path('sortie_unsubscribe', { id: sortie.idSortie }) }}">
<button type="submit">🔕</button>
</form>
{% endif %}
<form method="post" action="{{ path('sortie_view', { id: sortie.idSortie }) }}">
<button type="submit">👁️</button>
</form>
</td>
</tr>
{% else %}
<tr>
<td colspan="8" class="px-6 py-4 text-center text-gray-500">Aucune participant trouvé</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="flex flex-row flex-wrap mx-8">
{# Tableau des sorties dont je suis participant#}
<div class="w-1/2 p-4 shadow-lg rounded-lg">
<h4 class="text-start bg-gray-50 items-start justify-start text-base p-2 font-bold uppercase">Mes participations</h4>
<table class="min-w-full bg-white divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nom</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Adresse</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date début</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Durée</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
{% for sortie in sortiesParticipation %}
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.nom }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{{ sortie.lieu ? (sortie.lieu.ville ?: '') ~ ' ' ~ (sortie.lieu.codePostal ?: '') ~ ', ' ~ (sortie.lieu.rue ?: '') : '' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.dateHeureDebut|date('d/m/Y H:i') }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.duree }}</td>
<td class="flex flex-row px-6 py-4 whitespace-nowrap text-base text-gray-900">
<a href={{ path('sortie_view', { id: sortie.idSortie }) }}>👁️</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="8" class="px-6 py-4 text-center text-gray-500">Vous ne participez à aucune sortie</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{# Tableau des sorties dont je suis organisateur #}
<div class="w-1/2 p-4 shadow-lg rounded-lg">
<h4 class="text-start bg-gray-50 items-start justify-start text-base p-2 font-bold uppercase">Mes organisations</h4>
<table class="min-w-full bg-white divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nom</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Adresse</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date début</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Durée</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
{% for sortie in sortiesOrganisation %}
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.nom }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{{ sortie.lieu ? (sortie.lieu.ville ?: '') ~ ' ' ~ (sortie.lieu.codePostal ?: '') ~ ', ' ~ (sortie.lieu.rue ?: '') : '' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.dateHeureDebut|date('d/m/Y H:i') }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ sortie.duree }}</td>
<td class="flex flex-row px-6 py-4 whitespace-nowrap text-base text-gray-900">
<a href={{ path('sortie_view', { id: sortie.idSortie }) }}>👁️</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="8" class="px-6 py-4 text-center text-gray-500">Vous n'organisez aucune sortie</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}

View File

@@ -1,4 +1,4 @@
<footer class="w-full bg-green-700 text-white py-4">
<footer class="w-full text-white py-4">
<div class="flex justify-center">
ENI &copy; Sortie {{ "now"|date("Y") }}
</div>

View File

@@ -31,9 +31,10 @@
</button>
{% endif %}
<ul id="navbar" class="hidden absolute top-20 right-0 w-max bg-white shadow-md p-4 pl-2 flex-col space-y-4">
<li><a href="{{ path('home') }}" class="text-gray-700 font-bold hover:text-blue-500">Accueil</a></li>
<li><a href="{{ path('participants') }}" class="text-gray-700 font-bold hover:text-blue-500">Participants</a></li>
{% if app.user %}
<li><a href="{{ path('home') }}" class="text-gray-700 font-bold hover:text-blue-500">Accueil</a></li>
<li><a href="{{ path('sortie_list') }}" class="text-gray-700 font-bold hover:text-blue-500">Liste des sorties</a></li>
<li><a href="{{ path('participants') }}" class="text-gray-700 font-bold hover:text-blue-500">Participants</a></li>
<li><a href="{{ path('profile_view', {'uuid': app.user.idParticipant}) }}" class="text-gray-700 font-bold hover:text-blue-500">Mon profile</a></li>
{% endif %}
{% if app.user and ('ROLE_ADMIN' in app.user.roles) %}

View File

@@ -24,10 +24,9 @@
<tbody class="divide-y divide-gray-200">
{% for participant in participants %}
<tr>
<div class="relative">
<img src="{{ participant.fileName ? asset('upload/image/profile/' ~ participant.fileName) : asset('upload/image/profile/default.png') }}"
class="w-16 h-16 rounded-full mr-4" />
</div>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
<img src="{{ participant.fileName ? asset('upload/image/profile/' ~ participant.fileName) : asset('upload/image/profile/default.png') }}" class="w-16 h-16 rounded-full mr-4" />
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ participant.pseudo }}</td>

View File

@@ -24,9 +24,11 @@
<div class="text-sm mt-0 mb-2 text-slate-400 font-bold uppercase">
<i class="fas fa-map-marker-alt mr-2 text-slate-400 opacity-75"></i>{{ profile.pseudo }}
</div>
{% if isActiveUser %}
<div class="text-xs mt-0 mb-2 text-slate-400 font-bold uppercase">
<i class="fas fa-map-marker-alt mr-2 text-slate-400 opacity-75"></i>{{ profile.telephone }} - {{ profile.email }}
</div>
{% endif %}
</div>
{% if isActiveUser %}
<div class="mt-6 py-6 border-t border-slate-200 text-center">

View File

@@ -57,7 +57,11 @@
{% if sortie.participants is not empty %}
<ul class="list-disc pl-6 text-gray-800 mt-2">
{% for participant in sortie.participants %}
<li>{{ participant.nom }} {{ participant.prenom }}</li>
<li>
<a href="{{ path('profile_view', {'uuid': participant.idParticipant}) }}">
{{ participant.nom }} {{ participant.prenom }}
</a>
</li>
{% endfor %}
</ul>
{% else %}