From f7edee62ba832ffd5cd3a8c1946dd6a10bf33d1c Mon Sep 17 00:00:00 2001 From: Ben Shum Date: Fri, 26 Sep 2014 17:05:39 -0400 Subject: [PATCH] LP#1306814: Make use of patron timeout setting for selfcheck As described in the bug, the library setting "Self Check: Patron Login Timeout (in seconds)" does not appear to work with the newer selfcheck interface. It looks like some of it was already being pulled in, like the variable, but the interface was not utilizing it. This commit borrows from the old JS selfcheck and implements a default of three minutes for selfcheck timeout otherwise handled by the library setting. Signed-off-by: Ben Shum Signed-off-by: Michele Morgan --- .../js/ui/default/circ/selfcheck/selfcheck.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js index f3950cff4c..303cbb9fb7 100644 --- a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js +++ b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js @@ -14,6 +14,9 @@ dojo.require('openils.widget.OrgUnitFilteringSelect'); dojo.requireLocalization('openils.circ', 'selfcheck'); var localeStrings = dojo.i18n.getLocalization('openils.circ', 'selfcheck'); +// set patron timeout default +var patronTimeout = 180000; /* 3 minutes */ +var timerId = null; const SET_BARCODE_REGEX = 'opac.barcode_regex'; const SET_PATRON_TIMEOUT = 'circ.selfcheck.patron_login_timeout'; @@ -30,6 +33,22 @@ const SET_BLOCK_CHECKOUT_ON_COPY_STATUS = 'circ.selfcheck.block_checkout_on_copy // set before the login dialog is rendered openils.User.default_login_agent = 'selfcheck'; +// start the logout timer +function selfckStartTimer() { + timerId = setTimeout( + function() { + SelfCheckManager.prototype.logoutPatron(); + }, + patronTimeout + ); +} + +// reset the logout timer +function selfckResetTimer() { + clearTimeout(timerId); + selfckStartTimer(); +} + function SelfCheckManager() { this.cgi = new openils.CGI(); @@ -275,6 +294,9 @@ 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; } SelfCheckManager.prototype.drawLoginPage = function() { @@ -309,6 +331,9 @@ SelfCheckManager.prototype.drawLoginPage = function() { */ SelfCheckManager.prototype.loginPatron = function(barcode_or_usrname, passwd) { + // reset timeout + selfckResetTimer(); + this.setupStaffLogin(true); // verify still valid var barcode = null; @@ -583,6 +608,9 @@ SelfCheckManager.prototype.goToTab = function(name) { openils.Util.hide('oils-selfck-holds-page'); openils.Util.hide('oils-selfck-circ-page'); openils.Util.hide('oils-selfck-pay-fines-link'); + + // reset timeout + selfckResetTimer() switch(name) { case 'checkout': @@ -605,6 +633,9 @@ SelfCheckManager.prototype.goToTab = function(name) { SelfCheckManager.prototype.printList = function() { + // reset timeout + selfckResetTimer() + switch(this.tabName) { case 'checkout': this.printSessionReceipt(); -- 2.43.2