mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-19 03:06:31 +00:00
Fix for navigation issue
This commit is contained in:
parent
a0cace9b62
commit
1ff8f00397
@ -249,6 +249,7 @@ import { PageNotFoundComponent } from './components/page-not-found/page-not-foun
|
||||
import { AlignHorizontallyActionComponent } from './components/project-map/context-menu/actions/align-horizontally/align-horizontally.component';
|
||||
import { AlignVerticallyActionComponent } from './components/project-map/context-menu/actions/align_vertically/align-vertically.component';
|
||||
import { ConfirmationBottomSheetComponent } from './components/projects/confirmation-bottomsheet/confirmation-bottomsheet.component';
|
||||
import { NotificationService } from './services/notification.service';
|
||||
|
||||
if (environment.production) {
|
||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||
@ -504,7 +505,8 @@ if (environment.production) {
|
||||
InfoService,
|
||||
ComputeService,
|
||||
TracengService,
|
||||
PacketCaptureService
|
||||
PacketCaptureService,
|
||||
NotificationService
|
||||
],
|
||||
entryComponents: [
|
||||
AddServerDialogComponent,
|
||||
|
@ -63,6 +63,7 @@ import { EthernetLinkWidget } from '../../cartography/widgets/links/ethernet-lin
|
||||
import { SerialLinkWidget } from '../../cartography/widgets/links/serial-link';
|
||||
import { NavigationDialogComponent } from '../projects/navigation-dialog/navigation-dialog.component';
|
||||
import { ConfirmationBottomSheetComponent } from '../projects/confirmation-bottomsheet/confirmation-bottomsheet.component';
|
||||
import { NotificationService } from '../../services/notification.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -78,6 +79,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
public symbols: Symbol[] = [];
|
||||
public project: Project;
|
||||
public server: Server;
|
||||
public projectws: WebSocket;
|
||||
public ws: WebSocket;
|
||||
public isProjectMapMenuVisible: boolean = false;
|
||||
public isConsoleVisible: boolean = true;
|
||||
@ -146,7 +148,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
private mapSettingsService: MapSettingsService,
|
||||
private ethernetLinkWidget: EthernetLinkWidget,
|
||||
private serialLinkWidget: SerialLinkWidget,
|
||||
private bottomSheet: MatBottomSheet
|
||||
private bottomSheet: MatBottomSheet,
|
||||
private notificationService: NotificationService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -162,6 +165,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
.pipe(
|
||||
mergeMap((server: Server) => {
|
||||
this.server = server;
|
||||
this.setUpWS();
|
||||
return this.projectService.get(server, paramMap.get('project_id')).pipe(
|
||||
map(project => {
|
||||
return project;
|
||||
@ -311,25 +315,29 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
this.drawingsDataSource.set(drawings);
|
||||
|
||||
this.setUpMapCallbacks();
|
||||
this.setUpWS(project);
|
||||
this.setUpProjectWS(project);
|
||||
|
||||
this.progressService.deactivate();
|
||||
});
|
||||
this.subscriptions.push(subscription);
|
||||
}
|
||||
|
||||
setUpWS(project: Project) {
|
||||
this.ws = new WebSocket(this.projectService.notificationsPath(this.server, project.project_id));
|
||||
setUpProjectWS(project: Project) {
|
||||
this.projectws = new WebSocket(this.projectService.notificationsPath(this.server, project.project_id));
|
||||
|
||||
this.ws.onmessage = (event: MessageEvent) => {
|
||||
this.projectws.onmessage = (event: MessageEvent) => {
|
||||
this.projectWebServiceHandler.handleMessage(JSON.parse(event.data));
|
||||
};
|
||||
|
||||
this.ws.onerror = (event: MessageEvent) => {
|
||||
this.projectws.onerror = (event: MessageEvent) => {
|
||||
this.toasterService.error('Connection to host lost.');
|
||||
};
|
||||
}
|
||||
|
||||
setUpWS() {
|
||||
this.ws = new WebSocket(this.notificationService.notificationsPath(this.server));
|
||||
}
|
||||
|
||||
setUpMapCallbacks() {
|
||||
if (!this.readonly) {
|
||||
this.toolsService.selectionToolActivation(true);
|
||||
@ -802,8 +810,11 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
this.nodesDataSource.clear();
|
||||
this.linksDataSource.clear();
|
||||
|
||||
if (this.ws.OPEN) {
|
||||
this.ws.close();
|
||||
if (this.projectws) {
|
||||
if (this.projectws.OPEN) this.projectws.close();
|
||||
}
|
||||
if (this.ws) {
|
||||
if (this.ws.OPEN) this.ws.close();
|
||||
}
|
||||
this.subscriptions.forEach((subscription: Subscription) => subscription.unsubscribe());
|
||||
}
|
||||
|
12
src/app/services/notification.service.ts
Normal file
12
src/app/services/notification.service.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpServer } from './http-server.service';
|
||||
import { Server } from '../models/server';
|
||||
|
||||
@Injectable()
|
||||
export class NotificationService {
|
||||
constructor(private httpServer: HttpServer) {}
|
||||
|
||||
notificationsPath(server: Server): string {
|
||||
return `ws://${server.host}:${server.port}/v2/notifications/ws`;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user