4 * Displays key information and messages to the user.
6 * Currently displays network connection status, egHatch connection
7 * status, and messages delivered via
8 * $scope.$emit('egStatusBarMessage', msg)
11 angular.module('egCoreMod')
13 .directive('egStatusBar', function() {
17 templateUrl : 'eg-status-bar-template',
19 '$scope','$rootScope','egHatch',
20 function($scope , $rootScope , egHatch) {
21 $scope.messages = []; // keep a log of recent messages
23 $scope.netConnected = function() {
24 // TODO: should should be abstracted through egNet
25 return OpenSRF.websocketConnected();
28 // update the UI whenever we lose connection
29 OpenSRF.onWebSocketClosed = function() {
33 $scope.hatchConnected = function() {
34 return egHatch.hatchAvailable;
37 // update the UI whenever we lose connection
38 egHatch.onHatchClose = function() {
42 // update the UI whenever we lose connection
43 egHatch.onHatchOpen = function() {
47 $scope.hatchConnect = function() {
48 egHatch.hatchConnect();
51 $rootScope.$on('egStatusBarMessage', function(evt, args) {
52 $scope.messages.unshift(args.message);
54 // ensure the list does not exceed 10 messages
55 // TODO: configurable?
56 $scope.messages.splice(10, 1);