{"version":3,"file":"kiosk.js","mappings":"YACA,aACAA,uCAEAC,qLACAC,WACAC,8BACA,gCACAC,GAAyB,mEACzBC,sBACAC,cACAA,UAA0BC,WAAWC,uBAErC,YACAC,yBAEAH,oDACAA,wBACAA,wBACAA,gHACAA,mGACAA,gFACAA,uEAEA,iBACAI,SACAC,sCACA,EAEAC,aACAD,wCACAE,GACA,EAEAC,aACAC,YACAJ,wCACAD,UACA,EAEAG,aACAG,UACA,EAEAC,cACA,qBACA,mCACAC,wCAAyEC,aACzED,uBACA,YACA,mDACA,EACAA,CACA,EA0BAZ,6BACA,kBACA,qBACA,EA1BAc,mDACAd,qBACAA,gBACAA,oBACAe,iDACAf,uCACA,GACAA,qBAEAA,cACAgB,GAEA,EAAa,KAEbpB,OAAuCqB,8DACvCjB,iBAGyG,GAQzG,EAGAA,sBACAS,YACAH,GACA,EAEAN,+BACA,mBACA,oBAEAc,2CAAmEI,mCAAyC,CAAIC,YAChHC,SACAxB,OAAuCqB,sDACvCjB,iBACAA,qBACAA,gBACAA,oBACAe,iDACAf,uCACA,GACAA,sBACiB,WACjBJ,OAAuCqB,wFACvCjB,gBACA,EACA,EAEAA,sBACAA,iCACAc,2CAAmEI,+CAAsD,CAAIC,YAC7HC,SACAxB,OAAuCqB,iFACvCjB,iCACAA,qBACAA,gBACAA,oBACAe,iDACAf,uCACA,GACAA,sBACiB,YACjBA,iCACAJ,OAAuCqB,6CACvC,EACA,CACA,GACA","names":["angular","controller","alertService","$document","myHeaders","$rootScope","$scope","current","sorted","CheckoutKioskConfig","timeout","$","onExpires","onIdle","onActivity","$timeout","$state","mkIssue","issue","promise","$http","jQuery","startTimer","msg","op","headers","then"],"sourceRoot":"webpack:///","sources":["app/js/kiosk-app.js"],"sourcesContent":["(function () {\n 'use strict';\n angular.module('kohapac.kiosk-app', [])\n\n .controller('CheckoutKioskCtrl', [\"$scope\", \"$rootScope\", \"$state\", \"$timeout\", \"$http\", \"kwApi\", \"alertService\", \"bibService\", \"kwHotkeySvc\", \"$document\", \"configService\", function ($scope, $rootScope, $state, $timeout, $http, kwApi,\n alertService, bibService, kwHotkeySvc, $document, configService) {\n $document.unbind('keydown', kwHotkeySvc.keydown);\n var CheckoutKioskConfig = configService.CheckoutKioskConfig || {};\n var myHeaders = {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'};\n $rootScope.hideHeaderFooter = true;\n $scope.loggedin = false;\n $scope.issues = { current: {}, sorted: [], _loading: false };\n\n var timeout, millis = 60000;\n if (CheckoutKioskConfig.timeout) millis = CheckoutKioskConfig.timeout;\n\n $scope.heading = CheckoutKioskConfig.heading ? CheckoutKioskConfig.heading : 'Self Checkout Kiosk';\n $scope.head = CheckoutKioskConfig.head ? CheckoutKioskConfig.head : '';\n $scope.foot = CheckoutKioskConfig.foot ? CheckoutKioskConfig.foot : '';\n $scope.placeholderIdentifyPatron = CheckoutKioskConfig.placeholderIdentifyPatron ? CheckoutKioskConfig.placeholderIdentifyPatron : 'Enter Library Card Number';\n $scope.placeholderIdentifyItem = CheckoutKioskConfig.placeholderIdentifyItem ? CheckoutKioskConfig.placeholderIdentifyItem : 'Enter Item Barcode';\n $scope.enterButtonCardNumber = CheckoutKioskConfig.enterButtonCardNumber ? CheckoutKioskConfig.enterButtonCardNumber : 'Enter';\n $scope.enterButtonBarcode = CheckoutKioskConfig.enterButtonBarcode ? CheckoutKioskConfig.enterButtonBarcode : 'Enter';\n\n var startTimer = function () {\n timeout = $timeout(onExpires, millis);\n $(document).on(\"mousemove keypress\", onActivity);\n }\n\n var onExpires = function () {\n $(document).off(\"mousemove keypress\", onActivity);\n onIdle();\n }\n\n var onActivity = function () {\n $timeout.cancel(timeout);\n $(document).off(\"mousemove keypress\", onActivity);\n timeout = $timeout(startTimer, 1000); // Wait a second to avoid hammering the system.\n }\n\n var onIdle = function () {\n $state.reload();\n }\n\n var mkIssue = function(data){\n var issue = new kwApi.Issue( data );\n issue.itemSummary = issue._embed.item;\n issue.bib = bibService.get(issue.itemSummary.biblionumber, { promise: false });\n issue.can_renew = function(){\n if(!issue.bib.id) return;\n return issue.bib.itemsAreRenewable() && !(issue.renewedToday());\n };\n return issue;\n };\n\n var loadIssues = (login) => {\n $http.get('/api/kiosk/' + $scope.cardnumber).then( function (rsp) {\n $scope.issues._loading = true;\n $scope.patron = rsp.data;\n $scope.issues.current = {};\n jQuery.each($scope.patron._embed.issues, function(_,val){\n $scope.issues.current[val.issue.id] = mkIssue( val.issue );\n });\n $scope.issues._loading = false;\n if (login) {\n $scope.loggedin = true;\n startTimer();\n }\n }, () => {\n if (login) {\n alertService.add({ msg: 'Unable to log in, please see a librarian', type: 'error' });\n $scope.cardnumber = null;\n }\n else {\n alertService.add({ msg: 'Unable to process request, try again later', type: 'error' });\n }\n });\n }\n\n $scope.submitCardNumber = () => {\n if ($scope.cardnumber === undefined) return;\n if ($scope.cardnumber === '') return;\n loadIssues(true);\n }\n\n $scope.logMeOut = function () {\n $timeout.cancel(timeout);\n onExpires();\n }\n\n $scope.issueBarcode = function () {\n if ($scope.itembarcode === undefined) return;\n if ($scope.itembarcode === '') return;\n\n $http.post('/api/kiosk/' + $scope.cardnumber, $.param({op: 'issue', barcode: $scope.itembarcode}), {headers: myHeaders})\n .then( rsp => {\n alertService.add({ msg: \"Issued barcode: \" + $scope.itembarcode, type: 'success' });\n $scope.itembarcode = '';\n $scope.issues._loading = true;\n $scope.patron = rsp.data;\n $scope.issues.current = {};\n jQuery.each($scope.patron._embed.issues, function(_,val){\n $scope.issues.current[val.issue.id] = mkIssue( val.issue );\n });\n $scope.issues._loading = false;\n }, function () {\n alertService.add({ msg: \"Unable to issue barcode: \" + $scope.itembarcode + \", please see a librarian\" , type: 'error' });\n $scope.itembarcode = '';\n });\n }\n\n $scope.renewId = function (id) {\n $scope.issues.current[id]._renewing = true;\n $http.post('/api/kiosk/' + $scope.cardnumber, $.param({op: 'renew', id: $scope.issues.current[id].itemnumber}), {headers: myHeaders})\n .then( rsp => {\n alertService.add({ msg: \"Renewed barcode: \" + $scope.issues.current[id].itemSummary.barcode, type: 'success' });\n $scope.issues.current[id]._renewing = false;\n $scope.issues._loading = true;\n $scope.patron = rsp.data;\n $scope.issues.current = {};\n jQuery.each($scope.patron._embed.issues, function(_,val){\n $scope.issues.current[val.issue.id] = mkIssue( val.issue );\n });\n $scope.issues._loading = false;\n }, function (e) {\n $scope.issues.current[id]._renewing = false;\n alertService.add({ msg: \"Unable to renew: \" + e.data, type: 'error' });\n });\n };\n }])\n})();\n"],"x_google_ignoreList":[]}