From 41c942d1971ee4d71908b1487c5f7db5e1bd04dc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 27 Jan 2016 09:19:12 +0100 Subject: [PATCH] JS: Maintain auto-refresh interval over redirects This is far from beautiful. But JS needs a revamp anyway. Request should be an object and should be passed from function to function in order to maintain state. --- public/js/icinga/loader.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 198bc643f..284c1f062 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -331,7 +331,10 @@ } } - this.redirectToUrl(redirect, req.$target, req.url, req.getResponseHeader('X-Icinga-Rerender-Layout'), req.forceFocus); + this.redirectToUrl( + redirect, req.$target, req.url, req.getResponseHeader('X-Icinga-Rerender-Layout'), req.forceFocus, + req.getResponseHeader('X-Icinga-Refresh') + ); return true; }, @@ -343,7 +346,7 @@ * @param {string} origin * @param {boolean} rerenderLayout */ - redirectToUrl: function (url, $target, origin, rerenderLayout, forceFocus) { + redirectToUrl: function (url, $target, origin, rerenderLayout, forceFocus, autoRefreshInterval) { var icinga = this.icinga; if (typeof rerenderLayout === 'undefined') { @@ -394,6 +397,7 @@ var req = this.loadUrl(url, $target); req.forceFocus = url === origin ? forceFocus : null; + req.autoRefreshInterval = autoRefreshInterval; } } }, @@ -496,7 +500,7 @@ this.icinga.ui.setTitle(decodeURIComponent(title)); } - var refresh = req.getResponseHeader('X-Icinga-Refresh'); + var refresh = req.autoRefreshInterval || req.getResponseHeader('X-Icinga-Refresh'); if (refresh) { req.$target.data('icingaRefresh', refresh); } else {