Assign unique ids to dashlets and subcontainers

Without this we have no chance to cancel pending requests for dashlets.

fixes #6552
This commit is contained in:
Thomas Gelf 2014-06-24 06:40:08 +02:00
parent ef0963af38
commit 473a705e2e
2 changed files with 30 additions and 0 deletions

View File

@ -665,6 +665,7 @@
$container.append(content);
}
}
this.icinga.ui.assignUniqueContainerIds();
if (scrollPos !== false) {
$container.scrollTop(scrollPos);

View File

@ -479,6 +479,35 @@
return focusedTableDataUrl;
},
/**
* Assign a unique ID to each .container without such
*
* This usually applies to dashlets
*/
assignUniqueContainerIds: function() {
var currentMax = 0;
$('.container').each(function() {
var $el = $(this);
var m;
if (!$el.attr('id')) {
return;
}
if (m = $el.attr('id').match(/^ciu_(\d+)$/)) {
if (parseInt(m[1]) > currentMax) {
currentMax = parseInt(m[1]);
}
}
});
$('.container').each(function() {
var $el = $(this);
if (!!$el.attr('id')) {
return;
}
currentMax++;
$el.attr('id', 'ciu_' + currentMax);
});
},
refreshDebug: function () {
var size = this.getDefaultFontSize().toString();