From 8ad744213be25f3c62749f3bbaceb6e4c007aed1 Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Thu, 22 Aug 2019 00:32:28 -0700 Subject: [PATCH] Review fixes --- src/app/components/project-map/project-map.component.ts | 7 +++++-- .../import-project-dialog.component.ts | 2 +- src/app/services/project.service.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index 766e7c50..409a612b 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -475,10 +475,13 @@ export class ProjectMapComponent implements OnInit, OnDestroy { exportProject() { if (this.nodes.filter(node => node.node_type === 'virtualbox').length > 0) { this.toasterService.error('Map with VirtualBox machines cannot be exported.') - } else if (this.nodes.filter(node => node.status === 'started').length > 0) { + } else if (this.nodes.filter(node => + (node.status === 'started' && node.node_type==='vpcs') || + (node.status === 'started' && node.node_type==='virtualbox') || + (node.status === 'started' && node.node_type==='vmware')).length > 0) { this.toasterService.error('Project with running nodes cannot be exported.') } else { - window.location.href = `http://${this.server.host}:${this.server.port}/v2/projects/${this.project.project_id}/export`; + location.assign(this.projectService.getExportPath(this.server, this.project)); } } diff --git a/src/app/components/projects/import-project-dialog/import-project-dialog.component.ts b/src/app/components/projects/import-project-dialog/import-project-dialog.component.ts index bcb54385..1c1e8195 100644 --- a/src/app/components/projects/import-project-dialog/import-project-dialog.component.ts +++ b/src/app/components/projects/import-project-dialog/import-project-dialog.component.ts @@ -143,6 +143,6 @@ export class ImportProjectDialogComponent implements OnInit { prepareUploadPath(): string { this.uuid = uuid(); const projectName = this.projectNameForm.controls['projectName'].value; - return `http://${this.server.host}:${this.server.port}/v2/projects/${this.uuid}/import?name=${projectName}`; + return this.projectService.getUploadPath(this.server, uuid, projectName); } } diff --git a/src/app/services/project.service.ts b/src/app/services/project.service.ts index 4eee73a7..193722d6 100644 --- a/src/app/services/project.service.ts +++ b/src/app/services/project.service.ts @@ -49,6 +49,14 @@ export class ProjectService { return this.httpServer.delete(server, `/projects/${project_id}`); } + getUploadPath(server: Server, uuid: string, project_name: string) { + return `http://${server.host}:${server.port}/v2/projects/${uuid}/import?name=${project_name}`; + } + + getExportPath(server: Server, project: Project) { + return `http://${server.host}:${server.port}/v2/projects/${project.project_id}/export`; + } + export(server: Server, project_id: string): Observable { return this.httpServer.get(server, `/projects/${project_id}/export`) }