Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/2.0.x d70152692 -> b905a9854


only reload health table if browser window is active

(cherry picked from commit f0318c01d979faae2b0c151eb737a80075a696a7)


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/d87025d1
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/d87025d1
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/d87025d1

Branch: refs/heads/2.0.x
Commit: d87025d139ac40e20365031a06e244a7b820fe21
Parents: 67e082c
Author: Jeremy Mitchell <mitchell...@gmail.com>
Authored: Tue Mar 21 14:52:35 2017 -0600
Committer: Jeremy Mitchell <mitchell...@gmail.com>
Committed: Tue Mar 21 15:18:04 2017 -0600

----------------------------------------------------------------------
 .../app/templates/rascal_status/health.html.ep  | 31 ++++++++++++++++----
 1 file changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d87025d1/traffic_ops/app/templates/rascal_status/health.html.ep
----------------------------------------------------------------------
diff --git a/traffic_ops/app/templates/rascal_status/health.html.ep 
b/traffic_ops/app/templates/rascal_status/health.html.ep
index 47ead84..6f877de 100644
--- a/traffic_ops/app/templates/rascal_status/health.html.ep
+++ b/traffic_ops/app/templates/rascal_status/health.html.ep
@@ -130,12 +130,31 @@ $(function () {
                 "sAjaxSource": "/api/1.1/traffic_monitor/stats.json"
                });
 
-               setInterval(
-                       function() { 
-                               edgeHealthTable.fnReloadAjax();
-                       }, 
-                       30000
-               );
+            var reloadHealth = function() {
+                edgeHealthTable.fnReloadAjax();
+            };
+
+            var activeEvent,
+                intervalMilliseconds = 15000,
+                intervalId = setInterval(reloadHealth, intervalMilliseconds);
+
+            $(window).on("blur focus", function(e) {
+                activeEvent = $(this).data("activeEvent");
+                if (activeEvent != e.type) {
+                    switch (e.type) {
+                        case "blur":
+                            clearInterval(intervalId);
+                            intervalId = 0;
+                            break;
+                        case "focus":
+                            if (!intervalId) {
+                                intervalId = setInterval(reloadHealth, 
intervalMilliseconds);
+                            }
+                        break;
+                    }
+                }
+                $(this).data("activeEvent", e.type);
+            });
 
                // Set the mouseover descriptions of the table headers - prolly 
should do this smarter, but this works for now.
                // use _wrapper here, because of the sCrollY stuff

Reply via email to