mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-15 06:52:49 +00:00
Support for different names
This commit is contained in:
parent
b6d74c58cb
commit
f225de7467
@ -407,13 +407,16 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
this.subscriptions.push(onInterfaceLabelContextMenu);
|
this.subscriptions.push(onInterfaceLabelContextMenu);
|
||||||
this.mapChangeDetectorRef.detectChanges();
|
this.mapChangeDetectorRef.detectChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
onNodeCreation(nodeAddedEvent: NodeAddedEvent) {
|
onNodeCreation(nodeAddedEvent: NodeAddedEvent) {
|
||||||
if(!nodeAddedEvent) {
|
if(!nodeAddedEvent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.nodeService.createFromTemplate(this.server, this.project, nodeAddedEvent.template, nodeAddedEvent.x, nodeAddedEvent.y, 'local').subscribe((node: Node) => {
|
||||||
this.nodeService.createFromTemplate(this.server, this.project, nodeAddedEvent.template, nodeAddedEvent.x, nodeAddedEvent.y, 'local').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[]) => {
|
this.projectService.nodes(this.server, this.project.project_id).subscribe((nodes: Node[]) => {
|
||||||
|
|
||||||
nodes.filter((node) => node.label.style === null).forEach((node) => {
|
nodes.filter((node) => node.label.style === null).forEach((node) => {
|
||||||
@ -422,6 +425,12 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.nodesDataSource.set(nodes);
|
this.nodesDataSource.set(nodes);
|
||||||
|
nodeAddedEvent.numberOfNodes--;
|
||||||
|
if (nodeAddedEvent.numberOfNodes > 0) {
|
||||||
|
nodeAddedEvent.x = nodeAddedEvent.x + 50 < this.project.scene_width/2 ? nodeAddedEvent.x + 50 : nodeAddedEvent.x;
|
||||||
|
nodeAddedEvent.y = nodeAddedEvent.y + 50 < this.project.scene_height/2 ? nodeAddedEvent.y + 50 : nodeAddedEvent.y;
|
||||||
|
this.onNodeCreation(nodeAddedEvent);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<form [formGroup]="configurationForm">
|
<form [formGroup]="configurationForm">
|
||||||
<mat-form-field class="form-field">
|
<mat-form-field class="form-field">
|
||||||
<input matInput formControlName="name" placeholder="Enter name (default is taken from template)" />
|
<input type="text" matInput formControlName="name" placeholder="Enter name (default is taken from template)" />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field class="form-field">
|
<mat-form-field class="form-field">
|
||||||
<input matInput formControlName="numberOfNodes" placeholder="Enter number of nodes (default value is 1)" />
|
<input type="number" matInput formControlName="numberOfNodes" placeholder="Enter number of nodes (default value is 1)" />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@ -53,11 +53,11 @@
|
|||||||
<form [formGroup]="positionForm">
|
<form [formGroup]="positionForm">
|
||||||
Left:
|
Left:
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput formControlName="left"/>
|
<input matInput type="number" formControlName="left"/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
Top:
|
Top:
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput formControlName="top"/>
|
<input matInput type="number" formControlName="top"/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,7 +70,7 @@ export class TemplateListDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAddClick(): void {
|
onAddClick(): void {
|
||||||
if (!this.selectedTemplate) {
|
if (!this.selectedTemplate || this.filteredTemplates.length === 0) {
|
||||||
this.toasterService.error('Please firstly choose template.');
|
this.toasterService.error('Please firstly choose template.');
|
||||||
} else if (!this.positionForm.valid || !this.configurationForm.valid) {
|
} else if (!this.positionForm.valid || !this.configurationForm.valid) {
|
||||||
this.toasterService.error('Please fill all required fields.');
|
this.toasterService.error('Please fill all required fields.');
|
||||||
|
@ -45,7 +45,7 @@ export class NodeService {
|
|||||||
return this.httpServer.post(server, `/projects/${project.project_id}/nodes/reload`, {});
|
return this.httpServer.post(server, `/projects/${project.project_id}/nodes/reload`, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
createFromTemplate(server: Server, project: Project, template: Template, x: number, y: number, compute_id: string) {
|
createFromTemplate(server: Server, project: Project, template: Template, x: number, y: number, compute_id: string): Observable<Node> {
|
||||||
return this.httpServer.post(server, `/projects/${project.project_id}/templates/${template.template_id}`, {
|
return this.httpServer.post(server, `/projects/${project.project_id}/templates/${template.template_id}`, {
|
||||||
x: Math.round(x),
|
x: Math.round(x),
|
||||||
y: Math.round(y),
|
y: Math.round(y),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user