js: Always load redirects to their designated target
The server applies the redirection magic now, but only for compatibility reasons. resolves #4881
This commit is contained in:
parent
243192ba93
commit
4a52a653e4
|
@ -315,14 +315,29 @@ class Response extends Zend_Controller_Response_Http
|
|||
*/
|
||||
protected function prepare()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$redirectUrl = $this->getRedirectUrl();
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
if ($redirectUrl !== null) {
|
||||
if ($this->getRequest()->isGet() && Icinga::app()->getViewRenderer()->view->compact) {
|
||||
if ($request->isGet() && Icinga::app()->getViewRenderer()->view->compact) {
|
||||
$redirectUrl->getParams()->set('showCompact', true);
|
||||
}
|
||||
|
||||
$this->setHeader('X-Icinga-Redirect', rawurlencode($redirectUrl->getAbsoluteUrl()), true);
|
||||
$encodedRedirectUrl = rawurlencode($redirectUrl->getAbsoluteUrl());
|
||||
|
||||
// TODO: Compatibility only. Remove once v2.14 is out.
|
||||
$targetId = $request->getHeader('X-Icinga-Container');
|
||||
if ($request->isPost() && $targetId === 'col2' && $request->getHeader('X-Icinga-Col2-State')) {
|
||||
$col1State = Url::fromPath($request->getHeader('X-Icinga-Col1-State'));
|
||||
$col2State = Url::fromPath($request->getHeader('X-Icinga-Col2-State'));
|
||||
if ($col2State->getPath() !== $redirectUrl->getPath()
|
||||
&& $col1State->getPath() === $redirectUrl->getPath()
|
||||
) {
|
||||
$encodedRedirectUrl = '__CLOSE__';
|
||||
}
|
||||
}
|
||||
|
||||
$this->setHeader('X-Icinga-Redirect', $encodedRedirectUrl, true);
|
||||
if ($this->getRerenderLayout()) {
|
||||
$this->setHeader('X-Icinga-Rerender-Layout', 'yes', true);
|
||||
}
|
||||
|
|
|
@ -294,6 +294,11 @@
|
|||
headers['X-Icinga-Autorefresh'] = '1';
|
||||
}
|
||||
|
||||
if ($target.is('#col2')) {
|
||||
headers['X-Icinga-Col1-State'] = this.icinga.history.getCol1State();
|
||||
headers['X-Icinga-Col2-State'] = this.icinga.history.getCol2State().replace(/^#!/, '');
|
||||
}
|
||||
|
||||
// Ask for a new window id in case we don't already have one
|
||||
if (this.icinga.ui.hasWindowId()) {
|
||||
var windowId = this.icinga.ui.getWindowId();
|
||||
|
@ -677,16 +682,6 @@
|
|||
this.loadUrl(parts.shift(), $('#col1'));
|
||||
this.loadUrl(parts.shift(), $('#col2'));
|
||||
} else {
|
||||
if ($target.attr('id') === 'col2') { // TODO: multicol
|
||||
if (($target.data('icingaUrl') || '').split('?')[0] === url.split('?')[0]) {
|
||||
// Don't do anything in this case
|
||||
} else if ($('#col1').data('icingaUrl').split('?')[0] === url.split('?')[0]) {
|
||||
icinga.ui.layout1col();
|
||||
$target = $('#col1');
|
||||
delete(this.requests['col2']);
|
||||
}
|
||||
}
|
||||
|
||||
var req = this.loadUrl(url, $target);
|
||||
req.forceFocus = url === origin ? forceFocus : null;
|
||||
req.autoRefreshInterval = autoRefreshInterval;
|
||||
|
|
Loading…
Reference in New Issue