mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 18:59:04 +02:00
Regroup dashboard input elements
This commit is contained in:
parent
09b87eac90
commit
037adcb975
@ -48,6 +48,24 @@ class DashletForm extends BaseDashboardForm
|
|||||||
$this->addElement('hidden', 'org_home', ['required' => false]);
|
$this->addElement('hidden', 'org_home', ['required' => false]);
|
||||||
$this->addElement('hidden', 'org_dashlet', ['required' => false]);
|
$this->addElement('hidden', 'org_dashlet', ['required' => false]);
|
||||||
|
|
||||||
|
$this->addElement('text', 'dashlet', [
|
||||||
|
'required' => true,
|
||||||
|
'label' => t('Dashlet Title'),
|
||||||
|
'placeholder' => t('Enter a dashlet title'),
|
||||||
|
'description' => t('Enter a title for the dashlet.'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->addElement('textarea', 'url', [
|
||||||
|
'required' => true,
|
||||||
|
'label' => t('Url'),
|
||||||
|
'placeholder' => t('Enter dashlet url'),
|
||||||
|
'description' => t(
|
||||||
|
'Enter url to be loaded in the dashlet. You can paste the full URL, including filters.'
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->addHtml(new HtmlElement('hr'));
|
||||||
|
|
||||||
$this->addElement('select', 'home', [
|
$this->addElement('select', 'home', [
|
||||||
'class' => 'autosubmit',
|
'class' => 'autosubmit',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -55,7 +73,7 @@ class DashletForm extends BaseDashboardForm
|
|||||||
'value' => $populatedHome,
|
'value' => $populatedHome,
|
||||||
'multiOptions' => array_merge([self::CREATE_NEW_HOME => self::CREATE_NEW_HOME], $homes),
|
'multiOptions' => array_merge([self::CREATE_NEW_HOME => self::CREATE_NEW_HOME], $homes),
|
||||||
'label' => t('Select Home'),
|
'label' => t('Select Home'),
|
||||||
'descriptions' => t('Select a dashboard home you want to add the dashboard pane to.')
|
'description' => t('Select a dashboard home you want to add the dashboard pane to.')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (empty($homes) || $populatedHome === self::CREATE_NEW_HOME) {
|
if (empty($homes) || $populatedHome === self::CREATE_NEW_HOME) {
|
||||||
@ -79,7 +97,7 @@ class DashletForm extends BaseDashboardForm
|
|||||||
'class' => 'autosubmit',
|
'class' => 'autosubmit',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'disabled' => $disable ?: null,
|
'disabled' => $disable ?: null,
|
||||||
'value' => ! $disable ? $populatedPane : self::CREATE_NEW_PANE, // Cheat the browser complains
|
'value' => ! $disable ? $populatedPane : self::CREATE_NEW_PANE,
|
||||||
'multiOptions' => array_merge([self::CREATE_NEW_PANE => self::CREATE_NEW_PANE], $panes),
|
'multiOptions' => array_merge([self::CREATE_NEW_PANE => self::CREATE_NEW_PANE], $panes),
|
||||||
'label' => t('Select Dashboard'),
|
'label' => t('Select Dashboard'),
|
||||||
'description' => t('Select a dashboard you want to add the dashlet to.'),
|
'description' => t('Select a dashboard you want to add the dashlet to.'),
|
||||||
@ -94,24 +112,6 @@ class DashletForm extends BaseDashboardForm
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addHtml(new HtmlElement('hr'));
|
|
||||||
|
|
||||||
$this->addElement('textarea', 'url', [
|
|
||||||
'required' => true,
|
|
||||||
'label' => t('Url'),
|
|
||||||
'placeholder' => t('Enter dashlet url'),
|
|
||||||
'description' => t(
|
|
||||||
'Enter url to be loaded in the dashlet. You can paste the full URL, including filters.'
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->addElement('text', 'dashlet', [
|
|
||||||
'required' => true,
|
|
||||||
'label' => t('Dashlet Title'),
|
|
||||||
'placeholder' => t('Enter a dashlet title'),
|
|
||||||
'description' => t('Enter a title for the dashlet.'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$removeButton = null;
|
$removeButton = null;
|
||||||
if ($requestUrl->getPath() === Dashboard::BASE_ROUTE . '/edit-dashlet') {
|
if ($requestUrl->getPath() === Dashboard::BASE_ROUTE . '/edit-dashlet') {
|
||||||
$targetUrl = (clone $requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-dashlet');
|
$targetUrl = (clone $requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-dashlet');
|
||||||
|
@ -30,7 +30,15 @@ class HomePaneForm extends BaseDashboardForm
|
|||||||
$titleDesc = t('Edit the title of this dashboard pane');
|
$titleDesc = t('Edit the title of this dashboard pane');
|
||||||
$buttonLabel = t('Update Pane');
|
$buttonLabel = t('Update Pane');
|
||||||
$removeButtonLabel = t('Remove Pane');
|
$removeButtonLabel = t('Remove Pane');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addElement('text', 'title', [
|
||||||
|
'required' => true,
|
||||||
|
'label' => t('Title'),
|
||||||
|
'description' => $titleDesc
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($requestUrl->getPath() === Dashboard::BASE_ROUTE . '/edit-pane') {
|
||||||
$removeTargetUrl = (clone $requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-pane');
|
$removeTargetUrl = (clone $requestUrl)->setPath(Dashboard::BASE_ROUTE . '/remove-pane');
|
||||||
|
|
||||||
$homes = $this->dashboard->getEntryKeyTitleArr();
|
$homes = $this->dashboard->getEntryKeyTitleArr();
|
||||||
@ -55,12 +63,6 @@ class HomePaneForm extends BaseDashboardForm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addElement('text', 'title', [
|
|
||||||
'required' => true,
|
|
||||||
'label' => t('Title'),
|
|
||||||
'description' => $titleDesc
|
|
||||||
]);
|
|
||||||
|
|
||||||
$formControls = $this->createFormControls();
|
$formControls = $this->createFormControls();
|
||||||
$formControls->add([
|
$formControls->add([
|
||||||
$this->registerSubmitButton($buttonLabel),
|
$this->registerSubmitButton($buttonLabel),
|
||||||
@ -119,6 +121,8 @@ class HomePaneForm extends BaseDashboardForm
|
|||||||
try {
|
try {
|
||||||
$this->dashboard->manageEntry($currentHome);
|
$this->dashboard->manageEntry($currentHome);
|
||||||
$currentHome->manageEntry($currentPane, $orgHome);
|
$currentHome->manageEntry($currentPane, $orgHome);
|
||||||
|
// We have to update all the dashlet ids too sha1(username + home + pane + dashlet)
|
||||||
|
$currentPane->manageEntry($currentPane->getEntries());
|
||||||
|
|
||||||
$conn->commitTransaction();
|
$conn->commitTransaction();
|
||||||
} catch (\Exception $err) {
|
} catch (\Exception $err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user