commit
1c494b2b64
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Forms;
|
||||
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\User\Preferences;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Web\Session;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
/**
|
||||
* Form class to adjust user auto refresh preferences
|
||||
*/
|
||||
class AutoRefreshForm extends Form
|
||||
{
|
||||
/**
|
||||
* Initialize this form
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->setName('form_auto_refresh');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust preferences and persist them
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess()
|
||||
{
|
||||
/** @var Preferences $preferences */
|
||||
$preferences = $this->getRequest()->getUser()->getPreferences();
|
||||
$icingaweb = $preferences->get('icingaweb');
|
||||
|
||||
if ((bool) $preferences->getValue('icingaweb', 'auto_refresh', true) === false) {
|
||||
$icingaweb['auto_refresh'] = '1';
|
||||
$notification = $this->translate('Auto refresh successfully enabled');
|
||||
} else {
|
||||
$icingaweb['auto_refresh'] = '0';
|
||||
$notification = $this->translate('Auto refresh successfully disabled');
|
||||
}
|
||||
$preferences->icingaweb = $icingaweb;
|
||||
|
||||
Session::getSession()->user->setPreferences($preferences);
|
||||
Notification::success($notification);
|
||||
|
||||
$this->getResponse()->setHeader('X-Icinga-Rerender-Layout', 'yes');
|
||||
$this->setRedirectUrl(Url::fromRequest()->without('renderLayout'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Form::createElements()
|
||||
*/
|
||||
public function createElements(array $formData)
|
||||
{
|
||||
$preferences = $this->getRequest()->getUser()->getPreferences();
|
||||
|
||||
if ((bool) $preferences->getValue('icingaweb', 'auto_refresh', true) === false) {
|
||||
$value = $this->translate('Enable auto refresh');
|
||||
} else {
|
||||
$value = $this->translate('Disable auto refresh');
|
||||
}
|
||||
|
||||
$this->addElements(array(
|
||||
array(
|
||||
'button',
|
||||
'btn_submit',
|
||||
array(
|
||||
'ignore' => true,
|
||||
'type' => 'submit',
|
||||
'value' => $value,
|
||||
'decorators' => array('ViewHelper'),
|
||||
'escape' => false,
|
||||
'class' => 'link-like'
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
|
@ -185,6 +185,17 @@ class PreferenceForm extends Form
|
|||
)
|
||||
);
|
||||
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
'auto_refresh',
|
||||
array(
|
||||
'required' => false,
|
||||
'label' => $this->translate('Enable auto refresh'),
|
||||
'description' => $this->translate('This option allows you to enable or to disable the global page content auto refresh'),
|
||||
'value' => 1
|
||||
)
|
||||
);
|
||||
|
||||
if ($this->store) {
|
||||
$this->addElement(
|
||||
'submit',
|
||||
|
|
|
@ -16,6 +16,9 @@ if (! $this->auth()->isAuthenticated()) {
|
|||
<li>
|
||||
<a tabindex="0" href="#main"><?= t('Skip to Content'); ?></a>
|
||||
</li>
|
||||
<li>
|
||||
<?= $this->layout()->autoRefreshForm ?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="menu" data-last-update="<?= (time() - 14) ?>000" data-base-target="_main" class="container"
|
||||
|
|
|
@ -10,6 +10,7 @@ use Icinga\Authentication\Manager;
|
|||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\File\Pdf;
|
||||
use Icinga\Forms\AutoRefreshForm;
|
||||
use Icinga\Security\SecurityException;
|
||||
use Icinga\Util\Translator;
|
||||
use Icinga\Web\Notification;
|
||||
|
@ -379,6 +380,16 @@ class ActionController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Zend_Controller_Action::preDispatch()
|
||||
*/
|
||||
public function preDispatch()
|
||||
{
|
||||
$form = new AutoRefreshForm();
|
||||
$form->handleRequest();
|
||||
$this->_helper->layout()->autoRefreshForm = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect whether the current request requires changes in the layout and apply them before rendering
|
||||
*
|
||||
|
@ -399,6 +410,10 @@ class ActionController extends Zend_Controller_Action
|
|||
$layout->benchmark = $this->renderBenchmark();
|
||||
}
|
||||
}
|
||||
|
||||
if ((bool) $user->getPreferences()->getValue('icingaweb', 'auto_refresh', true) === false) {
|
||||
$this->disableAutoRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
if ($req->getParam('format') === 'pdf') {
|
||||
|
|
|
@ -280,26 +280,26 @@ a:focus {
|
|||
display: inline;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
a {
|
||||
a, button[type="submit"] {
|
||||
position: absolute;
|
||||
display: block;
|
||||
left: -999em;
|
||||
width: 10.4em;
|
||||
box-sizing: content-box;
|
||||
width: 10.4em !important;
|
||||
top: 0em;
|
||||
text-align: left !important;
|
||||
padding: 0.8em;
|
||||
background-color: white;
|
||||
z-index: 4;
|
||||
border: 1px @colorGray solid;
|
||||
&:focus {
|
||||
left: 0;
|
||||
outline: 1px dotted black !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.skip-links-inline {
|
||||
margin-top: -4em;
|
||||
ul > li > a {
|
||||
width: 16em;
|
||||
}
|
||||
margin-top: -3.5em;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue