From cc1eb1de86b96c0ecbac3d4154e07e87858f416b Mon Sep 17 00:00:00 2001 From: AllForNothing Date: Wed, 28 Oct 2020 14:16:23 +0800 Subject: [PATCH] Fix a bug for editing p2p instance Signed-off-by: AllForNothing --- .../distribution-setup-modal.component.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/portal/src/app/distribution/distribution-setup-modal/distribution-setup-modal.component.ts b/src/portal/src/app/distribution/distribution-setup-modal/distribution-setup-modal.component.ts index 7a9e74364..81004ccd0 100644 --- a/src/portal/src/app/distribution/distribution-setup-modal/distribution-setup-modal.component.ts +++ b/src/portal/src/app/distribution/distribution-setup-modal/distribution-setup-modal.component.ts @@ -208,10 +208,15 @@ export class DistributionSetupModalComponent implements OnInit, OnDestroy { instance.vendor = this.model.vendor; instance.name = this.model.name; instance.endpoint = this.model.endpoint; + instance.insecure = this.model.insecure; instance.enabled = this.model.enabled; - instance.description = this.model.description; instance.auth_mode = this.model.auth_mode; - instance.auth_info = this.model.auth_info; + instance.description = this.model.description; + if (instance.auth_mode !== AuthMode.NONE) { + instance.auth_info = this.authData; + } else { + delete instance.auth_info; + } this.distributionService.UpdateInstance({preheatInstanceName: this.model.name, instance: this.handleInstance(instance) }).subscribe( response => { @@ -247,6 +252,8 @@ export class DistributionSetupModalComponent implements OnInit, OnDestroy { } else { delete this.model.auth_info; } + // set insure property to true or false + this.model.insecure = !!this.model.insecure; this.distributionService.CreateInstance({instance: this.model}).subscribe( response => { this.translate.get('DISTRIBUTION.CREATE_SUCCESS').subscribe(msg => { @@ -278,6 +285,9 @@ export class DistributionSetupModalComponent implements OnInit, OnDestroy { if (editingMode) { this.model = clone(data); this.originModelForEdit = clone(data); + // set insure property to true or false + this.originModelForEdit.insecure = !!data.insecure; + this.model.insecure = !!data.insecure; this.authData = this.model.auth_info || {}; } else { this.reset();