From f064a80ba5a557ce353d74b1198a0418d70c35ae Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 9 Apr 2014 17:16:46 -0400 Subject: [PATCH] browser staff : status bar; print repairs Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/css/style.css.tt2 | 32 +++++++++---- Open-ILS/src/templates/staff/parts/statusbar.tt2 | 32 +++++++++++++ Open-ILS/src/templates/staff/t_base.tt2 | 4 ++ Open-ILS/src/templates/staff/t_base_js.tt2 | 1 + .../web/js/ui/default/staff/circ/patron/app.js | 4 +- Open-ILS/web/js/ui/default/staff/navbar.js | 4 +- Open-ILS/web/js/ui/default/staff/services/grid.js | 2 +- .../web/js/ui/default/staff/services/printstore.js | 24 +++++++--- .../web/js/ui/default/staff/services/statusbar.js | 56 ++++++++++++++++++++++ 9 files changed, 141 insertions(+), 18 deletions(-) create mode 100644 Open-ILS/src/templates/staff/parts/statusbar.tt2 create mode 100644 Open-ILS/web/js/ui/default/staff/services/statusbar.js diff --git a/Open-ILS/src/templates/staff/css/style.css.tt2 b/Open-ILS/src/templates/staff/css/style.css.tt2 index 5c19ab02fa..9f55306ffe 100644 --- a/Open-ILS/src/templates/staff/css/style.css.tt2 +++ b/Open-ILS/src/templates/staff/css/style.css.tt2 @@ -2,29 +2,45 @@ * Simple default navbar style adjustements to apply the Evergreen color. * TODO: style other components to match EG color scheme */ -.navbar-default { +#top-navbar.navbar-default { background: -webkit-linear-gradient(#00593d, #007a54); background-color: #007a54; color: #fff; } - -.navbar-default .navbar-nav>li>a { +#top-navbar.navbar-default .navbar-nav>li>a { color: #fff; } - -.navbar-default .navbar-nav>li>a:hover { +#top-navbar.navbar-default .navbar-nav>li>a:hover { color: #ddd; } - -.navbar-default .navbar-nav>.dropdown>a .caret { +#top-navbar.navbar-default .navbar-nav>.dropdown>a .caret { border-top-color: #fff; border-bottom-color: #fff; } -.navbar-default .navbar-nav>.dropdown>a:hover .caret { +#top-navbar.navbar-default .navbar-nav>.dropdown>a:hover .caret { border-top-color: #ddd; border-bottom-color: #ddd; } +/* status bar along the bottom of the page ------------------------ */ +/* decrease padding to decrease overall height */ +#status-bar { + min-height:1.8em !important; +} +#status-bar > ul { + margin-right:6px; +} +#status-bar li { + padding-left: 10px; +} +#status-bar > li > a { + padding-top:5px !important; + padding-bottom:5px !important; +} +.status-bar-connected { + color: rgb(92, 184, 92); /* success */ +} + /* -------------------------------------------------------------------------- * Structural modifications */ diff --git a/Open-ILS/src/templates/staff/parts/statusbar.tt2 b/Open-ILS/src/templates/staff/parts/statusbar.tt2 new file mode 100644 index 0000000000..17523fdc59 --- /dev/null +++ b/Open-ILS/src/templates/staff/parts/statusbar.tt2 @@ -0,0 +1,32 @@ + + + diff --git a/Open-ILS/src/templates/staff/t_base.tt2 b/Open-ILS/src/templates/staff/t_base.tt2 index 0f54e03907..aade37c657 100644 --- a/Open-ILS/src/templates/staff/t_base.tt2 +++ b/Open-ILS/src/templates/staff/t_base.tt2 @@ -16,6 +16,10 @@ [% INCLUDE "staff/t_navbar.tt2" %]
[% content %]
[% + # status bar along bottom of page + INCLUDE "staff/parts/statusbar.tt2"; + + # script imports INCLUDE "staff/t_base_js.tt2"; # App-specific JS load commands go into an APP_JS block. diff --git a/Open-ILS/src/templates/staff/t_base_js.tt2 b/Open-ILS/src/templates/staff/t_base_js.tt2 index ab243c3df0..403981b403 100644 --- a/Open-ILS/src/templates/staff/t_base_js.tt2 +++ b/Open-ILS/src/templates/staff/t_base_js.tt2 @@ -35,6 +35,7 @@ + diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index eddf008bb6..5cb2900df9 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -297,10 +297,10 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egEnv, ); return deferred.promise; } - } else { - patronSvc.lastSearch = fullSearch; } + patronSvc.lastSearch = fullSearch; + if (fullSearch.search.id) { // search by user id performs a direct ID lookup var userId = fullSearch.search.id.value; diff --git a/Open-ILS/web/js/ui/default/staff/navbar.js b/Open-ILS/web/js/ui/default/staff/navbar.js index b54975c1d0..ce7c7e3010 100644 --- a/Open-ILS/web/js/ui/default/staff/navbar.js +++ b/Open-ILS/web/js/ui/default/staff/navbar.js @@ -33,6 +33,7 @@ function NavCtrl($scope, $window, $location, egStartup, egAuth, egEnv) { egStartup.go().then( function() { + // login page will not have a cached user if (!egAuth.user()) return; @@ -48,5 +49,6 @@ function NavCtrl($scope, $window, $location, egStartup, egAuth, egEnv) { } // minify-safe dependency injection -NavCtrl.$inject = ['$scope', '$window', +NavCtrl.$inject = ['$scope', '$window', '$location', 'egStartup', 'egAuth', 'egEnv']; + diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index 7051ff438c..f230bcca1a 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -806,7 +806,7 @@ angular.module('egGridMod', provider.query, { sort : provider.sort, limit : count, - offset : index + offset : offset } ); } 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 c4a886d9d4..d3c30816ff 100644 --- a/Open-ILS/web/js/ui/default/staff/services/printstore.js +++ b/Open-ILS/web/js/ui/default/staff/services/printstore.js @@ -60,6 +60,8 @@ angular.module('egCoreMod') service.socket.onopen = function() { console.debug('connected to Hatch'); service.hatchAvailable = true; + if (service.onHatchOpen) + service.onHatchOpen(); angular.forEach(service.pending, function(msg) { service.socket.send(JSON.stringify(msg)); }); @@ -70,12 +72,16 @@ angular.module('egCoreMod') console.debug("disconnected from Hatch"); service.socket = null; service.hatchAvailable = null; // reset + if (service.onHatchClose) + service.onHatchClose(); } service.socket.onerror = function() { console.debug( "unable to connect to Hatch server at " + service.hatchURL); service.redirectPendingMessages(); + if (service.onHatchClose) + service.onHatchClose(); } service.socket.onmessage = function(evt) { @@ -135,10 +141,10 @@ angular.module('egCoreMod') return { restrict : 'AE', template : '
{{printContent}}
', - controller : ['$scope', '$window', 'egPrintStore', - function($scope, $window, egPrintStore) { + controller : ['$scope','$window','$timeout','egPrintStore', + function($scope, $window, $timeout, egPrintStore) { egPrintStore.onBrowserPrint = function(mime, data) { - console.log('printing ' + data.length + ' of ' + mime); + console.log('printing ' + data.length + ' chars of ' + mime); switch(mime) { case 'text/csv': case 'text/plain': @@ -150,9 +156,15 @@ angular.module('egCoreMod') } // force the template to absorb the data before printing - $scope.$apply(); - $window.print(); - $scope.printContent = ''; + // if an apply/digest loop is not already in progress + //if (!$scope.$$phase) $scope.$apply(); + + $timeout( + function() { + $scope.$apply(); + $window.print(); + } + ); } } ] diff --git a/Open-ILS/web/js/ui/default/staff/services/statusbar.js b/Open-ILS/web/js/ui/default/staff/services/statusbar.js new file mode 100644 index 0000000000..78a5d94c0b --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/services/statusbar.js @@ -0,0 +1,56 @@ +/** + * egStatusBar + * + * Displays key information and messages to the user. + * + * Currently displays network connection status, egPrintStore connection + * status, and messages delivered via + * $scope.$emit('egStatusBarMessage', msg) + */ + +angular.module('egCoreMod') + +.directive('egStatusBar', function() { + return { + restrict : 'AE', + replace : true, + templateUrl : 'eg-status-bar-template', + controller : [ + '$scope', '$rootScope', 'egPrintStore', + function($scope, $rootScope, egPrintStore) { + $scope.messages = []; // keep a log of recent messages + + $scope.netConnected = function() { + // TODO: should should be abstracted through egNet + return OpenSRF.websocketConnected(); + } + + // update the UI whenever we lose connection + OpenSRF.onWebSocketClosed = function() { + $scope.$apply(); + } + + $scope.hatchConnected = function() { + return egPrintStore.hatchAvailable; + } + + // update the UI whenever we lose connection + egPrintStore.onHatchClose = function() { + $scope.$apply(); + } + + // update the UI whenever we lose connection + egPrintStore.onHatchOpen = function() { + $scope.$apply(); + } + + $rootScope.$on('egStatusBarMessage', function(evt, args) { + $scope.messages.unshift(args.message); + + // ensure the list does not exceed 10 messages + // TODO: configurable? + $scope.messages.splice(10, 1); + }); + }] + } +}); -- 2.11.0