diff --git a/library/Icinga/Model/Pane.php b/library/Icinga/Model/Pane.php index cb80fe35c..fc843b572 100644 --- a/library/Icinga/Model/Pane.php +++ b/library/Icinga/Model/Pane.php @@ -56,8 +56,6 @@ class Pane extends Model $relations->belongsTo('home', Home::class) ->setCandidateKey('home_id'); - $relations->hasMany('dashboard_override', DashboardOverride::class) - ->setJoinType('LEFT'); $relations->hasMany('dashlet', Dashlet::class) ->setJoinType('LEFT'); } diff --git a/library/Icinga/Web/Dashboard/Common/DashboardManager.php b/library/Icinga/Web/Dashboard/Common/DashboardManager.php index b2e73170a..e7db25689 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardManager.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardManager.php @@ -5,6 +5,7 @@ namespace Icinga\Web\Dashboard\Common; use Icinga\Application\Icinga; +use Icinga\Application\Modules\DashletContainer; use Icinga\Authentication\Auth; use Icinga\Common\Database; use Icinga\Exception\ProgrammingError; @@ -14,7 +15,8 @@ use Icinga\Web\Dashboard\Dashboard; use Icinga\Web\Dashboard\DashboardHome; use Icinga\Web\Dashboard\Dashlet; use Icinga\Web\Dashboard\Pane; -use Icinga\Web\HomeMenu; +use Icinga\Web\Menu; +use Icinga\Web\Navigation\DashboardPane; use ipl\Orm\Query; use ipl\Sql\Connection; use ipl\Sql\Expression; @@ -40,7 +42,7 @@ trait DashboardManager public function load() { - $this->setEntries((new HomeMenu())->loadHomes()); + $this->setEntries((new Menu())->loadHomes()); $this->loadDashboardEntries(); $this->initGetDefaultHome(); @@ -253,36 +255,47 @@ trait DashboardManager { $moduleManager = Icinga::app()->getModuleManager(); foreach ($moduleManager->getLoadedModules() as $module) { + /** @var DashboardPane $dashboardPane */ foreach ($module->getDashboard() as $dashboardPane) { - $priority = 0; - /** @var Dashlet $dashlet */ - foreach ($dashboardPane->getEntries() as $dashlet) { - $uuid = self::getSHA1($module->getName() . $dashboardPane->getName() . $dashlet->getName()); + $pane = new Pane($dashboardPane->getName()); + $pane->setTitle($dashboardPane->getLabel()); + $pane->fromArray($dashboardPane->getAttributes()); + + foreach ($dashboardPane->getIterator()->getItems() as $dashletItem) { + $uuid = self::getSHA1($module->getName() . $pane->getName() . $dashletItem->getName()); + $dashlet = new Dashlet($dashletItem->getName(), $dashletItem->getUrl(), $pane); + $dashlet->fromArray($dashletItem->getAttributes()); $dashlet ->setUuid($uuid) - ->setPriority($priority++) ->setModule($module->getName()) - ->setModuleDashlet(true); + ->setModuleDashlet(true) + ->setPriority($dashletItem->getPriority()); self::updateOrInsertModuleDashlet($dashlet); + $pane->addEntry($dashlet); } if (in_array($module->getName(), ['monitoring', 'icingadb'], true)) { - self::$defaultPanes[$dashboardPane->getName()] = $dashboardPane; + self::$defaultPanes[$pane->getName()] = $pane; } } $priority = 0; foreach ($module->getDashlets() as $dashlet) { $identifier = self::getSHA1($module->getName() . $dashlet->getName()); - - $dashlet + $newDashlet = new Dashlet($dashlet->getName(), $dashlet->getUrl()); + $newDashlet->fromArray($dashlet->getProperties()); + $newDashlet ->setUuid($identifier) - ->setPriority($priority++) ->setModule($module->getName()) ->setModuleDashlet(true); - self::updateOrInsertModuleDashlet($dashlet); + if (! $newDashlet->getPriority()) { + $newDashlet->setPriority($priority); + } + + self::updateOrInsertModuleDashlet($newDashlet); + $priority++; } } } diff --git a/library/Icinga/Web/Dashboard/Common/ItemListControl.php b/library/Icinga/Web/Dashboard/Common/ItemListControl.php index afd11e741..874dd75a6 100644 --- a/library/Icinga/Web/Dashboard/Common/ItemListControl.php +++ b/library/Icinga/Web/Dashboard/Common/ItemListControl.php @@ -19,28 +19,28 @@ abstract class ItemListControl extends BaseHtmlElement * * @return string */ - protected abstract function getHtmlId(); + abstract protected function getHtmlId(); /** * Get a class name for the collapsible control * * @return string */ - protected abstract function getCollapsibleControlClass(); + abstract protected function getCollapsibleControlClass(); /** * Create an action link to be added at the end of the list * * @return HtmlElement */ - protected abstract function createActionLink(); + abstract protected function createActionLink(); /** * Create the appropriate item list of this control * * @return HtmlElement */ - protected abstract function createItemList(); + abstract protected function createItemList(); /** * Assemble a header element for this item list diff --git a/library/Icinga/Web/Dashboard/Settings.php b/library/Icinga/Web/Dashboard/Settings.php index 8b88d4df9..3e0479390 100644 --- a/library/Icinga/Web/Dashboard/Settings.php +++ b/library/Icinga/Web/Dashboard/Settings.php @@ -28,6 +28,8 @@ class Settings extends BaseHtmlElement { $activeHome = $this->dashboard->getActiveHome(); if (count($this->dashboard->getEntries()) === 1 && $activeHome->getName() === DashboardHome::DEFAULT_HOME) { + $this->setAttribute('data-icinga-home', DashboardHome::DEFAULT_HOME); + foreach ($activeHome->getEntries() as $pane) { $pane->setHome($activeHome); diff --git a/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php b/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php index 286d59918..b9ed59572 100644 --- a/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php +++ b/library/Icinga/Web/Widget/Tabextension/DashboardSettings.php @@ -1,5 +1,5 @@ urlParam = $urlParam; + $this->urlParams = $urlParams; } /** @@ -34,8 +34,7 @@ class DashboardSettings implements Tabextension */ public function apply(Tabs $tabs) { - $url = Url::fromPath(Dashboard::BASE_ROUTE . '/settings'); - $url = empty($this->urlParam) ? $url : $url->addParams($this->urlParam); + $url = Url::fromPath(Dashboard::BASE_ROUTE . '/settings')->addParams($this->urlParams); $tabs->add('dashboard_settings', [ 'icon' => 'service', 'url' => (string) $url,