mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
JS/XHR: get ready to get XHR redirect-aware
These are just the first steps, there is more to come
This commit is contained in:
parent
b3f65c8e37
commit
99aae5a0d9
@ -370,13 +370,19 @@ class ActionController extends Zend_Controller_Action
|
||||
**/
|
||||
public function redirectNow($url)
|
||||
{
|
||||
if ($url instanceof Url) {
|
||||
$url = $url->getRelativeUrl();
|
||||
} else {
|
||||
$url = Url::fromPath($url)->getRelativeUrl();
|
||||
if (! $url instanceof Url) {
|
||||
$url = Url::fromPath($url);
|
||||
}
|
||||
$this->_helper->Redirector->gotoUrlAndExit(preg_replace('~&~', '&', $url));
|
||||
$this->isRedirect = true;
|
||||
$url = preg_replace('~&~', '&', $url);
|
||||
if ($this->_request->isXmlHttpRequest()) {
|
||||
header('X-Icinga-Redirect: ' . rawurlencode($url));
|
||||
// $this->getResponse()->sendHeaders() ??
|
||||
// Session shutdown
|
||||
exit; // Really?
|
||||
} else {
|
||||
$this->_helper->Redirector->gotoUrlAndExit($url);
|
||||
}
|
||||
$this->isRedirect = true; // pretty useless right now
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,6 +244,15 @@
|
||||
this.icinga.logger.debug(
|
||||
'Got response for ', req.$target, ', URL was ' + url
|
||||
);
|
||||
var redirect = req.getResponseHeader('X-Icinga-Redirect');
|
||||
if (redirect) {
|
||||
this.icinga.logger.debug(
|
||||
'Got redirect for ', req.$target, ', URL was ' + redirect
|
||||
);
|
||||
redirect = decodeURIComponent(redirect);
|
||||
this.loadUrl(redirect, req.$target);
|
||||
return;
|
||||
}
|
||||
|
||||
// div helps getting an XML tree
|
||||
var $resp = $('<div>' + req.responseText + '</div>');
|
||||
@ -400,6 +409,7 @@
|
||||
this.icinga.history.pushCurrentState();
|
||||
}
|
||||
}
|
||||
|
||||
this.icinga.ui.initializeTriStates($resp);
|
||||
|
||||
// Make multiselection-tables not selectable.
|
||||
@ -459,7 +469,6 @@
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (active) {
|
||||
var focusedUrl = this.icinga.ui.getFocusedContainerDataUrl();
|
||||
var oldSelectionData = this.icinga.ui.loadSelectionData();
|
||||
|
Loading…
x
Reference in New Issue
Block a user