diff --git a/library/Icinga/Web/Dashboard/Common/BaseDashboard.php b/library/Icinga/Web/Dashboard/Common/BaseDashboard.php index de39d2da7..abe3b9fe2 100644 --- a/library/Icinga/Web/Dashboard/Common/BaseDashboard.php +++ b/library/Icinga/Web/Dashboard/Common/BaseDashboard.php @@ -253,7 +253,7 @@ abstract class BaseDashboard implements DashboardEntry { } - public function manageEntry($entry, BaseDashboard $origin = null, $updateChildEntries = false) + public function manageEntry($entry, BaseDashboard $origin = null, $manageRecursive = false) { } diff --git a/library/Icinga/Web/Dashboard/Common/DashboardEntry.php b/library/Icinga/Web/Dashboard/Common/DashboardEntry.php index 0d5ab139f..92b891d9f 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardEntry.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardEntry.php @@ -105,13 +105,14 @@ interface DashboardEntry * move pane(s)|dashlet(s) from another to this widget you have to also provide the origin from which the * given entry(ies) originated * - * @param BaseDashboard|BaseDashboard[] $entry - * @param ?BaseDashboard $origin - * @param bool $updateChildEntries + * @param BaseDashboard|BaseDashboard[] $entry The actual dashboard entry to be managed + * @param ?BaseDashboard $origin The original widget from which the given entry originates + * @param bool $manageRecursive Whether the given entry should be managed recursively e.g if the given entry + * is a Pane type, all its dashlets can be managed recursively * * @return $this */ - public function manageEntry($entry, BaseDashboard $origin = null, $updateChildEntries = false); + public function manageEntry($entry, BaseDashboard $origin = null, $manageRecursive = false); /** * Load all the assigned entries to this widget diff --git a/library/Icinga/Web/Dashboard/Common/DashboardManager.php b/library/Icinga/Web/Dashboard/Common/DashboardManager.php index d4a2e898c..b2e73170a 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardManager.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardManager.php @@ -156,7 +156,7 @@ trait DashboardManager return $this; } - public function manageEntry($entry, BaseDashboard $origin = null, $updateChildEntries = false) + public function manageEntry($entry, BaseDashboard $origin = null, $manageRecursive = false) { $conn = self::getConn(); $homes = is_array($entry) ? $entry : [$entry]; diff --git a/library/Icinga/Web/Dashboard/DashboardHome.php b/library/Icinga/Web/Dashboard/DashboardHome.php index fc7cf97b7..d3adf3c10 100644 --- a/library/Icinga/Web/Dashboard/DashboardHome.php +++ b/library/Icinga/Web/Dashboard/DashboardHome.php @@ -38,6 +38,11 @@ class DashboardHome extends BaseDashboard implements Sortable */ protected $type = Dashboard::SYSTEM; + /** + * A flag whether this home has been activated + * + * @var bool + */ protected $active; /** @@ -49,7 +54,14 @@ class DashboardHome extends BaseDashboard implements Sortable */ public static function create(DashboardHomeItem $homeItem) { - return new self($homeItem->getName(), $homeItem->getAttributes()); + $self = new self($homeItem->getName()); + $self + ->setTitle($homeItem->getLabel()) + ->setPriority($homeItem->getPriority()) + ->setType($homeItem->getAttribute('type')) + ->setUuid($homeItem->getAttribute('uuid')); + + return $self; } /** @@ -160,7 +172,7 @@ class DashboardHome extends BaseDashboard implements Sortable return $this; } - public function manageEntry($entry, BaseDashboard $origin = null, $updateChildEntries = false) + public function manageEntry($entry, BaseDashboard $origin = null, $manageRecursive = false) { $user = Dashboard::getUser(); $conn = Dashboard::getConn(); @@ -218,7 +230,7 @@ class DashboardHome extends BaseDashboard implements Sortable $pane->setUuid($uuid); } - if ($updateChildEntries) { + if ($manageRecursive) { // Those dashboard panes are usually system defaults and go up when // the user is clicking on the "Use System Defaults" button $dashlets = $pane->getEntries(); diff --git a/library/Icinga/Web/Dashboard/Pane.php b/library/Icinga/Web/Dashboard/Pane.php index d41a62677..1b2626648 100644 --- a/library/Icinga/Web/Dashboard/Pane.php +++ b/library/Icinga/Web/Dashboard/Pane.php @@ -187,7 +187,7 @@ class Pane extends BaseDashboard implements Sortable, OverridingWidget $newDashlet = new Dashlet($dashlet->name, $dashlet->url, $this); $newDashlet->fromArray([ 'uuid' => $dashlet->id, - 'title' => t($dashlet->label), + 'title' => $dashlet->label, 'priority' => $dashlet->priority, 'pane' => $this, 'description' => $dashlet->module_dashlet->description @@ -199,7 +199,7 @@ class Pane extends BaseDashboard implements Sortable, OverridingWidget return $this; } - public function manageEntry($entry, BaseDashboard $origin = null, $updateChildEntries = false) + public function manageEntry($entry, BaseDashboard $origin = null, $manageRecursive = false) { if ($origin && ! $origin instanceof Pane) { throw new \InvalidArgumentException(sprintf( diff --git a/library/Icinga/Web/HomeMenu.php b/library/Icinga/Web/HomeMenu.php index a5a202ca2..7bd640645 100644 --- a/library/Icinga/Web/HomeMenu.php +++ b/library/Icinga/Web/HomeMenu.php @@ -55,10 +55,7 @@ class HomeMenu extends Menu continue; } - $home = DashboardHome::create($child); - $home->setTitle($child->getLabel()); - - $homes[$child->getName()] = $home; + $homes[$child->getName()] = DashboardHome::create($child); } return $homes;