Merge pull request #4293 from Icinga/fix/actioncontroller-setAutorefreshInterval
Drop new parameter from ActionController::setAutorefreshInterval()
This commit is contained in:
commit
a3db4d1a5b
|
@ -17,6 +17,8 @@ class ApplicationStateController extends Controller
|
|||
{
|
||||
protected $requiresAuthentication = false;
|
||||
|
||||
protected $autorefreshInterval = 60;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
@ -63,8 +65,6 @@ class ApplicationStateController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->setAutorefreshInterval(60, true);
|
||||
}
|
||||
|
||||
public function summaryAction()
|
||||
|
@ -72,8 +72,6 @@ class ApplicationStateController extends Controller
|
|||
if ($this->Auth()->isAuthenticated()) {
|
||||
$this->getResponse()->setBody((string) Widget::create('ApplicationStateMessages'));
|
||||
}
|
||||
|
||||
$this->setAutorefreshInterval(60, true);
|
||||
}
|
||||
|
||||
public function acknowledgeMessageAction()
|
||||
|
|
|
@ -64,6 +64,13 @@ class ActionController extends Zend_Controller_Action
|
|||
*/
|
||||
protected $moduleName;
|
||||
|
||||
/**
|
||||
* A page's automatic refresh interval
|
||||
*
|
||||
* The initial value will not be subject to a user's preferences.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $autorefreshInterval;
|
||||
|
||||
protected $reloadCss = false;
|
||||
|
@ -341,7 +348,19 @@ class ActionController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function setAutorefreshInterval($interval, $bypassUserPreferences = false)
|
||||
/**
|
||||
* Set the interval (in seconds) at which the page should automatically refresh
|
||||
*
|
||||
* This may be adjusted based on the user's preferences. The result could be a
|
||||
* lower or higher rate of the page's automatic refresh. If this is not desired,
|
||||
* the only way to bypass this is to initialize the {@see ActionController::$autorefreshInterval}
|
||||
* property or to set the `autorefreshInterval` property of the layout directly.
|
||||
*
|
||||
* @param int $interval
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAutorefreshInterval($interval)
|
||||
{
|
||||
if (! is_int($interval) || $interval < 1) {
|
||||
throw new ProgrammingError(
|
||||
|
@ -349,24 +368,21 @@ class ActionController extends Zend_Controller_Action
|
|||
);
|
||||
}
|
||||
|
||||
if (! $bypassUserPreferences) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
if ($user !== null) {
|
||||
$speed = (float) $user->getPreferences()->getValue('icingaweb', 'auto_refresh_speed', 1.0);
|
||||
$interval = max(round($interval * $speed), min($interval, 5));
|
||||
}
|
||||
$user = $this->getRequest()->getUser();
|
||||
if ($user !== null) {
|
||||
$speed = (float) $user->getPreferences()->getValue('icingaweb', 'auto_refresh_speed', 1.0);
|
||||
$interval = max(round($interval * $speed), min($interval, 5));
|
||||
}
|
||||
|
||||
$this->autorefreshInterval = $interval;
|
||||
$this->_helper->layout()->autorefreshInterval = $interval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function disableAutoRefresh()
|
||||
{
|
||||
$this->autorefreshInterval = null;
|
||||
$this->_helper->layout()->autorefreshInterval = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -483,6 +499,10 @@ class ActionController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->autorefreshInterval !== null) {
|
||||
$layout->autorefreshInterval = $this->autorefreshInterval;
|
||||
}
|
||||
|
||||
if ($req->getParam('error_handler') === null && $req->getParam('format') === 'pdf') {
|
||||
$this->sendAsPdf();
|
||||
$this->shutdownSession();
|
||||
|
|
Loading…
Reference in New Issue