feat: add dashboard widget with placeholder template
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0116af5d40
commit
263ab8a9d9
3 changed files with 83 additions and 0 deletions
29
EventSubscriber/DashboardSubscriber.php
Normal file
29
EventSubscriber/DashboardSubscriber.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace KimaiPlugin\KimaiHeatmapBundle\EventSubscriber;
|
||||
|
||||
use App\Event\DashboardEvent;
|
||||
use App\Widget\WidgetService;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
final class DashboardSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(private readonly WidgetService $widgetService)
|
||||
{
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
DashboardEvent::class => ['onDashboard', 100],
|
||||
];
|
||||
}
|
||||
|
||||
public function onDashboard(DashboardEvent $event): void
|
||||
{
|
||||
$widget = $this->widgetService->getWidget('HeatmapWidget');
|
||||
if ($widget !== null) {
|
||||
$event->addWidget($widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Resources/views/widget/heatmap.html.twig
Normal file
10
Resources/views/widget/heatmap.html.twig
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{% embed '@theme/embeds/card.html.twig' with {'margin_bottom': 0} %}
|
||||
{% block box_title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
{% block box_body %}
|
||||
<div id="heatmap-container" data-url="{{ path('heatmap_data') }}" style="min-height: 150px; padding: 1rem;">
|
||||
<p style="color: var(--bs-secondary);">Heatmap visualization coming in Phase 3</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
44
Widget/HeatmapWidget.php
Normal file
44
Widget/HeatmapWidget.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace KimaiPlugin\KimaiHeatmapBundle\Widget;
|
||||
|
||||
use App\Widget\Type\AbstractWidget;
|
||||
use App\Widget\WidgetInterface;
|
||||
|
||||
final class HeatmapWidget extends AbstractWidget
|
||||
{
|
||||
public function getId(): string
|
||||
{
|
||||
return 'HeatmapWidget';
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Activity Heatmap';
|
||||
}
|
||||
|
||||
public function getWidth(): int
|
||||
{
|
||||
return WidgetInterface::WIDTH_FULL;
|
||||
}
|
||||
|
||||
public function getHeight(): int
|
||||
{
|
||||
return WidgetInterface::HEIGHT_LARGE;
|
||||
}
|
||||
|
||||
public function getPermissions(): array
|
||||
{
|
||||
return ['view_own_timesheet'];
|
||||
}
|
||||
|
||||
public function getData(array $options = []): mixed
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getTemplateName(): string
|
||||
{
|
||||
return '@KimaiHeatmapBundle/widget/heatmap.html.twig';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue