mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 10:57:40 +02:00
Dashboard: Introduce Settings
class to manage to the new dashbaords
This commit is contained in:
parent
610effb140
commit
077ee4b537
59
library/Icinga/Web/Dashboard/Settings.php
Normal file
59
library/Icinga/Web/Dashboard/Settings.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/* Icinga Web 2 | (c) 2022 Icinga GmbH | GPLv2+ */
|
||||
|
||||
namespace Icinga\Web\Dashboard;
|
||||
|
||||
use Icinga\Web\Dashboard\ItemList\DashboardHomeList;
|
||||
use Icinga\Web\Dashboard\ItemList\DashboardList;
|
||||
use Icinga\Web\Navigation\DashboardHome;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Web\Url;
|
||||
use ipl\Web\Widget\ActionLink;
|
||||
|
||||
class Settings extends BaseHtmlElement
|
||||
{
|
||||
protected $defaultAttributes = ['class' => ['dashboard-settings content']];
|
||||
|
||||
protected $tag = 'div';
|
||||
|
||||
/** @var Dashboard */
|
||||
protected $dashboard;
|
||||
|
||||
public function __construct(Dashboard $dashboard)
|
||||
{
|
||||
$this->dashboard = $dashboard;
|
||||
}
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
// TODO: What we should with disabled homes??
|
||||
$activeHome = $this->dashboard->getActiveHome();
|
||||
|
||||
if (empty($this->dashboard->getHomes())) {
|
||||
// TODO: No dashboard homes :( what should we render now??
|
||||
} elseif (count($this->dashboard->getHomes()) === 1 && $activeHome->getName() === DashboardHome::DEFAULT_HOME) {
|
||||
foreach ($activeHome->getPanes() as $pane) {
|
||||
$pane->setHome($activeHome);
|
||||
|
||||
$this->addHtml(new DashboardList($pane));
|
||||
}
|
||||
|
||||
$this->addHtml(new ActionLink(
|
||||
t('Add Dashboard'),
|
||||
Url::fromPath(Dashboard::BASE_ROUTE . '/new-dashlet'),
|
||||
'plus',
|
||||
[
|
||||
'class' => 'add-dashboard',
|
||||
'data-icinga-modal' => true,
|
||||
'data-no-icinga-ajax' => true
|
||||
]
|
||||
));
|
||||
} else {
|
||||
// Make a list of dashbaord homes
|
||||
foreach ($this->dashboard->getHomes() as $home) {
|
||||
$this->addHtml(new DashboardHomeList($home));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user