Skip to content

Commit 911ac1c

Browse files
committed
Fix #14
1 parent 463a108 commit 911ac1c

File tree

8 files changed

+55
-12
lines changed

8 files changed

+55
-12
lines changed

Diff for: config/routes.php

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
->add('bug_catcher.dashboard.index', '/')
2626
->controller(DashboardController::class . "::index")
2727
->methods(['GET'])
28-
->add('bug_catcher.dashboard.status', '/status/{status}')
29-
->controller(DashboardController::class . "::index")
30-
->methods(['GET'])
3128
->add('bug_catcher.dashboard.detail', '/detail/{record}')
3229
->controller(DashboardController::class . "::detail")
3330
->methods(['GET']);

Diff for: src/Controller/DashboardController.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
namespace BugCatcher\Controller;
44

5+
use BugCatcher\Entity\Project;
6+
use BugCatcher\Repository\ProjectRepository;
7+
use Doctrine\ORM\EntityManagerInterface;
58
use Exception;
69
use BugCatcher\Entity\Record;
710
use Symfony\Component\DependencyInjection\Attribute\Autowire;
11+
use Symfony\Component\HttpFoundation\Request;
812
use Symfony\Component\HttpFoundation\Response;
13+
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
14+
use Symfony\Component\Uid\Uuid;
915

1016
final class DashboardController extends AbstractController
1117
{
@@ -18,9 +24,23 @@ public function __construct(
1824
) {}
1925

2026
public function index(
27+
EntityManagerInterface $em,
28+
Request $request,
29+
#[MapQueryParameter]
30+
string $project = 'all',
31+
#[MapQueryParameter]
2132
string $status = 'new'
2233
): Response {
23-
return $this->render('@BugCatcher/dashboard/index.html.twig', [
34+
if ($project == 'all') {
35+
$project = null;
36+
} else {
37+
$project = $em->getReference(Project::class, new Uuid($project));
38+
}
39+
$request->attributes->set('project', $project);
40+
$request->attributes->set('status', $status);
41+
42+
return $this->render('@BugCatcher/dashboard/index.html.twig', [
43+
"project" => $project,
2444
"status" => $status,
2545
"components" => $this->components,
2646
"refreshInterval" => $this->refreshInterval,

Diff for: src/Repository/RecordPingRepository.php

+8
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ public function save(RecordPing $entity, bool $flush = false): void
4141
}
4242

4343

44+
public function getQBWith(Project $project): QueryBuilder
45+
{
46+
$qb = $this->createQueryBuilder('r');
47+
48+
$qb->andWhere('r.project = :project')
49+
->setParameter('project', $project->getId(), UuidType::NAME);
4450

51+
return $qb;
52+
}
4553

4654
public function getLastRecord(Project $project, string $maxLife = '-1 hour'): ?RecordPing
4755
{

Diff for: src/Twig/Components/LogList.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ final class LogList extends AbstractController
2525
#[LiveProp]
2626
public string $status;
2727

28+
#[LiveProp]
29+
public ?Project $project = null;
30+
2831
#[LiveProp]
2932
public string $id;
3033
/** @var Record[] */
@@ -52,6 +55,11 @@ public function init(): void
5255
$discriminatorMap = array_flip($discriminatorMap);
5356
$keys = array_map(fn($class) => $discriminatorMap[$class] ?? null, $this->classes);
5457

58+
if ($this->project) {
59+
$projects = [$this->project];
60+
} else {
61+
$projects = $this->getUser()->getActiveProjects()->toArray();
62+
}
5563
/** @var Record[] $records */
5664
$records = $this->recordRepo->createQueryBuilder("record")
5765
->where("record.status like :status")
@@ -60,7 +68,7 @@ public function init(): void
6068
->setParameter("status", $this->status . '%')
6169
->setParameter("class", $keys)
6270
->setParameter('projects',
63-
array_map(fn(Project $p) => $p->getId()->toBinary(), $this->getUser()->getActiveProjects()->toArray())
71+
array_map(fn(Project $p) => $p->getId()->toBinary(), $projects)
6472
)
6573
->orderBy("record.date", "DESC")
6674
->setMaxResults(100)

Diff for: templates/base.html.twig

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@
5757
<a class="dropdown-item" href="{{ path('bug_catcher.admin') }}">Administration</a>
5858
{% endif %}
5959
<hr class="dropdown-divider">
60-
<a class="dropdown-item" href="{{ path('bug_catcher.dashboard.status',{status:'archived'}) }}">Archived logs</a>
61-
<a class="dropdown-item" href="{{ path('bug_catcher.dashboard.status',{status:'withheld'}) }}">Withheld logs</a>
60+
<a class="dropdown-item" href="{{ path('bug_catcher.dashboard.index',{status:'archived'}) }}">Archived
61+
logs</a>
62+
<a class="dropdown-item" href="{{ path('bug_catcher.dashboard.index',{status:'withheld'}) }}">Withheld
63+
logs</a>
6264
<a class="dropdown-item" href="{{ path('bug_catcher.dashboard.index') }}">New logs</a>
6365
<hr class="dropdown-divider">
6466
<a class="dropdown-item" href="{{ path('bug_catcher.security.change-password') }}">Change password</a>

Diff for: templates/components/LogList.html.twig

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@
55
{% set logs = this.logs %}
66
{% if logs|length %}
77
<div class="nav justify-content-end pb-1">
8+
{% if app.request.attributes.get("project") is not null %}
9+
<a href="{{ path('bug_catcher.dashboard.index') }}" class="btn btn-primary btn-sm mx-1">
10+
<twig:ux:icon name="lucide:filter-x" width="20px" height="20px"/>
11+
{{ 'Clear filter'|trans }}
12+
</a>
13+
{% endif %}
814
<button class="btn btn-outline-secondary btn-sm" aria-current="page"
915
data-action="live#action"
1016
data-live-action-param="clearAll"
1117
data-live-from-param="{{ this.to|date('Y-m-d-H-i-s') }}"
1218
data-live-to-param="{{ this.from|date('Y-m-d-H-i-s') }}"
1319
>
1420
<twig:ux:icon name="game-icons:magic-broom" width="20px" height="20px"/>
15-
Fix all
21+
{{ 'Fix all'|trans }}
1622
</button>
1723
</div>
1824
<ul class="list-group">

Diff for: templates/components/LogList/RecordLog.html.twig

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
{% endif %}
2020
<div>
2121
<span class="badge text-bg-secondary ">{{ log.date|date('d.m.Y H:i:s') }}</span>
22-
<span class="badge text-bg-primary ">{{ log.project.name }}</span>
22+
<a href="{{ path('bug_catcher.dashboard.index',{project:log.project.id,status:this.status}) }}"
23+
class="badge text-bg-primary text-decoration-none">{{ log.project.name }}</a>
2324
<span class="badge text-bg-{{ status }} ">{{ log.count }}</span>
2425
<div class="d-inline text-break">{{ log.message }}</div>
2526
</div>
@@ -29,22 +30,22 @@
2930
data-action="live#action"
3031
data-live-action-param="clearOne"
3132
data-live-status-param="resolved"
32-
title="Fix it"
33+
title="{{ 'Fix it'|trans }}"
3334
>
3435
<twig:ux:icon name="game-icons:magic-broom" width="20px" height="20px"/>
3536
</button>
3637
<a href="{{ path('bug_catcher.dashboard.detail',{"record":log.id}) }}"
3738
class="btn btn-outline-success btn-sm"
3839
target="_blank"
39-
title="Detail"
40+
title="{{ 'Detail'|trans }}"
4041
>
4142
<twig:ux:icon name="covid:virus-lab-research-magnifier-1" width="20px" height="20px"/>
4243
</a>
4344
<button type="button" class="btn btn-outline-info btn-sm"
4445
data-action="live#action"
4546
data-live-action-param="clearOne"
4647
data-live-status-param="archived"
47-
title="Archive it"
48+
title="{{ 'Archive it'|trans }}"
4849
>
4950
<twig:ux:icon name="clarity:archive-line" width="20px" height="20px"/>
5051
</button>

Diff for: templates/dashboard/index.html.twig

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{% for dashboardComponent in components %}
1010
{{ component(dashboardComponent,{
1111
status:status,
12+
project:project,
1213
'data-poll':"delay("~refreshInterval~"000)|$render"
1314
}) }}
1415
{% endfor %}

0 commit comments

Comments
 (0)