Przeglądaj źródła

dashboard + icone menu + email password + listing collectifdata

master
Charly 3 lat temu
rodzic
commit
8a679bdec7
10 zmienionych plików z 174 dodań i 14 usunięć
  1. +8
    -1
      public/build/adminlte-common.css
  2. +9
    -1
      src/Controller/Admin/CollectifDataCrudController.php
  3. +24
    -6
      src/Controller/Admin/DashboardAnimatorController.php
  4. +38
    -0
      src/Controller/Admin/DashboardController.php
  5. +13
    -6
      src/Controller/Admin/UserCrudController.php
  6. +20
    -0
      src/Entity/CollectifData.php
  7. +11
    -0
      templates/adminlte/dashboard-animator.html.twig
  8. +38
    -0
      templates/adminlte/dashboard.html.twig
  9. +9
    -0
      templates/emails/password.html.twig
  10. +4
    -0
      translations/admin.fr.yaml

+ 8
- 1
public/build/adminlte-common.css
Plik diff jest za duży
Wyświetl plik


+ 9
- 1
src/Controller/Admin/CollectifDataCrudController.php Wyświetl plik

@@ -35,10 +35,17 @@ class CollectifDataCrudController extends AbstractCrudController
{
$fields = array();

$fields[] = TextField::new('resume');
$fields[] = AssociationField::new('territory')
->setTemplatePath('crud/field/association.html.twig');
$fields[] = IntegerField::new('nbParticipant');
$fields[] = TextField::new('nbDreams')
->onlyOnIndex();
$fields[] = TextField::new('nbRevolts')
->onlyOnIndex();
$fields[] = TextField::new('nbProjectsBoost')
->onlyOnIndex();
$fields[] = TextField::new('nbProjectsInspiring')
->onlyOnIndex();
$fields[] = CollectionField::new('revolts')
->setFormTypeOption('entry_type', RevoltsType::class)
->setFormTypeOption('by_reference', false)
@@ -95,6 +102,7 @@ class CollectifDataCrudController extends AbstractCrudController

public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void
{
$entityInstance->setUser($this->getUser());
$entityManager->persist($entityInstance);
$entityManager->flush();


+ 24
- 6
src/Controller/Admin/DashboardAnimatorController.php Wyświetl plik

@@ -22,13 +22,31 @@ use Symfony\Component\HttpFoundation\Response;

class DashboardAnimatorController extends SovDashboardController
{
private $adminUrlGenerator;
protected $adminUrlGenerator;

public function __construct(AdminUrlGenerator $adminUrlGenerator)
{
$this->adminUrlGenerator = $adminUrlGenerator;
}

public function index(): Response
{
$urlCreate = $this->adminUrlGenerator
->setController(CollectifDataCrudController::class)
->setAction(Action::NEW)
->generateUrl();

$nbForm = $this->getDoctrine()
->getRepository(CollectifData::class)
->findByUser($this->getUser());

return $this->render('/adminlte/dashboard-animator.html.twig',
[
'urlCreate' => $urlCreate,
'nbForm' => count($nbForm),
]);
}

public function configureMenuItems(): iterable
{
$urlCreate = $this->adminUrlGenerator
@@ -36,13 +54,13 @@ class DashboardAnimatorController extends SovDashboardController
->setAction(Action::NEW)
->generateUrl();

yield MenuItem::linkToDashboard('dashboard', 'circle');
yield MenuItem::linkToUrl('data_collectif_create', '', $urlCreate);
yield MenuItem::subMenu('account', 'user')
yield MenuItem::linkToDashboard('dashboard', 'far fa-circle');
yield MenuItem::linkToUrl('data_collectif_create', 'fas fa-plus', $urlCreate);
yield MenuItem::subMenu('account', 'fas fa-user')
->setSubItems(
[
MenuItem::linkToRoute('account_profile', '', 'sov_admin_account_profile'),
MenuItem::linkToRoute('account_password', '', 'sov_admin_account_password'),
MenuItem::linkToRoute('account_profile', 'fas fa-user-cog', 'sov_admin_account_profile'),
MenuItem::linkToRoute('account_password', 'fas fa-key', 'sov_admin_account_password'),
]
);


+ 38
- 0
src/Controller/Admin/DashboardController.php Wyświetl plik

@@ -6,7 +6,11 @@ namespace App\Controller\Admin;
use App\Entity\CollectifData;
use App\Entity\Common\TaxRate;
use App\Entity\Configuration;
use App\Entity\Dreams;
use App\Entity\IndividualData;
use App\Entity\ProjectsBoost;
use App\Entity\ProjectsInspiring;
use App\Entity\Revolts;
use App\Entity\Site\Page;
use App\Entity\Territory;
use App\Entity\Thematic;
@@ -18,11 +22,13 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\SovBundle\Controller\Dashboard\DashboardController as SovDashboardController;
use Symfony\Component\HttpFoundation\Response;

class DashboardController extends SovDashboardController
{
const ROLE_ADMIN = "ROLE_ADMIN";
const ROLE_SUPER_ADMIN = "ROLE_SUPER_ADMIN";
const ROLE_ANIMATOR = "ROLE_ANIMATOR";

private $adminUrlGenerator;

@@ -31,6 +37,38 @@ class DashboardController extends SovDashboardController
$this->adminUrlGenerator = $adminUrlGenerator;
}

public function index(): Response
{
$repoCollectifData = $this->getDoctrine()->getRepository(CollectifData::class);
$repoDreams = $this->getDoctrine()->getRepository(Dreams::class);
$repoRevolts = $this->getDoctrine()->getRepository(Revolts::class);
$repoProjectsBoost = $this->getDoctrine()->getRepository(ProjectsBoost::class);
$repoProjectsInsp = $this->getDoctrine()->getRepository(ProjectsInspiring::class);
$repoUser = $this->getDoctrine()->getRepository(User::class);

$formUnvalid = $repoCollectifData->findByStatus(0);

$formValid = $repoCollectifData->findByStatus(1);

$dreams = $repoDreams->findAll();
$revolts = $repoRevolts->findAll();
$projectsBoost = $repoProjectsBoost->findAll();
$projectsInsp = $repoProjectsInsp->findAll();

$animators = $repoUser->findByRole(self::ROLE_ANIMATOR);

return $this->render('/adminlte/dashboard.html.twig',
[
'nbFormUnvalid' => count($formUnvalid),
'nbFormValid' => count($formValid),
'nbDreams' => count($dreams),
'nbRevolts' => count($revolts),
'nbProjectsBoost' => count($projectsBoost),
'nbProjectsInsp' => count($projectsInsp),
'nbAnimator' => count($animators)
]);
}

public function configureMenuItems(): iterable
{
$urlNewCollectif = $this->adminUrlGenerator

+ 13
- 6
src/Controller/Admin/UserCrudController.php Wyświetl plik

@@ -9,8 +9,10 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\User\UserAdminController as AbstractUserCrudController;
use Lc\SovBundle\Definition\RolesDefinitionInterface;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Mailer\MailerInterface;
@@ -30,7 +32,7 @@ class UserCrudController extends AbstractUserCrudController
RequestStack $request,
EntityManager $em,
TranslatorAdmin $translatorAdmin,
Environment $twig,
RolesDefinitionInterface $rolesDefinition,
UserPasswordEncoderInterface $passwordEncoder,
EntityManager $entityManager,
MailerInterface $mailerInterface
@@ -41,7 +43,7 @@ class UserCrudController extends AbstractUserCrudController
$this->entityManager = $entityManager;
$this->mailerInterface = $mailerInterface;

parent::__construct($session, $request, $em, $translatorAdmin ,$twig);
parent::__construct($session, $request, $em, $translatorAdmin, $rolesDefinition);
}

public static function getEntityFqcn(): string
@@ -74,15 +76,20 @@ class UserCrudController extends AbstractUserCrudController
$this->entityManager->create($entityInstance);
$this->entityManager->flush();

$email = (new Email())
$email = (new TemplatedEmail())
->from('contact@laclic.fr')
->to('charly@laclic.fr')
->subject('Password')
->html($plainPassword);
->subject('Mot de passe Aux Actes Citoyens')
->htmlTemplate('emails/password.html.twig')
->context([
'password' => $plainPassword,
'firstname' => $entityInstance->getFirstname(),
'lastname' => $entityInstance->getLastname(),
]);

$this->mailerInterface->send($email);

parent::persistEntity($entityManager, $entityInstance); // TODO: Change the autogenerated stub
parent::persistEntity($entityManager, $entityInstance);
}

function generatePassword($caracteres = 12, $chaine = 'azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN123456789#!?+=-/%')

+ 20
- 0
src/Entity/CollectifData.php Wyświetl plik

@@ -78,6 +78,26 @@ class CollectifData implements StatusInterface, EntityInterface
return count($this->getRevolts()) . " révolte(s) - " . count($this->getDreams()) . " rêve(s) - " . count($this->getProjectsBoost()) . " projet(s) boosté(s) - " . count($this->getProjectsInspiring()) . " projets inspirants";
}

public function getNbDreams():string
{
return count($this->getDreams());
}

public function getNbRevolts():string
{
return count($this->getRevolts());
}

public function getNbProjectsBoost():string
{
return count($this->getProjectsBoost());
}

public function getNbProjectsInspiring():string
{
return count($this->getProjectsInspiring());
}

public function getId(): ?int
{
return $this->id;

+ 11
- 0
templates/adminlte/dashboard-animator.html.twig Wyświetl plik

@@ -0,0 +1,11 @@
{% extends '@LcSov/adminlte/layout.html.twig' %}
{% import '@LcSov/adminlte/macro/infobox.html.twig' as minfobox %}
{% block content_title %}
{{ 'dashboard'|lc_trans_admin_title }}
{% endblock %}

{% block main %}
<a class="btn btn-primary" style="margin-bottom: 40px;" href="{{ urlCreate }}" role="button" title="formulaire collectif">Accéder au formulaire collectif</a>

{{ minfobox.infobox("Nombre de formulaires collectifs", nbForm, "red", "fas fa-database") }}
{% endblock %}

+ 38
- 0
templates/adminlte/dashboard.html.twig Wyświetl plik

@@ -0,0 +1,38 @@
{% extends '@LcSov/adminlte/layout.html.twig' %}
{% import '@LcSov/adminlte/macro/infobox.html.twig' as minfobox %}

{% block content_title %}
{{ 'dashboard'|lc_trans_admin_title }}
{% endblock %}

{% block main %}
<div class="row">
<div class="col-sm-3 col-xs-12">
{{ minfobox.infobox("Nombre d'animateurs", nbAnimator, "blue", "fas fa-user") }}
</div>
</div>
<div class="row">
<div class="col-sm-6 col-xs-12">
{{ minfobox.infobox("Formulaires collectifs en attente de validation", nbFormUnvalid, "red", "fas fa-database") }}
</div>
<div class="col-sm-6 col-xs-12">
{{ minfobox.infobox("Formulaires collectifs validés", nbFormValid, "green", "fas fa-database") }}
</div>
</div>
<div class="row">
<div class="col-sm-6 col-xs-12">
{{ minfobox.infobox("Nombre de rêves ", nbDreams, "blue", "far fa-lightbulb") }}
</div>
<div class="col-sm-6 col-xs-12">
{{ minfobox.infobox("Nombre de révoltes ", nbRevolts, "red", "fas fa-bullhorn") }}
</div>
</div>
<div class="row">
<div class="col-sm-6 col-xs-12">
{{ minfobox.infobox("Nombre de projets boostés ", nbProjectsBoost, "indigo", "fas fa-thumbs-up") }}
</div>
<div class="col-sm-6 col-xs-12">
{{ minfobox.infobox("Nombre de projets inspirants ", nbProjectsInsp, "blue", "fas fa-smile") }}
</div>
</div>
{% endblock %}

+ 9
- 0
templates/emails/password.html.twig Wyświetl plik

@@ -0,0 +1,9 @@
<h1>Bonjour {{ firstname }} {{ lastname }}!</h1>

<p>
Vous trouverez ci-dessous vos informations de connexion pour accéder a votre compte.
</p>
<p>
Nom d'utilisateur : {{ email.to[0].address }}<br>
Mot de passe : {{ password }}
</p>

+ 4
- 0
translations/admin.fr.yaml Wyświetl plik

@@ -25,6 +25,10 @@ entity:
projectsboost: Les projets boostés
projectsinspiring: Les projets inspirants
resume: Résumé
nbDreams: Rêve(s)
nbRevolts: Révolte(s)
nbProjectsBoost: Projet(s) boosté(s)
nbProjectsInspiring: Projet(s) inspirant(s)
IndividualData:
label: Données individuel
label_plurial: Données du formulaire individuel

Ładowanie…
Anuluj
Zapisz