From: Bill Erickson Date: Thu, 27 Oct 2016 17:01:06 +0000 (-0400) Subject: Angular selfcheck WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f148431c0fb855a8009b87617a702affd30ee172;p=working%2FEvergreen.git Angular selfcheck WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 index dff68f76f1..04be1059d7 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/index.tt2 @@ -2,6 +2,7 @@ WRAPPER "staff/base.tt2"; ctx.page_title = l("Self-Checkout"); ctx.page_app = "egSelfCheckApp"; + ctx.page_ctrl = "SelfCheckCtrl"; ctx.hide_nav = 1; %] @@ -13,10 +14,67 @@ [% END %] -
+
+
+
+
[% l('Welcome, [_1]', '{{patron().first_given_name()}}') %]
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ [% l('Items Checked Out') %] +
[% l('Total items this session: [_1]', + '{{counts("session_circ")}}') %]
+
[% l('Total items on account: [_1]', + '{{counts("total_circ")}}') %]
+
+
+
+ [% l('Holds') %] +
[% l('You have [_1] item(s) ready for pickup', + '{{counts("hold_ready")}}') %]
+
[% l('You have [_1] total holds', + '{{counts("total_hold")}}') %]
+
+
+
+ [% l('Fines') %] +
+
+
+
+
[% END %] diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2 index da9848518c..b8f076ec29 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/t_checkout.tt2 @@ -1,3 +1,2 @@

CHECKOUT

-Welcome, {{patron.first_given_name()}} diff --git a/Open-ILS/src/templates/staff/circ/selfcheck/t_login.tt2 b/Open-ILS/src/templates/staff/circ/selfcheck/t_login.tt2 index b34a166dfa..3e15c44b32 100644 --- a/Open-ILS/src/templates/staff/circ/selfcheck/t_login.tt2 +++ b/Open-ILS/src/templates/staff/circ/selfcheck/t_login.tt2 @@ -5,7 +5,8 @@
[% l('Please log in with your username or library barcode.') %] -
+
diff --git a/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js b/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js index 4428364abc..d6c631a98c 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/selfcheck/app.js @@ -2,8 +2,8 @@ * Self-Checkout App */ -angular.module('egSelfCheckApp', ['ngRoute', 'ui.bootstrap', - 'egCoreMod', 'egUiMod', 'ngToast']) +angular.module('egSelfCheckApp', + ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod', 'ngToast']) .config(['ngToastProvider', function(ngToastProvider) { ngToastProvider.configure({ @@ -14,7 +14,6 @@ angular.module('egSelfCheckApp', ['ngRoute', 'ui.bootstrap', .config(function($routeProvider, $locationProvider, $compileProvider) { $locationProvider.html5Mode(true); - $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export // data loaded at startup which only requires an authtoken goes // here. this allows the requests to be run in parallel instead of @@ -68,8 +67,8 @@ angular.module('egSelfCheckApp', ['ngRoute', 'ui.bootstrap', * Self-Checkout Service */ .factory('scSvc', - ['$q','$timeout','$location','$timeout','egCore', -function($q , $timeout , $location , $timeout , egCore) { + ['$q','$timeout','$window','$location','$timeout','egCore','egConfirmDialog', +function($q , $timeout , $window , $location , $timeout , egCore , egConfirmDialog) { var service = { login_timer : null, @@ -83,12 +82,35 @@ function($q , $timeout , $location , $timeout , egCore) { // 20 second inactivity warning; total default timeout is 3 minutes. login_timeout_warning : 20000, + + session_circ_count : 0, + total_circ_count : 0, + hold_ready_count : 0, + total_hold_count : 0, + }; + service.show_timeout_warning = function() { + // TODO: force logout after warning timeout + + egConfirmDialog.open( + egCore.strings.CONFIRM_TIMEOUT_TITLE, + egCore.strings.CONFIRM_TIMEOUT_MSG, + { ok : function() { service.reset_login_timer() }, + cancel : function() { service.logout_patron() } + }, + egCore.strings.CONFIRM_TIMEOUT_CONTINUE, + egCore.strings.CONFIRM_TIMEOUT_LOGOUT + ); + + service.login_warning_timer = $timeout( + service.logout_patron, service.login_timeout_warning + ); + } service.start_login_timer = function() { service.login_timer = $timeout( - service.login_timer_handler, service.login_timeout + service.show_timeout_warning, service.login_timeout ); console.debug('starting patron login timer'); } @@ -96,70 +118,107 @@ function($q , $timeout , $location , $timeout , egCore) { service.reset_login_timer = function() { if (service.login_timer) { $timeout.cancel(service.login_timer); + service.login_timer = null; + } + if (service.login_warning_timer) { + $timeout.cancel(service.login_warning_timer); + service.login_warning_timer = null; } service.start_login_timer(); console.debug('reset patron login timer'); } - service.fetch_patron = function(username, barcode, deferred) { + service.fetch_patron = function(username, barcode) { + var evt; - egCore.net.request( + return egCore.net.request( 'open-ils.actor', 'open-ils.actor.user.retrieve_id_by_barcode_or_username', egCore.auth.token(), barcode, username ).then(function(patron_id) { - if (egCore.evt.parse(patron_id)) { - deferred.reject(); - return; + if (evt = egCore.evt.parse(patron_id)) { + console.warn(evt); + return $q.reject(evt); } - egCore.net.request( + return egCore.net.request( 'open-ils.actor', 'open-ils.actor.user.fleshed.retrieve.authoritative', egCore.auth.token(), patron_id ).then(function(patron) { - if (egCore.evt.parse(patron)) { - deferred.reject(); - return; + if (evt = egCore.evt.parse(patron)) { + console.warn(evt); + return $q.reject(evt); } service.patron = patron; - deferred.resolve(); + service.start_login_timer(); }); }); } service.login_patron = function(username, password) { - var deferred = $q.defer(); // TODO: test barcode regex var barcode = null; if (true) { // TODO: test password required - egCore.auth.verify({ + return egCore.auth.verify({ username : username, barcode : barcode, password : password - }).then( - function() { - service.fetch_patron(username, barcode, deferred); - }, - function() { deferred.reject() /* verify failed */ } - ); + }).then(function() { + return service.fetch_patron(username, barcode); + }); } else { - service.fetch_patron(username, barcode, deferred); + return service.fetch_patron(username, barcode); } - - return deferred.promise; } + service.logout_patron = function() { + // force a page reload to clear all cached data. + $window.location.href = $location.absUrl().replace( + /\/selfcheck\/.*/, '/selfcheck/login'); + } return service; }]) +/* Page-level parent controller for all self-check controllers. + * Handles navigation, scanbox, and page wrapper display. + * This controller is instantiated once per page load, not per navigation. + */ + +.controller('SelfCheckCtrl', + ['$scope','$q','$location','egCore','scSvc', +function($scope, $q, $location , egCore, scSvc) { + + // data shared with sub-scopes + $scope.counts = function(type) { + return scSvc[type + '_count']; + } + + $scope.is_login_page = function() { + return $location.path() == '/circ/selfcheck/login'; + } + + $scope.scanbox = { + text : '', + focus : false, + disabled : function() { + // TODO: inactive barcode, etc. + return false; + } + } + + $scope.patron = function() { return scSvc.patron } + +}]) + + /** * Manages tabbed patron view. * This is the parent scope of all patron tab scopes. @@ -176,7 +235,6 @@ function($scope, $q, $location , egCore, scSvc) { scSvc.login_patron(args.username, args.password).then( function() { - console.log('HERE'); $location.path('/circ/selfcheck/checkout'); }, function() { @@ -197,7 +255,8 @@ function($scope, $q, $location , egCore, scSvc) { return; } - $scope.patron = scSvc.patron; + scSvc.reset_login_timer(); + $scope.scanbox.focus = true; }])