Fix question of Cancel of OIDC configuration does not work

Signed-off-by: Yogi_Wang <yawang@vmware.com>
This commit is contained in:
Yogi_Wang 2019-05-08 16:25:10 +08:00
parent 709406eb75
commit 03ffe4fade
4 changed files with 12 additions and 43 deletions

View File

@ -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<any>();
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

View File

@ -6,13 +6,13 @@
<clr-tab>
<button id="config-auth" clrTabLink>{{'CONFIG.AUTH' | translate}}</button>
<clr-tab-content id="authentication" *clrIfActive>
<config-auth [allConfig]="allConfig"></config-auth>
<config-auth [allConfig]="allConfig" (refreshAllconfig)="refreshAllconfig()"></config-auth>
</clr-tab-content>
</clr-tab>
<clr-tab>
<button id="config-email" clrTabLink>{{'CONFIG.EMAIL' | translate }}</button>
<clr-tab-content id="email" *clrIfActive>
<config-email [mailConfig]="allConfig"></config-email>
<config-email [mailConfig]="allConfig" (refreshAllconfig)="refreshAllconfig()"></config-email>
</clr-tab-content>
</clr-tab>
<clr-tab>

View File

@ -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

View File

@ -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<any>();
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