Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js: Don't trigger beforerender or rendered for discarded content #5057

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions public/js/icinga/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@
}
})
} else {
this.renderContentToContainer(
let rendered = this.renderContentToContainer(
req.responseText,
req.$target,
req.action,
Expand All @@ -882,6 +882,10 @@
req.autosubmit || autoSubmit,
req.scripted
);

if (! rendered) {
req.discarded = true;
}
}

if (oldNotifications) {
Expand All @@ -905,6 +909,14 @@
req = reqOrError;
}

req.$target.data('lastUpdate', (new Date()).getTime());
delete this.requests[req.$target.attr('id')];
this.icinga.ui.fadeNotificationsAway();

if (req.discarded) {
return;
}

// Remove 'impact' class if there was such
if (req.$target.hasClass('impact')) {
req.$target.removeClass('impact');
Expand Down Expand Up @@ -957,10 +969,6 @@
}
}

req.$target.data('lastUpdate', (new Date()).getTime());
delete this.requests[req.$target.attr('id')];
this.icinga.ui.fadeNotificationsAway();

var extraUpdates = req.getResponseHeader('X-Icinga-Extra-Updates');
if (!! extraUpdates && req.getResponseHeader('X-Icinga-Redirect-Http') !== 'yes') {
$.each(extraUpdates.split(','), function (idx, el) {
Expand Down Expand Up @@ -1253,8 +1261,6 @@
}
}

$container.trigger('beforerender', [content, action, autorefresh, scripted, autoSubmit]);

var discard = false;
$.each(_this.icinga.behaviors, function(name, behavior) {
if (behavior.renderHook) {
Expand All @@ -1272,6 +1278,8 @@
});

if (! discard) {
$container.trigger('beforerender', [content, action, autorefresh, scripted, autoSubmit]);

if ($container.closest('.dashboard').length) {
var title = $('h1', $container).first().detach();
$container.html(title).append(content);
Expand Down Expand Up @@ -1337,6 +1345,8 @@

// Re-enable all click events (disabled as of performance reasons)
// $('*').off('click');

return ! discard;
},

/**
Expand Down