mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 05:44:36 +02:00
js: Enhance server side container closing
* Let response header `X-Icinga-Container` either influence a request's `$target` or `$redirectTarget`, but not both * Close a request's `$target` instead of the `$redirectTarget` upon the redirect url `__CLOSE__` * Issuing a `__CLOSE__` in a detail url still closes `#col2` and refreshes `#col1` * Issuing a `__CLOSE__` for a nested container still empties it * Issuing a `__CLOSE__` in a modal, now refreshes the modal openers container * If `X-Icinga-Extra-Updates` is set, automatic refreshing won't happen
This commit is contained in:
parent
65b3006adf
commit
eed6374dd2
@ -565,24 +565,35 @@
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (redirect.match(/__CLOSE__/)) {
|
} else if (redirect.match(/__CLOSE__/)) {
|
||||||
if (req.$redirectTarget.is('#col1')) {
|
if (req.$target.is('#col1') && req.$redirectTarget.is('#col1')) {
|
||||||
icinga.logger.warn('Cannot close #col1');
|
icinga.logger.warn('Cannot close #col1');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.$redirectTarget.is('.container') && req.$redirectTarget.parent().closest('.container').length > 0) {
|
if (req.$redirectTarget.is('.container') && ! req.$redirectTarget.is('#main > :scope')) {
|
||||||
// If it is a container that is not a top level container, we just empty it
|
// If it is a container that is not a top level container, we just empty it
|
||||||
req.$redirectTarget.empty();
|
req.$redirectTarget.empty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! req.$redirectTarget.is('#col2')) {
|
||||||
|
icinga.logger.debug('Cannot close container', req.$redirectTarget);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Close right column as requested
|
// Close right column as requested
|
||||||
icinga.ui.layout1col();
|
icinga.ui.layout1col();
|
||||||
|
|
||||||
|
if (!! req.getResponseHeader('X-Icinga-Extra-Updates')) {
|
||||||
|
icinga.logger.debug('Not refreshing #col1 due to outstanding extra updates');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh left column and produce a new history state for it
|
// Refresh left column and produce a new history state for it
|
||||||
var $col1 = $('#col1');
|
let $refreshTarget = $('#col1');
|
||||||
var col1Url = icinga.history.getCol1State();
|
let refreshUrl = icinga.history.getCol1State();
|
||||||
var refresh = this.loadUrl(col1Url, $col1);
|
let refresh = this.loadUrl(refreshUrl, $refreshTarget);
|
||||||
|
refresh.addToHistory = true;
|
||||||
refresh.scripted = true;
|
refresh.scripted = true;
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
@ -590,7 +601,7 @@
|
|||||||
// TODO: Find a better solution than a hardcoded one
|
// TODO: Find a better solution than a hardcoded one
|
||||||
// This is still the *cheat* to get live results
|
// This is still the *cheat* to get live results
|
||||||
// (in case there's a delay and a change is not instantly effective)
|
// (in case there's a delay and a change is not instantly effective)
|
||||||
var secondRefresh = _this.loadUrl(col1Url, $col1);
|
var secondRefresh = _this.loadUrl(refreshUrl, $refreshTarget);
|
||||||
if (secondRefresh !== refresh) {
|
if (secondRefresh !== refresh) {
|
||||||
// Only change these properties if it's not still the first refresh
|
// Only change these properties if it's not still the first refresh
|
||||||
secondRefresh.addToHistory = false;
|
secondRefresh.addToHistory = false;
|
||||||
@ -699,6 +710,7 @@
|
|||||||
var target = req.getResponseHeader('X-Icinga-Container');
|
var target = req.getResponseHeader('X-Icinga-Container');
|
||||||
var newBody = false;
|
var newBody = false;
|
||||||
var oldNotifications = false;
|
var oldNotifications = false;
|
||||||
|
var isRedirect = !! req.getResponseHeader('X-Icinga-Redirect');
|
||||||
if (target) {
|
if (target) {
|
||||||
if (target === 'ignore') {
|
if (target === 'ignore') {
|
||||||
return;
|
return;
|
||||||
@ -706,12 +718,15 @@
|
|||||||
|
|
||||||
var $newTarget = this.identifyLinkTarget(target, req.$target);
|
var $newTarget = this.identifyLinkTarget(target, req.$target);
|
||||||
if ($newTarget.length) {
|
if ($newTarget.length) {
|
||||||
// If we change the target, oncomplete will fail to clean up
|
if (isRedirect) {
|
||||||
// This fixes the problem, not using req.$target would be better
|
req.$redirectTarget = $newTarget;
|
||||||
delete this.requests[req.$target.attr('id')];
|
} else {
|
||||||
|
// If we change the target, oncomplete will fail to clean up.
|
||||||
|
// This fixes the problem, not using req.$target would be better
|
||||||
|
delete this.requests[req.$target.attr('id')];
|
||||||
|
|
||||||
req.$target = $newTarget;
|
req.$target = $newTarget;
|
||||||
req.$redirectTarget = $newTarget;
|
}
|
||||||
|
|
||||||
if (target === 'layout') {
|
if (target === 'layout') {
|
||||||
oldNotifications = $('#notifications li').detach();
|
oldNotifications = $('#notifications li').detach();
|
||||||
@ -735,7 +750,7 @@
|
|||||||
this.icinga.ui.reloadCss();
|
this.icinga.ui.reloadCss();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.getResponseHeader('X-Icinga-Redirect')) {
|
if (isRedirect) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user