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_pane' => $dashboard->getPane()->getName(),
|
||||||
'org_dashlet' => $dashboard->getName(),
|
'org_dashlet' => $dashboard->getName(),
|
||||||
'dashlet' => $dashboard->getTitle(),
|
'dashlet' => $dashboard->getTitle(),
|
||||||
'url' => $dashboard->getUrl()->getRelativeUrl()
|
'url' => $dashboard->getUrl()->getRelativeUrl(),
|
||||||
|
'description' => $dashboard->getDescription(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,6 +185,7 @@ class DashletForm extends SetupNewDashboardForm
|
|||||||
$customDashlet = null;
|
$customDashlet = null;
|
||||||
if (($dashlet = $this->getPopulatedValue('dashlet')) && ($url = $this->getPopulatedValue('url'))) {
|
if (($dashlet = $this->getPopulatedValue('dashlet')) && ($url = $this->getPopulatedValue('url'))) {
|
||||||
$customDashlet = new Dashlet($dashlet, $url, $currentPane);
|
$customDashlet = new Dashlet($dashlet, $url, $currentPane);
|
||||||
|
$customDashlet->setDescription($this->getPopulatedValue('description'));
|
||||||
|
|
||||||
if ($currentPane->hasEntry($customDashlet->getName()) || $this->customDashletAlreadyExists) {
|
if ($currentPane->hasEntry($customDashlet->getName()) || $this->customDashletAlreadyExists) {
|
||||||
if ($this->customDashletAlreadyExists) {
|
if ($this->customDashletAlreadyExists) {
|
||||||
@ -265,11 +267,14 @@ class DashletForm extends SetupNewDashboardForm
|
|||||||
$orgHome->setEntries([]);
|
$orgHome->setEntries([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var Dashlet $currentDashlet */
|
||||||
$currentDashlet = clone $orgDashlet;
|
$currentDashlet = clone $orgDashlet;
|
||||||
$currentDashlet
|
$currentDashlet
|
||||||
->setPane($currentPane)
|
->setPane($currentPane)
|
||||||
->setUrl($this->getValue('url'))
|
->setUrl($this->getValue('url'))
|
||||||
->setTitle($this->getValue('dashlet'));
|
->setTitle($this->getValue('dashlet'))
|
||||||
|
->setDescription($this->getValue('description'));
|
||||||
|
|
||||||
|
|
||||||
if ($orgPane->getName() !== $currentPane->getName()
|
if ($orgPane->getName() !== $currentPane->getName()
|
||||||
&& $currentPane->hasEntry($currentDashlet->getName())) {
|
&& $currentPane->hasEntry($currentDashlet->getName())) {
|
||||||
|
@ -43,7 +43,6 @@ class SetupNewDashboardForm extends BaseDashboardForm
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump all module dashlets which are not selected by the user
|
* 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'
|
* @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))) {
|
if ($this->getPopulatedValue($element) === 'y' || (! $strict && $this->getPopulatedValue($element))) {
|
||||||
$title = $this->getPopulatedValue($element);
|
$title = $this->getPopulatedValue($element);
|
||||||
$url = $this->getPopulatedValue($element . '_url');
|
$url = $this->getPopulatedValue($element . '_url');
|
||||||
|
$description = $this->getPopulatedValue($element . '_description');
|
||||||
|
|
||||||
if (! $strict && $title && $url) {
|
if (! $strict && $title && $url) {
|
||||||
$dashlet
|
$dashlet
|
||||||
->setUrl($url)
|
->setUrl($url)
|
||||||
->setName($title . '(' . $module . ')')
|
->setName($title . '(' . $module . ')')
|
||||||
->setTitle($title);
|
->setTitle($title)
|
||||||
|
->setDescription($description);
|
||||||
}
|
}
|
||||||
|
|
||||||
$chosenDashlets[$module][$dashlet->getName()] = $dashlet;
|
$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'
|
'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.'
|
'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()
|
protected function assemble()
|
||||||
|
@ -160,7 +160,8 @@ class DashletManager
|
|||||||
->setTitle($moduleDashlet->label)
|
->setTitle($moduleDashlet->label)
|
||||||
->setModuleDashlet(true)
|
->setModuleDashlet(true)
|
||||||
->setModule($moduleDashlet->module)
|
->setModule($moduleDashlet->module)
|
||||||
->setPriority($moduleDashlet->priority);
|
->setPriority($moduleDashlet->priority)
|
||||||
|
->setDescription($moduleDashlet->description);
|
||||||
|
|
||||||
if (! self::ensureItIsNotOrphaned($dashlet)) {
|
if (! self::ensureItIsNotOrphaned($dashlet)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -31,7 +31,8 @@ class Dashlet extends Model
|
|||||||
'label',
|
'label',
|
||||||
'url',
|
'url',
|
||||||
'priority',
|
'priority',
|
||||||
'disabled'
|
'disabled',
|
||||||
|
'description'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ CREATE TABLE `icingaweb_dashlet` (
|
|||||||
`url` VARCHAR NOT NULL,
|
`url` VARCHAR NOT NULL,
|
||||||
`priority` tinyint NOT NULL,
|
`priority` tinyint NOT NULL,
|
||||||
`disabled` TEXT CHECK ( disabled IN ('n', 'y') ) DEFAULT 'n',
|
`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
|
FOREIGN KEY (`dashboard_id`) REFERENCES `icingaweb_dashboard` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -252,12 +252,13 @@ class Dashlet extends BaseDashboard
|
|||||||
{
|
{
|
||||||
$pane = $this->getPane();
|
$pane = $this->getPane();
|
||||||
return [
|
return [
|
||||||
'id' => $this->getUuid(),
|
'id' => $this->getUuid(),
|
||||||
'pane' => ! $stringify ? $pane : ($pane ? $pane->getName() : null),
|
'pane' => ! $stringify ? $pane : ($pane ? $pane->getName() : null),
|
||||||
'name' => $this->getName(),
|
'name' => $this->getName(),
|
||||||
'url' => $this->getUrl()->getRelativeUrl(),
|
'url' => $this->getUrl()->getRelativeUrl(),
|
||||||
'label' => $this->getTitle(),
|
'label' => $this->getTitle(),
|
||||||
'priority' => $this->getPriority(),
|
'priority' => $this->getPriority(),
|
||||||
|
'description' => $this->getDescription()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ class Pane extends BaseDashboard implements Sortable
|
|||||||
->setDisabled($dashlet->disabled)
|
->setDisabled($dashlet->disabled)
|
||||||
->setModule($dashlet->icingaweb_module_dashlet->module ?? '')
|
->setModule($dashlet->icingaweb_module_dashlet->module ?? '')
|
||||||
->setModuleDashlet($dashlet->system_dashlet_id !== null)
|
->setModuleDashlet($dashlet->system_dashlet_id !== null)
|
||||||
->setDescription($dashlet->icingaweb_module_dashlet->description);
|
->setDescription($dashlet->description);
|
||||||
|
|
||||||
$this->addEntry($newDashlet);
|
$this->addEntry($newDashlet);
|
||||||
|
|
||||||
@ -193,7 +193,8 @@ class Pane extends BaseDashboard implements Sortable
|
|||||||
'label' => $dashlet->getTitle(),
|
'label' => $dashlet->getTitle(),
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'priority' => $order++,
|
'priority' => $order++,
|
||||||
'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled())
|
'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled()),
|
||||||
|
'description' => $dashlet->getDescription()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($dashlet->isModuleDashlet()) {
|
if ($dashlet->isModuleDashlet()) {
|
||||||
@ -233,7 +234,8 @@ class Pane extends BaseDashboard implements Sortable
|
|||||||
'label' => $dashlet->getTitle(),
|
'label' => $dashlet->getTitle(),
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'priority' => $moveDashlet ? $order++ : $dashlet->getPriority(),
|
'priority' => $moveDashlet ? $order++ : $dashlet->getPriority(),
|
||||||
'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled())
|
'disabled' => DBUtils::bool2BoolEnum($dashlet->isDisabled()),
|
||||||
|
'description' => $dashlet->getDescription()
|
||||||
], $filterCondition);
|
], $filterCondition);
|
||||||
} else {
|
} else {
|
||||||
// Failed to move the pane! Should have already been handled by the caller,
|
// Failed to move the pane! Should have already been handled by the caller,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user