From 6607af61e1aed722ebcf8d84a1202e5a02b19133 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 26 Apr 2016 13:50:02 +0200 Subject: [PATCH] Set dashboard active if it is not disabled --- .../Icinga/Web/Navigation/DashboardPane.php | 22 +++++++++++++++++++ library/Icinga/Web/Widget/Dashboard.php | 11 ++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Navigation/DashboardPane.php b/library/Icinga/Web/Navigation/DashboardPane.php index 02126240a..41d96bef4 100644 --- a/library/Icinga/Web/Navigation/DashboardPane.php +++ b/library/Icinga/Web/Navigation/DashboardPane.php @@ -17,6 +17,8 @@ class DashboardPane extends NavigationItem */ protected $dashlets; + protected $disabled; + /** * Set this pane's dashlets * @@ -72,4 +74,24 @@ class DashboardPane extends NavigationItem $item->getDashlets(false) )); } + + /** + * Set disabled state for pane + * + * @param bool $disabled + */ + public function setDisabled($disabled=true) + { + $this->disabled = (bool) $disabled; + } + + /** + * Get disabled state for pane + * + * @return bool + */ + public function getDisabled() + { + return $this->disabled; + } } diff --git a/library/Icinga/Web/Widget/Dashboard.php b/library/Icinga/Web/Widget/Dashboard.php index ab47afb3f..405360cd8 100644 --- a/library/Icinga/Web/Widget/Dashboard.php +++ b/library/Icinga/Web/Widget/Dashboard.php @@ -373,8 +373,15 @@ class Dashboard extends AbstractWidget */ private function setDefaultPane() { - reset($this->panes); - $active = key($this->panes); + $active = null; + + foreach ($this->panes as $key=>$pane) { + if ($pane->getDisabled() === false) { + $active = $key; + break; + } + } + if ($active !== null) { $this->activate($active); }