diff --git a/src/app/components/project-map/log-console/log-console.component.spec.ts b/src/app/components/project-map/log-console/log-console.component.spec.ts index 0efc8bd5..3ec36f58 100644 --- a/src/app/components/project-map/log-console/log-console.component.spec.ts +++ b/src/app/components/project-map/log-console/log-console.component.spec.ts @@ -18,6 +18,9 @@ export class MockedProjectWebServiceHandler { public nodeNotificationEmitter = new EventEmitter(); public linkNotificationEmitter = new EventEmitter(); public drawingNotificationEmitter = new EventEmitter(); + public infoNotificationEmitter = new EventEmitter(); + public warningNotificationEmitter = new EventEmitter(); + public errorNotificationEmitter = new EventEmitter(); } describe('LogConsoleComponent', () => { diff --git a/src/app/components/project-map/log-console/log-console.component.ts b/src/app/components/project-map/log-console/log-console.component.ts index 3febd6a9..6b1aed75 100644 --- a/src/app/components/project-map/log-console/log-console.component.ts +++ b/src/app/components/project-map/log-console/log-console.component.ts @@ -28,9 +28,12 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { private linkSubscription: Subscription; private drawingSubscription: Subscription; private serverRequestsSubscription: Subscription; + private errorSubscription: Subscription; + private warningSubscription: Subscription; + private infoSubscription: Subscription; command: string = ''; - filters: string[] = ['all', 'errors', 'warnings', 'map updates', 'server requests']; + filters: string[] = ['all', 'errors', 'warnings', 'info', 'map updates', 'server requests']; selectedFilter: string = 'all'; filteredEvents: LogEvent[] = []; @@ -79,6 +82,24 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { message: message }); }); + this.errorSubscription = this.projectWebServiceHandler.errorNotificationEmitter.subscribe((message) => { + this.showMessage({ + type: 'error', + message: message + }); + }); + this.errorSubscription = this.projectWebServiceHandler.warningNotificationEmitter.subscribe((message) => { + this.showMessage({ + type: 'warning', + message: message + }); + }); + this.errorSubscription = this.projectWebServiceHandler.infoNotificationEmitter.subscribe((message) => { + this.showMessage({ + type: 'info', + message: message + }); + }); } ngAfterViewInit() { @@ -90,6 +111,9 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { this.linkSubscription.unsubscribe(); this.drawingSubscription.unsubscribe(); this.serverRequestsSubscription.unsubscribe(); + this.errorSubscription.unsubscribe(); + this.warningSubscription.unsubscribe(); + this.infoSubscription.unsubscribe(); } applyFilter() { @@ -181,11 +205,13 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { getFilteredEvents(): LogEvent[] { if (this.selectedFilter === 'server requests') { - return this.logEventsDataSource.getItems().filter(n => n.type === 'server request' || n.type === 'command'); + return this.logEventsDataSource.getItems().filter(n => n.type === 'server request'); } else if (this.selectedFilter === 'errors') { - return this.logEventsDataSource.getItems().filter(n => n.type === 'error' || n.type === 'command'); + return this.logEventsDataSource.getItems().filter(n => n.type === 'error'); } else if (this.selectedFilter === 'warnings') { - return this.logEventsDataSource.getItems().filter(n => n.type === 'warning' || n.type === 'command'); + return this.logEventsDataSource.getItems().filter(n => n.type === 'warning'); + } else if (this.selectedFilter === 'info') { + return this.logEventsDataSource.getItems().filter(n => n.type === 'info'); } else if (this.selectedFilter === 'map updates') { return this.logEventsDataSource.getItems().filter(n => n.type === 'map update' || n.type === 'command'); } else { diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index e49eaaf6..dbba7a16 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -276,7 +276,6 @@ export class ProjectMapComponent implements OnInit, OnDestroy { this.ws = new WebSocket(this.projectService.notificationsPath(this.server, project.project_id)); this.ws.onmessage = (event: MessageEvent) => { - // console.log(event); this.projectWebServiceHandler.handleMessage(JSON.parse(event.data)); }; diff --git a/src/app/handlers/project-web-service-handler.ts b/src/app/handlers/project-web-service-handler.ts index c42379a9..e9405c62 100644 --- a/src/app/handlers/project-web-service-handler.ts +++ b/src/app/handlers/project-web-service-handler.ts @@ -19,6 +19,10 @@ export class ProjectWebServiceHandler { public linkNotificationEmitter = new EventEmitter(); public drawingNotificationEmitter = new EventEmitter(); + public infoNotificationEmitter = new EventEmitter(); + public warningNotificationEmitter = new EventEmitter(); + public errorNotificationEmitter = new EventEmitter(); + constructor( private nodesDataSource: NodesDataSource, private linksDataSource: LinksDataSource, @@ -62,5 +66,14 @@ export class ProjectWebServiceHandler { this.drawingsDataSource.remove(message.event as Drawing); this.drawingNotificationEmitter.emit(message); } + if (message.action === 'log.error') { + this.errorNotificationEmitter.emit(message.event); + } + if (message.action === 'log.warning') { + this.warningNotificationEmitter.emit(message.event); + } + if (message.action === 'log.info') { + this.infoNotificationEmitter.emit(message.event); + } } }