Review fixes

This commit is contained in:
Piotr Pekala 2019-08-22 00:32:28 -07:00
parent c2d5e6fd08
commit 8ad744213b
3 changed files with 14 additions and 3 deletions

View File

@ -475,10 +475,13 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
exportProject() { exportProject() {
if (this.nodes.filter(node => node.node_type === 'virtualbox').length > 0) { if (this.nodes.filter(node => node.node_type === 'virtualbox').length > 0) {
this.toasterService.error('Map with VirtualBox machines cannot be exported.') 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.') this.toasterService.error('Project with running nodes cannot be exported.')
} else { } 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));
} }
} }

View File

@ -143,6 +143,6 @@ export class ImportProjectDialogComponent implements OnInit {
prepareUploadPath(): string { prepareUploadPath(): string {
this.uuid = uuid(); this.uuid = uuid();
const projectName = this.projectNameForm.controls['projectName'].value; 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);
} }
} }

View File

@ -49,6 +49,14 @@ export class ProjectService {
return this.httpServer.delete(server, `/projects/${project_id}`); 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<any> { export(server: Server, project_id: string): Observable<any> {
return this.httpServer.get(server, `/projects/${project_id}/export`) return this.httpServer.get(server, `/projects/${project_id}/export`)
} }