diff --git a/api/core/event/event.create.js b/api/core/event/event.create.js index 6228af4e7e..7ad4c05a44 100644 --- a/api/core/event/event.create.js +++ b/api/core/event/event.create.js @@ -90,6 +90,11 @@ module.exports = function create(event){ return eventSaved; }) .then((eventSaved) => { + + if(!eventSaved.user) { + return eventSaved; + } + gladys.socket.emit('newEvent', { id: eventSaved.id, name: eventType.name, diff --git a/assets/js/app/event/event.controller.js b/assets/js/app/event/event.controller.js index 60aac0de7b..c8196c6a5b 100644 --- a/assets/js/app/event/event.controller.js +++ b/assets/js/app/event/event.controller.js @@ -6,9 +6,9 @@ .module('gladys') .controller('EventCtrl', EventCtrl); - EventCtrl.$inject = ['eventService']; + EventCtrl.$inject = ['eventService', '$scope']; - function EventCtrl(eventService) { + function EventCtrl(eventService, $scope) { /* jshint validthis: true */ var vm = this; vm.events = []; @@ -49,7 +49,9 @@ // waiting for websocket message function waitForNewEvent() { io.socket.on('newEvent', function (event) { - vm.events.unshift(event); + $scope.$apply(function(){ + vm.events.unshift(event) + }) }); }