JS/cleanup: separate redirect header handling
This commit is contained in:
parent
4646b74fbc
commit
2bf58b034b
|
@ -222,12 +222,23 @@
|
||||||
|
|
||||||
processNotificationHeader: function(req) {
|
processNotificationHeader: function(req) {
|
||||||
var header = req.getResponseHeader('X-Icinga-Notification');
|
var header = req.getResponseHeader('X-Icinga-Notification');
|
||||||
if (typeof header === 'undefined' || ! header) return false;
|
if (! header) return false;
|
||||||
var parts = decodeURIComponent(header).split(' ');
|
var parts = decodeURIComponent(header).split(' ');
|
||||||
this.createNotice(parts.shift(), parts.join(' '));
|
this.createNotice(parts.shift(), parts.join(' '));
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
processRedirectHeader: function(req) {
|
||||||
|
var redirect = req.getResponseHeader('X-Icinga-Redirect');
|
||||||
|
if (! redirect) return false;
|
||||||
|
this.icinga.logger.debug(
|
||||||
|
'Got redirect for ', req.$target, ', URL was ' + redirect
|
||||||
|
);
|
||||||
|
redirect = decodeURIComponent(redirect);
|
||||||
|
this.loadUrl(redirect, req.$target);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle successful XHR response
|
* Handle successful XHR response
|
||||||
*/
|
*/
|
||||||
|
@ -255,14 +266,7 @@
|
||||||
this.processNotificationHeader(req);
|
this.processNotificationHeader(req);
|
||||||
|
|
||||||
var redirect = req.getResponseHeader('X-Icinga-Redirect');
|
var redirect = req.getResponseHeader('X-Icinga-Redirect');
|
||||||
if (redirect) {
|
if (this.processRedirectHeader(req)) return;
|
||||||
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
|
// div helps getting an XML tree
|
||||||
var $resp = $('<div>' + req.responseText + '</div>');
|
var $resp = $('<div>' + req.responseText + '</div>');
|
||||||
|
|
Loading…
Reference in New Issue