mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Cancel the pending request when loading a new container element
fixes #4947
This commit is contained in:
parent
9a8ae4c92a
commit
e0aae9d14b
@ -57,7 +57,22 @@ define(['jquery', 'logging', 'icinga/componentLoader', 'URIjs/URI', 'URIjs/URITe
|
|||||||
*/
|
*/
|
||||||
var detailContainer = null;
|
var detailContainer = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains currently pending requests
|
||||||
|
*
|
||||||
|
* @type {jqAJAX}
|
||||||
|
*/
|
||||||
var pendingDetailRequest = null;
|
var pendingDetailRequest = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel the pending request, if one exists
|
||||||
|
*/
|
||||||
|
var cancelPendingRequest = function() {
|
||||||
|
if (pendingDetailRequest) {
|
||||||
|
pendingDetailRequest.abort();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A handler for accessing icinga containers, i.e. the #icingamain, #icingadetail containers and specific 'app/container'
|
* A handler for accessing icinga containers, i.e. the #icingamain, #icingadetail containers and specific 'app/container'
|
||||||
* components.
|
* components.
|
||||||
@ -175,18 +190,17 @@ define(['jquery', 'logging', 'icinga/componentLoader', 'URIjs/URI', 'URIjs/URITe
|
|||||||
if (urlMgr.detailUrl === '') {
|
if (urlMgr.detailUrl === '') {
|
||||||
this.hideDetail();
|
this.hideDetail();
|
||||||
}
|
}
|
||||||
|
cancelPendingRequest();
|
||||||
if (pendingDetailRequest) {
|
|
||||||
pendingDetailRequest.abort();
|
|
||||||
}
|
|
||||||
this.containerDom.trigger('showLoadIndicator');
|
this.containerDom.trigger('showLoadIndicator');
|
||||||
pendingDetailRequest = $.ajax({
|
pendingDetailRequest = $.ajax({
|
||||||
'url' : url,
|
'url' : url,
|
||||||
'data' : {
|
'data' : {
|
||||||
'render' : 'detail'
|
'render' : 'detail'
|
||||||
}
|
}
|
||||||
}).done(
|
});
|
||||||
|
pendingDetailRequest.done(
|
||||||
(function(response) {
|
(function(response) {
|
||||||
|
pendingDetailRequest = null;
|
||||||
this.replaceDom($(response));
|
this.replaceDom($(response));
|
||||||
}).bind(this)
|
}).bind(this)
|
||||||
).fail(
|
).fail(
|
||||||
@ -258,7 +272,6 @@ define(['jquery', 'logging', 'icinga/componentLoader', 'URIjs/URI', 'URIjs/URITe
|
|||||||
*/
|
*/
|
||||||
this.registerOnShowLoadIndicator = function(fn) {
|
this.registerOnShowLoadIndicator = function(fn) {
|
||||||
this.containerDom.on('showLoadIndicator', fn);
|
this.containerDom.on('showLoadIndicator', fn);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -412,6 +425,7 @@ define(['jquery', 'logging', 'icinga/componentLoader', 'URIjs/URI', 'URIjs/URITe
|
|||||||
* Available as a static method on the Container object or as an instance method
|
* Available as a static method on the Container object or as an instance method
|
||||||
*/
|
*/
|
||||||
Container.prototype.hideDetail = Container.hideDetail = function() {
|
Container.prototype.hideDetail = Container.hideDetail = function() {
|
||||||
|
cancelPendingRequest();
|
||||||
urlMgr.setDetailUrl('');
|
urlMgr.setDetailUrl('');
|
||||||
var mainDom = Container.getMainContainer().containerDom,
|
var mainDom = Container.getMainContainer().containerDom,
|
||||||
detailDom = Container.getDetailContainer().containerDom;
|
detailDom = Container.getDetailContainer().containerDom;
|
||||||
@ -458,9 +472,8 @@ define(['jquery', 'logging', 'icinga/componentLoader', 'URIjs/URI', 'URIjs/URITe
|
|||||||
if (urlMgr.detailUrl) {
|
if (urlMgr.detailUrl) {
|
||||||
Container.getDetailContainer().replaceDomAsync(urlMgr.detailUrl);
|
Container.getDetailContainer().replaceDomAsync(urlMgr.detailUrl);
|
||||||
} else {
|
} else {
|
||||||
Container.hideDetail();
|
Container.hideDetail();
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,21 +189,28 @@ function(Container, $, logger, URI, tpl, urlMgr, Selectable, TableMultiSelection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var selected = new Selectable(this);
|
||||||
switch (selectionMode) {
|
switch (selectionMode) {
|
||||||
case 'multi':
|
case 'multi':
|
||||||
if (ev.ctrlKey || ev.metaKey) {
|
if (ev.ctrlKey || ev.metaKey) {
|
||||||
selection.toggle(new Selectable(this));
|
selection.toggle(selected);
|
||||||
} else if (ev.shiftKey) {
|
} else if (ev.shiftKey) {
|
||||||
selection.add(new Selectable(this));
|
selection.add(selected);
|
||||||
} else {
|
} else {
|
||||||
|
var oldState = selected.isActive();
|
||||||
selection.clear();
|
selection.clear();
|
||||||
selection.add(new Selectable(this));
|
if (!oldState) {
|
||||||
|
selection.add(selected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'single':
|
case 'single':
|
||||||
|
oldState = selected.isActive();
|
||||||
selection.clear();
|
selection.clear();
|
||||||
selection.add(new Selectable(this));
|
if (!oldState) {
|
||||||
|
selection.add(selected);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'none':
|
case 'none':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user