browser staff : status bar; print repairs
authorBill Erickson <berick@esilibrary.com>
Wed, 9 Apr 2014 21:16:46 +0000 (17:16 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 9 Apr 2014 21:16:46 +0000 (17:16 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/css/style.css.tt2
Open-ILS/src/templates/staff/parts/statusbar.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/t_base.tt2
Open-ILS/src/templates/staff/t_base_js.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js
Open-ILS/web/js/ui/default/staff/navbar.js
Open-ILS/web/js/ui/default/staff/services/grid.js
Open-ILS/web/js/ui/default/staff/services/printstore.js
Open-ILS/web/js/ui/default/staff/services/statusbar.js [new file with mode: 0644]

index 5c19ab0..9f55306 100644 (file)
@@ -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 (file)
index 0000000..17523fd
--- /dev/null
@@ -0,0 +1,32 @@
+<!-- Status bar along the bottom of the page -->
+
+<div id="status-bar" 
+  class="navbar navbar-default navbar-fixed-bottom" 
+  role="navigation">
+
+  <!-- 
+    Define the status bar as a directive so it may be used globally.
+    The template is defined inline (below) to leverage i18n and 
+    so one less network fetch is required.
+  -->
+  <eg-status-bar></eg-status-bar>
+  <script type="text/ng-template" id="eg-status-bar-template">
+    <ul class="nav navbar-nav navbar-right">
+      <li>{{messages[0]}}</li>
+      <li>
+        <span 
+          title="[% l('Print/Store Connection Status') %]"
+          class="glyphicon glyphicon-transfer"
+          ng-class="{'status-bar-connected' : hatchConnected()}">
+        </span>
+      </li>
+      <li>
+        <span 
+          title="[% l('Network Connection Status') %]"
+          class="glyphicon glyphicon-signal"
+          ng-class="{'status-bar-connected' : netConnected()}">
+        </span>
+      </li>
+    </ul>    
+  </script>
+</div>
index 0f54e03..aade37c 100644 (file)
     [% INCLUDE "staff/t_navbar.tt2" %]
     <div id="top-content-container" class="container">[% content %]</div>
     [% 
+      # 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.
index ab243c3..403981b 100644 (file)
@@ -35,6 +35,7 @@
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/startup.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/printstore.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/statusbar.js"></script>
 
 <!-- navbar driver -->
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/navbar.js"></script>
index eddf008..5cb2900 100644 (file)
@@ -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;
index b54975c..ce7c7e3 100644 (file)
@@ -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'];
+
index 7051ff4..f230bcc 100644 (file)
@@ -806,7 +806,7 @@ angular.module('egGridMod',
                         provider.query,
                         {   sort : provider.sort,
                             limit : count,
-                            offset : index
+                            offset : offset
                         }
                     );
                 }
index c4a886d..d3c3081 100644 (file)
@@ -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 : '<div>{{printContent}}</div>',
-        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 (file)
index 0000000..78a5d94
--- /dev/null
@@ -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); 
+            });
+        }]
+    }
+});