mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-21 07:58:25 +00:00
Merge pull request #597 from GNS3/Some-issues-with-projects-that-don't-exist
Some issues with projects that don't exist
This commit is contained in:
@ -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 { 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 { AlignVerticallyActionComponent } from './components/project-map/context-menu/actions/align_vertically/align-vertically.component';
|
||||||
import { ConfirmationBottomSheetComponent } from './components/projects/confirmation-bottomsheet/confirmation-bottomsheet.component';
|
import { ConfirmationBottomSheetComponent } from './components/projects/confirmation-bottomsheet/confirmation-bottomsheet.component';
|
||||||
|
import { NotificationService } from './services/notification.service';
|
||||||
import { DeviceDetectorModule } from 'ngx-device-detector';
|
import { DeviceDetectorModule } from 'ngx-device-detector';
|
||||||
import { ConfigDialogComponent } from './components/project-map/context-menu/dialogs/config-dialog/config-dialog.component';
|
import { ConfigDialogComponent } from './components/project-map/context-menu/dialogs/config-dialog/config-dialog.component';
|
||||||
|
|
||||||
@ -508,7 +509,8 @@ if (environment.production) {
|
|||||||
InfoService,
|
InfoService,
|
||||||
ComputeService,
|
ComputeService,
|
||||||
TracengService,
|
TracengService,
|
||||||
PacketCaptureService
|
PacketCaptureService,
|
||||||
|
NotificationService
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
AddServerDialogComponent,
|
AddServerDialogComponent,
|
||||||
|
@ -56,6 +56,7 @@ import { MockedActivatedRoute } from '../snapshots/list-of-snapshots/list-of-sna
|
|||||||
import { MapNodesDataSource, MapLinksDataSource, MapDrawingsDataSource, MapSymbolsDataSource } from '../../cartography/datasources/map-datasource';
|
import { MapNodesDataSource, MapLinksDataSource, MapDrawingsDataSource, MapSymbolsDataSource } from '../../cartography/datasources/map-datasource';
|
||||||
import { EthernetLinkWidget } from '../../cartography/widgets/links/ethernet-link';
|
import { EthernetLinkWidget } from '../../cartography/widgets/links/ethernet-link';
|
||||||
import { SerialLinkWidget } from '../../cartography/widgets/links/serial-link';
|
import { SerialLinkWidget } from '../../cartography/widgets/links/serial-link';
|
||||||
|
import { NotificationService } from '../../services/notification.service';
|
||||||
|
|
||||||
export class MockedProgressService {
|
export class MockedProgressService {
|
||||||
public activate() {}
|
public activate() {}
|
||||||
@ -298,7 +299,8 @@ describe('ProjectMapComponent', () => {
|
|||||||
{ provide: MapLinksDataSource, useClass: LinksDataSource },
|
{ provide: MapLinksDataSource, useClass: LinksDataSource },
|
||||||
{ provide: MapDrawingsDataSource, useClass: MapDrawingsDataSource },
|
{ provide: MapDrawingsDataSource, useClass: MapDrawingsDataSource },
|
||||||
{ provide: MapSymbolsDataSource, useClass: MapSymbolsDataSource },
|
{ provide: MapSymbolsDataSource, useClass: MapSymbolsDataSource },
|
||||||
{ provide: MapSettingsService, useClass: MapSettingsService }
|
{ provide: MapSettingsService, useClass: MapSettingsService },
|
||||||
|
{ provide: NotificationService }
|
||||||
],
|
],
|
||||||
declarations: [ProjectMapComponent, ProjectMapMenuComponent, D3MapComponent, ...ANGULAR_MAP_DECLARATIONS],
|
declarations: [ProjectMapComponent, ProjectMapMenuComponent, D3MapComponent, ...ANGULAR_MAP_DECLARATIONS],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
@ -63,6 +63,7 @@ import { EthernetLinkWidget } from '../../cartography/widgets/links/ethernet-lin
|
|||||||
import { SerialLinkWidget } from '../../cartography/widgets/links/serial-link';
|
import { SerialLinkWidget } from '../../cartography/widgets/links/serial-link';
|
||||||
import { NavigationDialogComponent } from '../projects/navigation-dialog/navigation-dialog.component';
|
import { NavigationDialogComponent } from '../projects/navigation-dialog/navigation-dialog.component';
|
||||||
import { ConfirmationBottomSheetComponent } from '../projects/confirmation-bottomsheet/confirmation-bottomsheet.component';
|
import { ConfirmationBottomSheetComponent } from '../projects/confirmation-bottomsheet/confirmation-bottomsheet.component';
|
||||||
|
import { NotificationService } from '../../services/notification.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -78,6 +79,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
public symbols: Symbol[] = [];
|
public symbols: Symbol[] = [];
|
||||||
public project: Project;
|
public project: Project;
|
||||||
public server: Server;
|
public server: Server;
|
||||||
|
public projectws: WebSocket;
|
||||||
public ws: WebSocket;
|
public ws: WebSocket;
|
||||||
public isProjectMapMenuVisible: boolean = false;
|
public isProjectMapMenuVisible: boolean = false;
|
||||||
public isConsoleVisible: boolean = true;
|
public isConsoleVisible: boolean = true;
|
||||||
@ -146,7 +148,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
private mapSettingsService: MapSettingsService,
|
private mapSettingsService: MapSettingsService,
|
||||||
private ethernetLinkWidget: EthernetLinkWidget,
|
private ethernetLinkWidget: EthernetLinkWidget,
|
||||||
private serialLinkWidget: SerialLinkWidget,
|
private serialLinkWidget: SerialLinkWidget,
|
||||||
private bottomSheet: MatBottomSheet
|
private bottomSheet: MatBottomSheet,
|
||||||
|
private notificationService: NotificationService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -311,25 +314,29 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.drawingsDataSource.set(drawings);
|
this.drawingsDataSource.set(drawings);
|
||||||
|
|
||||||
this.setUpMapCallbacks();
|
this.setUpMapCallbacks();
|
||||||
this.setUpWS(project);
|
this.setUpProjectWS(project);
|
||||||
|
|
||||||
this.progressService.deactivate();
|
this.progressService.deactivate();
|
||||||
});
|
});
|
||||||
this.subscriptions.push(subscription);
|
this.subscriptions.push(subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
setUpWS(project: Project) {
|
setUpProjectWS(project: Project) {
|
||||||
this.ws = new WebSocket(this.projectService.notificationsPath(this.server, project.project_id));
|
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.projectWebServiceHandler.handleMessage(JSON.parse(event.data));
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ws.onerror = (event: MessageEvent) => {
|
this.projectws.onerror = (event: MessageEvent) => {
|
||||||
this.toasterService.error('Connection to host lost.');
|
this.toasterService.error('Connection to host lost.');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setUpWS() {
|
||||||
|
this.ws = new WebSocket(this.notificationService.notificationsPath(this.server));
|
||||||
|
}
|
||||||
|
|
||||||
setUpMapCallbacks() {
|
setUpMapCallbacks() {
|
||||||
if (!this.readonly) {
|
if (!this.readonly) {
|
||||||
this.toolsService.selectionToolActivation(true);
|
this.toolsService.selectionToolActivation(true);
|
||||||
@ -802,8 +809,11 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.nodesDataSource.clear();
|
this.nodesDataSource.clear();
|
||||||
this.linksDataSource.clear();
|
this.linksDataSource.clear();
|
||||||
|
|
||||||
if (this.ws.OPEN) {
|
if (this.projectws) {
|
||||||
this.ws.close();
|
if (this.projectws.OPEN) this.projectws.close();
|
||||||
|
}
|
||||||
|
if (this.ws) {
|
||||||
|
if (this.ws.OPEN) this.ws.close();
|
||||||
}
|
}
|
||||||
this.subscriptions.forEach((subscription: Subscription) => subscription.unsubscribe());
|
this.subscriptions.forEach((subscription: Subscription) => subscription.unsubscribe());
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import { ProjectsFilter } from '../../filters/projectsFilter.pipe';
|
|||||||
import { ChooseNameDialogComponent } from './choose-name-dialog/choose-name-dialog.component';
|
import { ChooseNameDialogComponent } from './choose-name-dialog/choose-name-dialog.component';
|
||||||
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
||||||
import { OverlayRef } from '@angular/cdk/overlay';
|
import { OverlayRef } from '@angular/cdk/overlay';
|
||||||
|
import { ToasterService } from '../../services/toaster.service';
|
||||||
|
|
||||||
describe('ProjectsComponent', () => {
|
describe('ProjectsComponent', () => {
|
||||||
let component: ProjectsComponent;
|
let component: ProjectsComponent;
|
||||||
@ -53,6 +54,7 @@ describe('ProjectsComponent', () => {
|
|||||||
{ provide: ServerService, useClass: MockedServerService },
|
{ provide: ServerService, useClass: MockedServerService },
|
||||||
{ provide: ProjectService, useValue: mockedProjectService },
|
{ provide: ProjectService, useValue: mockedProjectService },
|
||||||
{ provide: SettingsService, useClass: MockedSettingsService },
|
{ provide: SettingsService, useClass: MockedSettingsService },
|
||||||
|
{ provide: ToasterService },
|
||||||
ProgressService
|
ProgressService
|
||||||
],
|
],
|
||||||
declarations: [ProjectsComponent, ChooseNameDialogComponent, ProjectsFilter],
|
declarations: [ProjectsComponent, ChooseNameDialogComponent, ProjectsFilter],
|
||||||
|
@ -19,6 +19,7 @@ import { AddBlankProjectDialogComponent } from './add-blank-project-dialog/add-b
|
|||||||
import { ChooseNameDialogComponent } from './choose-name-dialog/choose-name-dialog.component';
|
import { ChooseNameDialogComponent } from './choose-name-dialog/choose-name-dialog.component';
|
||||||
import { NavigationDialogComponent } from './navigation-dialog/navigation-dialog.component';
|
import { NavigationDialogComponent } from './navigation-dialog/navigation-dialog.component';
|
||||||
import { ConfirmationBottomSheetComponent } from './confirmation-bottomsheet/confirmation-bottomsheet.component';
|
import { ConfirmationBottomSheetComponent } from './confirmation-bottomsheet/confirmation-bottomsheet.component';
|
||||||
|
import { ToasterService } from '../../services/toaster.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-projects',
|
selector: 'app-projects',
|
||||||
@ -44,7 +45,8 @@ export class ProjectsComponent implements OnInit {
|
|||||||
private progressService: ProgressService,
|
private progressService: ProgressService,
|
||||||
public dialog: MatDialog,
|
public dialog: MatDialog,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private bottomSheet: MatBottomSheet
|
private bottomSheet: MatBottomSheet,
|
||||||
|
private toasterService: ToasterService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -100,7 +102,11 @@ export class ProjectsComponent implements OnInit {
|
|||||||
() => {
|
() => {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
() => {},
|
() => {
|
||||||
|
this.refresh();
|
||||||
|
this.progressService.deactivate();
|
||||||
|
this.toasterService.error('Project was deleted.');
|
||||||
|
},
|
||||||
() => {
|
() => {
|
||||||
this.progressService.deactivate();
|
this.progressService.deactivate();
|
||||||
}
|
}
|
||||||
|
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`;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user