From e90445462334c5e69b5c11e2a434044e06828f3a Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Wed, 11 Sep 2019 04:58:45 -0700 Subject: [PATCH] Fix for virtualbox --- src/app/cartography/models/node.ts | 2 ++ .../custom-adapters-table.component.ts | 4 +--- .../configurator-virtualbox.component.html | 5 +++-- .../configurator-virtualbox.component.ts | 17 +++++++++++++++-- src/app/services/node.service.ts | 10 ++++++++++ 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/app/cartography/models/node.ts b/src/app/cartography/models/node.ts index c464e865..f7f15621 100644 --- a/src/app/cartography/models/node.ts +++ b/src/app/cartography/models/node.ts @@ -1,5 +1,6 @@ import { Label } from './label'; import { Port } from '../../models/port'; +import { CustomAdapter } from '../../models/qemu/qemu-custom-adapter'; export class PortsMapping { name: string; @@ -27,6 +28,7 @@ export class Node { console_auto_start: boolean; console_host: string; console_type: string; + custom_adapters?: CustomAdapter[]; first_port_name: string; height: number; label: Label; diff --git a/src/app/components/preferences/common/custom-adapters-table/custom-adapters-table.component.ts b/src/app/components/preferences/common/custom-adapters-table/custom-adapters-table.component.ts index 290262b2..f9ad5452 100644 --- a/src/app/components/preferences/common/custom-adapters-table/custom-adapters-table.component.ts +++ b/src/app/components/preferences/common/custom-adapters-table/custom-adapters-table.component.ts @@ -19,9 +19,7 @@ export class CustomAdaptersTableComponent { adapter_number: this.adapters.length, adapter_type: this.networkTypes[0] } - this.adapters.push(adapter); - console.log(this.adapters); - this.adapters = [adapter]; + this.adapters = this.adapters.concat([adapter]); } delete(adapter: CustomAdapter) { diff --git a/src/app/components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component.html b/src/app/components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component.html index a7b20b57..991be342 100644 --- a/src/app/components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component.html +++ b/src/app/components/project-map/node-editors/configurator/virtualbox/configurator-virtualbox.component.html @@ -6,7 +6,7 @@ -
+
@@ -36,10 +36,11 @@ - +
Allow GNS3 to use any configured VirtualBox adapter , public nodeService: NodeService, @@ -58,7 +61,17 @@ export class ConfiguratorDialogVirtualBoxComponent implements OnInit { onSaveClick() { if (this.generalSettingsForm.valid) { - this.nodeService.updateNode(this.server, this.node).subscribe(() => { + this.node.custom_adapters = []; + this.customAdapters.adapters.forEach(n => { + this.node.custom_adapters.push({ + adapter_number: n.adapter_number, + adapter_type: n.adapter_type + }) + }); + + this.node.properties.adapters = this.node.custom_adapters.length; + + this.nodeService.updateNodeWithCustomAdapters(this.server, this.node).subscribe(() => { this.toasterService.success(`Node ${this.node.name} updated.`); this.onCancelClick(); }); diff --git a/src/app/services/node.service.ts b/src/app/services/node.service.ts index c94bd3c5..d07c19d6 100644 --- a/src/app/services/node.service.ts +++ b/src/app/services/node.service.ts @@ -94,6 +94,16 @@ export class NodeService { }); } + updateNodeWithCustomAdapters(server: Server, node: Node): Observable { + return this.httpServer.put(server, `/projects/${node.project_id}/nodes/${node.node_id}`, { + console_type: node.console_type, + console_auto_start: node.console_auto_start, + custom_adapters: node.custom_adapters, + name: node.name, + properties: node.properties + }); + } + delete(server: Server, node: Node) { return this.httpServer.delete(server, `/projects/${node.project_id}/nodes/${node.node_id}`); }