diff --git a/assets/js/controllers.js b/assets/js/controllers.js index 81a05b5..f5c83a1 100644 --- a/assets/js/controllers.js +++ b/assets/js/controllers.js @@ -19,6 +19,30 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) { $scope.eventDone = 0; $scope.eventFailed = 0; + $scope.hasEventSource = false; + $scope.source = null; + + $(function() { + $scope.source = new EventSource('/api/v1/events'); + $scope.source.addEventListener('message', function(e) { + $scope.$apply(function() { + $scope.messages.push(JSON.parse(e.data)); + }); + }, false); + $scope.source.addEventListener('open', function(e) { + $scope.$apply(function() { + $scope.hasEventSource = true; + }); + }, false); + $scope.source.addEventListener('error', function(e) { + if(e.readyState == EventSource.CLOSED) { + $scope.$apply(function() { + $scope.hasEventSource = false; + }); + } + }, false); + }); + $scope.startEvent = function(name, args, glyphicon) { var eID = guid(); console.log("Starting event '" + name + "' with id '" + eID + "'") diff --git a/assets/templates/layout.html b/assets/templates/layout.html index 720104c..30e90c3 100644 --- a/assets/templates/layout.html +++ b/assets/templates/layout.html @@ -76,6 +76,12 @@ padding: 9px 10px; pointer-events: none; } + .ev_good { + color: green; + } + .ev_bad { + color: red; + } @@ -108,6 +114,11 @@ +
  • + + + +