loader.js: Support behaviors as well as multipart update targets

This commit is contained in:
Johannes Meyer 2020-11-06 11:28:32 +01:00
parent f05f905d14
commit 2c7b2330a7

View File

@ -771,9 +771,18 @@
}
$.each(req.responseText.split(contentSeparator), function (idx, el) {
var match = el.match(/for=(\S+)\s+(.*)/ms);
var match = el.match(/for=(Behavior:)?(\S+)\s+(.*)/ms);
if (!! match) {
var $target = $('#' + match[1]);
if (match[1]) {
var behavior = _this.icinga.behaviors[match[2].toLowerCase()];
if (typeof behavior !== 'undefined' && typeof behavior.update === 'function') {
behavior.update(JSON.parse(match[3]));
} else {
_this.icinga.logger.warn(
'Invalid behavior. Cannot update behavior "' + match[2] + '"');
}
} else {
var $target = $('#' + match[2]);
if ($target.length) {
var forceFocus;
if (req.forceFocus
@ -784,7 +793,7 @@
}
_this.renderContentToContainer(
match[2],
match[3],
$target,
'replace',
req.autorefresh,
@ -794,7 +803,8 @@
);
} else {
_this.icinga.logger.warn(
'Invalid target ID. Cannot render multipart to #' + match[1]);
'Invalid target ID. Cannot render multipart to #' + match[2]);
}
}
} else {
_this.icinga.logger.error('Ill-formed multipart', el);