JBAS-821 LP1476370 SCKO logout warning xport
authorBill Erickson <berickxx@gmail.com>
Wed, 19 Aug 2015 15:37:56 +0000 (11:37 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
 * Show a logout warning dialog 20 seconds before discontinuing
   a self-check patron login session.

 * Reset the inactivity timer with each checkout.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/openils/var/templates_kcls/circ/selfcheck/main.tt2
Open-ILS/web/js/ui/kcls/circ/selfcheck/selfcheck.js

index 9011b6e..aaf2607 100644 (file)
@@ -79,6 +79,7 @@ function switchTo(str,subpage) {
 <script src="[% ctx.media_prefix %]/js/ui/kcls/circ/selfcheck/payment.js"></script>
 <link rel='stylesheet' type='text/css' href='[% ctx.media_prefix %]/css/skin/kcls/selfcheck.css'/>
 [% INCLUDE 'circ/selfcheck/audio_config.tt2' %]
+[% INCLUDE 'circ/selfcheck/logout_dialog.tt2' %]
 
   <div id="step0" class="checkout" style="width=100%;text-align:center;">Staff login required</div>
   <div id="step1" class="checkout hidden" style="padding-top:15px;">
index 191a919..1e04a6e 100644 (file)
@@ -13,8 +13,13 @@ dojo.requireLocalization('openils.circ', 'selfcheck');
 var localeStrings = dojo.i18n.getLocalization('openils.circ', 'selfcheck');
 
 // set patron timeout default
-var patronTimeout = 180000; /* 3 minutes */
+var patronTimeout = 160000; /* 2 minutes, 40 seconds */
 var timerId = null;
+// 20 second inactivity warning; total default timeout is 3 minutes.
+var patronTimeoutWarning = 20000; 
+var selfckWarningSetup = false;
+var selfckWarningTimer;
+
 
 var selfCheckMgr;
 var itemsOutCirc = [];
@@ -40,7 +45,7 @@ openils.User.default_login_agent = 'selfcheck';
 function selfckStartTimer() {
     timerId = setTimeout(
         function() {
-            SelfCheckManager.prototype.logoutPatron();
+            selfckLogoutWarning();
         },
         patronTimeout
     );
@@ -53,6 +58,41 @@ function selfckResetTimer() {
     selfckStartTimer();
 }
 
+function selfckLogoutWarning() {
+
+    // connect the logout warning dialog button handlers if needed
+    if (!selfckWarningSetup) {
+        selfckWarningSetup = true;
+
+        dojo.connect(oilsSelfckLogout, 'onClick', 
+            function() {
+                clearTimeout(selfckWarningTimer);
+                oilsSelfckLogoutDialog.hide();
+                SelfCheckManager.prototype.logoutPatron();
+            }
+        );
+
+        dojo.connect(oilsSelfckContinue, 'onClick', 
+            function() {
+                clearTimeout(selfckWarningTimer);
+                oilsSelfckLogoutDialog.hide();
+                selfckResetTimer();
+            }
+        );
+    }
+
+    // warn the patron of imminent logout
+    oilsSelfckLogoutDialog.show();
+    selfckWarningTimer = setTimeout(
+        function() {
+            // no action was taken, force a logout.
+            oilsSelfckLogoutDialog.hide();
+            SelfCheckManager.prototype.logoutPatron();
+        },
+        patronTimeoutWarning
+    );
+}
+
 function SelfCheckManager() {
        selfCheckMgr = this;
        switchTo('step1');
@@ -297,8 +337,13 @@ SelfCheckManager.prototype.loadOrgSettings = function() {
     if(settings[SET_BARCODE_REGEX]) 
         this.patronBarcodeRegex = new RegExp(settings[SET_BARCODE_REGEX].value);
 
-    if(settings[SET_PATRON_TIMEOUT])
-        patronTimeout = parseInt(settings[SET_PATRON_TIMEOUT].value) * 1000;
+    // Subtract the timeout warning interval from the configured timeout 
+    // so that when taken together they add up to the configured amount.
+    if(settings[SET_PATRON_TIMEOUT]) {
+        patronTimeout = 
+            (parseInt(settings[SET_PATRON_TIMEOUT].value) * 1000) 
+            - patronTimeoutWarning;
+    }
 }
 
 SelfCheckManager.prototype.drawLoginPage = function() {
@@ -933,6 +978,10 @@ SelfCheckManager.prototype.checkin = function(barcode, abortTransit) {
  * out to the patron, redirect to renew()
  */
 SelfCheckManager.prototype.checkout = function(barcode, override) {
+
+    // reset timeout
+    selfckResetTimer();
+
     this.prevCirc = null;
 
     if(!barcode) {