mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-23 08:55:32 +00:00
Support for log events added
This commit is contained in:
@ -18,6 +18,9 @@ export class MockedProjectWebServiceHandler {
|
|||||||
public nodeNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
public nodeNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||||
public linkNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
public linkNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||||
public drawingNotificationEmitter = 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', () => {
|
describe('LogConsoleComponent', () => {
|
||||||
|
@ -28,9 +28,12 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
private linkSubscription: Subscription;
|
private linkSubscription: Subscription;
|
||||||
private drawingSubscription: Subscription;
|
private drawingSubscription: Subscription;
|
||||||
private serverRequestsSubscription: Subscription;
|
private serverRequestsSubscription: Subscription;
|
||||||
|
private errorSubscription: Subscription;
|
||||||
|
private warningSubscription: Subscription;
|
||||||
|
private infoSubscription: Subscription;
|
||||||
command: string = '';
|
command: string = '';
|
||||||
|
|
||||||
filters: string[] = ['all', 'errors', 'warnings', 'map updates', 'server requests'];
|
filters: string[] = ['all', 'errors', 'warnings', 'info', 'map updates', 'server requests'];
|
||||||
selectedFilter: string = 'all';
|
selectedFilter: string = 'all';
|
||||||
filteredEvents: LogEvent[] = [];
|
filteredEvents: LogEvent[] = [];
|
||||||
|
|
||||||
@ -79,6 +82,24 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
message: message
|
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() {
|
ngAfterViewInit() {
|
||||||
@ -90,6 +111,9 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.linkSubscription.unsubscribe();
|
this.linkSubscription.unsubscribe();
|
||||||
this.drawingSubscription.unsubscribe();
|
this.drawingSubscription.unsubscribe();
|
||||||
this.serverRequestsSubscription.unsubscribe();
|
this.serverRequestsSubscription.unsubscribe();
|
||||||
|
this.errorSubscription.unsubscribe();
|
||||||
|
this.warningSubscription.unsubscribe();
|
||||||
|
this.infoSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
applyFilter() {
|
applyFilter() {
|
||||||
@ -181,11 +205,13 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
getFilteredEvents(): LogEvent[] {
|
getFilteredEvents(): LogEvent[] {
|
||||||
if (this.selectedFilter === 'server requests') {
|
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') {
|
} 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') {
|
} 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') {
|
} else if (this.selectedFilter === 'map updates') {
|
||||||
return this.logEventsDataSource.getItems().filter(n => n.type === 'map update' || n.type === 'command');
|
return this.logEventsDataSource.getItems().filter(n => n.type === 'map update' || n.type === 'command');
|
||||||
} else {
|
} 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 = new WebSocket(this.projectService.notificationsPath(this.server, project.project_id));
|
||||||
|
|
||||||
this.ws.onmessage = (event: MessageEvent) => {
|
this.ws.onmessage = (event: MessageEvent) => {
|
||||||
// console.log(event);
|
|
||||||
this.projectWebServiceHandler.handleMessage(JSON.parse(event.data));
|
this.projectWebServiceHandler.handleMessage(JSON.parse(event.data));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ export class ProjectWebServiceHandler {
|
|||||||
public linkNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
public linkNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||||
public drawingNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
public drawingNotificationEmitter = new EventEmitter<WebServiceMessage>();
|
||||||
|
|
||||||
|
public infoNotificationEmitter = new EventEmitter<any>();
|
||||||
|
public warningNotificationEmitter = new EventEmitter<any>();
|
||||||
|
public errorNotificationEmitter = new EventEmitter<any>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private nodesDataSource: NodesDataSource,
|
private nodesDataSource: NodesDataSource,
|
||||||
private linksDataSource: LinksDataSource,
|
private linksDataSource: LinksDataSource,
|
||||||
@ -62,5 +66,14 @@ export class ProjectWebServiceHandler {
|
|||||||
this.drawingsDataSource.remove(message.event as Drawing);
|
this.drawingsDataSource.remove(message.event as Drawing);
|
||||||
this.drawingNotificationEmitter.emit(message);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user