From 03ffe4fade65c9dcb0af7b16b9a4fd4319934865 Mon Sep 17 00:00:00 2001 From: Yogi_Wang Date: Wed, 8 May 2019 16:25:10 +0800 Subject: [PATCH] Fix question of `Cancel` of OIDC configuration does not work Signed-off-by: Yogi_Wang --- .../app/config/auth/config-auth.component.ts | 24 +++---------------- .../src/app/config/config.component.html | 4 ++-- src/portal/src/app/config/config.component.ts | 4 +++- .../config/email/config-email.component.ts | 23 ++++-------------- 4 files changed, 12 insertions(+), 43 deletions(-) diff --git a/src/portal/src/app/config/auth/config-auth.component.ts b/src/portal/src/app/config/auth/config-auth.component.ts index 4dc279213..447913dda 100644 --- a/src/portal/src/app/config/auth/config-auth.component.ts +++ b/src/portal/src/app/config/auth/config-auth.component.ts @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import { Component, Input, ViewChild, SimpleChanges, OnChanges, OnInit } from '@angular/core'; +import { Component, Input, ViewChild, SimpleChanges, OnChanges, OnInit, Output, EventEmitter } from '@angular/core'; import { NgForm } from '@angular/forms'; import { Subscription } from "rxjs"; @@ -37,6 +37,7 @@ export class ConfigurationAuthComponent implements OnChanges, OnInit { @Input('allConfig') currentConfig: Configuration = new Configuration(); private originalConfig: Configuration; @ViewChild('authConfigFrom') authForm: NgForm; + @Output() refreshAllconfig = new EventEmitter(); constructor( private msgHandler: MessageHandlerService, @@ -202,7 +203,7 @@ export class ConfigurationAuthComponent implements OnChanges, OnInit { this.configService.saveConfiguration(changes) .subscribe(response => { this.onGoing = false; - this.retrieveConfig(); + this.refreshAllconfig.emit(); // Reload bootstrap option this.appConfigService.load().subscribe(() => { } , error => console.error('Failed to reload bootstrap option with error: ', error)); @@ -217,25 +218,6 @@ export class ConfigurationAuthComponent implements OnChanges, OnInit { } } - retrieveConfig(): void { - this.onGoing = true; - this.configService.getConfiguration() - .subscribe((configurations: Configuration) => { - this.onGoing = false; - - // Add two password fields - configurations.ldap_search_password = new StringValueItem(fakePass, true); - configurations.uaa_client_secret = new StringValueItem(fakePass, true); - configurations.oidc_client_secret = new StringValueItem(fakePass, true); - this.currentConfig = configurations; - // Keep the original copy of the data - this.originalConfig = clone(configurations); - }, error => { - this.onGoing = false; - this.msgHandler.handleError(error); - }); - } - /** * * Discard current changes if have and reset diff --git a/src/portal/src/app/config/config.component.html b/src/portal/src/app/config/config.component.html index ed0847ea1..1b89bb2b5 100644 --- a/src/portal/src/app/config/config.component.html +++ b/src/portal/src/app/config/config.component.html @@ -6,13 +6,13 @@ - + - + diff --git a/src/portal/src/app/config/config.component.ts b/src/portal/src/app/config/config.component.ts index cca18cf06..31e5c932f 100644 --- a/src/portal/src/app/config/config.component.ts +++ b/src/portal/src/app/config/config.component.ts @@ -80,7 +80,9 @@ export class ConfigurationComponent implements OnInit, OnDestroy { isCurrentTabContent(contentId: string): boolean { return TabLinkContentMap[this.currentTabId] === contentId; } - + refreshAllconfig() { + this.retrieveConfig(); + } ngOnInit(): void { // First load // Double confirm the current use has admin role diff --git a/src/portal/src/app/config/email/config-email.component.ts b/src/portal/src/app/config/email/config-email.component.ts index d92c74fd4..a5ccfaba7 100644 --- a/src/portal/src/app/config/email/config-email.component.ts +++ b/src/portal/src/app/config/email/config-email.component.ts @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import { Component, Input, ViewChild, SimpleChanges, OnChanges } from '@angular/core'; +import { Component, Input, ViewChild, SimpleChanges, OnChanges, Output, EventEmitter } from '@angular/core'; import { NgForm } from '@angular/forms'; import { Configuration, clone, isEmpty, getChanges, StringValueItem} from '@harbor/ui'; @@ -27,6 +27,7 @@ const fakePass = 'aWpLOSYkIzJTTU4wMDkx'; export class ConfigurationEmailComponent implements OnChanges { // tslint:disable-next-line:no-input-rename @Input("mailConfig") currentConfig: Configuration = new Configuration(); + @Output() refreshAllconfig = new EventEmitter(); private originalConfig: Configuration; testingMailOnGoing = false; onGoing = false; @@ -135,7 +136,8 @@ export class ConfigurationEmailComponent implements OnChanges { this.configService.saveConfiguration(changes) .subscribe(response => { this.onGoing = false; - this.retrieveConfig(); + // refresh allConfig + this.refreshAllconfig.emit(); this.msgHandler.showSuccess('CONFIG.SAVE_SUCCESS'); }, error => { this.onGoing = false; @@ -147,23 +149,6 @@ export class ConfigurationEmailComponent implements OnChanges { } } - retrieveConfig(): void { - this.onGoing = true; - this.configService.getConfiguration() - .subscribe((configurations: Configuration) => { - this.onGoing = false; - - // Add two password fields - configurations.email_password = new StringValueItem(fakePass, true); - this.currentConfig = configurations; - // Keep the original copy of the data - this.originalConfig = clone(configurations); - }, error => { - this.onGoing = false; - this.msgHandler.handleError(error); - }); - } - /** * * Discard current changes if have and reset