mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 18:59:04 +02:00
Dashboard: Introduce DashboardHomeList
widget
This commit is contained in:
parent
a121c9571d
commit
3dcf9fa02a
72
library/Icinga/Web/Dashboard/ItemList/DashboardHomeList.php
Normal file
72
library/Icinga/Web/Dashboard/ItemList/DashboardHomeList.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Web\Dashboard\ItemList;
|
||||
|
||||
use Icinga\Web\Dashboard\Dashboard;
|
||||
use Icinga\Web\Navigation\DashboardHome;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\HtmlElement;
|
||||
use ipl\Web\Url;
|
||||
use ipl\Web\Widget\ActionLink;
|
||||
use ipl\Web\Widget\Icon;
|
||||
use ipl\Web\Widget\Link;
|
||||
|
||||
class DashboardHomeList extends BaseHtmlElement
|
||||
{
|
||||
protected $defaultAttributes = ['class' => 'home-item-list'];
|
||||
|
||||
protected $tag = 'ul';
|
||||
|
||||
/** @var DashboardHome */
|
||||
protected $home;
|
||||
|
||||
public function __construct(DashboardHome $home)
|
||||
{
|
||||
$this->home = $home;
|
||||
$this->home->setActive();
|
||||
$this->home->loadDashboardsFromDB();
|
||||
|
||||
$this->getAttributes()->add('class', $home->getName());
|
||||
}
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
$wrapper = HtmlElement::create('div', [
|
||||
'class' => 'home-list-control collapsible',
|
||||
'data-toggle-element' => '.dashboard-list-info'
|
||||
]);
|
||||
|
||||
$wrapper->addHtml(HtmlElement::create('div', ['class' => 'dashboard-list-info'], [
|
||||
new Icon('angle-down', ['class' => 'expand-icon', 'title' => t('Expand')]),
|
||||
new Icon('angle-up', ['class' => 'collapse-icon', 'title' => t('Collapse')])
|
||||
]));
|
||||
|
||||
$header = HtmlElement::create('h1', ['class' => 'collapsible-header home'], $this->home->getLabel());
|
||||
$url = Url::fromPath(Dashboard::BASE_ROUTE . '/rename-home')->setParams(['home' => $this->home->getName()]);
|
||||
|
||||
$header->addHtml(new Link(t('Edit'), $url, [
|
||||
'data-icinga-modal' => true,
|
||||
'data-no-icinga-ajax' => true
|
||||
]));
|
||||
|
||||
$wrapper->addHtml($header);
|
||||
|
||||
// List all dashboard panes
|
||||
foreach ($this->home->getPanes() as $pane) {
|
||||
$pane->setHome($this->home); // In case it's not set
|
||||
|
||||
$this->addHtml(new DashboardList($pane));
|
||||
}
|
||||
|
||||
$url = Url::fromPath(Dashboard::BASE_ROUTE . '/new-dashlet');
|
||||
$url->setParams(['home' => $this->home->getName()]);
|
||||
|
||||
$wrapper->addHtml(new ActionLink(t('Add Dashboard'), $url, 'plus', [
|
||||
'class' => 'add-dashboard',
|
||||
'data-icinga-modal' => true,
|
||||
'data-no-icinga-ajax' => true
|
||||
]));
|
||||
|
||||
$this->addWrapper($wrapper);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user