From 8bb0e4e0a0ba9d3924a16f3f569ee38cbda0291c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Feb 2015 16:34:29 +0100 Subject: [PATCH] Failure requests: Fix auto refresh and history II Allow to change url's in history and stop auto auto refresh if the container URL is not up to date. Use variable after ajax call and the check is more robust. --- public/js/icinga/loader.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 6a85a5144..417c47c1c 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -118,6 +118,8 @@ req.historyTriggered = false; req.autorefresh = autorefresh; req.action = action; + req.failure = false; + if (id) { this.requests[id] = req; } @@ -555,7 +557,7 @@ // Update history when necessary. Don't do so for requests triggered // by history or autorefresh events if (! req.historyTriggered && ! req.autorefresh) { - if (req.$target.hasClass('container')) { + if (req.$target.hasClass('container') && ! req.failure) { // We only want to care about top-level containers if (req.$target.parent().closest('.container').length === 0) { this.icinga.history.pushCurrentState(); @@ -591,6 +593,17 @@ onFailure: function (req, textStatus, errorThrown) { var url = req.url; + req.failure = true; + + /* + * Test if a manual actions comes in and autorefresh is active: Stop refreshing + */ + if (! req.historyTriggered && ! req.autorefresh && req.$target.data('icingaRefresh') > 0 + && req.$target.data('icingaUrl') !== url) { + req.$target.data('icingaRefresh', 0); + req.$target.data('icingaUrl', url); + } + if (req.status > 0) { this.icinga.logger.error( req.status,