js: Allow to reload the window

This commit is contained in:
Johannes Meyer 2021-07-07 09:36:54 +02:00
parent 9e0785b0b4
commit 228e503131
2 changed files with 39 additions and 0 deletions

View File

@ -47,6 +47,13 @@ class Response extends Zend_Controller_Response_Http
*/ */
protected $request; protected $request;
/**
* Whether to instruct the client to reload the window
*
* @var bool
*/
protected $reloadWindow;
/** /**
* Whether to instruct client side script code to reload CSS * Whether to instruct client side script code to reload CSS
* *
@ -198,6 +205,30 @@ class Response extends Zend_Controller_Response_Http
return $this->request; return $this->request;
} }
/**
* Get whether to instruct the client to reload the window
*
* @return bool
*/
public function isWindowReloaded()
{
return $this->reloadWindow;
}
/**
* Set whether to instruct the client to reload the window
*
* @param bool $reloadWindow
*
* @return $this
*/
public function setReloadWindow($reloadWindow)
{
$this->reloadWindow = $reloadWindow;
return $this;
}
/** /**
* Get whether to instruct client side script code to reload CSS * Get whether to instruct client side script code to reload CSS
* *
@ -302,6 +333,9 @@ class Response extends Zend_Controller_Response_Http
if ($this->getRerenderLayout()) { if ($this->getRerenderLayout()) {
$this->setHeader('X-Icinga-Container', 'layout', true); $this->setHeader('X-Icinga-Container', 'layout', true);
} }
if ($this->isWindowReloaded()) {
$this->setHeader('X-Icinga-Reload-Window', 'yes', true);
}
if ($this->isReloadCss()) { if ($this->isReloadCss()) {
$this->setHeader('X-Icinga-Reload-Css', 'now', true); $this->setHeader('X-Icinga-Reload-Css', 'now', true);
} }

View File

@ -930,6 +930,11 @@
} }
} }
if (req.getResponseHeader('X-Icinga-Reload-Window') === 'yes') {
window.location.reload();
return;
}
if (! req.autorefresh && ! req.autosubmit) { if (! req.autorefresh && ! req.autosubmit) {
// TODO: Hook for response/url? // TODO: Hook for response/url?
var url = req.url; var url = req.url;