From cb7afab3826d51be9cee87f780b824bf2f43928a Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 29 Oct 2025 09:29:51 +0100 Subject: [PATCH] update index page --- src/Controller/UserController.php | 29 ++------------- templates/user/index.html.twig | 58 ++++++++++++++++-------------- templates/user/indexTest.html.twig | 43 ---------------------- 3 files changed, 34 insertions(+), 96 deletions(-) delete mode 100644 templates/user/indexTest.html.twig diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index ac928a0..32ec0b7 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -41,31 +41,6 @@ class UserController extends AbstractController { } - #[Route('/', name: 'index', methods: ['GET'])] - public function index(): Response - { - $this->denyAccessUnlessGranted('ROLE_USER'); - - $user = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier()); - - if ($this->isGranted('ROLE_SUPER_ADMIN')) { - $uo = $this->uoRepository->findUsersWithOrganization(); - $noOrgUsers = $this->userService->formatNoOrgUsersAsAssoc( - $this->userRepository->findUsersWithoutOrganization()); - $usersByOrganization = $this->userService->groupByOrganization($uo); - $usersByOrganization += $noOrgUsers; - - //Log action - $this->actionService->createAction("View all users", $user, null, "All"); - - } else { - $usersByOrganization = []; - } - - return $this->render('user/index.html.twig', [ - 'usersByOrganization' => $usersByOrganization, - ]); - } #[Route('/view/{id}', name: 'show', methods: ['GET'])] public function view(int $id, Request $request): Response @@ -446,8 +421,8 @@ class UserController extends AbstractController ]); } - #[Route(path: '/indexTest', name: 'indexTest', methods: ['GET'])] - public function indexTest(): Response + #[Route(path: '/', name: 'index', methods: ['GET'])] + public function index(): Response { $actingUser = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier()); if ($this->userService->hasAccessTo($actingUser, true) && $this->isGranted("ROLE_ADMIN")) { diff --git a/templates/user/index.html.twig b/templates/user/index.html.twig index c968b04..21b685f 100644 --- a/templates/user/index.html.twig +++ b/templates/user/index.html.twig @@ -3,35 +3,41 @@ {% block title %}User Profile{% endblock %} {% block body %} -
- {# TODO: check for border-0#} -
-

Gestion Utilisateurs

- {% if is_granted('ROLE_SUPER_ADMIN') %} - Ajouter un utilisateur - {% endif %} -
-{#TODO: Remove/Adapt userList depending on design review #} - {% if is_granted('ROLE_SUPER_ADMIN') or is_granted('ROLE_ADMIN') %} - {% if usersByOrganization|length == 0 %} -
-

Aucun utilisateur trouvé

+ {% if is_granted('ROLE_SUPER_ADMIN') %} +
+
+
+
+

Gestion Utilisateurs

+ Ajouter un utilisateur +
- {% else %} - {% for org in usersByOrganization %} - {% include 'user/userList.html.twig' with { - title: org.name, - organizationId: org.id|default(null), - logo: org.logo|default(null), - users: org.users - } %} - {% endfor %} - {% endif %} - {% else %} + + {% if users|length == 0 %} +
+

Aucun utilisateur trouvé

+
+ {% else %} +
+
+
+
+
+
+ + {% endif %} +
+
+ + + {% else %} +

Accès limité

Vous n'avez pas les permissions nécessaires pour voir la liste des utilisateurs.

- {% endif %} -
+
+ {% endif %} {% endblock %} \ No newline at end of file diff --git a/templates/user/indexTest.html.twig b/templates/user/indexTest.html.twig deleted file mode 100644 index 21b685f..0000000 --- a/templates/user/indexTest.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}User Profile{% endblock %} - -{% block body %} - {% if is_granted('ROLE_SUPER_ADMIN') %} -
-
-
-
-

Gestion Utilisateurs

- Ajouter un utilisateur -
-
- - {% if users|length == 0 %} -
-

Aucun utilisateur trouvé

-
- {% else %} -
-
-
-
-
-
- - {% endif %} -
-
- - - {% else %} -
-
-

Accès limité

-

Vous n'avez pas les permissions nécessaires pour voir la liste des utilisateurs.

-
-
- {% endif %} -{% endblock %} \ No newline at end of file