From 861ada1aa7630f56eca096e68842644aabd43f5e Mon Sep 17 00:00:00 2001 From: Dragos Date: Sun, 30 May 2021 18:34:04 +0300 Subject: [PATCH] TRIX-20 fixed tags and metadata on machine creation --- .../instance-wizard.component.ts | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/app/src/app/instances/instance-wizard/instance-wizard.component.ts b/app/src/app/instances/instance-wizard/instance-wizard.component.ts index 6b95e08..0889be8 100644 --- a/app/src/app/instances/instance-wizard/instance-wizard.component.ts +++ b/app/src/app/instances/instance-wizard/instance-wizard.component.ts @@ -347,23 +347,19 @@ export class InstanceWizardComponent implements OnInit, OnDestroy const changes = this.editorForm.getRawValue(); - const instance = new Instance(); + const instance: any = {}; instance.name = changes.name; instance.image = changes.image.id; instance.package = changes.package.id; //instance.brand = changes.package.brand; instance.networks = changes.networks.filter(x => x.selected).map(x => x.id); instance.firewall_enabled = !!changes.cloudFirewall; - instance.tags = changes.tags.reduce((a, b) => - { - a[`tag.${b.key}`] = b.value; - return a; - }, {}); - instance.metadata = changes.metadata.reduce((a, b) => - { - a[`metadata.${b.key}`] = b.value; - return a; - }, {}); + + for (const tag of changes.tags) + instance[`tag.${tag.key}`] = tag.value; + + for (const metadata of changes.metadata) + instance[`metadata.${metadata.key}`] = metadata.value; if (!this.kvmRequired) instance.volumes = changes.volumes @@ -376,8 +372,6 @@ export class InstanceWizardComponent implements OnInit, OnDestroy mountpoint: volume.mountpoint })); - console.log(changes, instance); - this.instancesService.add(instance) .subscribe(x => {