fixed tags and metadata on machine creation
This commit is contained in:
Dragos 2021-05-30 18:34:04 +03:00
parent 068c31a93d
commit 861ada1aa7

View File

@ -347,23 +347,19 @@ export class InstanceWizardComponent implements OnInit, OnDestroy
const changes = this.editorForm.getRawValue(); const changes = this.editorForm.getRawValue();
const instance = new Instance(); const instance: any = {};
instance.name = changes.name; instance.name = changes.name;
instance.image = changes.image.id; instance.image = changes.image.id;
instance.package = changes.package.id; instance.package = changes.package.id;
//instance.brand = changes.package.brand; //instance.brand = changes.package.brand;
instance.networks = changes.networks.filter(x => x.selected).map(x => x.id); instance.networks = changes.networks.filter(x => x.selected).map(x => x.id);
instance.firewall_enabled = !!changes.cloudFirewall; instance.firewall_enabled = !!changes.cloudFirewall;
instance.tags = changes.tags.reduce((a, b) =>
{ for (const tag of changes.tags)
a[`tag.${b.key}`] = b.value; instance[`tag.${tag.key}`] = tag.value;
return a;
}, {}); for (const metadata of changes.metadata)
instance.metadata = changes.metadata.reduce((a, b) => instance[`metadata.${metadata.key}`] = metadata.value;
{
a[`metadata.${b.key}`] = b.value;
return a;
}, {});
if (!this.kvmRequired) if (!this.kvmRequired)
instance.volumes = changes.volumes instance.volumes = changes.volumes
@ -376,8 +372,6 @@ export class InstanceWizardComponent implements OnInit, OnDestroy
mountpoint: volume.mountpoint mountpoint: volume.mountpoint
})); }));
console.log(changes, instance);
this.instancesService.add(instance) this.instancesService.add(instance)
.subscribe(x => .subscribe(x =>
{ {