mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-19 07:46:13 +00:00
Support for log events added
This commit is contained in:
parent
40ef11edbe
commit
69934fb870
@ -18,6 +18,9 @@ export class MockedProjectWebServiceHandler {
|
||||
public nodeNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||
public linkNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||
public drawingNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||
public infoNotificationEmitter = new EventEmitter<any>();
|
||||
public warningNotificationEmitter = new EventEmitter<any>();
|
||||
public errorNotificationEmitter = new EventEmitter<any>();
|
||||
}
|
||||
|
||||
describe('LogConsoleComponent', () => {
|
||||
|
@ -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 {
|
||||
|
@ -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));
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,10 @@ export class ProjectWebServiceHandler {
|
||||
public linkNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||
public drawingNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||
|
||||
public infoNotificationEmitter = new EventEmitter<any>();
|
||||
public warningNotificationEmitter = new EventEmitter<any>();
|
||||
public errorNotificationEmitter = new EventEmitter<any>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user