From c9310b11a4899814e70d7c0ead086672d7bc2472 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 22 Apr 2014 17:18:08 -0400 Subject: [PATCH] browser staff : print config UI cont. Signed-off-by: Bill Erickson --- .../staff/admin/workstation/t_printing.tt2 | 22 ++++++++++++++++------ Open-ILS/src/templates/staff/parts/statusbar.tt2 | 1 + .../js/ui/default/staff/admin/workstation/app.js | 16 +++++++++++++--- .../web/js/ui/default/staff/services/printstore.js | 18 ++++++++++++------ .../web/js/ui/default/staff/services/statusbar.js | 4 ++++ 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 index efa78d42af..38743b15e5 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_printing.tt2 @@ -72,12 +72,22 @@
- +
+
+ + +
+
diff --git a/Open-ILS/src/templates/staff/parts/statusbar.tt2 b/Open-ILS/src/templates/staff/parts/statusbar.tt2 index 17523fdc59..7eef88b5d8 100644 --- a/Open-ILS/src/templates/staff/parts/statusbar.tt2 +++ b/Open-ILS/src/templates/staff/parts/statusbar.tt2 @@ -15,6 +15,7 @@
  • {{messages[0]}}
  • diff --git a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js index 683e5cc871..c4eb1dc14c 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js @@ -68,6 +68,8 @@ function($scope , egPrintStore) { .then(function(config) { $scope.printConfig = config; + if (!$scope.defaultPrinter) return; + // apply the default printer to every context which has // no printer configured. angular.forEach( @@ -81,9 +83,6 @@ function($scope , egPrintStore) { } } ); - - console.log("CONFIGS : " + - JSON.stringify($scope.printConfig, undefined, 2)); }); $scope.printerConfString = function() { @@ -93,6 +92,17 @@ function($scope , egPrintStore) { $scope.printConfig[$scope.context], undefined, 2); } + $scope.resetConfig = function() { + $scope.printConfig[$scope.context] = { + context : $scope.context + } + + if ($scope.defaultPrinter) { + $scope.printConfig[$scope.context].printer = + $scope.defaultPrinter.name; + } + } + $scope.configurePrinter = function() { $scope.actionPending = true; egPrintStore.configurePrinter( diff --git a/Open-ILS/web/js/ui/default/staff/services/printstore.js b/Open-ILS/web/js/ui/default/staff/services/printstore.js index 64c877998d..cd8dfccee0 100644 --- a/Open-ILS/web/js/ui/default/staff/services/printstore.js +++ b/Open-ILS/web/js/ui/default/staff/services/printstore.js @@ -41,6 +41,7 @@ angular.module('egCoreMod') if (key.match(/deferred/)) return; msg2[key] = val; }); + console.debug("sending '" + msg.action + "' command to Hatch"); service.socket.send(JSON.stringify(msg2)); } @@ -48,7 +49,7 @@ angular.module('egCoreMod') // Otherwise handle the request locally. service.dispatchRequest = function(msg) { - msg.msgid = '' + (service.msgId++); + msg.msgid = service.msgId++; msg.deferred = $q.defer(); service.messages[msg.msgid] = msg; @@ -74,6 +75,11 @@ angular.module('egCoreMod') // it from our tracked requests. service.resolveRequest = function(msg) { + if (!service.messages[msg.msgid]) { + console.warn('no cached message for ' + + msg.msgid + ' : ' + JSON.stringify(msg, null, 2)); + } + // for requests sent through Hatch, only the cached // request will have the original promise attached msg.deferred = service.messages[msg.msgid].deferred; @@ -81,10 +87,10 @@ angular.module('egCoreMod') // resolve / reject if (msg.error) { - console.error("egPrintStore command failed : " + msg.error); + console.error("egPrintStore command failed : " + + JSON.stringify(msg.error, null, 2)); msg.deferred.reject(msg.error); } else { - console.debug("egPrintStore command succeeded : " + msg.content); msg.deferred.resolve(msg.content); } } @@ -150,9 +156,9 @@ angular.module('egCoreMod') service.hatchAvailable = true; if (service.onHatchOpen) service.onHatchOpen(); - angular.forEach(service.pending, function(msg) { + while ( (msg = service.pending.shift()) ) { service.sendToHatch(msg); - }); + }; } service.socket.onclose = function() { @@ -181,8 +187,8 @@ angular.module('egCoreMod') return; } - console.debug('Hatch says ' + msgStr); var msgObj = JSON.parse(msgStr); + console.debug('Hatch says ' + JSON.stringify(msgObj, null, 2)); service.resolveRequest(msgObj); } } diff --git a/Open-ILS/web/js/ui/default/staff/services/statusbar.js b/Open-ILS/web/js/ui/default/staff/services/statusbar.js index 78a5d94c0b..079207b354 100644 --- a/Open-ILS/web/js/ui/default/staff/services/statusbar.js +++ b/Open-ILS/web/js/ui/default/staff/services/statusbar.js @@ -44,6 +44,10 @@ angular.module('egCoreMod') $scope.$apply(); } + $scope.hatchConnect = function() { + egPrintStore.hatchConnect(); + } + $rootScope.$on('egStatusBarMessage', function(evt, args) { $scope.messages.unshift(args.message); -- 2.11.0