LP1476370 Selfcheck logout warning, checkout resets
authorBill Erickson <berickxx@gmail.com>
Mon, 20 Jul 2015 20:26:30 +0000 (16:26 -0400)
committerBen Shum <bshum@biblio.org>
Tue, 28 Jul 2015 20:43:07 +0000 (16:43 -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>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/templates/circ/selfcheck/logout_dialog.tt2 [new file with mode: 0644]
Open-ILS/src/templates/circ/selfcheck/main.tt2
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js

diff --git a/Open-ILS/src/templates/circ/selfcheck/logout_dialog.tt2 b/Open-ILS/src/templates/circ/selfcheck/logout_dialog.tt2
new file mode 100644 (file)
index 0000000..11ecd07
--- /dev/null
@@ -0,0 +1,14 @@
+<div dojoType="dijit.Dialog" jsId='oilsSelfckLogoutDialog' style='display:none;'>
+  <p>[% l('Your login session will soon timeout due to inactivity.') %]</p>
+  <table><tr>
+    <td>
+      <button jsId='oilsSelfckLogout' 
+        dojoType='dijit.form.Button'>[% l('Logout') %]</button>
+    </td>
+    <td>
+      <button jsId='oilsSelfckContinue' 
+        dojoType='dijit.form.Button'>[% l('Continue Session') %]</button>
+    </td>
+  </tr></table>
+</div>
+
index 22022fe..c82337c 100644 (file)
@@ -4,6 +4,7 @@
 <script type="text/javascript" src="[% ctx.media_prefix %]/js/ui/default/circ/selfcheck/payment.js"></script>
 <link rel='stylesheet' type='text/css' href='[% ctx.media_prefix %]/css/skin/[% ctx.skin %]/selfcheck.css'/>
 [% INCLUDE 'circ/selfcheck/audio_config.tt2' %]
+[% INCLUDE 'circ/selfcheck/logout_dialog.tt2' %]
 
 <div id='oils-selfck-top-div'>
     [% INCLUDE 'circ/selfcheck/banner.tt2' %]
         </table>
     </form>
 </div>
+<div dojoType="dijit.Dialog" jsId='oilsSelfckWsDialog' class='oils-logout-dialog' style='display:none;'>
+    <form>
+        <table>
+            <tr>
+                <td>[% l('Choose a location') %]</td>
+                <td><div dojoType='openils.widget.OrgUnitFilteringSelect' jsId='oilsSelfckWsLocSelector' 
+                    searchAttr='shortname' labelAttr='shortname'></div></td>
+            </tr>
+            <tr>
+                <td>[% l('Enter a workstation name') %]</td>
+                <td><input dojoType='dijit.form.TextBox' jsId='oilsSelfckWsName'/></td>
+            </tr>
+            <tr>
+                <td colspan='2' align='center'>
+                    <button jsId='oilsSelfckWsSubmit' dojoType='dijit.form.Button'>[% l('Submit') %]</button>
+                </td>
+            </tr>
+        </table>
+    </form>
+</div>
+
 [% END %]
 
 
index 303cbb9..61ec139 100644 (file)
@@ -15,8 +15,12 @@ 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;
 
 const SET_BARCODE_REGEX = 'opac.barcode_regex';
 const SET_PATRON_TIMEOUT = 'circ.selfcheck.patron_login_timeout';
@@ -37,7 +41,7 @@ openils.User.default_login_agent = 'selfcheck';
 function selfckStartTimer() {
     timerId = setTimeout(
         function() {
-            SelfCheckManager.prototype.logoutPatron();
+            selfckLogoutWarning();
         },
         patronTimeout
     );
@@ -49,6 +53,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() {
 
     this.cgi = new openils.CGI();
@@ -295,8 +334,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() {
@@ -941,6 +985,9 @@ SelfCheckManager.prototype.checkin = function(barcode, abortTransit) {
  */
 SelfCheckManager.prototype.checkout = function(barcode, override) {
 
+    // reset timeout
+    selfckResetTimer();
+
     this.prevCirc = null;
 
     if(!barcode) {