mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
loader.js: Enhance __BACK__ handling
This commit is contained in:
parent
da565f4d16
commit
5f739deea3
@ -458,19 +458,43 @@
|
|||||||
redirect = redirect.replace(/__SELF__/, req.url);
|
redirect = redirect.replace(/__SELF__/, req.url);
|
||||||
}
|
}
|
||||||
} else if (redirect.match(/__BACK__/)) {
|
} else if (redirect.match(/__BACK__/)) {
|
||||||
|
if (req.$redirectTarget.is('#col1')) {
|
||||||
|
icinga.logger.warn('Cannot navigate back. Redirect target is #col1');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var originUrl = req.$target.data('icingaUrl');
|
||||||
|
|
||||||
// We may just close the right column, refresh the left one in this case
|
// We may just close the right column, refresh the left one in this case
|
||||||
$(window).on('popstate.__back__', { self: this }, function (event) {
|
$(window).on('popstate.__back__', { self: this }, function (event) {
|
||||||
var _this = event.data.self;
|
var _this = event.data.self;
|
||||||
|
var $refreshTarget = $('#col2');
|
||||||
|
var refreshUrl;
|
||||||
|
|
||||||
if (icinga.ui.isOneColLayout()) {
|
var hash = icinga.history.getCol2State();
|
||||||
var $col1 = $('#col1');
|
if (hash && hash.match(/^#!/)) {
|
||||||
_this.loadUrl($col1.data('icingaUrl'), $col1).autorefresh = true;
|
// TODO: These three lines are copied from history.js, I don't like this
|
||||||
|
var parts = hash.split(/#!/);
|
||||||
|
|
||||||
// TODO: Find a better solution than a hardcoded one
|
if (parts[1] === originUrl) {
|
||||||
setTimeout(function () {
|
// After a page load a call to back() seems not to have an effect
|
||||||
_this.loadUrl($col1.data('icingaUrl'), $col1).autorefresh = true;
|
icinga.ui.layout1col();
|
||||||
}, 1000);
|
} else {
|
||||||
|
refreshUrl = parts[1];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof refreshUrl === 'undefined' && icinga.ui.isOneColLayout()) {
|
||||||
|
refreshUrl = icinga.history.getCol1State();
|
||||||
|
$refreshTarget = $('#col1');
|
||||||
|
}
|
||||||
|
|
||||||
|
_this.loadUrl(refreshUrl, $refreshTarget).autorefresh = true;
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
// TODO: Find a better solution than a hardcoded one
|
||||||
|
_this.loadUrl(refreshUrl, $refreshTarget).autorefresh = true;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
$(window).off('popstate.__back__');
|
$(window).off('popstate.__back__');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user