dashboard widgets are configurable via config (#269)

This commit is contained in:
Kevin Papst
2018-08-17 23:17:02 +02:00
committed by GitHub
parent 7804ef83ce
commit dbbb434723
49 changed files with 2011 additions and 938 deletions

View File

@@ -135,7 +135,8 @@ And that's how to use it:
```php
use App\Event\DashboardEvent;
use App\Model\WidgetRow;
use App\Model\DashboardSection;
use App\Model\Widget;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class MyDashboardSubscriber implements EventSubscriberInterface
@@ -147,14 +148,19 @@ class MyDashboardSubscriber implements EventSubscriberInterface
public function onDashboardEvent(DashboardEvent $event)
{
$row = new WidgetRow('my_id', 'optional.row.title');
// this needs to be a valid twig template string
$row->add("{{ widgets.info_box_counter('a title', 100, 'far fa-hourglass', 'green') }}");
$event->addWidgetRow($row);
$section = new DashboardSection('optional.row.title');
$widget = new Widget('A title', 100);
$widget
->setIcon('duration')
->setColor('purple')
->setType(Widget::TYPE_COUNTER)
;
$section->addWidget($widget);
$event->addSection($section);
}
}
```
For more details check the [official dashboard subscriber](../../src/EventSubscriber/DashboardSubscriber.php).
For more details check this [dashboard subscriber](../../src/EventSubscriber/DashboardSubscriber.php).
## Adding tabs to the "control sidebar"
@@ -172,7 +178,8 @@ admin_lte:
icon: "fas fa-question-circle"
template: sidebar/home.html.twig
```
You have to define the `icon` (FontAwesome 5) to be used and one of: `controller` action or twig `template`.
You have to define the `icon` ([read more](theme.md)) to be used and either `controller` action or twig `template`.
Both follow the default naming syntax and you can link your bundle here instead of the app controller or templates.
You should NOT add them in `config/packages/kimai.yaml` but in your own bundle or the `local.yaml` [config](configurations.md),
otherwise they might get lost during an update.