Skip to content

Commit

Permalink
Ajuste la page stats pour le nouveau dashboard Metabase (#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca authored Jan 8, 2025
1 parent c0534af commit 5016a1e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 203 deletions.
11 changes: 0 additions & 11 deletions src/Application/Regulation/Query/GetStatisticsQuery.php

This file was deleted.

32 changes: 0 additions & 32 deletions src/Application/Regulation/Query/GetStatisticsQueryHandler.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Infrastructure/Controller/StatisticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace App\Infrastructure\Controller;

use App\Application\QueryBusInterface;
use App\Application\Regulation\Query\GetStatisticsQuery;
use App\Infrastructure\Adapter\MetabaseEmbedFactory;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
Expand All @@ -14,20 +12,16 @@ final class StatisticsController
{
public function __construct(
private \Twig\Environment $twig,
private QueryBusInterface $queryBus,
private MetabaseEmbedFactory $metabaseEmbedFactory,
) {
}

#[Route('/stats', name: 'app_stats', methods: ['GET'])]
public function __invoke(): Response
{
$statistics = $this->queryBus->handle(new GetStatisticsQuery());

$dashboardEmbedUrl = $this->metabaseEmbedFactory->makeDashboardUrl();

return new Response($this->twig->render('statistics.html.twig', [
'statistics' => $statistics,
'dashboardEmbedUrl' => $dashboardEmbedUrl,
]));
}
Expand Down
97 changes: 15 additions & 82 deletions templates/statistics.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,87 +8,20 @@
<div class="fr-container fr-x-max-w-156w fr-py-2w fr-py-md-5w">
<h1>{{ 'statistics.title'|trans }}</h1>

<div class="fr-grid-row fr-mb-3w">
<div class="fr-col">
<d-responsive-iframe
maxWidth="1200" {# Corresponds to 156w #}
extraPadding="32"
targetOrigin="{{ app.request.schemeAndHttpHost }}"
>
<iframe
src="{{ dashboardEmbedUrl }}"
frameborder="0"
width="1200"
height="500"
allowtransparency
title="{{ 'statistics.dashboard.title'|trans }}"
data-testid="stat"
></iframe>
</d-responsive-iframe>
</div>
</div>

<div class="fr-grid-row fr-grid-row--gutters fr-grid-row--middle fr-mb-3w">
<div class="fr-col fr-col-12 fr-col-md-6">
<div class="fr-card" data-testid="stat">
<div class="fr-card__body">
<div class="fr-card__content">
<h3 class="fr-card__title">{{ 'statistics.users'|trans }}</h3>
<p class="fr-card__desc">{{ statistics.users }}</p>
</div>
</div>
</div>
</div>
<div class="fr-col fr-col-12 fr-col-md-6">
<div class="fr-card" data-testid="stat">
<div class="fr-card__body">
<div class="fr-card__content">
<h3 class="fr-card__title">{{ 'statistics.organizations'|trans }}</h3>
<p class="fr-card__desc">{{ statistics.organizations }}</p>
</div>
</div>
</div>
</div>
<div class="fr-col fr-col-12 fr-col-md-6">
<div class="fr-card" data-testid="stat">
<div class="fr-card__body">
<div class="fr-card__content">
<h3 class="fr-card__title">{{ 'statistics.totalRegulationOrderRecords'|trans }}</h3>
<p class="fr-card__desc">{{ statistics.totalRegulationOrderRecords }}</p>
</div>
</div>
</div>
</div>
<div class="fr-col fr-col-12 fr-col-md-6">
<div class="fr-card" data-testid="stat">
<div class="fr-card__body">
<div class="fr-card__content">
<h3 class="fr-card__title">{{ 'statistics.publishedRegulationOrderRecords'|trans }}</h3>
<p class="fr-card__desc">{{ statistics.publishedRegulationOrderRecords }}</p>
</div>
</div>
</div>
</div>
<div class="fr-col fr-col-12 fr-col-md-6">
<div class="fr-card" data-testid="stat">
<div class="fr-card__body">
<div class="fr-card__content">
<h3 class="fr-card__title">{{ 'statistics.permanentRegulationOrderRecords'|trans }}</h3>
<p class="fr-card__desc">{{ statistics.permanentRegulationOrderRecords }}</p>
</div>
</div>
</div>
</div>
<div class="fr-col fr-col-12 fr-col-md-6">
<div class="fr-card" data-testid="stat">
<div class="fr-card__body">
<div class="fr-card__content">
<h3 class="fr-card__title">{{ 'statistics.temporaryRegulationOrderRecords'|trans }}</h3>
<p class="fr-card__desc">{{ statistics.temporaryRegulationOrderRecords }}</p>
</div>
</div>
</div>
</div>
</div>
<d-responsive-iframe
maxWidth="1200" {# Corresponds to 156w #}
extraPadding="32"
targetOrigin="{{ app.request.schemeAndHttpHost }}"
>
<iframe
src="{{ dashboardEmbedUrl }}"
frameborder="0"
width="1200"
height="1200"
allowtransparency
title="{{ 'statistics.dashboard.title'|trans }}"
data-testid="dashboard"
></iframe>
</d-responsive-iframe>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,7 @@ public function testStatistics(): void
$this->assertMetaTitle('Statistiques - DiaLog', $crawler);
$this->assertSame('Statistiques', $crawler->filter('h1')->text());

$stats = $crawler->filter('[data-testid=stat]');
$this->assertSame(7, $stats->count());

$this->assertSame('Tableau de bord des indicateurs', $stats->eq(0)->attr('title'));
$this->assertSame("Nombre total d'utilisateurs 3", $stats->eq(1)->text());
$this->assertSame("Nombre total d'organisations 2", $stats->eq(2)->text());
$this->assertSame("Nombre total d'arrếtés 1", $stats->eq(3)->text());
$this->assertSame("Nombre total d'arrếtés publiés 1", $stats->eq(4)->text());
$this->assertSame("Nombre total d'arrếtés permanents 0", $stats->eq(5)->text());
$this->assertSame("Nombre total d'arrếtés temporaires 1", $stats->eq(6)->text());
$dashboard = $crawler->filter('[data-testid=dashboard]')->eq(0);
$this->assertSame('Tableau de bord des indicateurs', $dashboard->attr('title'));
}
}

This file was deleted.

0 comments on commit 5016a1e

Please sign in to comment.