This commit is contained in:
Nicolas Debrigode 2024-01-20 15:40:16 +01:00
parent 773f62371e
commit c4e397cff5
7 changed files with 97 additions and 72 deletions

View File

@ -25,6 +25,7 @@ code-check: ## Vérification du code PHP
make phpstan
make analysis
make rector
make twig
analysis: ## Analyse de la qualité du code PHP
./vendor/bin/phpinsights analyse src -c phpinsights.php
@ -35,6 +36,9 @@ phpstan: ## Analyse statique du code PHP
rector: ## Analyse refactoring du code PHP
./vendor/bin/rector process --dry-run --config=rector.php
twig: ## Analyse TwigCS
./vendor/bin/twigcs --config .twig_cs.dist.php
# SERVEUR SYMFONY ######################################################################################################
proxy: ## Démarre le proxy du serveur Symfony

View File

@ -7,10 +7,12 @@ namespace App\Controller;
use App\Application\ConfigApplication;
use App\Exception\ConfigErrorException;
use App\Exception\DbErrorException;
use App\Form\LegendForm;
use App\Repository\GetAsDataRepository;
use App\Repository\KnowlinksRepository;
use App\Util\Annotation\Menu;
use Doctrine\DBAL\Exception;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -27,9 +29,10 @@ class IndexController extends BaseController
#[Route(
path: '/',
name: 'index',
methods: ['GET'],
methods: ['GET|POST'],
)]
public function index(
Request $request,
GetAsDataRepository $asDataRepository,
): Response {
$this->base_data['content_wrapper']['titre'] = \sprintf(
@ -38,10 +41,16 @@ class IndexController extends BaseController
'24 hours'
);
$form = $this->createForm(LegendForm::class);
$form->handleRequest($request);
return $this->render('pages/index.html.twig', [
'base_data' => $this->base_data,
'data' => $asDataRepository::get($this->base_data['top']),
'knownlinks' => KnowlinksRepository::get(),
'form' => [
'legend' => $form->createView(),
],
]);
}

37
src/Form/LegendForm.php Normal file
View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\Form;
use App\Repository\KnowlinksRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class LegendForm extends AbstractType
{
/**
* @param array<string, mixed> $options
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
foreach (KnowlinksRepository::get() as $knowlink) {
$builder
->add(\sprintf('%s', $knowlink['tag']), CheckboxType::class, [
'label' => false,
'translation_domain' => false,
'required' => false,
])
;
}
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'csrf_protection' => false,
]);
}
}

View File

@ -17,7 +17,6 @@
<body class="layout-fluid">
<div class="page">
{% include 'base/_header.html.twig' %}
{% include 'base/_legend.html.twig' %}
<div class="page-wrapper">
<div class="container-xl">

View File

@ -1,33 +0,0 @@
<div class="navbar-expand-md">
<div class="collapse navbar-collapse" id="navbar-menu">
<div class="navbar navbar-light">
<div class="container-xl">
<div class="table-responsive">
<table class="table table-borderless table-vcenter">
<tbody>
<tr>
{% if knownlinks is defined %}
{% for link in knownlinks %}
<td>
<table class="table-legend">
<tr>
{% if configapplication_graph('brighten_negative') %}
<td class="table-legend-td table-legend-td-brighten" style="background-color: #{{ link.color }}">&nbsp;</td>
<td class="table-legend-td table-legend-td-brighten" style="opacity: 0.73; background-color: #{{ link.color }}">&nbsp;</td>
{% else %}
<td class="table-legend-td" style="background-color: #{{ link.color }}">&nbsp;</td>
{% endif %}
</tr>
</table>
</td>
<td class="small">{{ link.descr }}</td>
{% endfor %}
{% endif %}
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,45 @@
<div class="col-lg-2 col-sm-12">
<div class="sticky-top sticky-top-legend">
<div class="card">
{{ form_start(form.legend) }}
<div class="card-body">
<h3 class="card-title">
<strong>Legend</strong>
</h3>
<div class="table-responsive">
<table class="table table-borderless table-vcenter table-sm">
<tbody>
{% if knownlinks is defined %}
{% for link in knownlinks %}
<tr>
<td>
<table class="table-legend">
<tr>
{% if configapplication_graph('brighten_negative') %}
<td class="table-legend-td table-legend-td-brighten" style="background-color: #{{ link.color }}">&nbsp;</td>
<td class="table-legend-td table-legend-td-brighten" style="opacity: 0.73; background-color: #{{ link.color }}">&nbsp;</td>
{% else %}
<td class="table-legend-td" style="background-color: #{{ link.color }}">&nbsp;</td>
{% endif %}
</tr>
</table>
</td>
<td class="small">{{ link.descr }}</td>
<td>
{% for field in form.legend %}
{% if field.vars.name == link.tag %}
{{ form_widget(field) }}
{% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
</div>
{{ form_end(form.legend) }}
</div>
</div>
</div>

View File

@ -10,43 +10,7 @@
{% block content %}
<div class="row row-cards">
<div class="col-2">
<div class="sticky-top sticky-top-legend">
<div class="card">
<div class="card-body">
<h3 class="card-title">
<strong>Legend</strong>
</h3>
<div class="table-responsive">
<table class="table table-borderless table-vcenter table-sm">
<tbody>
{% if knownlinks is defined %}
{% for link in knownlinks %}
<tr>
<td>
<table class="table-legend">
<tr>
{% if configapplication_graph('brighten_negative') %}
<td class="table-legend-td table-legend-td-brighten" style="background-color: #{{ link.color }}">&nbsp;</td>
<td class="table-legend-td table-legend-td-brighten" style="opacity: 0.73; background-color: #{{ link.color }}">&nbsp;</td>
{% else %}
<td class="table-legend-td" style="background-color: #{{ link.color }}">&nbsp;</td>
{% endif %}
</tr>
</table>
</td>
<td class="small">{{ link.descr }}</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% include 'core/legend.html.twig' %}
<div class="col">
<div class="row row-cards">
<div class="space-y">