From 8c758a9f126f81cc50fe290691d284947ec1804d Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 2 Feb 2015 13:32:40 +0100 Subject: [PATCH] Failure requests: Fix auto refresh and history Allow to change url's in history and stop auto auto refresh if the container URL is not up to date. --- public/js/icinga/loader.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 507a914e3..4c273ffdb 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -107,7 +107,8 @@ url : url, data : data, headers: headers, - context: self + context: self, + failure: false }); req.$target = $target; @@ -553,7 +554,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 === false) { // We only want to care about top-level containers if (req.$target.parent().closest('.container').length === 0) { this.icinga.history.pushCurrentState(); @@ -589,6 +590,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,