mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 06:14:25 +02:00
parent
72f0e809ae
commit
30920d1178
@ -6,6 +6,7 @@ namespace Icinga\Controllers;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Zend_Controller_Action_Exception;
|
use Zend_Controller_Action_Exception;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Icinga\Exception\Http\HttpNotFoundException;
|
||||||
use Icinga\Forms\ConfirmRemovalForm;
|
use Icinga\Forms\ConfirmRemovalForm;
|
||||||
use Icinga\Forms\Dashboard\DashletForm;
|
use Icinga\Forms\Dashboard\DashletForm;
|
||||||
use Icinga\Web\Controller\ActionController;
|
use Icinga\Web\Controller\ActionController;
|
||||||
@ -197,6 +198,62 @@ class DashboardController extends ActionController
|
|||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function renamePaneAction()
|
||||||
|
{
|
||||||
|
$paneName = $this->params->getRequired('pane');
|
||||||
|
if (! $this->dashboard->hasPane($paneName)) {
|
||||||
|
throw new HttpNotFoundException('Pane not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = new Form();
|
||||||
|
$form->setRedirectUrl('dashboard/settings');
|
||||||
|
$form->setSubmitLabel($this->translate('Update Pane'));
|
||||||
|
$form->addElement(
|
||||||
|
'text',
|
||||||
|
'name',
|
||||||
|
array(
|
||||||
|
'required' => true,
|
||||||
|
'label' => $this->translate('Name')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$form->addElement(
|
||||||
|
'text',
|
||||||
|
'title',
|
||||||
|
array(
|
||||||
|
'required' => true,
|
||||||
|
'label' => $this->translate('Title')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$form->setDefaults(array(
|
||||||
|
'name' => $paneName,
|
||||||
|
'title' => $this->dashboard->getPane($paneName)->getTitle()
|
||||||
|
));
|
||||||
|
$form->setOnSuccess(function ($form) use ($paneName) {
|
||||||
|
$newName = $form->getValue('name');
|
||||||
|
$newTitle = $form->getValue('title');
|
||||||
|
|
||||||
|
$pane = $this->dashboard->getPane($paneName);
|
||||||
|
$pane->setName($newName);
|
||||||
|
$pane->setTitle($newTitle);
|
||||||
|
$this->dashboard->getConfig()->saveIni();
|
||||||
|
|
||||||
|
Notification::success(
|
||||||
|
sprintf($this->translate('Pane "%s" successfully renamed to "%s"'), $paneName, $newName)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
$form->handleRequest();
|
||||||
|
|
||||||
|
$this->view->form = $form;
|
||||||
|
$this->getTabs()->add(
|
||||||
|
'update-pane',
|
||||||
|
array(
|
||||||
|
'title' => $this->translate('Update Pane'),
|
||||||
|
'url' => $this->getRequest()->getUrl()
|
||||||
|
)
|
||||||
|
)->activate('update-pane');
|
||||||
|
}
|
||||||
|
|
||||||
public function removePaneAction()
|
public function removePaneAction()
|
||||||
{
|
{
|
||||||
$form = new ConfirmRemovalForm();
|
$form = new ConfirmRemovalForm();
|
||||||
|
6
application/views/scripts/dashboard/rename-pane.phtml
Normal file
6
application/views/scripts/dashboard/rename-pane.phtml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<div class="controls">
|
||||||
|
<?= $this->tabs ?>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<?= $this->form; ?>
|
||||||
|
</div>
|
@ -21,7 +21,16 @@
|
|||||||
<?php if ($pane->getDisabled()) continue; ?>
|
<?php if ($pane->getDisabled()) continue; ?>
|
||||||
<tr style="background-color: #f1f1f1;">
|
<tr style="background-color: #f1f1f1;">
|
||||||
<th colspan="2" style="text-align: left; padding: 0.5em;">
|
<th colspan="2" style="text-align: left; padding: 0.5em;">
|
||||||
|
<?php if ($pane->isUserWidget()): ?>
|
||||||
|
<?= $this->qlink(
|
||||||
|
$pane->getName(),
|
||||||
|
'dashboard/rename-pane',
|
||||||
|
array('pane' => $pane->getName()),
|
||||||
|
array('title' => sprintf($this->translate('Edit pane %s'), $pane->getName()))
|
||||||
|
) ?>
|
||||||
|
<?php else: ?>
|
||||||
<?= $this->escape($pane->getName()) ?>
|
<?= $this->escape($pane->getName()) ?>
|
||||||
|
<?php endif ?>
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
<?= $this->qlink(
|
<?= $this->qlink(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user