js/loader: handle form redirections automagically

An XHR redirection in a right-side container pointing to the URL
shown on the left should close it's own container and refresh the
lefthand one.

refs #6436
fixes #6435
This commit is contained in:
Thomas Gelf 2014-06-30 16:19:05 +02:00
parent f3172b96e4
commit 590db51255
1 changed files with 9 additions and 1 deletions

View File

@ -244,9 +244,10 @@
},
processRedirectHeader: function(req) {
var icinga = this.icinga;
var redirect = req.getResponseHeader('X-Icinga-Redirect');
if (! redirect) return false;
this.icinga.logger.debug(
icinga.logger.debug(
'Got redirect for ', req.$target, ', URL was ' + redirect
);
redirect = decodeURIComponent(redirect);
@ -255,6 +256,13 @@
var redirectionUrl = this.addUrlFlag(redirect, 'renderLayout');
this.loadUrl(redirectionUrl, $('#layout')).url = redirect;
} else {
if (req.$target.attr('id') === 'col2') { // TODO: multicol
if ($('#col1').data('icingaUrl') === redirect) {
icinga.ui.layout1col();
req.$target = $('#col1');
}
}
this.loadUrl(redirect, req.$target);
}
return true;