mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-09 20:12:53 +00:00
Update project-map.component.ts
This commit is contained in:
parent
edb7aefba2
commit
0f4890fd10
@ -169,56 +169,16 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.mapSettingsService.logConsoleSubject.subscribe(value => this.isConsoleVisible = value);
|
this.mapSettingsService.logConsoleSubject.subscribe(value => this.isConsoleVisible = value);
|
||||||
|
|
||||||
this.progressService.activate();
|
this.progressService.activate();
|
||||||
const routeSub = this.route.paramMap.subscribe((paramMap: ParamMap) => {
|
|
||||||
const server_id = parseInt(paramMap.get('server_id'), 10);
|
|
||||||
|
|
||||||
from(this.serverService.get(server_id))
|
if (this.serverService.isServiceInitialized) {
|
||||||
.pipe(
|
this.getData();
|
||||||
mergeMap((server: Server) => {
|
} else {
|
||||||
this.server = server;
|
this.projectMapSubscription.add(
|
||||||
return this.projectService.get(server, paramMap.get('project_id')).pipe(
|
this.serverService.serviceInitialized.subscribe((val) => {
|
||||||
map(project => {
|
if (val) this.getData();
|
||||||
return project;
|
})
|
||||||
})
|
);
|
||||||
);
|
}
|
||||||
}),
|
|
||||||
mergeMap((project: Project) => {
|
|
||||||
this.project = project;
|
|
||||||
this.projectService.open(this.server, this.project.project_id);
|
|
||||||
this.title.setTitle(this.project.name);
|
|
||||||
|
|
||||||
if (this.mapSettingsService.interfaceLabels.has(project.project_id)) {
|
|
||||||
this.isInterfaceLabelVisible = this.mapSettingsService.interfaceLabels.get(project.project_id);
|
|
||||||
} else {
|
|
||||||
this.isInterfaceLabelVisible = this.project.show_interface_labels;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.recentlyOpenedProjectService.setServerId(this.server.id.toString());
|
|
||||||
this.recentlyOpenedProjectService.setProjectId(this.project.project_id);
|
|
||||||
|
|
||||||
if (this.project.status === 'opened') {
|
|
||||||
return new Observable<Project>(observer => {
|
|
||||||
observer.next(this.project);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return this.projectService.open(this.server, this.project.project_id);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.subscribe(
|
|
||||||
(project: Project) => {
|
|
||||||
this.onProjectLoad(project);
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
this.progressService.setError(error);
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.progressService.deactivate();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.projectMapSubscription.add(routeSub);
|
|
||||||
|
|
||||||
this.projectMapSubscription.add(
|
this.projectMapSubscription.add(
|
||||||
this.mapSettingsService.mapRenderedEmitter.subscribe((value: boolean) => {
|
this.mapSettingsService.mapRenderedEmitter.subscribe((value: boolean) => {
|
||||||
@ -272,6 +232,63 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.addKeyboardListeners();
|
this.addKeyboardListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getData() {
|
||||||
|
const routeSub = this.route.paramMap.subscribe((paramMap: ParamMap) => {
|
||||||
|
const server_id = parseInt(paramMap.get('server_id'), 10);
|
||||||
|
|
||||||
|
from(this.serverService.get(server_id))
|
||||||
|
.pipe(
|
||||||
|
mergeMap((server: Server) => {
|
||||||
|
if (!server ) this.router.navigate(['/servers']);
|
||||||
|
|
||||||
|
this.server = server;
|
||||||
|
return this.projectService.get(server, paramMap.get('project_id')).pipe(
|
||||||
|
map(project => {
|
||||||
|
return project;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
mergeMap((project: Project) => {
|
||||||
|
this.project = project;
|
||||||
|
if (!project ) this.router.navigate(['/servers']);
|
||||||
|
|
||||||
|
this.projectService.open(this.server, this.project.project_id);
|
||||||
|
this.title.setTitle(this.project.name);
|
||||||
|
|
||||||
|
if (this.mapSettingsService.interfaceLabels.has(project.project_id)) {
|
||||||
|
this.isInterfaceLabelVisible = this.mapSettingsService.interfaceLabels.get(project.project_id);
|
||||||
|
} else {
|
||||||
|
this.isInterfaceLabelVisible = this.project.show_interface_labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.recentlyOpenedProjectService.setServerId(this.server.id.toString());
|
||||||
|
this.recentlyOpenedProjectService.setProjectId(this.project.project_id);
|
||||||
|
|
||||||
|
if (this.project.status === 'opened') {
|
||||||
|
return new Observable<Project>(observer => {
|
||||||
|
observer.next(this.project);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return this.projectService.open(this.server, this.project.project_id);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe(
|
||||||
|
(project: Project) => {
|
||||||
|
this.onProjectLoad(project);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.progressService.setError(error);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.progressService.deactivate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.projectMapSubscription.add(routeSub);
|
||||||
|
}
|
||||||
|
|
||||||
addKeyboardListeners() {
|
addKeyboardListeners() {
|
||||||
Mousetrap.bind('ctrl++', (event: Event) => {
|
Mousetrap.bind('ctrl++', (event: Event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user