mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-24 10:27:46 +02:00
Allow adding and editing of dashlet description.
This commit is contained in:
parent
cc5e08da7d
commit
8f9a55fcbf
@ -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())) {
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -31,7 +31,8 @@ class Dashlet extends Model
|
||||
'label',
|
||||
'url',
|
||||
'priority',
|
||||
'disabled'
|
||||
'disabled',
|
||||
'description'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
);
|
||||
|
||||
|
@ -258,6 +258,7 @@ class Dashlet extends BaseDashboard
|
||||
'url' => $this->getUrl()->getRelativeUrl(),
|
||||
'label' => $this->getTitle(),
|
||||
'priority' => $this->getPriority(),
|
||||
'description' => $this->getDescription()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user