From c73a8ddf1694f35c590a0522c562894b05fb4016 Mon Sep 17 00:00:00 2001 From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com> Date: Mon, 24 Feb 2020 15:19:28 +0100 Subject: [PATCH] Updating add node dialog --- .../components/project-map/project-map.component.ts | 8 ++++---- .../template-list-dialog.component.html | 4 ++-- .../template-list-dialog.component.ts | 10 +++++----- src/app/services/node.service.ts | 7 +++++++ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index 99bd4865..0759c990 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -424,10 +424,10 @@ export class ProjectMapComponent implements OnInit, OnDestroy { return; } this.nodeService.createFromTemplate(this.server, this.project, nodeAddedEvent.template, nodeAddedEvent.x, nodeAddedEvent.y, nodeAddedEvent.server).subscribe((node: Node) => { - if (nodeAddedEvent.name !== nodeAddedEvent.template.name) { - node.name = nodeAddedEvent.name; - this.nodeService.updateNode(this.server, node).subscribe(()=>{}); - } + // if (nodeAddedEvent.name !== nodeAddedEvent.template.name) { + // node.name = nodeAddedEvent.name; + // this.nodeService.updateNode(this.server, node).subscribe(()=>{}); + // } this.projectService.nodes(this.server, this.project.project_id).subscribe((nodes: Node[]) => { nodes.filter((node) => node.label.style === null).forEach((node) => { diff --git a/src/app/components/template/template-list-dialog/template-list-dialog.component.html b/src/app/components/template/template-list-dialog/template-list-dialog.component.html index aa5b5b31..70c5851d 100644 --- a/src/app/components/template/template-list-dialog/template-list-dialog.component.html +++ b/src/app/components/template/template-list-dialog/template-list-dialog.component.html @@ -39,9 +39,9 @@
Configuration
- + diff --git a/src/app/components/template/template-list-dialog/template-list-dialog.component.ts b/src/app/components/template/template-list-dialog/template-list-dialog.component.ts index 83ef1c4e..3642162b 100644 --- a/src/app/components/template/template-list-dialog/template-list-dialog.component.ts +++ b/src/app/components/template/template-list-dialog/template-list-dialog.component.ts @@ -41,7 +41,7 @@ export class TemplateListDialogComponent implements OnInit { this.server = data['server']; this.project = data['project']; this.configurationForm = this.formBuilder.group({ - name: new FormControl('new node', Validators.required), + // name: new FormControl('new node', Validators.required), numberOfNodes: new FormControl(1, [Validators.required, nonNegativeValidator.get]) }); this.positionForm = this.formBuilder.group({ @@ -70,13 +70,13 @@ export class TemplateListDialogComponent implements OnInit { chooseTemplate(event) { this.selectedTemplate = event.value; - this.configurationForm.controls['name'].setValue(this.selectedTemplate.default_name_format); + // this.configurationForm.controls['name'].setValue(this.selectedTemplate.default_name_format); } onAddClick(): void { if (!this.selectedTemplate || this.filteredTemplates.length === 0) { this.toasterService.error('Please firstly choose template.'); - } else if (!this.positionForm.valid || !this.configurationForm.valid) { + } else if (!this.positionForm.valid || !this.configurationForm.valid || !this.selectedTemplate.compute_id) { this.toasterService.error('Please fill all required fields.'); } else { let x: number = this.positionForm.get('left').value; @@ -87,7 +87,7 @@ export class TemplateListDialogComponent implements OnInit { let event: NodeAddedEvent = { template: this.selectedTemplate, server: this.selectedTemplate.compute_id, - name: this.configurationForm.get('name').value, + // name: this.configurationForm.get('name').value, numberOfNodes: this.configurationForm.get('numberOfNodes').value, x: x, y: y @@ -101,7 +101,7 @@ export class TemplateListDialogComponent implements OnInit { export interface NodeAddedEvent { template: Template, server: string, - name: string, + name?: string, numberOfNodes: number; x: number; y: number; diff --git a/src/app/services/node.service.ts b/src/app/services/node.service.ts index 2e8467ae..50914980 100644 --- a/src/app/services/node.service.ts +++ b/src/app/services/node.service.ts @@ -46,6 +46,13 @@ export class NodeService { } createFromTemplate(server: Server, project: Project, template: Template, x: number, y: number, compute_id: string): Observable { + if (!compute_id) { + return this.httpServer.post(server, `/projects/${project.project_id}/templates/${template.template_id}`, { + x: Math.round(x), + y: Math.round(y), + compute_id: 'local' + }); + } return this.httpServer.post(server, `/projects/${project.project_id}/templates/${template.template_id}`, { x: Math.round(x), y: Math.round(y),