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',
20 '$scope','$rootScope','egHatch',
21 function($scope , $rootScope , egHatch) {
22 $scope.messages = []; // keep a log of recent messages
24 $scope.netConnected = function() {
25 // TODO: should should be abstracted through egNet
26 return OpenSRF.websocketConnected();
29 // update the UI whenever we lose connection
30 OpenSRF.onWebSocketClosed = function() {
34 $scope.hatchConnected = function() {
35 return egHatch.hatchAvailable;
38 // update the UI whenever we lose connection
39 egHatch.onHatchClose = function() {
43 // update the UI whenever we lose connection
44 egHatch.onHatchOpen = function() {
48 $scope.hatchConnect = function() {
49 egHatch.hatchConnect();
52 $rootScope.$on('egStatusBarMessage', function(evt, args) {
53 $scope.messages.unshift(args);
55 // ensure the list does not exceed 10 messages
56 // TODO: configurable?
57 $scope.messages.splice(10, 1);