Merge branch '18978-webshell-timeout-ux' into main. Closes #18978
authorStephen Smith <stephen@curii.com>
Thu, 5 May 2022 15:06:29 +0000 (11:06 -0400)
committerStephen Smith <stephen@curii.com>
Thu, 5 May 2022 15:06:29 +0000 (11:06 -0400)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

public/webshell/index.html
public/webshell/shell_in_a_box.js

index 028664c488f74b7f5dd8256d63e9a81390bdeab8..aae70a97afab13a30a553eb2a6196d2a074f9484 100644 (file)
@@ -60,7 +60,7 @@
         if (currentTime - lastTime > idleTimeoutMs) {
           //logout
           sh.reset();
-          sh.sessionClosed();
+          sh.sessionClosed("Session timed out after " + timeout + " seconds.");
           document.body.onmousemove = undefined;
           document.body.onkeydown = undefined;
         } else {
              sh.keysPressed(token + "\n");
              sh.vt100('(sent authentication token)\n');
              token = null;
-             updateIdleTimer();
-             document.body.onmousemove = updateIdleTimer;
-             document.body.onkeydown = updateIdleTimer;
-             setTimeout(checkIdleTimer, 1000);
+             if (timeout > 0) {
+               updateIdleTimer();
+               document.body.onmousemove = updateIdleTimer;
+               document.body.onkeydown = updateIdleTimer;
+               setTimeout(checkIdleTimer, 1000);
+             }
           } else {
             setTimeout(trySendToken, 200);
           }
index c258b5d7316e40eda679006c9310c97a478144da..6b0a5b69b5d8b9fff6653eb62ba06ae5cf7b3113 100644 (file)
@@ -128,7 +128,7 @@ function ShellInABox(url, container) {
 };
 extend(ShellInABox, VT100);
 
-ShellInABox.prototype.sessionClosed = function() {
+ShellInABox.prototype.sessionClosed = function(msg) {
   try {
     this.connected    = false;
     if (this.session) {
@@ -136,7 +136,7 @@ ShellInABox.prototype.sessionClosed = function() {
       if (this.cursorX > 0) {
         this.vt100('\r\n');
       }
-      this.vt100('Session closed.');
+      this.vt100(msg || 'Session closed.');
       this.currentRequest.abort();
     }
     // Revealing the "reconnect" button is commented out until we hook