diff --git a/application/controllers/DashboardsController.php b/application/controllers/DashboardsController.php index 4c0e76a0e..07444078b 100644 --- a/application/controllers/DashboardsController.php +++ b/application/controllers/DashboardsController.php @@ -45,11 +45,7 @@ class DashboardsController extends CompatController $activeHome = $this->dashboard->getActiveHome(); if (! $activeHome || ! $activeHome->hasEntries()) { - $this->getTabs()->add('dashboard', [ - 'active' => true, - 'title' => t('Welcome'), - 'url' => Url::fromRequest() - ]); + $this->addTitleTab(t('Welcome')); // Setup dashboard introduction form $welcomeForm = new WelcomeForm($this->dashboard); @@ -85,11 +81,7 @@ class DashboardsController extends CompatController $activeHome = $this->dashboard->getActiveHome(); if (! $activeHome->getEntries()) { - $this->getTabs()->add($activeHome->getName(), [ - 'active' => true, - 'title' => $activeHome->getTitle(), - 'url' => Url::fromRequest() - ]); + $this->addTitleTab($activeHome->getTitle()); } // Not to render the cog icon before the above tab diff --git a/library/Icinga/Web/Dashboard/Common/DashboardManager.php b/library/Icinga/Web/Dashboard/Common/DashboardManager.php index 289dede38..d7dc6c93c 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardManager.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardManager.php @@ -369,14 +369,16 @@ trait DashboardManager $dashlet->fromArray([ 'label' => t($moduleDashlet->label), 'priority' => $moduleDashlet->priority, - 'uuid' => $moduleDashlet->id + 'uuid' => $moduleDashlet->id, + 'module' => $moduleDashlet->module ]); if (($pane = $moduleDashlet->pane)) { $dashlet->setPane(new Pane($pane)); } - $dashlets[$moduleDashlet->module][$dashlet->getName()] = $dashlet; + $dashlet->setModuleDashlet(true); + $dashlets[$dashlet->getModule()][$dashlet->getName()] = $dashlet; } return $dashlets; diff --git a/library/Icinga/Web/Dashboard/Dashboard.php b/library/Icinga/Web/Dashboard/Dashboard.php index fe4fd6bff..7fd004ebe 100644 --- a/library/Icinga/Web/Dashboard/Dashboard.php +++ b/library/Icinga/Web/Dashboard/Dashboard.php @@ -140,10 +140,11 @@ class Dashboard extends BaseHtmlElement implements DashboardEntry return $this->tabs; } - foreach ($activeHome->getEntries() as $key => $pane) { - if (! $this->tabs->get($key)) { + /*** @var Pane $pane */ + foreach ($activeHome->getEntries() as $pane) { + if (! $this->tabs->get($pane->getName())) { $this->tabs->add( - $key, + $pane->getName(), [ 'title' => sprintf( t('Show %s', 'dashboard.pane.tooltip'), @@ -151,7 +152,7 @@ class Dashboard extends BaseHtmlElement implements DashboardEntry ), 'label' => $pane->getTitle(), 'url' => clone($url), - 'urlParams' => [$this->tabParam => $key] + 'urlParams' => [$this->tabParam => $pane->getName()] ] ); } @@ -163,18 +164,13 @@ class Dashboard extends BaseHtmlElement implements DashboardEntry /** * Activate the default pane of this dashboard and returns its name * - * @return ?int|string + * @return ?string */ private function setDefaultPane() { - $active = null; - $activeHome = $this->getActiveHome(); - foreach ($activeHome->getEntries() as $key => $pane) { - $active = $key; - break; - } - - if ($active !== null) { + $active = $this->getActiveHome()->rewindEntries(); + if ($active) { + $active = $active->getName(); $this->activate($active); } @@ -216,9 +212,8 @@ class Dashboard extends BaseHtmlElement implements DashboardEntry $active = $active->getName(); } - $panes = $activeHome->getEntries(); - if (isset($panes[$active])) { - return $panes[$active]; + if ($activeHome->hasEntry($active)) { + return $activeHome->getEntry($active); } throw new ConfigurationError('Could not determine active pane'); diff --git a/library/Icinga/Web/Dashboard/Pane.php b/library/Icinga/Web/Dashboard/Pane.php index b74e1ed7d..8b23cd209 100644 --- a/library/Icinga/Web/Dashboard/Pane.php +++ b/library/Icinga/Web/Dashboard/Pane.php @@ -156,19 +156,15 @@ class Pane extends BaseDashboard implements Sortable ]); if ($dashlet->isModuleDashlet()) { - $systemUuid = $dashlet->getUuid(); - if (! $systemUuid && $dashlet->getPane()) { - $systemUuid = Dashboard::getSHA1( - $dashlet->getModule() . $dashlet->getPane()->getName() . $dashlet->getName() - ); + $data = $dashlet->getModule(); + if (($pane = $dashlet->getPane())) { + $data .= $pane->getName(); } - if ($systemUuid) { - $conn->insert('icingaweb_system_dashlet', [ - 'dashlet_id' => $uuid, - 'module_dashlet_id' => $systemUuid - ]); - } + $conn->insert('icingaweb_system_dashlet', [ + 'dashlet_id' => $uuid, + 'module_dashlet_id' => Dashboard::getSHA1($data . $dashlet->getName()) + ]); } } elseif (! $this->hasEntry($dashlet->getName()) || ! $origin || ! $origin->hasEntry($dashlet->getName())) { diff --git a/library/Icinga/Web/Dashboard/Setup/SetupNewDashboard.php b/library/Icinga/Web/Dashboard/Setup/SetupNewDashboard.php index 0b7466801..8a81c13c4 100644 --- a/library/Icinga/Web/Dashboard/Setup/SetupNewDashboard.php +++ b/library/Icinga/Web/Dashboard/Setup/SetupNewDashboard.php @@ -201,19 +201,9 @@ class SetupNewDashboard extends BaseDashboardForm $title = $this->getPopulatedValue($element); $url = $this->getPopulatedValue($element . '_url'); - $dashlet ->setUrl($url) - ->setTitle($title) - ->setModule($module) - ->setModuleDashlet(true); - - if ($dashlet->getPane()) { - $paneName = $dashlet->getPane()->getName(); - $dashlet->setUuid(Dashboard::getSHA1($module . $paneName . $dashlet->getName())); - } else { - $dashlet->setUuid(Dashboard::getSHA1($module . $dashlet->getName())); - } + ->setTitle($title); $moduleDashlets[$dashlet->getName()] = $dashlet; } diff --git a/public/css/icinga/dashboards.less b/public/css/icinga/dashboards.less index 8a06ed9f5..3f83ea401 100644 --- a/public/css/icinga/dashboards.less +++ b/public/css/icinga/dashboards.less @@ -305,7 +305,7 @@ form.icinga-form .control-group.form-controls .remove-button { margin-right: auto; } -.modal-form .form-controls .modal-cancel { +.modal-form .control-group.form-controls .modal-cancel { padding: .5em 1em; } @@ -325,13 +325,9 @@ form.icinga-form .control-group.form-controls .remove-button { .sortable-chosen { .box-shadow(); background: fade(@icinga-blue, 20); - border: 5px @body-bg-color dashed; + border: .5em @body-bg-color dashed; } .home-list-control.sortable-drag { width: calc(85% + 1.4em); } - -.draggable-element { - opacity: .4; -}