You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ea...@apache.org on 2020/05/08 12:02:37 UTC

[qpid-dispatch] 02/02: Added idle timeout to avoid unresponsive console

This is an automated email from the ASF dual-hosted git repository.

eallen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git

commit 3cba4bc70831f79204b83abaa782eeb35a8ece8d
Author: Ernest Allen <ea...@redhat.com>
AuthorDate: Fri May 8 08:02:12 2020 -0400

    Added idle timeout to avoid unresponsive console
---
 console/react/src/overview/dashboard/layout.js | 29 ++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/console/react/src/overview/dashboard/layout.js b/console/react/src/overview/dashboard/layout.js
index ca8577a..e0c6831 100644
--- a/console/react/src/overview/dashboard/layout.js
+++ b/console/react/src/overview/dashboard/layout.js
@@ -101,6 +101,7 @@ class PageLayout extends React.PureComponent {
     this.inflightChartData = new inflightData(this.service);
     this.updateCharts();
     document.title = this.props.config.title;
+    this.idleUnregister = idle(1000 * 60 * 60, this.handleIdleTimeout);
   };
 
   componentWillUnmount = () => {
@@ -109,6 +110,15 @@ class PageLayout extends React.PureComponent {
       this.inflightChartData.stop();
       clearInterval(this.chartTimer);
     }
+    if (this.idleUnregister) {
+      this.idleUnregister();
+    }
+  };
+
+  handleIdleTimeout = () => {
+    this.props.history.replace(
+      `${this.props.location.pathname}${this.props.location.search}`
+    );
   };
 
   tryInitialConnect = () => {
@@ -531,3 +541,22 @@ class PageLayout extends React.PureComponent {
 }
 
 export default PageLayout;
+
+const idle = (elapsed, callback) => {
+  let timer;
+  const inactive = () => {
+    callback();
+    active();
+  };
+  const active = () => {
+    clearTimeout(timer);
+    timer = setTimeout(inactive, elapsed);
+  };
+  const unload = () => {
+    clearTimeout(timer);
+    document.removeEventListener("mousemove", active);
+  };
+  document.addEventListener("mousemove", active, true);
+  active();
+  return unload;
+};


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org