diff --git a/application/forms/Dashboard/DashletForm.php b/application/forms/Dashboard/DashletForm.php index bbcd2503d..544a4125c 100644 --- a/application/forms/Dashboard/DashletForm.php +++ b/application/forms/Dashboard/DashletForm.php @@ -31,7 +31,8 @@ class DashletForm extends SetupNewDashboardForm 'org_pane' => $dashboard->getPane()->getName(), 'org_dashlet' => $dashboard->getName(), 'dashlet' => $dashboard->getTitle(), - 'url' => $dashboard->getUrl()->getRelativeUrl() + 'url' => $dashboard->getUrl()->getRelativeUrl(), + 'description' => $dashboard->getDescription(), ]); } @@ -184,6 +185,7 @@ class DashletForm extends SetupNewDashboardForm $customDashlet = null; if (($dashlet = $this->getPopulatedValue('dashlet')) && ($url = $this->getPopulatedValue('url'))) { $customDashlet = new Dashlet($dashlet, $url, $currentPane); + $customDashlet->setDescription($this->getPopulatedValue('description')); if ($currentPane->hasEntry($customDashlet->getName()) || $this->customDashletAlreadyExists) { if ($this->customDashletAlreadyExists) { @@ -265,11 +267,14 @@ class DashletForm extends SetupNewDashboardForm $orgHome->setEntries([]); } + /** @var Dashlet $currentDashlet */ $currentDashlet = clone $orgDashlet; $currentDashlet ->setPane($currentPane) ->setUrl($this->getValue('url')) - ->setTitle($this->getValue('dashlet')); + ->setTitle($this->getValue('dashlet')) + ->setDescription($this->getValue('description')); + if ($orgPane->getName() !== $currentPane->getName() && $currentPane->hasEntry($currentDashlet->getName())) { diff --git a/application/forms/Dashboard/SetupNewDashboardForm.php b/application/forms/Dashboard/SetupNewDashboardForm.php index f980be5d5..f5d4652ee 100644 --- a/application/forms/Dashboard/SetupNewDashboardForm.php +++ b/application/forms/Dashboard/SetupNewDashboardForm.php @@ -43,7 +43,6 @@ class SetupNewDashboardForm extends BaseDashboardForm /** * Dump all module dashlets which are not selected by the user - * from the member variable * * @param bool $strict Whether to match populated of the dashlet against a 'y' * @@ -59,12 +58,14 @@ class SetupNewDashboardForm extends BaseDashboardForm if ($this->getPopulatedValue($element) === 'y' || (! $strict && $this->getPopulatedValue($element))) { $title = $this->getPopulatedValue($element); $url = $this->getPopulatedValue($element . '_url'); + $description = $this->getPopulatedValue($element . '_description'); if (! $strict && $title && $url) { $dashlet ->setUrl($url) ->setName($title . '(' . $module . ')') - ->setTitle($title); + ->setTitle($title) + ->setDescription($description); } $chosenDashlets[$module][$dashlet->getName()] = $dashlet; @@ -187,6 +188,12 @@ class SetupNewDashboardForm extends BaseDashboardForm 'Enter url to be loaded in the dashlet. You can paste the full URL, including filters' ) ]); + + $this->addElement('textarea', $elementId . '_description', [ + 'label' => t('Description'), + 'value' => $dashlet->getDescription(), + 'description' => t('Enter description for the dashlet') + ]); } } } @@ -210,6 +217,12 @@ class SetupNewDashboardForm extends BaseDashboardForm 'Enter url to be loaded in the dashlet. You can paste the full URL, including filters.' ), ]); + + $this->addElement('textarea', 'description', [ + 'label' => t('Description'), + 'placeholder' => t('Enter dashlet description'), + 'description' => t('Enter description for the dashlet'), + ]); } protected function assemble() diff --git a/library/Icinga/Application/Modules/DashletManager.php b/library/Icinga/Application/Modules/DashletManager.php index dd9cdb3c9..77c129f99 100644 --- a/library/Icinga/Application/Modules/DashletManager.php +++ b/library/Icinga/Application/Modules/DashletManager.php @@ -160,7 +160,8 @@ class DashletManager ->setTitle($moduleDashlet->label) ->setModuleDashlet(true) ->setModule($moduleDashlet->module) - ->setPriority($moduleDashlet->priority); + ->setPriority($moduleDashlet->priority) + ->setDescription($moduleDashlet->description); if (! self::ensureItIsNotOrphaned($dashlet)) { continue; diff --git a/library/Icinga/Model/Dashlet.php b/library/Icinga/Model/Dashlet.php index 79439ecb2..cd93a8e64 100644 --- a/library/Icinga/Model/Dashlet.php +++ b/library/Icinga/Model/Dashlet.php @@ -31,7 +31,8 @@ class Dashlet extends Model 'label', 'url', 'priority', - 'disabled' + 'disabled', + 'description' ]; } diff --git a/library/Icinga/Test/fixtures.sql b/library/Icinga/Test/fixtures.sql index c9720088f..df91d896a 100644 --- a/library/Icinga/Test/fixtures.sql +++ b/library/Icinga/Test/fixtures.sql @@ -33,6 +33,7 @@ CREATE TABLE `icingaweb_dashlet` ( `url` VARCHAR NOT NULL, `priority` tinyint NOT NULL, `disabled` TEXT CHECK ( disabled IN ('n', 'y') ) DEFAULT 'n', + `description` text DEFAULT NULL, FOREIGN KEY (`dashboard_id`) REFERENCES `icingaweb_dashboard` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ); diff --git a/library/Icinga/Web/Dashboard/Dashlet.php b/library/Icinga/Web/Dashboard/Dashlet.php index 79e2a9693..aae92a97a 100644 --- a/library/Icinga/Web/Dashboard/Dashlet.php +++ b/library/Icinga/Web/Dashboard/Dashlet.php @@ -252,12 +252,13 @@ class Dashlet extends BaseDashboard { $pane = $this->getPane(); return [ - 'id' => $this->getUuid(), - 'pane' => ! $stringify ? $pane : ($pane ? $pane->getName() : null), - 'name' => $this->getName(), - 'url' => $this->getUrl()->getRelativeUrl(), - 'label' => $this->getTitle(), - 'priority' => $this->getPriority(), + 'id' => $this->getUuid(), + 'pane' => ! $stringify ? $pane : ($pane ? $pane->getName() : null), + 'name' => $this->getName(), + 'url' => $this->getUrl()->getRelativeUrl(), + 'label' => $this->getTitle(), + 'priority' => $this->getPriority(), + 'description' => $this->getDescription() ]; } } diff --git a/library/Icinga/Web/Dashboard/Pane.php b/library/Icinga/Web/Dashboard/Pane.php index 3e2365d3a..73acfc9da 100644 --- a/library/Icinga/Web/Dashboard/Pane.php +++ b/library/Icinga/Web/Dashboard/Pane.php @@ -116,7 +116,7 @@ class Pane extends BaseDashboard implements Sortable ->setDisabled($dashlet->disabled) ->setModule($dashlet->icingaweb_module_dashlet->module ?? '') ->setModuleDashlet($dashlet->system_dashlet_id !== null) - ->setDescription($dashlet->icingaweb_module_dashlet->description); + ->setDescription($dashlet->description); $this->addEntry($newDashlet); @@ -193,7 +193,8 @@ class Pane extends BaseDashboard implements Sortable 'label' => $dashlet->getTitle(), 'url' => $url, 'priority' => $order++, - 'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled()) + 'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled()), + 'description' => $dashlet->getDescription() ]); if ($dashlet->isModuleDashlet()) { @@ -233,7 +234,8 @@ class Pane extends BaseDashboard implements Sortable 'label' => $dashlet->getTitle(), 'url' => $url, 'priority' => $moveDashlet ? $order++ : $dashlet->getPriority(), - 'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled()) + 'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled()), + 'description' => $dashlet->getDescription() ], $filterCondition); } else { // Failed to move the pane! Should have already been handled by the caller,